📄 sdlintrf.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 DosExit, ZFileSystemInit
EXTSYM getcmdline,GUIRestoreVars,getcfg,obtaindir,ConvertJoyMap,tparms
EXTSYM preparedir,SBHDMA
EXTSYM ccmdline
EXTSYM FilenameStart
EXTSYM spcon
EXTSYM cfgsoundon
EXTSYM pl1selk
EXTSYM pl1startk
EXTSYM pl1upk
EXTSYM pl1downk
EXTSYM pl1leftk
EXTSYM pl1rightk
EXTSYM pl1Xk
EXTSYM pl1Ak
EXTSYM pl1Lk
EXTSYM pl1Yk
EXTSYM pl1Bk
EXTSYM pl1Rk
EXTSYM cfgcvidmode
EXTSYM pl1contrl,pl2contrl
EXTSYM InitDir,InitDrive, SRAMDir, SRAMDrive
EXTSYM DOScreatenewcfg,ExecGUISaveVars
EXTSYM allocptr
EXTSYM putchar
EXTSYM getchar
EXTSYM exit
EXTSYM FPUCopy
EXTSYM ZOpenFile,ZOpenMode,CurrentHandle,ZFileSeek,ZOpenFileName,ZFileSeekMode
EXTSYM ZFileSeekPos,ZFileSeekHandle
EXTSYM ZFileWriteHandle,ZFileWriteSize,ZFileWriteBlock,ZFileWrite
EXTSYM ZFileReadHandle,ZFileReadSize,ZFileReadBlock,ZFileRead
EXTSYM ZFileDelFName,ZFileDelete
EXTSYM ZCloseFileHandle,ZCloseFile
EXTSYM ZFileTellHandle,ZFileTell
EXTSYM ZFFTimeFName,ZFTime,ZFDate,ZFileGetFTime
;EXTSYM kbhit
EXTSYM keyboardhit
EXTSYM GUIkeydelay2
EXTSYM ZFileMKDir,ZFileCHDir,ZFileRMDir,CHPath,MKPath,RMPath
EXTSYM ZFileGetDir,DriveNumber,DirName
EXTSYM DTALoc,DTALocPos,ZFileFindATTRIB,ZFileFindFirst,ZFileFindNext,ZFileFindPATH
EXTSYM oldhand9s,oldhand9o,interror,oldhand8s,oldhand8o,oldhandSBs,oldhandSBo
EXTSYM NoSoundReinit,soundon,DSPDisable,SBInt,NoSoundReinit,PICMaskP,SBIrq
EXTSYM SBHandler,InitSB,handler8h,handler9h,init60hz,Interror,init18_2hz,DeInitSPC
EXTSYM Start60HZ
EXTSYM pressed
EXTSYM RaisePitch,AdjustFrequency
EXTSYM vidbufferofsb,vidbuffer
EXTSYM clearwin
EXTSYM Stop60HZ
EXTSYM initwinvideo
EXTSYM vesa2_rpos
EXTSYM vesa2_gpos
EXTSYM vesa2_bpos
EXTSYM vesa2_rposng
EXTSYM vesa2_gposng
EXTSYM vesa2_bposng
EXTSYM vesa2_usbit
EXTSYM vesa2_clbit
EXTSYM vesa2_clbitng
EXTSYM vesa2_clbitng2
EXTSYM vesa2_clbitng3
EXTSYM genfulladdtabng
EXTSYM vesa2red10
EXTSYM res640
EXTSYM res480
EXTSYM AddSub256,InitVesa2,cbitmode,cvidmode
EXTSYM scanlines,vesa2_bits
EXTSYM vesa2_x,vesa2_y
EXTSYM vesa2selec,InitVesa12,videotroub
EXTSYM genfulladdtab
EXTSYM GUICPC
EXTSYM drawscreenwin
EXTSYM ConvertToAFormat
EXTSYM UnusedBit,HalfTrans,UnusedBitXor,UnusedBit,UnusedBitXor
EXTSYM ngrposng,nggposng,ngbposng,HalfTransB,HalfTransC
EXTSYM UpdateVFrame
EXTSYM GetMouseX
EXTSYM GetMouseY
EXTSYM GetMouseMoveX
EXTSYM GetMouseMoveY
EXTSYM GetMouseButton
EXTSYM SetMouseMinX,SetMouseMaxX
EXTSYM SetMouseMinY,SetMouseMaxY
EXTSYM SetMouseX,SetMouseY
EXTSYM T36HZEnabled
EXTSYM MouseButton
EXTSYM Start36HZ
EXTSYM Stop36HZ
EXTSYM BufferSizeW,BufferSizeB,ProcessSoundBuffer
EXTSYM CheckTimers
EXTSYM vesa2_rfull,vesa2_rtrcl,vesa2_rtrcla
EXTSYM vesa2_gfull,vesa2_gtrcl,vesa2_gtrcla
EXTSYM vesa2_bfull,vesa2_btrcl,vesa2_btrcla
EXTSYM Init_2xSaIMMXW
EXTSYM TCPIPPortNum
EXTSYM InitTCP
EXTSYM StartServerCycle
EXTSYM ServerCheckNewClient
EXTSYM acceptzuser
EXTSYM GUINetTextk2
EXTSYM ConnectServer
EXTSYM WaitForServer
EXTSYM SendData
EXTSYM SendDataUDP
EXTSYM GetData
EXTSYM DeInitTCP
EXTSYM StopServer
EXTSYM Disconnect
EXTSYM UDPDisableMode,UDPEnableMode,UDPClearVars,UDPWait1Sec
EXTSYM WinErrorA2,WinErrorB2,WinErrorC2
EXTSYM ZsnesPage
EXTSYM GetLocalTime
NEWSYM WinIntRFAsmStart
; 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 .data
;NEWSYM OSPort, db 3 ; 0 = DOS (C), 1 = DOS (ASM), 2 = Linux, 3 = Win95
SECTION .text
NEWSYM StartUp
call ZFileSystemInit
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
push es
mov byte[cfgcvidmode],2
mov byte[cvidmode],2
call getcmdline
%ifdef __LINUX__
mov byte[esi],'z'
mov byte[esi+1],'s'
mov byte[esi+2],'n'
mov byte[esi+3],'e'
mov byte[esi+4],'s'
mov byte[esi+5],'l'
mov byte[esi+6],'.'
mov byte[esi+7],'c'
mov byte[esi+8],'f'
mov byte[esi+9],'g'
mov byte[esi+10],0
mov byte[esi+256],'z'
mov byte[esi+1+256],'g'
mov byte[esi+2+256],'u'
mov byte[esi+3+256],'i'
mov byte[esi+4+256],'c'
mov byte[esi+5+256],'f'
mov byte[esi+6+256],'g'
mov byte[esi+7+256],'l'
mov byte[esi+8+256],'.'
mov byte[esi+9+256],'d'
mov byte[esi+10+256],'a'
mov byte[esi+11+256],'t'
mov byte[esi+12+256],0
%else
mov byte[esi],'Z'
mov byte[esi+1],'S'
mov byte[esi+2],'N'
mov byte[esi+3],'E'
mov byte[esi+4],'S'
mov byte[esi+5],'W'
mov byte[esi+6],'.'
mov byte[esi+7],'C'
mov byte[esi+8],'F'
mov byte[esi+9],'G'
mov byte[esi+10],0
mov byte[esi+256],'Z'
mov byte[esi+1+256],'G'
mov byte[esi+2+256],'U'
mov byte[esi+3+256],'I'
mov byte[esi+4+256],'C'
mov byte[esi+5+256],'F'
mov byte[esi+6+256],'G'
mov byte[esi+7+256],'W'
mov byte[esi+8+256],'.'
mov byte[esi+9+256],'D'
mov byte[esi+10+256],'A'
mov byte[esi+11+256],'T'
mov byte[esi+12+256],0
%endif
mov byte[pl1selk],54
mov byte[pl1startk],28 ; 1START = ENTER
%ifdef __LINUX__
mov byte[pl1upk],90 ; 1UP = up
mov byte[pl1downk],96 ; 1DOWN = down
mov byte[pl1leftk],92 ; 1LEFT = left
mov byte[pl1rightk],94 ; 1RIGHT = right
%else
mov byte[pl1upk],200 ; 1UP = up
mov byte[pl1downk],208 ; 1DOWN = down
mov byte[pl1leftk],203 ; 1LEFT = left
mov byte[pl1rightk],205 ; 1RIGHT = right
%endif
mov byte[pl1Xk],31 ; 1X = INS
mov byte[pl1Ak],45 ; 1A = HOME
mov byte[pl1Lk],32 ; 1L = PAGE UP
mov byte[pl1Yk],30 ; 1Y = DELETE
mov byte[pl1Bk],44 ; 1B = END
mov byte[pl1Rk],46 ; 1R = PAGE DOWN
mov byte[pl1contrl],1
mov byte[pl2contrl],1
mov byte[spcon],1
mov byte[soundon],1
mov byte[cfgsoundon],1
; Get and set the initial directory
%ifdef __LINUX__
call obtaindir
mov ebx,InitDir
mov edx,InitDrive
call Get_Dir
mov dl,[SRAMDrive]
mov ebx,SRAMDir
call Change_Dir
%else
mov ebx,InitDir
mov edx,InitDrive
call Get_Dir
mov dl,[InitDrive]
mov ebx,InitDir
call Change_Dir
%endif
call GUIRestoreVars ; Load GUI stuff
call getcfg ; Load cfg stuff
call obtaindir ; Get Save/Init Directories
call ConvertJoyMap ; Mini joystick init
call ccmdline
call tparms
%ifndef __LINUX__
call preparedir
%else
mov ebx,SRAMDir
call Change_Dir
%endif
mov byte[soundon],0
; call getblaster ; get set blaster environment
; cmp byte[Force8b],1
; jne .noforce8b
mov byte[SBHDMA],1
;.noforce8b
pop es
ret
; Configuration save re-routing functions. You can comment these out
; for debugging purposes or change it if you're using a different
; configuration format
NEWSYM createnewcfg
call DOScreatenewcfg
ret
NEWSYM GUISaveVars
call ExecGUISaveVars
ret
; Allocate memory - see allocptr in ui.asm for details on what to allocate
NEWSYM allocmem
call allocptr
ret
NEWSYM PrintChar
ret
; print character at dl, push all modified registers
NEWSYM 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
pop edx
inc edx
jmp .next
.finish
popad
ret
NEWSYM wfkey, db 0
NEWSYM WaitForKey ; Wait for a key to be pressed
pushad
call getchar
mov [wfkey],al
popad
mov al,[wfkey]
; return key in al
ret
NEWSYM OsExit
NEWSYM OSExit
jmp DosExit
NEWSYM MMXCheck
; Check for cpu that doesn't support CPUID
mov edx,cpuidfname
call Open_File
jc .skipcheck
mov bx,ax
call Close_File
jmp .nommx2
.skipcheck
; Create file
mov edx,cpuidfname
call Create_File
mov bx,ax
call Close_File
mov edx,cpuidtext
call PrintStr
; MMX support
mov byte[FPUCopy],0
mov eax,1
CPUID
push edx
mov edx,cpuidtext2
call PrintStr
pop edx
test edx,1 << 23
jz .nommx
mov byte[FPUCopy],2
mov edx,YesMMX
call PrintStr
.nommx
; Delete file
mov edx,cpuidfname
call Delete_File
.nommx2
ret
NEWSYM TempHandle, dd 0
NEWSYM Open_File
pushad
mov dword[ZOpenMode],0
mov dword[ZOpenFileName],edx
call ZOpenFile
cmp eax,0FFFFFFFFh
je .error
mov [TempHandle],eax
mov dword[ZFileSeekMode],0
mov dword[ZFileSeekPos],0
mov dword[ZFileSeekHandle],eax
call ZFileSeek
popad
mov ax,[TempHandle]
clc
ret
.error
popad
stc
ret
NEWSYM Open_File_Write
pushad
mov dword[ZOpenMode],2
mov dword[ZOpenFileName],edx
call ZOpenFile
cmp eax,0FFFFFFFFh
je .error
mov [TempHandle],eax
mov dword[ZFileSeekMode],0
mov dword[ZFileSeekPos],0
mov dword[ZFileSeekHandle],eax
call ZFileSeek
popad
mov ax,[TempHandle]
clc
ret
.error
popad
stc
ret
NEWSYM Create_File
pushad
mov dword[ZOpenMode],1
mov dword[ZOpenFileName],edx
call ZOpenFile
cmp eax,0FFFFFFFFh
je .error
mov [TempHandle],eax
popad
mov ax,[TempHandle]
clc
ret
.error
popad
stc
ret
NEWSYM Write_File
mov dword[ZFileWriteHandle],0
mov [ZFileWriteHandle],bx
mov [ZFileWriteSize],ecx
mov [ZFileWriteBlock],edx
pushad
call ZFileWrite
cmp eax,0FFFFFFFFh
je .fail
popad
mov eax,1
clc
ret
.fail
popad
mov eax,0
stc
ret
NEWSYM Read_File
mov dword[ZFileReadHandle],0
mov [ZFileReadHandle],bx
mov [ZFileReadSize],ecx
mov [ZFileReadBlock],edx
pushad
call ZFileRead
mov [TempVarSeek],eax
popad
mov eax,[TempVarSeek]
clc
ret
NEWSYM Delete_File
mov [ZFileDelFName],edx
pushad
call ZFileDelete
popad
ret
NEWSYM Close_File
mov dword[ZCloseFileHandle],0
mov [ZCloseFileHandle],bx
pushad
call ZCloseFile
popad
clc
ret
NEWSYM File_Seek
mov word[ZFileSeekPos+2],cx
mov word[ZFileSeekPos],dx
mov dword[ZFileSeekMode],0
mov dword[ZFileSeekHandle],0
mov word[ZFileSeekHandle],bx
pushad
call ZFileSeek
popad
mov ax,dx
mov dx,cx
ret
NEWSYM File_Seek_End
mov word[ZFileSeekPos+2],cx
mov word[ZFileSeekPos],dx
mov dword[ZFileSeekHandle],0
mov word[ZFileSeekHandle],bx
mov dword[ZFileSeekMode],1
mov dword[ZFileTellHandle],0
mov word[ZFileTellHandle],bx
pushad
call ZFileSeek
call ZFileTell
mov [TempVarSeek],eax
popad
mov ax,[TempVarSeek]
mov dx,[TempVarSeek+2]
ret
NEWSYM Get_Time
pushad
; call GetTime
mov [TempVarSeek],eax
popad
mov eax,[TempVarSeek]
ret
NEWSYM Get_TimeDate
pushad
; call GetDate
mov [TempVarSeek],eax
popad
mov eax,[TempVarSeek]
ret
NEWSYM Get_Date
; dl = day, dh = month, cx = year
mov dx,0
mov cx,0
ret
NEWSYM Get_File_Date
mov [ZFFTimeFName],edx
pushad
call ZFileGetFTime
popad
mov edx,[ZFDate]
mov ecx,[ZFTime]
ret
RefreshKeybBuffer:
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
sub ebx,80h
.skipdecval
cmp ebx,58h
jae .none
xor eax,eax
mov al,[Keybtail]
inc al
and al,0Fh
cmp al,[Keybhead]
je .none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -