SekRunPS Cyclone integration
[picodrive.git] / Pico / Cart.c
index 0762473..a865033 100644 (file)
@@ -12,6 +12,7 @@
 #include "../unzip/unzip.h"\r
 #include "../unzip/unzip_stream.h"\r
 \r
+\r
 static char *rom_exts[] = { "bin", "gen", "smd", "iso" };\r
 \r
 \r
@@ -78,6 +79,9 @@ zip_failed:
   f = fopen(path, "rb");\r
   if (f == NULL) return NULL;\r
 \r
+  /* we use our own buffering */\r
+  setvbuf(f, NULL, _IONBF, 0);\r
+\r
   file = malloc(sizeof(*file));\r
   if (file == NULL) {\r
     fclose(f);\r
@@ -120,7 +124,8 @@ int pm_seek(pm_file *stream, long offset, int whence)
 {\r
   if (stream->type == PMT_UNCOMPRESSED)\r
   {\r
-    return fseek(stream->file, offset, whence);\r
+    fseek(stream->file, offset, whence);\r
+    return ftell(stream->file);\r
   }\r
   else if (stream->type == PMT_ZIP)\r
   {\r
@@ -243,7 +248,10 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize)
 \r
   // Allocate space for the rom plus padding\r
   rom=PicoCartAlloc(size);\r
-  if (rom==NULL) return 1; // { fclose(f); return 1; }\r
+  if (rom==NULL) {\r
+    printf("out of memory (wanted %i)\n", size);\r
+    return 1;\r
+  }\r
 \r
   pm_read(rom,size,f); // Load up the rom\r
 \r