From 419973a6d6cb92f96a60f1d5ccda0beb8b28b15d Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 18 Aug 2013 02:43:52 +0300 Subject: [PATCH] 32x: some hacks.. --- pico/32x/32x.c | 2 ++ pico/32x/memory.c | 22 +++++++++++++++++++++- pico/pico_int.h | 5 +++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pico/32x/32x.c b/pico/32x/32x.c index 0eb2974f..ab522e41 100644 --- a/pico/32x/32x.c +++ b/pico/32x/32x.c @@ -523,6 +523,8 @@ void sync_sh2s_lockstep(unsigned int m68k_target) #define CPUS_RUN(m68k_cycles,s68k_cycles) do { \ SekRunM68k(m68k_cycles); \ + if (Pico32x.emu_flags & P32XF_Z80_32X_IO) \ + PicoSyncZ80(SekCycleCnt); \ if (Pico32x.emu_flags & (P32XF_68KCPOLL|P32XF_68KVPOLL)) \ p32x_sync_sh2s(SekCyclesDoneT2()); \ } while (0) diff --git a/pico/32x/memory.c b/pico/32x/memory.c index eabc1b62..08e48e86 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -195,8 +195,10 @@ static u32 p32x_reg_read16(u32 a) m68k_poll.cnt = 0; dr2 = SekDar(2); - if (cycles - msh2.m68krcycles_done > 500) + if (cycles - msh2.m68krcycles_done > 244 + || (Pico32x.comm_dirty_68k & comreg)) p32x_sync_sh2s(cycles); + if (Pico32x.comm_dirty_sh2 & comreg) Pico32x.comm_dirty_sh2 &= ~comreg; else if (m68k_poll_detect(a, cycles, P32XF_68KCPOLL)) { @@ -1523,6 +1525,21 @@ void REGPARM(3) p32x_sh2_write32(u32 a, u32 d, SH2 *sh2) // ----------------------------------------------------------------- +static void z80_md_bank_write_32x(unsigned int a, unsigned char d) +{ + unsigned int addr68k; + + addr68k = Pico.m.z80_bank68k << 15; + addr68k += a & 0x7fff; + if ((addr68k & 0xfff000) == 0xa15000) + Pico32x.emu_flags |= P32XF_Z80_32X_IO; + + elprintf(EL_Z80BNK, "z80->68k w8 [%06x] %02x", addr68k, d); + m68k_write8(addr68k, d); +} + +// ----------------------------------------------------------------- + static const u16 msh2_code[] = { // trap instructions 0xaffe, // bra @@ -1779,6 +1796,9 @@ void PicoMemSetup32x(void) sh2_drc_mem_setup(&msh2); sh2_drc_mem_setup(&ssh2); + + // z80 hack + z80_map_set(z80_write_map, 0x8000, 0xffff, z80_md_bank_write_32x, 1); } void Pico32xMemStateLoaded(void) diff --git a/pico/pico_int.h b/pico/pico_int.h index e71245a8..a4f446b4 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -482,8 +482,9 @@ typedef struct #define P32XP_FULL (1<<15) // PWM pulse #define P32XP_EMPTY (1<<14) -#define P32XF_68KCPOLL (1 << 0) -#define P32XF_68KVPOLL (1 << 1) +#define P32XF_68KCPOLL (1 << 0) +#define P32XF_68KVPOLL (1 << 1) +#define P32XF_Z80_32X_IO (1 << 7) // z80 does 32x io #define P32XI_VRES (1 << 14/2) // IRL/2 #define P32XI_VINT (1 << 12/2) -- 2.39.5