📄 winintrf.asm
字号:
;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 GUIkeydelay2,SBHDMAEXTSYM soundon,DSPDisable,Start60HZ,pressed,putchar,getchEXTSYM vidbufferofsb,vidbuffer,clearwin,Stop60HZ,initwinvideo,vesa2_rposEXTSYM vesa2_gpos,vesa2_bpos,vesa2_rposng,vesa2_gposng,vesa2_bposng,vesa2_usbitEXTSYM vesa2_clbit,vesa2_clbitng,vesa2_clbitng2,vesa2_clbitng3,vesa2red10,res640EXTSYM res480,cbitmode,cvidmode,vesa2_bits,vesa2_x,vesa2_y,genfulladdtab,GUICPCEXTSYM drawscreenwin,ConvertToAFormat,HalfTrans,UnusedBitXor,UnusedBitEXTSYM ngrposng,nggposng,ngbposng,HalfTransB,HalfTransCEXTSYM WinUpdateDevices,UpdateVFrame,GetMouseX,GetMouseY,GetMouseMoveXEXTSYM GetMouseMoveY,GetMouseButton,SetMouseMinX,SetMouseMaxX,SetMouseMinYEXTSYM SetMouseMaxY,SetMouseX,SetMouseY,T36HZEnabled,MouseButton,Start36HZEXTSYM Stop36HZ,BufferSizeW,BufferSizeB,ProcessSoundBuffer,CheckTimersEXTSYM vesa2_rfull,vesa2_rtrcl,vesa2_rtrcla,vesa2_gfull,vesa2_gtrcl,vesa2_gtrclaEXTSYM vesa2_bfull,vesa2_btrcl,vesa2_btrcla,Init_2xSaIMMXW,DoSleepEXTSYM V8Mode,GrayscaleMode,PrevWinMode,PrevFSMode,FrameSemaphoreEXTSYM DisplayWIPDisclaimerEXTSYM pl1upk,pl1downk,pl1leftk,pl1rightk,pl1startk,pl1selkEXTSYM pl1Ak,pl1Bk,pl1Xk,pl1Yk,pl1Lk,pl1RkEXTSYM pl2upk,pl2downk,pl2leftk,pl2rightk,pl2startk,pl2selkEXTSYM pl2Ak,pl2Bk,pl2Xk,pl2Yk,pl2Lk,pl2RkEXTSYM pl3upk,pl3downk,pl3leftk,pl3rightk,pl3startk,pl3selkEXTSYM pl3Ak,pl3Bk,pl3Xk,pl3Yk,pl3Lk,pl3RkEXTSYM pl4upk,pl4downk,pl4leftk,pl4rightk,pl4startk,pl4selkEXTSYM pl4Ak,pl4Bk,pl4Xk,pl4Yk,pl4Lk,pl4RkEXTSYM pl5upk,pl5downk,pl5leftk,pl5rightk,pl5startk,pl5selkEXTSYM pl5Ak,pl5Bk,pl5Xk,pl5Yk,pl5Lk,pl5Rk; NOTE: For timing, Game60hzcall should be called at 50hz or 60hz (depending; on romispal) after a call to InitPreGame and before DeInitPostGame are; made. GUI36hzcall should be called at 36hz after a call GUIInit and; before GUIDeInit.SECTION .textNEWSYM StartUp ret; SystemInit - Initialize all Joystick stuff, load in all configuration data,; parse commandline data, obtain current directory (One time initialization)NEWSYM SystemInit ; Be sure to set SBHDMA to a value other than 0 if 16bit sound exists%ifndef __RELEASE__ pushad call DisplayWIPDisclaimer popad%endif mov byte[SBHDMA],1 retNEWSYM PrintStr ; Print ASCIIZ string pushad.next mov al,[edx] or al,al jz .finish push edx mov dl,al push edx call putchar pop edx; mov ah,02h; int 21h pop edx inc edx jmp .next.finish popad retSECTION .dataNEWSYM wfkey, db 0SECTION .textNEWSYM WaitForKey ; Wait for a key to be pressed pushad call getch mov [wfkey],al popad mov al,[wfkey] ;mov ah,7 ;int 21h ; return key in al retRefreshKeybBuffer: call JoyRead mov ebx,[HoldKey] cmp byte[pressed+ebx],0 jne .holding mov dword[HoldKey],0.holding xor eax,eax xor ebx,ebx.loop cmp byte[PKeyBuf+eax],0 jne .not1 cmp byte[pressed+eax],0 je .not1 mov byte[PKeyBuf+eax],1 mov ebx,eax.not1 cmp byte[pressed+eax],0 jne .not0 mov byte[PKeyBuf+eax],0.not0 inc eax cmp eax,100h jne .loop or ebx,ebx jz .notpressed mov [HoldKey],ebx mov byte[GUIkeydelay2],14 call .processkey.notpressed ; Execute the following at 36hz cmp dword[HoldKey],0 je .noholder cmp byte[GUIkeydelay2],0 jne .noholder mov byte[GUIkeydelay2],3 call .processkey.noholder ret.processkey mov ebx,[HoldKey] cmp ebx,0A8h jb .skipdecval add ebx,-80h.skipdecval cmp ebx,58h jae .none movzx eax,byte[Keybtail] inc al and al,0Fh cmp al,[Keybhead] je .none mov al,[Keybtail] mov cl,[KeyConvTable+ebx] cmp byte[pressed+2Ah],0 jne .shift cmp byte[pressed+36h],0 je .noshift.shift mov cl,[KeyConvTableS+ebx].noshift mov [HoldKeyBuf+eax],cl inc al and al,0Fh mov [Keybtail],al.none retSECTION .dataKeybhead db 0Keybtail db 0HoldKey dd 0HoldKeyBuf times 16 db 0PKeyBuf times 100h db 0NEWSYM CurKeyPos, dd 0NEWSYM CurKeyReadPos, dd 0NEWSYM KeyBuffer, times 16 dd 0SECTION .textNEWSYM Check_Key mov al,[CurKeyPos] cmp al,[CurKeyReadPos] jne .yeskey xor al,al ret.yeskey mov al,0FFh ret ; returns 0 if there are no keys in the keyboard buffer, 0xFF otherwise pushad call RefreshKeybBuffer mov byte[wfkey],0 mov al,[Keybhead] cmp al,[Keybtail] je .nokeys mov byte[wfkey],0FFh.nokeys popad mov al,[wfkey]; mov ah,0Bh; int 21h retNEWSYM Get_Key ; wait if there are no keys in buffer, then return key in al ; for extended keys, return a 0, then the extended key afterwards xor eax,eax.nokey; call JoyRead mov al,[CurKeyReadPos] cmp al,[CurKeyPos] je .nokey test word[KeyBuffer+eax*4],100h jnz .upper mov al,[KeyBuffer+eax*4] inc dword[CurKeyReadPos] and dword[CurKeyReadPos],0Fh ret.upper add word[KeyBuffer+eax*4],-100h xor al,al ret pushad.nonewkey call RefreshKeybBuffer movzx eax,byte[Keybhead] cmp al,[Keybtail] je .nonewkey mov bl,[HoldKeyBuf+eax] test bl,80h jz .notupperkey xor bl,bl add byte[HoldKeyBuf+eax],-80h jmp .yesupperkey.notupperkey inc al and al,0Fh mov [Keybhead],al.yesupperkey; call getch mov [wfkey],bl popad mov al,[wfkey] ;mov ah,7 ;int 21h ; return key in al retSECTION .dataKeyConvTable: db 255,27 ,'1','2','3','4','5','6' ; 00h db '7','8','9','0','-','=',8 ,9 db 'Q','W','E','R','T','Y','U','I' ; 10h db 'O','P','[',']',13 ,255,'A','S' db 'D','F','G','H','J','K','L',';' ; 20h db 39 ,'`',255,'\','Z','X','C','V' db 'B','N','M',',','.','/',255,'*' ; 30h db 255,32 ,255,255,255,255,255,255 db 255,255,255,255,255,255,255,255 ; 40h db 200,201,202,203,204,205,206,207 db 208,209,210,211,255,255,255,255 ; 50hKeyConvTableS: db 255,27 ,'!','@','#','$','%','^' ; 00h db '&','*','(',')','_','+',8 ,9 db 'Q','W','E','R','T','Y','U','I' ; 10h db 'O','P','{','}',13 ,255,'A','S' db 'D','F','G','H','J','K','L',':' ; 20h db '"','~',255,'|','Z','X','C','V' db 'B','N','M','<','>','?',255,'*' ; 30h db 255,32 ,255,255,255,255,255,255 db 255,255,255,255,255,255,255,255 ; 40h db 200,201,202,203,204,205,206,207 db 208,209,210,211,255,255,255,255 ; 50hSECTION .textNEWSYM Get_Memfree mov eax,02000000h; mov ax,0500h; mov edi,edx; int 31h retNEWSYM Output_Text ; Output character (ah=02h) or string (ah=09h) pushad ; This function usually displays an error message on-screen cmp ah,02h je .char cmp ah,09h je .string ret.char push edx call putchar pop edx; int 21h ; print dl popad ret.string pushad call PrintStr ; print edx popad popad retNEWSYM InitPreGame ; Executes before starting/continuing a game mov byte[pressed+1],2 pushad call Start60HZ popad pushad call initwinvideo popad mov al,[GrayscaleMode] cmp al,[V8Mode] je .nochangemode xor byte[V8Mode],1 xor al,al.nochangemode pushad xor eax,eax mov edi,[vidbufferofsb] mov ecx,288*128 rep stosd popad pushad call clearwin popad ret ; set up interrupt handler ; get old handler pmode mode address ; Process stuff such as sound init, interrupt initialization retNEWSYM SetupPreGame ; Executes after pre-game init, can execute multiple ; times after a single InitPreGame mov byte[pressed+1],2 retNEWSYM DeInitPostGame ; Called after game is ended pushad call Stop60HZ popad ret; ****************************; Video Stuff; ****************************; ** init video mode functions **SECTION .dataNEWSYM firstvideo, dd 1SECTION .textNEWSYM initvideo ; Returns 1 in videotroub if trouble occurs mov byte[res640],1 mov byte[res480],1 mov byte[cbitmode],1 mov word[vesa2_x],512 mov word[vesa2_y],480 mov byte[vesa2_bits],16 mov dword[vesa2_bits],16 mov dword[vesa2_rpos],11 mov dword[vesa2_gpos],5 mov dword[vesa2_bpos],0 mov byte[vesa2red10],0 mov byte[vesa2_rposng],11 mov byte[vesa2_gposng],5 mov byte[vesa2_bposng],0 mov dword[vesa2_clbitng],1111011111011110b mov dword[vesa2_clbitng2],11110111110111101111011111011110b mov dword[vesa2_clbitng2+4],11110111110111101111011111011110b mov dword[vesa2_clbitng3],0111101111101111b pushad call initwinvideo popad movzx eax,byte[cvidmode] cmp byte[GUIWFVID+eax],0 je .prevwinmode mov [PrevFSMode],al jmp .doneprevmode.prevwinmode mov [PrevWinMode],al.doneprevmode cmp dword[firstvideo],1 je .skipinitgfx pushad call InitializeGfxStuff popad.skipinitgfx mov dword[firstvideo],0 pushad call InitializeGfxStuff popad retNEWSYM deinitvideo ret; ** copy video mode functions **SECTION .dataNEWSYM converta, dd 0SECTION .textNEWSYM DrawScreen ; In-game screen render w/ triple buffer check cmp dword[converta],1 jne near .skipconv pushad mov dword[UnusedBit], 10000000000000001000000000000000b mov dword[HalfTrans], 01111011110111100111101111011110b mov dword[UnusedBitXor], 01111111111111110111111111111111b mov dword[UnusedBit+4], 10000000000000001000000000000000b mov dword[HalfTrans+4], 01111011110111100111101111011110b mov dword[UnusedBitXor+4],01111111111111110111111111111111b mov dword[HalfTransB], 00000100001000010000010000100001b mov dword[HalfTransB+4], 00000100001000010000010000100001b mov dword[HalfTransC], 01111011110111100111101111011110b mov dword[HalfTransC+4], 01111011110111100111101111011110b mov dword[ngrposng],10 mov dword[nggposng],5 mov dword[ngbposng],0 call ConvertToAFormat popad.skipconv pushad call drawscreenwin popad ret; jmp DosDrawScreenNEWSYM vidpastecopyscr ; GUI screen render pushad mov eax,[vidbuffer] mov ecx,224*288 mov edx,ecx add ecx,-288 dec edx.loop movzx ebx,byte[eax+edx] mov bx,[GUICPC+ebx*2] mov [eax+edx*2],bx dec edx dec ecx jnz .loop popad jmp DrawScreen; ** Video Mode Variables **SECTION .data; Total Number of Video ModesNEWSYM NumVideoModes, dd 43; GUI Video Mode Names - Make sure that all names are of the same length; and end with a NULL terminatorNEWSYM GUIVideoModeNamesdb '256x224 R W',0 ;0db '256x224 R F',0 ;1db '512x448 R W',0 ;2db '512x448 DR W',0 ;3db '640x480 S W',0 ;4db '640x480 DS W',0 ;5db '640x480 DR F',0 ;6db '640x480 DS F',0 ;7db '640x480 S F',0 ;8db '768x672 R W',0 ;9db '768x672 DR W',0 ;10db '800x600 S W',0 ;11db '800x600 DS W',0 ;12db '800x600 S F',0 ;13db '800x600 DR F',0 ;14
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -