📄 hong_sprite.cpp
字号:
sub edx,lx; //j-=lx
add edi,edx; //dtmp+=j
jmp jmp_0416;//****************************************************
jmp_if1:///////////////////////////////////////
mov ax,[esi + 2];
add esi,4;
add edx,eax;
add esi,eax; //
cmp edx,lx; //
jle loop_while1;
sub edx,lx;
sub esi,edx;
mov eax,edx;
xor edx,edx;
jmp jmp_0429; //4.29
exit_while1: //end while(*stmp != 0xffff)*/
exit_if1: //end if(lx)
loop_while2:
cmp word ptr[esi],0xffff;
jz exit_while2;
movzx eax,word ptr[esi];
add edi,eax; //dtmp+=*stmp
add dx,ax; //j+=*stmp
jmp_0416:
mov ax,[esi + 2];
add esi,4;
jmp_0429:
mov ecx,eax; //l=k=*stmp
mov l,eax;
add eax,edx;
cmp eax, rx;
jle exit_if0;
cmp edx, rx;
jg exit_if0;
mov ecx, rx;
sub ecx,edx;
exit_if0:
cmp edx, rx;
jg else_if;
add edx, l; //j+=l;
sub l,ecx; //l-k;
// shr ecx,2; //move DATA
// jnc Next2_1; //
// movsw; //
// Next2_1: //
/// rep movsd; //
//
shr ecx,2; //move DATA
jnc Next2_1; //
mov ax, word ptr [edi]
mov word ptr [edi-2], ax
add esi, 2
add edi, 2
Next2_1: //
cmp cx, 0
jz NextVoid_2;
NextVoid:
mov eax, [edi];
mov [edi-2], eax
add esi, 4
add edi, 4
loop NextVoid
NextVoid_2:
add esi,l;
jmp loop_while2;
else_if:
add esi,l;
ext_loop:
cmp word ptr[esi],0xffff;
jz ext;
mov ax,[esi+2];
add esi,4;
add esi,eax;
jmp ext_loop;
ext:
exit_while2:
mov eax, dDxSize;
add esi,2;
add dword ptr Dtmp,eax;
dec ebx; //for(i=0;i<by;i++)
jnz loop_for1; //
exit_for1:
pop es;
};
}
void PutCmprsImgVoidNOTCliping(int x, int y, int yl, LPVOID Stmp, LPVOID dest )
{
DWORD j;
LPVOID Dtmp = (LPVOID)( (char*)dest + y * dDxSize + (x * 2 ));
j = yl;
_asm{
push es;
push ds;
pop es;
mov edx,Dtmp;
mov esi,Stmp;
mov ebx,j;
xor eax,eax;
xor ecx,ecx;
loop_1:
or bx,bx; // if(SY==0)
jz exit_1;
mov edi,edx;
loop_2:
cmp word ptr[esi],0xffff;
jz exit_2;
xor eax,eax
mov ax,[esi];
add edi,eax; //0 skip
mov cx,[esi+2]; //load data num
add esi,4;
shr ecx,2; //move DATA
jnc Next2; //
mov ax, word ptr [edi]
mov word ptr [edi-2], ax
add esi, 2
add edi, 2
Next2: //
cmp cx, 0
jz loop_2;
NextVoid:
mov eax, [edi];
mov [edi-2], eax
add esi, 4
add edi, 4
loop NextVoid
// rep movsd; //
jmp loop_2;
exit_2:
add esi,2;
add edx,dDxSize;
dec bx;
jmp loop_1;
exit_1:
pop es;
};
}
void PutCompressedImageVoid(int x, int y, Spr *sp )
{
int lx, rx, ty, by , IsC=0;
if( sp == NULL ) return;
if( sp->img == NULL ) return;
int xl = sp->xl;
int yl = sp->yl;
if( xl == 0 ) return;
if( yl == 0 ) return;
x -= sp->ox;
y -= sp->oy;
if( x >= (SCREEN_WIDTH-2) ) return;
else if( x + xl < 0 ) return;
if( y >= SCREEN_HEIGHT ) return;
else if( y + yl < 0 ) return;
rx = xl;
lx = 0;
ty = 0;
by = yl;
if( x + xl >= (SCREEN_WIDTH-2) )
{
rx -= x + xl - (SCREEN_WIDTH-2);
IsC = 1;
}
if( x < 0 )
{
lx = 0 - x;
x = 0;
rx -= lx;
IsC = 1;
}
if( y + yl >= SCREEN_HEIGHT )
{
by -= y + yl - SCREEN_HEIGHT;
IsC = 1;
}
if( y < 0 )
{
ty = 0 - y;
y = 0;
by -= ty;
IsC = 1;
}
if( IsC )
PutCmprsImgVoidCliping( x, y, sp->img, g_DestBackBuf, lx, rx, ty, by);
else
PutCmprsImgVoidNOTCliping( x, y, sp->yl, sp->img, g_DestBackBuf );
}
void PutCompressImageApart( int x, int y, Spr *sp, int sx, int sy, int ex, int ey, int alpha )
{
int lx, rx, ty, by , IsC=0;
int xl = sp->xl;
int yl = sp->yl;
if( sp == NULL ) return;
if( sp->img == NULL ) return;
if( xl == 0 ) return;
if( yl == 0 ) return;
// x -= sp->ox;
// y -= sp->oy;
if( x >= ex ) return;
else if( x + xl < sx ) return;
if( y >= ey ) return;
else if( y + yl < sy ) return;
rx = xl;
lx = sx;
ty = sy;
by = yl;
if( x + xl >= ex )
{
rx -= x + xl - ex;
}
if( x < sx )
{
lx = sx - x;
x = sx;
rx -= lx;
}
if( y + yl >= ey )
{
by -= y + yl - ey;
}
if( y < sy )
{
ty = sy - y;
y = sy;
by -= ty;
}
if( alpha > 31 )
{
PutCmprsImgCliping( x, y, sp->img, g_DestBackBuf, lx, rx, ty, by);
}
else
{
if( _PixelInfo.BitMaskR == 0x7C00)
{
PutCmprsImgClipingBlend555(x, y, sp->img, g_DestBackBuf, lx, rx, ty, by, alpha);
}
else
{
PutCmprsImgClipingBlend565(x, y, sp->img, g_DestBackBuf, lx, rx, ty, by, alpha);
}
}
}
void PutCompressImageSubApart( int x, int y, Spr *sp, int sx, int sy, int ex, int ey, int alpha )
{
int lx, rx, ty, by , IsC=0;
int xl = sp->xl;
int yl = sp->yl;
if( sp == NULL ) return;
if( sp->img == NULL ) return;
if( xl == 0 ) return;
if( yl == 0 ) return;
// x -= sp->ox;
// y -= sp->oy;
if( x >= ex ) return;
else if( x + xl < sx ) return;
if( y >= ey ) return;
else if( y + yl < sy ) return;
rx = xl;
lx = sx;
ty = sy;
by = yl;
if( x + xl >= ex )
{
rx -= x + xl - ex;
}
if( x < sx )
{
lx = sx - x;
x = sx;
rx -= lx;
}
if( y + yl >= ey )
{
by -= y + yl - ey;
}
if( y < sy )
{
ty = sy - y;
y = sy;
by -= ty;
}
if( alpha > 31 )
{
PutCmprsImgCliping( x, y, sp->img, g_DestBackBuf, lx, rx, ty, by);
}
else
{
if( _PixelInfo.BitMaskR == 0x7C00)
{
PutCmprsImgClipingSub555( x, y, sp->img, g_DestBackBuf, lx, rx, ty, by, alpha);
// PutCmprsImgClipingBlend555(x, y, sp->img, g_DestBackBuf, lx, rx, ty, by, alpha);
}
else
{
PutCmprsImgClipingSub565( x, y, sp->img, g_DestBackBuf, lx, rx, ty, by, alpha);
// PutCmprsImgClipingBlend565(x, y, sp->img, g_DestBackBuf, lx, rx, ty, by, alpha);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Put Sprite FX ---------------
// Put Sprite FX ---------------
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
void PutCmprsImgClipingHBlend565(
int x, int y, LPVOID Stmp, LPVOID dest, int lx, int rx, int ty, int by)
{
int l, kkk = lx << 1;
LPVOID Dtmp = (LPVOID)((char *)dest + y * wDxSize + (x * 2 ));
rx <<= 1;
lx <<= 1;
_asm{
push es;
push ds;
pop es;
xor eax,eax;
xor ecx,ecx;
mov esi,Stmp;
mov cx,word ptr ty;
or cx,cx;
jz exit_1;
loop_1:
cmp word ptr[esi],0xffff;
jz exit_xxxx;
mov ax,[esi+2];
add esi,4;
add esi,eax;
jmp loop_1;
exit_xxxx:
inc esi;
inc esi;
loop loop_1;
exit_1:
}
_asm{
mov bx,word ptr by; //
loop_for1:
or bx,bx; //for(i=0;i<by;i++)
jz exit_for1; //
xor eax,eax;
xor edx,edx;
xor ecx,ecx;
mov edi,Dtmp;
mov ax,word ptr lx; //if(lx)
or ax,ax; //
jz exit_if1;
loop_while1:
cmp word ptr[esi],0xffff; //while(*stmp != 0xffff)
jz exit_while1; //
add dx,[esi];
add esi,2;
cmp dx,word ptr lx; //if(j>lx)
jle jmp_if1; //
sub dx,word ptr lx; //j-=lx
cmp dx,word ptr rx;
jg jmp_00001;
add edi,edx; //dtmp+=j
lodsw; //k=*stmp
add dx,ax; //j+=k
mov cx,ax; //
cmp dx,word ptr rx; //new
jle jmp_0000;
add cx,word ptr rx;
sub cx,dx;
jmp xxxxxxx1;
jmp_00001:
lodsw;
add esi,eax;
jmp ext_loop;
jmp_if1:///////////////////////////////////////
lodsw; //
add dx,ax; //
add esi,eax; //
cmp dx,word ptr lx; //
jle loop_while1;
sub dx,word ptr lx;
sub esi,edx;
mov cx,dx;
cmp dx,word ptr rx; //new
jle jmp_0000; //"
mov cx,word ptr rx; //"
xxxxxxx1:
jmp_0000: //"
//************ move data ***********
shr cx,1;//*********************************************************
or cx,cx;
jz exit_movedata1;
loop_TR1:
lodsw
and ax,1111011111011110b;
and word ptr [edi],1111011111011110b;
add ax,[edi];
shr ax,1;
mov [edi],ax;
add edi,2;
loop loop_TR1;
exit_movedata1:
cmp dx,word ptr rx; //new
jle exit_while1; //"
mov eax,edx; //"
sub ax,word ptr rx; //"
add esi,eax; //new
exit_while1: //end while(*stmp != 0xffff)*/
exit_if1: //end if(lx)
loop_while2:
cmp word ptr[esi],0xffff;
jz exit_while2;
lodsw;
add edi,eax; //dtmp+=*stmp
add dx,ax; //j+=*stmp
lodsw;
mov cx,ax; //l=k=*stmp
mov word ptr l,ax;
add ax,dx;
cmp ax,word ptr rx;
jle exit_if0;
cmp dx,word ptr rx;
jg exit_if0;
//mov ax,cx;
mov cx,word ptr rx;
sub cx,dx;
exit_if0:
cmp dx,word ptr rx;
jg else_if;
add dx,word ptr l; //j+=l;
sub word ptr l,cx; //l-k;
//************ move data ***********
shr cx,1;//*********************************************************
or cx,cx;
jz exit_movedata2;
loop_TR2:
lodsw
and ax,1111011111011110b;
and word ptr [edi],1111011111011110b;
add ax,[edi];
shr ax,1;
mov [edi],ax;
add edi,2;
loop loop_TR2;
exit_movedata2:
mov ax,word ptr l;
add esi,eax;
jmp loop_while2;
else_if:
mov ax,word ptr l;
add esi,eax;
ext_loop:
cmp word ptr[esi],0xffff;
jz ext;
add esi,2;
lodsw
add esi,eax;
jmp ext_loop;
ext:
exit_while2:
add esi,2;
mov ax, wDxSize;
add dword ptr Dtmp,eax;
dec bx;
jmp loop_for1;
exit_for1:
pop es;
};
}
void PutCmprsImgNOTClipingHBlend565(int x, int y, int yl, LPVOID Stmp, LPVOID dest)
{
DWORD j;
LPVOID Dtmp = (LPVOID)((char *)dest + y * dDxSize + (x * 2 ));
j = yl;
_asm{
push es;
push ds;
pop es;
mov edx,Dtmp;
mov esi,Stmp;
mov ebx,j;
xor eax,eax;
xor ecx,ecx;
or ebx,ebx; // if(SY==0)
jz exit_1;
loop_1:
mov edi,edx;
loop_2:
cmp word ptr[esi],0xffff;
jz exit_2;
mov ax,[esi];
add edi,eax; //0 skip
mov cx,[esi+2]; //load data num
add esi,4;
shr ecx,1;
loop_TR:
mov eax,[esi];
mov ebx,[edi];
shr eax,2;
and eax,0011000111000110b;
and ebx,1111011111011110b;
add eax,ebx;
shr eax,1;
mov [edi],ax;
add esi,2;
add edi,2;
loop loop_TR;
jmp loop_2;
exit_2:
add esi,2;
add edx,dDxSize;
dec j;
jnz loop_1;
exit_1:
pop es;
};
}
void PutCmprsImgClipingHBlend555(
int x, int y, LPVOID Stmp, LPVOID dest, int lx, int rx, int ty, int by)
{
int l, kkk = lx << 1;
LPVOID Dtmp = (LPVOID)((char *)dest + y * wDxSize + (x * 2 ));
rx <<= 1;
lx <<= 1;
_asm{
push es;
push ds;
pop es;
xor eax,eax;
xor ecx,ecx;
mov esi,Stmp;
mov cx,word ptr ty;
or cx,cx;
jz exit_1;
loop_1:
cmp word ptr[esi],0xffff;
jz exit_xxxx;
mov ax,[esi+2];
add esi,4;
add esi,eax;
jmp loop_1;
exit_xxxx:
inc esi;
inc esi;
loop loop_1;
exit_1:
}
_asm{
mov bx,word ptr by; //
loop_for1:
or bx,bx; //for(i=0;i<by;i++)
jz exit_for1; //
xor eax,eax;
xor edx,edx;
xor ecx,ecx;
mov edi,Dtmp;
mov ax,word ptr lx; //if(lx)
or ax,ax; //
jz exit_if1;
loop_while1:
cmp word ptr[esi],0xffff; //while(*stmp != 0xffff)
jz exit_while1; //
add dx,[esi];
add esi,2;
cmp dx,word ptr lx; //if(j>lx)
jle jmp_if1; //
sub dx,word ptr lx; //j-=lx
cmp dx,word ptr rx;
jg jmp_00001;
add edi,edx; //dtmp+=j
lodsw; //k=*stmp
add dx,ax; //j+=k
mov cx,ax; //
cmp dx,word ptr rx; //new
jle jmp_0000;
add cx,word ptr rx;
sub cx,dx;
jmp xxxxxxx1;
jmp_00001:
lodsw;
add esi,eax;
jmp ext_loop;
jmp_if1:///////////////////////////////////////
lodsw; //
add dx,ax; //
add esi,eax; //
cmp dx,word ptr lx; //
jle loop_while1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -