Renaming files

This commit is contained in:
dborth 2008-08-07 05:20:24 +00:00
parent 023b0e4f3b
commit 994d3c8944

View File

@ -119,8 +119,8 @@
Snes9x homepage: http://www.snes9x.com Snes9x homepage: http://www.snes9x.com
Permission to use, copy, modify and/or distribute Snes9x in both binary Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear fee, providing that this license information and copyright notice appear
with all copies and any derived work. with all copies and any derived work.
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
@ -178,7 +178,7 @@
#include "controls.h" #include "controls.h"
#include "memfile.h" #include "memfile.h"
#include "gccore.h" #include "gccore.h"
#include "ftfont.h" #include "menudraw.h"
extern uint8 *SRAM; extern uint8 *SRAM;
@ -194,7 +194,7 @@ void S9xResetSaveTimer(bool8 dontsave){
static time_t t=-1; static time_t t=-1;
if(!dontsave && t!=-1 && time(NULL)-t>300){{ if(!dontsave && t!=-1 && time(NULL)-t>300){{
#ifndef NGC #ifndef NGC
char def [PATH_MAX]; char def [PATH_MAX];
char filename [PATH_MAX]; char filename [PATH_MAX];
char drive [_MAX_DRIVE]; char drive [_MAX_DRIVE];
@ -206,7 +206,7 @@ void S9xResetSaveTimer(bool8 dontsave){
SLASH_STR, def, _MAX_EXT-1, "oops"); SLASH_STR, def, _MAX_EXT-1, "oops");
S9xMessage(S9X_INFO, S9X_FREEZE_FILE_INFO, "Auto-saving 'oops' savestate"); S9xMessage(S9X_INFO, S9X_FREEZE_FILE_INFO, "Auto-saving 'oops' savestate");
Snapshot(filename); Snapshot(filename);
#endif #endif
}} }}
t=time(NULL); t=time(NULL);
} }
@ -305,28 +305,28 @@ static FreezeData SnapPPU [] = {
{OFFSET (BG[0].BGSize), 1, INT_V, 1, 9999}, {OFFSET (BG[0].BGSize), 1, INT_V, 1, 9999},
{OFFSET (BG[0].NameBase), 2, INT_V, 1, 9999}, {OFFSET (BG[0].NameBase), 2, INT_V, 1, 9999},
{OFFSET (BG[0].SCSize), 2, INT_V, 1, 9999}, {OFFSET (BG[0].SCSize), 2, INT_V, 1, 9999},
{OFFSET (BG[1].SCBase), 2, INT_V, 1, 9999}, {OFFSET (BG[1].SCBase), 2, INT_V, 1, 9999},
{OFFSET (BG[1].VOffset), 2, INT_V, 1, 9999}, {OFFSET (BG[1].VOffset), 2, INT_V, 1, 9999},
{OFFSET (BG[1].HOffset), 2, INT_V, 1, 9999}, {OFFSET (BG[1].HOffset), 2, INT_V, 1, 9999},
{OFFSET (BG[1].BGSize), 1, INT_V, 1, 9999}, {OFFSET (BG[1].BGSize), 1, INT_V, 1, 9999},
{OFFSET (BG[1].NameBase), 2, INT_V, 1, 9999}, {OFFSET (BG[1].NameBase), 2, INT_V, 1, 9999},
{OFFSET (BG[1].SCSize), 2, INT_V, 1, 9999}, {OFFSET (BG[1].SCSize), 2, INT_V, 1, 9999},
{OFFSET (BG[2].SCBase), 2, INT_V, 1, 9999}, {OFFSET (BG[2].SCBase), 2, INT_V, 1, 9999},
{OFFSET (BG[2].VOffset), 2, INT_V, 1, 9999}, {OFFSET (BG[2].VOffset), 2, INT_V, 1, 9999},
{OFFSET (BG[2].HOffset), 2, INT_V, 1, 9999}, {OFFSET (BG[2].HOffset), 2, INT_V, 1, 9999},
{OFFSET (BG[2].BGSize), 1, INT_V, 1, 9999}, {OFFSET (BG[2].BGSize), 1, INT_V, 1, 9999},
{OFFSET (BG[2].NameBase), 2, INT_V, 1, 9999}, {OFFSET (BG[2].NameBase), 2, INT_V, 1, 9999},
{OFFSET (BG[2].SCSize), 2, INT_V, 1, 9999}, {OFFSET (BG[2].SCSize), 2, INT_V, 1, 9999},
{OFFSET (BG[3].SCBase), 2, INT_V, 1, 9999}, {OFFSET (BG[3].SCBase), 2, INT_V, 1, 9999},
{OFFSET (BG[3].VOffset), 2, INT_V, 1, 9999}, {OFFSET (BG[3].VOffset), 2, INT_V, 1, 9999},
{OFFSET (BG[3].HOffset), 2, INT_V, 1, 9999}, {OFFSET (BG[3].HOffset), 2, INT_V, 1, 9999},
{OFFSET (BG[3].BGSize), 1, INT_V, 1, 9999}, {OFFSET (BG[3].BGSize), 1, INT_V, 1, 9999},
{OFFSET (BG[3].NameBase), 2, INT_V, 1, 9999}, {OFFSET (BG[3].NameBase), 2, INT_V, 1, 9999},
{OFFSET (BG[3].SCSize), 2, INT_V, 1, 9999}, {OFFSET (BG[3].SCSize), 2, INT_V, 1, 9999},
{OFFSET (CGFLIP), 1, INT_V, 1, 9999}, {OFFSET (CGFLIP), 1, INT_V, 1, 9999},
{OFFSET (CGDATA), 256, uint16_ARRAY_V, 1, 9999}, {OFFSET (CGDATA), 256, uint16_ARRAY_V, 1, 9999},
{OFFSET (FirstSprite), 1, INT_V, 1, 9999}, {OFFSET (FirstSprite), 1, INT_V, 1, 9999},
@ -339,7 +339,7 @@ static FreezeData SnapPPU [] = {
{OFFSET (OBJ[N].Priority), 1, INT_V, 1, 9999}, \ {OFFSET (OBJ[N].Priority), 1, INT_V, 1, 9999}, \
{OFFSET (OBJ[N].Palette), 1, INT_V, 1, 9999}, \ {OFFSET (OBJ[N].Palette), 1, INT_V, 1, 9999}, \
{OFFSET (OBJ[N].Size), 1, INT_V, 1, 9999} {OFFSET (OBJ[N].Size), 1, INT_V, 1, 9999}
O( 0), O( 1), O( 2), O( 3), O( 4), O( 5), O( 6), O( 7), O( 0), O( 1), O( 2), O( 3), O( 4), O( 5), O( 6), O( 7),
O( 8), O( 9), O( 10), O( 11), O( 12), O( 13), O( 14), O( 15), O( 8), O( 9), O( 10), O( 11), O( 12), O( 13), O( 14), O( 15),
O( 16), O( 17), O( 18), O( 19), O( 20), O( 21), O( 22), O( 23), O( 16), O( 17), O( 18), O( 19), O( 20), O( 21), O( 22), O( 23),
@ -408,11 +408,11 @@ static FreezeData SnapPPU [] = {
{OFFSET (ClipWindow2Enable[N]), 1, INT_V, 1, 9999}, \ {OFFSET (ClipWindow2Enable[N]), 1, INT_V, 1, 9999}, \
{OFFSET (ClipWindow1Inside[N]), 1, INT_V, 1, 9999}, \ {OFFSET (ClipWindow1Inside[N]), 1, INT_V, 1, 9999}, \
{OFFSET (ClipWindow2Inside[N]), 1, INT_V, 1, 9999} {OFFSET (ClipWindow2Inside[N]), 1, INT_V, 1, 9999}
O(0), O(1), O(2), O(3), O(4), O(5), O(0), O(1), O(2), O(3), O(4), O(5),
#undef O #undef O
{OFFSET (CGFLIPRead), 1, INT_V, 1, 9999}, {OFFSET (CGFLIPRead), 1, INT_V, 1, 9999},
{OFFSET (Need16x8Mulitply), 1, INT_V, 1, 9999}, {OFFSET (Need16x8Mulitply), 1, INT_V, 1, 9999},
{OFFSET (BGMosaic), 4, uint8_ARRAY_V, 1, 9999}, {OFFSET (BGMosaic), 4, uint8_ARRAY_V, 1, 9999},
@ -449,7 +449,7 @@ static FreezeData SnapDMA [] = {
{OFFSET (DoTransfer) + N * sizeof (struct SDMA), 1, INT_V, 1, 9999}, \ {OFFSET (DoTransfer) + N * sizeof (struct SDMA), 1, INT_V, 1, 9999}, \
{OFFSET (UnknownByte) + N * sizeof (struct SDMA), 1, INT_V, 2, 9999}, \ {OFFSET (UnknownByte) + N * sizeof (struct SDMA), 1, INT_V, 2, 9999}, \
{OFFSET (UnusedBit43x0) + N * sizeof (struct SDMA), 1, INT_V, 2, 9999} {OFFSET (UnusedBit43x0) + N * sizeof (struct SDMA), 1, INT_V, 2, 9999}
O(0), O(1), O(2), O(3), O(4), O(5), O(6), O(7) O(0), O(1), O(2), O(3), O(4), O(5), O(6), O(7)
#undef O #undef O
}; };
@ -528,7 +528,7 @@ static FreezeData SnapSoundData [] = {
{OFFSET (channels [N].block_pointer), 4, INT_V, 1, 9999}, \ {OFFSET (channels [N].block_pointer), 4, INT_V, 1, 9999}, \
{OFFSET (channels [N].sample_pointer), 4, INT_V, 1, 9999}, \ {OFFSET (channels [N].sample_pointer), 4, INT_V, 1, 9999}, \
{OFFSET (channels [N].mode), 4, INT_V, 1, 9999} {OFFSET (channels [N].mode), 4, INT_V, 1, 9999}
O(0), O(1), O(2), O(3), O(4), O(5), O(6), O(7), O(0), O(1), O(2), O(3), O(4), O(5), O(6), O(7),
#undef O #undef O
{OFFSET (noise_rate), 4, INT_V, 2, 9999}, {OFFSET (noise_rate), 4, INT_V, 2, 9999},
@ -736,26 +736,26 @@ bool8 S9xFreezeGame (const char *filename)
{ {
STREAM stream = NULL; STREAM stream = NULL;
#ifndef NGC #ifndef NGC
if (S9xOpenSnapshotFile (filename, FALSE, &stream)) if (S9xOpenSnapshotFile (filename, FALSE, &stream))
#endif #endif
{ {
S9xPrepareSoundForSnapshotSave (FALSE); S9xPrepareSoundForSnapshotSave (FALSE);
S9xFreezeToStream (stream); S9xFreezeToStream (stream);
S9xCloseSnapshotFile (stream); S9xCloseSnapshotFile (stream);
S9xPrepareSoundForSnapshotSave (TRUE); S9xPrepareSoundForSnapshotSave (TRUE);
S9xResetSaveTimer (TRUE); S9xResetSaveTimer (TRUE);
#ifndef NGC #ifndef NGC
if(S9xMovieActive()) if(S9xMovieActive())
{ {
sprintf(String, "Movie snapshot %s", S9xBasename (filename)); sprintf(String, "Movie snapshot %s", S9xBasename (filename));
S9xMessage (S9X_INFO, S9X_FREEZE_FILE_INFO, String); S9xMessage (S9X_INFO, S9X_FREEZE_FILE_INFO, String);
} }
else else
{ {
sprintf(String, "Saved %s", S9xBasename (filename)); sprintf(String, "Saved %s", S9xBasename (filename));
S9xMessage (S9X_INFO, S9X_FREEZE_FILE_INFO, String); S9xMessage (S9X_INFO, S9X_FREEZE_FILE_INFO, String);
@ -780,7 +780,7 @@ bool8 S9xUnfreezeGame (const char *filename)
_splitpath (filename, drive, dir, def, ext); _splitpath (filename, drive, dir, def, ext);
S9xResetSaveTimer (!strcmp(ext, "oops") || !strcmp(ext, "oop")); S9xResetSaveTimer (!strcmp(ext, "oops") || !strcmp(ext, "oop"));
ZeroMemory (&Obsolete, sizeof(Obsolete)); ZeroMemory (&Obsolete, sizeof(Obsolete));
#ifndef NGC #ifndef NGC
@ -789,14 +789,14 @@ bool8 S9xUnfreezeGame (const char *filename)
if (S9xLoadOrigSnapshot (filename)) if (S9xLoadOrigSnapshot (filename))
return (TRUE); return (TRUE);
if (S9xUnfreezeZSNES (filename)) if (S9xUnfreezeZSNES (filename))
return (TRUE); return (TRUE);
#endif #endif
STREAM snapshot = NULL; STREAM snapshot = NULL;
#ifndef NGC #ifndef NGC
if (S9xOpenSnapshotFile (filename, TRUE, &snapshot)) if (S9xOpenSnapshotFile (filename, TRUE, &snapshot))
#endif #endif
@ -807,7 +807,7 @@ bool8 S9xUnfreezeGame (const char *filename)
switch (result) switch (result)
{ {
case WRONG_FORMAT: case WRONG_FORMAT:
S9xMessage (S9X_ERROR, S9X_WRONG_FORMAT, S9xMessage (S9X_ERROR, S9X_WRONG_FORMAT,
"File not in Snes9x freeze format"); "File not in Snes9x freeze format");
WaitPrompt("File not in Snes9x freeze format"); WaitPrompt("File not in Snes9x freeze format");
break; break;
@ -842,7 +842,7 @@ bool8 S9xUnfreezeGame (const char *filename)
} }
S9xCloseSnapshotFile (snapshot); S9xCloseSnapshotFile (snapshot);
#endif #endif
return (TRUE); return (TRUE);
} }
@ -898,7 +898,7 @@ void S9xFreezeToStream (STREAM stream)
struct SControlSnapshot ctl_snap; struct SControlSnapshot ctl_snap;
S9xControlPreSave(&ctl_snap); S9xControlPreSave(&ctl_snap);
FreezeStruct (stream, "CTL", &ctl_snap, SnapControls, COUNT (SnapControls)); FreezeStruct (stream, "CTL", &ctl_snap, SnapControls, COUNT (SnapControls));
// Timings // Timings
FreezeStruct (stream, "TIM", &Timings, SnapTimings, COUNT (SnapTimings)); FreezeStruct (stream, "TIM", &Timings, SnapTimings, COUNT (SnapTimings));
@ -907,7 +907,7 @@ void S9xFreezeToStream (STREAM stream)
{ {
S9xSA1PackStatus (); S9xSA1PackStatus ();
FreezeStruct (stream, "SA1", &SA1, SnapSA1, COUNT (SnapSA1)); FreezeStruct (stream, "SA1", &SA1, SnapSA1, COUNT (SnapSA1));
FreezeStruct (stream, "SAR", &SA1Registers, SnapSA1Registers, FreezeStruct (stream, "SAR", &SA1Registers, SnapSA1Registers,
COUNT (SnapSA1Registers)); COUNT (SnapSA1Registers));
} }
@ -944,7 +944,7 @@ void S9xFreezeToStream (STREAM stream)
} }
} }
#endif #endif
S9xSetSoundMute (FALSE); S9xSetSoundMute (FALSE);
#ifdef ZSNES_FX #ifdef ZSNES_FX
if (Settings.SuperFX) if (Settings.SuperFX)
@ -957,25 +957,25 @@ int S9xUnfreezeFromStream (STREAM stream)
char buffer [_MAX_PATH + 1]; char buffer [_MAX_PATH + 1];
char rom_filename [_MAX_PATH + 1]; char rom_filename [_MAX_PATH + 1];
int result; int result;
int version; int version;
int len = strlen (SNAPSHOT_MAGIC) + 1 + 4 + 1; int len = strlen (SNAPSHOT_MAGIC) + 1 + 4 + 1;
#ifdef NGC #ifdef NGC
GetMem(buffer, len); GetMem(buffer, len);
#else #else
if (READ_STREAM (buffer, len, stream) != len) if (READ_STREAM (buffer, len, stream) != len)
return (WRONG_FORMAT); return (WRONG_FORMAT);
#endif #endif
if (strncmp (buffer, SNAPSHOT_MAGIC, strlen (SNAPSHOT_MAGIC)) != 0) if (strncmp (buffer, SNAPSHOT_MAGIC, strlen (SNAPSHOT_MAGIC)) != 0)
return (WRONG_FORMAT); return (WRONG_FORMAT);
if ((version = atoi (&buffer [strlen (SNAPSHOT_MAGIC) + 1])) > SNAPSHOT_VERSION) if ((version = atoi (&buffer [strlen (SNAPSHOT_MAGIC) + 1])) > SNAPSHOT_VERSION)
return (WRONG_VERSION); return (WRONG_VERSION);
if ((result = UnfreezeBlock (stream, "NAM", (uint8 *) rom_filename, _MAX_PATH)) != SUCCESS) if ((result = UnfreezeBlock (stream, "NAM", (uint8 *) rom_filename, _MAX_PATH)) != SUCCESS)
return (result); return (result);
#ifndef NGC #ifndef NGC
if (strcasecmp (rom_filename, Memory.ROMFilename) != 0 && if (strcasecmp (rom_filename, Memory.ROMFilename) != 0 &&
strcasecmp (S9xBasename (rom_filename), S9xBasename (Memory.ROMFilename)) != 0) strcasecmp (S9xBasename (rom_filename), S9xBasename (Memory.ROMFilename)) != 0)
{ {
@ -983,7 +983,7 @@ int S9xUnfreezeFromStream (STREAM stream)
"Current loaded ROM image doesn't match that required by freeze-game file."); "Current loaded ROM image doesn't match that required by freeze-game file.");
} }
#endif #endif
// ## begin load ## // ## begin load ##
uint8* local_cpu = NULL; uint8* local_cpu = NULL;
uint8* local_registers = NULL; uint8* local_registers = NULL;
@ -1005,7 +1005,7 @@ int S9xUnfreezeFromStream (STREAM stream)
uint8* local_control_data = NULL; uint8* local_control_data = NULL;
uint8* local_timing_data = NULL; uint8* local_timing_data = NULL;
uint8* local_bsx_data = NULL; uint8* local_bsx_data = NULL;
do do
{ {
if ((result = UnfreezeStructCopy (stream, "CPU", &local_cpu, SnapCPU, COUNT (SnapCPU), version)) != SUCCESS) if ((result = UnfreezeStructCopy (stream, "CPU", &local_cpu, SnapCPU, COUNT (SnapCPU), version)) != SUCCESS)
@ -1044,7 +1044,7 @@ int S9xUnfreezeFromStream (STREAM stream)
if ((result = UnfreezeStructCopy (stream, "SAR", &local_sa1_registers, SnapSA1Registers, COUNT (SnapSA1Registers), version)) != SUCCESS) if ((result = UnfreezeStructCopy (stream, "SAR", &local_sa1_registers, SnapSA1Registers, COUNT (SnapSA1Registers), version)) != SUCCESS)
break; break;
} }
if ((result = UnfreezeStructCopy (stream, "SP7", &local_spc, SnapSPC7110, COUNT(SnapSPC7110), version)) != SUCCESS) if ((result = UnfreezeStructCopy (stream, "SP7", &local_spc, SnapSPC7110, COUNT(SnapSPC7110), version)) != SUCCESS)
{ {
if(Settings.SPC7110) if(Settings.SPC7110)
@ -1089,7 +1089,7 @@ int S9xUnfreezeFromStream (STREAM stream)
} while(false); } while(false);
// ## end load ## // ## end load ##
if (result == SUCCESS) if (result == SUCCESS)
{ {
uint32 old_flags = CPU.Flags; uint32 old_flags = CPU.Flags;
@ -1125,7 +1125,7 @@ int S9xUnfreezeFromStream (STREAM stream)
{ {
UnfreezeStructFromCopy (&rtc_f9, SnapS7RTC, COUNT (SnapS7RTC), local_spc_rtc, version); UnfreezeStructFromCopy (&rtc_f9, SnapS7RTC, COUNT (SnapS7RTC), local_spc_rtc, version);
} }
struct SControlSnapshot ctl_snap; struct SControlSnapshot ctl_snap;
if(local_control_data) { if(local_control_data) {
UnfreezeStructFromCopy (&ctl_snap, SnapControls, COUNT (SnapControls), local_control_data, version); UnfreezeStructFromCopy (&ctl_snap, SnapControls, COUNT (SnapControls), local_control_data, version);
@ -1141,7 +1141,7 @@ int S9xUnfreezeFromStream (STREAM stream)
ctl_snap.justifier_select=0; ctl_snap.justifier_select=0;
} }
S9xControlPostLoad(&ctl_snap); S9xControlPostLoad(&ctl_snap);
if (local_timing_data) if (local_timing_data)
UnfreezeStructFromCopy (&Timings, SnapTimings, COUNT (SnapTimings), local_timing_data, version); UnfreezeStructFromCopy (&Timings, SnapTimings, COUNT (SnapTimings), local_timing_data, version);
else // Must be an old snes9x savestate else // Must be an old snes9x savestate
@ -1191,7 +1191,7 @@ int S9xUnfreezeFromStream (STREAM stream)
{ {
S9xUpdateRTC(); S9xUpdateRTC();
} }
if (local_bsx_data) if (local_bsx_data)
S9xFixBSXAfterSnapshotLoad(); S9xFixBSXAfterSnapshotLoad();
@ -1214,7 +1214,7 @@ int S9xUnfreezeFromStream (STREAM stream)
Memory.FillRAM[0x4213]=Memory.FillRAM[0x4201]=0xFF; Memory.FillRAM[0x4213]=Memory.FillRAM[0x4201]=0xFF;
} }
if(local_apu) APU.Flags = Obsolete.SAPU_Flags; if(local_apu) APU.Flags = Obsolete.SAPU_Flags;
// FIXME: assuming the old savesate was made outside S9xMainLoop(). // FIXME: assuming the old savesate was made outside S9xMainLoop().
// In this case, V=0 and HDMA was already initialized. // In this case, V=0 and HDMA was already initialized.
CPU.WhichEvent = HC_HDMA_INIT_EVENT; CPU.WhichEvent = HC_HDMA_INIT_EVENT;
@ -1233,13 +1233,13 @@ int S9xUnfreezeFromStream (STREAM stream)
if (Settings.SuperFX) if (Settings.SuperFX)
S9xSuperFXPostLoadState (); S9xSuperFXPostLoadState ();
#endif #endif
S9xSRTCPostLoadState (); S9xSRTCPostLoadState ();
if (Settings.SDD1) if (Settings.SDD1)
S9xSDD1PostLoadState (); S9xSDD1PostLoadState ();
IAPU.NextAPUTimerPos = CPU.Cycles << SNES_APUTIMER_ACCURACY; IAPU.NextAPUTimerPos = CPU.Cycles << SNES_APUTIMER_ACCURACY;
IAPU.APUTimerCounter = 0; IAPU.APUTimerCounter = 0;
} }
if (local_cpu) delete [] local_cpu; if (local_cpu) delete [] local_cpu;
@ -1371,7 +1371,7 @@ void FreezeStruct (STREAM stream, char *name, void *base, FreezeData *fields,
#else #else
NGCFreezeBlock(name, block, len); NGCFreezeBlock(name, block, len);
#endif #endif
delete[] block; delete[] block;
} }
@ -1381,25 +1381,25 @@ void FreezeBlock (STREAM stream, char *name, uint8 *block, int size)
sprintf (buffer, "%s:%06d:", name, size); sprintf (buffer, "%s:%06d:", name, size);
WRITE_STREAM (buffer, strlen (buffer), stream); WRITE_STREAM (buffer, strlen (buffer), stream);
WRITE_STREAM (block, size, stream); WRITE_STREAM (block, size, stream);
} }
#ifdef NGC #ifdef NGC
void NGCFreezeStruct() void NGCFreezeStruct()
{ {
STREAM s = NULL; STREAM s = NULL;
FreezeStruct (s,"CPU", &CPU, SnapCPU, COUNT (SnapCPU)); FreezeStruct (s,"CPU", &CPU, SnapCPU, COUNT (SnapCPU));
FreezeStruct (s,"REG", &Registers, SnapRegisters, COUNT (SnapRegisters)); FreezeStruct (s,"REG", &Registers, SnapRegisters, COUNT (SnapRegisters));
FreezeStruct (s,"PPU", &PPU, SnapPPU, COUNT (SnapPPU)); FreezeStruct (s,"PPU", &PPU, SnapPPU, COUNT (SnapPPU));
FreezeStruct (s,"DMA", DMA, SnapDMA, COUNT (SnapDMA)); FreezeStruct (s,"DMA", DMA, SnapDMA, COUNT (SnapDMA));
// RAM and VRAM // RAM and VRAM
NGCFreezeBlock ("VRA", Memory.VRAM, 0x10000); NGCFreezeBlock ("VRA", Memory.VRAM, 0x10000);
NGCFreezeBlock ("RAM", Memory.RAM, 0x20000); NGCFreezeBlock ("RAM", Memory.RAM, 0x20000);
NGCFreezeBlock ("SRA", ::SRAM, 0x20000); NGCFreezeBlock ("SRA", ::SRAM, 0x20000);
NGCFreezeBlock ("FIL", Memory.FillRAM, 0x8000); NGCFreezeBlock ("FIL", Memory.FillRAM, 0x8000);
if (Settings.APUEnabled) if (Settings.APUEnabled)
{ {
// APU // APU
@ -1415,7 +1415,7 @@ void NGCFreezeStruct()
struct SControlSnapshot ctl_snap; struct SControlSnapshot ctl_snap;
S9xControlPreSave(&ctl_snap); S9xControlPreSave(&ctl_snap);
FreezeStruct (s,"CTL", &ctl_snap, SnapControls, COUNT (SnapControls)); FreezeStruct (s,"CTL", &ctl_snap, SnapControls, COUNT (SnapControls));
// Timings // Timings
FreezeStruct (s,"TIM", &Timings, SnapTimings, COUNT (SnapTimings)); FreezeStruct (s,"TIM", &Timings, SnapTimings, COUNT (SnapTimings));
@ -1424,7 +1424,7 @@ void NGCFreezeStruct()
{ {
S9xSA1PackStatus (); S9xSA1PackStatus ();
FreezeStruct (s,"SA1", &SA1, SnapSA1, COUNT (SnapSA1)); FreezeStruct (s,"SA1", &SA1, SnapSA1, COUNT (SnapSA1));
FreezeStruct (s,"SAR", &SA1Registers, SnapSA1Registers, FreezeStruct (s,"SAR", &SA1Registers, SnapSA1Registers,
COUNT (SnapSA1Registers)); COUNT (SnapSA1Registers));
} }
@ -1442,7 +1442,7 @@ void NGCFreezeStruct()
if (Settings.BS) if (Settings.BS)
{ {
FreezeStruct (s,"BSX", &BSX, SnapBSX, COUNT (SnapBSX)); FreezeStruct (s,"BSX", &BSX, SnapBSX, COUNT (SnapBSX));
} }
} }
#endif #endif
@ -1493,7 +1493,7 @@ int UnfreezeBlock (STREAM stream, char *name, uint8 *block, int size)
#else #else
return NGCUnFreezeBlock(name, block, size); return NGCUnFreezeBlock(name, block, size);
#endif #endif
} }
int UnfreezeBlockCopy (STREAM stream, char *name, uint8** block, int size) int UnfreezeBlockCopy (STREAM stream, char *name, uint8** block, int size)
@ -1641,14 +1641,14 @@ bool8 S9xSPCDump (const char *filename)
static uint8 version = { static uint8 version = {
0x1e 0x1e
}; };
FILE *fs; FILE *fs;
S9xSetSoundMute (TRUE); S9xSetSoundMute (TRUE);
if (!(fs = fopen (filename, "wb"))) if (!(fs = fopen (filename, "wb")))
return (FALSE); return (FALSE);
// The SPC file format: // The SPC file format:
// 0000: header: 'SNES-SPC700 Sound File Data v0.30',26,26,26 // 0000: header: 'SNES-SPC700 Sound File Data v0.30',26,26,26
// 0036: version: $1e // 0036: version: $1e
@ -1671,7 +1671,7 @@ bool8 S9xSPCDump (const char *filename)
// 0000: Reserved: 36 bytes // 0000: Reserved: 36 bytes
// 0256: SPC700 RAM: 64K // 0256: SPC700 RAM: 64K
// ----: DSP Registers: 256 bytes // ----: DSP Registers: 256 bytes
if (fwrite (header, sizeof (header), 1, fs) != 1 || if (fwrite (header, sizeof (header), 1, fs) != 1 ||
fputc (version, fs) == EOF || fputc (version, fs) == EOF ||
fseek (fs, 37, SEEK_SET) == EOF || fseek (fs, 37, SEEK_SET) == EOF ||
@ -1699,24 +1699,24 @@ bool8 S9xUnfreezeZSNES (const char *filename)
{ {
FILE *fs; FILE *fs;
uint8 t [4000]; uint8 t [4000];
if (!(fs = fopen (filename, "rb"))) if (!(fs = fopen (filename, "rb")))
return (FALSE); return (FALSE);
if (fread (t, 64, 1, fs) == 1 && if (fread (t, 64, 1, fs) == 1 &&
strncmp ((char *) t, "ZSNES Save State File V0.6", 26) == 0) strncmp ((char *) t, "ZSNES Save State File V0.6", 26) == 0)
{ {
S9xReset (); S9xReset ();
S9xSetSoundMute (TRUE); S9xSetSoundMute (TRUE);
// 28 Curr cycle // 28 Curr cycle
CPU.V_Counter = READ_WORD (&t [29]); CPU.V_Counter = READ_WORD (&t [29]);
// 33 instrset // 33 instrset
Settings.APUEnabled = t [36]; Settings.APUEnabled = t [36];
// 34 bcycpl cycles per scanline // 34 bcycpl cycles per scanline
// 35 cycphb cyclers per hblank // 35 cycphb cyclers per hblank
Registers.A.W = READ_WORD (&t [41]); Registers.A.W = READ_WORD (&t [41]);
Registers.DB = t [43]; Registers.DB = t [43];
Registers.PB = t [44]; Registers.PB = t [44];
@ -1726,7 +1726,7 @@ bool8 S9xUnfreezeZSNES (const char *filename)
Registers.Y.W = READ_WORD (&t [51]); Registers.Y.W = READ_WORD (&t [51]);
Registers.P.W = READ_WORD (&t [53]); Registers.P.W = READ_WORD (&t [53]);
Registers.PCw = READ_WORD (&t [55]); Registers.PCw = READ_WORD (&t [55]);
fread (t, 1, 8, fs); fread (t, 1, 8, fs);
fread (t, 1, 3019, fs); fread (t, 1, 3019, fs);
S9xSetCPU (t [2], 0x4200); S9xSetCPU (t [2], 0x4200);
@ -1735,11 +1735,11 @@ bool8 S9xUnfreezeZSNES (const char *filename)
PPU.IRQHBeamPos = READ_WORD (&t [2527]); PPU.IRQHBeamPos = READ_WORD (&t [2527]);
PPU.Brightness = t [6]; PPU.Brightness = t [6];
PPU.ForcedBlanking = t [8] >> 7; PPU.ForcedBlanking = t [8] >> 7;
int i; int i;
for (i = 0; i < 544; i++) for (i = 0; i < 544; i++)
S9xSetPPU (t [0464 + i], 0x2104); S9xSetPPU (t [0464 + i], 0x2104);
PPU.OBJNameBase = READ_WORD (&t [9]); PPU.OBJNameBase = READ_WORD (&t [9]);
PPU.OBJNameSelect = READ_WORD (&t [13]) - PPU.OBJNameBase; PPU.OBJNameSelect = READ_WORD (&t [13]) - PPU.OBJNameBase;
switch (t [18]) switch (t [18])
@ -1810,7 +1810,7 @@ bool8 S9xUnfreezeZSNES (const char *filename)
PPU.VMA.Address = READ_DWORD (&t [101]); PPU.VMA.Address = READ_DWORD (&t [101]);
for (i = 0; i < 512; i++) for (i = 0; i < 512; i++)
S9xSetPPU (t [1488 + i], 0x2122); S9xSetPPU (t [1488 + i], 0x2122);
PPU.CGADD = (uint8) READ_WORD (&t [105]); PPU.CGADD = (uint8) READ_WORD (&t [105]);
Memory.FillRAM [0x212c] = t [108]; Memory.FillRAM [0x212c] = t [108];
Memory.FillRAM [0x212d] = t [109]; Memory.FillRAM [0x212d] = t [109];
@ -1851,13 +1851,13 @@ bool8 S9xUnfreezeZSNES (const char *filename)
Memory.FillRAM [0x2135] = t [157]; // Matrix mult Memory.FillRAM [0x2135] = t [157]; // Matrix mult
Memory.FillRAM [0x2136] = t [158]; // Matrix mult Memory.FillRAM [0x2136] = t [158]; // Matrix mult
PPU.WRAM = READ_DWORD (&t [161]); PPU.WRAM = READ_DWORD (&t [161]);
for (i = 0; i < 128; i++) for (i = 0; i < 128; i++)
S9xSetCPU (t [165 + i], 0x4300 + i); S9xSetCPU (t [165 + i], 0x4300 + i);
if (t [294]) if (t [294])
CPU.IRQActive |= PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE; CPU.IRQActive |= PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE;
S9xSetCPU (t [296], 0x420c); S9xSetCPU (t [296], 0x420c);
// hdmadata t[297] + 8 * 19 // hdmadata t[297] + 8 * 19
PPU.FixedColourRed = t [450]; PPU.FixedColourRed = t [450];
@ -1866,35 +1866,35 @@ bool8 S9xUnfreezeZSNES (const char *filename)
S9xSetPPU (t [454], 0x2130); S9xSetPPU (t [454], 0x2130);
S9xSetPPU (t [455], 0x2131); S9xSetPPU (t [455], 0x2131);
// vraminctype ... // vraminctype ...
fread (Memory.RAM, 1, 128 * 1024, fs); fread (Memory.RAM, 1, 128 * 1024, fs);
fread (Memory.VRAM, 1, 64 * 1024, fs); fread (Memory.VRAM, 1, 64 * 1024, fs);
if (Settings.APUEnabled) if (Settings.APUEnabled)
{ {
// SNES SPC700 RAM (64K) // SNES SPC700 RAM (64K)
fread (IAPU.RAM, 1, 64 * 1024, fs); fread (IAPU.RAM, 1, 64 * 1024, fs);
// Junk 16 bytes // Junk 16 bytes
fread (t, 1, 16, fs); fread (t, 1, 16, fs);
// SNES SPC700 state and internal ZSNES SPC700 emulation state // SNES SPC700 state and internal ZSNES SPC700 emulation state
fread (t, 1, 304, fs); fread (t, 1, 304, fs);
APURegisters.PC = READ_DWORD (&t [0]); APURegisters.PC = READ_DWORD (&t [0]);
APURegisters.YA.B.A = t [4]; APURegisters.YA.B.A = t [4];
APURegisters.X = t [8]; APURegisters.X = t [8];
APURegisters.YA.B.Y = t [12]; APURegisters.YA.B.Y = t [12];
APURegisters.P = t [16]; APURegisters.P = t [16];
APURegisters.S = t [24]; APURegisters.S = t [24];
APU.Cycles = READ_DWORD (&t [32]); APU.Cycles = READ_DWORD (&t [32]);
APU.ShowROM = (IAPU.RAM [0xf1] & 0x80) != 0; APU.ShowROM = (IAPU.RAM [0xf1] & 0x80) != 0;
APU.OutPorts [0] = t [36]; APU.OutPorts [0] = t [36];
APU.OutPorts [1] = t [37]; APU.OutPorts [1] = t [37];
APU.OutPorts [2] = t [38]; APU.OutPorts [2] = t [38];
APU.OutPorts [3] = t [39]; APU.OutPorts [3] = t [39];
APU.TimerEnabled [0] = (t [40] & 1) != 0; APU.TimerEnabled [0] = (t [40] & 1) != 0;
APU.TimerEnabled [1] = (t [40] & 2) != 0; APU.TimerEnabled [1] = (t [40] & 2) != 0;
APU.TimerEnabled [2] = (t [40] & 4) != 0; APU.TimerEnabled [2] = (t [40] & 4) != 0;
@ -1904,17 +1904,17 @@ bool8 S9xUnfreezeZSNES (const char *filename)
APU.Timer [0] = t [44]; APU.Timer [0] = t [44];
APU.Timer [1] = t [45]; APU.Timer [1] = t [45];
APU.Timer [2] = t [46]; APU.Timer [2] = t [46];
memmove (APU.ExtraRAM, &t [48], 64); memmove (APU.ExtraRAM, &t [48], 64);
// Internal ZSNES sound DSP state // Internal ZSNES sound DSP state
fread (t, 1, 1068, fs); fread (t, 1, 1068, fs);
// SNES sound DSP register values // SNES sound DSP register values
fread (t, 1, 256, fs); fread (t, 1, 256, fs);
uint8 saved = IAPU.RAM [0xf2]; uint8 saved = IAPU.RAM [0xf2];
for (i = 0; i < 128; i++) for (i = 0; i < 128; i++)
{ {
switch (i) switch (i)
@ -1933,7 +1933,7 @@ bool8 S9xUnfreezeZSNES (const char *filename)
IAPU.RAM [0xf2] = APU_KON; IAPU.RAM [0xf2] = APU_KON;
S9xSetAPUDSP (t [APU_KON]); S9xSetAPUDSP (t [APU_KON]);
IAPU.RAM [0xf2] = saved; IAPU.RAM [0xf2] = saved;
S9xSetSoundMute (FALSE); S9xSetSoundMute (FALSE);
IAPU.PC = IAPU.RAM + APURegisters.PC; IAPU.PC = IAPU.RAM + APURegisters.PC;
S9xAPUUnpackStatus (); S9xAPUUnpackStatus ();
@ -1950,7 +1950,7 @@ bool8 S9xUnfreezeZSNES (const char *filename)
IAPU.APUExecuting = FALSE; IAPU.APUExecuting = FALSE;
S9xSetSoundMute (TRUE); S9xSetSoundMute (TRUE);
} }
if (Settings.SuperFX) if (Settings.SuperFX)
{ {
fread (::SRAM, 1, 64 * 1024, fs); fread (::SRAM, 1, 64 * 1024, fs);
@ -1970,7 +1970,7 @@ bool8 S9xUnfreezeZSNES (const char *filename)
S9xSetSA1 (((READ_DWORD (&t [28]) - (4096*1024-0x6000))) >> 13, 0x2224); S9xSetSA1 (((READ_DWORD (&t [28]) - (4096*1024-0x6000))) >> 13, 0x2224);
S9xSetSA1 (t [36], 0x2201); S9xSetSA1 (t [36], 0x2201);
S9xSetSA1 (t [41], 0x2209); S9xSetSA1 (t [41], 0x2209);
SA1Registers.A.W = READ_DWORD (&t [592]); SA1Registers.A.W = READ_DWORD (&t [592]);
SA1Registers.X.W = READ_DWORD (&t [596]); SA1Registers.X.W = READ_DWORD (&t [596]);
SA1Registers.Y.W = READ_DWORD (&t [600]); SA1Registers.Y.W = READ_DWORD (&t [600]);
@ -1980,9 +1980,9 @@ bool8 S9xUnfreezeZSNES (const char *filename)
SA1Registers.S.W = READ_DWORD (&t [616]); SA1Registers.S.W = READ_DWORD (&t [616]);
SA1Registers.PCw = READ_DWORD (&t [636]); SA1Registers.PCw = READ_DWORD (&t [636]);
SA1Registers.P.W = t [620] | (t [624] << 8); SA1Registers.P.W = t [620] | (t [624] << 8);
memmove (&Memory.FillRAM [0x3000], t + 692, 2 * 1024); memmove (&Memory.FillRAM [0x3000], t + 692, 2 * 1024);
fread (::SRAM, 1, 64 * 1024, fs); fread (::SRAM, 1, 64 * 1024, fs);
fseek (fs, 64 * 1024, SEEK_CUR); fseek (fs, 64 * 1024, SEEK_CUR);
S9xFixSA1AfterSnapshotLoad (); S9xFixSA1AfterSnapshotLoad ();
@ -1991,10 +1991,10 @@ bool8 S9xUnfreezeZSNES (const char *filename)
{ {
uint32 temp; uint32 temp;
fread(&s7r.bank50, 1,0x10000, fs); fread(&s7r.bank50, 1,0x10000, fs);
//NEWSYM SPCMultA, dd 0 4820-23 //NEWSYM SPCMultA, dd 0 4820-23
fread(&temp, 1, 4, fs); fread(&temp, 1, 4, fs);
s7r.reg4820=temp&(0x0FF); s7r.reg4820=temp&(0x0FF);
s7r.reg4821=(temp>>8)&(0x0FF); s7r.reg4821=(temp>>8)&(0x0FF);
s7r.reg4822=(temp>>16)&(0x0FF); s7r.reg4822=(temp>>16)&(0x0FF);
@ -2013,12 +2013,12 @@ bool8 S9xUnfreezeZSNES (const char *filename)
//NEWSYM SPCMulRes, dd 0 4828-B //NEWSYM SPCMulRes, dd 0 4828-B
fread(&temp, 1, 4, fs); fread(&temp, 1, 4, fs);
s7r.reg4828=temp&(0x0FF); s7r.reg4828=temp&(0x0FF);
s7r.reg4829=(temp>>8)&(0x0FF); s7r.reg4829=(temp>>8)&(0x0FF);
s7r.reg482A=(temp>>16)&(0x0FF); s7r.reg482A=(temp>>16)&(0x0FF);
s7r.reg482B=(temp>>24)&(0x0FF); s7r.reg482B=(temp>>24)&(0x0FF);
//NEWSYM SPCDivRes, dd 0 482C-D //NEWSYM SPCDivRes, dd 0 482C-D
fread(&temp, 1,4,fs); fread(&temp, 1,4,fs);
s7r.reg482C=temp&(0x0FF); s7r.reg482C=temp&(0x0FF);
@ -2026,14 +2026,14 @@ bool8 S9xUnfreezeZSNES (const char *filename)
//NEWSYM SPC7110BankA, dd 020100h 4831-3 //NEWSYM SPC7110BankA, dd 020100h 4831-3
fread(&temp, 1, 4, fs); fread(&temp, 1, 4, fs);
s7r.reg4831=temp&(0x0FF); s7r.reg4831=temp&(0x0FF);
s7r.reg4832=(temp>>8)&(0x0FF); s7r.reg4832=(temp>>8)&(0x0FF);
s7r.reg4833=(temp>>16)&(0x0FF); s7r.reg4833=(temp>>16)&(0x0FF);
//NEWSYM SPC7110RTCStat, dd 0 4840,init,command, index //NEWSYM SPC7110RTCStat, dd 0 4840,init,command, index
fread(&temp, 1, 4, fs); fread(&temp, 1, 4, fs);
s7r.reg4840=temp&(0x0FF); s7r.reg4840=temp&(0x0FF);
//NEWSYM SPC7110RTC, db 00,00,00,00,00,00,01,00,01,00,00,00,00,00,0Fh,00 //NEWSYM SPC7110RTC, db 00,00,00,00,00,00,01,00,01,00,00,00,00,00,0Fh,00
@ -2077,7 +2077,7 @@ fread(&temp, 1, 4, fs);
//NEWSYM SPCROMPtr, dd 0 4811-4813 //NEWSYM SPCROMPtr, dd 0 4811-4813
fread(&temp, 1, 4, fs); fread(&temp, 1, 4, fs);
s7r.reg4811=temp&(0x0FF); s7r.reg4811=temp&(0x0FF);
s7r.reg4812=(temp>>8)&(0x0FF); s7r.reg4812=(temp>>8)&(0x0FF);
s7r.reg4813=(temp>>16)&(0x0FF); s7r.reg4813=(temp>>16)&(0x0FF);
@ -2093,13 +2093,13 @@ fread(&temp, 1, 4, fs);
s7r.reg4817=(temp>>8)&(0x0FF); s7r.reg4817=(temp>>8)&(0x0FF);
//NEWSYM SPCROMCom, dd 0 4818 //NEWSYM SPCROMCom, dd 0 4818
fread(&temp, 1, 4, fs); fread(&temp, 1, 4, fs);
s7r.reg4818=temp&(0x0FF); s7r.reg4818=temp&(0x0FF);
//NEWSYM SPCCompPtr, dd 0 4801-4804 (+b50i) if"manual" //NEWSYM SPCCompPtr, dd 0 4801-4804 (+b50i) if"manual"
fread(&temp, 1, 4, fs); fread(&temp, 1, 4, fs);
//do table check //do table check
s7r.reg4801=temp&(0x0FF); s7r.reg4801=temp&(0x0FF);
s7r.reg4802=(temp>>8)&(0x0FF); s7r.reg4802=(temp>>8)&(0x0FF);
s7r.reg4803=(temp>>16)&(0x0FF); s7r.reg4803=(temp>>16)&(0x0FF);
@ -2114,26 +2114,26 @@ fread(&temp, 1, 4, fs);
s7r.reg480A=(temp>>8)&(0x0FF); s7r.reg480A=(temp>>8)&(0x0FF);
//NEWSYM SPCCompCommand, dd 0 480B //NEWSYM SPCCompCommand, dd 0 480B
fread(&temp, 1, 4, fs); fread(&temp, 1, 4, fs);
s7r.reg480B=temp&(0x0FF); s7r.reg480B=temp&(0x0FF);
//NEWSYM SPCCheckFix, dd 0 written(if 1, then set writtne to max value!) //NEWSYM SPCCheckFix, dd 0 written(if 1, then set writtne to max value!)
fread(&temp, 1, 4, fs); fread(&temp, 1, 4, fs);
(temp&(0x0FF))?s7r.written=0x1F:s7r.written=0x00; (temp&(0x0FF))?s7r.written=0x1F:s7r.written=0x00;
//NEWSYM SPCSignedVal, dd 0 482E //NEWSYM SPCSignedVal, dd 0 482E
fread(&temp, 1, 4, fs); fread(&temp, 1, 4, fs);
s7r.reg482E=temp&(0x0FF); s7r.reg482E=temp&(0x0FF);
} }
fclose (fs); fclose (fs);
Memory.FixROMSpeed (); Memory.FixROMSpeed ();
IPPU.ColorsChanged = TRUE; IPPU.ColorsChanged = TRUE;
IPPU.OBJChanged = TRUE; IPPU.OBJChanged = TRUE;
CPU.InDMA = CPU.InWRAM_DMA = FALSE; CPU.InDMA = CPU.InWRAM_DMA = FALSE;
S9xFixColourBrightness (); S9xFixColourBrightness ();
IPPU.RenderThisFrame = FALSE; IPPU.RenderThisFrame = FALSE;
S9xFixSoundAfterSnapshotLoad (1); S9xFixSoundAfterSnapshotLoad (1);
ICPU.ShiftedPB = Registers.PB << 16; ICPU.ShiftedPB = Registers.PB << 16;
ICPU.ShiftedDB = Registers.DB << 16; ICPU.ShiftedDB = Registers.DB << 16;