diff --git a/source/fceultra/state.cpp b/source/fceultra/state.cpp index fc6c989..9cc3705 100644 --- a/source/fceultra/state.cpp +++ b/source/fceultra/state.cpp @@ -341,7 +341,11 @@ bool FCEUSS_SaveMS(std::ostream* outstream, int compressionLevel) //a temp memory stream. we'll dump some data here and then compress //TODO - support dumping directly without compressing to save a buffer copy +#ifdef GEKKO + memorystream ms(512*1024); // set aside some space, otherwise expand fails on Wii! +#else memorystream ms; +#endif std::ostream* os = (std::ostream*)&ms; uint32 totalsize = 0; @@ -386,7 +390,11 @@ bool FCEUSS_SaveMS(std::ostream* outstream, int compressionLevel) if(SPreSave) SPostSave(); //save the length of the file +#ifdef GEKKO + int len = ms.tellp(); +#else int len = ms.size(); +#endif //sanity check: len and totalsize should be the same if(len != totalsize) diff --git a/source/ngc/fceuload.cpp b/source/ngc/fceuload.cpp index 062a7e0..dcbd8b2 100644 --- a/source/ngc/fceuload.cpp +++ b/source/ngc/fceuload.cpp @@ -62,14 +62,14 @@ int GCMemROM(int method, int size) fceufp->stream = fceumem; fceufp->filename = romFilename; - nesGameType = 0; + romLoaded = false; if (iNESLoad(romFilename, fceufp, 1)) - nesGameType = 1; + romLoaded = true; else if (UNIFLoad(romFilename, fceufp)) - nesGameType = 2; + romLoaded = true; else if (NSFLoad(fceufp)) - nesGameType = 3; + romLoaded = true; else { // read FDS BIOS into FDSBIOS - should be 8192 bytes @@ -93,39 +93,38 @@ int GCMemROM(int method, int size) { if (biosSize > 0) ErrorPrompt("FDS BIOS file is invalid!"); - + else + ErrorPrompt("FDS BIOS file not found!"); return 0; // BIOS not loaded, do not load game } free(tmpbuffer); } // load game - if (FDSLoad(NULL, fceufp)) - nesGameType = 4; + if (FDSLoad(romFilename, fceufp)) + romLoaded = true; } - //delete fceufp; - //delete fceumem; + delete fceufp; - if (nesGameType > 0) + if (romLoaded) { FCEU_ResetVidSys(); - if(GameInfo->type!=GIT_NSF) - if(FSettings.GameGenie) - OpenGenie(); + //if(GameInfo->type!=GIT_NSF) + // if(FSettings.GameGenie) + // OpenGenie(); PowerNES(); - if(GameInfo->type!=GIT_NSF) - FCEU_LoadGamePalette(); + //if(GameInfo->type!=GIT_NSF) + // FCEU_LoadGamePalette(); FCEU_ResetPalette(); FCEU_ResetMessages(); // Save state, status messages, etc. - if(GameInfo->type!=GIT_NSF) - FCEU_LoadGameCheats(0); + //if(GameInfo->type!=GIT_NSF) + // FCEU_LoadGameCheats(0); ResetAudio(); - romLoaded = true; return 1; } else diff --git a/source/ngc/fceuram.cpp b/source/ngc/fceuram.cpp index 770107f..cff43ad 100644 --- a/source/ngc/fceuram.cpp +++ b/source/ngc/fceuram.cpp @@ -56,7 +56,7 @@ bool SaveRAM (char * filepath, int method, bool silent) int datasize = 0; int offset = 0; - if(nesGameType == 4) + if(GameInfo->type == GIT_FDS) { if(!silent) InfoPrompt("RAM saving is not available for FDS games!"); @@ -72,9 +72,9 @@ bool SaveRAM (char * filepath, int method, bool silent) AllocSaveBuffer (); // save game save to savebuffer - if(nesGameType == 1) + if(GameInfo->type == GIT_CART) datasize = NGCFCEU_GameSave(&iNESCart, 0, method); - else if(nesGameType == 2) + else if(GameInfo->type == GIT_VSUNI) datasize = NGCFCEU_GameSave(&UNIFCart, 0, method); if (datasize) @@ -129,7 +129,7 @@ bool LoadRAM (char * filepath, int method, bool silent) int offset = 0; bool retval = false; - if(nesGameType == 4) // RAM saves don't exist for FDS games + if(GameInfo->type == GIT_FDS) // RAM saves don't exist for FDS games return false; if(method == METHOD_AUTO) @@ -144,9 +144,9 @@ bool LoadRAM (char * filepath, int method, bool silent) if (offset > 0) { - if(nesGameType == 1) + if(GameInfo->type == GIT_CART) NGCFCEU_GameSave(&iNESCart, 1, method); - else if(nesGameType == 2) + else if(GameInfo->type == GIT_VSUNI) NGCFCEU_GameSave(&UNIFCart, 1, method); ResetNES(); diff --git a/source/ngc/fceustate.cpp b/source/ngc/fceustate.cpp index 76a61ba..f1f9f6f 100644 --- a/source/ngc/fceustate.cpp +++ b/source/ngc/fceustate.cpp @@ -66,12 +66,10 @@ bool SaveState (char * filepath, int method, bool silent) FreeSaveBuffer (); } - std::vector tmpbuffer(SAVEBUFFERSIZE); - memorystream save(&tmpbuffer); - FCEUSS_SaveMS(&save, Z_NO_COMPRESSION); + memorystream save(SAVEBUFFERSIZE); + FCEUSS_SaveMS(&save, Z_BEST_COMPRESSION); save.sync(); - save.trim(); - datasize = save.size(); + datasize = save.tellp(); if (datasize) { @@ -84,11 +82,7 @@ bool SaveState (char * filepath, int method, bool silent) snprintf (comments[1], 32, romFilename); SetMCSaveComments(comments); } - - AllocSaveBuffer (); - memcpy(savebuffer, save.buf(), datasize); - offset = SaveFile(filepath, datasize, method, silent); - FreeSaveBuffer (); + offset = SaveFile(save.buf(), filepath, datasize, method, silent); } if (offset > 0) diff --git a/source/ngc/fceusupport.cpp b/source/ngc/fceusupport.cpp index a852e1d..b7faf18 100644 --- a/source/ngc/fceusupport.cpp +++ b/source/ngc/fceusupport.cpp @@ -6,8 +6,7 @@ #include "gcaudio.h" #include "gcvideo.h" #include "fceugx.h" - -extern int gametype; +#include "menu.h" /** * Closes a game. Frees memory, and deinitializes the drivers. @@ -36,20 +35,14 @@ std::fstream* FCEUD_UTF8_fstream(const char *fn, const char *m) bool FCEUD_ShouldDrawInputAids() { - return false; + return GCSettings.crosshair; } // General Logging -void FCEUD_PrintError(char *s) -{ -} - void FCEUD_PrintError(const char *errormsg) { -} - -void FCEUD_Message(char *text) -{ + if(GuiLoaded()) + ErrorPrompt(errormsg); } void FCEUD_Message(const char *text) diff --git a/source/ngc/filebrowser.cpp b/source/ngc/filebrowser.cpp index 96911db..32ef749 100644 --- a/source/ngc/filebrowser.cpp +++ b/source/ngc/filebrowser.cpp @@ -41,7 +41,6 @@ static char szpath[MAXPATHLEN]; static bool inSz = false; char romFilename[256]; -int nesGameType; /**************************************************************************** * autoLoadMethod() diff --git a/source/ngc/filebrowser.h b/source/ngc/filebrowser.h index 83e091f..ca0f612 100644 --- a/source/ngc/filebrowser.h +++ b/source/ngc/filebrowser.h @@ -39,7 +39,6 @@ extern BROWSERENTRY * browserList; extern char rootdir[10]; extern char romFilename[]; -extern int nesGameType; bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -2); int UpdateDirName(int method); diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index 566e252..64a2f74 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -74,6 +74,14 @@ static char progressMsg[200]; static int progressDone = 0; static int progressTotal = 0; +bool GuiLoaded() +{ + if(mainWindow) + return true; + else + return false; +} + /**************************************************************************** * ResumeGui * diff --git a/source/ngc/menu.h b/source/ngc/menu.h index 82f8fa1..02dab68 100644 --- a/source/ngc/menu.h +++ b/source/ngc/menu.h @@ -14,6 +14,7 @@ #include +bool GuiLoaded(); void InitGUIThreads(); void MainMenu (int menuitem); void ErrorPrompt(const char * msg); diff --git a/source/ngc/pad.cpp b/source/ngc/pad.cpp index d3dab67..ae4d355 100644 --- a/source/ngc/pad.cpp +++ b/source/ngc/pad.cpp @@ -173,7 +173,7 @@ void SetControllers() if(GCSettings.Controller == CTRL_ZAPPER) { int p; - if(nesGameType == 2) p = 0; + if(GameInfo->type == GIT_VSUNI) p = 0; else p = 1; zapperdata[p] = FCEU_InitZapper(p); FCEUI_SetInput(p, SI_ZAPPER, myzappers[p], 1); @@ -532,7 +532,7 @@ static unsigned char DecodeJoy( unsigned short pad ) } else { - if(nesGameType == 4) // FDS + if(GameInfo->type == GIT_FDS) // FDS { /* the commands shouldn't be issued in parallel so * we'll delay them so the virtual FDS has a chance @@ -565,7 +565,12 @@ static unsigned char DecodeJoy( unsigned short pad ) // zapper enabled if(GCSettings.Controller == CTRL_ZAPPER) { - int z = 1; // NES port # (0 or 1) + int z; // NES port # (0 or 1) + + if(GameInfo->type == GIT_VSUNI) + z = 0; + else + z = 1; myzappers[z][2] = 0; // reset trigger to not pressed