哪位高手帮忙把以下代码中的汇编部分翻译成delphi代码,谢谢 ( 积分: 100 )

  • 主题发起人 主题发起人 iamwgh
  • 开始时间 开始时间
I

iamwgh

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure DrawEffect (x, y, width, height: integer; ssuf: TDirectDrawSurface; eff: TColorEffect);
var
i, j, n, scount, srclen: integer;
sddsd: TDDSurfaceDesc;
sptr, peff: PByte;
//source: array[0..810] of byte;
source: array[0..SCREENWIDTH + 10] of byte;
begin
if Width > SCREENWIDTH then exit;
// if Width > 800 then exit;
if eff = ceNone then exit;
peff := nil;
case eff of
ceGrayScale: peff := @GrayScaleLevel;
ceBright: peff := @BrightColorLevel;
ceBlack: peff := @BlackColorLevel;
ceWhite: peff := @WhiteColorLevel;
ceRed: peff := @RedishColorLevel;
ceGreen: peff := @GreenColorLevel;
ceBlue: peff := @BlueColorLevel;
ceYellow: peff := @YellowColorLevel;
ceFuchsia: peff := @FuchsiaColorLevel;
//else exit;
end;
if peff = nil then begin
peff := nil;
exit;
end;
try
sddsd.dwSize := SizeOf(sddsd);
ssuf.Lock (TRect(nil^), sddsd);
srclen := width;
for i:=0 to height-1 do begin
sptr := PBYTE(integer(sddsd.lpSurface) + (y+i) * sddsd.lPitch + x);
asm
mov scount, 0 //scount:=0;
mov esi, sptr //esi := sptr;
lea edi, source //edi := @source;
@@CopySource:
mov ebx, scount //ebx := scount ;
cmp ebx, srclen
jae @@EndSourceCopy //if ebx >= srclen
{db $0F,$6F,$04,$1E /// }movq mm0, [esi+ebx]
{db $0F,$7F,$07 ///} movq [edi], mm0

mov ebx, 0
@@Loop8:
cmp ebx, 8
jz @@EndLoop8
movzx eax, [edi+ebx].byte
mov edx, peff
movzx eax, [edx+eax].byte //
mov [edi+ebx], al
inc ebx
jmp @@Loop8
@@EndLoop8:

mov ebx, scount
db $0F,$6F,$07 /// movq mm0, [edi]
db $0F,$7F,$04,$1E /// movq [esi+ebx], mm0

add edi, 8
add scount, 8
jmp @@CopySource
@@EndSourceCopy:
db $0F,$77 /// emms

end;
end;
finally
ssuf.UnLock();
end;
end;
 
mmx 代码,不可能翻译成 Delphi
 
把mmx 64位寄存器当作数组运算一下不行么,麻烦一点,只要写成delphi的就可以啊
 
其实就是利用mmx进行8字节一组的快速copy
 
后退
顶部