Fixed a slew of SRAM problems.

This commit is contained in:
n-a-c-h
2004-12-08 16:51:24 +00:00
parent 2ba4e544fd
commit ac3b3c4440
4 changed files with 84 additions and 87 deletions

View File

@@ -117,6 +117,7 @@ EXTSYM SfxSFR,nosprincr
EXTSYM cpucycle,debstop,switchtovirqdeb,debstop3,switchtonmideb
EXTSYM NetPlayNoMore
EXTSYM statefileloc
EXTSYM CHIPBATT,SaveSramData
%ifdef OPENSPC
EXTSYM OSPC_Run, ospc_cycle_frac
@@ -856,21 +857,15 @@ NetSaveState:
ret
%macro stim 0
; cmp byte[OSPort],1
; ja %%nosti
%ifdef __MSDOS__
sti
%endif
;%%nosti
%endmacro
%macro clim 0
; cmp byte[OSPort],1
; ja %%nocli
%ifdef __MSDOS__
cli
%endif
;%%nocli
%endmacro
%macro ProcessIRQStuffB 0
@@ -1346,74 +1341,8 @@ NEWSYM endprog
; mov eax,[numinst] ;Temporary
; mov eax,[NumBRRconv]
; call printnum
; save sram
; change to sram dir
mov dl,[SRAMDrive]
mov ebx,SRAMDir
call Change_Dir
cmp byte[sramsavedis],1
je .nosram
cmp dword[ramsize],0
je .nosram
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
xor esi,esi
xor edi,edi
mov edx,fnames+1
call Create_File
jc .nosram
mov bx,ax
xor ecx,ecx
mov ecx,[ramsize]
mov edx,[sram]
call Write_File
call Close_File
.nosram
cmp byte[SFXBATT],0
je .nosfxbatt
mov edx,fnames+1
call Create_File
jc .nosfxbatt
mov bx,ax
mov ecx,65536
mov edx,[sfxramdata]
call Write_File
call Close_File
.nosfxbatt
cmp byte[SETAEnable],0
je .nosetasram
mov edx,fnames+1
call Create_File
jc .nosetasram
mov bx,ax
mov ecx,4096
mov edx,[setaramdata]
call Write_File
call Close_File
.nosetasram
cmp byte[SA1Enable],1
jne .nosa1
mov edx,fnames+1
call Create_File
jc .nosa1
mov bx,ax
mov ecx,65536*2
mov edx,[SA1RAMArea]
call Write_File
call Close_File
.nosa1
; change dir to InitDrive/InitDir
mov dl,[InitDrive]
mov ebx,InitDir
call Change_Dir
call SaveSramData
call createnewcfg
call GUISaveVars
@@ -1497,7 +1426,6 @@ NEWSYM initaddrl, dd 0 ; initial address location
NEWSYM NetSent, dd 0
NEWSYM nextframe, dd 0 ; tick count for timer
NEWSYM curfps, db 0 ; frame/sec for current screen
NEWSYM SFXBATT, db 0
NEWSYM newgfxerror, db 'NEED MEMORY FOR GFX ENGINE',0
NEWSYM newgfxerror2, db 'NEED 320x240 FOR NEW GFX 16B',0
;newgfxerror db 'NEW GFX IN 16BIT IS N/A',0

View File

