improved game vidmode change detection; some iface changes
[picodrive.git] / pico / cart.c
index 26fb59b..45f3866 100644 (file)
@@ -21,7 +21,7 @@ void (*PicoCartMemSetup)(void);
 void (*PicoCartLoadProgressCB)(int percent) = NULL;\r
 void (*PicoCDLoadProgressCB)(const char *fname, int percent) = NULL; // handled in Pico/cd/cd_file.c\r
 \r
-static void PicoCartDetect(void);\r
+static void PicoCartDetect(const char *carthw_cfg);\r
 \r
 /* cso struct */\r
 typedef struct _cso_struct\r
@@ -541,7 +541,7 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms)
 }\r
 \r
 // Insert a cartridge:\r
-int PicoCartInsert(unsigned char *rom,unsigned int romsize)\r
+int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_cfg)\r
 {\r
   // notaz: add a 68k "jump one op back" opcode to the end of ROM.\r
   // This will hang the emu, but will prevent nasty crashes.\r
@@ -572,7 +572,7 @@ int PicoCartInsert(unsigned char *rom,unsigned int romsize)
   carthw_chunks = NULL;\r
 \r
   if (!(PicoAHW & (PAHW_MCD|PAHW_SMS)))\r
-    PicoCartDetect();\r
+    PicoCartDetect(carthw_cfg);\r
 \r
   // setup correct memory map for loaded ROM\r
   switch (PicoAHW) {\r
@@ -695,16 +695,16 @@ static int is_expr(const char *expr, char **pr)
   return 1;\r
 }\r
 \r
-static void parse_carthw(int *fill_sram)\r
+static void parse_carthw(const char *carthw_cfg, int *fill_sram)\r
 {\r
   int line = 0, any_checks_passed = 0, skip_sect = 0;\r
   int tmp, rom_crc = 0;\r
   char buff[256], *p, *r;\r
   FILE *f;\r
 \r
-  f = fopen("carthw.cfg", "r");\r
+  f = fopen(carthw_cfg, "r");\r
   if (f == NULL) {\r
-    elprintf(EL_STATUS, "couldn't open carthw.txt!");\r
+    elprintf(EL_STATUS, "couldn't open carthw.cfg!");\r
     return;\r
   }\r
 \r
@@ -924,7 +924,7 @@ no_checks:
 /*\r
  * various cart-specific things, which can't be handled by generic code\r
  */\r
-static void PicoCartDetect(void)\r
+static void PicoCartDetect(const char *carthw_cfg)\r
 {\r
   int fill_sram = 0;\r
 \r
@@ -954,7 +954,8 @@ static void PicoCartDetect(void)
   SRam.eeprom_bit_in = 0;\r
   SRam.eeprom_bit_out= 0;\r
 \r
-  parse_carthw(&fill_sram);\r
+  if (carthw_cfg != NULL)\r
+    parse_carthw(carthw_cfg, &fill_sram);\r
 \r
   if (SRam.flags & SRF_ENABLED)\r
   {\r