X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FCart.c;h=52f5cf507f630307fc6c77be46c53a628c44922a;hb=a12b1b29cc7e394128da59614c2efe8f5d182741;hp=34a497ea9cd9577fea3df20351da72d357cba3e7;hpb=f53f286a8b48d19c65e83f90d00aa47e8e87c889;p=picodrive.git diff --git a/Pico/Cart.c b/Pico/Cart.c index 34a497e..52f5cf5 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -15,6 +15,8 @@ static char *rom_exts[] = { "bin", "gen", "smd", "iso" }; +void (*PicoCartUnloadHook)(void) = NULL; + void (*PicoCartLoadProgressCB)(int percent) = NULL; void (*PicoCDLoadProgressCB)(int percent) = NULL; // handled in Pico/cd/cd_file.c @@ -481,7 +483,7 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize) return 0; } -// Insert/remove a cartridge: +// Insert a cartridge: int PicoCartInsert(unsigned char *rom,unsigned int romsize) { // notaz: add a 68k "jump one op back" opcode to the end of ROM. @@ -493,21 +495,38 @@ int PicoCartInsert(unsigned char *rom,unsigned int romsize) Pico.rom=rom; Pico.romsize=romsize; + if (PicoCartUnloadHook != NULL) { + PicoCartUnloadHook(); + PicoCartUnloadHook = NULL; + } + + PicoMemResetHooks(); + PicoDmaHook = NULL; + PicoResetHook = NULL; + PicoLineHook = NULL; + carthw_chunks = NULL; + + PicoMemReset(); + + if (!(PicoMCD & 1)) + PicoCartDetect(); + // setup correct memory map for loaded ROM + // call PicoMemReset again due to possible memmap change if (PicoMCD & 1) PicoMemSetupCD(); else PicoMemSetup(); PicoMemReset(); - if (!(PicoMCD & 1)) - PicoCartDetect(); - return PicoReset(1); } -int PicoUnloadCart(unsigned char* romdata) +int PicoCartUnload(void) { - free(romdata); + if (Pico.rom != NULL) { + free(Pico.rom); + Pico.rom=NULL; + } return 0; } @@ -526,7 +545,10 @@ static int name_cmp(const char *name) return rom_strcmp(0x150, name); } -/* various cart-specific things, which can't be handled by generic code */ +/* + * various cart-specific things, which can't be handled by generic code + * (maybe I should start using CRC for this stuff?) + */ void PicoCartDetect(void) { int sram_size = 0, csum; @@ -624,21 +646,38 @@ void PicoCartDetect(void) SRam.eeprom_bit_out= 7; } + // SVP detection + else if (name_cmp("Virtua Racing") == 0 || + name_cmp("VIRTUA RACING") == 0) + { + PicoSVPStartup(); + } + + // Detect 12-in-1 mapper + else if ((name_cmp("ROBOCOP 3") && Pico.romsize == 0x200000) || + (rom_strcmp(0x160, "FLICKY") && Pico.romsize >= 0x200000)) + { + carthw_12in1_startup(); + } + + // Realtec mapper + else if (Pico.romsize == 512*1024 && ( + rom_strcmp(0x94, "THE EARTH DEFEND") || + rom_strcmp(0xfe, "WISEGAME 11-03-1993") || // Funny World + rom_strcmp(0x95, "MALLET LEGEND "))) // Whac-A-Critter + { + carthw_realtec_startup(); + } + // Some games malfunction if SRAM is not filled with 0xff if (name_cmp("DINO DINI'S SOCCER") == 0 || name_cmp("MICRO MACHINES II") == 0) + { memset(SRam.data, 0xff, sram_size); + } // Unusual region 'code' if (rom_strcmp(0x1f0, "EUROPE") == 0) *(int *) (Pico.rom+0x1f0) = 0x20204520; - - // SVP detection - if (name_cmp("Virtua Racing") == 0) - { - PicoSVPInit(); - PicoRead16Hook = PicoSVPRead16; - PicoWrite8Hook = PicoSVPWrite8; - } }