X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fcd%2Fmemory.c;h=8fce606fcd5429a38104d51f73a0921853d0cc5f;hb=33be04ca5fee314271f1959672e22cf94d670ea6;hp=2d8cc7643e843f24cfb42eec6fef0e66988153ba;hpb=30e8aac43f1a7afbc3ac8a4b0b13c80d1a7243d2;p=picodrive.git diff --git a/pico/cd/memory.c b/pico/cd/memory.c index 2d8cc76..8fce606 100644 --- a/pico/cd/memory.c +++ b/pico/cd/memory.c @@ -10,7 +10,6 @@ #include "../memory.h" #include "gfx_cd.h" -#include "pcm.h" uptr s68k_read8_map [0x1000000 >> M68K_MEM_SHIFT]; uptr s68k_read16_map [0x1000000 >> M68K_MEM_SHIFT]; @@ -28,11 +27,6 @@ MAKE_68K_WRITE32(s68k_write32, s68k_write16_map) // provided by ASM code: #ifdef _ASM_CD_MEMORY_C -u32 PicoReadM68k8_io(u32 a); -u32 PicoReadM68k16_io(u32 a); -void PicoWriteM68k8_io(u32 a, u32 d); -void PicoWriteM68k16_io(u32 a, u32 d); - u32 PicoReadS68k8_pr(u32 a); u32 PicoReadS68k16_pr(u32 a); void PicoWriteS68k8_pr(u32 a, u32 d); @@ -75,9 +69,10 @@ static void remap_word_ram(u32 r3); void m68k_comm_check(u32 a) { pcd_sync_s68k(SekCyclesDone(), 0); - if (a != Pico_mcd->m.m68k_poll_a) { + if (SekNotPolling || a != Pico_mcd->m.m68k_poll_a) { Pico_mcd->m.m68k_poll_a = a; Pico_mcd->m.m68k_poll_cnt = 0; + SekNotPolling = 0; return; } Pico_mcd->m.m68k_poll_cnt++; @@ -246,7 +241,7 @@ u32 s68k_poll_detect(u32 a, u32 d) return d; cycles = SekCyclesDoneS68k(); - if (a == Pico_mcd->m.s68k_poll_a) { + if (!SekNotPolling && a == Pico_mcd->m.s68k_poll_a) { u32 clkdiff = cycles - Pico_mcd->m.s68k_poll_clk; if (clkdiff <= POLL_CYCLES) { cnt = Pico_mcd->m.s68k_poll_cnt + 1; @@ -261,6 +256,7 @@ u32 s68k_poll_detect(u32 a, u32 d) Pico_mcd->m.s68k_poll_a = a; Pico_mcd->m.s68k_poll_clk = cycles; Pico_mcd->m.s68k_poll_cnt = cnt; + SekNotPollingS68k = 0; #endif return d; } @@ -334,6 +330,10 @@ void s68k_reg_write8(u32 a, u32 d) { // Warning: d might have upper bits set switch (a) { + case 1: + if (!(d & 1)) + pcd_soft_reset(); + return; case 2: return; // only m68k can change WP case 3: { @@ -551,18 +551,20 @@ static void PicoWriteM68k8_ramc(u32 a, u32 d) return; } - elprintf(EL_UIO, "m68k unmapped w8 [%06x] %02x @%06x", a, d & 0xff, SekPc); + elprintf(EL_UIO, "m68k unmapped w8 [%06x] %02x @%06x", + a, d & 0xff, SekPc); } static void PicoWriteM68k16_ramc(u32 a, u32 d) { - elprintf(EL_ANOMALY, "ramcart w16: [%06x] %04x @%06x", a, d, SekPcS68k); + elprintf(EL_ANOMALY, "ramcart w16: [%06x] %04x @%06x", + a, d, SekPcS68k); PicoWriteM68k8_ramc(a + 1, d); } // IO/control/cd registers (a10000 - ...) #ifndef _ASM_CD_MEMORY_C -static u32 PicoReadM68k8_io(u32 a) +u32 PicoRead8_mcd_io(u32 a) { u32 d; if ((a & 0xff00) == 0x2000) { // a12000 - a120ff @@ -570,7 +572,8 @@ static u32 PicoReadM68k8_io(u32 a) if (!(a & 1)) d >>= 8; d &= 0xff; - elprintf(EL_CDREGS, "m68k_regs r8: [%02x] %02x @%06x", a & 0x3f, d, SekPc); + elprintf(EL_CDREGS, "m68k_regs r8: [%02x] %02x @%06x", + a & 0x3f, d, SekPc); return d; } @@ -578,22 +581,24 @@ static u32 PicoReadM68k8_io(u32 a) return PicoRead8_io(a); } -static u32 PicoReadM68k16_io(u32 a) +u32 PicoRead16_mcd_io(u32 a) { u32 d; if ((a & 0xff00) == 0x2000) { d = m68k_reg_read16(a); - elprintf(EL_CDREGS, "m68k_regs r16: [%02x] %04x @%06x", a & 0x3f, d, SekPc); + elprintf(EL_CDREGS, "m68k_regs r16: [%02x] %04x @%06x", + a & 0x3f, d, SekPc); return d; } return PicoRead16_io(a); } -static void PicoWriteM68k8_io(u32 a, u32 d) +void PicoWrite8_mcd_io(u32 a, u32 d) { if ((a & 0xff00) == 0x2000) { // a12000 - a120ff - elprintf(EL_CDREGS, "m68k_regs w8: [%02x] %02x @%06x", a&0x3f, d, SekPc); + elprintf(EL_CDREGS, "m68k_regs w8: [%02x] %02x @%06x", + a & 0x3f, d, SekPc); m68k_reg_write8(a, d); return; } @@ -601,10 +606,11 @@ static void PicoWriteM68k8_io(u32 a, u32 d) PicoWrite16_io(a, d); } -static void PicoWriteM68k16_io(u32 a, u32 d) +void PicoWrite16_mcd_io(u32 a, u32 d) { if ((a & 0xff00) == 0x2000) { // a12000 - a120ff - elprintf(EL_CDREGS, "m68k_regs w16: [%02x] %04x @%06x", a&0x3f, d, SekPc); + elprintf(EL_CDREGS, "m68k_regs w16: [%02x] %04x @%06x", + a & 0x3f, d, SekPc); m68k_reg_write8(a, d >> 8); if ((a & 0x3e) != 0x0e) // special case @@ -634,12 +640,14 @@ static u32 s68k_unmapped_read16(u32 a) static void s68k_unmapped_write8(u32 a, u32 d) { - elprintf(EL_UIO, "s68k unmapped w8 [%06x] %02x @%06x", a, d & 0xff, SekPc); + elprintf(EL_UIO, "s68k unmapped w8 [%06x] %02x @%06x", + a, d & 0xff, SekPc); } static void s68k_unmapped_write16(u32 a, u32 d) { - elprintf(EL_UIO, "s68k unmapped w16 [%06x] %04x @%06x", a, d & 0xffff, SekPc); + elprintf(EL_UIO, "s68k unmapped w16 [%06x] %04x @%06x", + a, d & 0xffff, SekPc); } // PRG RAM protected range (000000 - 01fdff)? @@ -825,13 +833,10 @@ regs_done: a &= 0x7fff; if (a >= 0x2000) d = Pico_mcd->pcm_ram_b[Pico_mcd->pcm.bank][(a >> 1) & 0xfff]; - else if (a >= 0x20) { - a &= 0x1e; - d = Pico_mcd->pcm.ch[a>>2].addr >> PCM_STEP_SHIFT; - if (a & 2) - d >>= 8; - } - return d & 0xff; + else if (a >= 0x20) + d = pcd_pcm_read(a >> 1); + + return d; } return s68k_unmapped_read8(a); @@ -855,16 +860,12 @@ static u32 PicoReadS68k16_pr(u32 a) // PCM if ((a & 0x8000) == 0x0000) { - //elprintf(EL_ANOMALY, "FIXME: s68k_pcm r16: [%06x] @%06x", a, SekPcS68k); a &= 0x7fff; if (a >= 0x2000) - d = Pico_mcd->pcm_ram_b[Pico_mcd->pcm.bank][(a>>1)&0xfff]; - else if (a >= 0x20) { - a &= 0x1e; - d = Pico_mcd->pcm.ch[a>>2].addr >> PCM_STEP_SHIFT; - if (a & 2) d >>= 8; - } - elprintf(EL_CDREGS, "ret = %04x", d); + d = Pico_mcd->pcm_ram_b[Pico_mcd->pcm.bank][(a >> 1) & 0xfff]; + else if (a >= 0x20) + d = pcd_pcm_read(a >> 1); + return d; } @@ -889,7 +890,7 @@ static void PicoWriteS68k8_pr(u32 a, u32 d) if (a >= 0x2000) Pico_mcd->pcm_ram_b[Pico_mcd->pcm.bank][(a>>1)&0xfff] = d; else if (a < 0x12) - pcm_write(a>>1, d); + pcd_pcm_write(a>>1, d); return; } @@ -923,7 +924,7 @@ static void PicoWriteS68k16_pr(u32 a, u32 d) if (a >= 0x2000) Pico_mcd->pcm_ram_b[Pico_mcd->pcm.bank][(a>>1)&0xfff] = d; else if (a < 0x12) - pcm_write(a>>1, d & 0xff); + pcd_pcm_write(a>>1, d & 0xff); return; } @@ -1047,10 +1048,10 @@ PICO_INTERNAL void PicoMemSetupCD(void) } // registers/IO: - cpu68k_map_set(m68k_read8_map, 0xa10000, 0xa1ffff, PicoReadM68k8_io, 1); - cpu68k_map_set(m68k_read16_map, 0xa10000, 0xa1ffff, PicoReadM68k16_io, 1); - cpu68k_map_set(m68k_write8_map, 0xa10000, 0xa1ffff, PicoWriteM68k8_io, 1); - cpu68k_map_set(m68k_write16_map, 0xa10000, 0xa1ffff, PicoWriteM68k16_io, 1); + cpu68k_map_set(m68k_read8_map, 0xa10000, 0xa1ffff, PicoRead8_mcd_io, 1); + cpu68k_map_set(m68k_read16_map, 0xa10000, 0xa1ffff, PicoRead16_mcd_io, 1); + cpu68k_map_set(m68k_write8_map, 0xa10000, 0xa1ffff, PicoWrite8_mcd_io, 1); + cpu68k_map_set(m68k_write16_map, 0xa10000, 0xa1ffff, PicoWrite16_mcd_io, 1); // sub68k map cpu68k_map_set(s68k_read8_map, 0x000000, 0xffffff, s68k_unmapped_read8, 1);