Add autosave qty and frequency to config + stability fix
This commit is contained in:
parent
32f0231910
commit
270ce9466b
|
@ -45,7 +45,7 @@ extern CFGSTRUCT NetplayConfig[];
|
||||||
extern CFGSTRUCT InputConfig[];
|
extern CFGSTRUCT InputConfig[];
|
||||||
extern CFGSTRUCT HotkeyConfig[];
|
extern CFGSTRUCT HotkeyConfig[];
|
||||||
extern int autoHoldKey, autoHoldClearKey;
|
extern int autoHoldKey, autoHoldClearKey;
|
||||||
extern int EnableAutosave;
|
extern int EnableAutosave, AutosaveQty, AutosaveFrequency;
|
||||||
extern int AFon, AFoff, AutoFireOffset;
|
extern int AFon, AFoff, AutoFireOffset;
|
||||||
extern int DesynchAutoFire;
|
extern int DesynchAutoFire;
|
||||||
extern bool lagCounterDisplay;
|
extern bool lagCounterDisplay;
|
||||||
|
@ -222,6 +222,8 @@ static CFGSTRUCT fceuconfig[] = {
|
||||||
AC(MemWCollapsed),
|
AC(MemWCollapsed),
|
||||||
AC(BindToMain),
|
AC(BindToMain),
|
||||||
AC(EnableAutosave),
|
AC(EnableAutosave),
|
||||||
|
AC(AutosaveQty),
|
||||||
|
AC(AutosaveFrequency),
|
||||||
AC(frameAdvanceLagSkip),
|
AC(frameAdvanceLagSkip),
|
||||||
AC(debuggerAutoload),
|
AC(debuggerAutoload),
|
||||||
AC(allowUDLR),
|
AC(allowUDLR),
|
||||||
|
|
|
@ -1098,6 +1098,10 @@ BOOL CALLBACK InputConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix to deal with corrupted config.
|
||||||
|
if (InputType[port]>SI_COUNT || InputType[port]<0)
|
||||||
|
InputType[port]=SI_UNSET;
|
||||||
|
|
||||||
// Update the combobox selection according to the
|
// Update the combobox selection according to the
|
||||||
// currently selected input mode.
|
// currently selected input mode.
|
||||||
SendDlgItemMessage(hwndDlg,
|
SendDlgItemMessage(hwndDlg,
|
||||||
|
@ -1133,6 +1137,9 @@ BOOL CALLBACK InputConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (InputType[FAMICOM_POSITION]>SI_COUNT || InputType[FAMICOM_POSITION]<0)
|
||||||
|
InputType[FAMICOM_POSITION]=SI_UNSET;
|
||||||
|
|
||||||
// Update the combobox selection according to the
|
// Update the combobox selection according to the
|
||||||
// currently selected input mode.
|
// currently selected input mode.
|
||||||
SendDlgItemMessage(
|
SendDlgItemMessage(
|
||||||
|
|
20
src/fceu.cpp
20
src/fceu.cpp
|
@ -183,8 +183,10 @@ int frameAdvanceDelay;
|
||||||
//indicates that the emulation core just frame advanced (consumed the frame advance state and paused)
|
//indicates that the emulation core just frame advanced (consumed the frame advance state and paused)
|
||||||
bool JustFrameAdvanced=false;
|
bool JustFrameAdvanced=false;
|
||||||
|
|
||||||
static int AutosaveStatus[4] = {0, 0, 0, 0}; //is it safe to load Auto-savestate
|
static int *AutosaveStatus; //is it safe to load Auto-savestate
|
||||||
static int AutosaveIndex = 0; //which Auto-savestate we're on
|
static int AutosaveIndex = 0; //which Auto-savestate we're on
|
||||||
|
int AutosaveQty = 4; // Number of Autosaves to store
|
||||||
|
int AutosaveFrequency = 256; // Number of frames between autosaves
|
||||||
|
|
||||||
// Flag that indicates whether the Auto-save option is enabled or not
|
// Flag that indicates whether the Auto-save option is enabled or not
|
||||||
int EnableAutosave = 0;
|
int EnableAutosave = 0;
|
||||||
|
@ -406,8 +408,10 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode)
|
||||||
|
|
||||||
ResetGameLoaded();
|
ResetGameLoaded();
|
||||||
|
|
||||||
AutosaveStatus[0] = AutosaveStatus[1] = 0;
|
if (!AutosaveStatus)
|
||||||
AutosaveStatus[2] = AutosaveStatus[3] = 0;
|
AutosaveStatus = (int*)malloc(sizeof(int)*AutosaveQty);
|
||||||
|
for (AutosaveIndex=0; AutosaveIndex<AutosaveQty; ++AutosaveIndex)
|
||||||
|
AutosaveStatus[AutosaveIndex] = 0;
|
||||||
|
|
||||||
CloseGame();
|
CloseGame();
|
||||||
GameInfo = new FCEUGI();
|
GameInfo = new FCEUGI();
|
||||||
|
@ -937,10 +941,10 @@ void UpdateAutosave(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char * f;
|
char * f;
|
||||||
AutosaveCounter = (AutosaveCounter + 1) % 256;
|
if(++AutosaveCounter >= AutosaveFrequency)
|
||||||
if(AutosaveCounter == 0)
|
|
||||||
{
|
{
|
||||||
AutosaveIndex = (AutosaveIndex + 1) % 4;
|
AutosaveCounter = 0;
|
||||||
|
AutosaveIndex = (AutosaveIndex + 1) % AutosaveQty;
|
||||||
f = strdup(FCEU_MakeFName(FCEUMKF_AUTOSTATE,AutosaveIndex,0).c_str());
|
f = strdup(FCEU_MakeFName(FCEUMKF_AUTOSTATE,AutosaveIndex,0).c_str());
|
||||||
FCEUSS_Save(f);
|
FCEUSS_Save(f);
|
||||||
AutoSS = true; //Flag that an auto-savestate was made
|
AutoSS = true; //Flag that an auto-savestate was made
|
||||||
|
@ -962,9 +966,9 @@ void FCEUI_Autosave(void)
|
||||||
free(f);
|
free(f);
|
||||||
|
|
||||||
//Set pointer to previous available slot
|
//Set pointer to previous available slot
|
||||||
if(AutosaveStatus[(AutosaveIndex + 3)%4] == 1)
|
if(AutosaveStatus[(AutosaveIndex + AutosaveQty-1)%AutosaveQty] == 1)
|
||||||
{
|
{
|
||||||
AutosaveIndex = (AutosaveIndex + 3)%4;
|
AutosaveIndex = (AutosaveIndex + AutosaveQty-1)%AutosaveQty;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reset time to next Auto-save
|
//Reset time to next Auto-save
|
||||||
|
|
Loading…
Reference in New Issue