Attempts to reset majora's mask internally. Not working yet.

This commit is contained in:
LT_Schmiddy (Alex Schmid) 2024-11-20 16:25:10 -05:00
parent 0d0f64e32f
commit 6586a869cc
7 changed files with 64 additions and 0 deletions

View File

@ -73,6 +73,13 @@
</panel> </panel>
</tabset> </tabset>
<div class="config__icon-buttons"> <div class="config__icon-buttons">
<button
class="icon-button"
onclick="open_reset_game_prompt"
id="config__reset_game-button"
>
<svg src="icons/Reset.svg" />
</button>
<button <button
class="icon-button" class="icon-button"
onclick="open_quit_game_prompt" onclick="open_quit_game_prompt"

View File

@ -88,6 +88,9 @@ namespace zelda64 {
void set_analog_cam_mode(AnalogCamMode mode); void set_analog_cam_mode(AnalogCamMode mode);
void open_quit_game_prompt(); void open_quit_game_prompt();
void open_reset_game_prompt();
extern bool should_game_reset;
}; };
#endif #endif

View File

@ -1,6 +1,10 @@
#include "play_patches.h" #include "play_patches.h"
#include "z64debug_display.h" #include "z64debug_display.h"
#include "input.h" #include "input.h"
#include "input.h"
#include "z64game.h"
#include "overlays/gamestates/ovl_title/z_title.h"
extern Input D_801F6C18; extern Input D_801F6C18;
@ -8,11 +12,20 @@ void controls_play_update(PlayState* play) {
gSaveContext.options.zTargetSetting = recomp_get_targeting_mode(); gSaveContext.options.zTargetSetting = recomp_get_targeting_mode();
} }
void do_reset_game(PlayState* this) {
STOP_GAMESTATE(&this->state);
SET_NEXT_GAMESTATE(&this->state, ConsoleLogo_Init, sizeof(ConsoleLogoState));
}
// @recomp Patched to add hooks for various added functionality. // @recomp Patched to add hooks for various added functionality.
RECOMP_PATCH void Play_Main(GameState* thisx) { 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 // @recomp
debug_play_update(this); debug_play_update(this);
controls_play_update(this); controls_play_update(this);

View File

@ -2,6 +2,9 @@
#define __PLAY_PATCHES_H__ #define __PLAY_PATCHES_H__
#include "patches.h" #include "patches.h"
#include "patch_helpers.h"
DECLARE_FUNC(bool, recomp_should_reset_game);
void debug_play_update(PlayState* play); void debug_play_update(PlayState* play);
void camera_pre_play_update(PlayState* play); void camera_pre_play_update(PlayState* play);
@ -11,4 +14,6 @@ void analog_cam_post_play_update(PlayState* play);
void matrix_play_update(PlayState* play); void matrix_play_update(PlayState* play);
void autosave_post_play_update(PlayState* play); void autosave_post_play_update(PlayState* play);
#endif #endif

View File

@ -44,3 +44,4 @@ recomp_get_inverted_axes = 0x8F0000A4;
recomp_high_precision_fb_enabled = 0x8F0000A8; recomp_high_precision_fb_enabled = 0x8F0000A8;
recomp_get_resolution_scale = 0x8F0000AC; recomp_get_resolution_scale = 0x8F0000AC;
recomp_get_analog_inverted_axes = 0x8F0000B0; recomp_get_analog_inverted_axes = 0x8F0000B0;
recomp_should_reset_game = 0x8F0000B4;

View File

@ -166,3 +166,11 @@ 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) {
bool retVal = zelda64::should_game_reset;
zelda64::should_game_reset = false;
_return(ctx, retVal);
}

View File

@ -161,6 +161,11 @@ static bool sample_positions_supported = false;
static bool cont_active = true; static bool cont_active = true;
namespace zelda64 {
bool should_game_reset;
}
static recomp::InputDevice cur_device = recomp::InputDevice::Controller; static recomp::InputDevice cur_device = recomp::InputDevice::Controller;
int recomp::get_scanned_input_index() { int recomp::get_scanned_input_index() {
@ -279,6 +284,23 @@ void zelda64::open_quit_game_prompt() {
); );
} }
void zelda64::open_reset_game_prompt() {
prompt_context.open_prompt(
"Return to the main menu?",
"Any progress since your last save will be lost.",
"Quit",
"Cancel",
[]() {
should_game_reset = true;
},
[]() {},
recompui::ButtonVariant::Error,
recompui::ButtonVariant::Tertiary,
true,
"config__quit-game-button"
);
}
// These defaults values don't matter, as the config file handling overrides them. // These defaults values don't matter, as the config file handling overrides them.
struct ControlOptionsContext { struct ControlOptionsContext {
int rumble_strength; // 0 to 100 int rumble_strength; // 0 to 100
@ -559,6 +581,11 @@ public:
zelda64::open_quit_game_prompt(); zelda64::open_quit_game_prompt();
}); });
recompui::register_event(listener, "open_reset_game_prompt",
[](const std::string& param, Rml::Event& event) {
zelda64::open_reset_game_prompt();
});
recompui::register_event(listener, "toggle_input_device", recompui::register_event(listener, "toggle_input_device",
[](const std::string& param, Rml::Event& event) { [](const std::string& param, Rml::Event& event) {
cur_device = cur_device == recomp::InputDevice::Controller cur_device = cur_device == recomp::InputDevice::Controller