From ba2b97dc24bf1ea054da06d2e7f4fe699e6ce189 Mon Sep 17 00:00:00 2001 From: kub Date: Sat, 20 Jan 2024 17:15:51 +0100 Subject: [PATCH] core, fix Pico horizontal irq (on irq level 5) --- pico/pico.c | 1 + pico/pico_cmn.c | 4 ++-- pico/pico_int.h | 2 +- pico/sek.c | 3 ++- pico/videoport.c | 7 ++++--- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pico/pico.c b/pico/pico.c index ad57b6ec..cc5ef7cc 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -185,6 +185,7 @@ int PicoReset(void) PicoDetectRegion(); Pico.video.status = 0x3428 | Pico.m.pal; // 'always set' bits | vblank | collision | pal + Pico.video.hint_irq = (PicoIn.AHW & PAHW_PICO ? 5 : 4); PsndReset(); // pal must be known here diff --git a/pico/pico_cmn.c b/pico/pico_cmn.c index 5a735449..d51477f1 100644 --- a/pico/pico_cmn.c +++ b/pico/pico_cmn.c @@ -105,8 +105,8 @@ static void do_hint(struct PicoVideo *pv) pv->pending_ints |= 0x10; if (pv->reg[0] & 0x10) { elprintf(EL_INTS, "hint: @ %06x [%u]", SekPc, SekCyclesDone()); - if (SekIrqLevel < 4) - SekInterrupt(4); + if (SekIrqLevel < pv->hint_irq) + SekInterrupt(pv->hint_irq); } } diff --git a/pico/pico_int.h b/pico/pico_int.h index 9ccfddb7..cbf61e43 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -312,7 +312,7 @@ struct PicoVideo unsigned char debug_p; // ... parsed: PVD_* unsigned char addr_u; // bit16 of .addr unsigned char hint_cnt; - unsigned char pad2; + unsigned char hint_irq; // irq# of HINT (4 on MD, 5 on Pico) unsigned short hv_latch; // latched hvcounter value signed int fifo_cnt; // pending xfers for blocking FIFO queue entries signed int fifo_bgcnt; // pending xfers for background FIFO queue entries diff --git a/pico/sek.c b/pico/sek.c index 4dd0b4ab..236d03fe 100644 --- a/pico/sek.c +++ b/pico/sek.c @@ -35,7 +35,8 @@ static int do_ack(int level) if (pv->pending_ints & pv->reg[1] & 0x20) { pv->pending_ints &= ~0x20; pv->status &= ~SR_F; - return (pv->reg[0] & pv->pending_ints & 0x10) >> 2; + if (pv->reg[0] & pv->pending_ints & 0x10) + return pv->hint_irq; } else if (pv->pending_ints & pv->reg[0] & 0x10) pv->pending_ints &= ~0x10; diff --git a/pico/videoport.c b/pico/videoport.c index fe8e5ebd..dcfc58c8 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -979,7 +979,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(u32 a,unsigned short d) } SATaddr = ((pvid->reg[5]&0x7f) << 9) | ((pvid->reg[6]&0x20) << 11); SATmask = ~0x1ff; - if (Pico.video.reg[12]&1) + if (pvid->reg[12]&1) SATaddr &= ~0x200, SATmask &= ~0x200; // H40, zero lowest SAT bit //elprintf(EL_STATUS, "spritep moved to %04x", SATaddr); return; @@ -993,8 +993,9 @@ update_irq: lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10); pints = pvid->pending_ints & lines; if (pints & 0x20) irq = 6; - else if (pints & 0x10) irq = 4; - SekInterrupt(irq); // update line + else if (pints & 0x10) irq = pvid->hint_irq; + if (SekIrqLevel < irq) + SekInterrupt(irq); // update line // this is broken because cost of current insn isn't known here if (irq) SekEndRun(21); // make it delayed -- 2.39.2