Skip to content

Commit

Permalink
sms, fix save/load bugs (irq, mapper)
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Mar 24, 2024
1 parent 64360d1 commit da41488
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions pico/sms.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,9 @@ void PicoMemSetupMS(void)
void PicoStateLoadedMS(void)
{
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) {
u16 a = Pico.ms.carthw[0] << 12;
xwrite(a, *(unsigned char *)(PicoMem.vram+0x4000));
Expand Down Expand Up @@ -828,6 +831,7 @@ void PicoStateLoadedMS(void)
xwrite(0xfffe, Pico.ms.carthw[0x0e]);
xwrite(0xffff, Pico.ms.carthw[0x0f]);
}
memcpy(PicoMem.zram+0x1ff0, zram_dff0, 16);
}

void PicoFrameMS(void)
Expand Down Expand Up @@ -868,6 +872,7 @@ void PicoFrameMS(void)
switch (is_pal ? -lines_vis : lines_vis) {
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 240: if (y > 252) 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 -240: if (y > 266) pv->v_counter = y - (lines-256); break;
Expand Down
9 changes: 5 additions & 4 deletions pico/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,13 @@ static int state_load(void *file)
Pico32xStateLoaded(0);
if (PicoIn.AHW & PAHW_MCD)
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.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;

out:
Expand Down
5 changes: 3 additions & 2 deletions pico/z80if.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void z80_pack(void *data)
s->iff1 = !!zIFF1;
s->iff2 = !!zIFF2;
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;
}
#endif
Expand Down Expand Up @@ -276,7 +276,8 @@ int z80_unpack(const void *data)
Cz80_Set_Reg(&CZ80, CZ80_IFF1, s->iff1);
Cz80_Set_Reg(&CZ80, CZ80_IFF2, s->iff2);
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;
}
#else
Expand Down

0 comments on commit da41488

Please sign in to comment.