\r
static char *rom_exts[] = { "bin", "gen", "smd", "iso" };\r
\r
+void (*PicoCartUnloadHook)(void) = NULL;\r
+\r
void (*PicoCartLoadProgressCB)(int percent) = NULL;\r
void (*PicoCDLoadProgressCB)(int percent) = NULL; // handled in Pico/cd/cd_file.c\r
\r
static unsigned char *cd_realloc(void *old, int filesize)\r
{\r
unsigned char *rom;\r
- dprintf("sizeof(mcd_state): %i", sizeof(mcd_state));\r
rom=realloc(old, sizeof(mcd_state));\r
if (rom) memset(rom+0x20000, 0, sizeof(mcd_state)-0x20000);\r
return rom;\r
alloc_size&=~0x7ffff; // use alloc size of multiples of 512K, so that memhandlers could be set up more efficiently\r
if((filesize&0x3fff)==0x200) alloc_size+=0x200;\r
else if(alloc_size-filesize < 4) alloc_size+=4; // padding for out-of-bound exec protection\r
- //dprintf("alloc_size: %x\n", alloc_size);\r
\r
// Allocate space for the rom plus padding\r
rom=(unsigned char *)malloc(alloc_size);\r
return 0;\r
}\r
\r
-// Insert/remove a cartridge:\r
+// Insert a cartridge:\r
int PicoCartInsert(unsigned char *rom,unsigned int romsize)\r
{\r
// notaz: add a 68k "jump one op back" opcode to the end of ROM.\r
Pico.rom=rom;\r
Pico.romsize=romsize;\r
\r
+ if (PicoCartUnloadHook != NULL) {\r
+ PicoCartUnloadHook();\r
+ PicoCartUnloadHook = NULL;\r
+ }\r
+\r
+ PicoMemResetHooks();\r
+ PicoDmaHook = NULL;\r
+ PicoResetHook = NULL;\r
+ PicoLineHook = NULL;\r
+ carthw_chunks = NULL;\r
+\r
+ PicoMemReset();\r
+\r
+ if (!(PicoMCD & 1))\r
+ PicoCartDetect();\r
+\r
// setup correct memory map for loaded ROM\r
+ // call PicoMemReset again due to possible memmap change\r
if (PicoMCD & 1)\r
PicoMemSetupCD();\r
else PicoMemSetup();\r
PicoMemReset();\r
\r
- if (!(PicoMCD & 1))\r
- PicoCartDetect();\r
-\r
return PicoReset(1);\r
}\r
\r
-int PicoUnloadCart(unsigned char* romdata)\r
+int PicoCartUnload(void)\r
{\r
- free(romdata);\r
+ if (Pico.rom != NULL) {\r
+ free(Pico.rom);\r
+ Pico.rom=NULL;\r
+ }\r
return 0;\r
}\r
\r
return rom_strcmp(0x150, name);\r
}\r
\r
-/* various cart-specific things, which can't be handled by generic code */\r
+/*\r
+ * various cart-specific things, which can't be handled by generic code\r
+ * (maybe I should start using CRC for this stuff?)\r
+ */\r
void PicoCartDetect(void)\r
{\r
int sram_size = 0, csum;\r
Pico.m.sram_reg |= 4;\r
} else {\r
// normal SRAM\r
- SRam.start = PicoRead32(0x1B4) & 0xFFFF00;\r
+ SRam.start = PicoRead32(0x1B4) & ~0xff;\r
SRam.end = PicoRead32(0x1B8) | 1;\r
sram_size = SRam.end - SRam.start + 1;\r
}\r
+ SRam.start &= ~0xff000000;\r
+ SRam.end &= ~0xff000000;\r
Pico.m.sram_reg |= 0x10; // SRAM was detected\r
}\r
if (sram_size <= 0)\r
SRam.eeprom_bit_out= 7;\r
}\r
\r
+ // SVP detection\r
+ else if (name_cmp("Virtua Racing") == 0 ||\r
+ name_cmp("VIRTUA RACING") == 0)\r
+ {\r
+ PicoSVPStartup();\r
+ }\r
+\r
+ // Detect 12-in-1 mapper\r
+ else if ((name_cmp("ROBOCOP 3") && Pico.romsize == 0x200000) ||\r
+ (rom_strcmp(0x160, "FLICKY") && Pico.romsize >= 0x200000))\r
+ {\r
+ carthw_12in1_startup();\r
+ }\r
+\r
+ // Realtec mapper\r
+ else if (Pico.romsize == 512*1024 && (\r
+ rom_strcmp(0x94, "THE EARTH DEFEND") ||\r
+ rom_strcmp(0xfe, "WISEGAME 11-03-1993") || // Funny World\r
+ rom_strcmp(0x95, "MALLET LEGEND "))) // Whac-A-Critter\r
+ {\r
+ carthw_realtec_startup();\r
+ }\r
+\r
// Some games malfunction if SRAM is not filled with 0xff\r
if (name_cmp("DINO DINI'S SOCCER") == 0 ||\r
name_cmp("MICRO MACHINES II") == 0)\r
+ {\r
memset(SRam.data, 0xff, sram_size);\r
+ }\r
\r
// Unusual region 'code'\r
if (rom_strcmp(0x1f0, "EUROPE") == 0)\r