From: kub Date: Fri, 14 May 2021 14:50:13 +0000 (+0200) Subject: mcd, improve polling detection X-Git-Tag: v2.00~529 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbebab6934d7c3889047a1c04019421294e74250;p=picodrive.git mcd, improve polling detection --- diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index 7554f8c6..732a4299 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -281,7 +281,8 @@ void pcd_irq_s68k(int irq, int state) { if (state) { SekInterruptS68k(irq); - SekSetStopS68k(0); + if (SekIsStoppedS68k()) + SekSetStopS68k(0); Pico_mcd->m.s68k_poll_a = 0; } else SekInterruptClearS68k(irq); @@ -342,21 +343,24 @@ void pcd_run_cpus_normal(int m68k_cycles) #ifdef USE_POLL_DETECT if (Pico_mcd->m.m68k_poll_cnt >= 16) { + int s68k_left; // main CPU is polling, (wake and) run sub only - SekSetStopS68k(0); - pcd_sync_s68k(Pico.t.m68c_aim, 1); + if (SekIsStoppedS68k()) + SekSetStopS68k(0); + s68k_left = pcd_sync_s68k(Pico.t.m68c_aim, 1); Pico.t.m68c_cnt = Pico.t.m68c_aim; + if (s68k_left > 0) + Pico.t.m68c_cnt -= ((long long)s68k_left * mcd_s68k_cycle_mult >> 16); if (SekIsStoppedS68k()) { // slave has stopped, wake master to avoid lockups Pico_mcd->m.m68k_poll_cnt = 0; } elprintf(EL_CDPOLL, "m68k poll [%02x] x%d @%06x", Pico_mcd->m.m68k_poll_a, Pico_mcd->m.m68k_poll_cnt, SekPc); - } + } else #endif - - SekRunM68kOnce(); + SekRunM68kOnce(); if (Pico_mcd->m.need_sync) { Pico_mcd->m.need_sync = 0; pcd_sync_s68k(Pico.t.m68c_cnt, 0); diff --git a/pico/cd/memory.c b/pico/cd/memory.c index 558251c7..a7b47b91 100644 --- a/pico/cd/memory.c +++ b/pico/cd/memory.c @@ -144,6 +144,8 @@ void m68k_reg_write8(u32 a, u32 d) u32 dold; a &= 0x3f; + Pico_mcd->m.m68k_poll_cnt = 0; + switch (a) { case 0: d &= 1; @@ -180,8 +182,7 @@ void m68k_reg_write8(u32 a, u32 d) return; case 2: elprintf(EL_CDREGS, "m68k: prg wp=%02x", d); - Pico_mcd->s68k_regs[2] = d; // really use s68k side register - return; + goto write_comm; case 3: dold = Pico_mcd->s68k_regs[3]; elprintf(EL_CDREG3, "m68k_regs w3: %02x @%06x", (u8)d, SekPc); @@ -331,7 +332,7 @@ u32 s68k_reg_read16(u32 a) d = (Pico_mcd->s68k_regs[a]<<8) | Pico_mcd->s68k_regs[a+1]; - if (a >= 0x0e && a < 0x20) + if (a >= 0x0e && a < 0x30) return s68k_poll_detect(a, d); return d; @@ -494,6 +495,8 @@ void s68k_reg_write16(u32 a, u32 d) { u8 *r = Pico_mcd->s68k_regs; + Pico_mcd->m.s68k_poll_cnt = 0; + if ((a & 0x1f0) == 0x20) goto write_comm; @@ -501,8 +504,8 @@ void s68k_reg_write16(u32 a, u32 d) case 0x0e: // special case, 2 byte writes would be handled differently // TODO: verify - r[0xf] = d; - return; + d = (u8)d | (r[0xe] << 8); + goto write_comm; case 0x58: // stamp data size r[0x59] = d & 7; return;