From: kub Date: Fri, 30 Jun 2023 21:44:26 +0000 (+0000) Subject: 32x, add disabling via ADEN (for testpico) X-Git-Tag: v2.00~196 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f7abd68dfb68c407a8f055d94a771ecab20225f;p=picodrive.git 32x, add disabling via ADEN (for testpico) --- diff --git a/pico/32x/32x.c b/pico/32x/32x.c index e91c724b..67ad5a3a 100644 --- a/pico/32x/32x.c +++ b/pico/32x/32x.c @@ -124,6 +124,20 @@ void Pico32xStartup(void) emu_32x_startup(); } +void Pico32xShutdown(void) +{ + sh2_finish(&msh2); + sh2_finish(&ssh2); + + Pico32x.vdp_regs[6] = P32XS_RV; + + rendstatus_old = -1; + + PicoIn.AHW &= ~PAHW_32X; + PicoMemSetup(); + emu_32x_startup(); +} + void p32x_reset_sh2s(void) { elprintf(EL_32X, "sh2 reset"); @@ -195,13 +209,11 @@ void PicoPower32x(void) void PicoUnload32x(void) { - sh2_finish(&msh2); - sh2_finish(&ssh2); + Pico32xShutdown(); + if (Pico32xMem != NULL) plat_munmap(Pico32xMem, sizeof(*Pico32xMem)); Pico32xMem = NULL; - - PicoIn.AHW &= ~PAHW_32X; } void PicoReset32x(void) @@ -452,7 +464,7 @@ void sync_sh2s_normal(unsigned int m68k_target) elprintf(EL_32X, "sh2 sync to %u", m68k_target); - if (!(Pico32x.regs[0] & P32XS_nRES)) { + if (!(Pico32x.regs[0] & P32XS_nRES) || !(Pico32x.regs[0] & P32XS_ADEN)) { msh2.m68krcycles_done = ssh2.m68krcycles_done = m68k_target; return; // rare } diff --git a/pico/32x/memory.c b/pico/32x/memory.c index 261c3d09..2e7befe1 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -416,7 +416,10 @@ static void p32x_reg_write8(u32 a, u32 d) REG8IN16(r, 0x00) = d & 0x80; return; case 0x01: // adapter ctl: RES and ADEN writable - if ((d ^ r[0]) & d & P32XS_nRES) + if ((d ^ r[0]) & ~d & P32XS_ADEN) { + d |= P32XS_nRES; + Pico32xShutdown(); + } else if ((d ^ r[0]) & d & P32XS_nRES) p32x_reset_sh2s(); REG8IN16(r, 0x01) &= ~(P32XS_nRES|P32XS_ADEN); REG8IN16(r, 0x01) |= d & (P32XS_nRES|P32XS_ADEN); @@ -581,7 +584,10 @@ static void p32x_reg_write16(u32 a, u32 d) switch (a/2) { case 0x00/2: // adapter ctl - if ((d ^ r[0]) & d & P32XS_nRES) + if ((d ^ r[0]) & ~d & P32XS_ADEN) { + d |= P32XS_nRES; + Pico32xShutdown(); + } else if ((d ^ r[0]) & d & P32XS_nRES) p32x_reset_sh2s(); r[0] &= ~(P32XS_FM|P32XS_nRES|P32XS_ADEN); r[0] |= d & (P32XS_FM|P32XS_nRES|P32XS_ADEN); @@ -1240,7 +1246,10 @@ void PicoWrite8_32x(u32 a, u32 d) } return; } - + if (a == 7) { + r[0x06/2] &= ~P32XS_RV; + r[0x06/2] |= d & P32XS_RV; + } // allow only COMM for now if ((a & 0x30) == 0x20) { u8 *r8 = (u8 *)r; @@ -1269,6 +1278,10 @@ void PicoWrite16_32x(u32 a, u32 d) } return; } + if (a == 6) { + r[0x06/2] &= ~P32XS_RV; + r[0x06/2] |= d & P32XS_RV; + } // allow only COMM for now if ((a & 0x30) == 0x20)