From 87fa23d7fd366dc76005ccb921a9fc74a3fd03ff Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 19 May 2024 15:37:52 -0400 Subject: [PATCH] libretro: Update the libretro state values --- src/system/libretro/tic80_libretro.c | 30 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/system/libretro/tic80_libretro.c b/src/system/libretro/tic80_libretro.c index 062e5d1bb..5230b09d4 100644 --- a/src/system/libretro/tic80_libretro.c +++ b/src/system/libretro/tic80_libretro.c @@ -75,7 +75,7 @@ struct tic80_state int mouseHideTimerStart; tic80* tic; }; -static struct tic80_state* state; +static struct tic80_state* state = NULL; /** * TIC-80 callback; Request counter @@ -98,9 +98,11 @@ static u64 tic80_libretro_freq() */ void tic80_libretro_exit() { - if (state != NULL) { - state->quit = true; + if (state == NULL) { + return; } + + state->quit = true; } /** @@ -150,9 +152,9 @@ void tic80_libretro_fallback_log(enum retro_log_level level, const char *fmt, .. */ RETRO_API void retro_init(void) { - // Ensure the state is ready. + // Do not re-initialize. if (state != NULL) { - retro_deinit(); + return; } // Initialize the base state. @@ -294,10 +296,12 @@ RETRO_API void retro_deinit(void) retro_unload_game(); // Free up the state. - if (state != NULL) { - free(state); - state = NULL; + if (state == NULL) { + return; } + + free(state); + state = NULL; } /** @@ -1082,12 +1086,12 @@ RETRO_API bool retro_load_game(const struct retro_game_info *info) */ RETRO_API void retro_unload_game(void) { - if (state != NULL) { - if (state->tic != NULL) { - tic80_delete(state->tic); - state->tic = NULL; - } + if (state == NULL || state->tic == NULL) { + return; } + + tic80_delete(state->tic); + state->tic = NULL; } /**