Changed rewind to auto-save

This commit is contained in:
adelikat 2008-06-25 00:43:02 +00:00
parent 18c4e20c21
commit 3eecd0033e
11 changed files with 44 additions and 43 deletions

View File

@ -47,7 +47,7 @@ static struct
//{ EMUCMD_FDS_SIDE_SELECT, SCAN_F6, },
{ EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, SCAN_COMMA, },
//{ EMUCMD_MOVIE_READONLY_TOGGLE, SCAN_8 | CMD_KEY_SHIFT, },*/
//{ EMUCMD_MISC_REWIND, SCAN_R, }, Removed until rewind is fixed?
//{ EMUCMD_MISC_AUTOSAVE, SCAN_R, }, adelikat - Since Auto-save is disabled by default, so should the hotkey mapping
//mbg 7/31/06 - these have been removed as defaults until we decide whether hotkey philosophy permits them
{ EMUCMD_SAVE_STATE_SLOT_0, SCAN_F10 | CMD_KEY_SHIFT, },
{ EMUCMD_SAVE_STATE_SLOT_1, SCAN_F1 | CMD_KEY_SHIFT, },

View File

@ -845,6 +845,7 @@ void CreateMemWatch()
}
}
if (MemWatchLoadFileOnStart) OpenMemwatchRecentFile(0);
else fileChanged = false;
}
void AddMemWatch(char memaddress[32])
{

View File

@ -78,7 +78,7 @@ BEGIN
MENUITEM "Pause After Playback", MENU_PAUSEAFTERPLAYBACK
MENUITEM "Enable Run in Background", MENU_RUN_IN_BACKGROUND
MENUITEM "Enable Background Input", MENU_BACKGROUND_INPUT
MENUITEM "Enable Rewind", MENU_ENABLE_REWIND
MENUITEM "Enable Auto-save", MENU_ENABLE_AUTOSAVE
MENUITEM SEPARATOR
MENUITEM "Game Genie", MENU_GAME_GENIE
MENUITEM "PAL Emulation", MENU_PAL

View File

@ -221,7 +221,7 @@
#define IDC_LABEL_AUTHORINFO 303
#define IDC_BTN_CHEAT_UPD 303
#define IDC_VIDEOCONFIG_YSCALE 303
#define MENU_ENABLE_REWIND 304
#define MENU_ENABLE_AUTOSAVE 304
#define IDC_LABEL_ROMUSED 304
#define IDC_BTN_CHEAT_RESET 304
#define IDC_VIDEOCONFIG_SCALER_FS 304

View File

@ -62,7 +62,7 @@
// Extern variables
extern FCEUGI *GameInfo;
extern int EnableRewind;
extern int EnableAutosave;
// Extern functions
@ -271,7 +271,7 @@ void UpdateCheckedMenuItems()
CheckMenuItem(fceumenu, MENU_ALTERNATE_AB, GetAutoFireDesynch() ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(fceumenu, MENU_BACKGROUND_INPUT, EnableBackgroundInput ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(fceumenu, MENU_ENABLE_REWIND, EnableRewind ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(fceumenu, MENU_ENABLE_AUTOSAVE, EnableAutosave ? MF_CHECKED : MF_UNCHECKED);
int AutoFirePatternIDs[] = {
MENU_AUTOFIRE_PATTERN_1,
@ -931,8 +931,8 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
UpdateCheckedMenuItems();
break;
case MENU_ENABLE_REWIND:
EnableRewind ^= 1;
case MENU_ENABLE_AUTOSAVE:
EnableAutosave ^= 1;
UpdateCheckedMenuItems();
break;

View File

@ -120,11 +120,11 @@ int frameAdvanceDelay;
//indicates that the emulation core just frame advanced (consumed the frame advance state and paused)
bool JustFrameAdvanced=false;
static int RewindStatus[4] = {0, 0, 0, 0}; //is it safe to load rewind state
static int RewindIndex = 0; //which rewind state we're on
static int AutosaveStatus[4] = {0, 0, 0, 0}; //is it safe to load Auto-savestate
static int AutosaveIndex = 0; //which Auto-savestate we're on
// Flag that indicates whether the rewind option is enabled or not
int EnableRewind = 0;
// Flag that indicates whether the Auto-save option is enabled or not
int EnableAutosave = 0;
///a wrapper for unzip.c
extern "C" FILE *FCEUI_UTF8fopen_C(const char *n, const char *m) { return ::FCEUD_UTF8fopen(n,m); }
@ -333,8 +333,8 @@ FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode)
ResetGameLoaded();
RewindStatus[0] = RewindStatus[1] = 0;
RewindStatus[2] = RewindStatus[3] = 0;
AutosaveStatus[0] = AutosaveStatus[1] = 0;
AutosaveStatus[2] = AutosaveStatus[3] = 0;
CloseGame();
GameInfo = new FCEUGI;
@ -485,7 +485,7 @@ void AutoFire(void)
}
}
void UpdateRewind(void);
void UpdateAutosave(void);
///Emulates a single frame.
@ -524,7 +524,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
if(!FCEU_BotMode())
{
AutoFire();
UpdateRewind();
UpdateAutosave();
}
FCEU_UpdateInput();
@ -783,45 +783,45 @@ void FCEUI_FrameAdvance(void)
frameAdvanceDelay = 0;
}
static int RewindCounter = 0;
static int AutosaveCounter = 0;
void UpdateRewind(void)
void UpdateAutosave(void)
{
if(!EnableRewind)
if(!EnableAutosave)
return;
char * f;
RewindCounter = (RewindCounter + 1) % 256;
if(RewindCounter == 0)
AutosaveCounter = (AutosaveCounter + 1) % 256;
if(AutosaveCounter == 0)
{
RewindIndex = (RewindIndex + 1) % 4;
f = strdup(FCEU_MakeFName(FCEUMKF_REWINDSTATE,RewindIndex,0).c_str());
AutosaveIndex = (AutosaveIndex + 1) % 4;
f = strdup(FCEU_MakeFName(FCEUMKF_AUTOSTATE,AutosaveIndex,0).c_str());
FCEUSS_Save(f);
free(f);
RewindStatus[RewindIndex] = 1;
AutosaveStatus[AutosaveIndex] = 1;
}
}
void FCEUI_Rewind(void)
void FCEUI_Autosave(void)
{
if(!EnableRewind)
if(!EnableAutosave)
return;
if(RewindStatus[RewindIndex] == 1)
if(AutosaveStatus[AutosaveIndex] == 1)
{
char * f;
f = strdup(FCEU_MakeFName(FCEUMKF_REWINDSTATE,RewindIndex,0).c_str());
f = strdup(FCEU_MakeFName(FCEUMKF_AUTOSTATE,AutosaveIndex,0).c_str());
FCEUSS_Load(f);
free(f);
//Set pointer to previous available slot
if(RewindStatus[(RewindIndex + 3)%4] == 1)
if(AutosaveStatus[(AutosaveIndex + 3)%4] == 1)
{
RewindIndex = (RewindIndex + 3)%4;
AutosaveIndex = (AutosaveIndex + 3)%4;
}
//Reset time to next rewind save
RewindCounter = 0;
//Reset time to next Auto-save
AutosaveCounter = 0;
}
}

View File

@ -25,7 +25,7 @@ void PowerNES(void);
void SetAutoFireOffset(int offset);
void SetAutoFirePattern(int onframes, int offframes);
void AutoFire(void);
void FCEUI_Rewind(void);
void FCEUI_Autosave(void);
//mbg 7/23/06
char *FCEUI_GetAboutString();

View File

@ -459,7 +459,7 @@ uint64 FCEU_ftell(FCEUFILE *fp)
return ftell((FILE *)fp->fp);
}
void FCEU_rewind(FCEUFILE *fp)
void FCEU_autosave(FCEUFILE *fp)
{
if(fp->type==1)
{
@ -470,7 +470,7 @@ void FCEU_rewind(FCEUFILE *fp)
((MEMWRAP *)(fp->fp))->location=0;
}
else
/* Rewind */
//Autosave load
fseek((FILE*)fp->fp,0,SEEK_SET); //mbg merge 7/17/06 - added cast to FILE*
}
@ -787,24 +787,24 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
sprintf(ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory.c_str(),FileBase,cd1);
}
break;
case FCEUMKF_REWINDSTATE:
case FCEUMKF_AUTOSTATE:
if(odirs[FCEUIOD_STATES])
{
sprintf(ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATES],id1);
sprintf(ret,"%s"PSS"autosave%d.fcs",odirs[FCEUIOD_STATES],id1);
}
else
{
sprintf(ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory.c_str(),id1);
sprintf(ret,"%s"PSS"fcs"PSS"autosave%d.fcs",BaseDirectory.c_str(),id1);
}
if(stat(ret,&tmpstat)==-1)
{
if(odirs[FCEUIOD_STATES])
{
sprintf(ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATES],id1);
sprintf(ret,"%s"PSS"autosave%d.fcs",odirs[FCEUIOD_STATES],id1);
}
else
{
sprintf(ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory.c_str(),id1);
sprintf(ret,"%s"PSS"fcs"PSS"autosave%d.fcs",BaseDirectory.c_str(),id1);
}
}
break;

