📄 makev16b.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 cursprloc,curypos,scrndis,scrnon,winon,winonsp,drawmode716extbg,drawmode716extbg2,SA1Enable
EXTSYM alreadydrawn,bg1cachloc,bg1tdabloc,bg1tdatloc,bg1vbufloc,bg1xposloc
EXTSYM bg1yaddval,bgcoloradder,bgmode,bgtilesz,curbgnum,drawn,makewindow
EXTSYM winbg1en,winenabs
EXTSYM mosaicon,winenabm
EXTSYM vidbuffer
EXTSYM bg3high2,colormodedef,colormodeofs,curbgpr,curblank
EXTSYM currentobjptr,curvidoffset,cwinenabm,drawline16t,forceblnk
EXTSYM makewindowsp,maxbr,newengen,newengine16b,preparesprpr
EXTSYM procbackgrnd,scaddset,scaddtype,spritetablea,sprleftpr,ForceNewGfxOff
EXTSYM bg1scrolx,bg1scroly,drawmode716b,mode7set,mosaicsz,sprleftpr1
EXTSYM sprleftpr2,sprleftpr3,sprlefttot,sprprifix,interlval
EXTSYM extbgdone
EXTSYM FPUZero,coladdb,coladdg,coladdr,pal16b,vesa2_bpos
EXTSYM V8Mode,doveg,pal16bcl,pal16bxcl,prevbright,prevpal,vesa2_clbit
EXTSYM vesa2_gpos,vesa2_rpos,vesa2_usbit,vidbright
EXTSYM cgmod,cgram,gammalevel16b,dovegrest
EXTSYM winspdata
EXTSYM csprbit,csprprlft,sprclprio,sprsingle,sprpriodata
EXTSYM bgofwptr,bgsubby,bshifter,curmosaicsz,cwinptr,osm2dis,temp
EXTSYM tempcach,temptile,winptrref,vcache2b,vcache4b,vcache8b
EXTSYM xtravbuf,yadder,yrevadder
EXTSYM vcache2ba,vcache4ba,vcache8ba
EXTSYM hirestiledat,res512switch
EXTSYM numwin,windowdata
EXTSYM bg1objptr,bg1ptr,bg1ptrc,bg3ptr,bg3scrolx,bg3scroly,cachesingle
EXTSYM colormoded2,offsetenab,offsetmclr,offsetmcol,offsetmodeptr
EXTSYM offsetmptr,offsetmshl,offsetmtst,offsetptra,offsetptrb,posyscroll
EXTSYM prevoffsetdat,prevtempcache,tempoffset,vidmemch2,vidmemch4
EXTSYM vidmemch8,vram
EXTSYM ofsmcptr,ofsmady,ofsmadx,yposng,yposngom,flipyposng,flipyposngom
EXTSYM ofsmtptr,ofsmmptr,ofsmcyps,bgtxadd,bg1ptrx,bg1ptry
EXTSYM a16x16xinc,a16x16yinc
NEWSYM MakeV16BAsmStart
%include "video/vidmacro.mac"
;drawspritesprio
NEWSYM tempstuff, dd 0
ALIGN16
.stuff dd 0
.stuff2 db 0,0
%macro procmode716bextbg 3
xor eax,eax
xor edx,edx
mov ax,[curypos]
test byte[mode7set],02h
jz %%noflip
mov ax,261
sub ax,[curypos]
dec ax
%%noflip
mov byte[curmosaicsz],1
test byte[mosaicon],%3
jz %%nomos
mov bl,[mosaicsz]
cmp bl,0
je %%nomos
inc bl
mov [curmosaicsz],bl
xor bh,bh
div bx
xor edx,edx
mul bx
%%nomos
add ax,%1
mov dx,%2
call drawmode716extbg
%endmacro
%macro procmode716bextbg2 3
xor eax,eax
xor edx,edx
mov ax,[curypos]
mov byte[curmosaicsz],1
test byte[mosaicon],%3
jz %%nomos
mov bl,[mosaicsz]
cmp bl,0
je %%nomos
inc bl
mov [curmosaicsz],bl
xor bh,bh
div bx
xor edx,edx
mul bx
%%nomos
call drawmode716extbg2
%endmacro
NEWSYM procspritessub16b
test byte[scrndis],10h
jnz .nosprites
test byte[scrnon+1],10h
jz .nosprites
test byte[scrnon],10h
jnz .nosprites
cmp byte[winonsp],0FFh
je .nosprites
xor ebx,ebx
mov bl,[curypos]
add ebx,[cursprloc]
mov cl,[ebx]
cmp byte[sprprifix],0
jne .sprprio
add dword[cursprloc],256
.sprprio
cmp cl,0
je .nosprites
call drawsprites16b
.nosprites
ret
NEWSYM procspritesmain16b
test byte[scrndis],10h
jnz .nosprites
test byte[scrnon],10h
jz .nosprites
cmp byte[winonsp],0FFh
je .nosprites
xor ebx,ebx
mov bl,[curypos]
add ebx,[cursprloc]
mov cl,[ebx]
cmp byte[sprprifix],0
jne .sprprio
add dword[cursprloc],256
.sprprio
cmp cl,0
je .nosprites
call drawsprites16b
.nosprites
ret
NEWSYM drawbackgrndsub16b
mov esi,[colormodeofs]
mov bl,[esi+ebp]
cmp bl,0
je near .noback
mov al,[curbgnum]
test byte[scrnon+1],al
jz near .noback
test byte[scrnon],al
jnz near .noback
test byte[alreadydrawn],al
jnz near .noback
test byte[scrndis],al
jnz near .noback
mov byte[winon],0
test byte[winenabs],al
jz near .nobackwin
; procwindow [winbg1en+ebp]
mov al,[winbg1en+ebp]
call makewindow
cmp byte[winon],0FFh
je near .noback
.nobackwin
mov bl,[curbgnum]
mov byte[curmosaicsz],1
test byte[mosaicon],bl
jz .nomos
mov bl,[mosaicsz]
cmp bl,0
je .nomos
inc bl
mov [curmosaicsz],bl
.nomos
mov byte[bgcoloradder],0
cmp byte[bgmode],0
jne .nomode0
mov eax,ebp
mov bl,20h
mul bl
mov byte[bgcoloradder],al
.nomode0
mov esi,[bg1vbufloc+ebp*4]
mov edi,[bg1tdatloc+ebp*4]
mov edx,[bg1tdabloc+ebp*4]
mov ebx,[bg1cachloc+ebp*4]
mov eax,[bg1xposloc+ebp*4]
mov cl,[curbgnum]
test byte[bgtilesz],cl
jnz .16x16
mov ecx,[bg1yaddval+ebp*4]
call draw8x816b
cmp byte[drawn],33
jne .notalldrawn
mov al,[curbgnum]
or [alreadydrawn],al
.notalldrawn
jmp .noback
.16x16
mov ecx,[bg1yaddval+ebp*4]
call draw16x1616b
cmp byte[drawn],33
jne .notalldrawnb
mov al,[curbgnum]
or [alreadydrawn],al
.notalldrawnb
.noback
ret
NEWSYM drawbackgrndmain16b
mov esi,[colormodeofs]
mov bl,[esi+ebp]
cmp bl,0
je near .noback
mov al,[curbgnum]
test byte[scrnon],al
jz near .noback
test byte[alreadydrawn],al
jnz near .noback
test byte[scrndis],al
jnz near .noback
mov byte[winon],0
test byte[winenabm],al
jz near .nobackwin
; procwindow [winbg1en+ebp]
mov al,[winbg1en+ebp]
call makewindow
cmp byte[winon],0FFh
je near .noback
.nobackwin
mov bl,[curbgnum]
mov byte[curmosaicsz],1
test byte[mosaicon],bl
jz .nomos
mov bl,[mosaicsz]
cmp bl,0
je .nomos
inc bl
mov [curmosaicsz],bl
.nomos
mov byte[bgcoloradder],0
cmp byte[bgmode],0
jne .nomode0
mov eax,ebp
mov bl,20h
mul bl
mov byte[bgcoloradder],al
.nomode0
mov esi,[bg1vbufloc+ebp*4]
mov edi,[bg1tdatloc+ebp*4]
mov edx,[bg1tdabloc+ebp*4]
mov ebx,[bg1cachloc+ebp*4]
mov eax,[bg1xposloc+ebp*4]
mov cl,[curbgnum]
test byte[bgtilesz],cl
jnz .16x16
mov ecx,[bg1yaddval+ebp*4]
call draw8x816b
cmp byte[drawn],33
jne .notalldrawn
mov al,[curbgnum]
or [alreadydrawn],al
.notalldrawn
jmp .noback
.16x16
mov ecx,[bg1yaddval+ebp*4]
call draw16x1616b
cmp byte[drawn],33
jne .notalldrawnb
mov al,[curbgnum]
or [alreadydrawn],al
.notalldrawnb
.noback
ret
NEWSYM blanker16b
; calculate current video offset
push ebx
push esi
xor ebx,ebx
mov bx,[curypos]
mov esi,ebx
shl esi,9
shl ebx,6
add esi,ebx
add esi,32
add esi,[vidbuffer]
mov bl,128
.next
mov dword[esi],0
add esi,4
dec bl
jnz .next
pop esi
pop ebx
ret
NEWSYM drawline16b
cmp byte[ForceNewGfxOff],0
jne .nonewgfx
cmp byte[newengen],1
je near newengine16b
.nonewgfx
cmp byte[curblank],0
jne near nodrawline16b
mov al,[vidbright]
cmp al,[maxbr]
jbe .nochange
mov [maxbr],al
.nochange
cmp byte[forceblnk],0
jne blanker16b
mov byte[alreadydrawn],0
push ebx
xor ebx,ebx
mov bl,[bgmode]
shl bl,2
add ebx,colormodedef
mov [colormodeofs],ebx
pop ebx
cmp byte[SA1Enable],0
je .noscrnona
cmp word[scrnon],1317h
jne .noscrnona
cmp byte[scaddtype],0
jne .noscrnona
mov word[scrnon],1317h
mov byte[scaddtype],44h
mov byte[scaddset],02h
.noscrnona
cmp word[scrnon],0117h
jne .notransph
cmp word[scaddset],8202h
jne .notransph
mov word[scrnon],0116h
.notransph
test byte[scaddset],02h
jnz near drawline16t
cmp dword[coladdr],0
je .nocoladd
test byte[scaddtype],3Fh
jnz near drawline16t
.nocoladd
cmp byte[bgmode],7
je near processmode716b
push esi
push edi
push ebx
push edx
push ebp
; calculate current video offset
xor ebx,ebx
mov bx,[curypos]
mov esi,ebx
shl esi,9
shl ebx,6
add esi,ebx
add esi,32
add esi,[vidbuffer]
mov [curvidoffset],esi
; do sprite windowing
call makewindowsp
; set palette
call setpalette16b
; clear back area w/ back color
call clearback16b
; clear registers
xor eax,eax
xor ecx,ecx
; get current sprite table
xor ebx,ebx
mov bl,[curypos]
shl ebx,9
add ebx,[spritetablea]
mov [currentobjptr],ebx
mov dword[cursprloc],sprleftpr
; setup priorities
cmp byte[sprprifix],0
je .nosprprio
mov dword[cursprloc],sprlefttot
call preparesprpr
.nosprprio
; process backgrounds
; do background 2
mov byte[curbgnum],02h
mov ebp,01h
call procbackgrnd
; do background 1
mov byte[curbgnum],01h
mov ebp,00h
call procbackgrnd
; do background 4
mov byte[curbgnum],08h
mov ebp,03h
call procbackgrnd
; do background 3
mov byte[curbgnum],04h
mov ebp,02h
call procbackgrnd
cmp byte[bgmode],1
ja near priority216b
mov al,[winenabm]
mov [cwinenabm],al
mov byte[curbgpr],0h
; do background 4
mov byte[curbgnum],08h
mov ebp,03h
call drawbackgrndmain16b
; do background 3
mov byte[curbgnum],04h
mov ebp,02h
call drawbackgrndmain16b
mov ebp,0
call procspritesmain16b
mov byte[curbgpr],20h
; do background 4
mov byte[curbgnum],08h
mov ebp,03h
call drawbackgrndmain16b
; do background 3
cmp byte[bg3high2],1
je .bg3nothighb
mov byte[curbgnum],04h
mov ebp,02h
call drawbackgrndmain16b
.bg3nothighb
mov ebp,1
call procspritesmain16b
; do background 2
mov byte[curbgpr],0h
mov byte[curbgnum],02h
mov ebp,01h
call drawbackgrndmain16b
; do background 1
mov byte[curbgnum],01h
mov ebp,00h
call drawbackgrndmain16b
mov ebp,2
call procspritesmain16b
; do background 2
mov byte[curbgpr],20h
mov byte[curbgnum],02h
mov ebp,01h
call drawbackgrndmain16b
; do background 1
mov byte[curbgnum],01h
mov ebp,00h
call drawbackgrndmain16b
mov ebp,3
call procspritesmain16b
cmp byte[bg3high2],1
jne .bg3highb
; do background 3
mov byte[curbgpr],20h
mov byte[curbgnum],04h
mov ebp,02h
call drawbackgrndmain16b
.bg3highb
pop ebp
pop edx
pop ebx
pop edi
pop esi
xor eax,eax
xor ecx,ecx
NEWSYM nodrawline16b
ret
NEWSYM priority216b
mov al,[winenabm]
mov [cwinenabm],al
; do background 2
mov byte[curbgpr],0h
mov byte[curbgnum],02h
mov ebp,01h
call drawbackgrndmain16b
mov ebp,0
call procspritesmain16b
; do background 1
mov byte[curbgnum],01h
mov ebp,00h
call drawbackgrndmain16b
mov ebp,1
call procspritesmain16b
; do background 2
mov byte[curbgpr],20h
mov byte[curbgnum],02h
mov ebp,01h
call drawbackgrndmain16b
mov ebp,2
call procspritesmain16b
; do background 1
mov byte[curbgnum],01h
mov ebp,00h
call drawbackgrndmain16b
mov ebp,3
call procspritesmain16b
cmp byte[bg3high2],1
pop ebp
pop edx
pop ebx
pop edi
pop esi
xor eax,eax
xor ecx,ecx
ret
NEWSYM processmode716b
mov al,[winenabm]
mov [cwinenabm],al
push esi
push edi
push ebx
push edx
push ebp
; get current sprite table
xor ebx,ebx
mov bl,[curypos]
shl ebx,9
add ebx,[spritetablea]
mov [currentobjptr],ebx
; setup priorities
cmp byte[sprprifix],0
je .nosprprio
mov dword[cursprloc],sprlefttot
call preparesprpr
.nosprprio
; calculate current video offset
xor ebx,ebx
mov bx,[curypos]
mov esi,ebx
shl esi,9
shl ebx,6
add esi,ebx
add esi,32
add esi,[vidbuffer]
mov [curvidoffset],esi
; do sprite windowing
call makewindowsp
; set palette
call setpalette16b
; clear back area w/ back color
call clearback16b
; clear registers
xor eax,eax
xor ecx,ecx
mov byte[extbgdone],0
; mode 7 extbg
test byte[interlval],40h
jz near .noback0
test byte[scrndis],02h
jnz near .noback0
; do background 1
test word[scrnon],0202h
jz near .noback0
mov byte[winon],0
test word[winenabm],0001h
jz near .nobackwin0
test word[winenabm],0100h
jnz near .nobackwin0
mov al,[winbg1en]
call makewindow
cmp byte[winon],0FFh
je near .noback0
.nobackwin0
mov byte[extbgdone],1
procmode716bextbg [bg1scroly],[bg1scrolx],1
.noback0
; do objects
test byte[scrndis],10h
jnz near .nosprites1
test word[scrnon],1010h
jz near .nosprites1
cmp byte[winonsp],0FFh
je .nosprites1
xor ebx,ebx
mov bl,[curypos]
mov cl,[sprleftpr+ebx]
cmp byte[sprprifix],0
je .nosprprio2
mov cl,[sprlefttot+ebx]
.nosprprio2
cmp cl,0
je .nosprites1
mov ebp,0
call drawsprites16b
.nosprites1
; display mode7
test byte[interlval],40h
jnz near .noback1
test byte[scrndis],01h
jnz near .noback1
; do background 1
test word[scrnon],0101h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -