fixed some portability issues
[picodrive.git] / Pico / cd / Memory.c
index c883a76..b1faacd 100644 (file)
@@ -18,10 +18,15 @@ typedef unsigned int   u32;
 #define UTYPES_DEFINED\r
 #endif\r
 \r
+#ifdef _MSC_VER\r
+#define rdprintf\r
+#define wrdprintf\r
+#else\r
 //#define rdprintf dprintf\r
 #define rdprintf(...)\r
 //#define wrdprintf dprintf\r
 #define wrdprintf(...)\r
+#endif\r
 \r
 #ifdef EMU_CORE_DEBUG\r
 extern u32 lastread_a, lastread_d[16], lastwrite_cyc_d[16];\r
@@ -376,11 +381,11 @@ void s68k_reg_write8(u32 a, u32 d)
 }\r
 \r
 \r
-#ifndef _ASM_CD_MEMORY_C\r
 static u32 OtherRead16End(u32 a, int realsize)\r
 {\r
   u32 d=0;\r
 \r
+#ifndef _ASM_CD_MEMORY_C\r
   if ((a&0xffffc0)==0xa12000) {\r
     d=m68k_reg_read16(a);\r
     goto end;\r
@@ -403,16 +408,20 @@ static u32 OtherRead16End(u32 a, int realsize)
     d=Pico_mcd->m.bcram_reg;\r
     goto end;\r
   }\r
+#endif\r
 \r
   elprintf(EL_UIO, "m68k FIXME: unusual r%i: %06x @%06x", realsize&~1, (a&0xfffffe)+(realsize&1), SekPc);\r
 \r
+#ifndef _ASM_CD_MEMORY_C\r
 end:\r
+#endif\r
   return d;\r
 }\r
 \r
 \r
 static void OtherWrite8End(u32 a, u32 d, int realsize)\r
 {\r
+#ifndef _ASM_CD_MEMORY_C\r
   if ((a&0xffffc0)==0xa12000) { m68k_reg_write8(a, d); return; }\r
 \r
   if ((a&0xfe0000)==0x600000) {\r
@@ -427,15 +436,17 @@ static void OtherWrite8End(u32 a, u32 d, int realsize)
     Pico_mcd->m.bcram_reg=d;\r
     return;\r
   }\r
+#endif\r
 \r
   elprintf(EL_UIO, "m68k FIXME: strange w%i: [%06x], %08x @%06x", realsize, a&0xffffff, d, SekPc);\r
 }\r
 \r
+#ifndef _ASM_CD_MEMORY_C\r
 #define _CD_MEMORY_C\r
 #undef _ASM_MEMORY_C\r
 #include "../MemoryCmn.c"\r
 #include "cell_map.c"\r
-#endif // !def _ASM_CD_MEMORY_C\r
+#endif\r
 \r
 \r
 // -----------------------------------------------------------------\r
@@ -1152,11 +1163,12 @@ static u32 PicoReadS68k32(u32 a)
   // word RAM (1M area)\r
   if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff\r
     int bank;\r
+    u16 *pm;\r
     wrdprintf("s68k_wram1M r32: [%06x] @%06x", a, SekPcS68k);\r
 //    if (!(Pico_mcd->s68k_regs[3]&4))\r
 //      dprintf("s68k_wram1M FIXME: wrong mode");\r
     bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
-    u16 *pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe)); d = (pm[0]<<16)|pm[1];\r
+    pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe)); d = (pm[0]<<16)|pm[1];\r
     wrdprintf("ret = %08x", d);\r
     goto end;\r
   }\r
@@ -1626,6 +1638,10 @@ void PicoMemResetCD(int r3)
 \r
 PICO_INTERNAL void PicoMemSetupCD(void)\r
 {\r
+  // additional handlers for common code\r
+  PicoRead16Hook = OtherRead16End;\r
+  PicoWrite8Hook = OtherWrite8End;\r
+\r
 #ifdef EMU_C68K\r
   // Setup m68k memory callbacks:\r
   PicoCpuCM68k.checkpc=PicoCheckPcM68k;\r