\r
/* checks if romFileName points to valid MegaCD image\r
* if so, checks for suitable BIOS */\r
-static int cd_check(char *ext, char **bios_file)\r
+static int cd_check(char **bios_file)\r
{\r
unsigned char buf[32];\r
- FILE *cd_f;\r
+ pm_file *cd_f;\r
int type = 0, region = 4; // 1: Japan, 4: US, 8: Europe\r
\r
- cd_f = fopen(romFileName, "rb");\r
+ cd_f = pm_open(romFileName);\r
if (!cd_f) return 0; // let the upper level handle this\r
\r
- if (fread(buf, 1, 32, cd_f) != 32) {\r
- fclose(cd_f);\r
+ if (pm_read(buf, 32, cd_f) != 32) {\r
+ pm_close(cd_f);\r
return 0;\r
}\r
\r
if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x00, 14)) type = 1; // Sega CD (ISO)\r
if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x10, 14)) type = 2; // Sega CD (BIN)\r
if (type == 0) {\r
- fclose(cd_f);\r
+ pm_close(cd_f);\r
return 0;\r
}\r
\r
/* it seems we have a CD image here. Try to detect region and load a suitable BIOS now.. */\r
- fseek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET);\r
- fread(buf, 1, 1, cd_f);\r
- fclose(cd_f);\r
+ pm_seek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET);\r
+ pm_read(buf, 1, cd_f);\r
+ pm_close(cd_f);\r
\r
if (buf[0] == 0x64) region = 8; // EU\r
if (buf[0] == 0xa1) region = 1; // JAP\r
unsigned int rom_size = 0;\r
char *used_rom_name = romFileName;\r
char ext[5];\r
- FILE *rom;\r
+ pm_file *rom;\r
int ret, cd_state;\r
\r
printf("emu_ReloadRom(%s)\n", romFileName);\r
}\r
\r
// check for MegaCD image\r
- cd_state = cd_check(ext, &used_rom_name);\r
+ cd_state = cd_check(&used_rom_name);\r
if (cd_state > 0) {\r
PicoMCD |= 1;\r
get_ext(used_rom_name, ext);\r
PicoMCD &= ~1;\r
}\r
\r
- rom = fopen(used_rom_name, "rb");\r
+ rom = pm_open(used_rom_name);\r
if(!rom) {\r
sprintf(menuErrorMsg, "Failed to open rom.");\r
return 0;\r
rom_size = 0;\r
}\r
\r
- // zipfile support\r
- if(!strcasecmp(ext, ".zip")) {\r
- fclose(rom);\r
- ret = CartLoadZip(used_rom_name, &rom_data, &rom_size);\r
- if(ret) {\r
- if (ret == 4) strcpy(menuErrorMsg, "No ROMs found in zip.");\r
- else sprintf(menuErrorMsg, "Unzip failed with code %i", ret);\r
- printf("%s\n", menuErrorMsg);\r
- return 0;\r
- }\r
- } else {\r
- if( (ret = PicoCartLoad(rom, &rom_data, &rom_size)) ) {\r
- sprintf(menuErrorMsg, "PicoCartLoad() failed.");\r
- printf("%s\n", menuErrorMsg);\r
- fclose(rom);\r
- return 0;\r
- }\r
- fclose(rom);\r
+ if( (ret = PicoCartLoad(rom, &rom_data, &rom_size)) ) {\r
+ sprintf(menuErrorMsg, "PicoCartLoad() failed.");\r
+ printf("%s\n", menuErrorMsg);\r
+ pm_close(rom);\r
+ return 0;\r
}\r
+ pm_close(rom);\r
\r
// detect wrong files (Pico crashes on very small files), also see if ROM EP is good\r
if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 ||\r