Skip to content

Commit

Permalink
32x, fix reset interrupt handling
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed May 13, 2024
1 parent fb79e7b commit 8341673
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions pico/32x/32x.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ void p32x_update_irls(SH2 *active_sh2, unsigned int m68k_cycles)
// find top bit = highest irq number (0 <= irl <= 14/2) by binary search

// msh2
irqs = Pico32x.sh2irqs | Pico32x.sh2irqi[0];
irqs = Pico32x.sh2irqi[0];
if (irqs >= 0x10) mlvl += 8, irqs >>= 4;
if (irqs >= 0x04) mlvl += 4, irqs >>= 2;
if (irqs >= 0x02) mlvl += 2, irqs >>= 1;

// ssh2
irqs = Pico32x.sh2irqs | Pico32x.sh2irqi[1];
irqs = Pico32x.sh2irqi[1];
if (irqs >= 0x10) slvl += 8, irqs >>= 4;
if (irqs >= 0x04) slvl += 4, irqs >>= 2;
if (irqs >= 0x02) slvl += 2, irqs >>= 1;
Expand All @@ -77,7 +77,8 @@ void p32x_update_irls(SH2 *active_sh2, unsigned int m68k_cycles)
// TODO: test on hw..
void p32x_trigger_irq(SH2 *sh2, unsigned int m68k_cycles, unsigned int mask)
{
Pico32x.sh2irqs |= mask & P32XI_VRES;
Pico32x.sh2irqi[0] |= mask & P32XI_VRES;
Pico32x.sh2irqi[1] |= mask & P32XI_VRES;
Pico32x.sh2irqi[0] |= mask & (Pico32x.sh2irq_mask[0] << 3);
Pico32x.sh2irqi[1] |= mask & (Pico32x.sh2irq_mask[1] << 3);

Expand Down Expand Up @@ -238,8 +239,6 @@ void PicoReset32x(void)
p32x_sh2_poll_event(ssh2.poll_addr, &ssh2, SH2_IDLE_STATES, SekCyclesDone());
p32x_pwm_ctl_changed();
p32x_timers_recalc();
Pico32x.vdp_regs[0] &= ~P32XV_Mx; // 32X graphics disabled
Pico32x.pending_fb = Pico32x.vdp_regs[0x0a/2] & P32XV_FS;
}
}

Expand Down
2 changes: 1 addition & 1 deletion pico/32x/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// NB: 32X officially doesn't support H32 mode. However, it does work since the
// cartridge slot carries the EDCLK signal which is always H40 clock and is used
// as video clock by the 32X. The H32 MD image is overlayed with the 320 px 32X
// as video clock by the 32X. The H32 MD image is overlaid with the 320 px 32X
// image which has the same on-screen width. How the /YS signal on the cartridge
// slot (signalling the display of background color) is processed in this case
// is however unclear and might lead to glitches due to race conditions by the
Expand Down
2 changes: 1 addition & 1 deletion pico/32x/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ static void p32x_sh2reg_write16(u32 a, u32 d, SH2 *sh2)
Pico32x.regs[0] |= d & P32XS_FM;
break;
case 0x14/2:
Pico32x.sh2irqs &= ~P32XI_VRES;
Pico32x.sh2irqi[sh2->is_slave] &= ~P32XI_VRES;
goto irls;
case 0x16/2:
Pico32x.sh2irqi[sh2->is_slave] &= ~P32XI_VINT;
Expand Down
2 changes: 1 addition & 1 deletion pico/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ char *PDebug32x(void)
}
r = Pico32x.sh2_regs;
sprintf(dstrp, "SH: %04x %04x %04x IRQs: %02x eflags: %02x\n",
r[0], r[1], r[2], Pico32x.sh2irqs, Pico32x.emu_flags); MVP;
r[0], r[1], r[2], Pico32x.sh2irqi[0]|Pico32x.sh2irqi[1], Pico32x.emu_flags); MVP;

i = 0;
r = Pico32x.vdp_regs;
Expand Down
2 changes: 1 addition & 1 deletion pico/pico_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ struct Pico32x
unsigned int emu_flags;
unsigned char sh2irq_mask[2];
unsigned char sh2irqi[2]; // individual
unsigned int sh2irqs; // common irqs
unsigned int pad4; // was sh2irqs
unsigned short dmac_fifo[DMAC_FIFO_LEN];
unsigned int pad[4];
unsigned int dmac0_fifo_ptr;
Expand Down

0 comments on commit 8341673

Please sign in to comment.