X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=picodrive.git;a=blobdiff_plain;f=pico%2Fcart.c;h=9fcb01a4daf6323f824489efc7ba40b773a6aa32;hp=f17ce5e7b365142de4400059882ebdbc5905a299;hb=8b9dbcde387f567a154e15ca14a0c6e5b3efa3ef;hpb=88fd63ad10faa746ef9d7ad7d98a72e51fe2aa86 diff --git a/pico/cart.c b/pico/cart.c index f17ce5e..9fcb01a 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -391,8 +391,8 @@ int pm_seek(pm_file *stream, long offset, int whence) offset = pos; } - if (PicoMessage != NULL && offset > 4 * 1024 * 1024) - PicoMessage("Decompressing data..."); + if (PicoIn.osdMessage != NULL && offset > 4 * 1024 * 1024) + PicoIn.osdMessage("Decompressing data..."); while (offset > 0) { char buf[16 * 1024]; @@ -576,9 +576,9 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms) if (!is_sms) { // maybe we are loading MegaCD BIOS? - if (!(PicoAHW & PAHW_MCD) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) || + if (!(PicoIn.AHW & PAHW_MCD) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) || !strncmp((char *)rom+0x128, "BOOT", 4))) { - PicoAHW |= PAHW_MCD; + PicoIn.AHW |= PAHW_MCD; } // Check for SMD: @@ -628,7 +628,7 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_ } pdb_cleanup(); - PicoAHW &= PAHW_MCD|PAHW_SMS; + PicoIn.AHW &= PAHW_MCD|PAHW_SMS; PicoCartMemSetup = NULL; PicoDmaHook = NULL; @@ -637,13 +637,13 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_ PicoLoadStateHook = NULL; carthw_chunks = NULL; - if (!(PicoAHW & (PAHW_MCD|PAHW_SMS))) + if (!(PicoIn.AHW & (PAHW_MCD|PAHW_SMS))) PicoCartDetect(carthw_cfg); // setup correct memory map for loaded ROM - switch (PicoAHW) { + switch (PicoIn.AHW) { default: - elprintf(EL_STATUS|EL_ANOMALY, "starting in unknown hw configuration: %x", PicoAHW); + elprintf(EL_STATUS|EL_ANOMALY, "starting in unknown hw configuration: %x", PicoIn.AHW); case 0: case PAHW_SVP: PicoMemSetup(); break; case PAHW_MCD: PicoMemSetupCD(); break; @@ -654,7 +654,7 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_ if (PicoCartMemSetup != NULL) PicoCartMemSetup(); - if (PicoAHW & PAHW_SMS) + if (PicoIn.AHW & PAHW_SMS) PicoPowerMS(); else PicoPower(); @@ -681,7 +681,7 @@ void PicoCartUnload(void) PicoCartUnloadHook = NULL; } - if (PicoAHW & PAHW_32X) + if (PicoIn.AHW & PAHW_32X) PicoUnload32x(); if (Pico.rom != NULL) { @@ -778,7 +778,8 @@ static int is_expr(const char *expr, char **pr) #include "carthw_cfg.c" -static void parse_carthw(const char *carthw_cfg, int *fill_sram) +static void parse_carthw(const char *carthw_cfg, int *fill_sram, + int *hw_detected) { int line = 0, any_checks_passed = 0, skip_sect = 0; const char *s, *builtin = builtin_carthw_cfg; @@ -902,6 +903,7 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram) if (is_expr("hw", &p)) { if (!any_checks_passed) goto no_checks; + *hw_detected = 1; rstrip(p); if (strcmp(p, "svp") == 0) @@ -925,6 +927,7 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram) else { elprintf(EL_STATUS, "carthw:%d: unsupported mapper: %s", line, p); skip_sect = 1; + *hw_detected = 0; } continue; } @@ -965,7 +968,7 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram) else if (strcmp(p, "filled_sram") == 0) *fill_sram = 1; else if (strcmp(p, "force_6btn") == 0) - PicoQuirks |= PQUIRK_FORCE_6BTN; + PicoIn.quirks |= PQUIRK_FORCE_6BTN; else { elprintf(EL_STATUS, "carthw:%d: unsupported prop: %s", line, p); goto bad_nomsg; @@ -1038,6 +1041,7 @@ no_checks: */ static void PicoCartDetect(const char *carthw_cfg) { + int carthw_detected = 0; int fill_sram = 0; memset(&Pico.sv, 0, sizeof(Pico.sv)); @@ -1067,7 +1071,11 @@ static void PicoCartDetect(const char *carthw_cfg) Pico.sv.eeprom_bit_out= 0; if (carthw_cfg != NULL) - parse_carthw(carthw_cfg, &fill_sram); + parse_carthw(carthw_cfg, &fill_sram, &carthw_detected); + + // assume the standard mapper for large roms + if (!carthw_detected && Pico.romsize > 0x400000) + carthw_ssf2_startup(); if (Pico.sv.flags & SRF_ENABLED) {