diff --git a/include/zelda_game.h b/include/zelda_game.h index 16be35d..1e4f395 100644 --- a/include/zelda_game.h +++ b/include/zelda_game.h @@ -6,7 +6,7 @@ namespace zelda64 { //void quicksave_save(); //void quicksave_load(); - extern bool should_game_reset; + void enqueue_game_reset(); }; #endif diff --git a/src/game/recomp_api.cpp b/src/game/recomp_api.cpp index 3b0da56..b9d16ed 100644 --- a/src/game/recomp_api.cpp +++ b/src/game/recomp_api.cpp @@ -15,8 +15,10 @@ #include "ultramodern/ultramodern.hpp" #include "ultramodern/config.hpp" -namespace zelda64 { - bool should_game_reset; +static std::atomic should_game_reset = 0x00; + +void zelda64::enqueue_game_reset() { + should_game_reset.store(0x01); } extern "C" void recomp_update_inputs(uint8_t* rdram, recomp_context* ctx) { @@ -174,8 +176,5 @@ extern "C" void recomp_set_right_analog_suppressed(uint8_t* rdram, recomp_contex extern "C" void recomp_should_reset_game(uint8_t* rdram, recomp_context* ctx) { - bool retVal = zelda64::should_game_reset; - zelda64::should_game_reset = false; - - _return(ctx, retVal); + _return(ctx, should_game_reset.exchange(0x00)); } \ No newline at end of file diff --git a/src/ui/ui_config.cpp b/src/ui/ui_config.cpp index 93292bb..abf9923 100644 --- a/src/ui/ui_config.cpp +++ b/src/ui/ui_config.cpp @@ -287,7 +287,7 @@ void zelda64::open_reset_game_prompt() { "Quit", "Cancel", []() { - should_game_reset = true; + zelda64::enqueue_game_reset(); close_config_menu(); }, []() {},