sms, fix save/load bugs (irq, mapper)

This commit is contained in:
kub 2024-03-24 17:45:10 +01:00
parent 64360d13b0
commit da4148881e
3 changed files with 13 additions and 6 deletions

View file

@ -795,6 +795,9 @@ void PicoMemSetupMS(void)
void PicoStateLoadedMS(void) void PicoStateLoadedMS(void)
{ {
u8 mapper = Pico.ms.mapper; u8 mapper = Pico.ms.mapper;
u8 zram_dff0[16]; // TODO xwrite also writes to zram :-/
memcpy(zram_dff0, PicoMem.zram+0x1ff0, 16);
if (mapper == PMS_MAP_8KBRAM || mapper == PMS_MAP_32KBRAM) { if (mapper == PMS_MAP_8KBRAM || mapper == PMS_MAP_32KBRAM) {
u16 a = Pico.ms.carthw[0] << 12; u16 a = Pico.ms.carthw[0] << 12;
xwrite(a, *(unsigned char *)(PicoMem.vram+0x4000)); xwrite(a, *(unsigned char *)(PicoMem.vram+0x4000));
@ -828,6 +831,7 @@ void PicoStateLoadedMS(void)
xwrite(0xfffe, Pico.ms.carthw[0x0e]); xwrite(0xfffe, Pico.ms.carthw[0x0e]);
xwrite(0xffff, Pico.ms.carthw[0x0f]); xwrite(0xffff, Pico.ms.carthw[0x0f]);
} }
memcpy(PicoMem.zram+0x1ff0, zram_dff0, 16);
} }
void PicoFrameMS(void) void PicoFrameMS(void)
@ -868,6 +872,7 @@ void PicoFrameMS(void)
switch (is_pal ? -lines_vis : lines_vis) { switch (is_pal ? -lines_vis : lines_vis) {
case 192: if (y > 218) pv->v_counter = y - (lines-256); break; case 192: if (y > 218) pv->v_counter = y - (lines-256); break;
case 224: if (y > 234) pv->v_counter = y - (lines-256); break; case 224: if (y > 234) pv->v_counter = y - (lines-256); break;
/* case 240: if (y > 252) pv->v_counter = y - (lines-256); break; ? */
case -192: if (y > 242) pv->v_counter = y - (lines-256); break; case -192: if (y > 242) pv->v_counter = y - (lines-256); break;
case -224: if (y > 258) pv->v_counter = y - (lines-256); break; case -224: if (y > 258) pv->v_counter = y - (lines-256); break;
case -240: if (y > 266) pv->v_counter = y - (lines-256); break; case -240: if (y > 266) pv->v_counter = y - (lines-256); break;

View file

@ -605,12 +605,13 @@ readend:
Pico32xStateLoaded(0); Pico32xStateLoaded(0);
if (PicoIn.AHW & PAHW_MCD) if (PicoIn.AHW & PAHW_MCD)
pcd_state_loaded(); pcd_state_loaded();
if (!(PicoIn.AHW & PAHW_SMS)) {
Pico.video.status &= ~(SR_VB | SR_F);
Pico.video.status |= ((Pico.video.reg[1] >> 3) ^ SR_VB) & SR_VB;
Pico.video.status |= (Pico.video.pending_ints << 2) & SR_F;
}
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;
Pico.video.status &= ~(SR_VB | SR_F);
Pico.video.status |= ((Pico.video.reg[1] >> 3) ^ SR_VB) & SR_VB;
Pico.video.status |= (Pico.video.pending_ints << 2) & SR_F;
retval = 0; retval = 0;
out: out:

View file

@ -209,7 +209,7 @@ void z80_pack(void *data)
s->iff1 = !!zIFF1; s->iff1 = !!zIFF1;
s->iff2 = !!zIFF2; s->iff2 = !!zIFF2;
s->im = zIM; s->im = zIM;
s->irq_pending = (Cz80_Get_Reg(&CZ80, CZ80_IRQ) == HOLD_LINE); s->irq_pending = (Cz80_Get_Reg(&CZ80, CZ80_IRQ) != CLEAR_LINE);
s->irq_vector[0] = 0xff; s->irq_vector[0] = 0xff;
} }
#endif #endif
@ -276,7 +276,8 @@ int z80_unpack(const void *data)
Cz80_Set_Reg(&CZ80, CZ80_IFF1, s->iff1); Cz80_Set_Reg(&CZ80, CZ80_IFF1, s->iff1);
Cz80_Set_Reg(&CZ80, CZ80_IFF2, s->iff2); Cz80_Set_Reg(&CZ80, CZ80_IFF2, s->iff2);
zIM = s->im; zIM = s->im;
Cz80_Set_Reg(&CZ80, CZ80_IRQ, s->irq_pending ? HOLD_LINE : CLEAR_LINE); Cz80_Set_Reg(&CZ80, CZ80_IRQ, s->irq_pending ? ASSERT_LINE : CLEAR_LINE);
Cz80_Set_IRQ(&CZ80, 0, Cz80_Get_Reg(&CZ80, CZ80_IRQ));
return 0; return 0;
} }
#else #else