SF [ 2046985 ] SRAM not wiped on power cycle (during movies)
This commit is contained in:
parent
595df73847
commit
3e983865df
|
@ -1,5 +1,6 @@
|
||||||
---version 2.0.2 released---
|
---version 2.0.2 released---
|
||||||
|
|
||||||
|
11-aug-2008 - zeromus - SF [ 2046985 ] SRAM not wiped on power cycle (during movies)
|
||||||
11-aug-2008 - zeromus - restore IPS patching capability which was lost when archive support was added
|
11-aug-2008 - zeromus - restore IPS patching capability which was lost when archive support was added
|
||||||
11-aug-2008 - zeromus - SF [ 2011550 ] Buffer overflow (change vsprintf to vsnprintf)
|
11-aug-2008 - zeromus - SF [ 2011550 ] Buffer overflow (change vsprintf to vsnprintf)
|
||||||
11-aug-2008 - zeromus - SF [ 2047004 ] Moviefilenames without extension don't automatically get fm2
|
11-aug-2008 - zeromus - SF [ 2047004 ] Moviefilenames without extension don't automatically get fm2
|
||||||
|
|
27
src/cart.cpp
27
src/cart.cpp
|
@ -636,25 +636,21 @@ void FCEU_SaveGameSave(CartInfo *LocalHWInfo)
|
||||||
if(LocalHWInfo->battery && LocalHWInfo->SaveGame[0])
|
if(LocalHWInfo->battery && LocalHWInfo->SaveGame[0])
|
||||||
{
|
{
|
||||||
FILE *sp;
|
FILE *sp;
|
||||||
char *soot;
|
|
||||||
|
|
||||||
soot=strdup(FCEU_MakeFName(FCEUMKF_SAV,0,"sav").c_str());
|
std::string soot = FCEU_MakeFName(FCEUMKF_SAV,0,"sav");
|
||||||
if((sp=FCEUD_UTF8fopen(soot,"wb"))==NULL)
|
if((sp=FCEUD_UTF8fopen(soot,"wb"))==NULL)
|
||||||
{
|
{
|
||||||
FCEU_PrintError("WRAM file \"%s\" cannot be written to.\n",soot);
|
FCEU_PrintError("WRAM file \"%s\" cannot be written to.\n",soot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int x;
|
for(int x=0;x<4;x++)
|
||||||
|
|
||||||
for(x=0;x<4;x++)
|
|
||||||
if(LocalHWInfo->SaveGame[x])
|
if(LocalHWInfo->SaveGame[x])
|
||||||
{
|
{
|
||||||
fwrite(LocalHWInfo->SaveGame[x],1,
|
fwrite(LocalHWInfo->SaveGame[x],1,
|
||||||
LocalHWInfo->SaveGameLen[x],sp);
|
LocalHWInfo->SaveGameLen[x],sp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(soot);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,19 +662,26 @@ void FCEU_LoadGameSave(CartInfo *LocalHWInfo)
|
||||||
if(LocalHWInfo->battery && LocalHWInfo->SaveGame[0] && !disableBatteryLoading)
|
if(LocalHWInfo->battery && LocalHWInfo->SaveGame[0] && !disableBatteryLoading)
|
||||||
{
|
{
|
||||||
FILE *sp;
|
FILE *sp;
|
||||||
char *soot;
|
|
||||||
|
|
||||||
soot=strdup(FCEU_MakeFName(FCEUMKF_SAV,0,"sav").c_str());
|
std::string soot = FCEU_MakeFName(FCEUMKF_SAV,0,"sav");
|
||||||
sp=FCEUD_UTF8fopen(soot,"rb");
|
sp=FCEUD_UTF8fopen(soot,"rb");
|
||||||
if(sp!=NULL)
|
if(sp!=NULL)
|
||||||
{
|
{
|
||||||
int x;
|
for(int x=0;x<4;x++)
|
||||||
for(x=0;x<4;x++)
|
|
||||||
if(LocalHWInfo->SaveGame[x])
|
if(LocalHWInfo->SaveGame[x])
|
||||||
fread(LocalHWInfo->SaveGame[x],1,LocalHWInfo->SaveGameLen[x],sp);
|
fread(LocalHWInfo->SaveGame[x],1,LocalHWInfo->SaveGameLen[x],sp);
|
||||||
}
|
}
|
||||||
free(soot);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//clears all save memory. call this if you want to pretend the saveram has been reset (it doesnt touch what is on disk though)
|
||||||
|
void FCEU_ClearGameSave(CartInfo *LocalHWInfo)
|
||||||
|
{
|
||||||
|
if(LocalHWInfo->battery && LocalHWInfo->SaveGame[0])
|
||||||
|
{
|
||||||
|
FILE *sp;
|
||||||
|
for(int x=0;x<4;x++)
|
||||||
|
if(LocalHWInfo->SaveGame[x])
|
||||||
|
memset(LocalHWInfo->SaveGame[x],0,LocalHWInfo->SaveGameLen[x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ typedef struct {
|
||||||
|
|
||||||
void FCEU_SaveGameSave(CartInfo *LocalHWInfo);
|
void FCEU_SaveGameSave(CartInfo *LocalHWInfo);
|
||||||
void FCEU_LoadGameSave(CartInfo *LocalHWInfo);
|
void FCEU_LoadGameSave(CartInfo *LocalHWInfo);
|
||||||
|
void FCEU_ClearGameSave(CartInfo *LocalHWInfo);
|
||||||
|
|
||||||
extern uint8 *Page[32],*VPage[8],*MMC5SPRVPage[8],*MMC5BGVPage[8];
|
extern uint8 *Page[32],*VPage[8],*MMC5SPRVPage[8],*MMC5BGVPage[8];
|
||||||
|
|
||||||
|
|
|
@ -1282,7 +1282,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||||
return FALSE; //TRUE;
|
return FALSE; //TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void iNESGI(int h);
|
extern void iNESGI(GI h);
|
||||||
|
|
||||||
void DoPatcher(int address,HWND hParent){
|
void DoPatcher(int address,HWND hParent){
|
||||||
iapoffset=address;
|
iapoffset=address;
|
||||||
|
|
16
src/fceu.cpp
16
src/fceu.cpp
|
@ -84,8 +84,6 @@ static void CloseGame(void)
|
||||||
FCEUD_NetworkClose();
|
FCEUD_NetworkClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
FCEUI_StopMovie();
|
|
||||||
|
|
||||||
if(GameInfo->name)
|
if(GameInfo->name)
|
||||||
{
|
{
|
||||||
free(GameInfo->name);
|
free(GameInfo->name);
|
||||||
|
@ -99,6 +97,8 @@ static void CloseGame(void)
|
||||||
|
|
||||||
GameInterface(GI_CLOSE);
|
GameInterface(GI_CLOSE);
|
||||||
|
|
||||||
|
FCEUI_StopMovie();
|
||||||
|
|
||||||
ResetExState(0,0);
|
ResetExState(0,0);
|
||||||
|
|
||||||
//mbg 5/9/08 - clear screen when game is closed
|
//mbg 5/9/08 - clear screen when game is closed
|
||||||
|
@ -120,7 +120,7 @@ uint64 timestampbase;
|
||||||
|
|
||||||
FCEUGI *GameInfo = 0;
|
FCEUGI *GameInfo = 0;
|
||||||
|
|
||||||
void (*GameInterface)(int h);
|
void (*GameInterface)(GI h);
|
||||||
void (*GameStateRestore)(int version);
|
void (*GameStateRestore)(int version);
|
||||||
|
|
||||||
readfunc ARead[0x10000];
|
readfunc ARead[0x10000];
|
||||||
|
@ -656,8 +656,8 @@ void hand(X6502 *X, int type, unsigned int A)
|
||||||
int suppressAddPowerCommand=0; // hack... yeah, I know...
|
int suppressAddPowerCommand=0; // hack... yeah, I know...
|
||||||
void PowerNES(void)
|
void PowerNES(void)
|
||||||
{
|
{
|
||||||
/*void MapperInit();
|
//void MapperInit();
|
||||||
MapperInit();*/
|
//MapperInit();
|
||||||
|
|
||||||
if(!suppressAddPowerCommand)
|
if(!suppressAddPowerCommand)
|
||||||
FCEUMOV_AddCommand(FCEUNPCMD_POWER);
|
FCEUMOV_AddCommand(FCEUNPCMD_POWER);
|
||||||
|
@ -689,6 +689,12 @@ void PowerNES(void)
|
||||||
if(GameInfo->type==GIT_VSUNI)
|
if(GameInfo->type==GIT_VSUNI)
|
||||||
FCEU_VSUniPower();
|
FCEU_VSUniPower();
|
||||||
|
|
||||||
|
//if we are in a movie, then reset the saveram
|
||||||
|
extern int disableBatteryLoading;
|
||||||
|
if(disableBatteryLoading)
|
||||||
|
GameInterface(GI_RESETSAVE);
|
||||||
|
|
||||||
|
|
||||||
timestampbase=0;
|
timestampbase=0;
|
||||||
LagCounterReset();
|
LagCounterReset();
|
||||||
|
|
||||||
|
|
13
src/fceu.h
13
src/fceu.h
|
@ -47,12 +47,17 @@ extern int EmulationPaused;
|
||||||
extern readfunc ARead[0x10000];
|
extern readfunc ARead[0x10000];
|
||||||
extern writefunc BWrite[0x10000];
|
extern writefunc BWrite[0x10000];
|
||||||
|
|
||||||
extern void (*GameInterface)(int h);
|
|
||||||
|
enum GI {
|
||||||
|
GI_RESETM2 =1,
|
||||||
|
GI_POWER =2,
|
||||||
|
GI_CLOSE =3,
|
||||||
|
GI_RESETSAVE = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void (*GameInterface)(GI h);
|
||||||
extern void (*GameStateRestore)(int version);
|
extern void (*GameStateRestore)(int version);
|
||||||
|
|
||||||
#define GI_RESETM2 1
|
|
||||||
#define GI_POWER 2
|
|
||||||
#define GI_CLOSE 3
|
|
||||||
|
|
||||||
#include "git.h"
|
#include "git.h"
|
||||||
extern FCEUGI *GameInfo;
|
extern FCEUGI *GameInfo;
|
||||||
|
|
|
@ -84,7 +84,7 @@ static uint8 SelectDisk,InDisk;
|
||||||
|
|
||||||
#define DC_INC 1
|
#define DC_INC 1
|
||||||
|
|
||||||
void FDSGI(int h)
|
void FDSGI(GI h)
|
||||||
{
|
{
|
||||||
switch(h)
|
switch(h)
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,10 +89,14 @@ static DECLFR(TrainerRead)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void iNESGI(int h) //bbit edited: removed static keyword
|
void iNESGI(GI h) //bbit edited: removed static keyword
|
||||||
{
|
{
|
||||||
switch(h)
|
switch(h)
|
||||||
{
|
{
|
||||||
|
case GI_RESETSAVE:
|
||||||
|
FCEU_ClearGameSave(&iNESCart);
|
||||||
|
break;
|
||||||
|
|
||||||
case GI_RESETM2:
|
case GI_RESETM2:
|
||||||
if(MapperReset)
|
if(MapperReset)
|
||||||
MapperReset();
|
MapperReset();
|
||||||
|
|
|
@ -595,37 +595,30 @@ void FCEUI_StopMovie()
|
||||||
static void poweron(bool shouldDisableBatteryLoading)
|
static void poweron(bool shouldDisableBatteryLoading)
|
||||||
{
|
{
|
||||||
//// make a for-movie-recording power-on clear the game's save data, too
|
//// make a for-movie-recording power-on clear the game's save data, too
|
||||||
// extern char lastLoadedGameName [2048];
|
//extern char lastLoadedGameName [2048];
|
||||||
// extern int disableBatteryLoading, suppressAddPowerCommand;
|
//extern int disableBatteryLoading, suppressAddPowerCommand;
|
||||||
// suppressAddPowerCommand=1;
|
//suppressAddPowerCommand=1;
|
||||||
// if(shouldDisableBatteryLoading) disableBatteryLoading=1;
|
//if(shouldDisableBatteryLoading) disableBatteryLoading=1;
|
||||||
// suppressMovieStop=true;
|
//suppressMovieStop=true;
|
||||||
// {
|
//{
|
||||||
// //we need to save the pause state through this process
|
// //we need to save the pause state through this process
|
||||||
// int oldPaused = EmulationPaused;
|
// int oldPaused = EmulationPaused;
|
||||||
|
|
||||||
// // NOTE: this will NOT write an FCEUNPCMD_POWER into the movie file
|
// // NOTE: this will NOT write an FCEUNPCMD_POWER into the movie file
|
||||||
// FCEUGI* gi = FCEUI_LoadGame(lastLoadedGameName, 0);
|
// FCEUGI* gi = FCEUI_LoadGame(lastLoadedGameName, 0);
|
||||||
// //mbg 5/23/08 - wtf? why would this return null?
|
// assert(gi);
|
||||||
// //if(!gi) PowerNES();
|
// PowerNES();
|
||||||
// assert(gi);
|
|
||||||
|
|
||||||
// EmulationPaused = oldPaused;
|
// EmulationPaused = oldPaused;
|
||||||
// }
|
//}
|
||||||
// suppressMovieStop=false;
|
//suppressMovieStop=false;
|
||||||
// if(shouldDisableBatteryLoading) disableBatteryLoading=0;
|
//if(shouldDisableBatteryLoading) disableBatteryLoading=0;
|
||||||
// suppressAddPowerCommand=0;
|
//suppressAddPowerCommand=0;
|
||||||
|
|
||||||
//mbg 6/25/08
|
|
||||||
//ok this pissed me off
|
|
||||||
//the only reason for lastLoadedGameName and all these hacks was for this fix:
|
|
||||||
//"hack for movie WRAM clearing on record from poweron"
|
|
||||||
//but W-T-F. are you telling me that there is some problem with the poweron sequence?
|
|
||||||
//screw that. we're using the main poweron sequence, even if that breaks old movie compatibility (unlikely)
|
|
||||||
extern int disableBatteryLoading;
|
extern int disableBatteryLoading;
|
||||||
if(shouldDisableBatteryLoading) disableBatteryLoading=1;
|
disableBatteryLoading = 1;
|
||||||
PowerNES();
|
PowerNES();
|
||||||
if(shouldDisableBatteryLoading) disableBatteryLoading=0;
|
disableBatteryLoading = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ NSF_HEADER NSFHeader; //mbg merge 6/29/06 - needs to be global
|
||||||
void NSFMMC5_Close(void);
|
void NSFMMC5_Close(void);
|
||||||
static uint8 *ExWRAM=0;
|
static uint8 *ExWRAM=0;
|
||||||
|
|
||||||
void NSFGI(int h)
|
void NSFGI(GI h)
|
||||||
{
|
{
|
||||||
switch(h)
|
switch(h)
|
||||||
{
|
{
|
||||||
|
|
|
@ -501,10 +501,14 @@ static int InitializeBoard(void)
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UNIFGI(int h)
|
static void UNIFGI(GI h)
|
||||||
{
|
{
|
||||||
switch(h)
|
switch(h)
|
||||||
{
|
{
|
||||||
|
case GI_RESETSAVE:
|
||||||
|
FCEU_ClearGameSave(&UNIFCart);
|
||||||
|
break;
|
||||||
|
|
||||||
case GI_RESETM2:
|
case GI_RESETM2:
|
||||||
if(UNIFCart.Reset)
|
if(UNIFCart.Reset)
|
||||||
UNIFCart.Reset();
|
UNIFCart.Reset();
|
||||||
|
|
Loading…
Reference in New Issue