handle 32x+cd
[picodrive.git] / pico / cd / memory.c
index 2d8cc76..1d844da 100644 (file)
@@ -28,11 +28,6 @@ MAKE_68K_WRITE32(s68k_write32, s68k_write16_map)
 \r
 // provided by ASM code:\r
 #ifdef _ASM_CD_MEMORY_C\r
-u32 PicoReadM68k8_io(u32 a);\r
-u32 PicoReadM68k16_io(u32 a);\r
-void PicoWriteM68k8_io(u32 a, u32 d);\r
-void PicoWriteM68k16_io(u32 a, u32 d);\r
-\r
 u32 PicoReadS68k8_pr(u32 a);\r
 u32 PicoReadS68k16_pr(u32 a);\r
 void PicoWriteS68k8_pr(u32 a, u32 d);\r
@@ -75,9 +70,10 @@ static void remap_word_ram(u32 r3);
 void m68k_comm_check(u32 a)\r
 {\r
   pcd_sync_s68k(SekCyclesDone(), 0);\r
-  if (a != Pico_mcd->m.m68k_poll_a) {\r
+  if (SekNotPolling || a != Pico_mcd->m.m68k_poll_a) {\r
     Pico_mcd->m.m68k_poll_a = a;\r
     Pico_mcd->m.m68k_poll_cnt = 0;\r
+    SekNotPolling = 0;\r
     return;\r
   }\r
   Pico_mcd->m.m68k_poll_cnt++;\r
@@ -246,7 +242,7 @@ u32 s68k_poll_detect(u32 a, u32 d)
     return d;\r
 \r
   cycles = SekCyclesDoneS68k();\r
-  if (a == Pico_mcd->m.s68k_poll_a) {\r
+  if (!SekNotPolling && a == Pico_mcd->m.s68k_poll_a) {\r
     u32 clkdiff = cycles - Pico_mcd->m.s68k_poll_clk;\r
     if (clkdiff <= POLL_CYCLES) {\r
       cnt = Pico_mcd->m.s68k_poll_cnt + 1;\r
@@ -261,6 +257,7 @@ u32 s68k_poll_detect(u32 a, u32 d)
   Pico_mcd->m.s68k_poll_a = a;\r
   Pico_mcd->m.s68k_poll_clk = cycles;\r
   Pico_mcd->m.s68k_poll_cnt = cnt;\r
+  SekNotPollingS68k = 0;\r
 #endif\r
   return d;\r
 }\r
@@ -551,18 +548,20 @@ static void PicoWriteM68k8_ramc(u32 a, u32 d)
     return;\r
   }\r
 \r
-  elprintf(EL_UIO, "m68k unmapped w8  [%06x]   %02x @%06x", a, d & 0xff, SekPc);\r
+  elprintf(EL_UIO, "m68k unmapped w8  [%06x]   %02x @%06x",\r
+    a, d & 0xff, SekPc);\r
 }\r
 \r
 static void PicoWriteM68k16_ramc(u32 a, u32 d)\r
 {\r
-  elprintf(EL_ANOMALY, "ramcart w16: [%06x] %04x @%06x", a, d, SekPcS68k);\r
+  elprintf(EL_ANOMALY, "ramcart w16: [%06x] %04x @%06x",\r
+    a, d, SekPcS68k);\r
   PicoWriteM68k8_ramc(a + 1, d);\r
 }\r
 \r
 // IO/control/cd registers (a10000 - ...)\r
 #ifndef _ASM_CD_MEMORY_C\r
-static u32 PicoReadM68k8_io(u32 a)\r
+u32 PicoRead8_mcd_io(u32 a)\r
 {\r
   u32 d;\r
   if ((a & 0xff00) == 0x2000) { // a12000 - a120ff\r
@@ -570,7 +569,8 @@ static u32 PicoReadM68k8_io(u32 a)
     if (!(a & 1))\r
       d >>= 8;\r
     d &= 0xff;\r
-    elprintf(EL_CDREGS, "m68k_regs r8:  [%02x]   %02x @%06x", a & 0x3f, d, SekPc);\r
+    elprintf(EL_CDREGS, "m68k_regs r8:  [%02x]   %02x @%06x",\r
+      a & 0x3f, d, SekPc);\r
     return d;\r
   }\r
 \r
@@ -578,22 +578,24 @@ static u32 PicoReadM68k8_io(u32 a)
   return PicoRead8_io(a);\r
 }\r
 \r
-static u32 PicoReadM68k16_io(u32 a)\r
+u32 PicoRead16_mcd_io(u32 a)\r
 {\r
   u32 d;\r
   if ((a & 0xff00) == 0x2000) {\r
     d = m68k_reg_read16(a);\r
-    elprintf(EL_CDREGS, "m68k_regs r16: [%02x] %04x @%06x", a & 0x3f, d, SekPc);\r
+    elprintf(EL_CDREGS, "m68k_regs r16: [%02x] %04x @%06x",\r
+      a & 0x3f, d, SekPc);\r
     return d;\r
   }\r
 \r
   return PicoRead16_io(a);\r
 }\r
 \r
-static void PicoWriteM68k8_io(u32 a, u32 d)\r
+void PicoWrite8_mcd_io(u32 a, u32 d)\r
 {\r
   if ((a & 0xff00) == 0x2000) { // a12000 - a120ff\r
-    elprintf(EL_CDREGS, "m68k_regs w8:  [%02x]   %02x @%06x", a&0x3f, d, SekPc);\r
+    elprintf(EL_CDREGS, "m68k_regs w8:  [%02x]   %02x @%06x",\r
+      a & 0x3f, d, SekPc);\r
     m68k_reg_write8(a, d);\r
     return;\r
   }\r
@@ -601,10 +603,11 @@ static void PicoWriteM68k8_io(u32 a, u32 d)
   PicoWrite16_io(a, d);\r
 }\r
 \r
-static void PicoWriteM68k16_io(u32 a, u32 d)\r
+void PicoWrite16_mcd_io(u32 a, u32 d)\r
 {\r
   if ((a & 0xff00) == 0x2000) { // a12000 - a120ff\r
-    elprintf(EL_CDREGS, "m68k_regs w16: [%02x] %04x @%06x", a&0x3f, d, SekPc);\r
+    elprintf(EL_CDREGS, "m68k_regs w16: [%02x] %04x @%06x",\r
+      a & 0x3f, d, SekPc);\r
 \r
     m68k_reg_write8(a,     d >> 8);\r
     if ((a & 0x3e) != 0x0e) // special case\r
@@ -634,12 +637,14 @@ static u32 s68k_unmapped_read16(u32 a)
 \r
 static void s68k_unmapped_write8(u32 a, u32 d)\r
 {\r
-  elprintf(EL_UIO, "s68k unmapped w8  [%06x]   %02x @%06x", a, d & 0xff, SekPc);\r
+  elprintf(EL_UIO, "s68k unmapped w8  [%06x]   %02x @%06x",\r
+    a, d & 0xff, SekPc);\r
 }\r
 \r
 static void s68k_unmapped_write16(u32 a, u32 d)\r
 {\r
-  elprintf(EL_UIO, "s68k unmapped w16 [%06x] %04x @%06x", a, d & 0xffff, SekPc);\r
+  elprintf(EL_UIO, "s68k unmapped w16 [%06x] %04x @%06x",\r
+    a, d & 0xffff, SekPc);\r
 }\r
 \r
 // PRG RAM protected range (000000 - 01fdff)?\r
@@ -1047,10 +1052,10 @@ PICO_INTERNAL void PicoMemSetupCD(void)
   }\r
 \r
   // registers/IO:\r
-  cpu68k_map_set(m68k_read8_map,   0xa10000, 0xa1ffff, PicoReadM68k8_io, 1);\r
-  cpu68k_map_set(m68k_read16_map,  0xa10000, 0xa1ffff, PicoReadM68k16_io, 1);\r
-  cpu68k_map_set(m68k_write8_map,  0xa10000, 0xa1ffff, PicoWriteM68k8_io, 1);\r
-  cpu68k_map_set(m68k_write16_map, 0xa10000, 0xa1ffff, PicoWriteM68k16_io, 1);\r
+  cpu68k_map_set(m68k_read8_map,   0xa10000, 0xa1ffff, PicoRead8_mcd_io, 1);\r
+  cpu68k_map_set(m68k_read16_map,  0xa10000, 0xa1ffff, PicoRead16_mcd_io, 1);\r
+  cpu68k_map_set(m68k_write8_map,  0xa10000, 0xa1ffff, PicoWrite8_mcd_io, 1);\r
+  cpu68k_map_set(m68k_write16_map, 0xa10000, 0xa1ffff, PicoWrite16_mcd_io, 1);\r
 \r
   // sub68k map\r
   cpu68k_map_set(s68k_read8_map,   0x000000, 0xffffff, s68k_unmapped_read8, 1);\r