/*
* PicoDrive
- * (C) notaz, 2009,2010
+ * (C) notaz, 2009,2010,2013
*
* This work is licensed under the terms of MAME license.
* See COPYING file in the top-level directory.
typedef void (event_cb)(unsigned int now);
-static unsigned int event_times[P32X_EVENT_COUNT];
+unsigned int event_times[P32X_EVENT_COUNT];
static unsigned int event_time_next;
static event_cb *event_cbs[] = {
[P32X_EVENT_PWM] = pwm_irq_event,
void Pico32xStateLoaded(void)
{
+ sh2s[0].m68krcycles_done = sh2s[1].m68krcycles_done = SekCycleCntT;
+ p32x_poll_event(3, 0);
+
bank_switch(Pico32x.regs[4 / 2]);
Pico32xSwapDRAM((Pico32x.vdp_regs[0x0a / 2] & P32XV_FS) ^ P32XV_FS);
- p32x_poll_event(3, 0);
Pico32x.dirty_pal = 1;
memset(Pico32xMem->pwm, 0, sizeof(Pico32xMem->pwm));
p32x_timers_recalc();
// 32x/32x.c\r
#ifndef NO_32X\r
extern struct Pico32x Pico32x;\r
+enum p32x_event {\r
+ P32X_EVENT_PWM,\r
+ P32X_EVENT_FILLEND,\r
+ P32X_EVENT_COUNT,\r
+};\r
+extern unsigned int event_times[P32X_EVENT_COUNT];\r
+\r
void Pico32xInit(void);\r
void PicoPower32x(void);\r
void PicoReset32x(void);\r
void p32x_sync_sh2s(unsigned int m68k_target);\r
void p32x_update_irls(int nested_call);\r
void p32x_reset_sh2s(void);\r
-\r
-enum p32x_event {\r
- P32X_EVENT_PWM,\r
- P32X_EVENT_FILLEND,\r
- P32X_EVENT_COUNT,\r
-};\r
void p32x_event_schedule(enum p32x_event event, unsigned int now, int after);\r
\r
// 32x/memory.c\r
cpu[0x4d] = (context->execinfo & FM68K_HALTED) ? 1 : 0;\r
#endif\r
\r
- *(unsigned int *)(cpu+0x40)=pc;\r
+ *(unsigned int *)(cpu+0x40) = pc;\r
+ *(unsigned int *)(cpu+0x50) = SekCycleCntT;\r
}\r
\r
PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)\r
context->execinfo &= ~FM68K_HALTED;\r
if (cpu[0x4d]&1) context->execinfo |= FM68K_HALTED;\r
#endif\r
+ SekCycleCntT = *(unsigned int *)(cpu+0x50);\r
}\r
\r
\r
CHUNK_SDRAM,\r
CHUNK_DRAM,\r
CHUNK_32XPAL,\r
+ CHUNK_32X_EVT,\r
//\r
CHUNK_DEFAULT_COUNT,\r
CHUNK_CARTHW_ = CHUNK_CARTHW, // defined in PicoInt\r
"SDRAM",\r
"DRAM",\r
"PAL",\r
+ "events",\r
};\r
\r
static int write_chunk(chunk_name_e name, int len, void *data, void *file)\r
CHECKED_WRITE_BUFF(CHUNK_DRAM, Pico32xMem->dram);\r
CHECKED_WRITE_BUFF(CHUNK_32XPAL, Pico32xMem->pal);\r
\r
- sh2s[0].m68krcycles_done = sh2s[1].m68krcycles_done = SekCycleCnt;\r
+ memset(buff, 0, 0x40);\r
+ memcpy(buff, event_times, sizeof(event_times));\r
+ CHECKED_WRITE(CHUNK_32X_EVT, 0x40, buff);\r
}\r
#endif\r
\r
unsigned char buff_m68k[0x60], buff_s68k[0x60];\r
unsigned char buff_z80[Z80_STATE_SIZE];\r
unsigned char buff_sh2[SH2_STATE_SIZE];\r
+ unsigned char buff[0x40];\r
unsigned char chunk;\r
void *ym2612_regs;\r
char header[8];\r
case CHUNK_SDRAM: CHECKED_READ_BUFF(Pico32xMem->sdram); break;\r
case CHUNK_DRAM: CHECKED_READ_BUFF(Pico32xMem->dram); break;\r
case CHUNK_32XPAL: CHECKED_READ_BUFF(Pico32xMem->pal); break;\r
+\r
+ case CHUNK_32X_EVT:\r
+ CHECKED_READ_BUFF(buff);\r
+ memcpy(event_times, buff, sizeof(event_times));\r
+ break;\r
#endif\r
default:\r
if (carthw_chunks != NULL)\r