X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FCart.c;h=07ced8c5514b917e1196a31e8d7c2e85d9631474;hb=48e8482fc2d74c9b96e581241390bade986acb22;hp=076247385520d55897ef525d1efdcc32f6767fec;hpb=83bd0b76aba19ff62368cfee76089e15579e3b7c;p=picodrive.git diff --git a/Pico/Cart.c b/Pico/Cart.c index 0762473..07ced8c 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -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