diff --git a/source/ngc/cheatmgr.cpp b/source/ngc/cheatmgr.cpp index eb7931d..1ec3e6a 100644 --- a/source/ngc/cheatmgr.cpp +++ b/source/ngc/cheatmgr.cpp @@ -18,7 +18,6 @@ #include "menudraw.h" extern SCheatData Cheat; -extern unsigned char savebuffer[]; /**************************************************************************** * NGCLoadCheatFile diff --git a/source/ngc/dvd.cpp b/source/ngc/dvd.cpp index d0e1373..7180376 100644 --- a/source/ngc/dvd.cpp +++ b/source/ngc/dvd.cpp @@ -17,21 +17,15 @@ #include #ifdef WII_DVD -#ifdef __cplusplus extern "C" { #include } #endif -#endif #include "menudraw.h" #include "snes9xGX.h" #include "unzip.h" -extern int offset; -extern int selection; -extern FILEENTRIES filelist[MAXFILES]; -extern int maxfiles; u64 dvddir = 0; u64 dvdrootdir = 0; int dvddirlength = 0; diff --git a/source/ngc/fileop.cpp b/source/ngc/fileop.cpp index ec78482..1c42c61 100644 --- a/source/ngc/fileop.cpp +++ b/source/ngc/fileop.cpp @@ -29,13 +29,6 @@ FILE * filehandle; -extern unsigned char savebuffer[]; -extern char output[16384]; -extern int offset; -extern int selection; -extern char currentdir[MAXPATHLEN]; -extern FILEENTRIES filelist[MAXFILES]; - /**************************************************************************** * fat_is_mounted * to check whether FAT media are detected. diff --git a/source/ngc/filesel.cpp b/source/ngc/filesel.cpp index eff214e..3198151 100644 --- a/source/ngc/filesel.cpp +++ b/source/ngc/filesel.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef WII_DVD extern "C" { @@ -33,7 +34,6 @@ extern "C" { #include "menudraw.h" #include "video.h" #include "aram.h" -#include "filesel.h" #include "smbop.h" #include "fileop.h" #include "memcardop.h" @@ -55,16 +55,20 @@ int hasloaded = 0; // Global file entry table FILEENTRIES filelist[MAXFILES]; -unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN (32); +unsigned char *savebuffer = NULL; /**************************************************************************** * ClearSaveBuffer () - * Clear the savebuffer + * Allocate and clear the savebuffer ***************************************************************************/ void ClearSaveBuffer () { - memset (savebuffer, 0, SAVEBUFFERSIZE); + if (savebuffer) + free(savebuffer); + + savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE); + memset (savebuffer, 0, SAVEBUFFERSIZE); } /**************************************************************************** diff --git a/source/ngc/filesel.h b/source/ngc/filesel.h index 3502a7e..833edf8 100644 --- a/source/ngc/filesel.h +++ b/source/ngc/filesel.h @@ -3,7 +3,7 @@ * * softdev July 2006 * crunchy2 May 2007 - * Michniewski 2008 + * Michniewski 2008 * Tantric August 2008 * * filesel.h @@ -14,7 +14,9 @@ #ifndef _NGCFILESEL_ #define _NGCFILESEL_ -#define SAVEBUFFERSIZE ((512 * 1024) + 2048 + 64 + 4 + 4) +#include + +#define SAVEBUFFERSIZE (512 * 1024) #define MAXJOLIET 255 #define MAXDISPLAY 54 @@ -29,6 +31,11 @@ typedef struct #define MAXFILES 2000 // Restrict to 2000 files per dir extern FILEENTRIES filelist[MAXFILES]; +extern unsigned char *savebuffer; +extern int offset; +extern int selection; +extern char currentdir[MAXPATHLEN]; +extern int maxfiles; void ClearSaveBuffer (); int OpenROM (int method); diff --git a/source/ngc/freeze.cpp b/source/ngc/freeze.cpp index 7f79ed6..f805c0b 100644 --- a/source/ngc/freeze.cpp +++ b/source/ngc/freeze.cpp @@ -40,7 +40,6 @@ extern void S9xSRTCPreSaveState (); extern void NGCFreezeStruct (); extern bool8 S9xUnfreezeGame (const char *filename); -extern unsigned char savebuffer[]; static int bufoffset; diff --git a/source/ngc/memcardop.cpp b/source/ngc/memcardop.cpp index 167e3d9..db5c622 100644 --- a/source/ngc/memcardop.cpp +++ b/source/ngc/memcardop.cpp @@ -17,18 +17,6 @@ #include #include -#include "snes9x.h" -#include "memmap.h" -#include "debug.h" -#include "cpuexec.h" -#include "ppu.h" -#include "apu.h" -#include "display.h" -#include "gfx.h" -#include "soundux.h" -#include "spc700.h" -#include "spc7110.h" - #include "snes9xGX.h" #include "video.h" #include "menudraw.h" @@ -39,10 +27,10 @@ #include "preferences.h" #include "memcardop.h" #include "fileop.h" +#include "filesel.h" #define VERIFBUFFERSIZE 65536 static u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32); -extern unsigned char savebuffer[]; unsigned char verifbuffer[VERIFBUFFERSIZE] ATTRIBUTE_ALIGN (32); card_dir CardDir; card_file CardFile; diff --git a/source/ngc/preferences.cpp b/source/ngc/preferences.cpp index 680c8a6..b0884ec 100644 --- a/source/ngc/preferences.cpp +++ b/source/ngc/preferences.cpp @@ -26,7 +26,6 @@ #include "smbop.h" #include "filesel.h" -extern unsigned char savebuffer[]; extern int currconfig[4]; // button map configurations @@ -120,7 +119,7 @@ int preparePrefsData (int method) { int offset = 0; - memset (savebuffer, 0, SAVEBUFFERSIZE); + ClearSaveBuffer (); // add save icon and comments for Memory Card saves if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) diff --git a/source/ngc/smbop.cpp b/source/ngc/smbop.cpp index d3876ac..164fd74 100644 --- a/source/ngc/smbop.cpp +++ b/source/ngc/smbop.cpp @@ -35,14 +35,6 @@ unsigned int SMBTimer = 0; SMBCONN smbconn; #define ZIPCHUNK 16384 -extern unsigned char savebuffer[]; -extern char output[16384]; -extern int offset; -extern int selection; -extern char currentdir[MAXPATHLEN]; -extern FILEENTRIES filelist[MAXFILES]; - - /**************************************************************************** * InitializeNetwork * Initializes the Wii/GameCube network interface @@ -281,7 +273,6 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent) WaitPrompt (msg); } - ClearSaveBuffer (); return boffset; } diff --git a/source/ngc/sram.cpp b/source/ngc/sram.cpp index 7883161..06a900d 100644 --- a/source/ngc/sram.cpp +++ b/source/ngc/sram.cpp @@ -27,7 +27,6 @@ #include "smbop.h" #include "filesel.h" -extern unsigned char savebuffer[]; extern int padcal; extern unsigned short gcpadmap[];