State sizes now calculated on game load. Thumbnail only displayed if in the ZST.
This commit is contained in:
@@ -106,7 +106,7 @@ static unsigned int zst_version;
|
||||
#define loading_old_state (!buffer && read && (zst_version == 60))
|
||||
#define loading_state_no_sram (!buffer && read && !SRAMState)
|
||||
|
||||
void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **, void *, size_t), bool read)
|
||||
static void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **, void *, size_t), bool read)
|
||||
{
|
||||
copy_snes_data(&buffer, copy_func);
|
||||
|
||||
@@ -226,6 +226,7 @@ void RestoreCVFrame()
|
||||
|
||||
extern unsigned int RewindPos, RewindOldPos, RewindTimer;
|
||||
|
||||
|
||||
void InitRewindVars()
|
||||
{
|
||||
RewindPos = 0;
|
||||
@@ -545,6 +546,37 @@ static void write_save_state_data(unsigned char **dest, void *data, size_t len)
|
||||
static const char zst_header_old[] = "ZSNES Save State File V0.6\x1a\x3c";
|
||||
static const char zst_header_cur[] = "ZSNES Save State File V143\x1a\x3c";
|
||||
|
||||
static size_t state_size;
|
||||
static void state_size_tally(unsigned char **dest, void *src, size_t len)
|
||||
{
|
||||
state_size += len;
|
||||
}
|
||||
|
||||
size_t rewind_state_size, cur_zst_size, old_zst_size;
|
||||
void calculate_state_sizes()
|
||||
{
|
||||
state_size = 0;
|
||||
copy_state_data(StateBackup, state_size_tally, false);
|
||||
rewind_state_size = state_size;
|
||||
|
||||
state_size = 0;
|
||||
zst_version = 143;
|
||||
copy_state_data(0, state_size_tally, false);
|
||||
cur_zst_size = state_size + sizeof(zst_header_cur)-1;
|
||||
|
||||
state_size = 0;
|
||||
zst_version = 60;
|
||||
copy_state_data(0, state_size_tally, true);
|
||||
old_zst_size = state_size + sizeof(zst_header_old)-1;
|
||||
|
||||
/*
|
||||
printf("Rewind size: %u; ZST v1.43 size: %u; ZST v0.60 size: %u\n"
|
||||
"ZST sizes with thumbnails. v1.43 size: %u; v0.60 size: %u\n",
|
||||
rewind_state_size, cur_zst_size, old_zst_size,
|
||||
cur_zst_size + 64*56*sizeof(unsigned short), old_zst_size + 64*56*sizeof(unsigned short));
|
||||
*/
|
||||
}
|
||||
|
||||
void PrepareOffset()
|
||||
{
|
||||
Curtableaddr -= (unsigned int)tableA;
|
||||
@@ -623,10 +655,10 @@ void statesaver()
|
||||
if (cbitmode && !NoPictureSave)
|
||||
{
|
||||
CapturePicture();
|
||||
fwrite(PrevPicture, 1, 64*56*2, fhandle);
|
||||
fwrite(PrevPicture, 1, 64*56*sizeof(unsigned short), fhandle);
|
||||
}
|
||||
|
||||
fclose (fhandle);
|
||||
fclose(fhandle);
|
||||
|
||||
//Display message on the screen, 'STATE X SAVED.'
|
||||
if (fnamest[statefileloc] == 't')
|
||||
|
||||
@@ -132,6 +132,8 @@ EXTSYM IntlEHi
|
||||
EXTSYM CHIPBATT,SFXEnable,C4Enable,SPC7110Enable,RTCEnable,SA1Enable,SDD1Enable,OBCEnable
|
||||
EXTSYM SETAEnable,ST18Enable,SGBEnable,DSP1Enable,DSP2Enable,DSP3Enable,DSP4Enable,BSEnable
|
||||
|
||||
EXTSYM calculate_state_sizes
|
||||
|
||||
EXTSYM SetaCmdEnable,setaramdata
|
||||
EXTSYM setaaccessbankr8,setaaccessbankw8,setaaccessbankr8a,setaaccessbankw8a
|
||||
EXTSYM setaaccessbankr16,setaaccessbankw16,setaaccessbankr16a,setaaccessbankw16a
|
||||
@@ -3166,6 +3168,7 @@ NEWSYM SetupROM
|
||||
mov [curromsize],cl
|
||||
pushad
|
||||
call SetupSramSize
|
||||
call calculate_state_sizes
|
||||
popad
|
||||
|
||||
; get pal/ntsc
|
||||
@@ -3200,9 +3203,6 @@ NEWSYM SetupROM
|
||||
NEWSYM CheckROMType
|
||||
pushad
|
||||
call BankCheck
|
||||
popad
|
||||
|
||||
pushad
|
||||
call MirrorROM
|
||||
popad
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ EXTSYM vidbufferofsb
|
||||
;EXTSYM Super2xSaI
|
||||
EXTSYM HalfTransB,HalfTransC
|
||||
|
||||
EXTSYM cur_zst_size,old_zst_size
|
||||
|
||||
%ifdef __MSDOS__
|
||||
EXTSYM SB_blank
|
||||
%endif
|
||||
@@ -1306,18 +1308,18 @@ GetPicture:
|
||||
call File_Seek_End
|
||||
shl edx,16
|
||||
mov dx,ax
|
||||
;Just draw! - If you want to make it exact, you set all the sizes
|
||||
;cmp edx,266879+64*56*2
|
||||
;je .draw
|
||||
;cmp edx,398643+64*56*2
|
||||
;je .draw
|
||||
;cmp edx,400692+64*56*2
|
||||
;je .draw
|
||||
;cmp edx,275071+64*56*2
|
||||
;je .draw
|
||||
;jmp .nodraw
|
||||
;.draw
|
||||
sub edx,64*56*2
|
||||
push eax
|
||||
sub edx,64*56*2 ;Size of thumbnail
|
||||
mov eax,[cur_zst_size]
|
||||
cmp edx,eax
|
||||
je .draw
|
||||
mov eax,[old_zst_size]
|
||||
cmp edx,eax
|
||||
je .draw
|
||||
pop eax
|
||||
jmp .nodraw
|
||||
.draw
|
||||
pop eax
|
||||
mov ax,dx
|
||||
shr edx,16
|
||||
mov cx,dx
|
||||
|
||||
Reference in New Issue
Block a user