📄 mv16tms.asm
字号:
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
;
;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either
;version 2 of the License, or (at your option) any later
;version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License
;along with this program; if not, write to the Free Software
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%include "macros.mac"
EXTSYM bgcoloradder,bgofwptr,bgsubby,bshifter,curbgpr,curmosaicsz
EXTSYM curvidoffset,cwinptr,domosaic16b,drawn,pal16b,scaddtype
EXTSYM scrnon,temp,tempcach,temptile,tileleft16b,transpbuf,vcache2b
EXTSYM vcache4b,vcache8b,winon,winptrref,xtravbuf,yadd,yadder
EXTSYM yrevadder,draw16x816t,bgmode
EXTSYM vcache2ba,vcache4ba,vcache8ba
EXTSYM fulladdtab,pal16bcl
EXTSYM pal16bxcl
EXTSYM coadder16
EXTSYM a16x16xinc,a16x16yinc,curypos,yflipadd
NEWSYM MV16TMSAsmStart
%include "video/vidmacro.mac"
;*******************************************************
; Processes & Draws 8x8 tiles in 2, 4, & 8 bit mode
;*******************************************************
%macro draw8x816tams 2
mov al,[ebx+%1]
or al,al
jz %%loop
add al,dh
mov ecx,[ebp+%2]
mov eax,[pal16b+eax*4]
mov [ebp+%2],ax
test ecx,0FFFFh
je %%noadd
and eax,1111011111011110b ; [vesa2_clbit]
and ecx,1111011111011110b ; [vesa2_clbit]
add eax,ecx
shr eax,1
%%noadd
mov [esi+%2],ax
xor eax,eax
%%loop
%endmacro
%macro draw8x816tbms 2
mov al,[edi+%1]
or al,al
jz %%loop
add al,dh
mov ebx,[ebp+%2]
mov ecx,[pal16bcl+eax*4]
mov [ebp+%2],cx
and ebx,1111011111011110b ; [vesa2_clbit]
add ecx,ebx
shr ecx,1
mov ecx,[fulladdtab+ecx*2]
mov [esi+%2],cx
%%loop
%endmacro
%macro draw8x816tcms 2
mov al,[edi+%1]
or al,al
jz %%loop
add al,dh
mov ebx,[ebp+%2]
mov ecx,[pal16bxcl+eax*4]
mov [ebp+%2],cx
and ebx,1111011111011110b ; [vesa2_clbit]
add ecx,ebx
shr ecx,1
mov ecx,[fulladdtab+ecx*2]
xor ecx,0FFFFh
mov [esi+%2],cx
%%loop
%endmacro
%macro draw8x816tawinonms 2
mov al,[ebx+%1]
or al,al
jz %%loop
test byte[edx+%1],0FFh
jnz %%loop
add al,[coadder16]
mov ecx,[ebp+%2]
mov eax,[pal16b+eax*4]
mov [ebp+%2],ax
test ecx,0FFFFh
je %%noadd
and eax,1111011111011110b ; [vesa2_clbit]
and ecx,1111011111011110b ; [vesa2_clbit]
add eax,ecx
shr eax,1
%%noadd
mov [esi+%2],ax
xor eax,eax
%%loop
%endmacro
%macro draw8x816tbwinonms 2
mov al,[edi+%1]
or al,al
jz %%loop
test byte[edx+%1],0FFh
jnz %%loop
add al,[coadder16]
mov ebx,[ebp+%2]
mov ecx,[pal16bcl+eax*4]
mov [ebp+%2],cx
and ebx,1111011111011110b ; [vesa2_clbit]
add ecx,ebx
shr ecx,1
mov ecx,[fulladdtab+ecx*2]
mov [esi+%2],cx
%%loop
%endmacro
%macro draw8x816tcwinonms 2
mov al,[edi+%1]
or al,al
jz %%loop
test byte[edx+%1],0FFh
jnz %%loop
add al,[coadder16]
mov ebx,[ebp+%2]
mov ecx,[pal16bxcl+eax*4]
mov [ebp+%2],cx
and ebx,1111011111011110b ; [vesa2_clbit]
add ecx,ebx
shr ecx,1
mov ecx,[fulladdtab+ecx*2]
xor ecx,0FFFFh
mov [esi+%2],cx
%%loop
%endmacro
%macro draw8x816tawinonbms 2
mov al,[ebx+%1]
or al,al
jz %%loop
test byte[edx+7-%1],0FFh
jnz %%loop
add al,[coadder16]
mov ecx,[ebp+%2]
mov eax,[pal16b+eax*4]
mov [ebp+%2],ax
test ecx,0FFFFh
je %%noadd
and eax,1111011111011110b ; [vesa2_clbit]
and ecx,1111011111011110b ; [vesa2_clbit]
add eax,ecx
shr eax,1
%%noadd
mov [esi+%2],ax
xor eax,eax
%%loop
%endmacro
%macro draw8x816tbwinonbms 2
mov al,[edi+%1]
or al,al
jz %%loop
test byte[edx+7-%1],0FFh
jnz %%loop
add al,[coadder16]
mov ebx,[ebp+%2]
mov ecx,[pal16bcl+eax*4]
mov [ebp+%2],cx
and ebx,1111011111011110b ; [vesa2_clbit]
add ecx,ebx
shr ecx,1
mov ecx,[fulladdtab+ecx*2]
mov [esi+%2],cx
%%loop
%endmacro
%macro draw8x816tcwinonbms 2
mov al,[edi+%1]
or al,al
jz %%loop
test byte[edx+7-%1],0FFh
jnz %%loop
add al,[coadder16]
mov ebx,[ebp+%2]
mov ecx,[pal16bxcl+eax*4]
mov [ebp+%2],cx
and ebx,1111011111011110b ; [vesa2_clbit]
add ecx,ebx
shr ecx,1
mov ecx,[fulladdtab+ecx*2]
xor ecx,0FFFFh
mov [esi+%2],cx
%%loop
%endmacro
NEWSYM draw8x816tms
cmp byte[bgmode],5
je near draw16x816t
mov [temp],al
mov [bshifter],ah
mov eax,esi
mov [yadder],ecx
mov [tempcach],ebx
mov ebx,56
sub ebx,ecx
mov [yrevadder],ebx
; esi = pointer to video buffer
mov esi,[cwinptr]
sub esi,eax
mov [winptrref],esi
mov esi,[curvidoffset]
sub esi,eax ; esi = [vidbuffer] + curypos * 288 + 16 - HOfs
sub esi,eax
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+32
mov ecx,128
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+32
sub esi,eax
sub esi,eax
.nomosaic
mov [temptile],edx
mov dword[bgofwptr],vcache2ba+262144
mov dword[bgsubby],262144
cmp dword[tempcach],vcache2ba+262144
jb .nobit
mov dword[bgofwptr],vcache4ba+131072
mov dword[bgsubby],131072
cmp dword[tempcach],vcache4ba+131072
jb .nobit
mov dword[bgofwptr],vcache8ba+65536
mov dword[bgsubby],65536
.nobit
; tile value : bit 15 = flipy, bit 14 = flipx, bit 13 = priority value
; bit 10-12 = palette, 0-9=tile#
cmp byte[curmosaicsz],1
jne .domosaic
cmp byte[winon],0
jne near draw8x816twinonms
.domosaic
mov ebp,transpbuf+32
sub ebp,eax
sub ebp,eax
test byte[scaddtype],80h
jnz near draw8x816tsms
test byte[scaddtype],40h
jz near draw8x8fulladdms
cmp byte[scrnon+1],0
jz near draw8x8fulladdms
mov byte[tileleft16b],33
mov byte[drawn],0
mov dl,[temp]
.loopa
mov ax,[edi]
mov dh,ah
add edi,2
xor dh,[curbgpr]
test dh,20h
jnz near .hprior
inc byte[drawn]
and eax,03FFh ; filter out tile #
mov ebx,[tempcach]
shl eax,6
add ebx,eax
cmp ebx,[bgofwptr]
jb .noclip
sub ebx,[bgsubby]
.noclip
test dh,80h
jz .normadd
add ebx,[yrevadder]
jmp .skipadd
.normadd
add ebx,[yadder]
.skipadd
test dh,40h
jnz near .rloop
; Begin Normal Loop
mov cl,[bshifter]
and dh,1Ch
shl dh,cl ; process palette # (bits 10-12)
add dh,[bgcoloradder]
xor eax,eax
xor ecx,ecx
; Start loop
drawtilegrp draw8x816tams
.hprior
add esi,16
add ebp,16
inc dl
cmp dl,20h
jne .loopc2
mov edi,[temptile]
.loopc2
dec byte[tileleft16b]
jnz near .loopa
cmp byte[drawn],0
je .nodraw
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
.nodraw
ret
; reversed loop
.rloop
mov cl,[bshifter]
and dh,1Ch
shl dh,cl ; process palette # (bits 10-12)
add dh,[bgcoloradder]
xor eax,eax
xor ecx,ecx
drawtilegrpf draw8x816tams
add esi,16
add ebp,16
inc dl
cmp dl,20h
jne .loopc
mov edi,[temptile]
.loopc
dec byte[tileleft16b]
jnz near .loopa
cmp byte[drawn],0
je .nodraw2
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
.nodraw2
ret
NEWSYM draw8x8fulladdms
mov byte[tileleft16b],33
mov byte[drawn],0
mov dl,[temp]
.loopa
mov ax,[edi]
mov dh,ah
add edi,2
push edi
xor dh,[curbgpr]
test dh,20h
jnz near .hprior
inc byte[drawn]
and eax,03FFh ; filter out tile #
mov edi,[tempcach]
shl eax,6
add edi,eax
cmp edi,[bgofwptr]
jb .noclip
sub edi,[bgsubby]
.noclip
test dh,80h
jz .normadd
add edi,[yrevadder]
jmp .skipadd
.normadd
add edi,[yadder]
.skipadd
test dh,40h
jnz near .rloop
; Begin Normal Loop
mov cl,[bshifter]
and dh,1Ch
shl dh,cl ; process palette # (bits 10-12)
add dh,[bgcoloradder]
xor eax,eax
xor ecx,ecx
; Start loop
drawtilegrpfull draw8x816tbms
.hprior
pop edi
add esi,16
add ebp,16
inc dl
cmp dl,20h
jne .loopc2
mov edi,[temptile]
.loopc2
dec byte[tileleft16b]
jnz near .loopa
cmp byte[drawn],0
je .nodraw
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
.nodraw
ret
; reversed loop
.rloop
mov cl,[bshifter]
and dh,1Ch
shl dh,cl ; process palette # (bits 10-12)
add dh,[bgcoloradder]
xor eax,eax
xor ecx,ecx
drawtilegrpfullf draw8x816tbms
pop edi
add esi,16
add ebp,16
inc dl
cmp dl,20h
jne .loopc
mov edi,[temptile]
.loopc
dec byte[tileleft16b]
jnz near .loopa
cmp byte[drawn],0
je .nodraw2
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
.nodraw2
ret
NEWSYM draw8x816tsms
mov byte[tileleft16b],33
mov byte[drawn],0
mov dl,[temp]
.loopa
mov ax,[edi]
mov dh,ah
add edi,2
push edi
xor dh,[curbgpr]
test dh,20h
jnz near .hprior
inc byte[drawn]
and eax,03FFh ; filter out tile #
mov edi,[tempcach]
shl eax,6
add edi,eax
cmp edi,[bgofwptr]
jb .noclip
sub edi,[bgsubby]
.noclip
test dh,80h
jz .normadd
add edi,[yrevadder]
jmp .skipadd
.normadd
add edi,[yadder]
.skipadd
test dh,40h
jnz near .rloop
; Begin Normal Loop
mov cl,[bshifter]
and dh,1Ch
shl dh,cl ; process palette # (bits 10-12)
add dh,[bgcoloradder]
xor eax,eax
xor ecx,ecx
; Start loop
drawtilegrpfull draw8x816tcms
.hprior
pop edi
add esi,16
add ebp,16
inc dl
cmp dl,20h
jne .loopc2
mov edi,[temptile]
.loopc2
dec byte[tileleft16b]
jnz near .loopa
ret
; reversed loop
.rloop
mov cl,[bshifter]
and dh,1Ch
shl dh,cl ; process palette # (bits 10-12)
add dh,[bgcoloradder]
xor eax,eax
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -