From 40486da61defe78cd36140b4b00b5094af1ed545 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 14 Jan 2023 15:49:50 +0200 Subject: [PATCH] Statefile save uae-configuration support --- cfgfile.cpp | 13 ++++++++++++ include/savestate.h | 48 ++++++++++++++++++++++----------------------- inputdevice.cpp | 2 +- savestate.cpp | 6 +++++- 4 files changed, 43 insertions(+), 26 deletions(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index 79268fd1..2f25ccdf 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -7680,6 +7680,19 @@ int cmdlineparser (const TCHAR *s, TCHAR *outp[], int max) static bool cfgfile_parse_uaelib_option (struct uae_prefs *p, TCHAR *option, TCHAR *value, int type) { + TCHAR tmp[MAX_DPATH]; + if (cfgfile_path(option, value, _T("statefile_save"), tmp, sizeof(tmp) / sizeof(TCHAR))) { + if (!savestate_state) { + savestate_state = STATE_SAVE; + fetch_statefilepath(savestate_fname, sizeof(savestate_fname) / sizeof(TCHAR)); + _tcscat(savestate_fname, tmp); + if (_tcslen(savestate_fname) >= 4 && _tcsicmp(savestate_fname + _tcslen(savestate_fname) - 4, _T(".uss"))) { + _tcscat(savestate_fname, _T(".uss")); + } + } + return true; + } + return false; } diff --git a/include/savestate.h b/include/savestate.h index 4a0966d1..b295ac3d 100644 --- a/include/savestate.h +++ b/include/savestate.h @@ -230,24 +230,22 @@ extern uae_u8 *restore_expansion_info_old(uae_u8*); #endif extern void restore_expansion_finish(void); -extern uae_u8 *restore_action_replay (uae_u8 *); -extern uae_u8 *save_action_replay (size_t *, uae_u8 *); -extern uae_u8 *restore_hrtmon (uae_u8 *); -extern uae_u8 *save_hrtmon (size_t *, uae_u8 *); -extern void restore_ar_finish (void); - -extern void savestate_initsave (const TCHAR *filename, int docompress, int nodialogs, bool save); -extern int save_state (const TCHAR *filename, const TCHAR *description); -extern void restore_state (const TCHAR *filename); +extern uae_u8 *restore_action_replay(uae_u8 *); +extern uae_u8 *save_action_replay(size_t *, uae_u8 *); +extern uae_u8 *restore_hrtmon(uae_u8 *); +extern uae_u8 *save_hrtmon(size_t *, uae_u8 *); +extern void restore_ar_finish(void); + +extern void savestate_initsave(const TCHAR *filename, int docompress, int nodialogs, bool save); +extern int save_state(const TCHAR *filename, const TCHAR *description); +extern void restore_state(const TCHAR *filename); extern bool savestate_restore_finish(void); extern void savestate_restore_final(void); -extern void savestate_memorysave (void); +extern void savestate_memorysave(void); +extern void custom_prepare_savestate(void); -extern void custom_save_state (void); -extern void custom_prepare_savestate (void); - -extern bool savestate_check (void); +extern bool savestate_check(void); #define STATE_SAVE 1 #define STATE_RESTORE 2 @@ -256,24 +254,26 @@ extern bool savestate_check (void); #define STATE_REWIND 16 #define STATE_DOREWIND 32 +#define STATE_SAVE_DESCRIPTION _T("Description!") + extern int savestate_state; extern TCHAR savestate_fname[MAX_DPATH]; extern struct zfile *savestate_file; -STATIC_INLINE bool isrestore (void) +STATIC_INLINE bool isrestore(void) { return savestate_state == STATE_RESTORE || savestate_state == STATE_REWIND; } -extern void savestate_quick (int slot, int save); +extern void savestate_quick(int slot, int save); -extern void savestate_capture (int); -extern void savestate_free (void); -extern void savestate_init (void); -extern void savestate_rewind (void); -extern int savestate_dorewind (int); -extern void savestate_listrewind (void); -extern void statefile_save_recording (const TCHAR*); -extern void savestate_capture_request (void); +extern void savestate_capture(int); +extern void savestate_free(void); +extern void savestate_init(void); +extern void savestate_rewind(void); +extern int savestate_dorewind(int); +extern void savestate_listrewind(void); +extern void statefile_save_recording(const TCHAR*); +extern void savestate_capture_request(void); #endif /* UAE_SAVESTATE_H */ diff --git a/inputdevice.cpp b/inputdevice.cpp index e70f4b0e..7c5c9279 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -4595,7 +4595,7 @@ static bool inputdevice_handle_inputcode2(int monid, int code, int state, const case AKS_STATESAVEDIALOG: if (s) { savestate_initsave (s, 1, true, true); - save_state (savestate_fname, _T("Description!")); + save_state (savestate_fname, STATE_SAVE_DESCRIPTION); } else { gui_display (5); } diff --git a/savestate.cpp b/savestate.cpp index eafa765c..9f2dcc20 100644 --- a/savestate.cpp +++ b/savestate.cpp @@ -1294,7 +1294,7 @@ void savestate_quick (int slot, int save) } } -bool savestate_check (void) +bool savestate_check(void) { if (vpos == 0 && !savestate_state) { if (hsync_counter == 0 && input_play == INPREC_PLAY_NORMAL) @@ -1307,6 +1307,10 @@ bool savestate_check (void) } else if (savestate_state == STATE_DOREWIND) { savestate_state = STATE_REWIND; return true; + } else if (savestate_state == STATE_SAVE) { + savestate_initsave(savestate_fname, 1, true, true); + save_state(savestate_fname, STATE_SAVE_DESCRIPTION); + return false; } return false; } -- 2.47.3