@@ -77,7 +77,7 @@ EXTSYM Voice0Status, Voice1Status, Voice2Status, Voice3Status, Voice4Status
EXTSYM Voice5Status, Voice6Status, Voice7Status, romtype, SetIRQVectors
EXTSYM ClearScreen, statesaver, loadstate2, vidbuffer, ASCII2Font, hirestiledat
EXTSYM showallext, ROMTypeNOTFound, scanlines,statefileloc,pl1selk,pl2selk
EXTSYM fnamest,sprlefttot,spritetablea,fnames,SFXBATT,sfxramdata,setaramdata,SETAEnable,cgram,srama
EXTSYM fnamest,sprlefttot,spritetablea,fnames,CHIPBATT,sfxramdata,setaramdata,SETAEnable,cgram,srama
EXTSYM tempco0,prevbright,maxbr,prevpal,coladdr,coladdg,coladdb
EXTSYM scaddtype,ScreenScale,vesa2red10,initvideo2,initvideo,pressed,UpdateDevices
EXTSYM memtabler8,memtablew8,writeon,pl1contrl,pl2contrl,JoyRead,SetInputDevice
@@ -821,7 +821,9 @@ clearsram:
inc eax
dec ecx
jnz .loop
cmp byte[SFXBATT],0
cmp byte[SFXEnable],0
je .nosfxbatt
cmp byte[CHIPBATT],0
je .nosfxbatt
mov eax,[sfxramdata]
mov ecx,65536
@@ -845,6 +847,8 @@ clearsram:
cmp byte[SA1Enable],1
jne .nosa1
cmp byte[CHIPBATT],1
jne .nosa1
mov eax,[SA1RAMArea]
mov ecx,65536*2
.loop3
@@ -1462,12 +1466,21 @@ SECTION .text
NEWSYM SaveSramData
; save sram
; change to sram dir
mov dl,[SRAMDrive]
mov ebx,SRAMDir
call Change_Dir
clim
cmp byte[SFXEnable],1
je .nosram
cmp byte[SA1Enable],1
je .nosram
cmp byte[sramsavedis],1
je .nosram
cmp dword[ramsize],0
je .nosram
clim
xor eax,eax
xor ebx,ebx
xor ecx,ecx
@@ -1478,14 +1491,60 @@ NEWSYM SaveSramData
call Create_File
jc .failed
mov bx,ax
xor ecx,ecx
mov ecx,[ramsize]
mov edx,[sram]
call Write_File
call Close_File
.nosram
cmp byte[SFXEnable],0
je .nosfxbatt
cmp byte[CHIPBATT],0
je .nosfxbatt
mov edx,fnames+1
call Create_File
jc .failed
mov bx,ax
mov ecx,65536
mov edx,[sfxramdata]
call Write_File
call Close_File
.nosfxbatt
cmp byte[SETAEnable],0
je .nosetasram
mov edx,fnames+1
call Create_File
jc .failed
mov bx,ax
mov ecx,4096
mov edx,[setaramdata]
call Write_File
call Close_File
.nosetasram
cmp byte[SA1Enable],1
jne .nosa1
cmp byte[CHIPBATT],1
jne .nosa1
mov edx,fnames+1
call Create_File
jc .failed
mov bx,ax
mov ecx,65536*2
mov edx,[SA1RAMArea]
call Write_File
call Close_File
.nosa1
.failed
stim
.nosram
call SaveCombFile
; change dir to InitDrive/InitDir
mov dl,[InitDrive]
mov ebx,InitDir
call Change_Dir
ret
NEWSYM ProcRewind
@@ -1798,7 +1857,9 @@ NEWSYM StartGUI
call SaveSramData
cmp byte[SFXBATT],0
cmp byte[SFXEnable],0
je .nosfxbatt
cmp byte[CHIPBATT],0
je .nosfxbatt
clim
mov edx,fnames+1

View File

@@ -1422,12 +1422,20 @@ SECTION .data
SECTION .text
transfersram:
cmp byte[SFXBATT],0
jne .nosram
;Do players want SRAM sent?
cmp byte[UseRemoteSRAMData],0
je .nosram
;It has a battery, send it.
cmp byte[CHIPBATT],1
je .yessram
;If last if failed, no battery, so no SRAM sending for SA1 (SFX doesn't set ramsize)
cmp byte[SA1Enable],1
je .nosram
cmp dword[ramsize],0
je .nosram
.yessram
cmp byte[UseRemoteSRAMData],1
je .uselocal
cmp byte[UseRemoteSRAMData],2
@@ -1436,6 +1444,7 @@ transfersram:
call clearsram
ret
.uselocal
call PreparePacket
mov al,233

View File

@@ -94,7 +94,7 @@ EXTSYM SRAMDir,SRAMDrive,cfgloadsdir,fnamest,statefileloc
EXTSYM ForcePal,ForceROMTiming,ForceHiLoROM,InitDir,InitDrive,enterpress,frameskip
EXTSYM maxromspace,curromspace,infoloc, patchfile
EXTSYM gotoroot,headdata,printnum,romispal
EXTSYM InitFxTables,SFXBATT,SfxR1,SfxR2,SfxSCMR,SfxSFR,finterleave
EXTSYM InitFxTables,SfxR1,SfxR2,SfxSCMR,SfxSFR,finterleave
EXTSYM initregr,initregw,memtabler16,DSP1Read16b3F,memaccessbankr16
EXTSYM memtabler8,DSP1Read8b3F,memaccessbankr8,memtablew16,DSP1Write16b
EXTSYM memaccessbankw16,memtablew8,DSP1Write8b,memaccessbankw8,DSP1Write16b3F
@@ -4134,7 +4134,6 @@ NEWSYM CheckROMType
mov byte[RTCEnable],0
mov byte[SA1Enable],0
mov byte[SDD1Enable],0
mov byte[SFXBATT],0
mov byte[OBCEnable],0
mov byte[CHIPBATT],0
mov byte[SGBEnable],0
@@ -4215,13 +4214,13 @@ NEWSYM CheckROMType
cmp ax,01520h
jne .notSFXC
mov byte[SFXEnable],1
mov byte[SFXBATT],1 ;Contains Battery
mov byte[CHIPBATT],1 ;Contains Battery
jmp .endchpdtct
.notSFXC
cmp ax,01A20h
jne .notSFXD
mov byte[SFXEnable],1
mov byte[SFXBATT],1 ;Contains Battery
mov byte[CHIPBATT],1 ;Contains Battery
jmp .endchpdtct
.notSFXD
cmp ax,05535h