From 8673cbe6776e0ccf3ae12b915a3941a12ad769e2 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 20 Aug 2022 11:21:40 -0400 Subject: [PATCH 1/5] cleanup Play_Update --- include/functions.h | 12 ++-- include/z64.h | 12 +++- src/code/z_kankyo.c | 2 +- src/code/z_parameter.c | 2 +- src/code/z_play.c | 112 ++++++++++++++++++--------------- tools/disasm/functions.txt | 4 +- tools/sizes/code_functions.csv | 4 +- 7 files changed, 85 insertions(+), 63 deletions(-) diff --git a/include/functions.h b/include/functions.h index 55c8d46106..e266f3938e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1450,7 +1450,9 @@ void func_800F6FF8(PlayState* play, EnvironmentContext* envCtx, LightContext* li // void func_800F88C4(void); // void func_800F8970(void); // void func_800F8A9C(void); -// void func_800F8CD4(PlayState* play, EnvironmentContext* envCtx, LightContext* lightCtx, s32 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContext* lightCtx, + PauseContext* pauseCtx, MessageContext* msgCtx, GameOverContext* gameOverCtx, + GraphicsContext* gfxCtx); // void func_800F8D84(void); // void func_800F9728(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); void func_800F9824(PlayState* play, EnvironmentContext* envCtx, View* view, GraphicsContext* gfxCtx, Vec3f vec, f32 arg5, f32 arg6, s8 arg7, s8 arg8); @@ -1886,7 +1888,7 @@ void Interface_Draw(PlayState* play); // void func_80120F90(void); // void func_80121000(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE1 param_8, UNK_TYPE1 param_9, UNK_TYPE1 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE4 param_13, UNK_TYPE4 param_14); // void func_80121064(void); -// void func_801210E0(void); +void Interface_Update(PlayState* play); void func_80121F94(PlayState* play); void func_80121FC4(PlayState* play); Path* Path_GetByIndex(PlayState* play, s16 index, s16 max); @@ -2499,16 +2501,16 @@ void func_80163D80(TransitionContext* transitionCtx, PlayState* play); // void func_80163DC0(void); // void func_8016418C(void); void TransitionUnk_Destroy(FbDemoStruct* this); -// void TransitionUnk_Init(void); +FbDemoStruct* TransitionUnk_Init(FbDemoStruct* this, s32 row, s32 col); // void func_80164438(void); // void func_8016454C(void); // void func_80164678(void); -// void func_801647AC(void); +void func_801647AC(FbDemoStruct* this); // UNK_TYPE4 func_801647B8(void); // void TransitionFade_Start(void); void* TransitionFade_Init(TransitionFade* arg0); void TransitionFade_Destroy(TransitionFade* arg0); -// void TransitionFade_Update(void); +void TransitionFade_Update(TransitionFade* thisx, s32 updateRate); // void TransitionFade_Draw(void); // void TransitionFade_IsDone(void); void TransitionFade_SetColor(TransitionFade* arg0, u32 color); diff --git a/include/z64.h b/include/z64.h index dcbb359356..e2357794cd 100644 --- a/include/z64.h +++ b/include/z64.h @@ -752,8 +752,8 @@ typedef enum { /* 5 */ TRANS_MODE_FILL_IN, /* 6 */ TRANS_MODE_FILL_OUT, /* 7 */ TRANS_MODE_FILL_BROWN_INIT, - /* 8 */ TRANS_MODE_08, - /* 9 */ TRANS_MODE_09, + /* 8 */ TRANS_MODE_08, // unused + /* 9 */ TRANS_MODE_09, // unused /* 10 */ TRANS_MODE_INSTANT, /* 11 */ TRANS_MODE_INSTANCE_WAIT, /* 12 */ TRANS_MODE_SANDSTORM_INIT, @@ -814,6 +814,14 @@ typedef struct { /* 0x003 */ char unk03[0x5]; /* 0x008 */ s32 instanceData; /* 0x00C */ char unk0C[0x224]; + /* + union { + TransitionFade fade; + TransitionCircle circle; + TransitionTriforce triforce; + TransitionWipe wipe; + } instanceData; + */ /* 0x230 */ void* (*init)(void* transition); /* 0x234 */ void (*destroy)(void* transition); /* 0x238 */ void (*update)(void* transition, s32 updateRate); diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index ad66fe4a18..492eff0c0b 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -42,7 +42,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F8A9C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F8CD4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_Update.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F8D84.s") diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 9bde1cffe2..bffe85d078 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1370,7 +1370,7 @@ u8 D_801BFD94 = 0; s16 D_801BFD98 = 0; s16 D_801BFD9C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801210E0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_Update.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121F94.s") diff --git a/src/code/z_play.c b/src/code/z_play.c index 8e8a545567..da449c324c 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64rumble.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" #include "overlays/gamestates/ovl_opening/z_opening.h" #include "overlays/gamestates/ovl_file_choose/z_file_choose.h" @@ -917,15 +918,8 @@ void Play_UpdateTransition(PlayState* this) { } #ifdef NON_MATCHING -void TransitionFade_Update(TransitionFade*, s32); -void Rumble_SetUpdateEnabled(s32); -void func_800F8CD4(PlayState *, EnvironmentContext *, LightContext *, PauseContext *, MessageContext *, GameOverContext *, GraphicsContext *); -void func_801210E0(PlayState *); -s32 func_801642D8(FbDemoStruct *, s32, s32); -void func_801647AC(FbDemoStruct *); - -void Play_Update(PlayState *play2) { - PlayState* play = play2; +void Play_Update(PlayState* play) { + PlayState* play2 = play; u8 pad60; s32 sp5C = 0; Input* pad58 = play->state.input; @@ -934,53 +928,63 @@ void Play_Update(PlayState *play2) { gSegments[5] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); gSegments[2] = VIRTUAL_TO_PHYSICAL(play->sceneSegment); - if (gGameInfo->data[0xB9] == 2) { - gGameInfo->data[0xB9] = 3; + if (SREG(89) == 2) { + SREG(89) = 3; MsgEvent_SendNullTask(); func_80165E1C(&play->pauseBgPreRender); - gGameInfo->data[0xB9] = 0; + SREG(89) = 0; } Actor_SetMovementScale(play->state.framerateDivisor); - if (FrameAdvance_Update(&play->frameAdvCtx, &pad58[1]) != 0) { - if ((play->transitionMode == 0) && (play->transitionTrigger != 0)) { - play->transitionMode = 1; + if (FrameAdvance_Update(&play->frameAdvCtx, &pad58[1])) { + if ((play->transitionMode == TRANS_MODE_OFF) && (play->transitionTrigger != TRANS_TRIGGER_OFF)) { + play->transitionMode = TRANS_MODE_SETUP; } - switch (D_801F6D10) { - case 0: - break; - case 2: - if (func_801642D8(&D_801F6C30, 0xA, 7) == 0) { - D_801F6D10 = 0; - } else { - D_801F6D0C = gZBufferPtr; - D_801F6D10 = 3; - Game_SetFramerateDivisor(&play->state, 1); - } - break; - case 3: - func_801647AC(&D_801F6C30); - break; + + if (gTrnsnUnkState != 0) { + switch (gTrnsnUnkState) { + case 2: + if (TransitionUnk_Init(&sTrnsnUnk, 10, 7) == NULL) { + gTrnsnUnkState = 0; + } else { + D_801F6D0C = gZBufferPtr; + gTrnsnUnkState = 3; + Game_SetFramerateDivisor(&play->state, 1); + } + break; + case 3: + func_801647AC(&sTrnsnUnk); + break; + } } - func_80166B30(play); - if (D_801F6D10 != 3) { - if ((gSaveContext.gameMode == 0) && (((play->msgCtx.msgMode == 0)) || ((play->msgCtx.currentTextId == 0xFF) && (play->msgCtx.msgMode == 0x42) && (play->msgCtx.unk12020 == 0x41)) || ((play->msgCtx.currentTextId >= 0x100) && ( play->msgCtx.currentTextId < 0x201))) && (play->gameOverCtx.state == 0)) { + Play_UpdateTransition(play); + if (gTrnsnUnkState != 3) { + if ((gSaveContext.gameMode == 0) && + (((play->msgCtx.msgMode == 0)) || + ((play->msgCtx.currentTextId == 0xFF) && (play->msgCtx.msgMode == 0x42) && + (play->msgCtx.unk12020 == 0x41)) || + ((play->msgCtx.currentTextId >= 0x100) && (play->msgCtx.currentTextId < 0x201))) && + (play->gameOverCtx.state == 0)) { KaleidoSetup_Update(play); } + sp5C = (play->pauseCtx.state != 0) || (play->pauseCtx.debugEditor != 0); AnimationContext_Reset(&play->animationCtx); Object_UpdateBank(&play->objectCtx); - if ((sp5C == 0) && (gGameInfo->data[0x3A8] == 0)) { + + if ((sp5C == 0) && (IREG(72) == 0)) { play->gameplayFrames++; - Rumble_SetUpdateEnabled(1); - if((play->actorCtx.freezeFlashTimer != 0) && (play->actorCtx.freezeFlashTimer-- < 5)) { - if ((play->actorCtx.freezeFlashTimer > 0) && (( play->actorCtx.freezeFlashTimer % 2) != 0)) { - play->envCtx.fillScreen = 1; - play->envCtx.screenFillColor[0] = play->envCtx.screenFillColor[1] = play->envCtx.screenFillColor[2] = 150; + Rumble_SetUpdateEnabled(true); + if ((play->actorCtx.freezeFlashTimer != 0) && (play->actorCtx.freezeFlashTimer-- < 5)) { + pad60 = play->actorCtx.freezeFlashTimer; + if ((pad60 > 0) && ((pad60 % 2) != 0)) { + play->envCtx.fillScreen = true; + play->envCtx.screenFillColor[0] = play->envCtx.screenFillColor[1] = + play->envCtx.screenFillColor[2] = 150; play->envCtx.screenFillColor[3] = 80; } else { - play->envCtx.fillScreen = 0; + play->envCtx.fillScreen = false; } } else { Room_HandleLoadCallbacks(play, &play->roomCtx); @@ -998,44 +1002,52 @@ void Play_Update(PlayState *play2) { EffFootmark_Update(play); } } else { - Rumble_SetUpdateEnabled(0); + Rumble_SetUpdateEnabled(false); } + Room_nop8012D510(play, &play->roomCtx.currRoom, &pad58[1], 0); Room_nop8012D510(play, &play->roomCtx.prevRoom, &pad58[1], 1); SkyboxDraw_Noop(&play->skyboxCtx); - if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugEditor != 0)) { + + if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { KaleidoScopeCall_Update(play); } else if (play->gameOverCtx.state != 0) { GameOver_Update(play); } + func_8015680C(play); - func_801210E0(play); + Interface_Update(play); AnimationContext_Update(play, &play->animationCtx); SoundSource_UpdateAll(play); ShrinkWindow_Update(play->state.framerateDivisor); TransitionFade_Update(&play->unk_18E48, play->state.framerateDivisor); } } - if ((sp5C == 0) || (gDbgCamEnabled != 0)) { - s32 sp54; + + if (!sp5C || gDbgCamEnabled) { + s32 sp54; // camId s32 sp50; - Vec3s sp48; + Vec3s sp48; // InputDir play->nextCamera = play->activeCamId; - for(sp54 = 0; sp54 < 4; sp54++) { + for (sp54 = 0; sp54 < 4; sp54++) { if ((sp54 != play->nextCamera) && (play->cameraPtrs[sp54] != NULL)) { Camera_Update(&sp48, play->cameraPtrs[sp54]); } } Camera_Update(&sp48, play->cameraPtrs[play->nextCamera]); } - if (sp5C == 0) { + + if (!sp5C) { func_80166968(play, play->cameraPtrs[play->nextCamera]); Distortion_Update(); } - func_800F8CD4(play, &play->envCtx, &play->lightCtx, &play->pauseCtx, &play->msgCtx, &play->gameOverCtx, play->state.gfxCtx); + + Environment_Update(play, &play->envCtx, &play->lightCtx, &play->pauseCtx, &play->msgCtx, &play->gameOverCtx, + play->state.gfxCtx); + if (play->sramCtx.status != 0) { - if (gSaveContext.save.isOwlSave != 0) { + if (gSaveContext.save.isOwlSave) { func_80147198(&play->sramCtx); } else { func_80147068(&play->sramCtx); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 003057763b..ba741d7707 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1727,7 +1727,7 @@ 0x800F88C4:("func_800F88C4",), 0x800F8970:("func_800F8970",), 0x800F8A9C:("func_800F8A9C",), - 0x800F8CD4:("func_800F8CD4",), + 0x800F8CD4:("Environment_Update",), 0x800F8D84:("func_800F8D84",), 0x800F9728:("func_800F9728",), 0x800F9824:("func_800F9824",), @@ -2164,7 +2164,7 @@ 0x8011F0E0:("Interface_Draw",), 0x80120F90:("func_80120F90",), 0x80121064:("func_80121064",), - 0x801210E0:("func_801210E0",), + 0x801210E0:("Interface_Update",), 0x80121F94:("func_80121F94",), 0x80121FC4:("func_80121FC4",), 0x801224E0:("Path_GetByIndex",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 83e0ca0a08..f1ea540020 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1241,7 +1241,7 @@ asm/non_matchings/code/z_kankyo/func_800F8554.s,func_800F8554,0x800F8554,0xDC asm/non_matchings/code/z_kankyo/func_800F88C4.s,func_800F88C4,0x800F88C4,0x2B asm/non_matchings/code/z_kankyo/func_800F8970.s,func_800F8970,0x800F8970,0x4B asm/non_matchings/code/z_kankyo/func_800F8A9C.s,func_800F8A9C,0x800F8A9C,0x8E -asm/non_matchings/code/z_kankyo/func_800F8CD4.s,func_800F8CD4,0x800F8CD4,0x2C +asm/non_matchings/code/z_kankyo/Environment_Update.s,Environment_Update,0x800F8CD4,0x2C asm/non_matchings/code/z_kankyo/func_800F8D84.s,func_800F8D84,0x800F8D84,0x269 asm/non_matchings/code/z_kankyo/func_800F9728.s,func_800F9728,0x800F9728,0x3F asm/non_matchings/code/z_kankyo/func_800F9824.s,func_800F9824,0x800F9824,0x2DE @@ -1678,7 +1678,7 @@ asm/non_matchings/code/z_parameter/func_8011E730.s,func_8011E730,0x8011E730,0x26 asm/non_matchings/code/z_parameter/Interface_Draw.s,Interface_Draw,0x8011F0E0,0x7AC asm/non_matchings/code/z_parameter/func_80120F90.s,func_80120F90,0x80120F90,0x35 asm/non_matchings/code/z_parameter/func_80121064.s,func_80121064,0x80121064,0x1F -asm/non_matchings/code/z_parameter/func_801210E0.s,func_801210E0,0x801210E0,0x3AD +asm/non_matchings/code/z_parameter/Interface_Update.s,Interface_Update,0x801210E0,0x3AD asm/non_matchings/code/z_parameter/func_80121F94.s,func_80121F94,0x80121F94,0xC asm/non_matchings/code/z_parameter/func_80121FC4.s,func_80121FC4,0x80121FC4,0x147 asm/non_matchings/code/z_path/func_801224E0.s,func_801224E0,0x801224E0,0x11 From 0cebae413eda4dbbe833d51eed4992600576b35f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 20 Aug 2022 11:35:43 -0400 Subject: [PATCH 2/5] more cleanup --- src/code/z_play.c | 163 +++++++++++++++++++++++----------------------- 1 file changed, 82 insertions(+), 81 deletions(-) diff --git a/src/code/z_play.c b/src/code/z_play.c index da449c324c..a0083aea90 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -917,28 +917,29 @@ void Play_UpdateTransition(PlayState* this) { } } +// Stack issues #ifdef NON_MATCHING -void Play_Update(PlayState* play) { - PlayState* play2 = play; +void Play_Update(PlayState* this) { + PlayState* this2 = this; u8 pad60; s32 sp5C = 0; - Input* pad58 = play->state.input; + Input* pad58 = this->state.input; - gSegments[4] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.mainKeepIndex].segment); - gSegments[5] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); - gSegments[2] = VIRTUAL_TO_PHYSICAL(play->sceneSegment); + gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment); if (SREG(89) == 2) { SREG(89) = 3; MsgEvent_SendNullTask(); - func_80165E1C(&play->pauseBgPreRender); + func_80165E1C(&this->pauseBgPreRender); SREG(89) = 0; } - Actor_SetMovementScale(play->state.framerateDivisor); + Actor_SetMovementScale(this->state.framerateDivisor); - if (FrameAdvance_Update(&play->frameAdvCtx, &pad58[1])) { - if ((play->transitionMode == TRANS_MODE_OFF) && (play->transitionTrigger != TRANS_TRIGGER_OFF)) { - play->transitionMode = TRANS_MODE_SETUP; + if (FrameAdvance_Update(&this->frameAdvCtx, &pad58[1])) { + if ((this->transitionMode == TRANS_MODE_OFF) && (this->transitionTrigger != TRANS_TRIGGER_OFF)) { + this->transitionMode = TRANS_MODE_SETUP; } if (gTrnsnUnkState != 0) { @@ -949,7 +950,7 @@ void Play_Update(PlayState* play) { } else { D_801F6D0C = gZBufferPtr; gTrnsnUnkState = 3; - Game_SetFramerateDivisor(&play->state, 1); + Game_SetFramerateDivisor(&this->state, 1); } break; case 3: @@ -957,70 +958,70 @@ void Play_Update(PlayState* play) { break; } } - Play_UpdateTransition(play); + Play_UpdateTransition(this); if (gTrnsnUnkState != 3) { if ((gSaveContext.gameMode == 0) && - (((play->msgCtx.msgMode == 0)) || - ((play->msgCtx.currentTextId == 0xFF) && (play->msgCtx.msgMode == 0x42) && - (play->msgCtx.unk12020 == 0x41)) || - ((play->msgCtx.currentTextId >= 0x100) && (play->msgCtx.currentTextId < 0x201))) && - (play->gameOverCtx.state == 0)) { - KaleidoSetup_Update(play); + (((this->msgCtx.msgMode == 0)) || + ((this->msgCtx.currentTextId == 0xFF) && (this->msgCtx.msgMode == 0x42) && + (this->msgCtx.unk12020 == 0x41)) || + ((this->msgCtx.currentTextId >= 0x100) && (this->msgCtx.currentTextId <= 0x200))) && + (this->gameOverCtx.state == 0)) { + KaleidoSetup_Update(this); } - sp5C = (play->pauseCtx.state != 0) || (play->pauseCtx.debugEditor != 0); + sp5C = (this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE); - AnimationContext_Reset(&play->animationCtx); - Object_UpdateBank(&play->objectCtx); + AnimationContext_Reset(&this->animationCtx); + Object_UpdateBank(&this->objectCtx); if ((sp5C == 0) && (IREG(72) == 0)) { - play->gameplayFrames++; + this->gameplayFrames++; Rumble_SetUpdateEnabled(true); - if ((play->actorCtx.freezeFlashTimer != 0) && (play->actorCtx.freezeFlashTimer-- < 5)) { - pad60 = play->actorCtx.freezeFlashTimer; + if ((this->actorCtx.freezeFlashTimer != 0) && (this->actorCtx.freezeFlashTimer-- < 5)) { + pad60 = this->actorCtx.freezeFlashTimer; if ((pad60 > 0) && ((pad60 % 2) != 0)) { - play->envCtx.fillScreen = true; - play->envCtx.screenFillColor[0] = play->envCtx.screenFillColor[1] = - play->envCtx.screenFillColor[2] = 150; - play->envCtx.screenFillColor[3] = 80; + this->envCtx.fillScreen = true; + this->envCtx.screenFillColor[0] = this->envCtx.screenFillColor[1] = + this->envCtx.screenFillColor[2] = 150; + this->envCtx.screenFillColor[3] = 80; } else { - play->envCtx.fillScreen = false; + this->envCtx.fillScreen = false; } } else { - Room_HandleLoadCallbacks(play, &play->roomCtx); - CollisionCheck_AT(play, &play->colChkCtx); - CollisionCheck_OC(play, &play->colChkCtx); - CollisionCheck_Damage(play, &play->colChkCtx); - CollisionCheck_ClearContext(play, &play->colChkCtx); - if (play->unk_18845 == 0) { - Actor_UpdateAll(play, &play->actorCtx); + Room_HandleLoadCallbacks(this, &this->roomCtx); + CollisionCheck_AT(this, &this->colChkCtx); + CollisionCheck_OC(this, &this->colChkCtx); + CollisionCheck_Damage(this, &this->colChkCtx); + CollisionCheck_ClearContext(this, &this->colChkCtx); + if (this->unk_18845 == 0) { + Actor_UpdateAll(this, &this->actorCtx); } - Cutscene_Update1(play, &play->csCtx); - Cutscene_Update2(play, &play->csCtx); - Effect_UpdateAll(play); - EffectSS_UpdateAllParticles(play); - EffFootmark_Update(play); + Cutscene_Update1(this, &this->csCtx); + Cutscene_Update2(this, &this->csCtx); + Effect_UpdateAll(this); + EffectSS_UpdateAllParticles(this); + EffFootmark_Update(this); } } else { Rumble_SetUpdateEnabled(false); } - Room_nop8012D510(play, &play->roomCtx.currRoom, &pad58[1], 0); - Room_nop8012D510(play, &play->roomCtx.prevRoom, &pad58[1], 1); - SkyboxDraw_Noop(&play->skyboxCtx); + Room_nop8012D510(this, &this->roomCtx.currRoom, &pad58[1], 0); + Room_nop8012D510(this, &this->roomCtx.prevRoom, &pad58[1], 1); + SkyboxDraw_Noop(&this->skyboxCtx); - if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { - KaleidoScopeCall_Update(play); - } else if (play->gameOverCtx.state != 0) { - GameOver_Update(play); + if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { + KaleidoScopeCall_Update(this); + } else if (this->gameOverCtx.state != 0) { + GameOver_Update(this); } - func_8015680C(play); - Interface_Update(play); - AnimationContext_Update(play, &play->animationCtx); - SoundSource_UpdateAll(play); - ShrinkWindow_Update(play->state.framerateDivisor); - TransitionFade_Update(&play->unk_18E48, play->state.framerateDivisor); + func_8015680C(this); + Interface_Update(this); + AnimationContext_Update(this, &this->animationCtx); + SoundSource_UpdateAll(this); + ShrinkWindow_Update(this->state.framerateDivisor); + TransitionFade_Update(&this->unk_18E48, this->state.framerateDivisor); } } @@ -1029,28 +1030,28 @@ void Play_Update(PlayState* play) { s32 sp50; Vec3s sp48; // InputDir - play->nextCamera = play->activeCamId; + this->nextCamera = this->activeCamId; for (sp54 = 0; sp54 < 4; sp54++) { - if ((sp54 != play->nextCamera) && (play->cameraPtrs[sp54] != NULL)) { - Camera_Update(&sp48, play->cameraPtrs[sp54]); + if ((sp54 != this->nextCamera) && (this->cameraPtrs[sp54] != NULL)) { + Camera_Update(&sp48, this->cameraPtrs[sp54]); } } - Camera_Update(&sp48, play->cameraPtrs[play->nextCamera]); + Camera_Update(&sp48, this->cameraPtrs[this->nextCamera]); } if (!sp5C) { - func_80166968(play, play->cameraPtrs[play->nextCamera]); + func_80166968(this, this->cameraPtrs[this->nextCamera]); Distortion_Update(); } - Environment_Update(play, &play->envCtx, &play->lightCtx, &play->pauseCtx, &play->msgCtx, &play->gameOverCtx, - play->state.gfxCtx); + Environment_Update(this, &this->envCtx, &this->lightCtx, &this->pauseCtx, &this->msgCtx, &this->gameOverCtx, + this->state.gfxCtx); - if (play->sramCtx.status != 0) { + if (this->sramCtx.status != 0) { if (gSaveContext.save.isOwlSave) { - func_80147198(&play->sramCtx); + func_80147198(&this->sramCtx); } else { - func_80147068(&play->sramCtx); + func_80147068(&this->sramCtx); } } } @@ -1058,31 +1059,31 @@ void Play_Update(PlayState* play) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s") #endif -void func_80167DE4(PlayState* play) { +void func_80167DE4(PlayState* this) { if (!D_801F6DFC) { - if (play->pauseCtx.unk_1F0 != 0) { + if (this->pauseCtx.unk_1F0 != 0) { D_801F6DFC = true; D_801F6D50.unk_00 = 0; } } else { - if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_L) || - CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_START) || (gIrqMgrResetStatus != 0)) { + if (CHECK_BTN_ALL(CONTROLLER1(&this->state)->press.button, BTN_L) || + CHECK_BTN_ALL(CONTROLLER1(&this->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&this->state)->press.button, BTN_START) || (gIrqMgrResetStatus != 0)) { D_801F6DFC = false; - play->pauseCtx.unk_1F0 = 0; + this->pauseCtx.unk_1F0 = 0; D_801F6D50.unk_00 = 0; - play->msgCtx.msgLength = 0; - play->msgCtx.msgMode = 0; - play->msgCtx.currentTextId = 0; - play->msgCtx.stateTimer = 0; + this->msgCtx.msgLength = 0; + this->msgCtx.msgMode = 0; + this->msgCtx.currentTextId = 0; + this->msgCtx.stateTimer = 0; play_sound(NA_SE_SY_CANCEL); } } if (D_801F6DFC) { - func_8016F5A8(play, &D_801F6D50, play->state.input); - func_8015680C(play); + func_8016F5A8(this, &D_801F6D50, this->state.input); + func_8015680C(this); } else { - Play_Update(play); + Play_Update(this); } } @@ -1206,8 +1207,8 @@ s32 Play_InCsMode(PlayState* this) { return (this->csCtx.state != 0) || Player_InCsMode(this); } -f32 func_80169100(PlayState* play, MtxF* mtx, CollisionPoly** poly, s32* bgId, Vec3f* feetPos) { - f32 floorHeight = BgCheck_EntityRaycastFloor3(&play->colCtx, poly, bgId, feetPos); +f32 func_80169100(PlayState* this, MtxF* mtx, CollisionPoly** poly, s32* bgId, Vec3f* feetPos) { + f32 floorHeight = BgCheck_EntityRaycastFloor3(&this->colCtx, poly, bgId, feetPos); if (floorHeight > BGCHECK_Y_MIN) { func_800C0094(*poly, feetPos->x, floorHeight, feetPos->z, mtx); @@ -1686,7 +1687,7 @@ s32 func_8016A02C(GameState* thisx, Actor* actor, s16* yaw) { /** * @brief Tests if \p pos is underwater. * - * @param[in] play PlayState + * @param[in] this PlayState * @param[in] pos position to test * @return true if inside a waterbox and not above a void. */ From 9001ed07b7a34a57c5d40c22db76c4799f99499f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 20 Aug 2022 11:47:33 -0400 Subject: [PATCH 3/5] slightly more docs --- include/functions.h | 2 +- src/code/z_message.c | 2 +- src/code/z_play.c | 36 +++++++++---------- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 6 ++-- tools/disasm/functions.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/functions.h b/include/functions.h index e266f3938e..bf65caa15c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2434,7 +2434,7 @@ u8 Message_GetState(MessageContext* msgCtx); // void func_80153EF0(void); void func_801541D4(PlayState* play, Gfx** gfxp); void Message_Draw(PlayState* play); -void func_8015680C(PlayState* play); +void Message_Update(PlayState* play); void func_801586A4(PlayState* play); void Message_Init(PlayState* play); void Message_FindMessageNES(PlayState* play, u16 textId); diff --git a/src/code/z_message.c b/src/code/z_message.c index 3e1b8e4418..60421a9de9 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -553,7 +553,7 @@ void Message_Draw(PlayState* play) { CLOSE_DISPS(gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015680C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_Update.s") void func_801586A4(PlayState* play) { play->msgCtx.messageEntryTableNes = D_801C6B98; diff --git a/src/code/z_play.c b/src/code/z_play.c index a0083aea90..6f10b4bc7e 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -965,7 +965,7 @@ void Play_Update(PlayState* this) { ((this->msgCtx.currentTextId == 0xFF) && (this->msgCtx.msgMode == 0x42) && (this->msgCtx.unk12020 == 0x41)) || ((this->msgCtx.currentTextId >= 0x100) && (this->msgCtx.currentTextId <= 0x200))) && - (this->gameOverCtx.state == 0)) { + (this->gameOverCtx.state == GAMEOVER_INACTIVE)) { KaleidoSetup_Update(this); } @@ -1012,11 +1012,11 @@ void Play_Update(PlayState* this) { if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { KaleidoScopeCall_Update(this); - } else if (this->gameOverCtx.state != 0) { + } else if (this->gameOverCtx.state != GAMEOVER_INACTIVE) { GameOver_Update(this); } - func_8015680C(this); + Message_Update(this); Interface_Update(this); AnimationContext_Update(this, &this->animationCtx); SoundSource_UpdateAll(this); @@ -1081,17 +1081,13 @@ void func_80167DE4(PlayState* this) { } if (D_801F6DFC) { func_8016F5A8(this, &D_801F6D50, this->state.input); - func_8015680C(this); + Message_Update(this); } else { Play_Update(this); } } void Play_DrawOverlayElements(PlayState* this) { - Gfx* sp34; - Gfx* sp30; - GraphicsContext* gfxCtx; - if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { KaleidoScopeCall_Draw(this); } @@ -1105,25 +1101,29 @@ void Play_DrawOverlayElements(PlayState* this) { Message_Draw(this); } - if (this->gameOverCtx.state != 0) { + if (this->gameOverCtx.state != GAMEOVER_INACTIVE) { GameOver_FadeLights(this); } - if (gSaveContext.screenScaleFlag != 0) { - gfxCtx = this->state.gfxCtx; + // Shrink the whole screen display (at the end of First and Second Day by default) + if (gSaveContext.screenScaleFlag) { + Gfx* nextOpa; + Gfx* opa; + GraphicsContext* gfxCtx = this->state.gfxCtx; + D_801F6D4C->scale = gSaveContext.screenScale / 1000.0f; OPEN_DISPS(gfxCtx); - sp30 = POLY_OPA_DISP; - sp34 = Graph_GfxPlusOne(sp30); - gSPDisplayList(OVERLAY_DISP++, sp34); + opa = POLY_OPA_DISP; + nextOpa = Graph_GfxPlusOne(opa); + gSPDisplayList(OVERLAY_DISP++, nextOpa); - func_80141778(D_801F6D4C, &sp34, this->unk_18E60, gfxCtx); + func_80141778(D_801F6D4C, &nextOpa, this->unk_18E60, gfxCtx); - gSPEndDisplayList(sp34++); - Graph_BranchDlist(sp30, sp34); - POLY_OPA_DISP = sp34; + gSPEndDisplayList(nextOpa++); + Graph_BranchDlist(opa, nextOpa); + POLY_OPA_DISP = nextOpa; CLOSE_DISPS(gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index d5d8583fd2..fd5ffa12f3 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -282,7 +282,7 @@ void func_80A425E4(EnTest4* this, PlayState* play) { gSaveContext.screenScale = 1000.0f; } if (gSaveContext.screenScale != 1000.0f) { - gSaveContext.screenScaleFlag = 1; + gSaveContext.screenScaleFlag = true; } } } @@ -309,7 +309,7 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { } else { sIsLoaded = true; this->actor.room = -1; - gSaveContext.screenScaleFlag = 0; + gSaveContext.screenScaleFlag = false; gSaveContext.screenScale = 1000.0f; if (CURRENT_DAY == 0) { if (gSaveContext.save.time < CLOCK_TIME(6, 1)) { @@ -357,7 +357,7 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { this->lastBellTime = gSaveContext.save.time; if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.unk5 & 2)) { - gSaveContext.screenScaleFlag = 0; + gSaveContext.screenScaleFlag = false; gSaveContext.screenScale = 1000.0f; } } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ba741d7707..552bb27060 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2871,7 +2871,7 @@ 0x80153EF0:("func_80153EF0",), 0x801541D4:("func_801541D4",), 0x80156758:("Message_Draw",), - 0x8015680C:("func_8015680C",), + 0x8015680C:("Message_Update",), 0x801586A4:("func_801586A4",), 0x801586D4:("Message_Init",), 0x801588D0:("Message_FindMessageNES",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index f1ea540020..70feab60bd 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2385,7 +2385,7 @@ asm/non_matchings/code/z_message/func_80153E7C.s,func_80153E7C,0x80153E7C,0x1D asm/non_matchings/code/z_message/func_80153EF0.s,func_80153EF0,0x80153EF0,0xB9 asm/non_matchings/code/z_message/func_801541D4.s,func_801541D4,0x801541D4,0x961 asm/non_matchings/code/z_message/Message_Draw.s,Message_Draw,0x80156758,0x2D -asm/non_matchings/code/z_message/func_8015680C.s,func_8015680C,0x8015680C,0x7A6 +asm/non_matchings/code/z_message/Message_Update.s,Message_Update,0x8015680C,0x7A6 asm/non_matchings/code/z_message/func_801586A4.s,func_801586A4,0x801586A4,0xC asm/non_matchings/code/z_message/Message_Init.s,Message_Init,0x801586D4,0x7F asm/non_matchings/code/z_message_nes/Message_FindMessageNES.s,Message_FindMessageNES,0x801588D0,0x2E From a0f786c2ad54bc8501811e97aed1d539eb2c8c37 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 20 Aug 2022 12:00:43 -0400 Subject: [PATCH 4/5] small docs --- include/functions.h | 2 +- include/variables.h | 2 +- include/z64.h | 2 +- src/code/z_demo.c | 20 +++++++++---------- src/code/z_play.c | 10 +++++----- src/code/z_vr_box_draw.c | 2 +- .../ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c | 2 +- .../z_bg_ikana_rotaryroom.c | 2 +- tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/functions.h b/include/functions.h index bf65caa15c..86d3be8a87 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2381,7 +2381,7 @@ void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB); void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); -void SkyboxDraw_Noop(SkyboxContext* skyboxCtx); +void SkyboxDraw_Update(SkyboxContext* skyboxCtx); // void func_80147520(void); void func_80147564(PlayState* play); diff --git a/include/variables.h b/include/variables.h index 43516ca27e..ed451ee39e 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3196,7 +3196,7 @@ extern Input D_801F6C18; // extern UNK_TYPE1 D_801F6D0C; extern UNK_TYPE4 gTrnsnUnkState; // extern UNK_TYPE1 D_801F6D18; -extern Color_RGBA8 D_801F6D30; +extern Color_RGBA8 gVisMonoColor; // extern UNK_TYPE1 D_801F6D38; // extern UNK_TYPE4 D_801F6D4C; // extern UNK_TYPE1 D_801F6D50; diff --git a/include/z64.h b/include/z64.h index e2357794cd..4b5ff4254c 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1177,7 +1177,7 @@ struct PlayState { /* 0x1883C */ Mtx* billboardMtx; /* 0x18840 */ u32 gameplayFrames; /* 0x18844 */ u8 unk_18844; - /* 0x18845 */ u8 unk_18845; + /* 0x18845 */ u8 haltAllActors; /* 0x18846 */ s16 numSetupActors; /* 0x18848 */ u8 numRooms; /* 0x1884C */ RomFile* roomList; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index baf3679228..0c66a6283d 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -204,16 +204,16 @@ void Cutscene_Command_Misc(PlayState* play2, CutsceneContext* csCtx, CsCmdBase* } break; case 0xA: - D_801F6D30.r = 255; - D_801F6D30.g = 255; - D_801F6D30.b = 255; - D_801F6D30.a = 255 * progress; + gVisMonoColor.r = 255; + gVisMonoColor.g = 255; + gVisMonoColor.b = 255; + gVisMonoColor.a = 255 * progress; break; case 0xB: - D_801F6D30.r = 255; - D_801F6D30.g = 180; - D_801F6D30.b = 100; - D_801F6D30.a = 255 * progress; + gVisMonoColor.r = 255; + gVisMonoColor.g = 180; + gVisMonoColor.b = 100; + gVisMonoColor.a = 255 * progress; break; case 0xC: play->roomCtx.currRoom.segment = NULL; @@ -234,10 +234,10 @@ void Cutscene_Command_Misc(PlayState* play2, CutsceneContext* csCtx, CsCmdBase* } break; case 0xE: - play->unk_18845 = 1; + play->haltAllActors = true; break; case 0xF: - play->unk_18845 = 0; + play->haltAllActors = false; break; case 0x10: if (isStartFrame) { diff --git a/src/code/z_play.c b/src/code/z_play.c index 6f10b4bc7e..3c02a51758 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -15,7 +15,7 @@ extern FbDemoStruct sTrnsnUnk; extern u16* D_801F6D0C; extern s32 gTrnsnUnkState; extern VisMono D_801F6D18; -extern Color_RGBA8 D_801F6D30; +extern Color_RGBA8 gVisMonoColor; extern Struct_80140E80 D_801F6D38; extern Struct_80140E80* D_801F6D4C; extern HiresoStruct D_801F6D50; @@ -993,7 +993,7 @@ void Play_Update(PlayState* this) { CollisionCheck_OC(this, &this->colChkCtx); CollisionCheck_Damage(this, &this->colChkCtx); CollisionCheck_ClearContext(this, &this->colChkCtx); - if (this->unk_18845 == 0) { + if (!this->haltAllActors) { Actor_UpdateAll(this, &this->actorCtx); } Cutscene_Update1(this, &this->csCtx); @@ -1008,7 +1008,7 @@ void Play_Update(PlayState* this) { Room_nop8012D510(this, &this->roomCtx.currRoom, &pad58[1], 0); Room_nop8012D510(this, &this->roomCtx.prevRoom, &pad58[1], 1); - SkyboxDraw_Noop(&this->skyboxCtx); + SkyboxDraw_Update(&this->skyboxCtx); if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { KaleidoScopeCall_Update(this); @@ -1972,7 +1972,7 @@ void Play_Init(GameState* thisx) { this->transitionTrigger = TRANS_TRIGGER_END; this->unk_18876 = 0; this->bgCoverAlpha = 0; - this->unk_18845 = 0; + this->haltAllActors = false; this->unk_18844 = 0; if (gSaveContext.gameMode != 1) { @@ -1993,7 +1993,7 @@ void Play_Init(GameState* thisx) { TransitionFade_Start(&this->unk_18E48); VisMono_Init(&D_801F6D18); - D_801F6D30.a = 0; + gVisMonoColor.a = 0; D_801F6D4C = &D_801F6D38; func_80140E80(D_801F6D4C); D_801F6D4C->lodProportion = 0.0f; diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.c index 326fcb3e2f..48b37ce8e4 100644 --- a/src/code/z_vr_box_draw.c +++ b/src/code/z_vr_box_draw.c @@ -63,5 +63,5 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb CLOSE_DISPS(gfxCtx); } -void SkyboxDraw_Noop(SkyboxContext* skyboxCtx) { +void SkyboxDraw_Update(SkyboxContext* skyboxCtx) { } diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c index 1a0cb50586..45286fccb4 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c @@ -273,7 +273,7 @@ void func_80A70F2C(BgCraceMovebg* this, PlayState* play) { func_80A70C04(this, play); if (Math_StepToF(&this->unk160, 0.0f, 1.0f)) { if (!(this->unk170 & 2) && !Flags_GetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1)) { - play->unk_18845 = 1; + play->haltAllActors = true; func_80169FDC(&play->state); play_sound(NA_SE_OC_ABYSS); } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index 94eec2c1d6..99fd93627b 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -649,7 +649,7 @@ void func_80B814B8(BgIkanaRotaryroom* this, PlayState* play) { func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); func_80169EFC(&play->state); func_800B8E58(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->unk_92); - play->unk_18845 = 1; + play->haltAllActors = true; play_sound(NA_SE_OC_ABYSS); this->actionFunc = NULL; } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 552bb27060..787f991734 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2786,7 +2786,7 @@ 0x801435A0:("SkyboxDraw_UpdateMatrix",), 0x80143624:("SkyboxDraw_SetColors",), 0x80143668:("SkyboxDraw_Draw",), - 0x80143A04:("SkyboxDraw_Noop",), + 0x80143A04:("SkyboxDraw_Update",), 0x80143A10:("Sram_ActivateOwl",), 0x80143A54:("Sram_ClearHighscores",), 0x80143AC4:("Sram_ClearFlagsAtDawnOfTheFirstDay",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index bf6f1375c0..18a6cae872 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4059,7 +4059,7 @@ 0x801F6D0C:("D_801F6D0C","UNK_TYPE1","",0x1), 0x801F6D10:("gTrnsnUnkState","UNK_TYPE4","",0x4), 0x801F6D18:("D_801F6D18","UNK_TYPE1","",0x1), - 0x801F6D30:("D_801F6D30","Color_RGBA8","",0x4), + 0x801F6D30:("gVisMonoColor","Color_RGBA8","",0x4), 0x801F6D38:("D_801F6D38","UNK_TYPE1","",0x1), 0x801F6D4C:("D_801F6D4C","UNK_TYPE4","",0x4), 0x801F6D50:("D_801F6D50","UNK_TYPE1","",0x1), From 16758bd7bd452cc00f2adc80128736954c64e9b6 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 20 Aug 2022 16:57:11 -0400 Subject: [PATCH 5/5] Play_Draw WIP Thanks @petrie911 --- include/functions.h | 23 +- include/variables.h | 2 +- src/code/z_actor.c | 6 +- src/code/z_fbdemo.c | 2 +- src/code/z_kankyo.c | 12 +- src/code/z_play.c | 302 +++++++++++++++++- src/code/z_scene_proc.c | 2 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 14 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 4 +- src/overlays/gamestates/ovl_title/z_title.c | 2 +- tools/disasm/functions.txt | 16 +- tools/sizes/code_functions.csv | 16 +- 12 files changed, 350 insertions(+), 51 deletions(-) diff --git a/include/functions.h b/include/functions.h index 86d3be8a87..7d06ad159e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1336,6 +1336,7 @@ s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* tors void SaveContext_Init(void); void GameInfo_Init(void); DebugDispObject* DebugDisplay_Init(void); +void DebugDisplay_DrawObjects(PlayState* play); DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx); // void func_800E9C90(void); // void func_800E9CA0(s32 param_1, UNK_TYPE1 param_2, s8* param_3); @@ -1435,7 +1436,7 @@ void Kankyo_Init(PlayState* play, EnvironmentContext* envCtx, s32 arg2); u32 func_800F5954(u8* param_1, u32 param_2, u32 param_3, u8 param_4, u8 param_5); f32 Environment_LerpWeight(u16 max, u16 min, u16 val); // void func_800F5B10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_800F5CD0(void); +void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxContext* skyboxCtx); void func_800F6834(PlayState* play, s32 waterLightsIndex); void func_800F694C(PlayState* play); // void func_800F6A04(void); @@ -1454,11 +1455,11 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex PauseContext* pauseCtx, MessageContext* msgCtx, GameOverContext* gameOverCtx, GraphicsContext* gfxCtx); // void func_800F8D84(void); -// void func_800F9728(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +void Environment_DrawSunLensFlare(PlayState* play, EnvironmentContext* envCtx, View* view, GraphicsContext* gfxCtx, Vec3f pos); void func_800F9824(PlayState* play, EnvironmentContext* envCtx, View* view, GraphicsContext* gfxCtx, Vec3f vec, f32 arg5, f32 arg6, s8 arg7, s8 arg8); // void func_800FA39C(void); // void func_800FA3C4(void); -// void func_800FA9FC(void); +void Environment_DrawRain(PlayState* play, View* view, GraphicsContext* gfxCtx); void func_800FAAB4(PlayState* play, u8 arg1); // void func_800FAC20(void); // void func_800FAF74(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); @@ -1467,13 +1468,13 @@ void Environment_AddLightningBolts(PlayState* play, u8 num); // void func_800FB388(void); void func_800FB758(PlayState* play); // void func_800FB9B4(void); -// void func_800FBCBC(void); +void Environment_DrawCustomLensFlare(PlayState* play); void Kankyo_InitGameOverLights(PlayState* play); void Kankyo_FadeInGameOverLights(PlayState* play); void Kankyo_FadeOutGameOverLights(PlayState* play); // void func_800FC3DC(void); -void func_800FC444(GraphicsContext* gfxCtx, u8 arg1, u8 arg2, u8 arg3, u8 arg4, UNK_TYPE arg5); -// void func_800FC64C(void); +void Environment_FillScreen(GraphicsContext* gfxCtx, u8 red, u8 green, u8 blue, u8 alpha, u8 drawFlags); +void Environment_DrawSandstorm(PlayState* play, u8 sandstormState); s32 func_800FD2B4(PlayState* play, f32 arg1, f32 arg2, f32 arg3, f32 arg4); void func_800FD538(Color_RGB8* param_1, Color_RGB8* param_2, f32 param_3, Vec3s* param_4); void func_800FD59C(PlayState* play, Color_RGB8* pzParm2, f32 fParm3); @@ -1491,8 +1492,8 @@ void func_800FD928(s32 param_1); // void func_800FD980(void); // void func_800FDAF8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_800FDC94(void); -// void func_800FE390(void); -// void func_800FE3E0(void); +void func_800FE390(PlayState* play); +void func_800FE3E0(PlayState* play); void func_800FE484(void); void func_800FE498(void); // void func_800FE4A8(void); @@ -2158,7 +2159,7 @@ void Scene_SetExitFade(PlayState* play); s32 Scene_ProcessHeader(PlayState* play, SceneCmd* header); u16 Entrance_Create(s32 scene, s32 spawn, s32 layer); u16 Entrance_CreateFromSpawn(s32 spawn); -void Scene_ExecuteDrawConfig(PlayState* play); +void Scene_Draw(PlayState* play); void Scene_DrawConfigDefault(PlayState* play); Gfx* AnimatedMat_TexScroll(PlayState* play, AnimatedMatTexScrollParams* params); void AnimatedMat_DrawTexScroll(PlayState* play, s32 segment, void* params); @@ -2503,7 +2504,7 @@ void func_80163D80(TransitionContext* transitionCtx, PlayState* play); void TransitionUnk_Destroy(FbDemoStruct* this); FbDemoStruct* TransitionUnk_Init(FbDemoStruct* this, s32 row, s32 col); // void func_80164438(void); -// void func_8016454C(void); +void TransitionUnk_Draw(FbDemoStruct* this, Gfx**); // void func_80164678(void); void func_801647AC(FbDemoStruct* this); // UNK_TYPE4 func_801647B8(void); @@ -2511,7 +2512,7 @@ void func_801647AC(FbDemoStruct* this); void* TransitionFade_Init(TransitionFade* arg0); void TransitionFade_Destroy(TransitionFade* arg0); void TransitionFade_Update(TransitionFade* thisx, s32 updateRate); -// void TransitionFade_Draw(void); +void TransitionFade_Draw(void* thisx, Gfx** gfxP); // void TransitionFade_IsDone(void); void TransitionFade_SetColor(TransitionFade* arg0, u32 color); void TransitionFade_SetType(TransitionFade* arg0, s32 arg1); diff --git a/include/variables.h b/include/variables.h index ed451ee39e..44958bd1b2 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3196,7 +3196,7 @@ extern Input D_801F6C18; // extern UNK_TYPE1 D_801F6D0C; extern UNK_TYPE4 gTrnsnUnkState; // extern UNK_TYPE1 D_801F6D18; -extern Color_RGBA8 gVisMonoColor; +extern Color_RGBA8_u32 gVisMonoColor; // extern UNK_TYPE1 D_801F6D38; // extern UNK_TYPE4 D_801F6D4C; // extern UNK_TYPE1 D_801F6D50; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index da2b70292d..fb2b41c489 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2411,7 +2411,7 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { params.player = player; params.play = play; - if (play->unk_18844 != 0) { + if (play->unk_18844) { params.unk_18 = ACTOR_FLAG_200000; } else { params.unk_18 = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_10; @@ -2850,7 +2850,7 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { s32 actorFlags; s32 i; - if (play->unk_18844 != 0) { + if (play->unk_18844) { actorFlags = ACTOR_FLAG_200000; } else { actorFlags = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_20; @@ -2921,7 +2921,7 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { gSPBranchList(ref2, &tmp2[1]); POLY_XLU_DISP = &tmp2[1]; - if (play->unk_18844 == 0) { + if (!play->unk_18844) { Lights_DrawGlow(play); } diff --git a/src/code/z_fbdemo.c b/src/code/z_fbdemo.c index afb1ae830b..c145087a24 100644 --- a/src/code/z_fbdemo.c +++ b/src/code/z_fbdemo.c @@ -11,7 +11,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_80164438.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_8016454C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/TransitionUnk_Draw.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_80164678.s") diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 492eff0c0b..81fc6c46e4 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -12,7 +12,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5B10.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5CD0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_UpdateSkybox.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F6834.s") @@ -46,7 +46,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F8D84.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F9728.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_DrawSunLensFlare.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F9824.s") @@ -54,7 +54,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FA3C4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FA9FC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_DrawRain.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FAAB4.s") @@ -72,7 +72,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB9B4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FBCBC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_DrawCustomLensFlare.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_InitGameOverLights.s") @@ -82,9 +82,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FC3DC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FC444.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_FillScreen.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FC64C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_DrawSandstorm.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FD2B4.s") diff --git a/src/code/z_play.c b/src/code/z_play.c index 3c02a51758..1e9ff69726 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -5,6 +5,8 @@ #include "overlays/gamestates/ovl_file_choose/z_file_choose.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" +extern Gfx D_0E000140[]; + s32 gDbgCamEnabled = false; u8 D_801D0D54 = false; @@ -15,7 +17,7 @@ extern FbDemoStruct sTrnsnUnk; extern u16* D_801F6D0C; extern s32 gTrnsnUnkState; extern VisMono D_801F6D18; -extern Color_RGBA8 gVisMonoColor; +extern Color_RGBA8_u32 gVisMonoColor; extern Struct_80140E80 D_801F6D38; extern Struct_80140E80* D_801F6D4C; extern HiresoStruct D_801F6D50; @@ -1129,7 +1131,303 @@ void Play_DrawOverlayElements(PlayState* this) { } } +#ifdef NON_MATCHING +void Play_Draw(PlayState* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; + Lights* sp268; + Vec3f sp25C; + u8 sp25B = false; + f32 var_fv0; // fogFar + + if (SREG(94) >= 4) { + PreRender_ApplyFiltersSlowlyDestroy(&this->pauseBgPreRender); + SREG(94) = 0; + } + + if ((SREG(94) < 2) && (gTrnsnUnkState < 2)) { + if (this->skyboxCtx.skyboxShouldDraw || (this->roomCtx.currRoom.mesh->type0.type == 1)) { + func_8012CF0C(gfxCtx, 0, 1, 0, 0, 0); + } else { + func_8012CF0C(gfxCtx, 1, 1, this->lightCtx.unk7, this->lightCtx.unk8, this->lightCtx.unk9); + } + } else { + func_8012CF0C(gfxCtx, 0, 0, 0, 0, 0); + } + + OPEN_DISPS(gfxCtx); + + gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment); + + gSPSegment(POLY_OPA_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + gSPSegment(OVERLAY_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + + gSPSegment(POLY_OPA_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSPSegment(OVERLAY_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + + gSPSegment(POLY_OPA_DISP++, 0x02, this->sceneSegment); + gSPSegment(POLY_XLU_DISP++, 0x02, this->sceneSegment); + gSPSegment(OVERLAY_DISP++, 0x02, this->sceneSegment); + + ShrinkWindow_Draw(gfxCtx); + + POLY_OPA_DISP = func_801660B8(this, POLY_OPA_DISP); + POLY_XLU_DISP = func_801660B8(this, POLY_XLU_DISP); + + // fogFar + var_fv0 = this->lightCtx.unkC; + if (var_fv0 > 12800.0f) { + var_fv0 = 12800.0f; + } + + func_8013F0D0(&this->view, this->view.fovy, this->view.zNear, var_fv0); + + View_RenderView(&this->view, 0xF); + + Matrix_MtxToMtxF(&this->view.viewing, &this->billboardMtxF); + Matrix_MtxToMtxF(&this->view.projection, &this->viewProjectionMtxF); + + this->unk_187F0.x = this->viewProjectionMtxF.xx; + this->unk_187F0.y = this->viewProjectionMtxF.yy; + this->unk_187F0.z = -this->viewProjectionMtxF.zz; + + SkinMatrix_MtxFMtxFMult(&this->viewProjectionMtxF, &this->billboardMtxF, &this->viewProjectionMtxF); + + this->billboardMtxF.mf[3][2] = + (this->billboardMtxF.mf[3][1] = + (this->billboardMtxF.mf[3][0] = + (this->billboardMtxF.mf[2][3] = + (this->billboardMtxF.mf[1][3] = (this->billboardMtxF.mf[0][3] = 0.0f))))); + + Matrix_Transpose(&this->billboardMtxF); + + this->billboardMtx = GRAPH_ALLOC(this->state.gfxCtx, 0x80); + + Matrix_MtxFToMtx(&this->billboardMtxF, this->billboardMtx); + Matrix_RotateYF(((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(this)) + 0x8000)) * 0.0000958738f, MTXMODE_NEW); + Matrix_ToMtx(this->billboardMtx + 1); + + gSPSegment(POLY_OPA_DISP++, 0x01, this->billboardMtx); + gSPSegment(POLY_XLU_DISP++, 0x01, this->billboardMtx); + gSPSegment(OVERLAY_DISP++, 0x01, this->billboardMtx); + + if (1) { + Gfx* sp218; + Gfx* sp214 = POLY_OPA_DISP; + + sp218 = Graph_GfxPlusOne(sp214); + gSPDisplayList(OVERLAY_DISP++, sp218); + + if (((this->transitionMode == TRANS_MODE_INSTANCE_RUNNING) || (this->transitionMode == TRANS_TYPE_INSTANT)) || + D_801D0D54) { + View spA8; + + View_Init(&spA8, gfxCtx); + spA8.flags = 0xA; + + SET_FULLSCREEN_VIEWPORT(&spA8); + + func_801400CC(&spA8, &sp218); + this->transitionCtx.draw(&this->transitionCtx.instanceData, &sp218); + } + + TransitionFade_Draw(&this->unk_18E48, &sp218); + + if (gVisMonoColor.a != 0) { + D_801F6D18.primColor.rgba = gVisMonoColor.rgba; + VisMono_Draw(&D_801F6D18, &sp218); + } + + gSPEndDisplayList(sp218++); + Graph_BranchDlist(sp214, sp218); + POLY_OPA_DISP = sp218; + } + + if (gTrnsnUnkState == 3) { + Gfx* sp90 = POLY_OPA_DISP; + + TransitionUnk_Draw(&sTrnsnUnk, &sp90); + POLY_OPA_DISP = sp90; + sp25B = true; + goto Play_Draw_DrawOverlayElements; + } + + PreRender_SetValues(&this->pauseBgPreRender, D_801FBBCC, D_801FBBCE, gfxCtx->curFrameBuffer, gfxCtx->zbuffer); + + if (SREG(94) == 2) { + MsgEvent_SendNullTask(); + if (!gSaveContext.screenScaleFlag) { + PreRender_ApplyFiltersSlowlyInit(&this->pauseBgPreRender); + } + SREG(94) = 3; + SREG(33) |= 1; + } else { + if (SREG(94) == 3) { + Gfx* sp8C = POLY_OPA_DISP; + + if (this->pauseBgPreRender.unk_4D == 2) { + func_80170B28(&this->pauseBgPreRender, &sp8C); + } else { + func_80170798(&this->pauseBgPreRender, &sp8C); + } + + gSPDisplayList(sp8C++, D_0E000140); + POLY_OPA_DISP = sp8C; + sp25B = true; + goto Play_Draw_DrawOverlayElements; + } + + if (!this->unk_18844) { + if (this->skyboxId && !this->envCtx.skyboxDisabled) { + if ((this->skyboxId == 1) || (this->skyboxId == 3)) { + Environment_UpdateSkybox(this->skyboxId, &this->envCtx, &this->skyboxCtx); + SkyboxDraw_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.unk_13, this->view.eye.x, + this->view.eye.y, this->view.eye.z); + } else if (!this->skyboxCtx.skyboxShouldDraw) { + SkyboxDraw_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x, this->view.eye.y, + this->view.eye.z); + } + } + + func_800FE390(this); + sp268 = LightContext_NewLights(&this->lightCtx, gfxCtx); + + if (this->roomCtx.currRoom.enablePosLights || (MREG(93) != 0)) { + sp268->enablePosLights = true; + } + + Lights_BindAll(sp268, this->lightCtx.listHead, NULL, this); + Lights_Draw(sp268, gfxCtx); + + Scene_Draw(this); + + if (this->roomCtx.unk78) { + //! FAKE: Regalloc around here. s64 solves the regalloc, + // but much too large on the stack. Need: + // `if (stuff that evaluates to 0 but not trivially)` + s64 roomDrawFlags = 3; + + Room_Draw(this, &this->roomCtx.currRoom, roomDrawFlags); + Room_Draw(this, &this->roomCtx.prevRoom, roomDrawFlags); + } + + if (this->skyboxCtx.skyboxShouldDraw) { + Vec3f sp78; + + if (1) {} + Camera_GetQuakeOffset(&sp78, GET_ACTIVE_CAM(this)); + SkyboxDraw_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + sp78.x, + this->view.eye.y + sp78.y, this->view.eye.z + sp78.z); + } + + // envCtx.precipitation[PRECIP_RAIN_CUR] + if (this->envCtx.unk_F2[1] != 0) { + Environment_DrawRain(this, &this->view, gfxCtx); + } + } + + Environment_FillScreen(gfxCtx, 0, 0, 0, this->bgCoverAlpha, 1); + + Actor_DrawAll(this, &this->actorCtx); + + if (!this->envCtx.sunMoonDisabled) { + sp25C.x = this->view.eye.x + this->envCtx.unk_4; + sp25C.y = this->view.eye.y + this->envCtx.unk_8; + sp25C.z = this->view.eye.z + this->envCtx.unk_C; + Environment_DrawSunLensFlare(this, &this->envCtx, &this->view, gfxCtx, sp25C); + } + + Environment_DrawCustomLensFlare(this); + + if (MREG(64) != 0) { + Environment_FillScreen(gfxCtx, MREG(65), MREG(66), MREG(67), MREG(68), 3); + } + + switch (this->envCtx.fillScreen) { + case 1: + Environment_FillScreen(gfxCtx, this->envCtx.screenFillColor[0], this->envCtx.screenFillColor[1], + this->envCtx.screenFillColor[2], this->envCtx.screenFillColor[3], 3); + break; + default: + break; + } + + if (this->envCtx.sandstormState != 0) { + Environment_DrawSandstorm(this, this->envCtx.sandstormState); + } + + if (this->unk_18876 != 0) { + Environment_FillScreen(gfxCtx, 0, 0, 0, this->unk_18876, 3); + } + + DebugDisplay_DrawObjects(this); + func_80165460(this); + + if (((SREG(94) == 1) || (gTrnsnUnkState == 1)) || (SREG(89) == 1)) { + Gfx* sp74; + Gfx* sp70 = POLY_OPA_DISP; + + sp74 = Graph_GfxPlusOne(sp70); + gSPDisplayList(OVERLAY_DISP++, sp74); + this->pauseBgPreRender.fbuf = gfxCtx->curFrameBuffer; + + if (SREG(94) == 1) { + SREG(94) = 2; + this->pauseBgPreRender.fbufSave = (u16*)gfxCtx->zbuffer; + this->pauseBgPreRender.cvgSave = this->unk_18E58; + } else if (SREG(89) == 1) { + SREG(89) = 2; + this->pauseBgPreRender.fbufSave = (u16*)gfxCtx->zbuffer; + this->pauseBgPreRender.cvgSave = this->unk_18E58; + } else { + gTrnsnUnkState = 2; + this->pauseBgPreRender.fbufSave = (u16*)gfxCtx->zbuffer; + this->pauseBgPreRender.cvgSave = NULL; + } + + func_801705B4(&this->pauseBgPreRender, &sp74); + + if (this->pauseBgPreRender.cvgSave != NULL) { + func_80170730(&this->pauseBgPreRender, &sp74); + } + + gSPEndDisplayList(sp74++); + Graph_BranchDlist(sp70, sp74); + POLY_OPA_DISP = sp74; + this->unk_18B49 = 2; + SREG(33) |= 1; + } else { + Play_Draw_DrawOverlayElements: + Play_DrawOverlayElements(this); + } + } + + //! Fake: regalloc around here + if (this && this && this) {} + + if ((this->view.unk164 != 0) && !gDbgCamEnabled) { + Vec3s sp4C; + + Camera_Update(&sp4C, GET_ACTIVE_CAM(this)); + func_80140024(&this->view); + this->view.unk164 = 0; + if ((this->skyboxId != 0) && !this->envCtx.skyboxDisabled) { + SkyboxDraw_UpdateMatrix(&this->skyboxCtx, this->view.eye.x, this->view.eye.y, this->view.eye.z); + } + } + + if (!sp25B) { + func_800FE3E0(this); + } + + CLOSE_DISPS(this->state.gfxCtx); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Draw.s") +#endif void func_80168DAC(PlayState* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; @@ -1973,7 +2271,7 @@ void Play_Init(GameState* thisx) { this->unk_18876 = 0; this->bgCoverAlpha = 0; this->haltAllActors = false; - this->unk_18844 = 0; + this->unk_18844 = false; if (gSaveContext.gameMode != 1) { if (gSaveContext.nextTransitionType == TRANS_NEXT_TYPE_DEFAULT) { diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index 8ddde8a825..d5224067a8 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -22,7 +22,7 @@ static Gfx sSceneDrawDefaultDL[] = { /** * Executes the current scene draw config handler. */ -void Scene_ExecuteDrawConfig(PlayState* play) { +void Scene_Draw(PlayState* play) { static void (*sceneDrawConfigHandlers[])(PlayState*) = { Scene_DrawConfigDefault, Scene_DrawConfigMatAnim, diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index ae5dcb5700..c99d008a64 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -398,7 +398,7 @@ void func_80A916F0(EnTest6* this, PlayState* play) { Player* player = GET_PLAYER(play); player->actor.freezeTimer = 0; - play->unk_18844 = 0; + play->unk_18844 = false; ActorCutscene_Stop(play->playerActorCsIds[8]); func_800B7298(play, NULL, 6); func_80A90C34(); @@ -470,7 +470,7 @@ void func_80A91760(EnTest6* this, PlayState* play) { func_80A90C08(0x78); Distortion_SetType(0x20); Distortion_SetCountdown(80); - play->unk_18844 = 1; + play->unk_18844 = true; this->unk_274 = 95; } break; @@ -524,7 +524,7 @@ void func_80A91760(EnTest6* this, PlayState* play) { this->unk_14C = 0.1f; func_80A90C34(); Distortion_ClearType(0x20); - play->unk_18844 = 0; + play->unk_18844 = false; if (this->unk_254 != NULL) { ZeldaArena_Free(this->unk_254); } @@ -619,7 +619,7 @@ void func_80A92118(EnTest6* this, PlayState* play) { Player* player = GET_PLAYER(play); player->actor.freezeTimer = 0; - play->unk_18844 = 0; + play->unk_18844 = false; ActorCutscene_Stop(play->playerActorCsIds[8]); func_800B7298(play, NULL, 6); func_80A90C34(); @@ -662,7 +662,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { func_800FD5E0(play, &D_80A94070, 1.0f); func_800FD654(play, &D_80A94068, 1.0f); func_800FD698(play, D_80A94074, D_80A94078, 1.0f); - play->unk_18844 = 1; + play->unk_18844 = true; } if (this->unk_27A == 15) { @@ -670,7 +670,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { func_800FD5E0(play, &D_80A94070, 0.0f); func_800FD654(play, &D_80A94068, 0.0f); func_800FD698(play, D_80A94074, D_80A94078, 0.0f); - play->unk_18844 = 0; + play->unk_18844 = false; } if (this->unk_286 >= 20) { @@ -678,7 +678,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { func_800FD5E0(play, &D_80A94070, this->unk_160); func_800FD654(play, &D_80A94068, this->unk_160); func_800FD698(play, D_80A94074, D_80A94078, this->unk_160); - play->unk_18844 = 0; + play->unk_18844 = false; } func_800B8F98(&player->actor, NA_SE_PL_FLYING_AIR - SFX_FLAG); diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index 83e92d2770..6c6f3bd0fe 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -438,7 +438,7 @@ void func_80AF19A8(EnTest7* this, PlayState* play) { } else { ActorCutscene_Start(play->playerActorCsIds[8], NULL); func_80AF082C(this, func_80AF1A2C); - play->unk_18844 = 1; + play->unk_18844 = true; } } @@ -599,7 +599,7 @@ void func_80AF2030(EnTest7* this, PlayState* play) { MREG(66) = 255; MREG(67) = 255; MREG(68) = 255; - play->unk_18844 = 0; + play->unk_18844 = false; this->unk_144 &= ~4; func_80AF082C(this, func_80AF21E8); func_80165690(); diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 68488b336b..027c57cea0 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -109,7 +109,7 @@ void Title_Draw(GameState* thisx) { 1 << 10, 1 << 10); } - func_800FC444(this->gameState.gfxCtx, 0, 0, 0, this->coverAlpha, 2); + Environment_FillScreen(this->gameState.gfxCtx, 0, 0, 0, this->coverAlpha, 2); titleRotation += 300; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 787f991734..b60a767f5c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1712,7 +1712,7 @@ 0x800F5954:("func_800F5954",), 0x800F5A8C:("Environment_LerpWeight",), 0x800F5B10:("func_800F5B10",), - 0x800F5CD0:("func_800F5CD0",), + 0x800F5CD0:("Environment_UpdateSkybox",), 0x800F6834:("func_800F6834",), 0x800F694C:("func_800F694C",), 0x800F6A04:("func_800F6A04",), @@ -1729,11 +1729,11 @@ 0x800F8A9C:("func_800F8A9C",), 0x800F8CD4:("Environment_Update",), 0x800F8D84:("func_800F8D84",), - 0x800F9728:("func_800F9728",), + 0x800F9728:("Environment_DrawSunLensFlare",), 0x800F9824:("func_800F9824",), 0x800FA39C:("func_800FA39C",), 0x800FA3C4:("func_800FA3C4",), - 0x800FA9FC:("func_800FA9FC",), + 0x800FA9FC:("Environment_DrawRain",), 0x800FAAB4:("func_800FAAB4",), 0x800FAC20:("func_800FAC20",), 0x800FAF74:("func_800FAF74",), @@ -1742,13 +1742,13 @@ 0x800FB388:("func_800FB388",), 0x800FB758:("func_800FB758",), 0x800FB9B4:("func_800FB9B4",), - 0x800FBCBC:("func_800FBCBC",), + 0x800FBCBC:("Environment_DrawCustomLensFlare",), 0x800FBDEC:("Kankyo_InitGameOverLights",), 0x800FBF3C:("Kankyo_FadeInGameOverLights",), 0x800FC158:("Kankyo_FadeOutGameOverLights",), 0x800FC3DC:("func_800FC3DC",), - 0x800FC444:("func_800FC444",), - 0x800FC64C:("func_800FC64C",), + 0x800FC444:("Environment_FillScreen",), + 0x800FC64C:("Environment_DrawSandstorm",), 0x800FD2B4:("func_800FD2B4",), 0x800FD538:("func_800FD538",), 0x800FD59C:("func_800FD59C",), @@ -2458,7 +2458,7 @@ 0x801306E8:("Scene_ProcessHeader",), 0x80130768:("Entrance_Create",), 0x80130784:("Entrance_CreateFromSpawn",), - 0x801307C0:("Scene_ExecuteDrawConfig",), + 0x801307C0:("Scene_Draw",), 0x801307F4:("Scene_DrawConfigDefault",), 0x80130834:("AnimatedMat_TexScroll",), 0x801308A0:("AnimatedMat_DrawTexScroll",), @@ -2943,7 +2943,7 @@ 0x8016424C:("TransitionUnk_Destroy",), 0x801642D8:("TransitionUnk_Init",), 0x80164438:("func_80164438",), - 0x8016454C:("func_8016454C",), + 0x8016454C:("TransitionUnk_Draw",), 0x80164678:("func_80164678",), 0x801647AC:("func_801647AC",), 0x801647B8:("func_801647B8",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 70feab60bd..8c986e485c 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1226,7 +1226,7 @@ asm/non_matchings/code/z_kankyo/Kankyo_Init.s,Kankyo_Init,0x800F510C,0x212 asm/non_matchings/code/z_kankyo/func_800F5954.s,func_800F5954,0x800F5954,0x4E asm/non_matchings/code/z_kankyo/Environment_LerpWeight.s,Environment_LerpWeight,0x800F5A8C,0x21 asm/non_matchings/code/z_kankyo/func_800F5B10.s,func_800F5B10,0x800F5B10,0x70 -asm/non_matchings/code/z_kankyo/func_800F5CD0.s,func_800F5CD0,0x800F5CD0,0x2D9 +asm/non_matchings/code/z_kankyo/Environment_UpdateSkybox.s,Environment_UpdateSkybox,0x800F5CD0,0x2D9 asm/non_matchings/code/z_kankyo/func_800F6834.s,func_800F6834,0x800F6834,0x46 asm/non_matchings/code/z_kankyo/func_800F694C.s,func_800F694C,0x800F694C,0x2E asm/non_matchings/code/z_kankyo/func_800F6A04.s,func_800F6A04,0x800F6A04,0xF @@ -1243,11 +1243,11 @@ asm/non_matchings/code/z_kankyo/func_800F8970.s,func_800F8970,0x800F8970,0x4B asm/non_matchings/code/z_kankyo/func_800F8A9C.s,func_800F8A9C,0x800F8A9C,0x8E asm/non_matchings/code/z_kankyo/Environment_Update.s,Environment_Update,0x800F8CD4,0x2C asm/non_matchings/code/z_kankyo/func_800F8D84.s,func_800F8D84,0x800F8D84,0x269 -asm/non_matchings/code/z_kankyo/func_800F9728.s,func_800F9728,0x800F9728,0x3F +asm/non_matchings/code/z_kankyo/Environment_DrawSunLensFlare.s,Environment_DrawSunLensFlare,0x800F9728,0x3F asm/non_matchings/code/z_kankyo/func_800F9824.s,func_800F9824,0x800F9824,0x2DE asm/non_matchings/code/z_kankyo/func_800FA39C.s,func_800FA39C,0x800FA39C,0xA asm/non_matchings/code/z_kankyo/func_800FA3C4.s,func_800FA3C4,0x800FA3C4,0x18E -asm/non_matchings/code/z_kankyo/func_800FA9FC.s,func_800FA9FC,0x800FA9FC,0x2E +asm/non_matchings/code/z_kankyo/Environment_DrawRain.s,Environment_DrawRain,0x800FA9FC,0x2E asm/non_matchings/code/z_kankyo/func_800FAAB4.s,func_800FAAB4,0x800FAAB4,0x5B asm/non_matchings/code/z_kankyo/func_800FAC20.s,func_800FAC20,0x800FAC20,0xD5 asm/non_matchings/code/z_kankyo/func_800FAF74.s,func_800FAF74,0x800FAF74,0x27 @@ -1256,13 +1256,13 @@ asm/non_matchings/code/z_kankyo/Environment_AddLightningBolts.s,Environment_AddL asm/non_matchings/code/z_kankyo/func_800FB388.s,func_800FB388,0x800FB388,0xF4 asm/non_matchings/code/z_kankyo/func_800FB758.s,func_800FB758,0x800FB758,0x97 asm/non_matchings/code/z_kankyo/func_800FB9B4.s,func_800FB9B4,0x800FB9B4,0xC2 -asm/non_matchings/code/z_kankyo/func_800FBCBC.s,func_800FBCBC,0x800FBCBC,0x4C +asm/non_matchings/code/z_kankyo/Environment_DrawCustomLensFlare.s,Environment_DrawCustomLensFlare,0x800FBCBC,0x4C asm/non_matchings/code/z_kankyo/Kankyo_InitGameOverLights.s,Kankyo_InitGameOverLights,0x800FBDEC,0x54 asm/non_matchings/code/z_kankyo/Kankyo_FadeInGameOverLights.s,Kankyo_FadeInGameOverLights,0x800FBF3C,0x87 asm/non_matchings/code/z_kankyo/Kankyo_FadeOutGameOverLights.s,Kankyo_FadeOutGameOverLights,0x800FC158,0xA1 asm/non_matchings/code/z_kankyo/func_800FC3DC.s,func_800FC3DC,0x800FC3DC,0x1A -asm/non_matchings/code/z_kankyo/func_800FC444.s,func_800FC444,0x800FC444,0x82 -asm/non_matchings/code/z_kankyo/func_800FC64C.s,func_800FC64C,0x800FC64C,0x31A +asm/non_matchings/code/z_kankyo/Environment_FillScreen.s,Environment_FillScreen,0x800FC444,0x82 +asm/non_matchings/code/z_kankyo/Environment_DrawSandstorm.s,Environment_DrawSandstorm,0x800FC64C,0x31A asm/non_matchings/code/z_kankyo/func_800FD2B4.s,func_800FD2B4,0x800FD2B4,0xA1 asm/non_matchings/code/z_kankyo/func_800FD538.s,func_800FD538,0x800FD538,0x19 asm/non_matchings/code/z_kankyo/func_800FD59C.s,func_800FD59C,0x800FD59C,0x11 @@ -1972,7 +1972,7 @@ asm/non_matchings/code/z_scene/Scene_SetExitFade.s,Scene_SetExitFade,0x801306A4, asm/non_matchings/code/z_scene/Scene_ProcessHeader.s,Scene_ProcessHeader,0x801306E8,0x20 asm/non_matchings/code/z_scene/Entrance_Create.s,Entrance_Create,0x80130768,0x7 asm/non_matchings/code/z_scene/Entrance_CreateFromSpawn.s,Entrance_CreateFromSpawn,0x80130784,0xF -asm/non_matchings/code/z_scene_proc/Scene_ExecuteDrawConfig.s,Scene_ExecuteDrawConfig,0x801307C0,0xD +asm/non_matchings/code/z_scene_proc/Scene_Draw.s,Scene_Draw,0x801307C0,0xD asm/non_matchings/code/z_scene_proc/Scene_DrawConfigDefault.s,Scene_DrawConfigDefault,0x801307F4,0x10 asm/non_matchings/code/z_scene_proc/AnimatedMat_TexScroll.s,AnimatedMat_TexScroll,0x80130834,0x1B asm/non_matchings/code/z_scene_proc/AnimatedMat_DrawTexScroll.s,AnimatedMat_DrawTexScroll,0x801308A0,0x28 @@ -2457,7 +2457,7 @@ asm/non_matchings/code/z_fbdemo/func_8016418C.s,func_8016418C,0x8016418C,0x30 asm/non_matchings/code/z_fbdemo/TransitionUnk_Destroy.s,TransitionUnk_Destroy,0x8016424C,0x23 asm/non_matchings/code/z_fbdemo/TransitionUnk_Init.s,TransitionUnk_Init,0x801642D8,0x58 asm/non_matchings/code/z_fbdemo/func_80164438.s,func_80164438,0x80164438,0x45 -asm/non_matchings/code/z_fbdemo/func_8016454C.s,func_8016454C,0x8016454C,0x4B +asm/non_matchings/code/z_fbdemo/TransitionUnk_Draw.s,TransitionUnk_Draw,0x8016454C,0x4B asm/non_matchings/code/z_fbdemo/func_80164678.s,func_80164678,0x80164678,0x4D asm/non_matchings/code/z_fbdemo/func_801647AC.s,func_801647AC,0x801647AC,0x3 asm/non_matchings/code/z_fbdemo/func_801647B8.s,func_801647B8,0x801647B8,0x6