blitbit.asm
来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 3,447 行 · 第 1/4 页
ASM
3,447 行
shl ebx,5
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,5
shl eax,3
stosw
shr eax,16
stosb
@@32k_2: dec ecx
jnz @@32k_1
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
dec edx
jnz @@32k_0
add edi,d[CurrentBankBig]
jmp @@9
@@32k_3: add edi,3
jmp @@32k_2
;
@@b32k: pushm ecx,esi,edi
@@b32k_0: lodsw
cmp ax,w[_VBB_Chroma]
jz @@b32k_3
movzx ebx,ax
shl ebx,1+16
xor eax,eax
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,5
shl eax,3
mov bl,3
@@b32k_4: bank edi
sub edi,d[CurrentBankBig]
stosb
shr eax,8
add edi,d[CurrentBankBig]
dec bl
jnz @@b32k_4
@@b32k_2: dec ecx
jnz @@b32k_0
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
jmp @@9
@@b32k_3: add edi,3
jmp @@b32k_2
;
;64k colour bitmap.
;
@@64k: or ebx,ebx
jz @@b64k
sub edi,d[CurrentBankBig]
@@64k_0: pushm ecx,esi,edi
@@64k_1: lodsw
cmp ax,w[_VBB_Chroma]
jz @@64k_3
movzx ebx,ax
shl ebx,16
xor eax,eax
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,6
shl eax,2
shl ebx,6
shld eax,ebx,5
shl eax,3
stosw
shr eax,16
stosb
@@64k_2: dec ecx
jnz @@64k_1
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
dec edx
jnz @@64k_0
add edi,d[CurrentBankBig]
jmp @@9
@@64k_3: add edi,3
jmp @@64k_2
;
@@b64k: pushm ecx,esi,edi
@@b64k_0: lodsw
cmp ax,w[_VBB_Chroma]
jz @@b64k_3
movzx ebx,ax
shl ebx,16
xor eax,eax
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,6
shl eax,2
shl ebx,6
shld eax,ebx,5
shl eax,3
mov bl,3
@@b64k_4: bank edi
sub edi,d[CurrentBankBig]
stosb
shr eax,8
add edi,d[CurrentBankBig]
dec bl
jnz @@b64k_4
@@b64k_2: dec ecx
jnz @@b64k_0
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
jmp @@9
@@b64k_3: add edi,3
jmp @@b64k_2
;
;16m colour bitmap.
;
@@16m: or ebx,ebx
jz @@b16m
lea ecx,[ecx][ecx*2]
sub edi,d[CurrentBankBig]
@@16m_0: pushm ecx,esi,edi
@@16m_1: lodsd
dec esi
and eax,0ffffffh
cmp eax,d[_VBB_Chroma]
jz @@16m_3
stosw
shr eax,16
stosb
@@16m_2: popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
dec edx
jnz @@16m_0
add edi,d[CurrentBankBig]
jmp @@9
@@16m_3: add edi,3
jmp @@16m_2
;
@@b16m: pushm ecx,esi,edi
@@b16m_0: lodsd
dec esi
and eax,0ffffffh
cmp eax,d[_VBB_Chroma]
jz @@b16m_3
mov bl,3
@@b16m_4: bank edi
sub edi,d[CurrentBankBig]
stosb
shr eax,8
add edi,d[CurrentBankBig]
dec bl
jnz @@b16m_4
@@b16m_2: dec ecx
jnz @@b16m_0
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
jmp @@9
@@b16m_3: add edi,3
jmp @@b16m_2
;
@@9: ret
vPutORBitmap16m endp
;-------------------------------------------------------------------------
;
;Blit a bitmap in 16m 32-bit colour mode.
;
;On Entry:
;
;EBX - state, 0=broken, !=0=clean.
;ECX - width.
;EDX - depth.
;ESI - source.
;EDI - destination.
;EBP - Bitmap (BM) header.
;
vPutORBitmap16m32 proc near
push edx
mov eax,BM_Wide[ebp]
mul BM_PWide[ebp]
pop edx
mov ebp,BM_Flags[ebp]
xchg ebp,eax
and eax,15
jz @@256
dec eax
jz @@32k
dec eax
jz @@64k
dec eax
jz @@16m
jmp @@9
;
;256 colour bitmap.
;
@@256: or ebx,ebx
jz @@b256
sub edi,d[CurrentBankBig]
@@256_0: pushm ecx,esi,edi
@@256_1: lodsb
movzx eax,al
cmp al,b[_VBB_Chroma]
jz @@256_3
mov eax,d[HardwarePalette+eax][eax*2]
shl eax,2
mov bl,al
shr eax,8
xchg ah,bl
shl eax,8
mov al,bl
stosd
@@256_2: dec ecx
jnz @@256_1
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
dec edx
jnz @@256_0
add edi,d[CurrentBankBig]
jmp @@9
@@256_3: add edi,4
jmp @@256_2
;
@@b256: pushm ecx,esi,edi
@@b256_0: bank edi
sub edi,d[CurrentBankBig]
lodsb
movzx eax,al
cmp al,b[_VBB_Chroma]
jz @@b256_3
mov eax,d[HardwarePalette+eax][eax*2]
shl eax,2
mov bl,al
shr eax,8
xchg ah,bl
shl eax,8
mov al,bl
stosd
@@b256_2: add edi,d[CurrentBankBig]
dec ecx
jnz @@b256_0
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
jmp @@9
@@b256_3: add edi,4
jmp @@b256_2
;
;32k colour bitmap.
;
@@32k: or ebx,ebx
jz @@b32k
sub edi,d[CurrentBankBig]
@@32k_0: pushm ecx,esi,edi
@@32k_1: lodsw
cmp ax,w[_VBB_Chroma]
jz @@32k_3
movzx ebx,ax
shl ebx,1+16
xor eax,eax
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,5
shl eax,3
stosd
@@32k_2: dec ecx
jnz @@32k_1
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
dec edx
jnz @@32k_0
add edi,d[CurrentBankBig]
jmp @@9
@@32k_3: add edi,4
jmp @@32k_2
;
@@b32k: pushm ecx,esi,edi
@@b32k_0: bank edi
sub edi,d[CurrentBankBig]
lodsw
cmp ax,w[_VBB_Chroma]
jz @@b32k_3
movzx ebx,ax
shl ebx,1+16
xor eax,eax
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,5
shl eax,3
stosd
@@b32k_2: add edi,d[CurrentBankBig]
dec ecx
jnz @@b32k_0
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
jmp @@9
@@b32k_3: add edi,4
jmp @@b32k_2
;
;64k colour bitmap.
;
@@64k: or ebx,ebx
jz @@b64k
sub edi,d[CurrentBankBig]
@@64k_0: pushm ecx,esi,edi
@@64k_1: lodsw
cmp ax,w[_VBB_Chroma]
jz @@64k_3
movzx ebx,ax
shl ebx,16
xor eax,eax
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,6
shl eax,2
shl ebx,6
shld eax,ebx,5
shl eax,3
stosd
@@64k_2: dec ecx
jnz @@64k_1
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
dec edx
jnz @@64k_0
add edi,d[CurrentBankBig]
jmp @@9
@@64k_3: add edi,4
jmp @@64k_2
;
@@b64k: pushm ecx,esi,edi
@@b64k_0: bank edi
sub edi,d[CurrentBankBig]
lodsw
cmp ax,w[_VBB_Chroma]
jz @@b64k_3
movzx ebx,ax
shl ebx,16
xor eax,eax
shld eax,ebx,5
shl eax,3
shl ebx,5
shld eax,ebx,6
shl eax,2
shl ebx,6
shld eax,ebx,5
shl eax,3
stosd
@@b64k_2: add edi,d[CurrentBankBig]
dec ecx
jnz @@b64k_0
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
jmp @@9
@@b64k_3: add edi,4
jmp @@b64k_2
;
;16m colour bitmap.
;
@@16m: or ebx,ebx
jz @@b16m
sub edi,d[CurrentBankBig]
@@16m_0: pushm ecx,esi,edi
@@16m_1: lodsd
dec esi
and eax,0ffffffh
cmp eax,d[_VBB_Chroma]
jz @@16m_3
stosd
@@16m_2: dec ecx
jnz @@16m_1
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
dec edx
jnz @@16m_0
add edi,d[CurrentBankBig]
jmp @@9
@@16m_3: add edi,4
jmp @@16m_2
;
@@b16m: pushm ecx,esi,edi
@@b16m_0: bank edi
sub edi,d[CurrentBankBig]
lodsd
dec esi
and eax,0ffffffh
cmp eax,d[_VBB_Chroma]
jz @@b16m_3
stosd
@@b16m_2: add edi,d[CurrentBankBig]
dec ecx
jnz @@b16m_0
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
jmp @@9
@@b16m_3: add edi,4
jmp @@b16m_2
;
@@9: ret
vPutORBitmap16m32 endp
;-------------------------------------------------------------------------
;
;Blit a bitmap in text mode.
;
;On Entry:
;
;EBX - state, 0=broken, !=0=clean.
;ECX - width.
;EDX - depth.
;ESI - source.
;EDI - destination.
;EBP - Bitmap (BM) header.
;
vPutORBitmapText proc near
push edx
mov eax,BM_Wide[ebp]
mul BM_PWide[ebp]
pop edx
mov ebp,BM_Flags[ebp]
xchg ebp,eax
and eax,1
jz @@chars
dec eax
jz @@chratt
jmp @@9
;
;Just character data.
;
@@chars: sub edi,d[CurrentBankBig]
@@chars_0: pushm ecx,esi,edi
@@chars_1: lodsb
cmp al,b[_VBB_Chroma]
jz @@chars_3
stosb
inc edi
@@chars_2: dec ecx
jnz @@chars_1
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
dec edx
jnz @@chars_0
add edi,d[CurrentBankBig]
jmp @@9
@@chars_3: add edi,2
jmp @@chars_2
;
;Character and attribute data.
;
@@chratt: sub edi,d[CurrentBankBig]
@@chratt_0: pushm ecx,esi,edi
@@chratt_1: lodsw
cmp ax,w[_VBB_Chroma]
jz @@chratt_3
stosw
@@chratt_2: dec ecx
jnz @@chratt_1
popm ecx,esi,edi
add esi,ebp
add edi,VideoHardwareWidth
dec edx
jnz @@chratt_0
add edi,d[CurrentBankBig]
jmp @@9
@@chratt_3: add edi,2
jmp @@chratt_2
;
@@9: ret
vPutORBitmapText endp
;-------------------------------------------------------------------------
;
;Blit a bitmap in 256 colour mode.
;
;On Entry:
;
;EBX - state, 0=broken, !=0=clean.
;ECX - width.
;EDX - depth.
;ESI - source.
;EDI - destination.
;EBP - Bitmap (BM) header.
;
vGetBitmap256 proc near
mov BM_Flags[ebp],0
mov BM_PWide[ebp],1
push edx
mov eax,BM_Wide[ebp]
mul BM_PWide[ebp]
pop edx
mov ebp,eax
;
assume ds:nothing
pushm ds,es
popm es,ds
;
or ebx,ebx
jz @@b256
sub esi,ss:d[CurrentBankBig]
@@256_0: pushm ecx,esi,edi
rep_movsb
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
dec edx
jnz @@256_0
add esi,ss:d[CurrentBankBig]
jmp @@9
;
@@b256: pushm ecx,esi,edi
@@b256_0: bank esi
sub esi,ss:d[CurrentBankBig]
movsb
add esi,ss:d[CurrentBankBig]
dec ecx
jnz @@b256_0
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
;
@@9: pushm ds,es
popm es,ds
assume ds:DGROUP
ret
vGetBitmap256 endp
;-------------------------------------------------------------------------
;
;Blit a bitmap in 32k colour mode.
;
;On Entry:
;
;EBX - state, 0=broken, !=0=clean.
;ECX - width.
;EDX - depth.
;ESI - source.
;EDI - destination.
;EBP - Bitmap (BM) header.
;
vGetBitmap32k proc near
mov BM_Flags[ebp],1
mov BM_PWide[ebp],2
push edx
mov eax,BM_Wide[ebp]
mul BM_PWide[ebp]
pop edx
mov ebp,eax
;
assume ds:nothing
pushm ds,es
popm es,ds
;
or ebx,ebx
jz @@b32k
sub esi,ss:d[CurrentBankBig]
@@32k_0: pushm ecx,esi,edi
rep_movsw
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
dec edx
jnz @@32k_0
add esi,ss:d[CurrentBankBig]
jmp @@9
;
@@b32k: pushm ecx,esi,edi
@@b32k_0: bank esi
sub esi,ss:d[CurrentBankBig]
movsw
add esi,ss:d[CurrentBankBig]
dec ecx
jnz @@b32k_0
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
;
@@9: pushm ds,es
popm es,ds
assume ds:DGROUP
ret
vGetBitmap32k endp
;-------------------------------------------------------------------------
;
;Blit a bitmap in 256 colour mode.
;
;On Entry:
;
;EBX - state, 0=broken, !=0=clean.
;ECX - width.
;EDX - depth.
;ESI - source.
;EDI - destination.
;EBP - Bitmap (BM) header.
;
vGetBitmap64k proc near
mov BM_Flags[ebp],2
mov BM_PWide[ebp],2
push edx
mov eax,BM_Wide[ebp]
mul BM_PWide[ebp]
pop edx
mov ebp,eax
;
assume ds:nothing
pushm ds,es
popm es,ds
;
or ebx,ebx
jz @@b64k
sub esi,ss:d[CurrentBankBig]
@@64k_0: pushm ecx,esi,edi
rep_movsw
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
dec edx
jnz @@64k_0
add esi,ss:d[CurrentBankBig]
jmp @@9
;
@@b64k: pushm ecx,esi,edi
@@b64k_0: bank esi
sub esi,ss:d[CurrentBankBig]
movsw
add esi,ss:d[CurrentBankBig]
dec ecx
jnz @@b64k_0
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
;
@@9: pushm ds,es
popm es,ds
assume ds:DGROUP
ret
vGetBitmap64k endp
;-------------------------------------------------------------------------
;
;Blit a bitmap in 256 colour mode.
;
;On Entry:
;
;EBX - state, 0=broken, !=0=clean.
;ECX - width.
;EDX - depth.
;ESI - source.
;EDI - destination.
;EBP - Bitmap (BM) header.
;
vGetBitmap16m proc near
mov BM_Flags[ebp],3
mov BM_PWide[ebp],3
push edx
mov eax,BM_Wide[ebp]
mul BM_PWide[ebp]
pop edx
mov ebp,eax
;
assume ds:nothing
pushm ds,es
popm es,ds
;
or ebx,ebx
jz @@b16m
lea ecx,[ecx][ecx*2]
sub esi,ss:d[CurrentBankBig]
@@16m_0: pushm ecx,esi,edi
rep_movsb
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
dec edx
jnz @@16m_0
add esi,ss:d[CurrentBankBig]
jmp @@9
;
@@b16m: pushm ecx,esi,edi
lea ecx,[ecx+ecx*2]
@@b16m_0: bank esi
sub esi,ss:d[CurrentBankBig]
movsb
add esi,ss:d[CurrentBankBig]
dec ecx
jnz @@b16m_0
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
;
@@9: pushm ds,es
popm es,ds
assume ds:DGROUP
ret
vGetBitmap16m endp
;-------------------------------------------------------------------------
;
;Blit a bitmap in 16m 32-bit colour mode.
;
;On Entry:
;
;EBX - state, 0=broken, !=0=clean.
;ECX - width.
;EDX - depth.
;ESI - source.
;EDI - destination.
;EBP - Bitmap (BM) header.
;
vGetBitmap16m32 proc near
mov BM_Flags[ebp],3
mov BM_PWide[ebp],3
push edx
mov eax,BM_Wide[ebp]
mul BM_PWide[ebp]
pop edx
mov ebp,eax
;
assume ds:nothing
pushm ds,es
popm es,ds
;
or ebx,ebx
jz @@b16m
sub esi,ss:d[CurrentBankBig]
@@16m_0: pushm ecx,esi,edi
@@16m_1: lodsd
stosw
shr eax,16
stosb
dec ecx
jnz @@16m_1
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
dec edx
jnz @@16m_0
add esi,ss:d[CurrentBankBig]
jmp @@9
;
@@b16m: pushm ecx,esi,edi
@@b16m_0: bank esi
sub esi,ss:d[CurrentBankBig]
lodsd
stosw
shr eax,16
stosb
add esi,ss:d[CurrentBankBig]
dec ecx
jnz @@b16m_0
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
;
@@9: pushm ds,es
popm es,ds
assume ds:DGROUP
ret
vGetBitmap16m32 endp
;-------------------------------------------------------------------------
;
;Blit a bitmap in text mode.
;
;On Entry:
;
;EBX - state, 0=broken, !=0=clean.
;ECX - width.
;EDX - depth.
;ESI - source.
;EDI - destination.
;EBP - Bitmap (BM) header.
;
vGetBitmapText proc near
mov BM_Flags[ebp],8+1
mov BM_PWide[ebp],2
push edx
mov eax,BM_Wide[ebp]
mul BM_PWide[ebp]
pop edx
mov ebp,eax
;
assume ds:nothing
pushm ds,es
popm es,ds
;
sub esi,ss:d[CurrentBankBig]
@@256_0: pushm ecx,esi,edi
rep_movsw
popm ecx,esi,edi
add edi,ebp
add esi,ss:VideoHardwareWidth
dec edx
jnz @@256_0
add esi,ss:d[CurrentBankBig]
jmp @@9
;
@@9: pushm ds,es
popm es,ds
assume ds:DGROUP
ret
vGetBitmapText endp
sdata
_VBB_Chroma dd ?
;
PutRoutines dd vPutBitmap256,vPutBitmap32k,vPutBitmap64k,vPutBitmap16m
dd vPutBitmap16m32,3 dup (NearNull)
dd NearNull
dd vPutBitmapText
dd 6 dup (NearNull)
PutOrRoutines dd vPutORBitmap256,vPutORBitmap32k,vPutORBitmap64k,vPutORBitmap16m
dd vPutORBitmap16m32,3 dup (NearNull)
dd NearNull
dd vPutORBitmapText
dd 6 dup (NearNull)
GetRoutines dd vGetBitmap256,vGetBitmap32k,vGetBitmap64k,vGetBitmap16m
dd vGetBitmap16m32,3 dup (NearNull)
dd NearNull
dd vGetBitmapText
dd 6 dup (NearNull)
efile
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?