copyvwin.asm
来自「linux下的任天堂模拟器代码。供大家参考。」· 汇编 代码 · 共 1,555 行 · 第 1/2 页
ASM
1,555 行
;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 vidbuffer,GUIOn,MMXSupport,resolutn,En2xSaI,antienab,scanlinesEXTSYM hirestiledat,res512switch,curblank,spritetablea,lineleft,_2xSaILineWEXTSYM _2xSaISuperEagleLineW,_2xSaISuper2xSaILineW,newengen,cfield,HalfTransEXTSYM GUIOn2,FilteredGUI,SpecialLine,vidbufferofsb,HalfTransB,HalfTransCALIGN32SECTION .bssNEWSYM AddEndBytes, resd 1 ; Number of bytes between each lineNEWSYM NumBytesPerLine, resd 1 ; Total number of bytes per line (1024+AddEndBytes)NEWSYM WinVidMemStart, resd 1SECTION .textNEWSYM copy640x480x16bwin cmp byte[curblank],40h jne .startcopy ret.startcopy mov ax,ds mov es,ax mov esi,[vidbuffer] mov edi,[WinVidMemStart] add esi,16*2+256*2+32*2%ifdef __UNIXSDL__ cmp byte[GUIOn],1 je .not239 cmp byte[resolutn],239 jne .not239 add esi,8*288*2.not239%endif xor eax,eax ; Check if interpolation mode cmp byte[FilteredGUI],0 jne .yi cmp byte[GUIOn2],1 je .nointerp.yi cmp byte[MMXSupport],1 jne .nommx cmp byte[En2xSaI],0 jne near Process2xSaIwin.nommx cmp byte[antienab],1 je near interpolate640x480x16bwin.nointerp%ifdef __UNIXSDL__ mov dl,224%else mov dl,[resolutn]%endif cmp byte[scanlines],1 je near .scanlines cmp byte[scanlines],3 je near .halfscanlines cmp byte[scanlines],2 je near .quartscanlines mov ebx,hirestiledat+1 cmp byte[newengen],0 je .loopa mov ebx,SpecialLine+1.loopa mov ecx,256 cmp byte[ebx],1 je near .yeshires cmp byte[GUIOn],1 je .ignorehr cmp byte[ebx],1 ja near .yeshiresng.ignorehr cmp byte[MMXSupport],1 je near .mmx.a mov ax,[esi] shl eax,16 mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .a sub esi,256*2 add edi,[AddEndBytes] mov ecx,256.a2 mov ax,[esi] shl eax,16 mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .a2.return add esi,64 add edi,[AddEndBytes] inc ebx dec dl jnz near .loopa xor byte[res512switch],1 cmp byte[MMXSupport],1 je .mmx2 ret.mmx2 emms ret.yeshires mov byte[ebx],0 test byte[res512switch],1 jnz .rightside push ebx mov ebx,[NumBytesPerLine].b mov ax,[esi] mov [edi],ax mov [edi+ebx],ax add esi,2 add edi,4 dec ecx jnz .b pop ebx add edi,[NumBytesPerLine] jmp .return.rightside push ebx mov ebx,[NumBytesPerLine].c mov ax,[esi] mov [edi+2],ax mov [edi+2+ebx],ax add esi,2 add edi,4 dec ecx jnz .c pop ebx add edi,[NumBytesPerLine] jmp .return.mmx mov eax,[spritetablea] mov ecx,64 add eax,512.mmxr movq mm0,[esi] movq mm1,mm0 punpcklwd mm0,mm1 movq [edi],mm0 punpckhwd mm1,mm1 movq [edi+8],mm1 movq [eax],mm0 movq [eax+8],mm1 add esi,8 add edi,16 add eax,16 dec ecx jnz .mmxr mov eax,[spritetablea] mov ecx,32 add eax,512 add edi,[AddEndBytes].mmxr2 movq mm0,[eax] movq [edi],mm0 movq mm1,[eax+8] movq [edi+8],mm1 movq mm2,[eax+16] movq [edi+16],mm2 movq mm3,[eax+24] movq [edi+24],mm3 add eax,32 add edi,32 dec ecx jnz .mmxr2 jmp .return.yeshiresng call HighResProc jmp .return.bng mov eax,[esi+75036*4-2] mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .bng add edi,[AddEndBytes] sub esi,256*2 mov ecx,256.bngb mov eax,[esi+75036*4-2] mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .bngb jmp .return.scanlines mov ebx,hirestiledat+1 cmp byte[GUIOn],1 je .loopab cmp byte[newengen],0 je .loopab mov ebx,SpecialLine+1.loopab mov ecx,256 cmp byte[ebx],1 je .yeshiresb cmp byte[ebx],1 jbe .ignorehrb call HighResProc jmp .returnb.ignorehrb cmp byte[MMXSupport],1 je near .mmxsl.ab mov ax,[esi] shl eax,16 mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .ab.returnb add esi,64 add edi,[AddEndBytes] mov ecx,256.fslloop mov dword[edi],0 add edi,4 dec ecx jnz .fslloop add edi,[AddEndBytes] inc ebx dec dl jnz .loopab xor byte[res512switch],1 cmp byte[MMXSupport],1 je near .mmx2 ret.yeshiresb mov byte[ebx],0 test byte[res512switch],1 jnz .rightsideb.bb mov ax,[esi] mov [edi],ax add esi,2 add edi,4 dec ecx jnz .bb jmp .returnb.rightsideb.cb mov ax,[esi] mov [edi+2],ax add esi,2 add edi,4 dec ecx jnz .cb jmp .returnb.mmxsl mov ecx,64.mmxrsl movq mm0,[esi] movq mm1,mm0 punpcklwd mm0,mm1 punpckhwd mm1,mm1 movq [edi],mm0 movq [edi+8],mm1 add esi,8 add edi,16 add eax,16 dec ecx jnz .mmxrsl jmp .returnb.halfscanlines mov ebx,hirestiledat+1 cmp byte[GUIOn],1 je .loopabh cmp byte[newengen],0 je .loopabh mov ebx,SpecialLine+1.loopabh cmp byte[ebx],1 jbe .ignorehrbh call HighResProc jmp .returnbh.ignorehrbh cmp byte[MMXSupport],1 je near .mmxslh mov ecx,256.abh mov ax,[esi] shl eax,16 mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .abh mov ecx,256 sub esi,512 add edi,[AddEndBytes].abhs mov ax,[esi] shl eax,16 mov ax,[esi] and eax,[HalfTrans] shr eax,1 mov [edi],eax add esi,2 add edi,4 dec ecx jnz .abhs.returnbh add esi,64 add edi,[AddEndBytes] inc ebx dec dl jnz near .loopabh cmp byte[MMXSupport],1 je near .mmx2 ret.mmxslh mov eax,[spritetablea] mov ecx,64 add eax,512.mmxrslh movq mm0,[esi] movq mm1,mm0 punpcklwd mm0,mm1 punpckhwd mm1,mm1 movq [edi],mm0 movq [edi+8],mm1 movq [eax],mm0 movq [eax+8],mm1 add esi,8 add edi,16 add eax,16 dec ecx jnz .mmxrslh mov eax,[spritetablea] mov ecx,32 add eax,512 add edi,[AddEndBytes] movq mm4,[HalfTrans].mmxr2h movq mm0,[eax] movq mm1,[eax+8] movq mm2,[eax+16] movq mm3,[eax+24] pand mm0,mm4 pand mm1,mm4 pand mm2,mm4 pand mm3,mm4 psrlw mm0,1 psrlw mm1,1 psrlw mm2,1 psrlw mm3,1 movq [edi],mm0 movq [edi+8],mm1 movq [edi+16],mm2 movq [edi+24],mm3 add eax,32 add edi,32 dec ecx jnz .mmxr2h jmp .returnbh.quartscanlines mov [lineleft],dl mov ebx,hirestiledat+1 cmp byte[GUIOn],1 je .loopabh2 cmp byte[newengen],0 je .loopabh2 mov ebx,SpecialLine+1.loopabh2 cmp byte[ebx],1 jbe .ignorehrbh2 call HighResProc jmp .returnbh2.ignorehrbh2 cmp byte[MMXSupport],1 je near .mmxslh2 mov ecx,256.abh2 mov ax,[esi] shl eax,16 mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .abh2 mov ecx,256 sub esi,512 add edi,[AddEndBytes].abhs2 mov ax,[esi] shl eax,16 mov ax,[esi] and eax,[HalfTrans] shr eax,1 mov edx,eax and edx,[HalfTrans] shr edx,1 add eax,edx mov [edi],eax add esi,2 add edi,4 dec ecx jnz .abhs2.returnbh2 add esi,64 add edi,[AddEndBytes] inc ebx dec byte[lineleft] jnz near .loopabh2 cmp byte[MMXSupport],1 je near .mmx2 ret.mmxslh2 mov eax,[spritetablea] mov ecx,64 add eax,512.mmxrslh2 movq mm0,[esi] movq mm1,mm0 punpcklwd mm0,mm1 punpckhwd mm1,mm1 movq [edi],mm0 movq [edi+8],mm1 movq [eax],mm0 movq [eax+8],mm1 add esi,8 add edi,16 add eax,16 dec ecx jnz .mmxrslh2 mov eax,[spritetablea] mov ecx,64 add eax,512 add edi,[AddEndBytes] movq mm4,[HalfTrans].mmxr2h2 movq mm0,[eax] movq mm1,[eax+8] pand mm0,mm4 pand mm1,mm4 psrlw mm0,1 psrlw mm1,1 movq mm2,mm0 movq mm3,mm1 pand mm2,mm4 pand mm3,mm4 psrlw mm2,1 psrlw mm3,1 paddd mm0,mm2 paddd mm1,mm3 movq [edi],mm0 movq [edi+8],mm1 add eax,16 add edi,16 dec ecx jnz .mmxr2h2 jmp .returnbh2HighResProc: mov ecx,256 cmp byte[ebx],3 je near .hiresmode7 cmp byte[ebx],7 je near .hiresmode7 test byte[ebx],4 jz .nofield cmp byte[scanlines],0 jne .nofield test byte[cfield],1 jz .nofield add edi,[NumBytesPerLine].nofield test byte[ebx],3 jnz near .hires.a mov ax,[esi] shl eax,16 mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .a cmp byte[scanlines],0 jne .nofield test byte[cfield],1 jnz .nofielde add edi,[NumBytesPerLine].nofielde ret.hiresmode7 cmp byte[MMXSupport],1 je .yeshiresngmmxmode7.a2 mov ax,[esi] shl eax,16 mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .a2 add edi,[AddEndBytes] sub esi,512 mov ecx,256 add esi,75036*4.a2b mov ax,[esi] shl eax,16 mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .a2b sub esi,75036*4 ret.yeshiresngmmxmode7 mov ecx,64.mmxr movq mm0,[esi] movq mm1,mm0 punpcklwd mm0,mm1 movq [edi],mm0 punpckhwd mm1,mm1 movq [edi+8],mm1 add esi,8 add edi,16 add eax,16 dec ecx jnz .mmxr add edi,[AddEndBytes] sub esi,512 add esi,75036*4 mov ecx,64.mmxrb movq mm0,[esi] movq mm1,mm0 punpcklwd mm0,mm1 movq [edi],mm0 punpckhwd mm1,mm1 movq [edi+8],mm1 add esi,8 add edi,16 add eax,16 dec ecx jnz .mmxrb sub esi,75036*4 ret.hires cmp byte[MMXSupport],1 je near .yeshiresngmmx.bng mov eax,[esi+75036*4-2] mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .bng test byte[ebx],4 jz .nofieldb cmp byte[scanlines],0 jne .nofieldb test byte[cfield],1 jnz .lowerfield add edi,[NumBytesPerLine].lowerfield ret.nofieldb cmp byte[scanlines],1 je near .scanlines cmp byte[scanlines],3 je near .halfscanlines cmp byte[scanlines],2 je near .quartscanlines add edi,[AddEndBytes] sub esi,256*2 mov ecx,256.bngb mov eax,[esi+75036*4-2] mov ax,[esi] mov [edi],eax add esi,2 add edi,4 dec ecx jnz .bngb ret.scanlines ret.yeshiresngmmx mov eax,[spritetablea] mov ecx,64 add eax,512.ngal movq mm0,[esi] movq mm1,[esi+75036*4] movq mm2,mm0 punpcklwd mm0,mm1 movq [edi],mm0 punpckhwd mm2,mm1 movq [edi+8],mm2 movq [eax],mm0 movq [eax+8],mm2 add esi,8 add edi,16 add eax,16 dec ecx jnz .ngal test byte[ebx],4 jz .nofieldc cmp byte[scanlines],0 jne .nofieldc test byte[cfield],1 jnz .lowerfieldb add edi,[NumBytesPerLine].lowerfieldb ret.nofieldc cmp byte[scanlines],1 je near .scanlines cmp byte[scanlines],3 je near .halfscanlinesmmx cmp byte[scanlines],2 je near .quartscanlinesmmx test byte[ebx+1],3 jz .noaa cmp byte[En2xSaI],0 jne near .antialias cmp byte[antienab],0 jne near .antialias.noaa add edi,[AddEndBytes] mov eax,[spritetablea] mov ecx,32 add eax,512.mmxr2 movq mm0,[eax] movq [edi],mm0 movq mm1,[eax+8] movq [edi+8],mm1 movq mm2,[eax+16] movq [edi+16],mm2 movq mm3,[eax+24] movq [edi+24],mm3 add eax,32 add edi,32 dec ecx jnz .mmxr2 ret.antialias add edi,[AddEndBytes] mov eax,[spritetablea] mov ecx,64 add eax,512 movq mm4,[HalfTrans] sub esi,256*2.mmxr2aa movq mm0,[esi+288*2] movq mm1,[esi+288*2+75036*4] movq mm2,mm0 punpcklwd mm0,mm1 punpckhwd mm2,mm1 movq mm1,[eax] movq mm3,[eax+8] pand mm0,mm4 pand mm1,mm4 pand mm2,mm4 pand mm3,mm4 psrlw mm0,1 psrlw mm1,1 psrlw mm2,1 psrlw mm3,1 paddd mm0,mm1 paddd mm2,mm3 movq [edi],mm0 movq [edi+8],mm2 add eax,16 add edi,16 add esi,8 dec ecx jnz .mmxr2aa ret.halfscanlines add edi,[AddEndBytes] sub esi,256*2 mov ecx,256.abhs mov eax,[esi+75036*4-2] mov ax,[esi] and eax,[HalfTrans] shr eax,1 mov edx,eax mov [edi],eax add esi,2 add edi,4 dec ecx jnz .abhs ret.quartscanlines add edi,[AddEndBytes] sub esi,256*2 mov ecx,256.abhs2 mov eax,[esi+75036*4-2] mov ax,[esi] and eax,[HalfTrans] shr eax,1 mov edx,eax and edx,[HalfTrans] shr edx,1 add eax,edx mov [edi],eax add esi,2 add edi,4 dec ecx jnz .abhs2 ret.halfscanlinesmmx mov eax,[spritetablea] mov ecx,32 add eax,512 add edi,[AddEndBytes] movq mm4,[HalfTrans].mmxr2h movq mm0,[eax] movq mm1,[eax+8] movq mm2,[eax+16] movq mm3,[eax+24] pand mm0,mm4 pand mm1,mm4 pand mm2,mm4 pand mm3,mm4 psrlw mm0,1 psrlw mm1,1 psrlw mm2,1 psrlw mm3,1 movq [edi],mm0 movq [edi+8],mm1 movq [edi+16],mm2 movq [edi+24],mm3
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?