win32: added Config->Enable->Auto-resume old play session
This commit is contained in:
parent
bf4ba33801
commit
00b4304241
|
@ -76,8 +76,9 @@ extern int32 fps_scale_frameadvance;
|
|||
|
||||
extern TASEDITOR_CONFIG taseditor_config;
|
||||
extern char* recent_projects[];
|
||||
// Hacky fix for taseditor_config.last_author
|
||||
// Hacky fix for taseditor_config.last_author and rom_name_when_closing_emulator
|
||||
char* taseditor_config_last_author;
|
||||
char* ResumeROM;
|
||||
|
||||
//window positions and sizes:
|
||||
extern int ChtPosX,ChtPosY;
|
||||
|
@ -117,8 +118,8 @@ extern int RomFreezeColorB;
|
|||
char* ramWatchRecent[] = {0, 0, 0, 0, 0};
|
||||
|
||||
//Structure that contains configuration information
|
||||
static CFGSTRUCT fceuconfig[] = {
|
||||
|
||||
static CFGSTRUCT fceuconfig[] =
|
||||
{
|
||||
ACS(recent_files[0]),
|
||||
ACS(recent_files[1]),
|
||||
ACS(recent_files[2]),
|
||||
|
@ -165,6 +166,9 @@ static CFGSTRUCT fceuconfig[] = {
|
|||
ACS(recent_projects[8]),
|
||||
ACS(recent_projects[9]),
|
||||
|
||||
AC(AutoResumePlay),
|
||||
ACS(ResumeROM),
|
||||
|
||||
AC(gNoBGFillColor),
|
||||
AC(ntsccol),AC(ntsctint),AC(ntschue),
|
||||
AC(force_grayscale),
|
||||
|
@ -416,8 +420,9 @@ void SaveConfig(const char *filename)
|
|||
{
|
||||
ramWatchRecent[x] = rw_recent_files[x];
|
||||
}
|
||||
// Hacky fix for taseditor_config.last_author
|
||||
// Hacky fix for taseditor_config.last_author and rom_name_when_closing_emulator
|
||||
taseditor_config_last_author = taseditor_config.last_author;
|
||||
ResumeROM = rom_name_when_closing_emulator;
|
||||
//-----------------------------------
|
||||
|
||||
SaveFCEUConfig(filename,fceuconfig);
|
||||
|
@ -445,11 +450,16 @@ void LoadConfig(const char *filename)
|
|||
rw_recent_files[x][0] = 0;
|
||||
}
|
||||
}
|
||||
// Hacky fix for taseditor_config.last_author
|
||||
// Hacky fix for taseditor_config.last_author and rom_name_when_closing_emulator
|
||||
if (taseditor_config_last_author)
|
||||
strncpy(taseditor_config.last_author, taseditor_config_last_author, AUTHOR_MAX_LEN-1);
|
||||
else
|
||||
taseditor_config.last_author[0] = 0;
|
||||
if (ResumeROM)
|
||||
strncpy(rom_name_when_closing_emulator, ResumeROM, 128);
|
||||
else
|
||||
rom_name_when_closing_emulator[0] = 0;
|
||||
|
||||
//-----------------------------------
|
||||
}
|
||||
|
||||
|
|
|
@ -1716,7 +1716,9 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
case WM_INITMENU:
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch(HIWORD(wParam)) {
|
||||
{
|
||||
switch(HIWORD(wParam))
|
||||
{
|
||||
case BN_CLICKED:
|
||||
switch(LOWORD(wParam)) {
|
||||
case IDC_DEBUGGER_RESTORESIZE:
|
||||
|
@ -1929,6 +1931,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return FALSE; //TRUE;
|
||||
|
|
|
@ -418,11 +418,10 @@ void DoFCEUExit()
|
|||
if(exiting) //Eh, oops. I'll need to try to fix this later.
|
||||
return;
|
||||
|
||||
#ifdef WIN32
|
||||
//If user was asked to save changes in TAS Editor and chose cancel, don't close FCEUX
|
||||
// If user was asked to save changes in TAS Editor and chose cancel, don't close FCEUX
|
||||
extern bool ExitTasEditor();
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR) && !ExitTasEditor()) return;
|
||||
#endif
|
||||
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR) && !ExitTasEditor())
|
||||
return;
|
||||
|
||||
if (CloseMemoryWatch() && AskSave()) //If user was asked to save changes in the memory watch dialog or ram watch, and chose cancel, don't close FCEUX!
|
||||
{
|
||||
|
@ -449,12 +448,22 @@ void DoFCEUExit()
|
|||
|
||||
FCEUI_StopMovie();
|
||||
FCEUD_AviStop();
|
||||
#ifdef _S9XLUA_H
|
||||
#ifdef _S9XLUA_H
|
||||
FCEU_LuaStop(); // kill lua script before the gui dies
|
||||
#endif
|
||||
#endif
|
||||
|
||||
exiting = 1;
|
||||
closeGame = true;//mbg 6/30/06 - for housekeeping purposes we need to exit after the emulation cycle finishes
|
||||
// remember the ROM name
|
||||
extern char LoadedRomFName[2048];
|
||||
if (GameInfo)
|
||||
{
|
||||
strncpy(rom_name_when_closing_emulator, LoadedRomFName, 128);
|
||||
rom_name_when_closing_emulator[128] = 0;
|
||||
} else
|
||||
{
|
||||
rom_name_when_closing_emulator[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -745,12 +754,14 @@ int main(int argc,char *argv[])
|
|||
|
||||
InitSpeedThrottle();
|
||||
|
||||
if(t)
|
||||
if (t)
|
||||
{
|
||||
ALoad(t);
|
||||
}
|
||||
else if(eoptions & EO_FOAFTERSTART)
|
||||
} else
|
||||
{
|
||||
if (AutoResumePlay && rom_name_when_closing_emulator && rom_name_when_closing_emulator[0])
|
||||
ALoad(rom_name_when_closing_emulator);
|
||||
if (eoptions & EO_FOAFTERSTART)
|
||||
LoadNewGamey(hAppWnd, 0);
|
||||
}
|
||||
|
||||
|
@ -843,7 +854,7 @@ doloopy:
|
|||
FCEUD_Update(gfx, sound, ssize); //update displays and debug tools
|
||||
|
||||
//mbg 6/30/06 - close game if we were commanded to by calls nested in FCEUI_Emulate()
|
||||
if(closeGame)
|
||||
if (closeGame)
|
||||
{
|
||||
FCEUI_CloseGame();
|
||||
GameInfo = NULL;
|
||||
|
|
|
@ -120,6 +120,7 @@ BEGIN
|
|||
MENUITEM "&Frame Adv. - Skip Lag", MENU_DISPLAY_FA_LAGSKIP
|
||||
MENUITEM "Backup Savestates", ID_ENABLE_BACKUPSAVESTATES
|
||||
MENUITEM "Compress Savestates", ID_ENABLE_COMPRESSSAVESTATES
|
||||
MENUITEM "Auto-resume old play session", ID_ENABLE_AUTORESUME
|
||||
END
|
||||
POPUP "&Display"
|
||||
BEGIN
|
||||
|
|
|
@ -1149,6 +1149,8 @@
|
|||
#define ID_Menu40575 40575
|
||||
#define ID_EMULATIONSPEED_SETCUSTOMSPEEDFORFRAMEADVANCE 40576
|
||||
#define ID_EMULATIONSPEED_CUSTOMSPEED 40577
|
||||
#define ID_ENABLE_AUTO 40578
|
||||
#define ID_ENABLE_AUTORESUME 40579
|
||||
#define IDC_DEBUGGER_ICONTRAY 55535
|
||||
#define MW_ValueLabel2 65423
|
||||
#define MW_ValueLabel1 65426
|
||||
|
@ -1159,7 +1161,7 @@
|
|||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 289
|
||||
#define _APS_NEXT_COMMAND_VALUE 40578
|
||||
#define _APS_NEXT_COMMAND_VALUE 40580
|
||||
#define _APS_NEXT_CONTROL_VALUE 1282
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
|
|
|
@ -422,6 +422,7 @@ void UpdateCheckedMenuItems()
|
|||
CheckMenuItem(fceumenu, MENU_CONFIG_BINDSAVES, bindSavestate?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(fceumenu, ID_ENABLE_BACKUPSAVESTATES, backupSavestates?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(fceumenu, ID_ENABLE_COMPRESSSAVESTATES, compressSavestates?MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(fceumenu, ID_ENABLE_AUTORESUME, AutoResumePlay?MF_CHECKED : MF_UNCHECKED);
|
||||
|
||||
//Config - Display SubMenu
|
||||
CheckMenuItem(fceumenu, MENU_DISPLAY_LAGCOUNTER, lagCounterDisplay?MF_CHECKED : MF_UNCHECKED);
|
||||
|
@ -1882,6 +1883,10 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
|||
compressSavestates ^=1;
|
||||
UpdateCheckedMenuItems();
|
||||
break;
|
||||
case ID_ENABLE_AUTORESUME:
|
||||
AutoResumePlay ^=1;
|
||||
UpdateCheckedMenuItems();
|
||||
break;
|
||||
|
||||
//Display submenu
|
||||
case MENU_INPUTDISPLAY_0: //Input display off
|
||||
|
|
39
src/fceu.cpp
39
src/fceu.cpp
|
@ -92,6 +92,8 @@ bool frameAdvanceLagSkip = false; //If this is true, frame advance will skip ove
|
|||
bool AutoSS = false; //Flagged true when the first auto-savestate is made while a game is loaded, flagged false on game close
|
||||
bool movieSubtitles = true; //Toggle for displaying movie subtitles
|
||||
bool DebuggerWasUpdated = false; //To prevent the debugger from updating things without being updated.
|
||||
bool AutoResumePlay = true; // maybe this should be in "eoptions"...
|
||||
char rom_name_when_closing_emulator[129] = {0};
|
||||
|
||||
FCEUGI::FCEUGI()
|
||||
: filename(0)
|
||||
|
@ -133,13 +135,20 @@ void FCEU_TogglePPU(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
static void FCEU_CloseGame(void) {
|
||||
if (GameInfo) {
|
||||
#ifdef WIN32
|
||||
//SP CODE
|
||||
extern char LoadedRomFName[2048];
|
||||
static void FCEU_CloseGame(void)
|
||||
{
|
||||
if (GameInfo)
|
||||
{
|
||||
if (AutoResumePlay)
|
||||
{
|
||||
// save "-resume" savestate
|
||||
FCEUSS_Save(FCEU_MakeFName(FCEUMKF_RESUMESTATE, 0, 0).c_str());
|
||||
}
|
||||
|
||||
if (storePreferences(LoadedRomFName)) {
|
||||
#ifdef WIN32
|
||||
extern char LoadedRomFName[2048];
|
||||
if (storePreferences(LoadedRomFName))
|
||||
{
|
||||
FCEUD_PrintError("Couldn't store debugging data");
|
||||
}
|
||||
#endif
|
||||
|
@ -372,12 +381,8 @@ int NSFLoad(const char *name, FCEUFILE *fp);
|
|||
//char lastLoadedGameName [2048] = {0,}; // hack for movie WRAM clearing on record from poweron
|
||||
|
||||
//name should be UTF-8, hopefully, or else there may be trouble
|
||||
FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode) {
|
||||
//mbg merge 7/17/07 - why is this here
|
||||
//#ifdef WIN32
|
||||
// StopSound();
|
||||
//#endif
|
||||
|
||||
FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode)
|
||||
{
|
||||
//----------
|
||||
//attempt to open the files
|
||||
FCEUFILE *fp;
|
||||
|
@ -480,6 +485,15 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode) {
|
|||
DoDebuggerDataReload(); // Reloads data without reopening window
|
||||
#endif
|
||||
|
||||
if (AutoResumePlay)
|
||||
{
|
||||
// load "-resume" savestate
|
||||
if (FCEUSS_Load(FCEU_MakeFName(FCEUMKF_RESUMESTATE, 0, 0).c_str()))
|
||||
FCEU_DispMessage("Game resumed from savestate.", 0);
|
||||
else
|
||||
FCEU_DispMessage("Couldn't resume game from savestate.", 0);
|
||||
}
|
||||
|
||||
ResetScreenshotsCounter();
|
||||
|
||||
return GameInfo;
|
||||
|
@ -657,6 +671,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
|||
Update_RAM_Search(); // Update_RAM_Watch() is also called.
|
||||
RamChange();
|
||||
//FCEUI_AviVideoUpdate(XBuf);
|
||||
|
||||
extern int KillFCEUXonFrame;
|
||||
if (KillFCEUXonFrame && (FCEUMOV_GetFrame() >= KillFCEUXonFrame))
|
||||
DoFCEUExit();
|
||||
|
|
|
@ -5,6 +5,9 @@ extern int fceuindbg;
|
|||
extern int newppu;
|
||||
void ResetGameLoaded(void);
|
||||
|
||||
extern bool AutoResumePlay;
|
||||
extern char rom_name_when_closing_emulator[];
|
||||
|
||||
#define DECLFR(x) uint8 x (uint32 A)
|
||||
#define DECLFW(x) void x (uint32 A, uint8 V)
|
||||
|
||||
|
|
43
src/file.cpp
43
src/file.cpp
|
@ -601,8 +601,7 @@ std::string FCEU_MakeFName(int type, int id1, const char *cd1)
|
|||
if(odirs[FCEUIOD_STATES])
|
||||
{
|
||||
sprintf(ret,"%s"PSS"%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory.c_str(),FileBase,mfn,id1);
|
||||
}
|
||||
|
@ -611,14 +610,34 @@ std::string FCEU_MakeFName(int type, int id1, const char *cd1)
|
|||
if(odirs[FCEUIOD_STATES])
|
||||
{
|
||||
sprintf(ret,"%s"PSS"%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory.c_str(),FileBase,mfn,id1);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FCEUMKF_RESUMESTATE:
|
||||
{
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
{
|
||||
sprintf(ret,"%s"PSS"%s-resume.fcs",odirs[FCEUIOD_STATES],FileBase);
|
||||
} else
|
||||
{
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s-resume.fcs",BaseDirectory.c_str(),FileBase);
|
||||
}
|
||||
if(stat(ret,&tmpstat)==-1)
|
||||
{
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
{
|
||||
sprintf(ret,"%s"PSS"%s-resume.fcs",odirs[FCEUIOD_STATES],FileBase);
|
||||
} else
|
||||
{
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s-resume.fcs",BaseDirectory.c_str(),FileBase);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FCEUMKF_SNAP:
|
||||
if(odirs[FCEUIOD_SNAPS])
|
||||
sprintf(ret,"%s"PSS"%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1);
|
||||
|
@ -646,12 +665,21 @@ std::string FCEU_MakeFName(int type, int id1, const char *cd1)
|
|||
break;
|
||||
case FCEUMKF_AUTOSTATE:
|
||||
mfnString = GetMfn();
|
||||
if (mfnString.length() <= MAX_MOVIEFILENAME_LEN)
|
||||
{
|
||||
mfn = mfnString.c_str();
|
||||
} else
|
||||
{
|
||||
//This caps the movie filename length before adding it to the savestate filename.
|
||||
//This helps prevent possible crashes from savestate filenames of excessive length.
|
||||
mfnString = mfnString.substr(0, MAX_MOVIEFILENAME_LEN);
|
||||
mfn = mfnString.c_str();
|
||||
}
|
||||
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
{
|
||||
sprintf(ret,"%s"PSS"%s%s-autosave%d.fcs",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s%s-autosave%d.fcs",BaseDirectory.c_str(),FileBase,mfn,id1);
|
||||
}
|
||||
|
@ -660,8 +688,7 @@ std::string FCEU_MakeFName(int type, int id1, const char *cd1)
|
|||
if(odirs[FCEUIOD_STATES])
|
||||
{
|
||||
sprintf(ret,"%s"PSS"%s%s-autosave%d.fcs",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s%s-autosave%d.fcs",BaseDirectory.c_str(),FileBase,mfn,id1);
|
||||
}
|
||||
|
|
|
@ -165,4 +165,5 @@ void FCEU_SplitArchiveFilename(std::string src, std::string& archive, std::strin
|
|||
#define FCEUMKF_LUA 20
|
||||
#define FCEUMKF_AVI 21
|
||||
#define FCEUMKF_TASEDITOR 22
|
||||
#define FCEUMKF_RESUMESTATE 23
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue