X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2F32x%2Fmemory.c;h=5d882e373c422a421d295e81fcf6e6102abc0a58;hb=6b5feebabcf3fe4d136639a14f308005106f5dbf;hp=f9374c478cda29a64ae0c06a5b6fe51e00c4fe00;hpb=7eaa381224c5b50b90f39938be2e298a322b6f9f;p=picodrive.git diff --git a/pico/32x/memory.c b/pico/32x/memory.c index f9374c4..5d882e3 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) @@ -103,7 +103,7 @@ static void sh2_poll_detect(SH2 *sh2, u32 a, u32 flags, int maxcnt) if (a == sh2->poll_addr && sh2->poll_cycles - cycles_left <= 10) { if (sh2->poll_cnt++ > maxcnt) { if (!(sh2->state & flags)) - elprintf(EL_32X, "%csh2 state: %02x->%02x", sh2->is_slave?'s':'m', + elprintf_sh2(sh2, EL_32X, "state: %02x->%02x", sh2->state, sh2->state | flags); sh2->state |= flags; @@ -121,8 +121,8 @@ static void sh2_poll_detect(SH2 *sh2, u32 a, u32 flags, int maxcnt) void p32x_sh2_poll_event(SH2 *sh2, u32 flags, u32 m68k_cycles) { if (sh2->state & flags) { - elprintf(EL_32X, "%csh2 state: %02x->%02x", sh2->is_slave?'s':'m', - sh2->state, sh2->state & ~flags); + elprintf_sh2(sh2, EL_32X, "state: %02x->%02x", sh2->state, + sh2->state & ~flags); if (sh2->m68krcycles_done < m68k_cycles) sh2->m68krcycles_done = m68k_cycles; @@ -635,13 +635,13 @@ static void p32x_sh2reg_write8(u32 a, u32 d, SH2 *sh2) Pico32x.regs[0] |= (d << 8) & P32XS_FM; return; case 1: // HEN/irq masks - if ((d ^ Pico32x.sh2_regs[0]) & 0x80) - elprintf(EL_ANOMALY|EL_32X, "HEN"); - Pico32x.sh2irq_mask[sh2->is_slave] = d & 0x8f; + Pico32x.sh2irq_mask[sh2->is_slave] = d & 0x0f; Pico32x.sh2_regs[0] &= ~0x80; Pico32x.sh2_regs[0] |= d & 0x80; if (d & 1) p32x_pwm_schedule_sh2(sh2); + if (d & 4) + p32x_schedule_hint(sh2, 0); p32x_update_irls(sh2, 0); return; case 5: // H count @@ -1054,8 +1054,8 @@ static void bank_switch(int b) // read8 static u32 sh2_read8_unmapped(u32 a, SH2 *sh2) { - elprintf(EL_UIO, "%csh2 unmapped r8 [%08x] %02x @%06x", - sh2->is_slave ? 's' : 'm', a, 0, sh2_pc(sh2)); + elprintf_sh2(sh2, EL_32X, "unmapped r8 [%08x] %02x @%06x", + a, 0, sh2_pc(sh2)); return 0; } @@ -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); @@ -1094,8 +1096,8 @@ out_16to8: else d >>= 8; - elprintf(EL_32X, "%csh2 r8 [%08x] %02x @%06x", - sh2->is_slave ? 's' : 'm', a, d, sh2_pc(sh2)); + elprintf_sh2(sh2, EL_32X, "r8 [%08x] %02x @%06x", + a, d, sh2_pc(sh2)); return d; } @@ -1107,8 +1109,8 @@ static u32 sh2_read8_da(u32 a, SH2 *sh2) // read16 static u32 sh2_read16_unmapped(u32 a, SH2 *sh2) { - elprintf(EL_UIO, "%csh2 unmapped r16 [%08x] %04x @%06x", - sh2->is_slave ? 's' : 'm', a, 0, sh2_pc(sh2)); + elprintf_sh2(sh2, EL_32X, "unmapped r16 [%08x] %04x @%06x", + a, 0, sh2_pc(sh2)); return 0; } @@ -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 @@ -1142,8 +1146,8 @@ static u32 sh2_read16_cs0(u32 a, SH2 *sh2) return sh2_read16_unmapped(a, sh2); out: - elprintf(EL_32X, "%csh2 r16 [%08x] %04x @%06x", - sh2->is_slave ? 's' : 'm', a, d, sh2_pc(sh2)); + elprintf_sh2(sh2, EL_32X, "r16 [%08x] %04x @%06x", + a, d, sh2_pc(sh2)); return d; } @@ -1160,14 +1164,14 @@ static void REGPARM(3) sh2_write_ignore(u32 a, u32 d, SH2 *sh2) // write8 static void REGPARM(3) sh2_write8_unmapped(u32 a, u32 d, SH2 *sh2) { - elprintf(EL_UIO, "%csh2 unmapped w8 [%08x] %02x @%06x", - sh2->is_slave ? 's' : 'm', a, d & 0xff, sh2_pc(sh2)); + elprintf_sh2(sh2, EL_32X, "unmapped w8 [%08x] %02x @%06x", + a, d & 0xff, sh2_pc(sh2)); } static void REGPARM(3) sh2_write8_cs0(u32 a, u32 d, SH2 *sh2) { - elprintf(EL_32X, "%csh2 w8 [%08x] %02x @%06x", - sh2->is_slave ? 's' : 'm', a, d & 0xff, sh2_pc(sh2)); + elprintf_sh2(sh2, EL_32X, "w8 [%08x] %02x @%06x", + a, d & 0xff, sh2_pc(sh2)); if (Pico32x.regs[0] & P32XS_FM) { if ((a & 0x3ff00) == 0x4100) { @@ -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; @@ -1221,15 +1234,15 @@ static void REGPARM(3) sh2_write8_da(u32 a, u32 d, SH2 *sh2) // write16 static void REGPARM(3) sh2_write16_unmapped(u32 a, u32 d, SH2 *sh2) { - elprintf(EL_UIO, "%csh2 unmapped w16 [%08x] %04x @%06x", - sh2->is_slave ? 's' : 'm', a, d & 0xffff, sh2_pc(sh2)); + elprintf_sh2(sh2, EL_32X, "unmapped w16 [%08x] %04x @%06x", + a, d & 0xffff, sh2_pc(sh2)); } static void REGPARM(3) sh2_write16_cs0(u32 a, u32 d, SH2 *sh2) { if (((EL_LOGMASK & EL_PWM) || (a & 0x30) != 0x30)) // hide PWM - elprintf(EL_32X, "%csh2 w16 [%08x] %04x @%06x", - sh2->is_slave ? 's' : 'm', a, d & 0xffff, sh2_pc(sh2)); + elprintf_sh2(sh2, EL_32X, "w16 [%08x] %04x @%06x", + a, d & 0xffff, sh2_pc(sh2)); if (Pico32x.regs[0] & P32XS_FM) { if ((a & 0x3ff00) == 0x4100) { @@ -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;