Skip to content

Commit

Permalink
libretro: Update the libretro state values
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed May 19, 2024
1 parent 48005e6 commit 87fa23d
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/system/libretro/tic80_libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 87fa23d

Please sign in to comment.