makevid.asm

来自「linux下的任天堂模拟器代码。供大家参考。」· 汇编 代码 · 共 3,364 行 · 第 1/5 页

ASM
3,364
字号
;Copyright (C) 1997-2007 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach );;http://www.zsnes.com;http://sourceforge.net/projects/zsnes;https://zsnes.bountysource.com;;This program is free software; you can redistribute it and/or;modify it under the terms of the GNU General Public License;version 2 as published by the Free Software Foundation.;;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,winlogicaEXTSYM winenabm,winobjen,winlogicb,scrndis,scrnon,bgmode,bgtilesz,winbg1enEXTSYM winenabs,bg1objptr,bg1ptr,bg1ptrb,bg1ptrc,bg1ptrd,bg1scrolx,bg1scrolyEXTSYM cachebg1,curbgofs1,curcolbg1,vcache2b,vcache4b,vcache8bEXTSYM vidbuffer,bg3highst,cbitmode,colormodedef,ngptrdat2EXTSYM colormodeofs,drawline16b,forceblnk,newengine8b,preparesprpr,scaddsetEXTSYM spritetablea,sprleftpr,vidbright,ForceNewGfxOff,curypos,drawmode7EXTSYM mode7set,mosaicon,mosaicsz,sprleftpr1,sprleftpr2,sprleftpr3,sprlefttotEXTSYM sprprifix,drawmode7extbg,interlval,drawmode7extbg2,sprclprio,sprpriodataEXTSYM sprsingle,cachetile2b,cachetile4b,cachetile8b,vram,newengen,ofshvaladdEXTSYM cachetile2b16x16,cachetile4b16x16,cachetile8b16x16,osm2dis,xtravbufEXTSYM bg3ptr,bg3scrolx,bg3scroly,vidmemch4,ofsmcptr,ofsmady,ofsmadx,yposngomEXTSYM flipyposngom,ofsmtptr,ofsmmptr,ofsmcyps,bgtxadd,bg1ptrx,bg1ptryEXTSYM bg1scrolx_m7,bg1scroly_m7,OMBGTestVal,Testval,cachesingle4bng,m7startyEXTSYM ofsmtptrs,ofsmcptr2%include "video/vidmacro.mac"SECTION .bssNEWSYM bgcoloradder, resb 1NEWSYM res512switch, resb 1SECTION .text;*******************************************************; 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]    inc ax    test byte[mode7set],02h    jz %%noflip    neg ax    add ax,255%%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    mov [m7starty],ax    mov ax,%1    mov dx,%2    call drawmode7%endmacro%macro procmode7extbg 3    xor eax,eax    xor edx,edx    mov ax,[curypos]    inc ax    test byte[mode7set],02h    jz %%noflip    neg ax    add ax,255%%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    mov [m7starty],ax    mov ax,%1    mov dx,%2    call drawmode7extbg%endmacro%macro procmode7extbg2 3    xor eax,eax    xor edx,edx    mov ax,[curypos]    inc ax    test byte[mode7set],02h    jz %%noflip    neg ax    add ax,255%%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    mov [m7starty],ax    mov ax,%1    mov dx,%2    call drawmode7extbg2%endmacroSECTION .dataNEWSYM MosaicYAdder, dw 0,0,0,1,0,2,1,0,0,4,2,2,3,1,0,7NEWSYM cwinptr,    dd winbgdataSECTION .bssNEWSYM pwinbgenab, resb 1NEWSYM pwinbgtype, resd 1NEWSYM winonbtype, resb 1NEWSYM dualwinbg,  resb 1NEWSYM pwinspenab, resb 1NEWSYM pwinsptype, resd 1NEWSYM winonstype, resb 1NEWSYM dualwinsp,  resb 1NEWSYM dwinptrproc, resd 1SECTION .text; is this macro even used?%macro ClearWindowData 0    mov edi,winbgdata+16    xor eax,eax    mov ecx,64    rep stosd%endmacroNEWSYM 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    retNEWSYM 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],1NEWSYM 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 dualwinxnorNEWSYM 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    retNEWSYM 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    retNEWSYM 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    cmp dh,254    jae near .clipped.nooutclip    mov edi,[dwinptrproc]    xor eax,eax    ; start drawing 1's from 0 to left.nextdoti    xor 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    xor byte[edi+eax],1    inc al    jnz .nextdot3i.nextdot4i.donextwin    retNEWSYM dualwinxnor    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

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?