2024-03-03 04:23:29 +00:00
|
|
|
#include "play_patches.h"
|
|
|
|
#include "z64debug_display.h"
|
2024-03-04 07:13:12 +00:00
|
|
|
#include "input.h"
|
2024-03-03 04:23:29 +00:00
|
|
|
|
|
|
|
extern Input D_801F6C18;
|
|
|
|
|
2024-09-26 01:07:55 +00:00
|
|
|
RECOMP_DECLARE_EVENT(recomp_on_init(PlayState* play));
|
2024-09-02 16:01:22 +00:00
|
|
|
RECOMP_DECLARE_EVENT(recomp_on_play_main(PlayState* play));
|
|
|
|
RECOMP_DECLARE_EVENT(recomp_before_play_update(PlayState* play));
|
|
|
|
RECOMP_DECLARE_EVENT(recomp_after_play_update(PlayState* play));
|
|
|
|
|
2024-03-04 07:13:12 +00:00
|
|
|
void controls_play_update(PlayState* play) {
|
|
|
|
gSaveContext.options.zTargetSetting = recomp_get_targeting_mode();
|
|
|
|
}
|
|
|
|
|
2024-09-26 01:07:55 +00:00
|
|
|
bool inited = false;
|
|
|
|
|
2024-03-03 04:23:29 +00:00
|
|
|
// @recomp Patched to add hooks for various added functionality.
|
2024-07-26 02:17:00 +00:00
|
|
|
RECOMP_PATCH void Play_Main(GameState* thisx) {
|
2024-03-03 04:23:29 +00:00
|
|
|
static Input* prevInput = NULL;
|
|
|
|
PlayState* this = (PlayState*)thisx;
|
2024-09-26 01:07:55 +00:00
|
|
|
|
|
|
|
if (!inited) {
|
|
|
|
recomp_on_init(this);
|
|
|
|
inited = true;
|
|
|
|
}
|
|
|
|
|
2024-09-02 16:01:22 +00:00
|
|
|
recomp_on_play_main(this);
|
2024-03-03 04:23:29 +00:00
|
|
|
|
|
|
|
// @recomp
|
|
|
|
debug_play_update(this);
|
2024-03-04 07:13:12 +00:00
|
|
|
controls_play_update(this);
|
2024-05-26 13:34:26 +00:00
|
|
|
analog_cam_pre_play_update(this);
|
2024-04-01 03:12:22 +00:00
|
|
|
matrix_play_update(this);
|
2024-03-03 04:23:29 +00:00
|
|
|
|
|
|
|
// @recomp avoid unused variable warning
|
|
|
|
(void)prevInput;
|
|
|
|
|
|
|
|
prevInput = CONTROLLER1(&this->state);
|
|
|
|
DebugDisplay_Init();
|
|
|
|
|
|
|
|
{
|
|
|
|
GraphicsContext* gfxCtx = this->state.gfxCtx;
|
|
|
|
|
|
|
|
if (1) {
|
|
|
|
this->state.gfxCtx = NULL;
|
|
|
|
}
|
|
|
|
camera_pre_play_update(this);
|
2024-09-02 16:01:22 +00:00
|
|
|
recomp_before_play_update(this);
|
2024-03-03 04:23:29 +00:00
|
|
|
Play_Update(this);
|
2024-09-02 16:01:22 +00:00
|
|
|
recomp_after_play_update(this);
|
2024-03-03 04:23:29 +00:00
|
|
|
camera_post_play_update(this);
|
2024-05-26 13:34:26 +00:00
|
|
|
analog_cam_post_play_update(this);
|
2024-05-01 08:06:53 +00:00
|
|
|
autosave_post_play_update(this);
|
2024-03-03 04:23:29 +00:00
|
|
|
this->state.gfxCtx = gfxCtx;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Input input = *CONTROLLER1(&this->state);
|
|
|
|
|
|
|
|
if (1) {
|
|
|
|
*CONTROLLER1(&this->state) = D_801F6C18;
|
|
|
|
}
|
|
|
|
Play_Draw(this);
|
|
|
|
*CONTROLLER1(&this->state) = input;
|
|
|
|
}
|
|
|
|
|
|
|
|
CutsceneManager_Update();
|
|
|
|
CutsceneManager_ClearWaiting();
|
|
|
|
}
|
2024-03-28 04:35:10 +00:00
|
|
|
|
|
|
|
// @recomp Patched to add load a hook for loading rooms.
|
2024-07-26 02:17:00 +00:00
|
|
|
RECOMP_PATCH s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) {
|
2024-03-28 04:35:10 +00:00
|
|
|
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;
|
|
|
|
}
|