read_nothing\r
};\r
\r
-static int padTHLatency[3]; // TODO this should be in the save file structures\r
-static int padTLLatency[3]; // TODO this should be in the save file structures\r
+static int padTHLatency[3];\r
+static int padTLLatency[3];\r
\r
static NOINLINE u32 port_read(int i)\r
{\r
\r
// pull-ups: should be 0x7f, but Decap Attack has a bug where it temp.\r
// disables output before doing TH-low read, so emulate RC filter for TH.\r
- // Decap Attack reportedly doesn't work on Nomad but works on must\r
+ // Decap Attack reportedly doesn't work on Nomad but works on most\r
// other MD revisions (different pull-up strength?).\r
u32 mask = 0x3f;\r
if (CYCLES_GE(SekCyclesDone(), padTHLatency[i])) {\r
PicoMem.ioports[a] = d;\r
}\r
\r
+int io_ports_pack(void *buf, size_t size)\r
+{\r
+ size_t b, i;\r
+ memcpy(buf, PicoMem.ioports, (b = sizeof(PicoMem.ioports)));\r
+ for (i = 0; i < ARRAY_SIZE(Pico.m.padTHPhase); i++)\r
+ save_u8_(buf, &b, Pico.m.padTHPhase[i]);\r
+ for (i = 0; i < ARRAY_SIZE(Pico.m.padDelay); i++)\r
+ save_u8_(buf, &b, Pico.m.padDelay[i]);\r
+ for (i = 0; i < ARRAY_SIZE(padTHLatency); i++) {\r
+ save_u32(buf, &b, padTHLatency[i]);\r
+ save_u32(buf, &b, padTLLatency[i]);\r
+ }\r
+ assert(b <= size);\r
+ return b;\r
+}\r
+\r
+void io_ports_unpack(const void *buf, size_t size)\r
+{\r
+ size_t b, i;\r
+ memcpy(PicoMem.ioports, buf, (b = sizeof(PicoMem.ioports)));\r
+ for (i = 0; i < ARRAY_SIZE(Pico.m.padTHPhase); i++)\r
+ Pico.m.padTHPhase[i] = load_u8_(buf, &b);\r
+ for (i = 0; i < ARRAY_SIZE(Pico.m.padDelay); i++)\r
+ Pico.m.padDelay[i] = load_u8_(buf, &b);\r
+ for (i = 0; i < ARRAY_SIZE(padTHLatency); i++) {\r
+ padTHLatency[i] = load_u32(buf, &b);\r
+ padTLLatency[i] = load_u32(buf, &b);\r
+ }\r
+ assert(b <= size);\r
+}\r
+\r
static int z80_cycles_from_68k(void)\r
{\r
int m68k_cnt = SekCyclesDone() - Pico.t.m68c_frame_start;\r
void PicoWrite8_io(u32 a, u32 d);\r
void PicoWrite16_io(u32 a, u32 d);\r
u32 PicoReadPad(int i, u32 mask);\r
+int io_ports_pack(void *buf, size_t size);\r
+void io_ports_unpack(const void *buf, size_t size);\r
\r
// pico/memory.c\r
PICO_INTERNAL void PicoMemSetupPico(void);\r
CHUNK_RC, // old\r
CHUNK_MISC_CD,\r
//\r
- CHUNK_IOPORTS, // versions < 1.70 did not save that..\r
+ CHUNK_IOPORTS, // old\r
CHUNK_SMS, // 25\r
// 32x\r
CHUNK_MSH2,\r
CHUNK_CD_MSD,\r
CHUNK_VDP,\r
CHUNK_FM_TIMERS,\r
- CHUNK_FMv3,\r
+ CHUNK_FMv3 = 60,\r
+ CHUNK_IOPORTSv2,\r
//\r
CHUNK_DEFAULT_COUNT,\r
CHUNK_CARTHW_ = CHUNK_CARTHW, // 64 (defined in PicoInt)\r
CHECKED_WRITE_BUFF(CHUNK_RAM, PicoMem.ram);\r
CHECKED_WRITE_BUFF(CHUNK_VSRAM, PicoMem.vsram);\r
CHECKED_WRITE_BUFF(CHUNK_IOPORTS, PicoMem.ioports);\r
+ len = io_ports_pack(buf2, CHUNK_LIMIT_W);\r
+ CHECKED_WRITE(CHUNK_IOPORTSv2, len, buf2);\r
if (PicoIn.AHW & PAHW_PICO) {\r
len = PicoPicoPCMSave(buf2, CHUNK_LIMIT_W);\r
CHECKED_WRITE(CHUNK_PICO_PCM, len, buf2);\r
CHECKED_READ2(0x200+4, ym_regs);\r
ym2612_unpack_state_old();\r
break;\r
- case CHUNK_FM_TIMERS:\r
- CHECKED_READ(len, buf);\r
- ym2612_unpack_timers(buf, len);\r
- break;\r
- case CHUNK_FMv3:\r
- CHECKED_READ(len, buf);\r
- YM2612PicoStateLoad3(buf, len);\r
- break;\r
+ case CHUNK_FM_TIMERS: CHECKED_READ(len, buf); ym2612_unpack_timers(buf, len); break;\r
+ case CHUNK_FMv3: CHECKED_READ(len, buf); YM2612PicoStateLoad3(buf, len); break;\r
+ case CHUNK_IOPORTSv2: CHECKED_READ(len, buf); io_ports_unpack(buf, len); break;\r
\r
case CHUNK_PICO_PCM:\r
CHECKED_READ(len, buf);\r