region detection, cd states wip, fixes, stuff
[picodrive.git] / Pico / Pico.c
index f821cf4..1f201f4 100644 (file)
@@ -16,6 +16,7 @@ struct Pico Pico;
 int PicoOpt=0; // disable everything by default\r
 int PicoSkipFrame=0; // skip rendering frame?\r
 int PicoRegionOverride = 0; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
+int PicoAutoRgnOrder = 0;\r
 int emustatus = 0;\r
 void (*PicoWriteSound)(void) = 0; // called once per frame at the best time to send sound buffer (PsndOut) to hardware\r
 \r
@@ -106,9 +107,12 @@ int PicoReset(int hard)
       c=region>>(i<<3); c&=0xff;\r
       if (c<=' ') continue;\r
 \r
-           if (c=='J') support|=1;\r
-      else if (c=='U') support|=4;\r
-      else if (c=='E') support|=8;\r
+           if (c=='J')  support|=1;\r
+      else if (c=='U')  support|=4;\r
+      else if (c=='E')  support|=8;\r
+      else if (c=='j') {support|=1; break; }\r
+      else if (c=='u') {support|=4; break; }\r
+      else if (c=='e') {support|=8; break; }\r
       else\r
       {\r
         // New style code:\r
@@ -119,6 +123,13 @@ int PicoReset(int hard)
     }\r
   }\r
 \r
+  // auto detection order override\r
+  if (PicoAutoRgnOrder) {\r
+         if (((PicoAutoRgnOrder>>0)&0xf) & support) support = (PicoAutoRgnOrder>>0)&0xf;\r
+    else if (((PicoAutoRgnOrder>>4)&0xf) & support) support = (PicoAutoRgnOrder>>4)&0xf;\r
+    else if (((PicoAutoRgnOrder>>8)&0xf) & support) support = (PicoAutoRgnOrder>>8)&0xf;\r
+  }\r
+\r
   // Try to pick the best hardware value for English/50hz:\r
        if (support&8) { hw=0xc0; pal=1; } // Europe\r
   else if (support&4)   hw=0x80;          // USA\r