mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2026-04-28 05:01:39 +00:00
General code cleanup for reset button implementation
This commit is contained in:
parent
5b0578dd87
commit
cdaae070d5
7 changed files with 22 additions and 21 deletions
|
|
@ -14,25 +14,12 @@
|
||||||
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
|
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
void do_reset_game(GameState* this) {
|
|
||||||
PlayState* play = (PlayState*)this;
|
|
||||||
gSaveContext.gameMode = GAMEMODE_OWL_SAVE;
|
|
||||||
play->transitionTrigger = TRANS_TRIGGER_START;
|
|
||||||
play->transitionType = TRANS_TYPE_FADE_BLACK;
|
|
||||||
play->nextEntrance = ENTRANCE(CUTSCENE, 0);
|
|
||||||
gSaveContext.save.cutsceneIndex = 0;
|
|
||||||
gSaveContext.sceneLayer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
RECOMP_PATCH void GameState_Update(GameState* gameState) {
|
RECOMP_PATCH void GameState_Update(GameState* gameState) {
|
||||||
GraphicsContext* gfxCtx = gameState->gfxCtx;
|
GraphicsContext* gfxCtx = gameState->gfxCtx;
|
||||||
|
|
||||||
GameState_SetFrameBuffer(gameState->gfxCtx);
|
GameState_SetFrameBuffer(gameState->gfxCtx);
|
||||||
|
|
||||||
if (recomp_should_reset_game()) {
|
|
||||||
do_reset_game(gameState);
|
|
||||||
}
|
|
||||||
|
|
||||||
gameState->main(gameState);
|
gameState->main(gameState);
|
||||||
|
|
||||||
if (R_PAUSE_BG_PRERENDER_STATE != PAUSE_BG_PRERENDER_PROCESS) {
|
if (R_PAUSE_BG_PRERENDER_STATE != PAUSE_BG_PRERENDER_PROCESS) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,5 @@
|
||||||
#include "patches.h"
|
#include "patches.h"
|
||||||
#include "patch_helpers.h"
|
#include "patch_helpers.h"
|
||||||
|
|
||||||
DECLARE_FUNC(bool, recomp_should_reset_game);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,15 @@ RECOMP_DECLARE_EVENT(recomp_on_play_main(PlayState* play));
|
||||||
RECOMP_DECLARE_EVENT(recomp_on_play_update(PlayState* play));
|
RECOMP_DECLARE_EVENT(recomp_on_play_update(PlayState* play));
|
||||||
RECOMP_DECLARE_EVENT(recomp_after_play_update(PlayState* play));
|
RECOMP_DECLARE_EVENT(recomp_after_play_update(PlayState* play));
|
||||||
|
|
||||||
|
void do_reset_game(PlayState* play) {
|
||||||
|
gSaveContext.gameMode = GAMEMODE_OWL_SAVE;
|
||||||
|
play->transitionTrigger = TRANS_TRIGGER_START;
|
||||||
|
play->transitionType = TRANS_TYPE_FADE_BLACK;
|
||||||
|
play->nextEntrance = ENTRANCE(CUTSCENE, 0);
|
||||||
|
gSaveContext.save.cutsceneIndex = 0;
|
||||||
|
gSaveContext.sceneLayer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void controls_play_update(PlayState* play) {
|
void controls_play_update(PlayState* play) {
|
||||||
gSaveContext.options.zTargetSetting = recomp_get_targeting_mode();
|
gSaveContext.options.zTargetSetting = recomp_get_targeting_mode();
|
||||||
}
|
}
|
||||||
|
|
@ -42,6 +51,11 @@ RECOMP_PATCH void Play_Main(GameState* thisx) {
|
||||||
static Input* prevInput = NULL;
|
static Input* prevInput = NULL;
|
||||||
PlayState* this = (PlayState*)thisx;
|
PlayState* this = (PlayState*)thisx;
|
||||||
|
|
||||||
|
if (recomp_should_reset_game()) {
|
||||||
|
do_reset_game(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// @recomp_event recomp_on_play_main(PlayState* play): Allow mods to execute code every frame.
|
// @recomp_event recomp_on_play_main(PlayState* play): Allow mods to execute code every frame.
|
||||||
recomp_on_play_main(this);
|
recomp_on_play_main(this);
|
||||||
|
|
||||||
|
|
@ -177,6 +191,7 @@ RECOMP_PATCH void Play_Init(GameState* thisx) {
|
||||||
recomp_on_play_init(this);
|
recomp_on_play_init(this);
|
||||||
recomp_set_reset_button_visibility(1);
|
recomp_set_reset_button_visibility(1);
|
||||||
|
|
||||||
|
|
||||||
if ((gSaveContext.respawnFlag == -4) || (gSaveContext.respawnFlag == -0x63)) {
|
if ((gSaveContext.respawnFlag == -4) || (gSaveContext.respawnFlag == -0x63)) {
|
||||||
if (CHECK_EVENTINF(EVENTINF_TRIGGER_DAYTELOP)) {
|
if (CHECK_EVENTINF(EVENTINF_TRIGGER_DAYTELOP)) {
|
||||||
CLEAR_EVENTINF(EVENTINF_TRIGGER_DAYTELOP);
|
CLEAR_EVENTINF(EVENTINF_TRIGGER_DAYTELOP);
|
||||||
|
|
@ -444,9 +459,11 @@ RECOMP_PATCH void Play_Init(GameState* thisx) {
|
||||||
recomp_after_play_init(this);
|
recomp_after_play_init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Play_ClearTransition(PlayState* this);
|
void Play_ClearTransition(PlayState* this);
|
||||||
void Play_DestroyMotionBlur(void);
|
void Play_DestroyMotionBlur(void);
|
||||||
void ZeldaArena_Cleanup();
|
void ZeldaArena_Cleanup();
|
||||||
|
|
||||||
RECOMP_PATCH void Play_Destroy(GameState* thisx) {
|
RECOMP_PATCH void Play_Destroy(GameState* thisx) {
|
||||||
PlayState* this = (PlayState*)thisx;
|
PlayState* this = (PlayState*)thisx;
|
||||||
GraphicsContext* gfxCtx = this->state.gfxCtx;
|
GraphicsContext* gfxCtx = this->state.gfxCtx;
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,6 @@ void matrix_play_update(PlayState* play);
|
||||||
void autosave_post_play_update(PlayState* play);
|
void autosave_post_play_update(PlayState* play);
|
||||||
|
|
||||||
DECLARE_FUNC(void, recomp_set_reset_button_visibility, u8 visibility);
|
DECLARE_FUNC(void, recomp_set_reset_button_visibility, u8 visibility);
|
||||||
|
DECLARE_FUNC(bool, recomp_should_reset_game);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -175,14 +175,12 @@ extern "C" void recomp_set_right_analog_suppressed(uint8_t* rdram, recomp_contex
|
||||||
recomp::set_right_analog_suppressed(suppressed);
|
recomp::set_right_analog_suppressed(suppressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" void recomp_should_reset_game(uint8_t* rdram, recomp_context* ctx) {
|
extern "C" void recomp_should_reset_game(uint8_t* rdram, recomp_context* ctx) {
|
||||||
_return(ctx, should_game_reset.exchange(0x00));
|
_return(ctx, should_game_reset.exchange(0x00));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void recomp_set_reset_button_visibility(uint8_t* rdram, recomp_context* ctx) {
|
extern "C" void recomp_set_reset_button_visibility(uint8_t* rdram, recomp_context* ctx) {
|
||||||
uint8_t storeVal = _arg<0, uint8_t>(rdram, ctx);
|
uint8_t storeVal = _arg<0, uint8_t>(rdram, ctx);
|
||||||
std::cout << "Reset Button Visibility: " << std::to_string(storeVal) << "\n";
|
|
||||||
zelda64::set_reset_button_visibility((bool)storeVal);
|
zelda64::set_reset_button_visibility((bool)storeVal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <iostream>
|
||||||
#include "recomp_ui.h"
|
#include "recomp_ui.h"
|
||||||
#include "recomp_input.h"
|
#include "recomp_input.h"
|
||||||
#include "zelda_sound.h"
|
#include "zelda_sound.h"
|
||||||
|
|
@ -1049,10 +1050,11 @@ public:
|
||||||
throw std::runtime_error("Failed to make RmlUi data model for the game reset button");
|
throw std::runtime_error("Failed to make RmlUi data model for the game reset button");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind the debug mode enabled flag.
|
// Bind the reset button visibility flag.
|
||||||
|
|
||||||
reset_game_model_handle = constructor.GetModelHandle();
|
reset_game_model_handle = constructor.GetModelHandle();
|
||||||
|
|
||||||
|
// Ensuring the flag is set to false on startup.
|
||||||
|
reset_game_context.reset_button_visibility.store(false);
|
||||||
bind_atomic(constructor, reset_game_model_handle, "reset_button_visibility", &reset_game_context.reset_button_visibility);
|
bind_atomic(constructor, reset_game_model_handle, "reset_button_visibility", &reset_game_context.reset_button_visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
@ -16,7 +15,6 @@
|
||||||
#include "recomp_input.h"
|
#include "recomp_input.h"
|
||||||
#include "librecomp/game.hpp"
|
#include "librecomp/game.hpp"
|
||||||
#include "zelda_config.h"
|
#include "zelda_config.h"
|
||||||
#include "zelda_game.h"
|
|
||||||
#include "ui_rml_hacks.hpp"
|
#include "ui_rml_hacks.hpp"
|
||||||
|
|
||||||
#include "concurrentqueue.h"
|
#include "concurrentqueue.h"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue