Patched branch commands on Clock Town geometry in Termina field to fix force branch issue

This commit is contained in:
Mr-Wiseguy 2024-03-28 00:35:10 -04:00
parent 7ff1c194e0
commit 751fccb896
3 changed files with 62 additions and 0 deletions

View File

@ -51,6 +51,7 @@ void View_ApplyInterpolate(View* view, s32 mask, bool reset_interpolation_state)
void set_camera_skipped(bool skipped);
void clear_camera_skipped();
bool camera_was_skipped();
void room_load_hook(PlayState* play, Room* room);
void recomp_crash(const char* err);

View File

@ -48,3 +48,34 @@ void Play_Main(GameState* thisx) {
CutsceneManager_Update();
CutsceneManager_ClearWaiting();
}
// @recomp Patched to add load a hook for loading rooms.
s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) {
if (roomCtx->status == 1) {
if (osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) {
roomCtx->status = 0;
roomCtx->curRoom.segment = roomCtx->activeRoomVram;
gSegments[3] = OS_K0_TO_PHYSICAL(roomCtx->activeRoomVram);
// @recomp Call the room load hook.
room_load_hook(play, &roomCtx->curRoom);
Scene_ExecuteCommands(play, roomCtx->curRoom.segment);
func_80123140(play, GET_PLAYER(play));
Actor_SpawnTransitionActors(play, &play->actorCtx);
if (((play->sceneId != SCENE_IKANA) || (roomCtx->curRoom.num != 1)) && (play->sceneId != SCENE_IKNINSIDE)) {
play->envCtx.lightSettingOverride = LIGHT_SETTING_OVERRIDE_NONE;
play->envCtx.lightBlendOverride = LIGHT_BLEND_OVERRIDE_NONE;
}
func_800FEAB0();
if (Environment_GetStormState(play) == STORM_STATE_OFF) {
Environment_StopStormNatureAmbience(play);
}
} else {
return 0;
}
}
return 1;
}

30
patches/room_patches.c Normal file
View File

@ -0,0 +1,30 @@
#include "patches.h"
void room_load_hook(PlayState* play, Room* room) {
if (play->sceneId == SCENE_00KEIKOKU && room->num == 0) {
// Patch the branch commands that cause Clock Town geometry to disappear when forcing gbi branches.
extern Gfx Z2_00KEIKOKU_room_00DL_00D490[];
extern Gfx Z2_00KEIKOKU_room_00DL_00CD70[];
extern Gfx Z2_00KEIKOKU_room_00DL_00D9C8[];
Gfx* command = (Gfx*)SEGMENTED_TO_K0(Z2_00KEIKOKU_room_00DL_00D490 + 1);
if ((command[0].words.w0 >> 24) == G_RDPHALF_1 && (command[1].words.w0 >> 24) == G_BRANCH_Z) {
gSPNoOp(command + 0);
gSPNoOp(command + 1);
}
command = (Gfx*)SEGMENTED_TO_K0(Z2_00KEIKOKU_room_00DL_00CD70 + 1);
if ((command[0].words.w0 >> 24) == G_RDPHALF_1 && (command[1].words.w0 >> 24) == G_BRANCH_Z) {
gSPNoOp(command + 0);
gSPNoOp(command + 1);
}
command = (Gfx*)SEGMENTED_TO_K0(Z2_00KEIKOKU_room_00DL_00D9C8 + 1);
if ((command[0].words.w0 >> 24) == G_RDPHALF_1 && (command[1].words.w0 >> 24) == G_BRANCH_Z) {
gSPNoOp(command + 0);
gSPNoOp(command + 1);
}
}
}