read-ahead turn off, cfg file, minor adjustments
[picodrive.git] / Pico / Memory.c
index 8dc11bb..8632c7a 100644 (file)
@@ -37,6 +37,8 @@ extern unsigned int ppop;
 \r
 #ifdef IO_STATS\r
 void log_io(unsigned int addr, int bits, int rw);\r
+#elif defined(_MSC_VER)\r
+#define log_io\r
 #else\r
 #define log_io(...)\r
 #endif\r
@@ -203,10 +205,7 @@ static void SRAMWrite(u32 a, u32 d)
 }\r
 \r
 // for nonstandard reads\r
-#ifndef _ASM_MEMORY_C\r
-static\r
-#endif\r
-u32 OtherRead16End(u32 a, int realsize)\r
+static u32 OtherRead16End(u32 a, int realsize)\r
 {\r
   u32 d=0;\r
 \r
@@ -304,23 +303,11 @@ static void OtherWrite8End(u32 a,u32 d,int realsize)
 #endif\r
   elprintf(EL_UIO, "strange w%i: %06x, %08x @%06x", realsize, a&0xffffff, d, SekPc);\r
 \r
-  if(a >= 0xA13004 && a < 0xA13040) {\r
-    // dumb 12-in-1 or 4-in-1 banking support\r
-    int len;\r
-    a &= 0x3f; a <<= 16;\r
-    len = Pico.romsize - a;\r
-    if (len <= 0) return; // invalid/missing bank\r
-    if (len > 0x200000) len = 0x200000; // 2 megs\r
-    memcpy(Pico.rom, Pico.rom+a, len); // code which does this is in RAM so this is safe.\r
-    return;\r
-  }\r
-\r
   // for games with simple protection devices, discovered by Haze\r
-  else if ((a>>22) == 1)\r
+  if ((a>>22) == 1)\r
     Pico.m.prot_bytes[(a>>2)&1] = (u8)d;\r
 }\r
 \r
-\r
 #include "MemoryCmn.c"\r
 \r
 \r
@@ -499,6 +486,26 @@ static void PicoWrite32(u32 a,u32 d)
 \r
 \r
 // -----------------------------------------------------------------\r
+\r
+// TODO: asm code\r
+static void OtherWrite16End(u32 a,u32 d,int realsize)\r
+{\r
+  PicoWrite8Hook(a,  d>>8, realsize);\r
+  PicoWrite8Hook(a+1,d&0xff, realsize);\r
+}\r
+\r
+u32  (*PicoRead16Hook) (u32 a, int realsize) = OtherRead16End;\r
+void (*PicoWrite8Hook) (u32 a, u32 d, int realsize) = OtherWrite8End;\r
+void (*PicoWrite16Hook)(u32 a, u32 d, int realsize) = OtherWrite16End;\r
+\r
+PICO_INTERNAL void PicoMemResetHooks(void)\r
+{\r
+  // default unmapped/cart specific handlers\r
+  PicoRead16Hook = OtherRead16End;\r
+  PicoWrite8Hook = OtherWrite8End;\r
+  PicoWrite16Hook = OtherWrite16End;\r
+}\r
+\r
 PICO_INTERNAL void PicoMemSetup(void)\r
 {\r
   // Setup memory callbacks:\r