Relocated reset code to allow reset any time, not just in-game.

This commit is contained in:
LT-Schmiddy 2024-11-24 16:37:23 -05:00
parent 0076632916
commit 09e4c8e217
4 changed files with 53 additions and 17 deletions

43
patches/game_patches.c Normal file
View File

@ -0,0 +1,43 @@
#include "game_patches.h"
#include "global.h"
#include "audiomgr.h"
#include "idle.h"
#include "sys_cfb.h"
#include "libc64/malloc.h"
#include "z64debug_text.h"
#include "z64rumble.h"
#include "z64speed_meter.h"
#include "z64vimode.h"
#include "z64viscvg.h"
#include "z64vismono.h"
#include "z64viszbuf.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.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) {
GraphicsContext* gfxCtx = gameState->gfxCtx;
GameState_SetFrameBuffer(gameState->gfxCtx);
if (recomp_should_reset_game()) {
do_reset_game(gameState);
}
gameState->main(gameState);
if (R_PAUSE_BG_PRERENDER_STATE != PAUSE_BG_PRERENDER_PROCESS) {
GameState_Draw(gameState, gfxCtx);
GameState_DrawEnd(gfxCtx);
}
}

10
patches/game_patches.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef __PLAY_PATCHES_H__
#define __PLAY_PATCHES_H__
#include "patches.h"
#include "patch_helpers.h"
DECLARE_FUNC(bool, recomp_should_reset_game);
#endif

View File

@ -40,24 +40,11 @@ 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* 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;
}
// @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_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);

View File

@ -4,8 +4,6 @@
#include "patches.h" #include "patches.h"
#include "patch_helpers.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);
void camera_post_play_update(PlayState* play); void camera_post_play_update(PlayState* play);
@ -14,6 +12,4 @@ 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