mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-19 01:12:33 +00:00
Slight refactor. Make ssnes_load_state(), ssnes_save_state() public.
This commit is contained in:
parent
78136e0191
commit
e0408c30ae
2
driver.h
2
driver.h
@ -145,7 +145,7 @@ typedef struct video_driver
|
||||
// Callbacks essentially useless on PC, but useful on consoles where the drivers are used for more stuff.
|
||||
#ifdef SSNES_CONSOLE
|
||||
void (*set_swap_block_state)(void *data, bool toggle); // Block swapping from being called in ::frame().
|
||||
void (*swap)(void *data) // Explicitly swap buffers. Only useful when set_swap_block_state() is set to true.
|
||||
void (*swap)(void *data); // Explicitly swap buffers. Only useful when set_swap_block_state() is set to true.
|
||||
#endif
|
||||
} video_driver_t;
|
||||
|
||||
|
@ -396,6 +396,7 @@ struct global
|
||||
jmp_buf error_sjlj_context;
|
||||
};
|
||||
|
||||
// Public functions
|
||||
void config_load(void);
|
||||
void config_set_defaults(void);
|
||||
|
||||
@ -412,11 +413,17 @@ bool ssnes_main_iterate(void);
|
||||
void ssnes_main_deinit(void);
|
||||
void ssnes_render_cached_frame(void);
|
||||
|
||||
void ssnes_load_state(void);
|
||||
void ssnes_save_state(void);
|
||||
/////////
|
||||
|
||||
// Public data structures
|
||||
extern struct settings g_settings;
|
||||
extern struct global g_extern;
|
||||
#ifdef SSNES_CONSOLE
|
||||
extern struct console_settings g_console;
|
||||
#endif
|
||||
/////////
|
||||
|
||||
#define SSNES_LOG(...) do { \
|
||||
if (g_extern.verbose) \
|
||||
|
90
ssnes.c
90
ssnes.c
@ -1500,64 +1500,60 @@ static void fill_pathnames(void)
|
||||
}
|
||||
}
|
||||
|
||||
void ssnes_load_state(void)
|
||||
{
|
||||
char load_path[PATH_MAX];
|
||||
|
||||
if (g_extern.state_slot > 0)
|
||||
snprintf(load_path, sizeof(load_path), "%s%u", g_extern.savestate_name, g_extern.state_slot);
|
||||
else
|
||||
snprintf(load_path, sizeof(load_path), "%s", g_extern.savestate_name);
|
||||
|
||||
char msg[512];
|
||||
if (load_state(load_path))
|
||||
snprintf(msg, sizeof(msg), "Loaded state from slot #%u.", g_extern.state_slot);
|
||||
else
|
||||
snprintf(msg, sizeof(msg), "Failed to load state from \"%s\".", load_path);
|
||||
|
||||
msg_queue_clear(g_extern.msg_queue);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 2, 180);
|
||||
}
|
||||
|
||||
void ssnes_save_state(void)
|
||||
{
|
||||
if (g_settings.savestate_auto_index)
|
||||
g_extern.state_slot++;
|
||||
|
||||
char save_path[PATH_MAX];
|
||||
|
||||
if (g_extern.state_slot > 0)
|
||||
snprintf(save_path, sizeof(save_path), "%s%u", g_extern.savestate_name, g_extern.state_slot);
|
||||
else
|
||||
snprintf(save_path, sizeof(save_path), "%s", g_extern.savestate_name);
|
||||
|
||||
char msg[512];
|
||||
if (save_state(save_path))
|
||||
snprintf(msg, sizeof(msg), "Saved state to slot #%u.", g_extern.state_slot);
|
||||
else
|
||||
snprintf(msg, sizeof(msg), "Failed to save state to \"%s\".", save_path);
|
||||
|
||||
msg_queue_clear(g_extern.msg_queue);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 2, 180);
|
||||
}
|
||||
|
||||
// Save or load state here.
|
||||
static void check_savestates(void)
|
||||
{
|
||||
static bool old_should_savestate = false;
|
||||
bool should_savestate = driver.input->key_pressed(driver.input_data, SSNES_SAVE_STATE_KEY);
|
||||
if (should_savestate && !old_should_savestate)
|
||||
{
|
||||
if (g_settings.savestate_auto_index)
|
||||
g_extern.state_slot++;
|
||||
|
||||
char save_path[PATH_MAX];
|
||||
|
||||
if (g_extern.state_slot > 0)
|
||||
snprintf(save_path, sizeof(save_path), "%s%u", g_extern.savestate_name, g_extern.state_slot);
|
||||
else
|
||||
snprintf(save_path, sizeof(save_path), "%s", g_extern.savestate_name);
|
||||
|
||||
char msg[512];
|
||||
if (save_state(save_path))
|
||||
{
|
||||
msg_queue_clear(g_extern.msg_queue);
|
||||
snprintf(msg, sizeof(msg), "Saved state to slot #%u.", g_extern.state_slot);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg_queue_clear(g_extern.msg_queue);
|
||||
snprintf(msg, sizeof(msg), "Failed to save state to \"%s\"", save_path);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 2, 180);
|
||||
}
|
||||
}
|
||||
ssnes_save_state();
|
||||
old_should_savestate = should_savestate;
|
||||
|
||||
static bool old_should_loadstate = false;
|
||||
bool should_loadstate = driver.input->key_pressed(driver.input_data, SSNES_LOAD_STATE_KEY);
|
||||
if (!should_savestate && should_loadstate && !old_should_loadstate)
|
||||
{
|
||||
char load_path[PATH_MAX];
|
||||
|
||||
if (g_extern.state_slot > 0)
|
||||
snprintf(load_path, sizeof(load_path), "%s%u", g_extern.savestate_name, g_extern.state_slot);
|
||||
else
|
||||
snprintf(load_path, sizeof(load_path), "%s", g_extern.savestate_name);
|
||||
|
||||
char msg[512];
|
||||
if (load_state(load_path))
|
||||
{
|
||||
msg_queue_clear(g_extern.msg_queue);
|
||||
snprintf(msg, sizeof(msg), "Loaded state from slot #%u.", g_extern.state_slot);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg_queue_clear(g_extern.msg_queue);
|
||||
snprintf(msg, sizeof(msg), "Failed to load state from \"%s\"", load_path);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 2, 180);
|
||||
}
|
||||
}
|
||||
ssnes_load_state();
|
||||
old_should_loadstate = should_loadstate;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user