Pico version reg, irq3 handling changed
[picodrive.git] / Pico / Pico.c
index 4e34e51..2a18818 100644 (file)
@@ -80,39 +80,19 @@ void PicoPower(void)
   PicoReset();\r
 }\r
 \r
-int PicoReset(void)\r
+PICO_INTERNAL void PicoDetectRegion(void)\r
 {\r
-  unsigned int region=0;\r
-  int support=0,hw=0,i=0;\r
+  int support=0, hw=0, i;\r
   unsigned char pal=0;\r
-  unsigned char sram_reg=Pico.m.sram_reg; // must be preserved\r
-\r
-  if (Pico.romsize<=0) return 1;\r
-\r
-  /* must call now, so that banking is reset, and correct vectors get fetched */\r
-  if (PicoResetHook) PicoResetHook();\r
-\r
-  PicoMemReset();\r
-  SekReset();\r
-  // s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games).\r
-  SekSetRealTAS(PicoAHW & PAHW_MCD);\r
-  SekCycleCntT=0;\r
 \r
-  if (PicoAHW & PAHW_MCD)\r
-    // needed for MCD to reset properly, probably some bug hides behind this..\r
-    memset(Pico.ioports,0,sizeof(Pico.ioports));\r
-  emustatus = 0;\r
-\r
-  Pico.m.dirtyPal = 1;\r
-\r
-  if(PicoRegionOverride)\r
+  if (PicoRegionOverride)\r
   {\r
     support = PicoRegionOverride;\r
   }\r
   else\r
   {\r
     // Read cartridge region data:\r
-    region=PicoRead32(0x1f0);\r
+    int region=PicoRead32(0x1f0);\r
 \r
     for (i=0;i<4;i++)\r
     {\r
@@ -153,7 +133,32 @@ int PicoReset(void)
 \r
   Pico.m.hardware=(unsigned char)(hw|0x20); // No disk attached\r
   Pico.m.pal=pal;\r
-  Pico.video.status = 0x3408 | pal; // 'always set' bits | vblank | pal\r
+}\r
+\r
+int PicoReset(void)\r
+{\r
+  unsigned char sram_reg=Pico.m.sram_reg; // must be preserved\r
+\r
+  if (Pico.romsize<=0) return 1;\r
+\r
+  /* must call now, so that banking is reset, and correct vectors get fetched */\r
+  if (PicoResetHook) PicoResetHook();\r
+\r
+  PicoMemReset();\r
+  SekReset();\r
+  // s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games).\r
+  SekSetRealTAS(PicoAHW & PAHW_MCD);\r
+  SekCycleCntT=0;\r
+\r
+  if (PicoAHW & PAHW_MCD)\r
+    // needed for MCD to reset properly, probably some bug hides behind this..\r
+    memset(Pico.ioports,0,sizeof(Pico.ioports));\r
+  emustatus = 0;\r
+\r
+  Pico.m.dirtyPal = 1;\r
+\r
+  PicoDetectRegion();\r
+  Pico.video.status = 0x3408 | Pico.m.pal; // 'always set' bits | vblank | pal\r
 \r
   PsndReset(); // pal must be known here\r
 \r