From 3cda5a175d44dbb5e12ceedc92e30c5c790b7f8c Mon Sep 17 00:00:00 2001 From: Alejandro Javier Asenjo Nitti Date: Sun, 5 Nov 2023 18:52:03 -0300 Subject: match Play_UpdateMain & Play_DrawMain --- src/code/z_camera.c | 15 +++++-------- src/code/z_play.c | 61 ++++++++++++++++++++++------------------------------- 2 files changed, 30 insertions(+), 46 deletions(-) (limited to 'src/code') diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 49c31864b..b3fc36325 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -7366,7 +7366,7 @@ s32 Camera_RequestGiantsMaskSetting(Camera* camera) { } } -Vec3s* Camera_Update(Vec3s* inputDir, Camera* camera) { +Vec3s Camera_Update(Camera* camera) { Vec3f viewAt; Vec3f viewEye; Vec3f viewUp; @@ -7390,8 +7390,7 @@ Vec3s* Camera_Update(Vec3s* inputDir, Camera* camera) { // Camera of status CUT only updates to this point if (camera->status == CAM_STATUS_CUT) { - *inputDir = camera->inputDir; - return inputDir; + return camera->inputDir; } sUpdateCameraDirection = false; @@ -7535,8 +7534,7 @@ Vec3s* Camera_Update(Vec3s* inputDir, Camera* camera) { // Camera of status WAIT only updates to this point if (camera->status == CAM_STATUS_WAIT) { - *inputDir = camera->inputDir; - return inputDir; + return camera->inputDir; } camera->behaviorFlags = 0; @@ -7566,8 +7564,7 @@ Vec3s* Camera_Update(Vec3s* inputDir, Camera* camera) { // Camera of status UNK3 only updates to this point if (camera->status == CAM_STATUS_UNK3) { - *inputDir = camera->inputDir; - return inputDir; + return camera->inputDir; } /** @@ -7625,9 +7622,7 @@ Vec3s* Camera_Update(Vec3s* inputDir, Camera* camera) { camera->inputDir.z = 0; } - *inputDir = camera->inputDir; - - return inputDir; + return camera->inputDir; } s32 func_800DF498(Camera* camera) { diff --git a/src/code/z_play.c b/src/code/z_play.c index 3646d4e3e..4e3ace87e 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -915,12 +915,11 @@ const char D_801DFA34[][4] = { "h", "i", "f", "fa", "fb", "fc", "fd", "fe", "ff", "fg", "fh", "fi", "fj", "fk", }; -#ifdef NON_MATCHING -// Stack issues void Play_UpdateMain(PlayState* this) { + s32 pad; Input* input = this->state.input; - u8 freezeFlashTimer; s32 sp5C = false; + u8 freezeFlashTimer; gSegments[4] = OS_K0_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment); gSegments[5] = OS_K0_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment); @@ -932,6 +931,7 @@ void Play_UpdateMain(PlayState* this) { Play_TakePictoPhoto(&this->pauseBgPreRender); R_PICTO_PHOTO_STATE = PICTO_PHOTO_STATE_OFF; } + Actor_SetMovementScale(this->state.framerateDivisor); if (FrameAdvance_Update(&this->frameAdvCtx, &input[1])) { @@ -959,26 +959,28 @@ void Play_UpdateMain(PlayState* this) { break; } } + Play_UpdateTransition(this); + if (gTransitionTileState != TRANS_TILE_READY) { - if ((gSaveContext.gameMode == GAMEMODE_NORMAL) && - (((this->msgCtx.msgMode == MSGMODE_NONE)) || - ((this->msgCtx.currentTextId == 0xFF) && (this->msgCtx.msgMode == MSGMODE_TEXT_DONE) && - (this->msgCtx.textboxEndType == TEXTBOX_ENDTYPE_41)) || - ((this->msgCtx.currentTextId >= 0x100) && (this->msgCtx.currentTextId <= 0x200))) && + if (((gSaveContext.gameMode == GAMEMODE_NORMAL) && + (((this->msgCtx.msgMode == MSGMODE_NONE) || + (((this->msgCtx.currentTextId == 0xFF) && (this->msgCtx.msgMode == MSGMODE_TEXT_DONE)) && + (this->msgCtx.textboxEndType == TEXTBOX_ENDTYPE_41))) || + ((this->msgCtx.currentTextId >= 0x100) && (this->msgCtx.currentTextId <= 0x200)))) && (this->gameOverCtx.state == GAMEOVER_INACTIVE)) { KaleidoSetup_Update(this); } sp5C = (this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE); - AnimationContext_Reset(&this->animationCtx); Object_UpdateEntries(&this->objectCtx); if (!sp5C && (IREG(72) == 0)) { this->gameplayFrames++; Rumble_SetUpdateEnabled(true); - if ((this->actorCtx.freezeFlashTimer != 0) && (this->actorCtx.freezeFlashTimer-- < 5)) { + + if ((this->actorCtx.freezeFlashTimer != 0) && ((this->actorCtx.freezeFlashTimer--) < 5)) { freezeFlashTimer = this->actorCtx.freezeFlashTimer; if ((freezeFlashTimer > 0) && ((freezeFlashTimer % 2) != 0)) { this->envCtx.fillScreen = true; @@ -1026,17 +1028,16 @@ void Play_UpdateMain(PlayState* this) { } } - if (!sp5C || gDbgCamEnabled) { - s32 sp54; // camId - Vec3s sp48; // InputDir + if ((!sp5C) || gDbgCamEnabled) { + s32 i; this->nextCamera = this->activeCamId; - for (sp54 = 0; sp54 < 4; sp54++) { - if ((sp54 != this->nextCamera) && (this->cameraPtrs[sp54] != NULL)) { - Camera_Update(&sp48, this->cameraPtrs[sp54]); + for (i = 0; i < 4; i++) { + if ((i != this->nextCamera) && (this->cameraPtrs[i] != NULL)) { + Camera_Update(this->cameraPtrs[i]); } } - Camera_Update(&sp48, this->cameraPtrs[this->nextCamera]); + Camera_Update(this->cameraPtrs[this->nextCamera]); } if (!sp5C) { @@ -1055,10 +1056,6 @@ void Play_UpdateMain(PlayState* this) { } } } -#else -void Play_UpdateMain(PlayState* this); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_UpdateMain.s") -#endif void Play_Update(PlayState* this) { if (!sBombersNotebookOpen) { @@ -1128,13 +1125,12 @@ void Play_PostWorldDraw(PlayState* this) { } } -#ifdef NON_MATCHING -// Something weird going on with the stack of the unused arg0 of `Camera_Update` void Play_DrawMain(PlayState* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; Lights* sp268; - Vec3f sp25C; + Vec3f temp; u8 sp25B = false; + f32 var_fv0; // zFar if (R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_UNK4) { PreRender_ApplyFiltersSlowlyDestroy(&this->pauseBgPreRender); @@ -1171,7 +1167,6 @@ void Play_DrawMain(PlayState* this) { gSPSegment(OVERLAY_DISP++, 0x02, this->sceneSegment); if (1) { - f32 var_fv0; // zFar ShrinkWindow_Draw(gfxCtx); @@ -1340,10 +1335,10 @@ void Play_DrawMain(PlayState* this) { if (1) { if (!this->envCtx.sunDisabled) { - sp25C.x = this->view.eye.x + this->envCtx.sunPos.x; - sp25C.y = this->view.eye.y + this->envCtx.sunPos.y; - sp25C.z = this->view.eye.z + this->envCtx.sunPos.z; - Environment_DrawSunLensFlare(this, &this->envCtx, &this->view, gfxCtx, sp25C); + temp.x = this->view.eye.x + this->envCtx.sunPos.x; + temp.y = this->view.eye.y + this->envCtx.sunPos.y; + temp.z = this->view.eye.z + this->envCtx.sunPos.z; + Environment_DrawSunLensFlare(this, &this->envCtx, &this->view, gfxCtx, temp); } Environment_DrawCustomLensFlare(this); @@ -1430,9 +1425,7 @@ void Play_DrawMain(PlayState* this) { SkipPostWorldDraw: if ((this->view.unk164 != 0) && !gDbgCamEnabled) { - Vec3s sp4C; - - Camera_Update(&sp4C, GET_ACTIVE_CAM(this)); + Camera_Update(GET_ACTIVE_CAM(this)); View_UpdateViewingMatrix(&this->view); this->view.unk164 = 0; if ((this->skyboxId != SKYBOX_NONE) && !this->envCtx.skyboxDisabled) { @@ -1446,10 +1439,6 @@ SkipPostWorldDraw: CLOSE_DISPS(gfxCtx); } -#else -void Play_DrawMain(PlayState* this); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_DrawMain.s") -#endif void Play_Draw(PlayState* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; -- cgit v1.2.3