diff options
author | twinaphex | 2014-12-09 15:33:14 +0100 |
---|---|---|
committer | twinaphex | 2014-12-09 15:33:14 +0100 |
commit | 4a2c77bcc9d0b92d21a3ddce4272970c5a2f9a96 (patch) | |
tree | c10f5ccaee2838d93c98ddd1a3d14bade9c3fa91 | |
parent | 988c2e2655c7c1f724ba727f008d84e3faa6cd24 (diff) | |
download | picogpsp-4a2c77bcc9d0b92d21a3ddce4272970c5a2f9a96.tar.gz picogpsp-4a2c77bcc9d0b92d21a3ddce4272970c5a2f9a96.tar.bz2 picogpsp-4a2c77bcc9d0b92d21a3ddce4272970c5a2f9a96.zip |
Remove zip.c/zip.h
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | common.h | 1 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | memory.c | 7 | ||||
-rw-r--r-- | zip.c | 159 | ||||
-rw-r--r-- | zip.h | 26 |
6 files changed, 3 insertions, 195 deletions
@@ -28,7 +28,6 @@ OBJS += cpu_threaded.o OBJS += x86/x86_stub.o OBJS += cheats.o -OBJS += zip.o OBJS += libretro.o OBJS += libco/libco.o @@ -66,7 +65,7 @@ cpu_threaded.o: cpu_threaded.c $(CC) -c -o $@ $< $(ASFLAGS) $(OPTIMIZE) clean: -# rm -f main.o memory.o input.o sound.o x86_stub.o cheats.o zip.o libretro.o +# rm -f main.o memory.o input.o sound.o x86_stub.o cheats.o libretro.o rm -f $(OBJS) rm -f $(TARGET) @@ -230,7 +230,6 @@ typedef u32 fixed8_24; #include "sound.h" #include "main.h" #include "gui.h" -#include "zip.h" #include "cheats.h" #ifdef ARM_ARCH @@ -129,7 +129,7 @@ void trigger_ext_event(); } \ } \ -static const char *file_ext[] = { ".gba", ".bin", ".zip", NULL }; +static const char *file_ext[] = { ".gba", ".bin", NULL }; #ifndef PSP_BUILD static void ChangeWorkingDirectory(char *exe) @@ -2162,14 +2162,9 @@ char gamepak_filename[512]; u32 load_gamepak(const char *name) { - char *dot_position = strrchr(name, '.'); - s32 file_size; char cheats_filename[256]; - if(!strcmp(dot_position, ".zip")) - file_size = load_file_zip(name); - else - file_size = load_gamepak_raw(name); + s32 file_size = load_gamepak_raw(name); // A dumb April fool's joke was here once :o @@ -1,159 +0,0 @@ -/* gameplaySP - * - * Copyright (C) 2006 Exophase <exophase@gmail.com> - * Copyright (C) 2006 SiberianSTAR - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "common.h" -#include <zlib.h> - -#define ZIP_BUFFER_SIZE (128 * 1024) - -struct SZIPFileDataDescriptor -{ - s32 CRC32; - s32 CompressedSize; - s32 UncompressedSize; -} __attribute__((packed)); - -struct SZIPFileHeader -{ - char Sig[4]; // EDIT: Used to be s32 Sig; - s16 VersionToExtract; - s16 GeneralBitFlag; - s16 CompressionMethod; - s16 LastModFileTime; - s16 LastModFileDate; - struct SZIPFileDataDescriptor DataDescriptor; - s16 FilenameLength; - s16 ExtraFieldLength; -} __attribute__((packed)); - -u32 load_file_zip(const char *filename) -{ - struct SZIPFileHeader data; - char tmp[1024]; - s32 retval = -1; - u8 *buffer = NULL; - u8 *cbuffer; - char *ext; - int ret; - - file_open(fd, filename, read); - - if(!file_check_valid(fd)) - return -1; - - while (1) - { - ret = file_read(fd, &data, sizeof(data)); - if (ret != sizeof(data)) - break; - - // It checks for the following: 0x50 0x4B 0x03 0x04 (PK..) - if( data.Sig[0] != 0x50 || data.Sig[1] != 0x4B || - data.Sig[2] != 0x03 || data.Sig[3] != 0x04 ) - { - break; - } - - ret = file_read(fd, tmp, data.FilenameLength); - if (ret != data.FilenameLength) - break; - - tmp[data.FilenameLength] = 0; // end string - - if(data.ExtraFieldLength) - file_seek(fd, data.ExtraFieldLength, SEEK_CUR); - - if(data.GeneralBitFlag & 0x0008) - { - file_read(fd, &data.DataDescriptor, - sizeof(struct SZIPFileDataDescriptor)); - } - - ext = strrchr(tmp, '.') + 1; - - // file is too big - if(data.DataDescriptor.UncompressedSize > gamepak_ram_buffer_size) - goto skip; - - if(!strcasecmp(ext, "bin") || !strcasecmp(ext, "gba")) - { - buffer = gamepak_rom; - - // ok, found - switch(data.CompressionMethod) - { - case 0: - retval = data.DataDescriptor.UncompressedSize; - file_read(fd, buffer, retval); - goto outcode; - - case 8: - { - z_stream stream; - s32 err; - - cbuffer = malloc(ZIP_BUFFER_SIZE); - - stream.next_in = (Bytef*)cbuffer; - stream.avail_in = (u32)ZIP_BUFFER_SIZE; - - stream.next_out = (Bytef*)buffer; - - // EDIT: Now uses proper conversion of data types for retval. - retval = (u32)data.DataDescriptor.UncompressedSize; - stream.avail_out = data.DataDescriptor.UncompressedSize; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - err = inflateInit2(&stream, -MAX_WBITS); - - file_read(fd, cbuffer, ZIP_BUFFER_SIZE); - - if(err == Z_OK) - { - while(err != Z_STREAM_END) - { - err = inflate(&stream, Z_SYNC_FLUSH); - if(err == Z_BUF_ERROR) - { - stream.avail_in = ZIP_BUFFER_SIZE; - stream.next_in = (Bytef*)cbuffer; - file_read(fd, cbuffer, ZIP_BUFFER_SIZE); - } - } - err = Z_OK; - inflateEnd(&stream); - } - free(cbuffer); - goto outcode; - } - } - } - -skip: - file_seek(fd, data.DataDescriptor.CompressedSize, SEEK_CUR); - } - -outcode: - file_close(fd); - - return retval; -} @@ -1,26 +0,0 @@ -/* gameplaySP - * - * Copyright (C) 2006 Exophase <exophase@gmail.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef ZIP_H -#define ZIP_H - -u32 load_file_zip(const char *filename); - -#endif - |