From 0a75c99bb645a2ea5ceeab2754f88f28259316c8 Mon Sep 17 00:00:00 2001 From: Lucas Menge Date: Wed, 15 Feb 2012 18:14:34 -0300 Subject: [PATCH] Using vanilla SNES9X code (except 4 lines added to port.h --- Classes/LMAppDelegate.m | 1 + Classes/Prefix.pch | 23 +++++++++++++++++------ SNES9X/apu/apu.cpp | 8 ++++---- SNES9X/apu/apu.h | 2 +- SNES9X/apu/linear_resampler.h | 2 +- SNES9X/spc7110dec.cpp | 2 +- SNES9X/unzip/miniunz.c | 2 +- SNES9X/unzip/minizip.c | 2 +- SNES9X/unzip/unzip.c | 2 +- SNES9X/unzip/zip.c | 4 ++-- 10 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Classes/LMAppDelegate.m b/Classes/LMAppDelegate.m index 4d4a65e..2485b34 100644 --- a/Classes/LMAppDelegate.m +++ b/Classes/LMAppDelegate.m @@ -10,6 +10,7 @@ #import "LMROMBrowserController.h" +// TODO: LM: Crash when deleting the last file in a "Section" in LMROMBrowserController // TODO: LM: Open SMC, SFC, FIG, ZIP files from other iOS apps // TODO: LM: License diff --git a/Classes/Prefix.pch b/Classes/Prefix.pch index 3de15b1..04989ab 100644 --- a/Classes/Prefix.pch +++ b/Classes/Prefix.pch @@ -20,19 +20,30 @@ #define __IPHONE__ #define ZLIB #define UNZIP_SUPPORT -#define LSB_FIRST - -// "fixing" port.h so we don't have to modify the original SNES9X source -#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__x86_64__) || defined(__alpha__) || defined(__MIPSEL__) || defined(_M_IX86) || defined(_M_X64) -#undef LSB_FIRST -#endif +#define LSB_FIRST +// "Fixing" SNES9X Source when updated +// =================================== // IMPORTANT: if you crash on S9xFixColour* when porting updated SNES9X sources, modify port.h to have these, after "#define GFX_MULTI_FORMAT" #ifdef __IPHONE__ #undef GFX_MULTI_FORMAT #define PIXEL_FORMAT RGB555 #endif +// IMPORTANT: there was another fix that was applied some time ago, but it seems not to matter now. In apu.cpp, replace: +// - if (shrink_buffer_size < (sample_count << 1)) +// with +// + if (shrink_buffer_size < (sample_count << 1) || spc::shrink_buff + + +// "fixing" port.h so we don't have to further modify the original SNES9X source +#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__x86_64__) || defined(__alpha__) || defined(__MIPSEL__) || defined(_M_IX86) || defined(_M_X64) +#undef LSB_FIRST +#endif + +// "fixing" uint8_t error in spc7110dec.cpp +#import + // "Fixing" unzip // ============== diff --git a/SNES9X/apu/apu.cpp b/SNES9X/apu/apu.cpp index 265e058..f6e2445 100644 --- a/SNES9X/apu/apu.cpp +++ b/SNES9X/apu/apu.cpp @@ -177,10 +177,10 @@ #include -#include "../snes9x.h" +#include "snes9x.h" #include "apu.h" -#include "../snapshot.h" -#include "../display.h" +#include "snapshot.h" +#include "display.h" #include "linear_resampler.h" #include "hermite_resampler.h" @@ -292,7 +292,7 @@ bool8 S9xMixSamples (uint8 *buffer, int sample_count) sample_count <<= 1; /* We still have to generate 16-bit samples for bit-dropping, too */ - if (shrink_buffer_size < (sample_count << 1) || spc::shrink_buffer == NULL) + if (shrink_buffer_size < (sample_count << 1)) { delete[] spc::shrink_buffer; spc::shrink_buffer = new uint8[sample_count << 1]; diff --git a/SNES9X/apu/apu.h b/SNES9X/apu/apu.h index 2d32290..358469d 100644 --- a/SNES9X/apu/apu.h +++ b/SNES9X/apu/apu.h @@ -179,7 +179,7 @@ #ifndef _APU_H_ #define _APU_H_ -#include "../snes9x.h" +#include "snes9x.h" #include "SNES_SPC.h" typedef void (*apu_callback) (void *); diff --git a/SNES9X/apu/linear_resampler.h b/SNES9X/apu/linear_resampler.h index 9d3a13c..35789db 100644 --- a/SNES9X/apu/linear_resampler.h +++ b/SNES9X/apu/linear_resampler.h @@ -4,7 +4,7 @@ #define __LINEAR_RESAMPLER_H #include "resampler.h" -#include "../snes9x.h" +#include "snes9x.h" static const int f_prec = 15; static const uint32 f__one = (1 << f_prec); diff --git a/SNES9X/spc7110dec.cpp b/SNES9X/spc7110dec.cpp index 743562b..65d5586 100644 --- a/SNES9X/spc7110dec.cpp +++ b/SNES9X/spc7110dec.cpp @@ -498,7 +498,7 @@ void SPC7110Decomp::reset() { } SPC7110Decomp::SPC7110Decomp() { - decomp_buffer = new uint8[decomp_buffer_size]; + decomp_buffer = new uint8_t[decomp_buffer_size]; reset(); //initialize reverse morton lookup tables diff --git a/SNES9X/unzip/miniunz.c b/SNES9X/unzip/miniunz.c index 01197fd..b5bc8b5 100644 --- a/SNES9X/unzip/miniunz.c +++ b/SNES9X/unzip/miniunz.c @@ -13,7 +13,7 @@ #include #include -#if defined(unix) || defined(__IPHONE__) +#ifdef unix # include # include #else diff --git a/SNES9X/unzip/minizip.c b/SNES9X/unzip/minizip.c index 2698ba8..25f8389 100644 --- a/SNES9X/unzip/minizip.c +++ b/SNES9X/unzip/minizip.c @@ -16,7 +16,7 @@ #include #include -#if defined(unix) || defined(__IPHONE__) +#ifdef unix # include # include # include diff --git a/SNES9X/unzip/unzip.c b/SNES9X/unzip/unzip.c index ce366d0..17d730d 100644 --- a/SNES9X/unzip/unzip.c +++ b/SNES9X/unzip/unzip.c @@ -1291,7 +1291,7 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) return UNZ_PARAMERROR; - if (pfile_in_zip_read_info->read_buffer == NULL) + if ((pfile_in_zip_read_info->read_buffer == NULL)) return UNZ_END_OF_LIST_OF_FILE; if (len==0) return 0; diff --git a/SNES9X/unzip/zip.c b/SNES9X/unzip/zip.c index a3f352a..1451d61 100644 --- a/SNES9X/unzip/zip.c +++ b/SNES9X/unzip/zip.c @@ -765,9 +765,9 @@ extern int ZEXPORT zipOpenNewFileInZip4 (file, filename, zipfi, zi->ci.flag = flagBase; if ((level==8) || (level==9)) zi->ci.flag |= 2; - if (level==2) + if ((level==2)) zi->ci.flag |= 4; - if (level==1) + if ((level==1)) zi->ci.flag |= 6; if (password != NULL) zi->ci.flag |= 1;