Adjust snapshot to load old DSP data.

This commit is contained in:
BearOso 2023-03-16 15:21:41 -05:00
parent 410c52a7c9
commit f1881a21fc
3 changed files with 26 additions and 8 deletions

View File

@ -350,7 +350,6 @@ void S9xAPULoadState(uint8 *block)
SNES::smp.load_state(&ptr);
SNES::dsp.load_state(&ptr);
spc::reference_time = SNES::get_le32(ptr);
ptr += sizeof(int32);
spc::remainder = SNES::get_le32(ptr);

View File

@ -1576,16 +1576,35 @@ int S9xUnfreezeFromStream (STREAM stream)
if (local_fillram)
memcpy(Memory.FillRAM, local_fillram, 0x8000);
if(version < SNAPSHOT_VERSION_BAPU) {
if (version < SNAPSHOT_VERSION_BAPU)
{
printf("Using Blargg APU snapshot loading (snapshot version %d, current is %d)\n...", version, SNAPSHOT_VERSION);
S9xAPULoadBlarggState(local_apu_sound);
} else
S9xAPULoadState(local_apu_sound);
}
else if (version < 12)
{
printf("Adjusting old APU snapshot (snapshot version %d, current is %d)\n", version, SNAPSHOT_VERSION);
const size_t spc_block_size = 65700;
const size_t old_dsp_block_size = 514;
const size_t added_bytes_v12 = 128;
const size_t bytes_afterward = 16;
// Shift end to make room for extra 128 bytes
memmove(local_apu_sound + spc_block_size + old_dsp_block_size + added_bytes_v12,
local_apu_sound + spc_block_size + old_dsp_block_size,
bytes_afterward);
// Copy saved internal registers to external registers
memmove(local_apu_sound + spc_block_size + old_dsp_block_size, local_apu_sound + spc_block_size, added_bytes_v12);
S9xAPULoadState(local_apu_sound);
}
else if (version >= 12)
{
S9xAPULoadState(local_apu_sound);
}
struct SControlSnapshot ctl_snap;
UnfreezeStructFromCopy(&ctl_snap, SnapControls, COUNT(SnapControls), local_control_data, version);
struct SControlSnapshot ctl_snap;
UnfreezeStructFromCopy(&ctl_snap, SnapControls, COUNT(SnapControls), local_control_data, version);
UnfreezeStructFromCopy(&Timings, SnapTimings, COUNT(SnapTimings), local_timing_data, version);
UnfreezeStructFromCopy(&Timings, SnapTimings, COUNT(SnapTimings), local_timing_data, version);
if (local_superfx)
{

View File

@ -13,7 +13,7 @@
#define SNAPSHOT_VERSION_IRQ 7
#define SNAPSHOT_VERSION_BAPU 8
#define SNAPSHOT_VERSION_IRQ_2018 11 // irq changes were introduced earlier, since this we store NextIRQTimer directly
#define SNAPSHOT_VERSION 11
#define SNAPSHOT_VERSION 12
#define SUCCESS 1
#define WRONG_FORMAT (-1)