From 8a847c12e6a82869b7ff6f1742f53e0da1ad2db6 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 11 Aug 2013 23:49:01 +0300 Subject: [PATCH] 32x: some timing hacks.. --- pico/32x/memory.c | 18 ++++++++++++++++-- pico/pico_int.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pico/32x/memory.c b/pico/32x/memory.c index f9374c4..c6f3a31 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -32,7 +32,7 @@ * sys reg 0004000-00040ff 1 1 * vdp reg 0004100-00041ff 5 5 * vdp pal 0004200-00043ff 5 5 - * rom 2000000-23fffff 6-15 + * cart 2000000-23fffff 6-15 * dram/fb 4000000-401ffff 5-12 1-3 * fb ovr 4020000-403ffff * sdram 6000000-603ffff 12 2 (cycles) @@ -1063,6 +1063,8 @@ static u32 sh2_read8_cs0(u32 a, SH2 *sh2) { u32 d = 0; + sh2_burn_cycles(sh2, 1*2); + // 0x3ff00 is veridied if ((a & 0x3ff00) == 0x4000) { d = p32x_sh2reg_read16(a, sh2); @@ -1116,6 +1118,8 @@ static u32 sh2_read16_cs0(u32 a, SH2 *sh2) { u32 d = 0; + sh2_burn_cycles(sh2, 1*2); + if ((a & 0x3ff00) == 0x4000) { d = p32x_sh2reg_read16(a, sh2); if (!(EL_LOGMASK & EL_PWM) && (a & 0x30) == 0x30) // hide PWM @@ -1206,6 +1210,15 @@ static void REGPARM(3) sh2_write8_sdram(u32 a, u32 d, SH2 *sh2) Pico32xMem->sdram[a1 ^ 1] = d; } +static void REGPARM(3) sh2_write8_sdram_wt(u32 a, u32 d, SH2 *sh2) +{ + // xmen sync hack.. + if (a < 0x26000200) + sh2_end_run(sh2, 32); + + sh2_write8_sdram(a, d, sh2); +} + static void REGPARM(3) sh2_write8_da(u32 a, u32 d, SH2 *sh2) { u32 a1 = a & 0xfff; @@ -1609,7 +1622,8 @@ void PicoMemSetup32x(void) // CS3 - SDRAM sh2_read8_map[0x06/2].addr = sh2_read8_map[0x26/2].addr = sh2_read16_map[0x06/2].addr = sh2_read16_map[0x26/2].addr = MAP_MEMORY(Pico32xMem->sdram); - sh2_write8_map[0x06/2] = sh2_write8_map[0x26/2] = sh2_write8_sdram; + sh2_write8_map[0x06/2] = sh2_write8_sdram; + sh2_write8_map[0x26/2] = sh2_write8_sdram_wt; sh2_write16_map[0x06/2] = sh2_write16_map[0x26/2] = sh2_write16_sdram; sh2_read8_map[0x06/2].mask = sh2_read8_map[0x26/2].mask = sh2_read16_map[0x06/2].mask = sh2_read16_map[0x26/2].mask = 0x03ffff; diff --git a/pico/pico_int.h b/pico/pico_int.h index d636579..2a793e5 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -251,6 +251,7 @@ extern SH2 sh2s[2]; } \ } while (0) # define sh2_cycles_left(sh2) (sh2)->icount +# define sh2_burn_cycles(sh2, n) (sh2)->icount -= n # define sh2_pc(sh2) (sh2)->ppc #else # define sh2_end_run(sh2, after_) do { \ @@ -262,6 +263,7 @@ extern SH2 sh2s[2]; } \ } while (0) # define sh2_cycles_left(sh2) ((signed int)(sh2)->sr >> 12) +# define sh2_burn_cycles(sh2, n) (sh2)->sr -= ((n) << 12) # define sh2_pc(sh2) (sh2)->pc #endif -- 2.39.2