use system's zlib
[picodrive.git] / pico / cart.c
index 3bab615..9dce38d 100644 (file)
@@ -8,10 +8,9 @@
  */\r
 \r
 #include "pico_int.h"\r
-#include "../zlib/zlib.h"\r
 #include "../cpu/debug.h"\r
 #include "../unzip/unzip.h"\r
-#include "../unzip/unzip_stream.h"\r
+#include <zlib.h>\r
 \r
 \r
 static int rom_alloc_size;\r
@@ -50,7 +49,7 @@ typedef struct _cso_struct
 }\r
 cso_struct;\r
 \r
-static int uncompress2(void *dest, int destLen, void *source, int sourceLen)\r
+static int uncompress_buf(void *dest, int destLen, void *source, int sourceLen)\r
 {\r
     z_stream stream;\r
     int err;\r
@@ -298,7 +297,7 @@ size_t pm_read(void *ptr, size_t bytes, pm_file *stream)
           }\r
           cso->block_in_buff = block;\r
         }\r
-        rret = uncompress2(tmp_dst, 2048, cso->in_buff, read_len);\r
+        rret = uncompress_buf(tmp_dst, 2048, cso->in_buff, read_len);\r
         if (rret != 0) {\r
           elprintf(EL_STATUS, "cso: uncompress failed @ %08x with %i", read_pos, rret);\r
           break;\r
@@ -332,9 +331,7 @@ int pm_seek(pm_file *stream, long offset, int whence)
   if (stream->type == PMT_UNCOMPRESSED)\r
   {\r
     fseek(stream->file, offset, whence);\r
-    int ret = ftell(stream->file);\r
-    elprintf(EL_STATUS, "seeked ok."); //HACK for VITA\r
-    return ret;\r
+    return ftell(stream->file);\r
   }\r
 #ifndef NO_ZLIB\r
   else if (stream->type == PMT_ZIP)\r
@@ -515,7 +512,7 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms)
     bytes_read = pm_read(rom,size,f); // Load up the rom\r
   if (bytes_read <= 0) {\r
     elprintf(EL_STATUS, "read failed");\r
-    free(rom);\r
+    plat_munmap(rom, rom_alloc_size);\r
     return 3;\r
   }\r
 \r