From 064cc6d1037fd74b3a1b0062bbe05d1211994684 Mon Sep 17 00:00:00 2001 From: kub Date: Fri, 22 Mar 2019 20:18:33 +0100 Subject: [PATCH] kludges for wwf raw, nfl --- cpu/sh2/compiler.c | 8 ++++++++ pico/32x/memory.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/cpu/sh2/compiler.c b/cpu/sh2/compiler.c index c6522f37..aa3e772c 100644 --- a/cpu/sh2/compiler.c +++ b/cpu/sh2/compiler.c @@ -4233,6 +4233,14 @@ void scan_block(u32 base_pc, int is_slave, u8 *op_flags, u32 *end_pc_out, if (opd->imm < end_pc + MAX_LITERAL_OFFSET) { if (end_literals < opd->imm + opd->size * 2) end_literals = opd->imm + opd->size * 2; + if (opd->size == 2) { + // tweak for NFL: treat a 32bit literal as an address and check if it + // points to the literal space. In that case handle it like MOVA. + tmp = FETCH32(opd->imm) & ~0x20000000; // MUST ignore wt bit here + if (tmp >= end_pc && tmp < end_pc + MAX_LITERAL_OFFSET) + if (lowest_mova == 0 || tmp < lowest_mova) + lowest_mova = tmp; + } } } } diff --git a/pico/32x/memory.c b/pico/32x/memory.c index d815853d..c6b89a22 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -1487,6 +1487,20 @@ static void REGPARM(3) sh2_write16_da(u32 a, u32 d, SH2 *sh2) ((u16 *)sh2->data_array)[a1 / 2] = d; } +static void REGPARM(3) sh2_write16_rom(u32 a, u32 d, SH2 *sh2) +{ + u32 a1 = a & 0x3fffff; + // tweak for WWF Raw: does writes to ROM area, and it doesn't work without + // allowing this. + // Presumably the write goes to the CPU cache and is read back from there, + // but it would be extremely costly to emulate cache behaviour. Just allow + // writes to that region, hoping that the original ROM values are never used. + if ((a1 & 0x3e0000) == 0x3e0000) + ((u16 *)sh2->p_rom)[a1 / 2] = d; + else + sh2_write16_unmapped(a, d, sh2); +} + typedef u32 (sh2_read_handler)(u32 a, SH2 *sh2); typedef void REGPARM(3) (sh2_write_handler)(u32 a, u32 d, SH2 *sh2); @@ -1911,6 +1925,7 @@ void PicoMemSetup32x(void) bank_switch_rom_sh2(); sh2_read8_map[0x02/2].mask = sh2_read8_map[0x22/2].mask = sh2_read16_map[0x02/2].mask = sh2_read16_map[0x22/2].mask = 0x3fffff; // FIXME + sh2_write16_map[0x02/2] = sh2_write16_map[0x22/2] = sh2_write16_rom; // CS2 - DRAM - done by Pico32xSwapDRAM() sh2_read8_map[0x04/2].mask = sh2_read8_map[0x24/2].mask = sh2_read16_map[0x04/2].mask = sh2_read16_map[0x24/2].mask = 0x01ffff; -- 2.39.5