mirror of
https://github.com/dborth/fceugx.git
synced 2025-01-05 21:38:17 +01:00
save states work now, other misc bugfixes/improvements
This commit is contained in:
parent
e22f34ec7f
commit
aec5667532
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -66,12 +66,10 @@ bool SaveState (char * filepath, int method, bool silent)
|
||||
FreeSaveBuffer ();
|
||||
}
|
||||
|
||||
std::vector<char> 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)
|
||||
|
@ -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)
|
||||
|
@ -41,7 +41,6 @@ static char szpath[MAXPATHLEN];
|
||||
static bool inSz = false;
|
||||
|
||||
char romFilename[256];
|
||||
int nesGameType;
|
||||
|
||||
/****************************************************************************
|
||||
* autoLoadMethod()
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include <ogcsys.h>
|
||||
|
||||
bool GuiLoaded();
|
||||
void InitGUIThreads();
|
||||
void MainMenu (int menuitem);
|
||||
void ErrorPrompt(const char * msg);
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user