From: notaz Date: Sat, 10 Mar 2007 23:50:03 +0000 (+0000) Subject: support for zipped ISOs X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af6e9c49619b918da965e82e5ecb525d98aee862;p=libpicofe.git support for zipped ISOs git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@65 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/gp2x/Makefile b/gp2x/Makefile index a3c6961..081715a 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -68,7 +68,7 @@ OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2 OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \ ../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o # unzip -OBJS += ../../unzip/unzip.o +OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o # mp3 OBJS += mp3.o # CPU cores diff --git a/gp2x/emu.c b/gp2x/emu.c index c8c4f8a..3d6cd3a 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -169,31 +169,31 @@ int find_bios(int region, char **bios_file) /* checks if romFileName points to valid MegaCD image * if so, checks for suitable BIOS */ -static int cd_check(char *ext, char **bios_file) +static int cd_check(char **bios_file) { unsigned char buf[32]; - FILE *cd_f; + pm_file *cd_f; int type = 0, region = 4; // 1: Japan, 4: US, 8: Europe - cd_f = fopen(romFileName, "rb"); + cd_f = pm_open(romFileName); if (!cd_f) return 0; // let the upper level handle this - if (fread(buf, 1, 32, cd_f) != 32) { - fclose(cd_f); + if (pm_read(buf, 32, cd_f) != 32) { + pm_close(cd_f); return 0; } if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x00, 14)) type = 1; // Sega CD (ISO) if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x10, 14)) type = 2; // Sega CD (BIN) if (type == 0) { - fclose(cd_f); + pm_close(cd_f); return 0; } /* it seems we have a CD image here. Try to detect region and load a suitable BIOS now.. */ - fseek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET); - fread(buf, 1, 1, cd_f); - fclose(cd_f); + pm_seek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET); + pm_read(buf, 1, cd_f); + pm_close(cd_f); if (buf[0] == 0x64) region = 8; // EU if (buf[0] == 0xa1) region = 1; // JAP @@ -217,7 +217,7 @@ int emu_ReloadRom(void) unsigned int rom_size = 0; char *used_rom_name = romFileName; char ext[5]; - FILE *rom; + pm_file *rom; int ret, cd_state; printf("emu_ReloadRom(%s)\n", romFileName); @@ -284,7 +284,7 @@ int emu_ReloadRom(void) } // check for MegaCD image - cd_state = cd_check(ext, &used_rom_name); + cd_state = cd_check(&used_rom_name); if (cd_state > 0) { PicoMCD |= 1; get_ext(used_rom_name, ext); @@ -296,7 +296,7 @@ int emu_ReloadRom(void) PicoMCD &= ~1; } - rom = fopen(used_rom_name, "rb"); + rom = pm_open(used_rom_name); if(!rom) { sprintf(menuErrorMsg, "Failed to open rom."); return 0; @@ -308,25 +308,13 @@ int emu_ReloadRom(void) rom_size = 0; } - // zipfile support - if(!strcasecmp(ext, ".zip")) { - fclose(rom); - ret = CartLoadZip(used_rom_name, &rom_data, &rom_size); - if(ret) { - if (ret == 4) strcpy(menuErrorMsg, "No ROMs found in zip."); - else sprintf(menuErrorMsg, "Unzip failed with code %i", ret); - printf("%s\n", menuErrorMsg); - return 0; - } - } else { - if( (ret = PicoCartLoad(rom, &rom_data, &rom_size)) ) { - sprintf(menuErrorMsg, "PicoCartLoad() failed."); - printf("%s\n", menuErrorMsg); - fclose(rom); - return 0; - } - fclose(rom); + if( (ret = PicoCartLoad(rom, &rom_data, &rom_size)) ) { + sprintf(menuErrorMsg, "PicoCartLoad() failed."); + printf("%s\n", menuErrorMsg); + pm_close(rom); + return 0; } + pm_close(rom); // detect wrong files (Pico crashes on very small files), also see if ROM EP is good if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 || diff --git a/gp2x/menu.c b/gp2x/menu.c index 032616a..40eee48 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -407,7 +407,7 @@ static void draw_patchlist(int sel) if (pos < 0) continue; if (pos > 23) break; gp2x_smalltext8_lim(14, pos*10, PicoPatches[i].active ? "ON " : "OFF", 3); - gp2x_smalltext8_lim(14+6*4, pos*10, PicoPatches[i].name, 53-5); + gp2x_smalltext8_lim(14+6*4, pos*10, PicoPatches[i].name, 53-6); } pos = start + i; if (pos < 24) gp2x_smalltext8_lim(14, pos*10, "done", 4); diff --git a/linux/Makefile b/linux/Makefile index fc5ff06..cd18159 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -39,7 +39,7 @@ OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2 OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \ ../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o # unzip -OBJS += ../../unzip/unzip.o +OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o # mp3 OBJS += ../gp2x/mp3.o # CPU cores diff --git a/linux/gp2x.c b/linux/gp2x.c index e4e3421..cc4db98 100644 --- a/linux/gp2x.c +++ b/linux/gp2x.c @@ -164,6 +164,7 @@ void gp2x_init(void) printf("entering init()\n"); fflush(stdout); gp2x_screen = malloc(320*240*2 + 320*2); + memset(gp2x_screen, 0, 320*240*2 + 320*2); // snd mixerdev = open("/dev/mixer", O_RDWR);