📄 execute.asm
字号:
cmp byte[C4Enable],1
jne .noc4
mov ecx,2000h
add dword[Totalbyteloaded],ecx
mov edx,[C4Ram]
call Read_File
.noc4
cmp byte[SPC7110Enable],1
jne .nospc7110
mov edx,[romdata]
add edx,510000h
mov ecx,65536
call Read_File
mov edx,SPCMultA
mov ecx,[PHnum2writespc7110reg]
call Read_File
.nospc7110
cmp byte[SA1Enable],1
jne .nossa1
mov ecx,[PHnum2writesa1reg]
add dword[Totalbyteloaded],ecx
mov edx,SA1Mode
call Read_File
mov ecx,65536*2
add dword[Totalbyteloaded],ecx
mov edx,[SA1RAMArea]
call Read_File
; Convert back SA-1 stuff
push ebx
call RestoreSA1
pop ebx
call SA1UpdateDPage
.nossa1
cmp byte[SDD1Enable],1
jne .nosdd1
call UpdateBanksSDD1
.nosdd1
call Close_File
call repackfunct
mov byte[spcnumread],0
mov byte[nexthdma],0
; call headerhack
call initpitch
call initrevst
ret
.convert
; Load SNES PPU Register status
mov ecx,3019
mov edx,sndrot
call Read_File
; Load RAM (WRAM(128k),VRAM(64k),SRAM)
mov dword[cycpbl],0
mov dword[cycpblt],0
mov ah,[cycpbl2]
mov [cycpbl],ah
mov ah,[cycpblt2]
mov [cycpblt],ah
mov ecx,[ramsize]
add ecx,65536+65536+65536
mov edx,[wramdata]
call Read_File
cmp byte[spcon],0
je .nospconb
; Load SPC stuff
mov ecx,[PHspcsave]
mov edx,spcRam
call Read_File
; Load DSP stuff
mov ecx,32
mov edx,BRRBuffer
call Read_File
; Convert old to new data
; read/write 6, jump 2 for 8 times
mov edx,BRRPlace0
mov ecx,8
.loopconv
push edx
push ecx
mov ecx,4
call Read_File
pop ecx
pop edx
add edx,8
dec ecx
jnz .loopconv
;dspsave equ $-BRRBuffer
;dspconvb equ $-Voice0Freq
; Load DSP stuff
mov ecx,[PHdspsave]
sub ecx,64+32
sub ecx,8
mov edx,Voice0Freq
call Read_File
; Load DSP Mem
mov ecx,256
mov edx,DSPMem
call Read_File
.nospconb
call Close_File
call repackfunct
mov dword[cycpbl],0
mov byte[spcnumread],0
mov byte[nexthdma],0
call headerhack
call initpitch
call initrevst
ret
NEWSYM loadstate
mov byte[pressed+1],0
mov eax,[KeyLoadState]
mov byte[pressed+eax],2
mov byte[multchange],1
clim
%ifdef __LINUX__
mov dl,[SRAMDrive]
mov ebx,SRAMDir
call Change_Dir
%endif
; Get the state number
mov ebx,[statefileloc]
mov cl,[fnamest+ebx]
cmp cl,'T'
je .stateiszero
cmp cl,'t'
jne .writewhichstate
.stateiszero
mov cl,'0'
.writewhichstate
mov [.loadmsg+6],cl
mov [.convmsg+6],cl
mov [.nfndmsg+21],cl
mov edx,fnamest+1
call Open_File
jc near .nofile
call stateloader
; Clear Cache Check
mov esi,vidmemch2
mov ecx,4096+4096+4096
.next
mov byte[esi],1
inc esi
dec ecx
jnz .next
cmp byte[versn],60
jne near .convert
mov dword[Msgptr],.loadmsg
jmp .noconvert
.convert
mov dword[Msgptr],.convmsg
mov byte[versn],60
mov byte[versn-2],'6'
.noconvert
mov eax,[MsgCount]
mov [MessageOn],eax
add dword[Curtableaddr],tableA
add dword[spcPCRam],spcRam
add dword[spcRamDP],spcRam
call ResetState
call procexecloop
stim
jmp reexecuteb
.nofile
mov dword[Msgptr],.nfndmsg
mov eax,[MsgCount]
mov [MessageOn],eax
stim
jmp reexecuteb
.loadmsg db 'STATE - LOADED.',0
.convmsg db 'STATE - LOADED/CONVERTED',0
.nfndmsg db 'UNABLE TO LOAD STATE -.',0
NEWSYM loadstate2
mov edx,fnamest+1
NEWSYM loadstate3
call Open_File
jc near .nofile
mov dword[Totalbyteloaded],0
call stateloader
; Clear Cache Check
mov esi,vidmemch2
mov ecx,4096+4096+4096
.next
mov byte[esi],1
inc esi
dec ecx
jnz .next
add dword[Curtableaddr],tableA
add dword[spcPCRam],spcRam
add dword[spcRamDP],spcRam
call ResetState
call procexecloop
ret
.nofile
ret
;*******************************************************
; Int 08h vector
;*******************************************************
; sets to either 60Hz or 50Hz depending on PAL/NTSC
NEWSYM init60hz
cmp byte[romispal],0
jne .dopal
mov al,00110110b
out 43h,al
mov ax,19900 ; 65536/(60/((65536*24+175)/(60*60*24)))
mov dword[timercount],19900
out 40h,al
mov al,ah
out 40H,al
ret
.dopal
mov al,00110110b
out 43h,al
mov ax,23863 ; 65536/(50/((65536*24+175)/(60*60*24)))
mov dword[timercount],23863
out 40h,al
mov al,ah
out 40H,al
ret
NEWSYM init18_2hz
mov al,00110110b
out 43H,al
mov ax,0
mov dword[timercount],65536
out 40H,al
mov al,ah
out 40H,al
ret
NEWSYM Game60hzcall
inc word[t1cc]
inc byte[nextframe]
ret
NEWSYM handler8h
cli
push ds
push eax
; mov ax,0
mov ax,[cs:dssel]
NEWSYM handler8hseg
mov ds,ax
call Game60hzcall
mov eax,[timercount]
sub dword[timeradj],eax
jnc .noupd
add dword[timeradj],65536
pushf
call far [oldhand8o]
.noupd
mov al,20h
out 20h,al
pop eax
pop ds
sti
iretd
NEWSYM timeradj, dd 65536
NEWSYM t1cc, dw 0
;*******************************************************
; Int 09h vector
;*******************************************************
NEWSYM skipnextkey42, db 0
NEWSYM handler9h
cli
push ds
push eax
push ebx
mov ax,[cs:dssel]
mov ds,ax
xor ebx,ebx
in al,60H ; get keyboard scan code
cmp al,42
jne .no42
cmp byte[skipnextkey42],0
je .no42
mov byte[skipnextkey42],0
jmp .skipkeyrel
.no42
cmp al,0E0h
jne .noE0
mov byte[skipnextkey42],1
jmp .skipkeyrel
.noE0
mov byte[skipnextkey42],0
mov bl,al
xor bh,bh
test bl,80h ; check if bit 7 is on (key released)
jnz .keyrel
cmp byte[pressed+ebx],0
jne .skipa
mov byte[pressed+ebx],1 ; if not, set key to pressed
.skipa
jmp .skipkeyrel
.keyrel
and ebx,7Fh
cmp ebx,59
je .skipkeyrel
cmp ebx,[KeySaveState]
je .skipkeyrel
cmp ebx,[KeyLoadState]
je .skipkeyrel
cmp ebx,[KeyQuickExit]
je .skipkeyrel
cmp ebx,[KeyQuickLoad]
je .skipkeyrel
cmp ebx,[KeyQuickRst]
je .skipkeyrel
cmp bl,1
je .skipkeyrel
mov byte[pressed+ebx],0 ; if not, set key to pressed
.skipkeyrel
mov byte[pressed],0
in al,61h
mov ah,al
or al,80h
out 61h,al
mov al,20H ; turn off interrupt mode
out 20H,al
pop ebx ; Pop registers off
pop eax ; stack in correct
pop ds
sti
iretd
ALIGN32
NEWSYM soundcycleft, dd 0
NEWSYM curexecstate, dd 0
NEWSYM nmiprevaddrl, dd 0 ; observed address -5
NEWSYM nmiprevaddrh, dd 0 ; observed address +5
NEWSYM nmirept, dd 0 ; NMI repeat check, if 6 then okay
NEWSYM nmiprevline, dd 224 ; previous line
NEWSYM nmistatus, dd 0 ; 0 = none, 1 = waiting for nmi location,
; 2 = found, disable at next line
NEWSYM joycontren, dd 0 ; joystick read control check
NEWSYM NextLineCache, db 0
NEWSYM NetQuit, db 0
Donextlinecache:
cmp word[curypos],0
je .nocache
mov ax,[resolutn]
dec ax
cmp word[curypos],ax
jae .nocache
test byte[scrndis],10h
jnz .nocache
cmp byte[curblank],0h
jne .nocache
push ecx
push ebx
push esi
push edi
xor ecx,ecx
mov cl,[curypos]
push edx
.next
mov byte[sprlefttot+ecx],0
mov dword[sprleftpr+ecx*4],0
inc cl
jnz .next
call processsprites
call cachesprites
pop edx
pop edi
pop esi
pop ebx
pop ecx
.nocache
mov byte[NextLineCache],0
ret
%macro NetHelpExecSend 1
cmp byte[pl1neten+%1],1
jne %%nopl
mov eax,[ecx]
mov [cnetplaybuf+ebx],al
inc ebx
and ebx,1FFh
mov [cnetplaybuf+ebx],ah
inc ebx
and ebx,1FFh
ror eax,16
mov [cnetplaybuf+ebx],al
inc ebx
and ebx,1FFh
mov [cnetplaybuf+ebx],ah
inc ebx
and ebx,1FFh
ror eax,16
call RemoteSendEAX
add ecx,4
%%nopl
%endmacro
%macro NetHelpExecRecv 1
cmp byte[pl1neten+%1],2
jne %%nopl
call RemoteGetEAX
mov [ecx],eax
%%nopl
add ecx,4
%endmacro
%macro NetHelpExecRecv2 1
cmp byte[pl1neten+%1],1
jne %%nopl
mov al,[cnetplaybuf+ebx]
inc ebx
and ebx,1FFh
mov ah,[cnetplaybuf+ebx]
inc ebx
and ebx,1FFh
ror eax,16
mov al,[cnetplaybuf+ebx]
inc ebx
and ebx,1FFh
mov ah,[cnetplaybuf+ebx]
inc ebx
and ebx,1FFh
ror eax,16
mov [ecx],eax
%%nopl
add ecx,4
%endmacro
;*******************************************************
; 65816 execution
;*******************************************************
SpeedHackSafeTable
db 1,0,1,0,0,0,1,0,1,0,1,1,0,0,0,0
db 0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0
db 0,0,0,0,0,0,1,0,1,0,1,1,0,0,1,0
db 0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0
db 0,0,0,0,0,1,1,1,1,1,1,1,0,1,1,1
db 0,1,1,1,0,1,1,1,0,1,1,0,0,0,1,0
db 0,1,0,1,0,1,1,1,0,1,1,0,0,1,1,1
db 0,1,1,1,0,1,1,1,0,1,0,0,0,1,1,1
db 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0
db 0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0
db 0,1,0,1,0,1,1,1,1,1,0,0,0,1,1,1
db 0,1,1,1,0,1,1,1,0,1,0,0,0,1,1,1
NEWSYM exitloop2
mov byte[ExecExitOkay],0
NEWSYM exitloop
ret
cmp byte[nextmenupopup],1
je .okay
cmp byte[ExecExitOkay],0
je .okay
mov byte[pressed+1],0
mov byte[pressed+59],0
mov eax,[KeySaveState]
mov byte[pressed+eax],0
mov eax,[KeyLoadState]
mov byte[pressed+eax],0
mov eax,[KeyQuickExit]
mov byte[pressed+eax],0
mov eax,[KeyQuickLoad]
mov byte[pressed+eax],0
mov eax,[KeyQuickRst]
mov byte[pressed+eax],0
mov byte[ExecExitOkay],5
mov eax,[KeyQuickSnapShot]
mov byte[pressed+eax],0
mov byte[SSKeyPressed],0
jmp cpuover.returntoloop
.okay
mov byte[ExecExitOkay],5
ret
ALIGN16
%macro FlipCheck 0
cmp byte[FlipWait],0
je %%noflip
push edx
push eax
mov dx,3DAh ;VGA status port
in al,dx
test al,8
jz %%skipflip
push ebx
push ecx
mov ax,4F07h
mov bh,00h
mov bl,00h
xor cx,cx
mov dx,[NextLineStart]
mov [LastLineStart],dx
int 10h
mov byte[FlipWait],0
pop ecx
pop ebx
%%skipflip
pop eax
pop edx
%%noflip
%endmacro
NEWSYM execute
NEWSYM execloop
mov bl,dl
test byte[curexecstate],2
jnz .sound
mov edi,[tableadb+ebx*4]
mov bl,[esi]
inc esi
sub dh,[cpucycle+ebx]
jc .cpuover
.startagain
call dword near [edi+ebx*4]
.cpuover
jmp cpuover
.sound
mov edi,[tableadc+ebx*4]
sub dword[cycpbl],55
jnc .skipallspc
mov eax,[cycpblt]
mov bl,[ebp]
add dword[cycpbl],eax
; 1260, 10000/12625
inc ebp
call dword near [opcjmptab+ebx*4]
xor ebx,ebx
.skipallspc
mov bl,[esi]
inc esi
sub dh,[cpucycle+ebx]
jc .cpuovers
call dword near [edi+ebx*4]
.cpuovers
jmp cpuover
SECTION .data
ALIGN32
NEWSYM ExecExitOkay, db 1
NEWSYM JoyABack, dd 0
NEWSYM JoyBBack, dd 0
NEWSYM JoyCBack, dd 0
NEWSYM JoyDBack, dd 0
NEWSYM JoyEBack, dd 0
NEWSYM NetCommand, dd 0
NEWSYM spc700read, dd 0
NEWSYM lowestspc, dd 0
NEWSYM highestspc, dd 0
NEWSYM SA1UBound, dd 0
NEWSYM SA1LBound, dd 0
NEWSYM SA1SH, dd 0
NEWSYM SA1SHb, dd 0
NEWSYM NumberOfOpcodes2, dd 0
NEWSYM ChangeOps, dd 0
NEWSYM SFXProc, dd 0
SECTION .text
%macro C4Paused 0
; cmp byte[C4Pause],0
; je %%notpaused
; inc esi
; xor dh,dh
; jmp cpuover
;%%notpaused
%endmacro
NEWSYM cpuover
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -