return afile;\r
}\r
\r
-// legacy savestate loading\r
-#define SCANP(f, x) areaRead(&Pico.x, sizeof(Pico.x), 1, f)\r
-\r
-static int state_load_legacy(void *file)\r
-{\r
- unsigned char head[32];\r
- unsigned char cpu[0x60];\r
- unsigned char cpu_z80[Z80_STATE_SIZE];\r
- void *ym2612_regs;\r
- int ok;\r
-\r
- memset(&cpu,0,sizeof(cpu));\r
- memset(&cpu_z80,0,sizeof(cpu_z80));\r
-\r
- memset(head, 0, sizeof(head));\r
- areaRead(head, sizeof(head), 1, file);\r
- if (strcmp((char *)head, "Pico") != 0)\r
- return -1;\r
-\r
- elprintf(EL_STATUS, "legacy savestate");\r
-\r
- // Scan all the memory areas:\r
- SCANP(file, ram);\r
- SCANP(file, vram);\r
- SCANP(file, zram);\r
- SCANP(file, cram);\r
- SCANP(file, vsram);\r
-\r
- // Pack, scan and unpack the cpu data:\r
- areaRead(cpu, sizeof(cpu), 1, file);\r
- SekUnpackCpu(cpu, 0);\r
-\r
- SCANP(file, m);\r
- SCANP(file, video);\r
-\r
- ok = areaRead(cpu_z80, sizeof(cpu_z80), 1, file) == sizeof(cpu_z80);\r
- // do not unpack if we fail to load z80 state\r
- if (!ok) z80_reset();\r
- else z80_unpack(cpu_z80);\r
-\r
- ym2612_regs = YM2612GetRegs();\r
- areaRead(sn76496_regs, 28*4, 1, file);\r
- areaRead(ym2612_regs, 0x200+4, 1, file);\r
- ym2612_unpack_state();\r
-\r
- return 0;\r
-}\r
-\r
// ---------------------------------------------------------------------------\r
\r
typedef enum {\r
pcd_state_loaded();\r
}\r
\r
+ Pico.m.dirtyPal = 1;\r
+ Pico.video.status &= ~(SR_VB | SR_F);\r
+\r
retval = 0;\r
\r
out:\r
\r
if (is_save)\r
ret = state_save(afile);\r
- else {\r
+ else\r
ret = state_load(afile);\r
- if (ret != 0) {\r
- areaSeek(afile, 0, SEEK_SET);\r
- ret = state_load_legacy(afile);\r
- }\r
-\r
- Pico.m.dirtyPal = 1;\r
- Pico.video.status &= ~(SR_VB | SR_F);\r
- }\r
\r
return ret;\r
}\r
#endif
}
-/* save state stuff */
-static int z80_unpack_legacy(const void *data)
-{
-#if defined(_USE_DRZ80)
- if (*(int *)data == 0x015A7244) { // "DrZ" v1 save?
- u32 pc, sp;
- memcpy(&drZ80, data+4, 0x54);
- pc = (drZ80.Z80PC - drZ80.Z80PC_BASE) & 0xffff;
- sp = (drZ80.Z80SP - drZ80.Z80SP_BASE) & 0xffff;
- // update bases
- drz80_load_pcsp(pc, sp);
- return 0;
- }
-#elif defined(_USE_CZ80)
- if (*(int *)data == 0x00007a43) { // "Cz" save?
- memcpy(&CZ80, data+8, offsetof(cz80_struc, BasePC));
- Cz80_Set_Reg(&CZ80, CZ80_PC, *(int *)(data+4));
- return 0;
- }
-#endif
- return -1;
-}
-
struct z80sr_main {
u8 a, f;
u8 b, c;
{
const struct z80_state *s = data;
if (strcmp(s->magic, "Z80") != 0) {
- if (z80_unpack_legacy(data) != 0)
- goto fail;
- elprintf(EL_STATUS, "legacy z80 state");
+ elprintf(EL_STATUS, "legacy z80 state - ignored");
return 0;
}
Cz80_Set_Reg(&CZ80, CZ80_IRQ, s->irq_pending ? HOLD_LINE : CLEAR_LINE);
return 0;
}
+#else
+ return 0;
#endif
-
-fail:
- elprintf(EL_STATUS|EL_ANOMALY, "z80_unpack failed");
- z80_reset();
- z80_int();
- return -1;
}
void z80_exit(void)