X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FCart.c;h=a84708865fe108aabbad5d62e99999e82bdfaa6e;hb=1c88b865ceb1e1801bcf20010088fd62cdf2cc06;hp=076247385520d55897ef525d1efdcc32f6767fec;hpb=83bd0b76aba19ff62368cfee76089e15579e3b7c;p=picodrive.git diff --git a/Pico/Cart.c b/Pico/Cart.c index 0762473..a847088 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -1,7 +1,7 @@ // This is part of Pico Library // (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006 notaz, All rights reserved. +// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas // Free for non-commercial use. // For commercial use, separate licencing terms must be obtained. @@ -12,6 +12,7 @@ #include "../unzip/unzip.h" #include "../unzip/unzip_stream.h" + static char *rom_exts[] = { "bin", "gen", "smd", "iso" }; @@ -78,6 +79,9 @@ zip_failed: f = fopen(path, "rb"); if (f == NULL) return NULL; + /* we use our own buffering */ + setvbuf(f, NULL, _IONBF, 0); + file = malloc(sizeof(*file)); if (file == NULL) { fclose(f); @@ -120,10 +124,16 @@ int pm_seek(pm_file *stream, long offset, int whence) { if (stream->type == PMT_UNCOMPRESSED) { - return fseek(stream->file, offset, whence); + fseek(stream->file, offset, whence); + return ftell(stream->file); } else if (stream->type == PMT_ZIP) { + if (PicoMessage != NULL && offset > 6*1024*1024) { + long pos = gztell((gzFile) stream->param); + if (offset < pos || offset - pos > 6*1024*1024) + PicoMessage("Decompressing data..."); + } return gzseek((gzFile) stream->param, offset, whence); } else @@ -243,7 +253,10 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize) // Allocate space for the rom plus padding rom=PicoCartAlloc(size); - if (rom==NULL) return 1; // { fclose(f); return 1; } + if (rom==NULL) { + printf("out of memory (wanted %i)\n", size); + return 1; + } pm_read(rom,size,f); // Load up the rom