32x: implement standard/ssf2 mapper
[picodrive.git] / pico / cart.c
index 58a9a68..9fcb01a 100644 (file)
@@ -778,7 +778,8 @@ static int is_expr(const char *expr, char **pr)
 \r
 #include "carthw_cfg.c"\r
 \r
-static void parse_carthw(const char *carthw_cfg, int *fill_sram)\r
+static void parse_carthw(const char *carthw_cfg, int *fill_sram,\r
+  int *hw_detected)\r
 {\r
   int line = 0, any_checks_passed = 0, skip_sect = 0;\r
   const char *s, *builtin = builtin_carthw_cfg;\r
@@ -902,6 +903,7 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
     if (is_expr("hw", &p)) {\r
       if (!any_checks_passed)\r
         goto no_checks;\r
+      *hw_detected = 1;\r
       rstrip(p);\r
 \r
       if      (strcmp(p, "svp") == 0)\r
@@ -925,6 +927,7 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
       else {\r
         elprintf(EL_STATUS, "carthw:%d: unsupported mapper: %s", line, p);\r
         skip_sect = 1;\r
+        *hw_detected = 0;\r
       }\r
       continue;\r
     }\r
@@ -1038,6 +1041,7 @@ no_checks:
  */\r
 static void PicoCartDetect(const char *carthw_cfg)\r
 {\r
+  int carthw_detected = 0;\r
   int fill_sram = 0;\r
 \r
   memset(&Pico.sv, 0, sizeof(Pico.sv));\r
@@ -1067,7 +1071,11 @@ static void PicoCartDetect(const char *carthw_cfg)
   Pico.sv.eeprom_bit_out= 0;\r
 \r
   if (carthw_cfg != NULL)\r
-    parse_carthw(carthw_cfg, &fill_sram);\r
+    parse_carthw(carthw_cfg, &fill_sram, &carthw_detected);\r
+\r
+  // assume the standard mapper for large roms\r
+  if (!carthw_detected && Pico.romsize > 0x400000)\r
+    carthw_ssf2_startup();\r
 \r
   if (Pico.sv.flags & SRF_ENABLED)\r
   {\r