-
-
[求助]1汇编源码用RadAS集成开发环境 编译不了
-
发表于: 2011-3-17 19:35 2897
-
得到一源文件需要编译成obj文件 折腾了惨了 特向各位大大求教怎么编译 。源文件如下:
TITLE Sprite BLT
.486P
LARGESTACK
_TEXT SEGMENT DWORD PUBLIC USE32 'CODE'
ASSUME cs: _TEXT, ds: NOTHING, es: NOTHING
JUMPS
;-------------------------------------------------------
;
; TransCopyBMPBits
;
; Copy a block with transparency
;
; C++ prototype:
; extern "C"
; void pascal TransCopyBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src,
; int iTransClr
; )
;
;-------------------------------------------------------
PUBLIC C TransCopyBMPBits
TransCopyBMPBits PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD, \
bTranClr: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx, ecx
jz _TCBB_NoMore ; test for silly case
mov edx, dwHeight ; EDX is line counter
mov ah, BYTE PTR bTranClr ; AL has transparency color
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; DS:[EDI] point to dest
; ES is expected equal to DS
; 32 bit FLAT memory model only
sub dwScanD, ecx ; bias these
sub dwScanS, ecx
mov ebx, ecx ; save this for later
ALIGN 4
_TCBB_MoreLines:
mov ecx, ebx ; ECX is pixel counter
shr ecx, 2
jz SHORT _TCBB_CheckOdd
;
; The idea here is to not branch very often so we unroll the loop by four
; and try to not branch when a whole run of pixels is either transparent
; or not transparent.
;
; There are two loops. One loop is for a run of pixels equal to the
; transparent color, the other is for runs of pixels we need to store.
;
; When we detect a "bad" pixel we jump to the same position in the
; other loop.
;
; Here is the loop we will stay in as long as we encounter a "transparent"
; pixel in the source.
;
ALIGN 4
_TCBB_ToSkip:
mov al, ds:[esi]
cmp al, ah
jnz SHORT _TCBB_ToCopy0
_TCBB_ToSkip0:
mov al, ds:[esi+1]
cmp al, ah
jnz SHORT _TCBB_ToCopy1
_TCBB_ToSkip1:
mov al, ds:[esi+2]
cmp al, ah
jnz SHORT _TCBB_ToCopy2
_TCBB_ToSkip2:
mov al, ds:[esi+3]
cmp al, ah
jnz SHORT _TCBB_ToCopy3
_TCBB_ToSkip3:
add edi,4
add esi,4
dec ecx
jnz SHORT _TCBB_ToSkip
jmp SHORT _TCBB_CheckOdd
;
; Here is the loop we will stay in as long as
; we encounter a "non transparent" pixel in the source.
;
ALIGN 4
_TCBB_ToCopy:
mov al, ds:[esi]
cmp al, ah
jz SHORT _TCBB_ToSkip0
_TCBB_ToCopy0:
mov ds:[edi], al
mov al, ds:[esi+1]
cmp al, ah
jz SHORT _TCBB_ToSkip1
_TCBB_ToCopy1:
mov ds:[edi+1], al
mov al, ds:[esi+2]
cmp al, ah
jz SHORT _TCBB_ToSkip2
_TCBB_ToCopy2:
mov ds:[edi+2], al
mov al, ds:[esi+3]
cmp al, ah
jz SHORT _TCBB_ToSkip3
_TCBB_ToCopy3:
mov es:[edi+3],al
add edi,4
add esi,4
dec ecx
jnz SHORT _TCBB_ToCopy
jmp SHORT _TCBB_CheckOdd
;
; We are at the end of a scan, check for odd leftover pixels to do
; and go to the next scan.
;
ALIGN 4
_TCBB_CheckOdd:
mov ecx, ebx
and ecx, 11b
jnz SHORT _TCBB_CopyOdd
; move on to the start of the next line
_TCBB_NextScan:
add esi, dwScanS
add edi, dwScanD
dec edx ; line counter
jnz SHORT _TCBB_MoreLines
jmp SHORT _TCBB_NoMore
;
; If the width is not a multiple of 4 we will come here to clean up
; the last few pixels
;
_TCBB_CopyOdd:
inc ecx
_TCBB_OddLoop:
dec ecx
jz SHORT _TCBB_NextScan
mov al, ds:[esi]
inc esi
inc edi
cmp al, ah
je SHORT _TCBB_OddLoop
mov ds:[edi-1], al
jmp SHORT _TCBB_OddLoop
_TCBB_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-------------------------------------------------------
;
; SetColor
;
; Copy a block with transparency
;
; C++ prototype:
; extern "C"
; void pascal SetCopyBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src,
; int iTransClr,
; int iSetClr
; )
;
;-------------------------------------------------------
PUBLIC C SetColor
SetColor PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD, \
bTranClr: DWORD, \
bSetClr: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx, ecx
jz _SC_NoMore ; test for silly case
mov edx, dwHeight ; EDX is line counter
mov ah, BYTE PTR bTranClr ; AH has transparency color
mov bl, BYTE PTR bSetClr; BL has Set Color
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; DS:[EDI] point to dest
; ES is expected equal to DS
; 32 bit FLAT memory model only
sub dwScanD, ecx ; bias these
sub dwScanS, ecx
;mov ebx, ecx ; save this for later
ALIGN 4
_SC_MoreLines:
mov ecx, dwWidth ; ECX is pixel counter
shr ecx, 2
jz SHORT _SC_CheckOdd
;
; The idea here is to not branch very often so we unroll the loop by four
; and try to not branch when a whole run of pixels is either transparent
; or not transparent.
;
; There are two loops. One loop is for a run of pixels equal to the
; transparent color, the other is for runs of pixels we need to store.
;
; When we detect a "bad" pixel we jump to the same position in the
; other loop.
;
; Here is the loop we will stay in as long as we encounter a "transparent"
; pixel in the source.
;
ALIGN 4
_SC_ToSkip:
mov al, ds:[esi]
cmp al, ah
jnz SHORT _SC_ToCopy0
_SC_ToSkip0:
mov al, ds:[esi+1]
cmp al, ah
jnz SHORT _SC_ToCopy1
_SC_ToSkip1:
mov al, ds:[esi+2]
cmp al, ah
jnz SHORT _SC_ToCopy2
_SC_ToSkip2:
mov al, ds:[esi+3]
cmp al, ah
jnz SHORT _SC_ToCopy3
_SC_ToSkip3:
add edi,4
add esi,4
dec ecx
jnz SHORT _SC_ToSkip
jmp SHORT _SC_CheckOdd
;
; Here is the loop we will stay in as long as
; we encounter a "non transparent" pixel in the source.
;
ALIGN 4
_SC_ToCopy:
mov al, ds:[esi]
cmp al, ah
jz SHORT _SC_ToSkip0
_SC_ToCopy0:
mov ds:[edi], bl
mov al, ds:[esi+1]
cmp al, ah
jz SHORT _SC_ToSkip1
_SC_ToCopy1:
mov ds:[edi+1], bl
mov al, ds:[esi+2]
cmp al, ah
jz SHORT _SC_ToSkip2
_SC_ToCopy2:
mov ds:[edi+2], bl
mov al, ds:[esi+3]
cmp al, ah
jz SHORT _SC_ToSkip3
_SC_ToCopy3:
mov es:[edi+3], bl
add edi,4
add esi,4
dec ecx
jnz SHORT _SC_ToCopy
jmp SHORT _SC_CheckOdd
;
; We are at the end of a scan, check for odd leftover pixels to do
; and go to the next scan.
;
ALIGN 4
_SC_CheckOdd:
mov ecx, dwWidth
and ecx, 11b
jnz SHORT _SC_CopyOdd
; move on to the start of the next line
_SC_NextScan:
add esi, dwScanS
add edi, dwScanD
dec edx ; line counter
jnz SHORT _SC_MoreLines
jmp SHORT _SC_NoMore
;
; If the width is not a multiple of 4 we will come here to clean up
; the last few pixels
;
_SC_CopyOdd:
inc ecx
_SC_OddLoop:
dec ecx
jz SHORT _SC_NextScan
mov al, ds:[esi]
inc esi
inc edi
cmp al, ah
je SHORT _SC_OddLoop
mov ds:[edi-1], bl
jmp SHORT _SC_OddLoop
_SC_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; CopyBMPBits
;
; Copy a block without transparency
;
; C++ prototype:
; extern "C"
; void pascal CopyBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C CopyBMPBits
CopyBMPBits PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx,ecx
jz _CBB_NoMore ; test for silly case
mov edx, dwHeight ; test line counter
or edx, edx
jz _CBB_NoMore ; test for silly case
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
sub dwScanD, ecx ; bias these
sub dwScanS, ecx
mov ebx, ecx
shr ebx, 2
mov eax, ecx
and eax,11b
ALIGN 4
_CBB_Loop:
mov ecx, ebx
rep movsd
mov ecx,eax
rep movsb
add esi, dwScanS
add edi, dwScanD
dec edx ; line counter
jnz SHORT _CBB_Loop
_CBB_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; FastCopyBMP_32
;
; Copy a 32 * n block without transparency
;
; the idea here is to write a special routine
; to move 32*n blocks with few jump & compare
;
; C++ prototype:
; extern "C"
; void pascal CopyBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C FastCopyBMP_32
FastCopyBMP_32 PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ecx
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
ALIGN 4
mov ecx,dwHeight
_FCB_LOOP : ;move directly 32 bits
mov eax,[esi]
mov [edi],eax
mov eax,[esi+4]
mov [edi+4],eax
mov eax,[esi+8]
mov [edi+8],eax
mov eax,[esi+12]
mov [edi+12],eax
mov eax,[esi+16]
mov [edi+16],eax
mov eax,[esi+20]
mov [edi+20],eax
mov eax,[esi+24]
mov [edi+24],eax
mov eax,[esi+28]
mov [edi+28],eax
add esi,dwScanS
add edi,dwScanD
sub ecx,1
jne _FCB_LOOP
_FCB_NoMore:
pop ecx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; DecIndexBMPBits
;
; Dark destination bits with source
; It decrease a destination bit color index
; make the index indicate to a lower color
;
; C++ prototype:
; extern "C"
; void pascal DecIndexBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C DecIndexBMPBits
DecIndexBMPBits PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx,ecx
jz _DIBB_NoMore ; test for silly case
shr ecx,2
shl ecx,2 ;make it n*32 bits
mov edx, dwHeight ; test line counter
or edx, edx
jz _DIBB_NoMore ; test for silly case
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
mov eax, dwScanD
mov dwScanD, eax
sub dwScanD, ecx ; bias these
mov eax, dwScanS
mov dwScanS, eax
sub dwScanS, ecx
_DIBB_Loop:
mov ebx, ecx
shr ebx, 2
; mov eax, ecx
; and eax,11b
ALIGN 4
_DIBB_Line_Loop:
_DIBB_ToCopy0:
mov ah ,BYTE PTR [esi]
cmp ah,0
jz SHORT _DIBB_ToCopy1
mov al, BYTE PTR [edi]
mov ah,al
and al,00001111b
and ah,11110000b
sub al,11b
jnc SHORT _DIBB_DONE0
xor al,al
_DIBB_DONE0 :
or ah,al
mov [edi],ah
_DIBB_ToCopy1:
mov ah ,BYTE PTR [esi + 1]
cmp ah,0
jz SHORT _DIBB_ToCopy2
mov al, BYTE PTR [edi + 1]
mov ah,al
and al,00001111b
and ah,11110000b
sub al,11b
jnc SHORT _DIBB_DONE1
xor al,al
_DIBB_DONE1 :
or ah,al
mov [edi + 1],ah
_DIBB_ToCopy2:
mov ah ,BYTE PTR [esi + 2]
cmp ah,0
jz SHORT _DIBB_ToCopy3
mov al, BYTE PTR [edi + 2]
mov ah,al
and al,00001111b
and ah,11110000b
sub al,11b
jnc SHORT _DIBB_DONE2
xor al,al
_DIBB_DONE2 :
or ah,al
mov [edi + 2],ah
_DIBB_ToCopy3:
mov ah ,BYTE PTR [esi + 3]
cmp ah,0
jz SHORT _DIBB_NEXT_DWORD
mov al, BYTE PTR [edi + 3]
mov ah,al
and al,00001111b
and ah,11110000b
sub al,11b
jnc SHORT _DIBB_DONE3
xor al,al
_DIBB_DONE3 :
or ah,al
mov [edi + 3],ah
_DIBB_NEXT_DWORD :
add edi,4
add esi,4
dec ebx
jnz SHORT _DIBB_Line_Loop
add esi, dwScanS
add edi, dwScanD
dec edx ; line counter
jnz _DIBB_Loop
_DIBB_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; DecIndexBMPBitsEx
;
; Dark destination bits with source
; It decrease a destination bit color index
; make the index indicate to a lower color
; 1/4 size from source
;
; C++ prototype:
; extern "C"
; void pascal ShadowBMPBitsEx(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C DecIndexBMPBitsEx
DecIndexBMPBitsEx PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx,ecx
jz _DIBBE_NoMore ; test for silly case
shr ecx,2
shl ecx,2 ;make it n*32 bits
mov edx, dwHeight ; test line counter
or edx, edx
jz _DIBBE_NoMore ; test for silly case
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
;mov eax, dwScanD
;mov dwScanD, eax
;sub dwScanD, ecx ; bias these
;mov eax, dwScanS
;mov dwScanS, eax
;sub dwScanS, ecx
mov ebx, 3 ;factor for zoom
push ebx
_DIBBE_Loop:
mov esi, pSrc
mov edi, pDest
mov ebx, ecx
ALIGN 4
_DIBBE_Line_Loop:
mov ah ,BYTE PTR [esi]
cmp ah,0
jz SHORT _DIBBE_NEXT_BIT
mov al, BYTE PTR [edi]
mov ah,al
and al,00001111b
and ah,11110000b
sub al,11b
jnc SHORT _DIBBE_DONE0
xor al,al
_DIBBE_DONE0 :
or ah,al
mov [edi],ah
mov [edi + 1],ah
mov [edi + 2],ah
_DIBBE_NEXT_BIT :
add edi,3
add esi,4 ;next point
sub ebx,4
cmp ebx,0
jg SHORT _DIBBE_Line_Loop
mov eax, pSrc
add eax, dwScanS
pop ebx
dec ebx
jnz _DIBBE_JMP0
dec edx ; next line
mov ebx, 3
add eax, dwScanS ;next line
_DIBBE_JMP0 :
push ebx
mov pSrc, eax
mov eax, pDest
add eax, dwScanD ;next line
mov pDest,eax
dec edx ; line counter
cmp edx,0
jg _DIBBE_Loop
pop ebx
_DIBBE_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; IncIndexBMPBits
;
; Light destination bits with source
; It increase a destination bit color index
; make the index indicate to a higher color
;
; C++ prototype:
; extern "C"
; void pascal IncIndexBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C IncIndexBMPBits
IncIndexBMPBits PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx,ecx
jz _LBB_NoMore ; test for silly case
mov edx, dwHeight ; test line counter
or edx, edx
jz _LBB_NoMore ; test for silly case
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
mov eax, dwScanD
shr eax, 2
shl eax, 2
mov dwScanD, eax
sub dwScanD, ecx ; bias these
mov eax, dwScanS
shr eax, 2
shl eax, 2
mov dwScanS, eax
sub dwScanS, ecx
_LBB_Loop:
mov ebx, ecx
shr ebx, 2
mov eax, ecx
and eax,11b
ALIGN 4
_LBB_Line_Loop:
_LBB_ToCopy0:
mov al, BYTE PTR [edi]
mov ah,al
and al,1111b
not al
and al, 11b
add ah,al
mov [edi],ah
_LBB_ToCopy1:
mov al, BYTE PTR [edi + 1]
mov ah,al
and al,1111b
not al
and al, 11b
add ah,al
mov [edi + 1],ah
_LBB_ToCopy2:
mov al, BYTE PTR [edi + 2]
mov ah,al
and al,1111b
not al
and al, 11b
add ah,al
mov [edi + 2],ah
_LBB_ToCopy3:
mov al, BYTE PTR [edi + 3]
mov ah,al
and al,1111b
not al
and al, 11b
add ah,al
mov [edi + 3],ah
add edi,4
add esi,4
dec ebx
jnz SHORT _LBB_Line_Loop
add esi, dwScanS
add edi, dwScanD
dec edx ; line counter
jnz SHORT _LBB_Loop
_LBB_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; IncIndexBMPBitsEx
;
; Light destination bits with source
; It increase a destination bit color index
; make the index indicate to a lower color
; 1/4 size from source
;
; C++ prototype:
; extern "C"
; void pascal IncIndexBMPBitsEx(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C IncIndexBMPBitsEx
IncIndexBMPBitsEx PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx,ecx
jz _CBB_NoMore ; test for silly case
shr ecx,2
shl ecx,2 ;make it n*32 bits
mov edx, dwHeight ; test line counter
or edx, edx
jz _IBBEX_NoMore ; test for silly case
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
;mov eax, dwScanD
;mov dwScanD, eax
;sub dwScanD, ecx ; bias these
;mov eax, dwScanS
;mov dwScanS, eax
;sub dwScanS, ecx
mov ebx, 3 ;factor for zoom
push ebx
_IBBEX_Loop:
mov esi, pSrc
mov edi, pDest
mov ebx, ecx
ALIGN 4
_IBBEX_Line_Loop:
mov ah ,BYTE PTR [esi]
cmp ah,0
jz SHORT _IBBEX_NEXT_BIT
mov al, BYTE PTR [edi]
mov ah,al
and al,1111b
add al,11b
cmp al,1111b
jl SHORT _IBBEX_DONE0
mov al,1111b
_IBBEX_DONE0 :
or ah,al
mov [edi],ah
mov [edi + 1],ah
mov [edi + 2],ah
_IBBEX_NEXT_BIT :
add edi,3
add esi,4 ;next point
sub ebx,4
cmp ebx,0
jg SHORT _IBBEX_Line_Loop
mov eax, pSrc
add eax, dwScanS
pop ebx
dec ebx
jnz _IBB_JMP0
dec edx ; next line
mov ebx, 3
add eax, dwScanS ;next line
_IBB_JMP0 :
push ebx
mov pSrc, eax
mov eax, pDest
add eax, dwScanD ;next line
mov pDest,eax
dec edx ; line counter
cmp edx,0
jg _IBBEX_Loop
pop ebx
_IBBEX_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-------------------------------------------------------
;
; TransCopyRTBBits
;
; Copy a run-length sprite (RTB) with transparency
;
; C++ prototype:
; extern "C"
; void pascal TransCopyRTBBits(
; void* pDest,
; void* pSrcBase,
; void* pSrcIndex
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int cxClip
; )
;
;-------------------------------------------------------
PUBLIC C TransCopyRTBBits
TransCopyRTBBits PROC C NEAR \
pDest: DWORD, \
pSrcBase: DWORD, \
pSrcIndex: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwXClip: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
xor ecx, ecx
mov edx, pSrcIndex
mov edi, pDest
mov eax, dwWidth
sub dwScanD, eax
ALIGN 4
_TCRB_ScanLoop:
mov esi, [edx]
add esi, pSrcBase
mov eax, dwXClip
or eax, eax
jz SHORT _TCRB_BeginExpand
ALIGN 4
_TCRB_SkipXLoop:
mov cx, [esi]
lea esi, [esi+2]
sub eax, ecx
jbe SHORT _TCRB_SkipLast00
mov cx, [esi]
lea esi, [esi+2]
sub eax, ecx
jbe SHORT _TCRB_SkipLastFF
add esi, ecx
jmp SHORT _TCRB_SkipXLoop
_TCRB_SkipLast00:
mov ecx, eax
neg ecx
mov eax, dwWidth
jmp SHORT _TCRB_BeginExpand00
_TCRB_SkipLastFF:
add esi, ecx
add esi, eax
mov ecx, eax
neg ecx
mov eax, dwWidth
jmp SHORT _TCRB_BeginExpandFF
_TCRB_BeginExpand:
mov eax, dwWidth
ALIGN 4
_TCRB_ExpandLoop:
mov cx, [esi]
lea esi, [esi+2]
_TCRB_BeginExpand00:
sub eax, ecx
jbe SHORT _TCRB_ExpandLast00
add edi, ecx
mov cx, [esi]
lea esi, [esi+2]
_TCRB_BeginExpandFF:
sub eax, ecx
jbe SHORT _TCRB_ExpandLastFF
mov ebx, ecx
shr ecx, 2
rep movsd
mov ecx, ebx
and ecx, 3
rep movsb
jmp SHORT _TCRB_ExpandLoop
_TCRB_ExpandLast00:
add edi, ecx
add edi, eax
lea edx, [edx+4]
add edi, dwScanD
dec dwHeight
jnz SHORT _TCRB_ScanLoop
jmp SHORT _TCRB_End
_TCRB_ExpandLastFF:
add ecx, eax
mov ebx, ecx
shr ecx, 2
rep movsd
mov ecx, ebx
and ecx, 3
rep movsb
lea edx, [edx+4]
add edi, dwScanD
dec dwHeight
jnz _TCRB_ScanLoop
_TCRB_End:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-------------------------------------------------------
;
; TransCoverRTBBits
;
; Cover a run-length sprite (RTB) with a transparency glass
;
; C++ prototype:
; extern "C"
; void pascal TransCoverRTBBits(
; void* pDest,
; void* pSrcBase,
; void* pSrcIndex
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int cxClip
; BYTE* pSecondIndex
; )
;
;-------------------------------------------------------
PUBLIC C TransCoverRTBBits
TransCoverRTBBits PROC C NEAR \
pDest: DWORD, \
pSrcBase: DWORD, \
pSrcIndex: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwXClip: DWORD, \
pSecondIndex: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
xor ecx, ecx
mov edx, pSrcIndex
mov edi, pDest
mov eax, dwWidth
sub dwScanD, eax
ALIGN 4
_TCVRB_ScanLoop:
mov esi, [edx]
add esi, pSrcBase
mov eax, dwXClip
or eax, eax
jz SHORT _TCVRB_BeginExpand
ALIGN 4
_TCVRB_SkipXLoop:
mov cx, [esi]
lea esi, [esi+2]
sub eax, ecx
jbe SHORT _TCVRB_SkipLast00
mov cx, [esi]
lea esi, [esi+2]
sub eax, ecx
jbe SHORT _TCVRB_SkipLastFF
add esi, ecx
jmp SHORT _TCVRB_SkipXLoop
_TCVRB_SkipLast00:
mov ecx, eax
neg ecx
mov eax, dwWidth
jmp SHORT _TCVRB_BeginExpand00
_TCVRB_SkipLastFF:
add esi, ecx
add esi, eax
mov ecx, eax
neg ecx
mov eax, dwWidth
jmp SHORT _TCVRB_BeginExpandFF
_TCVRB_BeginExpand:
mov eax, dwWidth
ALIGN 4
_TCVRB_ExpandLoop:
mov cx, [esi]
lea esi, [esi+2]
_TCVRB_BeginExpand00:
sub eax, ecx
jbe SHORT _TCVRB_ExpandLast00
add edi, ecx
mov cx, [esi]
lea esi, [esi+2]
_TCVRB_BeginExpandFF:
sub eax, ecx
jbe SHORT _TCVRB_ExpandLastFF
; mov ebx, ecx
; shr ecx, 2
; rep movsd
; mov ecx, ebx
; and ecx, 3
; rep movsb
test ecx, ecx
jz SHORT _TCVRB_ExpandLoop
push edx
_TCVRB_MOVE0 :
mov edx,pSecondIndex
xor ebx, ebx
mov bl, [edi]
add edx, ebx
mov bl,[edx]
mov [edi],bl
inc esi
inc edi
dec ecx
jne SHORT _TCVRB_MOVE0
pop edx
jmp SHORT _TCVRB_ExpandLoop
_TCVRB_ExpandLast00:
add edi, ecx
add edi, eax
lea edx, [edx+4]
add edi, dwScanD
dec dwHeight
jnz _TCVRB_ScanLoop
jmp SHORT _TCVRB_End
_TCVRB_ExpandLastFF:
add ecx, eax
; mov ebx, ecx
; shr ecx, 2
; rep movsd
; mov ecx, ebx
; and ecx, 3
; rep movsb
test ecx, ecx
jz SHORT _TCVRB_ExpandLoop
push edx
_TCVRB_MOVE1 :
mov edx,pSecondIndex
xor ebx, ebx
mov bl, [edi]
add edx, ebx
mov bl,[edx]
mov [edi],bl
inc esi
inc edi
dec ecx
jne SHORT _TCVRB_MOVE1
pop edx
lea edx, [edx+4]
add edi, dwScanD
dec dwHeight
jnz _TCVRB_ScanLoop
_TCVRB_End:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
ENDS
END
TITLE Sprite BLT
.486P
LARGESTACK
_TEXT SEGMENT DWORD PUBLIC USE32 'CODE'
ASSUME cs: _TEXT, ds: NOTHING, es: NOTHING
JUMPS
;-------------------------------------------------------
;
; TransCopyBMPBits
;
; Copy a block with transparency
;
; C++ prototype:
; extern "C"
; void pascal TransCopyBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src,
; int iTransClr
; )
;
;-------------------------------------------------------
PUBLIC C TransCopyBMPBits
TransCopyBMPBits PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD, \
bTranClr: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx, ecx
jz _TCBB_NoMore ; test for silly case
mov edx, dwHeight ; EDX is line counter
mov ah, BYTE PTR bTranClr ; AL has transparency color
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; DS:[EDI] point to dest
; ES is expected equal to DS
; 32 bit FLAT memory model only
sub dwScanD, ecx ; bias these
sub dwScanS, ecx
mov ebx, ecx ; save this for later
ALIGN 4
_TCBB_MoreLines:
mov ecx, ebx ; ECX is pixel counter
shr ecx, 2
jz SHORT _TCBB_CheckOdd
;
; The idea here is to not branch very often so we unroll the loop by four
; and try to not branch when a whole run of pixels is either transparent
; or not transparent.
;
; There are two loops. One loop is for a run of pixels equal to the
; transparent color, the other is for runs of pixels we need to store.
;
; When we detect a "bad" pixel we jump to the same position in the
; other loop.
;
; Here is the loop we will stay in as long as we encounter a "transparent"
; pixel in the source.
;
ALIGN 4
_TCBB_ToSkip:
mov al, ds:[esi]
cmp al, ah
jnz SHORT _TCBB_ToCopy0
_TCBB_ToSkip0:
mov al, ds:[esi+1]
cmp al, ah
jnz SHORT _TCBB_ToCopy1
_TCBB_ToSkip1:
mov al, ds:[esi+2]
cmp al, ah
jnz SHORT _TCBB_ToCopy2
_TCBB_ToSkip2:
mov al, ds:[esi+3]
cmp al, ah
jnz SHORT _TCBB_ToCopy3
_TCBB_ToSkip3:
add edi,4
add esi,4
dec ecx
jnz SHORT _TCBB_ToSkip
jmp SHORT _TCBB_CheckOdd
;
; Here is the loop we will stay in as long as
; we encounter a "non transparent" pixel in the source.
;
ALIGN 4
_TCBB_ToCopy:
mov al, ds:[esi]
cmp al, ah
jz SHORT _TCBB_ToSkip0
_TCBB_ToCopy0:
mov ds:[edi], al
mov al, ds:[esi+1]
cmp al, ah
jz SHORT _TCBB_ToSkip1
_TCBB_ToCopy1:
mov ds:[edi+1], al
mov al, ds:[esi+2]
cmp al, ah
jz SHORT _TCBB_ToSkip2
_TCBB_ToCopy2:
mov ds:[edi+2], al
mov al, ds:[esi+3]
cmp al, ah
jz SHORT _TCBB_ToSkip3
_TCBB_ToCopy3:
mov es:[edi+3],al
add edi,4
add esi,4
dec ecx
jnz SHORT _TCBB_ToCopy
jmp SHORT _TCBB_CheckOdd
;
; We are at the end of a scan, check for odd leftover pixels to do
; and go to the next scan.
;
ALIGN 4
_TCBB_CheckOdd:
mov ecx, ebx
and ecx, 11b
jnz SHORT _TCBB_CopyOdd
; move on to the start of the next line
_TCBB_NextScan:
add esi, dwScanS
add edi, dwScanD
dec edx ; line counter
jnz SHORT _TCBB_MoreLines
jmp SHORT _TCBB_NoMore
;
; If the width is not a multiple of 4 we will come here to clean up
; the last few pixels
;
_TCBB_CopyOdd:
inc ecx
_TCBB_OddLoop:
dec ecx
jz SHORT _TCBB_NextScan
mov al, ds:[esi]
inc esi
inc edi
cmp al, ah
je SHORT _TCBB_OddLoop
mov ds:[edi-1], al
jmp SHORT _TCBB_OddLoop
_TCBB_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-------------------------------------------------------
;
; SetColor
;
; Copy a block with transparency
;
; C++ prototype:
; extern "C"
; void pascal SetCopyBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src,
; int iTransClr,
; int iSetClr
; )
;
;-------------------------------------------------------
PUBLIC C SetColor
SetColor PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD, \
bTranClr: DWORD, \
bSetClr: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx, ecx
jz _SC_NoMore ; test for silly case
mov edx, dwHeight ; EDX is line counter
mov ah, BYTE PTR bTranClr ; AH has transparency color
mov bl, BYTE PTR bSetClr; BL has Set Color
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; DS:[EDI] point to dest
; ES is expected equal to DS
; 32 bit FLAT memory model only
sub dwScanD, ecx ; bias these
sub dwScanS, ecx
;mov ebx, ecx ; save this for later
ALIGN 4
_SC_MoreLines:
mov ecx, dwWidth ; ECX is pixel counter
shr ecx, 2
jz SHORT _SC_CheckOdd
;
; The idea here is to not branch very often so we unroll the loop by four
; and try to not branch when a whole run of pixels is either transparent
; or not transparent.
;
; There are two loops. One loop is for a run of pixels equal to the
; transparent color, the other is for runs of pixels we need to store.
;
; When we detect a "bad" pixel we jump to the same position in the
; other loop.
;
; Here is the loop we will stay in as long as we encounter a "transparent"
; pixel in the source.
;
ALIGN 4
_SC_ToSkip:
mov al, ds:[esi]
cmp al, ah
jnz SHORT _SC_ToCopy0
_SC_ToSkip0:
mov al, ds:[esi+1]
cmp al, ah
jnz SHORT _SC_ToCopy1
_SC_ToSkip1:
mov al, ds:[esi+2]
cmp al, ah
jnz SHORT _SC_ToCopy2
_SC_ToSkip2:
mov al, ds:[esi+3]
cmp al, ah
jnz SHORT _SC_ToCopy3
_SC_ToSkip3:
add edi,4
add esi,4
dec ecx
jnz SHORT _SC_ToSkip
jmp SHORT _SC_CheckOdd
;
; Here is the loop we will stay in as long as
; we encounter a "non transparent" pixel in the source.
;
ALIGN 4
_SC_ToCopy:
mov al, ds:[esi]
cmp al, ah
jz SHORT _SC_ToSkip0
_SC_ToCopy0:
mov ds:[edi], bl
mov al, ds:[esi+1]
cmp al, ah
jz SHORT _SC_ToSkip1
_SC_ToCopy1:
mov ds:[edi+1], bl
mov al, ds:[esi+2]
cmp al, ah
jz SHORT _SC_ToSkip2
_SC_ToCopy2:
mov ds:[edi+2], bl
mov al, ds:[esi+3]
cmp al, ah
jz SHORT _SC_ToSkip3
_SC_ToCopy3:
mov es:[edi+3], bl
add edi,4
add esi,4
dec ecx
jnz SHORT _SC_ToCopy
jmp SHORT _SC_CheckOdd
;
; We are at the end of a scan, check for odd leftover pixels to do
; and go to the next scan.
;
ALIGN 4
_SC_CheckOdd:
mov ecx, dwWidth
and ecx, 11b
jnz SHORT _SC_CopyOdd
; move on to the start of the next line
_SC_NextScan:
add esi, dwScanS
add edi, dwScanD
dec edx ; line counter
jnz SHORT _SC_MoreLines
jmp SHORT _SC_NoMore
;
; If the width is not a multiple of 4 we will come here to clean up
; the last few pixels
;
_SC_CopyOdd:
inc ecx
_SC_OddLoop:
dec ecx
jz SHORT _SC_NextScan
mov al, ds:[esi]
inc esi
inc edi
cmp al, ah
je SHORT _SC_OddLoop
mov ds:[edi-1], bl
jmp SHORT _SC_OddLoop
_SC_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; CopyBMPBits
;
; Copy a block without transparency
;
; C++ prototype:
; extern "C"
; void pascal CopyBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C CopyBMPBits
CopyBMPBits PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx,ecx
jz _CBB_NoMore ; test for silly case
mov edx, dwHeight ; test line counter
or edx, edx
jz _CBB_NoMore ; test for silly case
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
sub dwScanD, ecx ; bias these
sub dwScanS, ecx
mov ebx, ecx
shr ebx, 2
mov eax, ecx
and eax,11b
ALIGN 4
_CBB_Loop:
mov ecx, ebx
rep movsd
mov ecx,eax
rep movsb
add esi, dwScanS
add edi, dwScanD
dec edx ; line counter
jnz SHORT _CBB_Loop
_CBB_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; FastCopyBMP_32
;
; Copy a 32 * n block without transparency
;
; the idea here is to write a special routine
; to move 32*n blocks with few jump & compare
;
; C++ prototype:
; extern "C"
; void pascal CopyBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C FastCopyBMP_32
FastCopyBMP_32 PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ecx
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
ALIGN 4
mov ecx,dwHeight
_FCB_LOOP : ;move directly 32 bits
mov eax,[esi]
mov [edi],eax
mov eax,[esi+4]
mov [edi+4],eax
mov eax,[esi+8]
mov [edi+8],eax
mov eax,[esi+12]
mov [edi+12],eax
mov eax,[esi+16]
mov [edi+16],eax
mov eax,[esi+20]
mov [edi+20],eax
mov eax,[esi+24]
mov [edi+24],eax
mov eax,[esi+28]
mov [edi+28],eax
add esi,dwScanS
add edi,dwScanD
sub ecx,1
jne _FCB_LOOP
_FCB_NoMore:
pop ecx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; DecIndexBMPBits
;
; Dark destination bits with source
; It decrease a destination bit color index
; make the index indicate to a lower color
;
; C++ prototype:
; extern "C"
; void pascal DecIndexBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C DecIndexBMPBits
DecIndexBMPBits PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx,ecx
jz _DIBB_NoMore ; test for silly case
shr ecx,2
shl ecx,2 ;make it n*32 bits
mov edx, dwHeight ; test line counter
or edx, edx
jz _DIBB_NoMore ; test for silly case
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
mov eax, dwScanD
mov dwScanD, eax
sub dwScanD, ecx ; bias these
mov eax, dwScanS
mov dwScanS, eax
sub dwScanS, ecx
_DIBB_Loop:
mov ebx, ecx
shr ebx, 2
; mov eax, ecx
; and eax,11b
ALIGN 4
_DIBB_Line_Loop:
_DIBB_ToCopy0:
mov ah ,BYTE PTR [esi]
cmp ah,0
jz SHORT _DIBB_ToCopy1
mov al, BYTE PTR [edi]
mov ah,al
and al,00001111b
and ah,11110000b
sub al,11b
jnc SHORT _DIBB_DONE0
xor al,al
_DIBB_DONE0 :
or ah,al
mov [edi],ah
_DIBB_ToCopy1:
mov ah ,BYTE PTR [esi + 1]
cmp ah,0
jz SHORT _DIBB_ToCopy2
mov al, BYTE PTR [edi + 1]
mov ah,al
and al,00001111b
and ah,11110000b
sub al,11b
jnc SHORT _DIBB_DONE1
xor al,al
_DIBB_DONE1 :
or ah,al
mov [edi + 1],ah
_DIBB_ToCopy2:
mov ah ,BYTE PTR [esi + 2]
cmp ah,0
jz SHORT _DIBB_ToCopy3
mov al, BYTE PTR [edi + 2]
mov ah,al
and al,00001111b
and ah,11110000b
sub al,11b
jnc SHORT _DIBB_DONE2
xor al,al
_DIBB_DONE2 :
or ah,al
mov [edi + 2],ah
_DIBB_ToCopy3:
mov ah ,BYTE PTR [esi + 3]
cmp ah,0
jz SHORT _DIBB_NEXT_DWORD
mov al, BYTE PTR [edi + 3]
mov ah,al
and al,00001111b
and ah,11110000b
sub al,11b
jnc SHORT _DIBB_DONE3
xor al,al
_DIBB_DONE3 :
or ah,al
mov [edi + 3],ah
_DIBB_NEXT_DWORD :
add edi,4
add esi,4
dec ebx
jnz SHORT _DIBB_Line_Loop
add esi, dwScanS
add edi, dwScanD
dec edx ; line counter
jnz _DIBB_Loop
_DIBB_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; DecIndexBMPBitsEx
;
; Dark destination bits with source
; It decrease a destination bit color index
; make the index indicate to a lower color
; 1/4 size from source
;
; C++ prototype:
; extern "C"
; void pascal ShadowBMPBitsEx(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C DecIndexBMPBitsEx
DecIndexBMPBitsEx PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx,ecx
jz _DIBBE_NoMore ; test for silly case
shr ecx,2
shl ecx,2 ;make it n*32 bits
mov edx, dwHeight ; test line counter
or edx, edx
jz _DIBBE_NoMore ; test for silly case
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
;mov eax, dwScanD
;mov dwScanD, eax
;sub dwScanD, ecx ; bias these
;mov eax, dwScanS
;mov dwScanS, eax
;sub dwScanS, ecx
mov ebx, 3 ;factor for zoom
push ebx
_DIBBE_Loop:
mov esi, pSrc
mov edi, pDest
mov ebx, ecx
ALIGN 4
_DIBBE_Line_Loop:
mov ah ,BYTE PTR [esi]
cmp ah,0
jz SHORT _DIBBE_NEXT_BIT
mov al, BYTE PTR [edi]
mov ah,al
and al,00001111b
and ah,11110000b
sub al,11b
jnc SHORT _DIBBE_DONE0
xor al,al
_DIBBE_DONE0 :
or ah,al
mov [edi],ah
mov [edi + 1],ah
mov [edi + 2],ah
_DIBBE_NEXT_BIT :
add edi,3
add esi,4 ;next point
sub ebx,4
cmp ebx,0
jg SHORT _DIBBE_Line_Loop
mov eax, pSrc
add eax, dwScanS
pop ebx
dec ebx
jnz _DIBBE_JMP0
dec edx ; next line
mov ebx, 3
add eax, dwScanS ;next line
_DIBBE_JMP0 :
push ebx
mov pSrc, eax
mov eax, pDest
add eax, dwScanD ;next line
mov pDest,eax
dec edx ; line counter
cmp edx,0
jg _DIBBE_Loop
pop ebx
_DIBBE_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; IncIndexBMPBits
;
; Light destination bits with source
; It increase a destination bit color index
; make the index indicate to a higher color
;
; C++ prototype:
; extern "C"
; void pascal IncIndexBMPBits(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C IncIndexBMPBits
IncIndexBMPBits PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx,ecx
jz _LBB_NoMore ; test for silly case
mov edx, dwHeight ; test line counter
or edx, edx
jz _LBB_NoMore ; test for silly case
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
mov eax, dwScanD
shr eax, 2
shl eax, 2
mov dwScanD, eax
sub dwScanD, ecx ; bias these
mov eax, dwScanS
shr eax, 2
shl eax, 2
mov dwScanS, eax
sub dwScanS, ecx
_LBB_Loop:
mov ebx, ecx
shr ebx, 2
mov eax, ecx
and eax,11b
ALIGN 4
_LBB_Line_Loop:
_LBB_ToCopy0:
mov al, BYTE PTR [edi]
mov ah,al
and al,1111b
not al
and al, 11b
add ah,al
mov [edi],ah
_LBB_ToCopy1:
mov al, BYTE PTR [edi + 1]
mov ah,al
and al,1111b
not al
and al, 11b
add ah,al
mov [edi + 1],ah
_LBB_ToCopy2:
mov al, BYTE PTR [edi + 2]
mov ah,al
and al,1111b
not al
and al, 11b
add ah,al
mov [edi + 2],ah
_LBB_ToCopy3:
mov al, BYTE PTR [edi + 3]
mov ah,al
and al,1111b
not al
and al, 11b
add ah,al
mov [edi + 3],ah
add edi,4
add esi,4
dec ebx
jnz SHORT _LBB_Line_Loop
add esi, dwScanS
add edi, dwScanD
dec edx ; line counter
jnz SHORT _LBB_Loop
_LBB_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-----------------------------------------------------------------------------;
;
; IncIndexBMPBitsEx
;
; Light destination bits with source
; It increase a destination bit color index
; make the index indicate to a lower color
; 1/4 size from source
;
; C++ prototype:
; extern "C"
; void pascal IncIndexBMPBitsEx(
; void* pDest,
; void* pSrc,
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int nNextScanLineOffset_Src
; )
;
;-----------------------------------------------------------------------------;
PUBLIC C IncIndexBMPBitsEx
IncIndexBMPBitsEx PROC C NEAR \
pDest: DWORD, \
pSrc: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwScanS: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
mov ecx, dwWidth
or ecx,ecx
jz _CBB_NoMore ; test for silly case
shr ecx,2
shl ecx,2 ;make it n*32 bits
mov edx, dwHeight ; test line counter
or edx, edx
jz _IBBEX_NoMore ; test for silly case
mov esi, pSrc ; DS:[ESI] point to source
mov edi, pDest ; ES:[EDI] point to dest
;mov eax, dwScanD
;mov dwScanD, eax
;sub dwScanD, ecx ; bias these
;mov eax, dwScanS
;mov dwScanS, eax
;sub dwScanS, ecx
mov ebx, 3 ;factor for zoom
push ebx
_IBBEX_Loop:
mov esi, pSrc
mov edi, pDest
mov ebx, ecx
ALIGN 4
_IBBEX_Line_Loop:
mov ah ,BYTE PTR [esi]
cmp ah,0
jz SHORT _IBBEX_NEXT_BIT
mov al, BYTE PTR [edi]
mov ah,al
and al,1111b
add al,11b
cmp al,1111b
jl SHORT _IBBEX_DONE0
mov al,1111b
_IBBEX_DONE0 :
or ah,al
mov [edi],ah
mov [edi + 1],ah
mov [edi + 2],ah
_IBBEX_NEXT_BIT :
add edi,3
add esi,4 ;next point
sub ebx,4
cmp ebx,0
jg SHORT _IBBEX_Line_Loop
mov eax, pSrc
add eax, dwScanS
pop ebx
dec ebx
jnz _IBB_JMP0
dec edx ; next line
mov ebx, 3
add eax, dwScanS ;next line
_IBB_JMP0 :
push ebx
mov pSrc, eax
mov eax, pDest
add eax, dwScanD ;next line
mov pDest,eax
dec edx ; line counter
cmp edx,0
jg _IBBEX_Loop
pop ebx
_IBBEX_NoMore:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-------------------------------------------------------
;
; TransCopyRTBBits
;
; Copy a run-length sprite (RTB) with transparency
;
; C++ prototype:
; extern "C"
; void pascal TransCopyRTBBits(
; void* pDest,
; void* pSrcBase,
; void* pSrcIndex
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int cxClip
; )
;
;-------------------------------------------------------
PUBLIC C TransCopyRTBBits
TransCopyRTBBits PROC C NEAR \
pDest: DWORD, \
pSrcBase: DWORD, \
pSrcIndex: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwXClip: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
xor ecx, ecx
mov edx, pSrcIndex
mov edi, pDest
mov eax, dwWidth
sub dwScanD, eax
ALIGN 4
_TCRB_ScanLoop:
mov esi, [edx]
add esi, pSrcBase
mov eax, dwXClip
or eax, eax
jz SHORT _TCRB_BeginExpand
ALIGN 4
_TCRB_SkipXLoop:
mov cx, [esi]
lea esi, [esi+2]
sub eax, ecx
jbe SHORT _TCRB_SkipLast00
mov cx, [esi]
lea esi, [esi+2]
sub eax, ecx
jbe SHORT _TCRB_SkipLastFF
add esi, ecx
jmp SHORT _TCRB_SkipXLoop
_TCRB_SkipLast00:
mov ecx, eax
neg ecx
mov eax, dwWidth
jmp SHORT _TCRB_BeginExpand00
_TCRB_SkipLastFF:
add esi, ecx
add esi, eax
mov ecx, eax
neg ecx
mov eax, dwWidth
jmp SHORT _TCRB_BeginExpandFF
_TCRB_BeginExpand:
mov eax, dwWidth
ALIGN 4
_TCRB_ExpandLoop:
mov cx, [esi]
lea esi, [esi+2]
_TCRB_BeginExpand00:
sub eax, ecx
jbe SHORT _TCRB_ExpandLast00
add edi, ecx
mov cx, [esi]
lea esi, [esi+2]
_TCRB_BeginExpandFF:
sub eax, ecx
jbe SHORT _TCRB_ExpandLastFF
mov ebx, ecx
shr ecx, 2
rep movsd
mov ecx, ebx
and ecx, 3
rep movsb
jmp SHORT _TCRB_ExpandLoop
_TCRB_ExpandLast00:
add edi, ecx
add edi, eax
lea edx, [edx+4]
add edi, dwScanD
dec dwHeight
jnz SHORT _TCRB_ScanLoop
jmp SHORT _TCRB_End
_TCRB_ExpandLastFF:
add ecx, eax
mov ebx, ecx
shr ecx, 2
rep movsd
mov ecx, ebx
and ecx, 3
rep movsb
lea edx, [edx+4]
add edi, dwScanD
dec dwHeight
jnz _TCRB_ScanLoop
_TCRB_End:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
;-------------------------------------------------------
;
; TransCoverRTBBits
;
; Cover a run-length sprite (RTB) with a transparency glass
;
; C++ prototype:
; extern "C"
; void pascal TransCoverRTBBits(
; void* pDest,
; void* pSrcBase,
; void* pSrcIndex
; int cx,
; int cy,
; int nNextScanLineOffset_Dest,
; int cxClip
; BYTE* pSecondIndex
; )
;
;-------------------------------------------------------
PUBLIC C TransCoverRTBBits
TransCoverRTBBits PROC C NEAR \
pDest: DWORD, \
pSrcBase: DWORD, \
pSrcIndex: DWORD, \
dwWidth: DWORD, \
dwHeight: DWORD, \
dwScanD: DWORD, \
dwXClip: DWORD, \
pSecondIndex: DWORD
push esi
push edi
push eax
push ebx
push ecx
push edx
xor ecx, ecx
mov edx, pSrcIndex
mov edi, pDest
mov eax, dwWidth
sub dwScanD, eax
ALIGN 4
_TCVRB_ScanLoop:
mov esi, [edx]
add esi, pSrcBase
mov eax, dwXClip
or eax, eax
jz SHORT _TCVRB_BeginExpand
ALIGN 4
_TCVRB_SkipXLoop:
mov cx, [esi]
lea esi, [esi+2]
sub eax, ecx
jbe SHORT _TCVRB_SkipLast00
mov cx, [esi]
lea esi, [esi+2]
sub eax, ecx
jbe SHORT _TCVRB_SkipLastFF
add esi, ecx
jmp SHORT _TCVRB_SkipXLoop
_TCVRB_SkipLast00:
mov ecx, eax
neg ecx
mov eax, dwWidth
jmp SHORT _TCVRB_BeginExpand00
_TCVRB_SkipLastFF:
add esi, ecx
add esi, eax
mov ecx, eax
neg ecx
mov eax, dwWidth
jmp SHORT _TCVRB_BeginExpandFF
_TCVRB_BeginExpand:
mov eax, dwWidth
ALIGN 4
_TCVRB_ExpandLoop:
mov cx, [esi]
lea esi, [esi+2]
_TCVRB_BeginExpand00:
sub eax, ecx
jbe SHORT _TCVRB_ExpandLast00
add edi, ecx
mov cx, [esi]
lea esi, [esi+2]
_TCVRB_BeginExpandFF:
sub eax, ecx
jbe SHORT _TCVRB_ExpandLastFF
; mov ebx, ecx
; shr ecx, 2
; rep movsd
; mov ecx, ebx
; and ecx, 3
; rep movsb
test ecx, ecx
jz SHORT _TCVRB_ExpandLoop
push edx
_TCVRB_MOVE0 :
mov edx,pSecondIndex
xor ebx, ebx
mov bl, [edi]
add edx, ebx
mov bl,[edx]
mov [edi],bl
inc esi
inc edi
dec ecx
jne SHORT _TCVRB_MOVE0
pop edx
jmp SHORT _TCVRB_ExpandLoop
_TCVRB_ExpandLast00:
add edi, ecx
add edi, eax
lea edx, [edx+4]
add edi, dwScanD
dec dwHeight
jnz _TCVRB_ScanLoop
jmp SHORT _TCVRB_End
_TCVRB_ExpandLastFF:
add ecx, eax
; mov ebx, ecx
; shr ecx, 2
; rep movsd
; mov ecx, ebx
; and ecx, 3
; rep movsb
test ecx, ecx
jz SHORT _TCVRB_ExpandLoop
push edx
_TCVRB_MOVE1 :
mov edx,pSecondIndex
xor ebx, ebx
mov bl, [edi]
add edx, ebx
mov bl,[edx]
mov [edi],bl
inc esi
inc edi
dec ecx
jne SHORT _TCVRB_MOVE1
pop edx
lea edx, [edx+4]
add edi, dwScanD
dec dwHeight
jnz _TCVRB_ScanLoop
_TCVRB_End:
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
ret
ENDP
ENDS
END

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
赞赏
雪币:
留言: