more wip SVP code
[picodrive.git] / Pico / Cart.c
index a19dcc8..7c3f36d 100644 (file)
@@ -481,7 +481,7 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize)
   return 0;\r
 }\r
 \r
-// Insert/remove a cartridge:\r
+// Insert a cartridge:\r
 int PicoCartInsert(unsigned char *rom,unsigned int romsize)\r
 {\r
   // notaz: add a 68k "jump one op back" opcode to the end of ROM.\r
@@ -493,15 +493,19 @@ int PicoCartInsert(unsigned char *rom,unsigned int romsize)
   Pico.rom=rom;\r
   Pico.romsize=romsize;\r
 \r
+  PicoMemResetHooks();\r
+  PicoDmaHook = NULL;\r
+  PicoResetHook = NULL;\r
+\r
+  if (!(PicoMCD & 1))\r
+    PicoCartDetect();\r
+\r
   // setup correct memory map for loaded ROM\r
   if (PicoMCD & 1)\r
        PicoMemSetupCD();\r
   else PicoMemSetup();\r
   PicoMemReset();\r
 \r
-  if (!(PicoMCD & 1))\r
-    PicoCartDetect();\r
-\r
   return PicoReset(1);\r
 }\r
 \r
@@ -546,10 +550,12 @@ void PicoCartDetect(void)
       Pico.m.sram_reg |= 4;\r
     } else {\r
       // normal SRAM\r
-      SRam.start = PicoRead32(0x1B4) & 0xFFFF00;\r
+      SRam.start = PicoRead32(0x1B4) & ~0xff;\r
       SRam.end   = PicoRead32(0x1B8) | 1;\r
       sram_size  = SRam.end - SRam.start + 1;\r
     }\r
+    SRam.start &= ~0xff000000;\r
+    SRam.end   &= ~0xff000000;\r
     Pico.m.sram_reg |= 0x10; // SRAM was detected\r
   }\r
   if (sram_size <= 0)\r
@@ -630,5 +636,11 @@ void PicoCartDetect(void)
   // Unusual region 'code'\r
   if (rom_strcmp(0x1f0, "EUROPE") == 0)\r
     *(int *) (Pico.rom+0x1f0) = 0x20204520;\r
+\r
+  // SVP detection\r
+  if (name_cmp("Virtua Racing") == 0)\r
+  {\r
+    PicoSVPInit();\r
+  }\r
 }\r
 \r