📄 makevid.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 disableeffects,winl1,winl2,winbgdata,winr1,winr2,winspdata
EXTSYM winlogica
EXTSYM winenabm,winobjen
EXTSYM winlogicb
EXTSYM scrndis,scrnon
EXTSYM bgmode,bgtilesz,winbg1en,winenabs
EXTSYM bg1objptr,bg1ptr,bg1ptrb,bg1ptrc,bg1ptrd,bg1scrolx,bg1scroly
EXTSYM cachebg1,curbgofs1,curcolbg1,vcache2b,vcache4b,vcache8b
EXTSYM vcache2ba,vcache4ba,vcache8ba
EXTSYM vidbuffer
EXTSYM bg3highst,cbitmode,colormodedef,colormodeofs,drawline16b
EXTSYM forceblnk,newengine8b,preparesprpr,scaddset,spritetablea
EXTSYM sprleftpr,vidbright,ForceNewGfxOff
EXTSYM curypos,drawmode7,mode7set,mosaicon,mosaicsz,sprleftpr1,sprleftpr2
EXTSYM sprleftpr3,sprlefttot,sprprifix,drawmode7extbg,interlval,drawmode7extbg2
EXTSYM sprclprio,sprpriodata,sprsingle
EXTSYM cachetile2b,cachetile4b,cachetile8b,vram,CacheCheckSkip
EXTSYM cachetile2b16x16,cachetile4b16x16,cachetile8b16x16
EXTSYM osm2dis,xtravbuf
EXTSYM bg3ptr,bg3scrolx,bg3scroly,cachesingle,colormoded2
EXTSYM tempoffset,vidmemch2,vidmemch4,vidmemch8
EXTSYM ofsmcptr,ofsmady,ofsmadx,yposng,yposngom,flipyposng,flipyposngom
EXTSYM ofsmtptr,ofsmmptr,ofsmcyps,bgtxadd,bg1ptrx,bg1ptry
NEWSYM MakeVidAsmStart
%include "video/vidmacro.mac"
;drawspritesprio
NEWSYM bgcoloradder, db 0
NEWSYM res512switch, db 0
; mov cl,[bshifter]
;*******************************************************
; DrawLine Draws the current line
;*******************************************************
; use curypos+bg1scroly for y location and bg1scrolx for x location
; use bg1ptr(b,c,d) for the pointer to the tile number contents
; use bg1objptr for the pointer to the object tile contents
%macro decideonmode 0
cmp bl,2
je .yes4bit
cmp bl,1
je .yes2bit
mov byte[bshifter],6
mov edx,[vcache8b]
jmp .skipbits
.yes4bit
mov byte[bshifter],2
mov edx,[vcache4b]
shl eax,1
jmp .skipbits
.yes2bit
mov byte[bshifter],0
shl eax,2
mov edx,[vcache2b]
.skipbits
%endmacro
%macro procmode7 3
xor eax,eax
xor edx,edx
mov ax,[curypos]
test byte[mode7set],02h
jz %%noflip
mov ax,261
sub ax,[curypos]
%%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 edx,edx
xor bh,bh
div bx
xor edx,edx
mul bx
xor edx,edx
mov dl,[mosaicsz]
add ax,[MosaicYAdder+edx*2]
%%nomos
add ax,%1
mov dx,%2
call drawmode7
%endmacro
%macro procmode7extbg 3
xor eax,eax
xor edx,edx
mov ax,[curypos]
test byte[mode7set],02h
jz %%noflip
mov ax,261
sub ax,[curypos]
%%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 edx,edx
xor bh,bh
div bx
xor edx,edx
mul bx
xor edx,edx
mov dl,[mosaicsz]
add ax,[MosaicYAdder+edx*2]
%%nomos
add ax,%1
mov dx,%2
call drawmode7extbg
%endmacro
%macro procmode7extbg2 3
xor eax,eax
xor edx,edx
mov ax,[curypos]
test byte[mode7set],02h
jz %%noflip
mov ax,261
sub ax,[curypos]
%%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 edx,edx
xor bh,bh
div bx
xor edx,edx
mul bx
xor edx,edx
mov dl,[mosaicsz]
add ax,[MosaicYAdder+edx*2]
%%nomos
add ax,%1
mov dx,%2
call drawmode7extbg2
%endmacro
NEWSYM MosaicYAdder, dw 0,0,0,1,0,2,1,0,0,4,2,2,3,1,0,7
NEWSYM pwinbgenab, db 0
NEWSYM pwinbgtype, dd 0
NEWSYM winonbtype, db 0
NEWSYM dualwinbg, db 0
NEWSYM pwinspenab, db 0
NEWSYM pwinsptype, dd 0
NEWSYM winonstype, db 0
NEWSYM dualwinsp, db 0
NEWSYM cwinptr, dd winbgdata
NEWSYM dwinptrproc, dd 0
; is this macro even used?
%macro ClearWindowData 0
mov edi,winbgdata+16
xor eax,eax
mov ecx,64
rep stosd
%endmacro
NEWSYM makewindow
; upon entry, al = win enable bits
cmp byte[disableeffects],1
je near .finishwin
mov bl,al
and bl,00001010b
cmp bl,00001010b
je near makedualwin
cmp bl,0
je near .finishwin
mov byte[winon],1
mov ebx,[winl1]
; check if data matches previous sprite data
cmp al,[pwinspenab]
jne .skipsprcheck
cmp ebx,[pwinsptype]
jne .skipsprcheck
mov dword[cwinptr],winspdata+16
mov al,[winonstype]
mov [winon],al
ret
.skipsprcheck
; check if data matches previous data
cmp al,[pwinbgenab]
jne .skipenab
cmp ebx,[pwinbgtype]
jne .skipenab2
mov dword[cwinptr],winbgdata+16
mov al,[winonbtype]
mov [winon],al
ret
.skipenab
mov [pwinbgenab],al
mov ebx,[winl1]
.skipenab2
mov [pwinbgtype],ebx
mov dl,[winl1]
mov dh,[winr1]
test al,00000010b
jnz .win1
mov dl,[winl2]
mov dh,[winr2]
shr al,2
.win1
test al,01h
jnz near .outside
cmp dl,254
je .clipped
cmp dl,dh
jb .clip
.clipped
mov byte[winon],0
mov byte[winonbtype],0
ret
.clip
mov edi,winbgdata+16
xor eax,eax
; start drawing 1's from 0 to left
cmp dl,0
je .nextdot2
.nextdot
mov byte[edi+eax],0
inc al
cmp al,dl
jb .nextdot ; blah
.nextdot2
mov byte[edi+eax],1
inc al
cmp al,dh
jb .nextdot2
mov byte[edi+eax],1
cmp dh,255
je .nextdot4
; start drawing 1's from right to 255
.nextdot3
mov byte[edi+eax],0
inc al
jnz .nextdot3
.nextdot4
mov byte[winon],1
mov byte[winonbtype],1
mov dword[cwinptr],winbgdata+16
ret
.outside
cmp dl,dh
jb .clip2
mov byte[winon],0FFh
mov byte[winonbtype],0FFh
mov dword[cwinptr],winbgdata+16
ret
.clip2
cmp dl,1
ja .nooutclip
cmp dh,254
jae near .clipped
.nooutclip
mov edi,winbgdata+16
xor eax,eax
; start drawing 1's from 0 to left
.nextdoti
mov byte[edi+eax],1
inc al
cmp al,dl
jb .nextdoti
.nextdot2i
mov byte[edi+eax],0
inc al
cmp al,dh
jb .nextdot2i
mov byte[edi+eax],0
cmp al,255
je .nextdot4i
inc al
; start drawing 1's from right to 255
.nextdot3i
mov byte[edi+eax],1
inc al
jnz .nextdot3i
.nextdot4i
mov byte[winon],1
mov byte[winonbtype],1
mov dword[cwinptr],winbgdata+16
ret
.finishwin
ret
NEWSYM makedualwin
mov ecx,ebp
shl cl,1
mov dl,[winlogica]
shr dl,cl
and dl,03h
mov cl,dl
mov byte[winon],1
mov ebx,[winl1]
; check if data matches previous sprite data
cmp cl,[dualwinsp]
jne .skipsprcheck
cmp al,[pwinspenab]
jne .skipsprcheck
cmp ebx,[pwinsptype]
jne .skipsprcheck
mov dword[cwinptr],winspdata+16
mov al,[winonstype]
mov [winon],al
ret
.skipsprcheck
; check if data matches previous data
cmp cl,[dualwinbg]
jne .skipenab3
cmp al,[pwinbgenab]
jne .skipenab
cmp ebx,[pwinbgtype]
jne .skipenab2
mov dword[cwinptr],winbgdata+16
mov al,[winonbtype]
mov [winon],al
ret
.skipenab3
mov [dualwinbg],cl
.skipenab
mov [pwinbgenab],al
mov ebx,[winl1]
.skipenab2
mov [pwinbgtype],ebx
mov dword[dwinptrproc],winbgdata+16
mov dword[cwinptr],winbgdata+16
mov byte[winon],1
mov byte[winonbtype],1
NEWSYM dualstartprocess
mov dl,[winl1]
mov dh,[winr1]
push eax
push ecx
test al,01h
jnz near .outside
cmp dl,254
je .clipped
cmp dl,dh
jb .clip
.clipped
mov edi,[dwinptrproc]
xor eax,eax
mov ecx,64
rep stosd
jmp .donextwin
.clip
mov edi,[dwinptrproc]
xor eax,eax
; start drawing 1's from 0 to left
cmp dl,0
je .nextdot2
.nextdot
mov byte[edi+eax],0
inc al
cmp al,dl
jbe .nextdot
.nextdot2
mov byte[edi+eax],1
inc al
cmp al,dh
jb .nextdot2
mov byte[edi+eax],1
cmp dh,255
je .nextdot4
; start drawing 1's from right to 255
.nextdot3
mov byte[edi+eax],0
inc al
jnz .nextdot3
.nextdot4
jmp .donextwin
.outside
cmp dl,dh
jb .clip2
mov edi,[dwinptrproc]
mov eax,01010101h
mov ecx,64
rep stosd
jmp .donextwin
.clip2
cmp dl,1
ja .nooutclip
cmp dh,254
jae near .clipped
.nooutclip
mov edi,[dwinptrproc]
xor eax,eax
; start drawing 1's from 0 to left
.nextdoti
mov byte[edi+eax],1
inc al
cmp al,dl
jb .nextdoti
.nextdot2i
mov byte[edi+eax],0
inc al
cmp al,dh
jb .nextdot2i
mov byte[edi+eax],0
cmp al,255
je .nextdot4i
inc al
; start drawing 1's from right to 255
.nextdot3i
mov byte[edi+eax],1
inc al
jnz .nextdot3i
.nextdot4i
.donextwin
pop ecx
pop eax
cmp cl,0
je near dualwinor
cmp cl,2
je near dualwinxor
cmp cl,3
je near dualwinxnor
NEWSYM dualwinand
mov dl,[winl2]
mov dh,[winr2]
test al,04h
jnz near .outside
cmp dl,254
je .clipped
cmp dl,dh
jb .clip
.clipped
mov edi,[dwinptrproc]
xor eax,eax
mov ecx,64
rep stosd
jmp .donextwin
.clip
mov edi,[dwinptrproc]
xor eax,eax
; start drawing 1's from 0 to left
cmp dl,0
je .nextdot2
.nextdot
mov byte[edi+eax],0
inc al
cmp al,dl
jbe .nextdot
.nextdot2
and byte[edi+eax],1
inc al
cmp al,dh
jb .nextdot2
and byte[edi+eax],1
cmp dh,255
je .nextdot4
; start drawing 1's from right to 255
.nextdot3
mov byte[edi+eax],0
inc al
jnz .nextdot3
.nextdot4
jmp .donextwin
.outside
cmp dl,dh
jb .clip2
jmp .donextwin
.clip2
cmp dl,1
ja .nooutclip
cmp dh,254
jae near .clipped
.nooutclip
mov edi,[dwinptrproc]
xor eax,eax
; start drawing 1's from 0 to left
.nextdoti
and byte[edi+eax],1
inc al
cmp al,dl
jb .nextdoti
.nextdot2i
mov byte[edi+eax],0
inc al
cmp al,dh
jb .nextdot2i
mov byte[edi+eax],0
cmp al,255
je .nextdot4i
inc al
; start drawing 1's from right to 255
.nextdot3i
and byte[edi+eax],1
inc al
jnz .nextdot3i
.nextdot4i
.donextwin
ret
NEWSYM dualwinor
mov dl,[winl2]
mov dh,[winr2]
test al,04h
jnz near .outside
cmp dl,254
je .clipped
cmp dl,dh
jb .clip
.clipped
jmp .donextwin
.clip
mov edi,[dwinptrproc]
xor eax,eax
; start drawing 1's from 0 to left
cmp dl,0
je .nextdot2
mov al,dl
inc al
.nextdot2
mov byte[edi+eax],1
inc al
cmp al,dh
jb .nextdot2
mov byte[edi+eax],1
jmp .donextwin
.outside
cmp dl,dh
jb .clip2
mov edi,[dwinptrproc]
mov eax,01010101h
mov ecx,64
rep stosd
jmp .donextwin
.clip2
cmp dl,1
ja .nooutclip
cmp dh,254
jae near .clipped
.nooutclip
mov edi,[dwinptrproc]
xor eax,eax
; start drawing 1's from 0 to left
.nextdoti
mov byte[edi+eax],1
inc al
cmp al,dl
jb .nextdoti
mov al,dh
cmp al,255
je .nextdot4i
inc al
; start drawing 1's from right to 255
.nextdot3i
mov byte[edi+eax],1
inc al
jnz .nextdot3i
.nextdot4i
.donextwin
ret
NEWSYM dualwinxor
mov dl,[winl2]
mov dh,[winr2]
test al,04h
jnz near .outside
cmp dl,254
je .clipped
cmp dl,dh
jb .clip
.clipped
jmp .donextwin
.clip
mov edi,[dwinptrproc]
xor eax,eax
; start drawing 1's from 0 to left
cmp dl,0
je .nextdot2
mov al,dl
inc al
.nextdot2
xor byte[edi+eax],1
inc al
cmp al,dh
jb .nextdot2
xor byte[edi+eax],1
jmp .donextwin
.outside
cmp dl,dh
jb .clip2
mov edi,[dwinptrproc]
mov ecx,64
.loopxor
xor dword[edi],01010101h
add edi,4
dec ecx
jnz .loopxor
jmp .donextwin
.clip2
cmp dl,1
ja .nooutclip
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -