mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Cleanups
This commit is contained in:
parent
03ba1153a4
commit
34f4d5ed0e
@ -2738,6 +2738,7 @@ TODO: Add a setting for these tweaks */
|
||||
case CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED:
|
||||
case CMD_EVENT_NETPLAY_GAME_WATCH:
|
||||
case CMD_EVENT_NETPLAY_HOST_TOGGLE:
|
||||
case CMD_EVENT_NETPLAY_DISCONNECT:
|
||||
return false;
|
||||
#endif
|
||||
case CMD_EVENT_FULLSCREEN_TOGGLE:
|
||||
|
@ -6786,7 +6786,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
|
||||
break;
|
||||
case DISPLAYLIST_VIDEO_SETTINGS_LIST:
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
|
||||
menu_displaylist_parse_settings_enum(menu, info,
|
||||
MENU_ENUM_LABEL_CRT_SWITCHRES_SETTINGS,
|
||||
|
@ -690,8 +690,7 @@ static void JSONLogError(JSONContext *pCtx)
|
||||
void playlist_write_runtime_file(playlist_t *playlist)
|
||||
{
|
||||
size_t i;
|
||||
RFILE *file = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
RFILE *file = NULL;
|
||||
JSONContext context = {0};
|
||||
|
||||
if (!playlist || !playlist->modified)
|
||||
@ -922,8 +921,8 @@ void playlist_write_file(playlist_t *playlist)
|
||||
else
|
||||
{
|
||||
JSONContext context = {0};
|
||||
context.writer = JSON_Writer_Create(NULL);
|
||||
context.file = file;
|
||||
context.writer = JSON_Writer_Create(NULL);
|
||||
context.file = file;
|
||||
|
||||
if (!context.writer)
|
||||
{
|
||||
|
@ -16,27 +16,14 @@
|
||||
#include "../configuration.h"
|
||||
#include "../retroarch.h"
|
||||
|
||||
static bool runahead_create(void);
|
||||
static bool runahead_save_state(void);
|
||||
static bool runahead_load_state(void);
|
||||
static bool runahead_load_state_secondary(void);
|
||||
static bool runahead_run_secondary(void);
|
||||
static void runahead_suspend_audio(void);
|
||||
static void runahead_resume_audio(void);
|
||||
static void runahead_suspend_video(void);
|
||||
static void runahead_resume_video(void);
|
||||
static void set_fast_savestate(void);
|
||||
static void unset_fast_savestate(void);
|
||||
static void set_hard_disable_audio(void);
|
||||
static void unset_hard_disable_audio(void);
|
||||
static size_t runahead_save_state_size = 0;
|
||||
|
||||
static bool core_run_use_last_input(void);
|
||||
|
||||
static size_t runahead_save_state_size = 0;
|
||||
static bool runahead_save_state_size_known = false;
|
||||
static bool request_fast_savestate = false;
|
||||
static bool hard_disable_audio = false;
|
||||
|
||||
/* Save State List for Run Ahead */
|
||||
static MyList *runahead_save_state_list;
|
||||
static MyList *runahead_save_state_list = NULL;
|
||||
|
||||
static void *runahead_save_state_alloc(void)
|
||||
{
|
||||
@ -105,7 +92,7 @@ static function_t originalRetroUnload = NULL;
|
||||
extern struct retro_core_t current_core;
|
||||
extern struct retro_callbacks retro_ctx;
|
||||
|
||||
static void remove_hooks(void)
|
||||
static void runahead_remove_hooks(void)
|
||||
{
|
||||
if (originalRetroDeinit)
|
||||
{
|
||||
@ -123,7 +110,7 @@ static void remove_hooks(void)
|
||||
|
||||
static void unload_hook(void)
|
||||
{
|
||||
remove_hooks();
|
||||
runahead_remove_hooks();
|
||||
runahead_destroy();
|
||||
secondary_core_destroy();
|
||||
if (current_core.retro_unload_game)
|
||||
@ -132,7 +119,7 @@ static void unload_hook(void)
|
||||
|
||||
static void deinit_hook(void)
|
||||
{
|
||||
remove_hooks();
|
||||
runahead_remove_hooks();
|
||||
runahead_destroy();
|
||||
secondary_core_destroy();
|
||||
if (current_core.retro_deinit)
|
||||
@ -193,6 +180,166 @@ static void runahead_check_for_gui(void)
|
||||
runahead_last_frame_count = frame_count;
|
||||
}
|
||||
|
||||
static void runahead_error(void)
|
||||
{
|
||||
runahead_available = false;
|
||||
runahead_save_state_list_destroy();
|
||||
runahead_remove_hooks();
|
||||
runahead_save_state_size = 0;
|
||||
runahead_save_state_size_known = true;
|
||||
}
|
||||
|
||||
|
||||
static bool runahead_create(void)
|
||||
{
|
||||
/* get savestate size and allocate buffer */
|
||||
retro_ctx_size_info_t info;
|
||||
request_fast_savestate = true;
|
||||
core_serialize_size(&info);
|
||||
request_fast_savestate = false;
|
||||
|
||||
runahead_save_state_list_init(info.size);
|
||||
runahead_video_driver_is_active = video_driver_is_active();
|
||||
|
||||
if (runahead_save_state_size == 0 || !runahead_save_state_size_known)
|
||||
{
|
||||
runahead_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
add_hooks();
|
||||
runahead_force_input_dirty = true;
|
||||
mylist_resize(runahead_save_state_list, 1, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool runahead_save_state(void)
|
||||
{
|
||||
bool okay = false;
|
||||
retro_ctx_serialize_info_t *serialize_info;
|
||||
if (!runahead_save_state_list)
|
||||
return false;
|
||||
serialize_info =
|
||||
(retro_ctx_serialize_info_t*)runahead_save_state_list->data[0];
|
||||
request_fast_savestate = true;
|
||||
okay = core_serialize(serialize_info);
|
||||
request_fast_savestate = false;
|
||||
|
||||
if (okay)
|
||||
return true;
|
||||
|
||||
runahead_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool runahead_load_state(void)
|
||||
{
|
||||
bool okay = false;
|
||||
retro_ctx_serialize_info_t *serialize_info = (retro_ctx_serialize_info_t*)
|
||||
runahead_save_state_list->data[0];
|
||||
bool last_dirty = input_is_dirty;
|
||||
|
||||
request_fast_savestate = true;
|
||||
/* calling core_unserialize has side effects with
|
||||
* netplay (it triggers transmitting your save state)
|
||||
call retro_unserialize directly from the core instead */
|
||||
okay = current_core.retro_unserialize(
|
||||
serialize_info->data_const, serialize_info->size);
|
||||
|
||||
request_fast_savestate = false;
|
||||
input_is_dirty = last_dirty;
|
||||
|
||||
if (!okay)
|
||||
runahead_error();
|
||||
|
||||
return okay;
|
||||
}
|
||||
|
||||
#if HAVE_DYNAMIC
|
||||
static bool runahead_load_state_secondary(void)
|
||||
{
|
||||
bool okay = false;
|
||||
retro_ctx_serialize_info_t *serialize_info =
|
||||
(retro_ctx_serialize_info_t*)runahead_save_state_list->data[0];
|
||||
|
||||
request_fast_savestate = true;
|
||||
okay = secondary_core_deserialize(
|
||||
serialize_info->data_const, (int)serialize_info->size);
|
||||
request_fast_savestate = false;
|
||||
|
||||
if (!okay)
|
||||
{
|
||||
runahead_secondary_core_available = false;
|
||||
runahead_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool runahead_run_secondary(void)
|
||||
{
|
||||
if (!secondary_core_run_use_last_input())
|
||||
{
|
||||
runahead_secondary_core_available = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void runahead_suspend_audio(void)
|
||||
{
|
||||
audio_driver_suspend();
|
||||
}
|
||||
|
||||
static void runahead_resume_audio(void)
|
||||
{
|
||||
audio_driver_resume();
|
||||
}
|
||||
|
||||
static void runahead_suspend_video(void)
|
||||
{
|
||||
video_driver_unset_active();
|
||||
}
|
||||
|
||||
static void runahead_resume_video(void)
|
||||
{
|
||||
if (runahead_video_driver_is_active)
|
||||
video_driver_set_active();
|
||||
else
|
||||
video_driver_unset_active();
|
||||
}
|
||||
|
||||
static void runahead_input_poll_null(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool runahead_core_run_use_last_input(void)
|
||||
{
|
||||
extern struct retro_callbacks retro_ctx;
|
||||
extern struct retro_core_t current_core;
|
||||
|
||||
retro_input_poll_t old_poll_function = retro_ctx.poll_cb;
|
||||
retro_input_state_t old_input_function = retro_ctx.state_cb;
|
||||
|
||||
retro_ctx.poll_cb = runahead_input_poll_null;
|
||||
retro_ctx.state_cb = input_state_get_last;
|
||||
|
||||
current_core.retro_set_input_poll(retro_ctx.poll_cb);
|
||||
current_core.retro_set_input_state(retro_ctx.state_cb);
|
||||
|
||||
current_core.retro_run();
|
||||
|
||||
retro_ctx.poll_cb = old_poll_function;
|
||||
retro_ctx.state_cb = old_input_function;
|
||||
|
||||
current_core.retro_set_input_poll(retro_ctx.poll_cb);
|
||||
current_core.retro_set_input_state(retro_ctx.state_cb);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void run_ahead(int runahead_count, bool useSecondary)
|
||||
{
|
||||
int frame_number = 0;
|
||||
@ -246,7 +393,7 @@ void run_ahead(int runahead_count, bool useSecondary)
|
||||
if (frame_number == 0)
|
||||
core_run();
|
||||
else
|
||||
core_run_use_last_input();
|
||||
runahead_core_run_use_last_input();
|
||||
|
||||
if (suspended_frame)
|
||||
{
|
||||
@ -310,215 +457,36 @@ void run_ahead(int runahead_count, bool useSecondary)
|
||||
{
|
||||
runahead_suspend_video();
|
||||
runahead_suspend_audio();
|
||||
set_hard_disable_audio();
|
||||
hard_disable_audio = true;
|
||||
runahead_run_secondary();
|
||||
unset_hard_disable_audio();
|
||||
hard_disable_audio = false;
|
||||
runahead_resume_audio();
|
||||
runahead_resume_video();
|
||||
}
|
||||
}
|
||||
runahead_suspend_audio();
|
||||
set_hard_disable_audio();
|
||||
hard_disable_audio = true;
|
||||
runahead_run_secondary();
|
||||
unset_hard_disable_audio();
|
||||
hard_disable_audio = false;
|
||||
runahead_resume_audio();
|
||||
#endif
|
||||
}
|
||||
runahead_force_input_dirty = false;
|
||||
}
|
||||
|
||||
static void runahead_error(void)
|
||||
{
|
||||
runahead_available = false;
|
||||
runahead_save_state_list_destroy();
|
||||
remove_hooks();
|
||||
runahead_save_state_size = 0;
|
||||
runahead_save_state_size_known = true;
|
||||
}
|
||||
|
||||
static bool runahead_create(void)
|
||||
{
|
||||
/* get savestate size and allocate buffer */
|
||||
retro_ctx_size_info_t info;
|
||||
set_fast_savestate();
|
||||
core_serialize_size(&info);
|
||||
unset_fast_savestate();
|
||||
|
||||
runahead_save_state_list_init(info.size);
|
||||
runahead_video_driver_is_active = video_driver_is_active();
|
||||
|
||||
if (runahead_save_state_size == 0 || !runahead_save_state_size_known)
|
||||
{
|
||||
runahead_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
add_hooks();
|
||||
runahead_force_input_dirty = true;
|
||||
mylist_resize(runahead_save_state_list, 1, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool runahead_save_state(void)
|
||||
{
|
||||
bool okay = false;
|
||||
retro_ctx_serialize_info_t *serialize_info;
|
||||
if (!runahead_save_state_list)
|
||||
return false;
|
||||
serialize_info =
|
||||
(retro_ctx_serialize_info_t*)runahead_save_state_list->data[0];
|
||||
set_fast_savestate();
|
||||
okay = core_serialize(serialize_info);
|
||||
unset_fast_savestate();
|
||||
if (!okay)
|
||||
{
|
||||
runahead_error();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool runahead_load_state(void)
|
||||
{
|
||||
bool okay = false;
|
||||
retro_ctx_serialize_info_t *serialize_info = (retro_ctx_serialize_info_t*)
|
||||
runahead_save_state_list->data[0];
|
||||
bool last_dirty = input_is_dirty;
|
||||
|
||||
set_fast_savestate();
|
||||
/* calling core_unserialize has side effects with
|
||||
* netplay (it triggers transmitting your save state)
|
||||
call retro_unserialize directly from the core instead */
|
||||
okay = current_core.retro_unserialize(
|
||||
serialize_info->data_const, serialize_info->size);
|
||||
unset_fast_savestate();
|
||||
input_is_dirty = last_dirty;
|
||||
|
||||
if (!okay)
|
||||
runahead_error();
|
||||
|
||||
return okay;
|
||||
}
|
||||
|
||||
static bool runahead_load_state_secondary(void)
|
||||
{
|
||||
bool okay = false;
|
||||
retro_ctx_serialize_info_t *serialize_info =
|
||||
(retro_ctx_serialize_info_t*)runahead_save_state_list->data[0];
|
||||
|
||||
set_fast_savestate();
|
||||
okay = secondary_core_deserialize(
|
||||
serialize_info->data_const, (int)serialize_info->size);
|
||||
unset_fast_savestate();
|
||||
|
||||
if (!okay)
|
||||
{
|
||||
runahead_secondary_core_available = false;
|
||||
runahead_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool runahead_run_secondary(void)
|
||||
{
|
||||
if (!secondary_core_run_use_last_input())
|
||||
{
|
||||
runahead_secondary_core_available = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void runahead_suspend_audio(void)
|
||||
{
|
||||
audio_driver_suspend();
|
||||
}
|
||||
|
||||
static void runahead_resume_audio(void)
|
||||
{
|
||||
audio_driver_resume();
|
||||
}
|
||||
|
||||
static void runahead_suspend_video(void)
|
||||
{
|
||||
video_driver_unset_active();
|
||||
}
|
||||
|
||||
static void runahead_resume_video(void)
|
||||
{
|
||||
if (runahead_video_driver_is_active)
|
||||
video_driver_set_active();
|
||||
else
|
||||
video_driver_unset_active();
|
||||
}
|
||||
|
||||
void runahead_destroy(void)
|
||||
{
|
||||
runahead_save_state_list_destroy();
|
||||
remove_hooks();
|
||||
runahead_remove_hooks();
|
||||
runahead_clear_variables();
|
||||
}
|
||||
|
||||
static bool request_fast_savestate;
|
||||
static bool hard_disable_audio;
|
||||
|
||||
bool want_fast_savestate(void)
|
||||
{
|
||||
return request_fast_savestate;
|
||||
}
|
||||
|
||||
static void set_fast_savestate(void)
|
||||
{
|
||||
request_fast_savestate = true;
|
||||
}
|
||||
|
||||
static void unset_fast_savestate(void)
|
||||
{
|
||||
request_fast_savestate = false;
|
||||
}
|
||||
|
||||
bool get_hard_disable_audio(void)
|
||||
{
|
||||
return hard_disable_audio;
|
||||
}
|
||||
|
||||
static void set_hard_disable_audio(void)
|
||||
{
|
||||
hard_disable_audio = true;
|
||||
}
|
||||
|
||||
static void unset_hard_disable_audio(void)
|
||||
{
|
||||
hard_disable_audio = false;
|
||||
}
|
||||
|
||||
static void runahead_input_poll_null(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool core_run_use_last_input(void)
|
||||
{
|
||||
extern struct retro_callbacks retro_ctx;
|
||||
extern struct retro_core_t current_core;
|
||||
|
||||
retro_input_poll_t old_poll_function = retro_ctx.poll_cb;
|
||||
retro_input_state_t old_input_function = retro_ctx.state_cb;
|
||||
|
||||
retro_ctx.poll_cb = runahead_input_poll_null;
|
||||
retro_ctx.state_cb = input_state_get_last;
|
||||
|
||||
current_core.retro_set_input_poll(retro_ctx.poll_cb);
|
||||
current_core.retro_set_input_state(retro_ctx.state_cb);
|
||||
|
||||
current_core.retro_run();
|
||||
|
||||
retro_ctx.poll_cb = old_poll_function;
|
||||
retro_ctx.state_cb = old_input_function;
|
||||
|
||||
current_core.retro_set_input_poll(retro_ctx.poll_cb);
|
||||
current_core.retro_set_input_state(retro_ctx.state_cb);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user