View File

@ -14,7 +14,7 @@ uint64 FCEU_fread(void *ptr, size_t size, size_t nmemb, FCEUFILE*);
uint64 FCEU_fwrite(void *ptr, size_t size, size_t nmemb, FCEUFILE*);
int FCEU_fseek(FCEUFILE*, long offset, int whence);
uint64 FCEU_ftell(FCEUFILE*);
void FCEU_rewind(FCEUFILE*);
void FCEU_autosave(FCEUFILE*);
int FCEU_read32le(uint32 *Bufo, FCEUFILE*);
int FCEU_read16le(uint16 *Bufo, FCEUFILE*);
int FCEU_fgetc(FCEUFILE*);
@ -42,7 +42,7 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1);
#define FCEUMKF_MOVIEGLOB 12
#define FCEUMKF_STATEGLOB 13
#define FCEUMKF_MOVIEGLOB2 14
#define FCEUMKF_REWINDSTATE 15
#define FCEUMKF_AUTOSTATE 15
#define FCEUMKF_MEMW 16
#define FCEUMKF_BBOT 17
#define FCEUMKF_ROMS 18

View File

@ -738,7 +738,7 @@ struct EMUCMDTABLE FCEUI_CommandTable[]=
{ EMUCMD_VSUNI_TOGGLE_DIP_7, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 7", },
{ EMUCMD_VSUNI_TOGGLE_DIP_8, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 8", },
{ EMUCMD_VSUNI_TOGGLE_DIP_9, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 9", },
{ EMUCMD_MISC_REWIND, EMUCMDTYPE_MISC, FCEUI_Rewind, 0, 0, "Rewind", },
{ EMUCMD_MISC_AUTOSAVE, EMUCMDTYPE_MISC, FCEUI_Autosave, 0, 0, "Auto-save", },
{ EMUCMD_MISC_SHOWSTATES, EMUCMDTYPE_MISC, ViewSlots, 0,0, "View save slots", },
{ EMUCMD_MISC_USE_INPUT_PRESET_1, EMUCMDTYPE_MISC, CommandUsePreset, 0,0, "Use Input Preset 1", },
{ EMUCMD_MISC_USE_INPUT_PRESET_2, EMUCMDTYPE_MISC, CommandUsePreset, 0,0, "Use Input Preset 2", },

View File

@ -221,7 +221,7 @@ enum EMUCMD
EMUCMD_VSUNI_TOGGLE_DIP_7,
EMUCMD_VSUNI_TOGGLE_DIP_8,
EMUCMD_VSUNI_TOGGLE_DIP_9,
EMUCMD_MISC_REWIND,
EMUCMD_MISC_AUTOSAVE,
EMUCMD_MISC_SHOWSTATES,
EMUCMD_MISC_USE_INPUT_PRESET_1,
EMUCMD_MISC_USE_INPUT_PRESET_2,