Work around very brittle snapshot code

This commit is contained in:
Snesrev
2023-03-06 03:42:00 +01:00
parent e3d2202053
commit 75ff49d4f2
5 changed files with 12 additions and 5 deletions

View File

@@ -54,7 +54,7 @@ void apu_reset(Apu* apu) {
}
void apu_saveload(Apu *apu, SaveLoadFunc *func, void *ctx) {
func(ctx, apu->ram, offsetof(Apu, hist) - offsetof(Apu, ram));
func(ctx, apu->ram, offsetof(Apu, pad) + 6 - offsetof(Apu, ram));
dsp_saveload(apu->dsp, func, ctx);
spc_saveload(apu->spc, func, ctx);
}

View File

@@ -33,6 +33,8 @@ struct Apu {
uint8_t outPorts[4];
Timer timer[3];
uint8_t cpuCyclesLeft;
uint8_t pad[6];
union {
struct DspRegWriteHistory hist;

View File

@@ -65,7 +65,7 @@ void dma_reset(Dma* dma) {
}
void dma_saveload(Dma *dma, SaveLoadFunc *func, void *ctx) {
func(ctx, &dma->channel, sizeof(Dma) - offsetof(Dma, channel));
func(ctx, &dma->channel, offsetof(Dma, pad) + 7 - offsetof(Dma, channel));
}
uint8_t dma_read(Dma* dma, uint16_t adr) {

View File

@@ -40,6 +40,7 @@ struct Dma {
uint16_t hdmaTimer;
uint32_t dmaTimer;
bool dmaBusy;
uint8_t pad[7];
};
Dma* dma_init(Snes* snes);

View File

@@ -24,16 +24,19 @@ struct Snes {
Ppu* ppu, *snes_ppu, *my_ppu;
Dma* dma;
Cart* cart;
Input *input1;
Input *input2;
// input
bool debug_cycles;
bool debug_apu_cycles;
bool disableRender;
uint8_t runningWhichVersion;
Input* input1;
Input* input2;
// ram
uint8_t *ram;
uint32_t ramAdr;
uint8_t *ram;
uint8_t padx[4];
// frame timing
uint16_t hPos;
uint16_t vPos;
@@ -41,6 +44,7 @@ struct Snes {
// cpu handling
uint8_t cpuCyclesLeft;
uint8_t cpuMemOps;
uint8_t padpad[2];
double apuCatchupCycles;
// nmi / irq
bool hIrqEnabled;