winintrf.asm
来自「linux下的任天堂模拟器代码。供大家参考。」· 汇编 代码 · 共 992 行 · 第 1/2 页
ASM
992 行
db '800x600 DS F',0 ;15db '1024x768 S W',0 ;16db '1024x768 DS W',0 ;17db '1024x768 S F',0 ;18db '1024x768 DR F',0 ;19db '1024x768 DS F',0 ;20db '1024x896 R W',0 ;21db '1024x896 DR W',0 ;22db '1280x960 S W',0 ;23db '1280x960 DS W',0 ;24db '1280x960 S F',0 ;25db '1280x960 DR F',0 ;26db '1280x960 DS F',0 ;27db '1280x1024 S W',0 ;28db '1280x1024 DS W',0 ;29db '1280x1024 S F',0 ;30db '1280x1024 DR F',0 ;31db '1280x1024 DS F',0 ;32db '1600x1200 S W',0 ;33db '1600x1200 DS W',0 ;34db '1600x1200 DR F',0 ;35db '1600x1200 DS F',0 ;36db '1600x1200 S F',0 ;37db 'CUSTOM D W',0 ;38db 'CUSTOM DS F',0 ;39db 'CUSTOM W',0 ;40db 'CUSTOM S F',0 ;41db 'CUSTOM DR F',0 ;42; Video Mode Feature Availability (1 = Available, 0 = Not Available); Left side starts with Video Mode 0; 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2NEWSYM GUIWFVID, db 0,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,0,1,0,1,1; FullscreenNEWSYM GUIDSIZE, db 0,0,0,1,0,1,1,1,0,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,0,0,1; D ModesNEWSYM GUISMODE, db 0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,1,0; Win Stretched ModesNEWSYM GUIDSMODE, db 0,0,0,0,0,1,0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,0,0; Win D-Stretched ModesNEWSYM GUIKEEP43, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0,0,1,1,1,1,0; Keep 4:3 RatioNEWSYM GUIM7VID, db 0,0,0,1,0,1,1,1,0,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,0,0,1; Hires Mode 7NEWSYM GUIHQ2X, db 0,0,0,1,0,1,1,1,0,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,0,0,1; Hq2x FilterNEWSYM GUIHQ3X, db 0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,0,0,1; Hq3x FilterNEWSYM GUIHQ4X, db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,0,0,1; Hq4x FilterNEWSYM GUINTVID, db 0,0,0,0,0,1,1,1,0,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,0,0,1; NTSC FilterSECTION .text; ****************************; Input Device Stuff; ****************************; Variables related to Input Device Routines:; pl1selk,pl1startk,pl1upk,pl1downk,pl1leftk,pl1rightk,pl1Xk,; pl1Ak,pl1Lk,pl1Yk,pl1Bk,pl1Rk; (Change 1 to 2,3,4 for other players); Each of these variables contains the corresponding key pressed value; for the key data; pressed[]; - This is an array of pressed/released data (bytes) where the; corresponding key pressed value is used as the index. The value; for each entry is 0 for released and 1 for pressed. Also, when; writing keyboard data to this array, be sure to first check if; the value of the array entry is 2 or not. If it is 2, do not write 1; to that array entry. (however, you can write 0 to it); As an example, to access Player 1 L button press data, it is; done like : pressed[pl1Lk]; The 3 character key description of that array entry is accessed by the; GUI through ScanCodeListing[pl1Lk*3]; Note: When storing the input device configuration of a dynamic input; device system (ie. Win9x) rather than a static system (ie. Dos), it; is best to store in the name of the device and relative button; assignments in the configuration file, then convert it to ZSNES'; numerical corresponding key format after reading from it. And then; convert it back when writing to it back.NEWSYM UpdateDevices ; One-time input device init call WinUpdateDevices retNEWSYM JoyRead pushad call UpdateVFrame popad retSECTION .data; Total Number of Input DevicesNEWSYM NumInputDevices, dd 2; Input Device NamesNEWSYM GUIInputNamesdb 'NONE ',0db 'KEYBOARD/GAMEPAD',0db ' ',0db ' ',0db ' ',0db ' ',0db ' ',0db ' ',0db ' ',0db ' ',0db ' ',0db ' ',0db ' ',0db ' ',0db ' ',0db ' ',0; GUI Description codes for each corresponding key pressed valueNEWSYM ScanCodeListing db '---','ESC',' 1 ',' 2 ',' 3 ',' 4 ',' 5 ',' 6 ' ; 00h db ' 7 ',' 8 ',' 9 ',' 0 ',' - ',' = ','BKS','TAB' db ' Q ',' W ',' E ',' R ',' T ',' Y ',' U ',' I ' ; 10h db ' O ',' P ',' [ ',' ] ','RET','LCT',' A ',' S ' db ' D ',' F ',' G ',' H ',' J ',' K ',' L ',' : ' ; 20h db ' " ',' ~ ','LSH',' \ ',' Z ',' X ',' C ',' V ' db ' B ',' N ',' M ',' , ',' . ',' / ','RSH',' * ' ; 30h db 'LAL','SPC','CAP','F1 ','F2 ','F3 ','F4 ','F5 ' db 'F6 ','F7 ','F8 ','F9 ','F10','NUM','SCR','KP7' ; 40h db 'KP8','KP9','KP-','KP4','KP5','KP6','KP+','KP1' db 'KP2','KP3','KP0','KP.',' ',' ','OEM','F11' ; 50h db 'F12','59H','5AH','5BH','5CH','5DH','5EH','5FH' db '60H','61H','62H','63H','64H','65H','66H','67H' ; 60h db '68H','69H','6AH','6BH','6CH','6DH','6EH','6FH' db '70H','71H','72H','73H','74H','75H','76H','77H' ; 70h db '78H','79H','7AH','7BH','7CH','7DH','7EH','7FH' ; Keyboard continued (Direct Input) db '80H','81H','82H','83H','84H','85H','86H','87H' ; 80h db '88H','89H','8AH','8BH','8CH','8DH','8EH','8FH' db '90H','91H','92H','93H','94H','95H','96H','97H' ; 90h db '98H','99H','9AH','9BH','9CH','9DH','9EH','9FH' db 'A0H','A1H','A2H','A3H','A4H','A5H','A6H','A7H' ; A0h db 'A8H','A9H','AAH','ABH','ACH','ADH','AEH','AFH' db 'B0H','B1H','B2H','B3H','B4H','B5H','B6H','B7H' ; B0h db 'B8H','B9H','BAH','BBH','BCH','BDH','BEH','BFH' db 'C0H','C1H','C2H','C3H','C4H','C5H','C6H','C7H' ; C0h db 'C8H','C9H','CAH','CBH','CCH','CDH','CEH','CFH' db 'D0H','D1H','D2H','D3H','D4H','D5H','D6H','D7H' ; D0h db 'D8H','D9H','DAH','DBH','DCH','DDH','DEH','DFH' db 'E0H','E1H','E2H','E3H','E4H','E5H','E6H','E7H' ; E0h db 'E8H','E9H','EAH','EBH','ECH','EDH','EEH','EFH' db 'F0H','F1H','F2H','F3H','F4H','F5H','F6H','F7H' ; F0h db 'F8H','F9H','FAH','FBH','FCH','FDH','FEH','FFH' ; Joystick Stuff (Direct Input) db 'J00','J01','J02','J03','J04','J05','J06','J07' db 'J08','J09','J0A','J0B','J0C','J0D','J0E','J0F' db 'J10','J11','J12','J13','J14','J15','J16','J17' db 'J18','J19','J1A','J1B','J1C','J1D','J1E','J1F' db 'J20','J21','J22','J23','J24','J25','J26','J27' db 'J28','J29','J2A','J2B','J2C','J2D','J2E','J2F' db 'J30','J31','J32','J33','J34','J35','J36','J37' db 'J38','J39','J3A','J3B','J3C','J3D','J3E','J3F' db 'J40','J41','J42','J43','J44','J45','J46','J47' db 'J48','J49','J4A','J4B','J4C','J4D','J4E','J4F' db 'J50','J51','J52','J53','J54','J55','J56','J57' db 'J58','J59','J5A','J5B','J5C','J5D','J5E','J5F' db 'J60','J61','J62','J63','J64','J65','J66','J67' db 'J68','J69','J6A','J6B','J6C','J6D','J6E','J6F' db 'J70','J71','J72','J73','J74','J75','J76','J77' db 'J78','J79','J7A','J7B','J7C','J7D','J7E','J7F' ; Extra Stuff (180h) (Parallel Port) db 'PPB','PPY','PSL','PST','PUP','PDN','PLT','PRT' db 'PPA','PPX','PPL','PPR',' ',' ',' ',' ' db 'P2B','P2Y','P2S','P2T','P2U','P2D','P2L','P2R' db 'P2A','P2X','P2L','P2R',' ',' ',' ',' ' db 'PPB','PPY','PSL','PST','PUP','PDN','PLT','PRT' db 'PPA','PPX','PPL','PPR',' ',' ',' ',' ' db 'P2B','P2Y','P2S','P2T','P2U','P2D','P2L','P2R' db 'P2A','P2X','P2L','P2R',' ',' ',' ',' 'SECTION .text; ****************************; Mouse Stuff; ****************************NEWSYM Init_Mouse ; return non-zero if successful mov eax,01h retSECTION .dataNEWSYM WMouseX, dd 0NEWSYM WMouseY, dd 0NEWSYM WMouseMoveX, dd 0NEWSYM WMouseMoveY, dd 0NEWSYM WMouseButton, dd 0SECTION .textNEWSYM Get_MouseData ; Returns both pressed and coordinates ; bx : bit 0 = left button, bit 1 = right button ; cx = Mouse X Position, dx = Mouse Y Position pushad call GetMouseX mov [WMouseX],eax call GetMouseY mov [WMouseY],eax call GetMouseButton mov [WMouseButton],eax popad mov cx,[WMouseX] mov dx,[WMouseY] mov bx,[WMouseButton] retNEWSYM Set_MouseXMax ; Sets the X boundaries (ecx = left, edx = right) pushad push ecx call SetMouseMinX pop ecx push edx call SetMouseMaxX pop edx popad retNEWSYM Set_MouseYMax ; Sets the Y boundaries (ecx = left, edx = right) pushad push ecx call SetMouseMinY pop ecx push edx call SetMouseMaxY pop edx popad retNEWSYM Set_MousePosition ; Sets Mouse Position (x:cx,y:dx) pushad push ecx call SetMouseX pop ecx push edx call SetMouseY pop edx popad retNEWSYM Get_MousePositionDisplacement ; returns x,y displacement in pixel in cx,dx pushad call GetMouseMoveX mov [WMouseMoveX],eax call GetMouseMoveY mov [WMouseMoveY],eax popad mov cx,[WMouseMoveX] mov dx,[WMouseMoveY] retNEWSYM MouseWindow pushad or byte[MouseButton],2 mov byte[T36HZEnabled],1 call GetMouseButton and byte[MouseButton],0FDh popad retNEWSYM GUIInit pushad call Start36HZ popad retNEWSYM GUIDeInit pushad call Stop36HZ popad ret; ****************************; Sound Stuff; ****************************NEWSYM StopSound call Start36HZ call JoyRead retNEWSYM StartSound call Start60HZ call JoyRead retNEWSYM SoundProcess ; This function is called ~60 times/s at full speed cmp byte[soundon],0 je .nosound cmp byte[DSPDisable],1 je .nosound mov eax,256 ; Size mov [BufferSizeB],eax add eax,eax mov [BufferSizeW],eax pushad call ProcessSoundBuffer popad ; DSPBuffer should contain the processed buffer in the specified size ; You will have to convert/clip it to 16-bit for actual sound process.nosound retsection .dataNEWSYM delayvalue, dd 0section .textNEWSYM delay mov [delayvalue],ecx pushad call DoSleep popad retNEWSYM Check60hz ; Call the timer update function here pushad call CheckTimers call FrameSemaphore popad retSECTION .dataBitPosR db 11BitPosG db 5BitPosB db 0BitSizeR db 5BitSizeG db 6BitSizeB db 5SECTION .textInitializeGfxStuff: ; Process Red Stuff mov al,[BitPosR] mov cl,al mov bx,1 shl bx,cl cmp byte[BitSizeR],6 jne .no6bit mov [vesa2_usbit],bx inc al.no6bit or [vesa2_clbit],bx mov [vesa2_rpos],al dec al mov cl,al mov bx,001Fh cmp cl,0FFh je .shrr shl bx,cl jmp .shlr.shrr shr bx,1.shlr mov [vesa2_rfull],bx add al,5 mov bx,1 mov cl,al shl bx,cl mov [vesa2_rtrcl],bx xor bx,0FFFFh mov [vesa2_rtrcla],bx ; Process Green Stuff mov al,[BitPosG] mov cl,al mov bx,1 shl bx,cl cmp byte[BitSizeG],6 jne .no6bitb mov [vesa2_usbit],bx inc al.no6bitb or [vesa2_clbit],bx mov [vesa2_gpos],al dec al mov cl,al mov bx,001Fh cmp cl,0FFh je .shrg shl bx,cl jmp .shlg.shrg shr bx,1.shlg mov [vesa2_gfull],bx add al,5 mov bx,1 mov cl,al shl bx,cl mov [vesa2_gtrcl],bx xor bx,0FFFFh mov [vesa2_gtrcla],bx ; Process Blue Stuff mov al,[BitPosB] mov cl,al mov bx,1 shl bx,cl cmp byte[BitSizeB],6 jne .no6bitc mov [vesa2_usbit],bx inc al.no6bitc or [vesa2_clbit],bx mov [vesa2_bpos],al dec al mov cl,al mov bx,001Fh cmp cl,0FFh je .shrb shl bx,cl jmp .shlb.shrb shr bx,1.shlb mov [vesa2_bfull],bx add al,5 mov bx,1 mov cl,al shl bx,cl mov [vesa2_btrcl],bx xor bx,0FFFFh mov [vesa2_btrcla],bx xor word[vesa2_clbit],0FFFFh call genfulladdtab cmp byte[converta],1 je .red10 mov eax,565 jmp .red11.red10 mov eax,555.red11 push eax call Init_2xSaIMMXW pop eax ret%macro SetDefaultKey2 13 mov dword[%1upk],%4 ; Up mov dword[%1downk],%5 ; Down mov dword[%1leftk],%6 ; Left mov dword[%1rightk],%7 ; Right mov dword[%1startk],%3 ; Start mov dword[%1selk],%2 ; Select mov dword[%1Ak],%9 ; A mov dword[%1Bk],%12 ; B mov dword[%1Xk],%8 ; X mov dword[%1Yk],%11 ; Y mov dword[%1Lk],%10 ; L mov dword[%1Rk],%13 ; R%endmacro%macro SetDefaultKey 12 cmp bh,0 jne %%nopl1 SetDefaultKey2 pl1,%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12%%nopl1 cmp bh,1 jne %%nopl2 SetDefaultKey2 pl2,%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12%%nopl2 cmp bh,2 jne %%nopl3 SetDefaultKey2 pl3,%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12%%nopl3 cmp bh,3 jne %%nopl4 SetDefaultKey2 pl4,%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12%%nopl4 cmp bh,4 jne %%nopl5 SetDefaultKey2 pl5,%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12%%nopl5%endmacroNEWSYM SetInputDevice ; bl = device #, bh = player # (0-4) ; Sets keys according to input device selected cmp bl,0 jne near .nozero SetDefaultKey 0,0,0,0,0,0,0,0,0,0,0,0 ret.nozero cmp bh,1 je near .input2 SetDefaultKey 54,28,200,208,203,205,31,45,32,30,44,46 ret.input2 SetDefaultKey 56,29,36,50,49,51,210,199,201,211,207,209 ret
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?