diff --git a/zsnes/src/chips/sa1regs.asm b/zsnes/src/chips/sa1regs.asm index 6da6cbdf..406497cc 100644 --- a/zsnes/src/chips/sa1regs.asm +++ b/zsnes/src/chips/sa1regs.asm @@ -1605,22 +1605,6 @@ NEWSYM SA1Reset mov word[SA1Overflow],0 ret -NEWSYM UpdateBanksSDD1 - pushad - cmp dword[SDD1BankA],0 - je .nobank - mov al,[SDD1BankA] - call sdd14804w - mov al,[SDD1BankA+1] - call sdd14805w - mov al,[SDD1BankA+2] - call sdd14806w - mov al,[SDD1BankA+3] - call sdd14807w -.nobank - popad - ret - %macro BankSwitch 4 push ecx push edx diff --git a/zsnes/src/cpu/65816d.inc b/zsnes/src/cpu/65816d.inc index 69c1245e..d8d83b82 100644 --- a/zsnes/src/cpu/65816d.inc +++ b/zsnes/src/cpu/65816d.inc @@ -1318,7 +1318,6 @@ COPemulmode test byte[curexecstate],01h jz .nodis65816 and byte[curexecstate],0FEh - call changeexecloop .nodis65816 cmp byte[curexecstate],0 jne .nn diff --git a/zsnes/src/cpu/65816db.inc b/zsnes/src/cpu/65816db.inc index 16b55cd1..b2a54dad 100644 --- a/zsnes/src/cpu/65816db.inc +++ b/zsnes/src/cpu/65816db.inc @@ -1317,7 +1317,6 @@ COPemulmode test byte[curexecstate],01h jz .nodis65816 and byte[curexecstate],0FEh - call changeexecloop .nodis65816 cmp byte[curexecstate],0 jne .nn diff --git a/zsnes/src/cpu/65816dc.inc b/zsnes/src/cpu/65816dc.inc index 35137e7d..31bede6a 100644 --- a/zsnes/src/cpu/65816dc.inc +++ b/zsnes/src/cpu/65816dc.inc @@ -1331,7 +1331,6 @@ COPemulmode test byte[curexecstate],01h jz near .nodis65816 and byte[curexecstate],0FEh - call changeexecloop .nodis65816 cmp byte[curexecstate],0 jne near .nn diff --git a/zsnes/src/cpu/dsp.asm b/zsnes/src/cpu/dsp.asm index 5adbab9d..80e99332 100644 --- a/zsnes/src/cpu/dsp.asm +++ b/zsnes/src/cpu/dsp.asm @@ -2225,7 +2225,7 @@ NEWSYM WDSPReg6B ; Voice 6 ret SECTION .bss -spcres resb 1 +NEWSYM spcres, resb 1 SECTION .text NEWSYM WDSPReg6C ; Voice 6 diff --git a/zsnes/src/cpu/dspproc.asm b/zsnes/src/cpu/dspproc.asm index 5e097310..4c8f5549 100644 --- a/zsnes/src/cpu/dspproc.asm +++ b/zsnes/src/cpu/dspproc.asm @@ -442,27 +442,6 @@ NEWSYM conv2speedb ret %endif -%macro initpitchm 1 - mov ax,[DSPMem+02h+%1*10h] - mov word[Voice0Pitch+%1*2],ax - And EAX, 03FFFh - Mul dword [dspPAdj] - ShRD EAX,EDX,8 - mov [Voice0Freq+%1*4],eax - ; modpitch -%endmacro - -NEWSYM initpitch - initpitchm 0 - initpitchm 1 - initpitchm 2 - initpitchm 3 - initpitchm 4 - initpitchm 5 - initpitchm 6 - initpitchm 7 - ret - %if 0 %macro fixdspm 1 mov esi,%1 @@ -2210,13 +2189,13 @@ NEWSYM Voice6Freq, resd 1 ; Frequency of Voice 6 (Delta Freq) NEWSYM Voice7Freq, resd 1 ; Frequency of Voice 7 (Delta Freq) NEWSYM Voice0Pitch, resw 1 ; Previous Pitch for Voice 0 -Voice1Pitch resw 1 ; Previous Pitch for Voice 1 -Voice2Pitch resw 1 ; Previous Pitch for Voice 2 -Voice3Pitch resw 1 ; Previous Pitch for Voice 3 -Voice4Pitch resw 1 ; Previous Pitch for Voice 4 -Voice5Pitch resw 1 ; Previous Pitch for Voice 5 -Voice6Pitch resw 1 ; Previous Pitch for Voice 6 -Voice7Pitch resw 1 ; Previous Pitch for Voice 7 +NEWSYM Voice1Pitch, resw 1 ; Previous Pitch for Voice 1 +NEWSYM Voice2Pitch, resw 1 ; Previous Pitch for Voice 2 +NEWSYM Voice3Pitch, resw 1 ; Previous Pitch for Voice 3 +NEWSYM Voice4Pitch, resw 1 ; Previous Pitch for Voice 4 +NEWSYM Voice5Pitch, resw 1 ; Previous Pitch for Voice 5 +NEWSYM Voice6Pitch, resw 1 ; Previous Pitch for Voice 6 +NEWSYM Voice7Pitch, resw 1 ; Previous Pitch for Voice 7 NEWSYM Voice0Status, resb 1 ; 0=Not Playing 1=Playing NEWSYM Voice1Status, resb 1 diff --git a/zsnes/src/cpu/execute.asm b/zsnes/src/cpu/execute.asm index 9bdbb3a8..6e099b21 100644 --- a/zsnes/src/cpu/execute.asm +++ b/zsnes/src/cpu/execute.asm @@ -120,7 +120,7 @@ EXTSYM SfxSFR,nosprincr EXTSYM cpucycle,debstop,switchtovirqdeb,debstop3,switchtonmideb EXTSYM NetPlayNoMore EXTSYM statefileloc -EXTSYM CHIPBATT,SaveSramData, BackupCVFrame, RestoreCVFrame +EXTSYM CHIPBATT,SaveSramData,BackupCVFrame,RestoreCVFrame,loadstate %ifdef OPENSPC EXTSYM OSPC_Run, ospc_cycle_frac @@ -1073,7 +1073,12 @@ reexecuteb2: jnz near savestate mov eax,[KeyLoadState] test byte[pressed+eax],1 - jnz near loadstate + jz .noloadstt0 + pushad + call loadstate + popad + jmp reexecuteb +.noloadstt0 cmp byte[SSKeyPressed],1 je near showmenu cmp byte[SPCKeyPressed],1 @@ -1241,312 +1246,13 @@ SECTION .data SECTION .bss cycpblblah resd 2 -SECTION .text - - ; Load State -NEWSYM stateloader - mov byte[MovieProcessing],0 - mov byte[prevoamptr],0FFh - ; Load 65816 status, etc. - mov bx,ax - mov ecx,[PHnum2writecpureg] - add dword[Totalbyteloaded],ecx - mov edx,zsmesg - call Read_File - cmp byte[versn],60 - jb near .convert - ; Load SPC timers - mov ecx,8 - add dword[Totalbyteloaded],ecx - mov edx,cycpbl - call Read_File - ; Load SNES PPU Register status - mov ecx,3019 ; 3019 - add dword[Totalbyteloaded],ecx - mov edx,sndrot - call Read_File - cmp byte[versn],60 - jne .not60 - mov byte[ioportval],0FFh -.not60 - ; Load RAM (WRAM(128k),VRAM(64k),SRAM) - mov ecx,65536+65536 - add dword[Totalbyteloaded],ecx - mov edx,[wramdata] - call Read_File - mov ecx,65536 - add dword[Totalbyteloaded],ecx - mov edx,[vram] - call Read_File - cmp byte[spcon],0 - je .nospcon - ; Load SPC stuff - mov ecx,[PHspcsave] - add dword[Totalbyteloaded],ecx - mov edx,spcRam - call Read_File - ; Load DSP stuff - mov ecx,[PHdspsave] - add dword[Totalbyteloaded],ecx - mov edx,BRRBuffer - call Read_File - ; Load DSP Mem - mov ecx,256 - add dword[Totalbyteloaded],ecx - mov edx,DSPMem - call Read_File -.nospcon - cmp byte[SFXEnable],1 - jne near .nosfx - mov ecx,65536*2 - add dword[Totalbyteloaded],ecx - mov edx,[sfxramdata] - call Read_File - - mov ecx,[PHnum2writesfxreg] - add dword[Totalbyteloaded],ecx - mov edx,SfxR0 - call Read_File - - xor ecx,ecx - mov cl,[SfxPBR] - mov ecx,[SfxMemTable+ecx*4] - mov [SfxCPB],ecx - - xor ecx,ecx - mov cl,[SfxROMBR] - mov ecx,[SfxMemTable+ecx*4] - mov [SfxCROM],ecx - - xor ecx,ecx - mov cl,[SfxRAMBR] - shl ecx,16 - add ecx,[sfxramdata] - mov dword [SfxRAMMem],ecx - - mov ecx,[SfxCROM] - add [SfxRomBuffer],ecx - mov ecx,[SfxRAMMem] - add [SfxLastRamAdr],ecx - -.nosfx - - cmp byte[SETAEnable],1 - jne near .noseta - mov ecx,4096 - add dword[Totalbyteloaded],ecx - mov edx,[setaramdata] - call Read_File - ; TODO: load the SetaCmdEnable? For completeness we should do it but currently we ignore it anyway. -.noseta - - 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 - pushad - call RestoreSA1 - popad - call SA1UpdateDPage -.nossa1 - cmp byte[SDD1Enable],1 - jne .nosdd1 - call UpdateBanksSDD1 -.nosdd1 - - call Close_File - call repackfunct - mov dword[spcnumread],0 - mov dword[spchalted],-1 - mov byte[nexthdma],0 - -; call headerhack - - call initpitch - 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 dword[spcnumread],0 - mov dword[spchalted],-1 - mov byte[nexthdma],0 - call headerhack - call initpitch - ret - -NEWSYM loadstate - mov byte[pressed+1],0 - mov eax,[KeyLoadState] - mov byte[pressed+eax],2 - mov byte[multchange],1 - clim -%ifdef __LINUX__ - pushad - call SRAMChdir - popad -%endif - ; Get the state number - mov ebx,[statefileloc] - mov cl,[fnamest+ebx] - cmp cl,'t' - jne .writewhichstate - 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 - jb 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 - pushad - call ResetState - popad - call procexecloop - stim - jmp reexecuteb -.nofile - mov dword[Msgptr],.nfndmsg - mov eax,[MsgCount] - mov [MessageOn],eax - stim - jmp reexecuteb SECTION .data -.loadmsg db 'STATE - LOADED.',0 -.convmsg db 'STATE - LOADED/CONVERTED',0 -.nfndmsg db 'UNABLE TO LOAD STATE -.',0 +NEWSYM txtloadmsg, db 'STATE - LOADED.',0 +NEWSYM txtconvmsg, db 'STATE - TOO OLD.',0 +NEWSYM txtnfndmsg, db 'UNABLE TO LOAD STATE -.',0 SECTION .text -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 - pushad - call ResetState - popad - call procexecloop - ret -.nofile - ret - ;******************************************************* ; Int 08h vector ;******************************************************* @@ -3205,7 +2911,6 @@ NEWSYM cpuover test byte[curexecstate],01h jnz .dis65816 or byte[curexecstate],01h -; call changeexecloop .dis65816 cmp byte[CheatOn],1 je near .cheater @@ -3407,7 +3112,6 @@ NEWSYM cpuover test byte[curexecstate],01h jnz .dis658162 or byte[curexecstate],01h -; call changeexecloop .dis658162 mov byte[doirqnext],0 xor ebx,ebx diff --git a/zsnes/src/cpu/regsw.inc b/zsnes/src/cpu/regsw.inc index 3199ee26..dbd6ddd4 100644 --- a/zsnes/src/cpu/regsw.inc +++ b/zsnes/src/cpu/regsw.inc @@ -291,125 +291,6 @@ NEWSYM initregw ; video memory change buffer for caching (65536/16=4096) ;vidmemch2, vidmemch4, vidmemch8. 4096 bytes each -NEWSYM repackfunct - ; Global/Echo Volumes - mov al,[DSPMem+0Ch] - call WDSPReg0C - mov al,[DSPMem+1Ch] - call WDSPReg1C - mov al,[DSPMem+2Ch] - call WDSPReg2C - mov al,[DSPMem+3Ch] - call WDSPReg3C - ; Echo Values - mov al,[DSPMem+7Dh] - call WDSPReg7D - mov al,[DSPMem+0Dh] - call WDSPReg0D - ; FIR Filter Values - mov al,[DSPMem+00Fh] - call WDSPReg0F - mov al,[DSPMem+01Fh] - call WDSPReg1F - mov al,[DSPMem+02Fh] - call WDSPReg2F - mov al,[DSPMem+03Fh] - call WDSPReg3F - mov al,[DSPMem+04Fh] - call WDSPReg4F - mov al,[DSPMem+05Fh] - call WDSPReg5F - mov al,[DSPMem+06Fh] - call WDSPReg6F - mov al,[DSPMem+07Fh] - call WDSPReg7F - ; Noise - mov al,[DSPMem+6Ch] - call WDSPReg6C - mov al,[DSPMem+3Dh] - call WDSPReg3D - - mov bx,[bg1ptrb] - sub bx,[bg1ptr] - mov [bg1ptrx],bx - mov bx,[bg1ptrc] - sub bx,[bg1ptr] - mov [bg1ptry],bx - mov bx,[bg2ptrb] - sub bx,[bg2ptr] - mov [bg2ptrx],bx - mov bx,[bg2ptrc] - sub bx,[bg2ptr] - mov [bg2ptry],bx - mov bx,[bg3ptrb] - sub bx,[bg3ptr] - mov [bg3ptrx],bx - mov bx,[bg3ptrc] - sub bx,[bg3ptr] - mov [bg3ptry],bx - mov bx,[bg4ptrb] - sub bx,[bg4ptr] - mov [bg4ptrx],bx - mov bx,[bg4ptrc] - sub bx,[bg4ptr] - mov [bg4ptry],bx - - ; 16x16 tiles - mov bl,[bgtilesz] - shl bl,4 - mov dword[BG116x16t],0 - add bl,bl - adc byte[BG416x16t],0 - add bl,bl - adc byte[BG316x16t],0 - add bl,bl - adc byte[BG216x16t],0 - add bl,bl - adc byte[BG116x16t],0 - - mov ebx,[oamaddrt] - and ebx,0FFFFh - mov [oamaddr],ebx - - mov ax,[xat] - mov [xa],ax - mov al,[xdbt] - mov [xdb],al - mov al,[xpbt] - mov [xpb],al - mov ax,[xst] - mov [xs],ax - mov ax,[xdt] - mov [xd],ax - mov ax,[xxt] - mov [xx],ax - mov ax,[xyt] - mov [xy],ax - - cmp byte[vramincby8on],1 - je near .incby8 - mov ebx,[regptw] - cmp byte[vramincr],1 - je .from2118 - mov dword[ebx+2118h*4],reg2118 - mov dword[ebx+2119h*4],reg2119inc - ret -.from2118 - mov dword[ebx+2118h*4],reg2118inc - mov dword[ebx+2119h*4],reg2119 - ret -.incby8 - mov ebx,[regptw] - cmp byte[vramincr],1 - je .from2118b - mov dword[ebx+2118h*4],reg2118inc8 - mov dword[ebx+2119h*4],reg2119inc8inc - ret -.from2118b - mov dword[ebx+2118h*4],reg2118inc8inc - mov dword[ebx+2119h*4],reg2119inc8 - ret - ;******************************************************* ; Registers Note : restore AH, ECX, ESI, EDI, *S & DX ;******************************************************* @@ -935,7 +816,7 @@ reg2117w: ret ; Video port data (Low) -reg2118: +NEWSYM reg2118 mov ebx,[vramaddr] mov [vrama+ebx],al shr ebx,4 @@ -944,7 +825,7 @@ reg2118: mov byte[vidmemch8+ebx],1 ret -reg2118inc: +NEWSYM reg2118inc mov ebx,[vramaddr] mov [vrama+ebx],al shr ebx,4 @@ -955,7 +836,7 @@ reg2118inc: add [vramaddr],bx ret -reg2118inc8: +NEWSYM reg2118inc8 push ecx xor ecx,ecx mov ebx,[vramaddr] @@ -985,7 +866,7 @@ reg2118inc8: .nochange2 ret -reg2118inc8inc: +NEWSYM reg2118inc8inc push ecx xor ecx,ecx mov ebx,[vramaddr] @@ -1017,7 +898,7 @@ reg2118inc8inc: add [vramaddr],bx ret -reg2119: +NEWSYM reg2119 cmp dword[vramaddr],0E000h jb .skip mov byte[debstop],1 @@ -1033,7 +914,7 @@ reg2119: .nochange ret -reg2119inc: +NEWSYM reg2119inc mov ebx,[vramaddr] ; cmp [vrama+ebx+1],al ; je .nochange @@ -1047,7 +928,7 @@ reg2119inc: add [vramaddr],bx ret -reg2119inc8: +NEWSYM reg2119inc8 push ecx xor ecx,ecx mov ebx,[vramaddr] @@ -1075,7 +956,7 @@ reg2119inc8: .nochange2 ret -reg2119inc8inc: +NEWSYM reg2119inc8inc push ecx xor ecx,ecx mov ebx,[vramaddr] diff --git a/zsnes/src/cpu/spc700.asm b/zsnes/src/cpu/spc700.asm index 602b27f8..e2b5a7a6 100644 --- a/zsnes/src/cpu/spc700.asm +++ b/zsnes/src/cpu/spc700.asm @@ -24,7 +24,7 @@ EXTSYM DSPMem,spcWptr,debstop,disablespcclr,SPCSkipXtraROM,SPC700sh EXTSYM cycpbl,spcRptr EXTSYM spc700read EXTSYM dspWptr -EXTSYM changeexecloop,curexecstate,SA1Enable,tableadb +EXTSYM curexecstate,SA1Enable,tableadb %include "cpu/regsw.mac" %include "cpu/spcdef.inc" diff --git a/zsnes/src/cpu/zstate.c b/zsnes/src/cpu/zstate.c index a07734d1..a2e51501 100755 --- a/zsnes/src/cpu/zstate.c +++ b/zsnes/src/cpu/zstate.c @@ -49,9 +49,9 @@ Big thanks to Nach, TRAC and anomie for helping me out on porting !!*/ extern unsigned int CBackupPos, PHnum2writecpureg, cycpbl; extern unsigned int *wramdata, *vram, PHspcsave, PHdspsave, *C4Ram, *sfxramdata; extern unsigned int PHnum2writesa1reg, SA1Mode, prevedi, SA1xpc, sa1dmaptr; -extern unsigned int soundcycleft, spc700read, timer2upd, xa; +extern unsigned int soundcycleft, spc700read, timer2upd, xa, PHnum2writesfxreg; extern unsigned int spcnumread, spchalted, opcd, HIRQCycNext, oamaddr; -extern unsigned int ReadHead, *setaramdata, ramsize, *sram; +extern unsigned int SfxR0, ReadHead, *setaramdata, ramsize, *sram; extern unsigned int tempesi, tempedi, tempedx, tempebp; extern unsigned char *StateBackup, zsmesg[26], sndrot, spcon, spcRam[65472]; @@ -84,7 +84,11 @@ void BackupCVFrame() if (C4Enable) { memcpyinc (curpos, C4Ram, 2048*4); } - if (SFXEnable) { memcpyinc (curpos, sfxramdata, 8192*16); } + if (SFXEnable) + { + memcpyinc (curpos, sfxramdata, 8192*16); + memcpyinc (curpos, &SfxR0, PHnum2writesfxreg); + } if (SA1Enable) { @@ -184,7 +188,11 @@ void RestoreCVFrame() if (C4Enable) { memcpyrinc (curpos, C4Ram, 2048*4); } - if (SFXEnable) { memcpyrinc (curpos, sfxramdata, 8192*16); } + if (SFXEnable) + { + memcpyrinc (curpos, sfxramdata, 8192*16); + memcpyrinc (curpos, &SfxR0, PHnum2writesfxreg); + } if (SA1Enable) { @@ -275,16 +283,153 @@ void unpackfunct() xyt = (xy & 0xFFFF); } +#define byteset(byte, checkbit) (byte & (1 << checkbit)) ? 1 : 0 + +extern unsigned int GlobalVL, GlobalVR, EchoVL, EchoVR, EchoRate[16], MaxEcho; +extern unsigned int EchoFB, NoiseSpeeds[32], dspPAdj, NoiseInc, bg1ptrx; +extern unsigned int bg1ptry, bg2ptrx, bg2ptry, bg3ptrx, bg3ptry, bg4ptrx; +extern unsigned int bg4ptry; +extern signed int FIRTAPVal0, FIRTAPVal1, FIRTAPVal2, FIRTAPVal3, FIRTAPVal4; +extern signed int FIRTAPVal5, FIRTAPVal6, FIRTAPVal7; +extern unsigned short VolumeConvTable[32768], bg1ptr, bg1ptrb, bg1ptrc; +extern unsigned short bg2ptr, bg2ptrb, bg2ptrc, bg3ptr, bg3ptrb, bg3ptrc; +extern unsigned short bg4ptr, bg4ptrb, bg4ptrc; +extern unsigned char VolumeTableb[256], MusicVol, spcres, Voice0Status; +extern unsigned char Voice1Status, Voice2Status, Voice3Status, Voice4Status; +extern unsigned char Voice5Status, Voice6Status, Voice7Status, Voice0Noise; +extern unsigned char Voice1Noise, Voice2Noise, Voice3Noise, Voice4Noise; +extern unsigned char Voice5Noise, Voice6Noise, Voice7Noise, bgtilesz; +extern unsigned char BG116x16t, BG216x16t, BG316x16t, BG416x16t, vramincby8on; +extern unsigned char vramincr; + +extern void (**regptw)(); +extern void reg2118(); +extern void reg2118inc(); +extern void reg2118inc8(); +extern void reg2118inc8inc(); +extern void reg2119(); +extern void reg2119inc(); +extern void reg2119inc8(); +extern void reg2119inc8inc(); + +void repackfunct() +{ + signed char val; + unsigned char block; + + // Global/Echo Volumes + GlobalVL = (VolumeConvTable[(MusicVol << 8) + VolumeTableb[DSPMem[0x0C]]] & 0xFF); + GlobalVR = (VolumeConvTable[(MusicVol << 8) + VolumeTableb[DSPMem[0x1C]]] & 0xFF); + EchoVL = (VolumeConvTable[(MusicVol << 8) + VolumeTableb[DSPMem[0x2C]]] & 0xFF); + EchoVR = (VolumeConvTable[(MusicVol << 8) + VolumeTableb[DSPMem[0x3C]]] & 0xFF); + + // Echo Values + MaxEcho = EchoRate[(DSPMem[0x7D] & 0xF)]; + EchoFB = VolumeTableb[DSPMem[0x0D]]; + + // FIR Filter Values + val = DSPMem[0x0F]; + FIRTAPVal0 = (signed int)val; + val = DSPMem[0x1F]; + FIRTAPVal1 = (signed int)val; + val = DSPMem[0x2F]; + FIRTAPVal2 = (signed int)val; + val = DSPMem[0x3F]; + FIRTAPVal3 = (signed int)val; + val = DSPMem[0x4F]; + FIRTAPVal4 = (signed int)val; + val = DSPMem[0x5F]; + FIRTAPVal5 = (signed int)val; + val = DSPMem[0x6F]; + FIRTAPVal6 = (signed int)val; + val = DSPMem[0x7F]; + FIRTAPVal7 = (signed int)val; + + // Noise + block = DSPMem[0x6C]; + DSPMem[0x6C] &= 0x7F; + + if (block && 0x80) { spcres++; } + + if (block && 0xC0) + { + Voice0Status = Voice1Status = Voice2Status = Voice3Status = 0; + Voice4Status = Voice5Status = Voice6Status = Voice7Status = 0; + } + + NoiseInc = (((NoiseSpeeds[(block & 0x1F)] * dspPAdj) >> 17) & 0xFFFFFFFF); + + Voice0Noise = byteset (DSPMem[0x3D], 0); + Voice1Noise = byteset (DSPMem[0x3D], 1); + Voice2Noise = byteset (DSPMem[0x3D], 2); + Voice3Noise = byteset (DSPMem[0x3D], 3); + Voice4Noise = byteset (DSPMem[0x3D], 4); + Voice5Noise = byteset (DSPMem[0x3D], 5); + Voice6Noise = byteset (DSPMem[0x3D], 6); + Voice7Noise = byteset (DSPMem[0x3D], 7); + + bg1ptrx = bg1ptrb - bg1ptr; + bg1ptry = bg1ptrc - bg1ptr; + bg2ptrx = bg2ptrb - bg2ptr; + bg2ptry = bg2ptrc - bg2ptr; + bg3ptrx = bg3ptrb - bg3ptr; + bg3ptry = bg3ptrc - bg3ptr; + bg4ptrx = bg4ptrb - bg4ptr; + bg4ptry = bg4ptrc - bg4ptr; + + // 16x16 tiles + BG116x16t = byteset (bgtilesz, 0); + BG216x16t = byteset (bgtilesz, 1); + BG316x16t = byteset (bgtilesz, 2); + BG416x16t = byteset (bgtilesz, 3); + + oamaddr = oamaddrt; + xa = xat; + xdb = xdbt; + xpb = xpbt; + xs = xst; + xd = xdt; + xx = xxt; + xy = xyt; + + if (vramincby8on == 1) + { + if (vramincr == 1) + { + regptw[0x2118] = reg2118inc8inc; + regptw[0x2119] = reg2119inc8; + } + else + { + regptw[0x2118] = reg2118inc8; + regptw[0x2119] = reg2119inc8inc; + } + } + else + { + if (vramincr == 1) + { + regptw[0x2118] = reg2118inc; + regptw[0x2119] = reg2119; + } + else + { + regptw[0x2118] = reg2118; + regptw[0x2119] = reg2119inc; + } + } +} + extern unsigned int SA1Stat; extern unsigned char IRAM[2049], *SA1Ptr, *SA1RegPCS, *CurBWPtr, *SA1BWPtr; extern unsigned char *SNSBWPtr, *romdata; void SaveSA1() { - unsigned int off1=(unsigned int)SA1RegPCS, off2=(unsigned int)romdata; + unsigned int offst=(unsigned int)SA1RegPCS; SA1Stat &= 0xFFFFFF00; - SA1Ptr -= off1; + SA1Ptr -= offst; if (SA1RegPCS == IRAM) { @@ -296,70 +441,21 @@ void SaveSA1() SA1Stat = (SA1Stat & 0xFFFFFF00) + 2; } - SA1RegPCS -= off2; - CurBWPtr -= off2; - SA1BWPtr -= off2; - SNSBWPtr -= off2; -} - -extern unsigned int NumofBanks, snesmmap[256], snesmap2[256]; -extern unsigned char SA1BankVal[4]; - -void BankSwitchC (unsigned char bank, unsigned short offset1, unsigned int offset2, unsigned int pointer) -{ - unsigned int curbankval=SA1BankVal[bank], membankval, i; - - if ((NumofBanks & 0xFF) == 64) { curbankval &= 1 ; } - - curbankval &= 7; - curbankval <<= 20; - - if (SA1BankVal[bank] & 0x80) - { - membankval = (pointer + (unsigned int)romdata - 0x8000); - } - else - { - membankval = (curbankval + (unsigned int)romdata - 0x8000); - } - - for (i=0 ; i<32 ; i++) - { - snesmmap[offset1+i] = membankval; - membankval += 0x8000; - } - - membankval = curbankval + (unsigned int)romdata; - - for (i=0 ; i<16 ; i++) - { - snesmap2[offset2+i] = membankval; - snesmmap[offset2+i] = membankval; - membankval += 0x10000; - } -} - -extern unsigned int SA1BankSw; - -void UpdateBanks() -{ - if ((SA1BankSw & 0xFF) == 1) - { - BankSwitchC (0, 0x000, 0x0C0, 0x000000) ; - BankSwitchC (1, 0x020, 0x0D0, 0x100000) ; - BankSwitchC (2, 0x080, 0x0E0, 0x200000) ; - BankSwitchC (3, 0x0A0, 0x0F0, 0x300000) ; - } + offst = (unsigned int)romdata; + SA1RegPCS -= offst; + CurBWPtr -= offst; + SA1BWPtr -= offst; + SNSBWPtr -= offst; } void RestoreSA1() { - unsigned int off1, off2=(unsigned int)romdata; + unsigned int offst=(unsigned int)romdata; - SA1RegPCS += off2; - CurBWPtr += off2; - SA1BWPtr += off2; - SNSBWPtr += off2; + SA1RegPCS += offst; + CurBWPtr += offst; + SA1BWPtr += offst; + SNSBWPtr += offst; if ((SA1Stat & 0xFF) == 1) { @@ -371,11 +467,9 @@ void RestoreSA1() SA1RegPCS = IRAM-0x3000; } - off1 = (unsigned int)SA1RegPCS; - SA1Ptr += off1; + offst = (unsigned int)SA1RegPCS; + SA1Ptr += offst; SA1RAMArea = romdata + 4096*1024; - - UpdateBanks(); } #define ResState(Voice_BufPtr) \ @@ -399,19 +493,19 @@ void ResetState() extern unsigned int Curtableaddr, tableA[256], spcPCRam, spcRamDP; extern unsigned int statefileloc, CurrentHandle, SfxRomBuffer; -extern unsigned int SfxCROM, SfxLastRamAdr, SfxRAMMem, PHnum2writesfxreg; -extern unsigned int *SfxR0, SPCMultA, PHnum2writespc7110reg; +extern unsigned int SfxCROM, SfxLastRamAdr, SfxRAMMem; +extern unsigned int SPCMultA, PHnum2writespc7110reg; extern unsigned int MsgCount, MessageOn; extern unsigned char AutoIncSaveSlot, firstsaveinc, fnamest[512]; -extern unsigned char SPC7110Enable, cbitmode, NoPictureSave, txtsavemsg[15]; -extern unsigned char *Msgptr, txtsavemsgfail[16]; +extern unsigned char SPC7110Enable, cbitmode, NoPictureSave, txtsavemsg[14]; +extern unsigned char *Msgptr, txtsavemsgfail[15]; extern unsigned short PrevPicture[64*56]; FILE *fhandle; -void SRAMChdir(); -void CapturePicture(); +extern void SRAMChdir(); +extern void CapturePicture(); void statesaver() { @@ -455,12 +549,12 @@ void statesaver() // Save State code #ifdef __LINUX__ - SRAMChdir() ; + SRAMChdir(); #endif if ((fhandle = fopen(fnamest+1,"wb")) != NULL) { - // Save 65816 status, etc. + // Save 65816 status, etc. fwrite (zsmesg, 1, PHnum2writecpureg, fhandle); fwrite (&cycpbl, 1, 2*4, fhandle); @@ -482,12 +576,14 @@ void statesaver() SfxRomBuffer -= SfxCROM; SfxLastRamAdr -= SfxRAMMem; fwrite (sfxramdata, 1, 8192*16, fhandle); - fwrite (SfxR0, 1, PHnum2writesfxreg, fhandle); + fwrite (&SfxR0, 1, PHnum2writesfxreg, fhandle); SfxRomBuffer += SfxCROM; SfxLastRamAdr += SfxRAMMem; } if (SETAEnable) { fwrite (setaramdata, 1, 256*16, fhandle); } + // TODO: save the SetaCmdEnable? For completeness we should do it + // but currently we ignore it anyway. if (SPC7110Enable) { @@ -541,3 +637,287 @@ void statesaver() ResetState(); stim(); } + +extern unsigned int snesmmap[256], snesmap2[256]; +/*extern unsigned int NumofBanks; +extern unsigned char SA1BankVal[4]; + +void BankSwitchC (unsigned char bank, unsigned int offset1, unsigned int offset2, unsigned int pointer) +{ + unsigned int curbankval=SA1BankVal[bank], membankval, i; + + if ((NumofBanks & 0xFF) == 64) { curbankval &= 1 ; } + + curbankval &= 7; + curbankval <<= 20; + + if (SA1BankVal[bank] & 0x80) + { + membankval = (pointer + (unsigned int)romdata - 0x8000); + } + else + { + membankval = (curbankval + (unsigned int)romdata - 0x8000); + } + + for (i=0 ; i<32 ; i++) + { + snesmmap[offset1+i] = membankval; + membankval += 0x8000; + } + + membankval = curbankval + (unsigned int)romdata; + + for (i=0 ; i<16 ; i++) + { + snesmap2[offset2+i] = membankval; + snesmmap[offset2+i] = membankval; + membankval += 0x10000; + } +} + +extern unsigned int SA1BankSw; + +void UpdateBanks() +{ + if ((SA1BankSw & 0xFF) == 1) + { + BankSwitchC (0, 0x000, 0x0C0, 0x000000) ; + BankSwitchC (1, 0x020, 0x0D0, 0x100000) ; + BankSwitchC (2, 0x080, 0x0E0, 0x200000) ; + BankSwitchC (3, 0x0A0, 0x0F0, 0x300000) ; + } +}*/ + +void BankSwitchSDD1C (unsigned char bankval, unsigned int offset) +{ + unsigned int curbankval = bankval, i; + + curbankval &= 7; + curbankval <<= 20; + curbankval += (unsigned int)romdata; + + for (i=0 ; i<16 ; i++) + { + snesmap2[offset+i] = curbankval; + snesmmap[offset+i] = curbankval; + curbankval += 0x10000; + } +} + +extern unsigned char SDD1BankA, SDD1BankB, SDD1BankC, SDD1BankD; + +void UpdateBanksSDD1() +{ + if (SDD1BankA) + { + BankSwitchSDD1C (SDD1BankA, 0x0C0); + BankSwitchSDD1C (SDD1BankB, 0x0D0); + BankSwitchSDD1C (SDD1BankC, 0x0E0); + BankSwitchSDD1C (SDD1BankD, 0x0F0); + } +} + +extern unsigned int Voice0Freq, Voice1Freq, Voice2Freq, Voice3Freq; +extern unsigned int Voice4Freq, Voice5Freq, Voice6Freq, Voice7Freq; +extern unsigned short Voice0Pitch, Voice1Pitch, Voice2Pitch, Voice3Pitch; +extern unsigned short Voice4Pitch, Voice5Pitch, Voice6Pitch, Voice7Pitch; + +void initpitch() +{ + Voice0Pitch = DSPMem[2+0*0x10]; + Voice0Freq = ((((Voice0Pitch & 0x3FFF) * dspPAdj) >> 8) & 0xFFFFFFFF); + Voice1Pitch = DSPMem[2+1*0x10]; + Voice1Freq = ((((Voice1Pitch & 0x3FFF) * dspPAdj) >> 8) & 0xFFFFFFFF); + Voice2Pitch = DSPMem[2+2*0x10]; + Voice2Freq = ((((Voice2Pitch & 0x3FFF) * dspPAdj) >> 8) & 0xFFFFFFFF); + Voice3Pitch = DSPMem[2+3*0x10]; + Voice3Freq = ((((Voice3Pitch & 0x3FFF) * dspPAdj) >> 8) & 0xFFFFFFFF); + Voice4Pitch = DSPMem[2+4*0x10]; + Voice4Freq = ((((Voice4Pitch & 0x3FFF) * dspPAdj) >> 8) & 0xFFFFFFFF); + Voice5Pitch = DSPMem[2+5*0x10]; + Voice5Freq = ((((Voice5Pitch & 0x3FFF) * dspPAdj) >> 8) & 0xFFFFFFFF); + Voice6Pitch = DSPMem[2+6*0x10]; + Voice6Freq = ((((Voice6Pitch & 0x3FFF) * dspPAdj) >> 8) & 0xFFFFFFFF); + Voice7Pitch = DSPMem[2+7*0x10]; + Voice7Freq = ((((Voice7Pitch & 0x3FFF) * dspPAdj) >> 8) & 0xFFFFFFFF); +} + +extern unsigned int KeyLoadState, Totalbyteloaded, SfxMemTable[256], SfxCPB; +extern unsigned int SfxPBR, SfxROMBR, SfxRAMBR; +extern unsigned char pressed[256+128+64], multchange, txtloadmsg[15]; +extern unsigned char txtconvmsg[16], txtnfndmsg[23], vidmemch2[4096]; +extern unsigned char vidmemch4[4096], vidmemch8[4096], versn, MovieProcessing; +extern unsigned char ioportval, SDD1Enable, nexthdma; + +extern void procexecloop(); + +void stateloader (unsigned char *statename, unsigned char keycheck, unsigned char xfercheck) +{ + unsigned int offst; + unsigned char statevalue; + + if (keycheck) + { + pressed[1] = 0; + pressed[KeyLoadState] = 2; + multchange = 1; + + clim(); + #ifdef __LINUX__ + SRAMChdir(); + #endif + + // Get the state number + if (fnamest[statefileloc] == 't') + { + statevalue = '0'; + } + else + { + statevalue = fnamest[statefileloc]; + } + + txtloadmsg[6] = statevalue; + txtconvmsg[6] = statevalue; + txtnfndmsg[21] = statevalue; + } + + // Actual state loading code + if ((fhandle = fopen(statename,"rb")) != NULL) + { + if (xfercheck) { Totalbyteloaded = 0; } + + MovieProcessing = 0; + prevoamptr = 0xFF; + + // Load 65816 status, etc. + Totalbyteloaded += fread (zsmesg, 1, PHnum2writecpureg, fhandle); + if (zsmesg[25] >= '6') // just drop older states + { + // Load SPC timers + Totalbyteloaded += fread (&cycpbl, 1, 2*4, fhandle); + // Load SNES PPU Register status + Totalbyteloaded += fread (&sndrot, 1, 3019, fhandle); + ioportval = 0xFF; + // Load WRAM (128k), VRAM (64k) + Totalbyteloaded += fread (wramdata, 1, 8192*16, fhandle); + Totalbyteloaded += fread (vram, 1, 4096*16, fhandle); + + if (spcon) // SPC stuff, DSP stuff + { + Totalbyteloaded += fread (spcRam, 1, PHspcsave, fhandle); + Totalbyteloaded += fread (BRRBuffer, 1, PHdspsave, fhandle); + Totalbyteloaded += fread (DSPMem, 1, 16*16, fhandle); + } + + if (C4Enable) { Totalbyteloaded += fread (C4Ram, 1, 2048*4, fhandle); } + + if (SFXEnable) + { + Totalbyteloaded += fread (sfxramdata, 1, 8192*16, fhandle); + Totalbyteloaded += fread (&SfxR0, 1, PHnum2writesfxreg, fhandle); + SfxCPB = SfxMemTable[(SfxPBR & 0xFF)]; + SfxCROM = SfxMemTable[(SfxROMBR & 0xFF)]; + SfxRAMMem = (unsigned int)sfxramdata + ((SfxRAMBR & 0xFF) << 16); + SfxRomBuffer += SfxCROM; + SfxLastRamAdr += SfxRAMMem; + } + + if (SETAEnable) { Totalbyteloaded += fread (setaramdata, 1, 256*16, fhandle); } + // TODO: load the SetaCmdEnable? For completeness we should do it + // but currently we ignore it anyway. + + if (SPC7110Enable) + { + Totalbyteloaded += fread (romdata+0x510000, 1, 65536, fhandle); + Totalbyteloaded += fread (&SPCMultA, 1, PHnum2writespc7110reg, fhandle); + } + + if (SA1Enable) + { + Totalbyteloaded += fread (&SA1Mode, 1, PHnum2writesa1reg, fhandle); + Totalbyteloaded += fread (SA1RAMArea, 1, 8192*16, fhandle); + + RestoreSA1(); // Convert back SA-1 stuff +// UpdateBanks(); +// It was in the asm, but the only thing it does is break Oshaberi Parodius... +// The C port is still present, just commented out. + SA1UpdateDPageC(); + } + + if (SDD1Enable) + { + UpdateBanksSDD1(); + } + + fclose (fhandle); + repackfunct(); + + spcnumread = 0; + spchalted = 0xFFFFFFFF; + nexthdma = 0; + +// ;call headerhack ; ASM ONLY ! I'm not porting hacks ever. + initpitch(); + + // Clear cache check if state loaded + memset (vidmemch2, 1, 4096); + memset (vidmemch4, 1, 4096); + memset (vidmemch8, 1, 4096); + + offst = (unsigned int)tableA; + Curtableaddr += offst; + offst = (unsigned int)spcRam; + spcPCRam += offst; + spcRamDP += offst; + + ResetState(); + procexecloop(); + + if (keycheck) { stim(); } + } + + if (keycheck) + { + if (!xfercheck) + { + if (zsmesg[25] < '6') { Msgptr = txtconvmsg; } + else { Msgptr = txtloadmsg; } + } + + MessageOn = MsgCount; + } + } + else + { + if (keycheck) + { + Msgptr = txtnfndmsg; + MessageOn = MsgCount; + stim(); + } + } +} + +void debugloadstate() +{ + stateloader (fnamest+1, 0, 0); +} + +void loadstate() +{ + stateloader (fnamest+1, 1, 0); +} + +void loadstate2() +{ + stateloader (fnamest+1, 0, 1); +} + +extern unsigned char Netfname[11]; + +void loadstate3() +{ + stateloader (Netfname, 0, 1); +} diff --git a/zsnes/src/dos/debug.asm b/zsnes/src/dos/debug.asm index 0b2cff0c..528febb0 100644 --- a/zsnes/src/dos/debug.asm +++ b/zsnes/src/dos/debug.asm @@ -51,6 +51,7 @@ EXTSYM SA1xpb,SA1xpc,SA1xa,SA1xx,SA1xy,SA1xd,SA1xdb,SA1xs EXTSYM cycpbl,debugbuf,soundon,spcA,spcNZ,spcP,spcPCRam EXTSYM spcRam,spcRamDP,spcS,spcX,spcY EXTSYM CurPtrVal,SPC7110Enable +EXTSYM debugloadstate ; debstop at regsw.asm 2118/2119 @@ -258,7 +259,12 @@ NEWSYM debugloopb cmp al,59 je near .execute65816 cmp al,62 - je near debugloadstate + jne .noloadstate + pushad + call debugloadstate + popad + jmp debugloopa +.noloadstate cmp al,60 je near debugsavestate jmp .loopd @@ -411,39 +417,8 @@ SECTION .data SECTION .text ;******************************************************* -; Debug save/load states +; Debug save states (debug load state ported to c) ;******************************************************* -NEWSYM debugloadstate - ; Load State - 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 - jmp .noconvert -.convert - mov byte[versn],60 - mov byte[versn-2],'6' -.noconvert - add dword[Curtableaddr],tableA - add dword[spcPCRam],spcRam - add dword[spcRamDP],spcRam - pushad - call ResetState - popad - call procexecloop -.nofile - jmp debugloopa - NEWSYM debugsavestate pushad call statesaver diff --git a/zsnes/src/gui/gui.asm b/zsnes/src/gui/gui.asm index 61d8d770..f7b924b0 100644 --- a/zsnes/src/gui/gui.asm +++ b/zsnes/src/gui/gui.asm @@ -3134,7 +3134,9 @@ MoviePlay: call SRAMChdir popad mov dword[Totalbyteloaded],0 + pushad call loadstate2 + popad mov edx,fnamest+1 call Open_File jc near .notexist @@ -3687,7 +3689,9 @@ GUIProcStates: call NetLoadStuff jmp .changedir .notnet + pushad call loadstate2 + popad .changedir ; change dir to LoadDrive/LoadDir call ChangetoLOADdir @@ -3715,9 +3719,9 @@ LoadSecondState: mov ebx,[statefileloc] mov al,[fnamest+ebx] mov byte[fnamest+ebx],'s' - push eax + pushad call loadstate2 - pop eax + popad mov ebx,[statefileloc] mov [fnamest+ebx],al call ChangetoLOADdir diff --git a/zsnes/src/gui/guimisc.inc b/zsnes/src/gui/guimisc.inc index d756ef59..46765c5c 100644 --- a/zsnes/src/gui/guimisc.inc +++ b/zsnes/src/gui/guimisc.inc @@ -515,7 +515,9 @@ NEWSYM GUIDoReset ; reset the snes call init65816 + pushad call procexecloop + popad mov eax,spcRam mov edx,0EFh diff --git a/zsnes/src/gui/guinetpl.inc b/zsnes/src/gui/guinetpl.inc index f70cb13a..674e1cf7 100644 --- a/zsnes/src/gui/guinetpl.inc +++ b/zsnes/src/gui/guinetpl.inc @@ -1630,7 +1630,7 @@ NetStateTotal resd 1 NetStateQuit resb 1 NetStateBuffer resb 2048 SECTION .data -Netfname db 'nettemp.zst',0 +NEWSYM Netfname, db 'nettemp.zst',0 SECTION .text NetLoadStuff: @@ -1756,7 +1756,9 @@ loadstatesend: cmp dword[NetStateSize],0 jne .notzero pushad + pushad call loadstate2 + popad mov byte[RestoreValues],0 mov bx,[NetLoadHandle] call Close_File @@ -1834,7 +1836,9 @@ loadstaterecv: popad mov edx,Netfname mov byte[RestoreValues],0 + pushad call loadstate3 + popad call ChangetoLOADdir cmp byte[NetLoadState],0 je .norun2 diff --git a/zsnes/src/init.asm b/zsnes/src/init.asm index 97a6aacf..a8528dc3 100644 --- a/zsnes/src/init.asm +++ b/zsnes/src/init.asm @@ -75,7 +75,7 @@ EXTSYM memaccessspc7110r8,memaccessspc7110r16,memaccessspc7110w8 EXTSYM memaccessspc7110w16 EXTSYM ram7f,snesmap2,snesmmap,sram,MultiTap EXTSYM memaccessbankr848mb,memaccessbankr1648mb -EXTSYM cpuover,execloop +EXTSYM cpuover,execloop,procexecloop ;EXTSYM execloopn,execloopns,execloops ;EXTSYM PHsizeofexecloop,PHsizeofexecloopn,PHsizeofexecloopns ;EXTSYM PHsizeofexecloops @@ -219,8 +219,9 @@ NEWSYM init call inittablec call SA1inittable ; SPC Init - call copyexecloop + pushad call procexecloop + popad ; SNES Init pushad call Setper2exec @@ -282,7 +283,9 @@ NEWSYM init .enddigits ; Load the specified state file + pushad call loadstate2 + popad ; Just skip the extension re-setup below if we don't need to do it cmp byte[autoloadstate],9 @@ -2394,31 +2397,6 @@ NEWSYM preparesfx jnz .n ret -;******************************************************* -; Copy execloop -;******************************************************* - -NEWSYM copyexecloop - ret - -;******************************************************* -; Process execloop -;******************************************************* -NEWSYM procexecloop - cmp byte[spcon],0 - jne .noprocloop - mov byte[curexecstate],1 - ret -.noprocloop - mov byte[curexecstate],3 - ret - -;******************************************************* -; Change execloop -;******************************************************* -NEWSYM changeexecloop - ret - ;******************************************************* ; Print Hexadecimal (16-bit/8-bit) ;******************************************************* diff --git a/zsnes/src/initc.c b/zsnes/src/initc.c index f65d6b05..04222c25 100755 --- a/zsnes/src/initc.c +++ b/zsnes/src/initc.c @@ -73,6 +73,17 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #define BSSizeOffset 25 //Contains Type as well //26 - 31 is the same +// Some archaic code from an unfinished Dynarec +extern unsigned int curexecstate; +extern unsigned char spcon; + +void procexecloop() +{ + curexecstate &= 0xFFFFFF00; + + if (spcon) { curexecstate += 3; } + else { curexecstate += 1; } +} void Debug_WriteString(char *str) {