mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
32x: fix savestates
This commit is contained in:
parent
5f0ca48fed
commit
27e2627380
5 changed files with 34 additions and 14 deletions
|
@ -118,6 +118,7 @@ void sh2_unpack(SH2 *sh2, const unsigned char *buff)
|
||||||
|
|
||||||
sh2->pending_int_irq = p[0];
|
sh2->pending_int_irq = p[0];
|
||||||
sh2->pending_int_vector = p[1];
|
sh2->pending_int_vector = p[1];
|
||||||
|
sh2->test_irq = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DRC_CMP
|
#ifdef DRC_CMP
|
||||||
|
|
|
@ -301,8 +301,10 @@ void sync_sh2s_normal(unsigned int m68k_target)
|
||||||
|
|
||||||
elprintf(EL_32X, "sh2 sync to %u", m68k_target);
|
elprintf(EL_32X, "sh2 sync to %u", m68k_target);
|
||||||
|
|
||||||
if (!(Pico32x.regs[0] & P32XS_nRES))
|
if (!(Pico32x.regs[0] & P32XS_nRES)) {
|
||||||
|
msh2.m68krcycles_done = ssh2.m68krcycles_done = m68k_target;
|
||||||
return; // rare
|
return; // rare
|
||||||
|
}
|
||||||
|
|
||||||
now = msh2.m68krcycles_done;
|
now = msh2.m68krcycles_done;
|
||||||
if (CYCLES_GT(now, ssh2.m68krcycles_done))
|
if (CYCLES_GT(now, ssh2.m68krcycles_done))
|
||||||
|
@ -416,4 +418,18 @@ void Pico32xSetClocks(int msh2_hz, int ssh2_hz)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Pico32xStateLoaded(int is_early)
|
||||||
|
{
|
||||||
|
if (is_early) {
|
||||||
|
Pico32xMemStateLoaded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sh2s[0].m68krcycles_done = sh2s[1].m68krcycles_done = SekCycleCntT;
|
||||||
|
p32x_update_irls(0);
|
||||||
|
p32x_poll_event(3, 0);
|
||||||
|
p32x_timers_recalc();
|
||||||
|
run_events(SekCycleCntT);
|
||||||
|
}
|
||||||
|
|
||||||
// vim:shiftwidth=2:ts=2:expandtab
|
// vim:shiftwidth=2:ts=2:expandtab
|
||||||
|
|
|
@ -121,8 +121,8 @@ void p32x_poll_event(int cpu_mask, int is_vdp)
|
||||||
|
|
||||||
// SH2 faking
|
// SH2 faking
|
||||||
//#define FAKE_SH2
|
//#define FAKE_SH2
|
||||||
int p32x_csum_faked;
|
|
||||||
#ifdef FAKE_SH2
|
#ifdef FAKE_SH2
|
||||||
|
static int p32x_csum_faked;
|
||||||
static const u16 comm_fakevals[] = {
|
static const u16 comm_fakevals[] = {
|
||||||
0x4d5f, 0x4f4b, // M_OK
|
0x4d5f, 0x4f4b, // M_OK
|
||||||
0x535f, 0x4f4b, // S_OK
|
0x535f, 0x4f4b, // S_OK
|
||||||
|
@ -1612,16 +1612,12 @@ void PicoMemSetup32x(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pico32xStateLoaded(void)
|
void Pico32xMemStateLoaded(void)
|
||||||
{
|
{
|
||||||
sh2s[0].m68krcycles_done = sh2s[1].m68krcycles_done = SekCycleCntT;
|
|
||||||
p32x_poll_event(3, 0);
|
|
||||||
|
|
||||||
bank_switch(Pico32x.regs[4 / 2]);
|
bank_switch(Pico32x.regs[4 / 2]);
|
||||||
Pico32xSwapDRAM((Pico32x.vdp_regs[0x0a / 2] & P32XV_FS) ^ P32XV_FS);
|
Pico32xSwapDRAM((Pico32x.vdp_regs[0x0a / 2] & P32XV_FS) ^ P32XV_FS);
|
||||||
Pico32x.dirty_pal = 1;
|
|
||||||
memset(Pico32xMem->pwm, 0, sizeof(Pico32xMem->pwm));
|
memset(Pico32xMem->pwm, 0, sizeof(Pico32xMem->pwm));
|
||||||
p32x_timers_recalc();
|
Pico32x.dirty_pal = 1;
|
||||||
#ifdef DRC_SH2
|
#ifdef DRC_SH2
|
||||||
sh2_drc_flush_all();
|
sh2_drc_flush_all();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -735,6 +735,7 @@ void PicoReset32x(void);
|
||||||
void Pico32xStartup(void);
|
void Pico32xStartup(void);
|
||||||
void PicoUnload32x(void);
|
void PicoUnload32x(void);
|
||||||
void PicoFrame32x(void);
|
void PicoFrame32x(void);
|
||||||
|
void Pico32xStateLoaded(int is_early);
|
||||||
void p32x_sync_sh2s(unsigned int m68k_target);
|
void p32x_sync_sh2s(unsigned int m68k_target);
|
||||||
void p32x_update_irls(int nested_call);
|
void p32x_update_irls(int nested_call);
|
||||||
void p32x_reset_sh2s(void);
|
void p32x_reset_sh2s(void);
|
||||||
|
@ -748,7 +749,7 @@ void PicoWrite8_32x(unsigned int a, unsigned int d);
|
||||||
void PicoWrite16_32x(unsigned int a, unsigned int d);
|
void PicoWrite16_32x(unsigned int a, unsigned int d);
|
||||||
void PicoMemSetup32x(void);
|
void PicoMemSetup32x(void);
|
||||||
void Pico32xSwapDRAM(int b);
|
void Pico32xSwapDRAM(int b);
|
||||||
void Pico32xStateLoaded(void);
|
void Pico32xMemStateLoaded(void);
|
||||||
void p32x_poll_event(int cpu_mask, int is_vdp);
|
void p32x_poll_event(int cpu_mask, int is_vdp);
|
||||||
|
|
||||||
// 32x/draw.c
|
// 32x/draw.c
|
||||||
|
|
16
pico/state.c
16
pico/state.c
|
@ -175,6 +175,8 @@ typedef enum {
|
||||||
CHUNK_DRAM,
|
CHUNK_DRAM,
|
||||||
CHUNK_32XPAL,
|
CHUNK_32XPAL,
|
||||||
CHUNK_32X_EVT,
|
CHUNK_32X_EVT,
|
||||||
|
CHUNK_32X_FIRST = CHUNK_MSH2,
|
||||||
|
CHUNK_32X_LAST = CHUNK_32X_EVT,
|
||||||
//
|
//
|
||||||
CHUNK_DEFAULT_COUNT,
|
CHUNK_DEFAULT_COUNT,
|
||||||
CHUNK_CARTHW_ = CHUNK_CARTHW, // defined in PicoInt
|
CHUNK_CARTHW_ = CHUNK_CARTHW, // defined in PicoInt
|
||||||
|
@ -411,8 +413,8 @@ static int state_load(void *file)
|
||||||
if (len < 0 || len > 1024*512) R_ERROR_RETURN("bad length");
|
if (len < 0 || len > 1024*512) R_ERROR_RETURN("bad length");
|
||||||
if (CHUNK_S68K <= chunk && chunk <= CHUNK_MISC_CD && !(PicoAHW & PAHW_MCD))
|
if (CHUNK_S68K <= chunk && chunk <= CHUNK_MISC_CD && !(PicoAHW & PAHW_MCD))
|
||||||
R_ERROR_RETURN("cd chunk in non CD state?");
|
R_ERROR_RETURN("cd chunk in non CD state?");
|
||||||
if (CHUNK_MSH2 <= chunk && chunk <= CHUNK_32XPAL && !(PicoAHW & PAHW_32X))
|
if (CHUNK_32X_FIRST <= chunk && chunk <= CHUNK_32X_LAST && !(PicoAHW & PAHW_32X))
|
||||||
R_ERROR_RETURN("32x chunk in non 32x state?");
|
Pico32xStartup();
|
||||||
|
|
||||||
switch (chunk)
|
switch (chunk)
|
||||||
{
|
{
|
||||||
|
@ -517,18 +519,22 @@ readend:
|
||||||
|
|
||||||
if (!(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))
|
if (!(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))
|
||||||
cdda_start_play();
|
cdda_start_play();
|
||||||
|
|
||||||
SekUnpackCpu(buff_s68k, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PicoAHW & PAHW_32X)
|
||||||
|
Pico32xStateLoaded(1);
|
||||||
|
|
||||||
// must unpack 68k and z80 after banks are set up
|
// must unpack 68k and z80 after banks are set up
|
||||||
if (!(PicoAHW & PAHW_SMS))
|
if (!(PicoAHW & PAHW_SMS))
|
||||||
SekUnpackCpu(buff_m68k, 0);
|
SekUnpackCpu(buff_m68k, 0);
|
||||||
|
if (PicoAHW & PAHW_MCD)
|
||||||
|
SekUnpackCpu(buff_s68k, 1);
|
||||||
|
|
||||||
z80_unpack(buff_z80);
|
z80_unpack(buff_z80);
|
||||||
|
|
||||||
|
// due to dep from 68k cycles..
|
||||||
if (PicoAHW & PAHW_32X)
|
if (PicoAHW & PAHW_32X)
|
||||||
Pico32xStateLoaded();
|
Pico32xStateLoaded(0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue