From 36ce1ab877959eb3a40cb01283b1b2270912e1e0 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 19 Aug 2022 19:16:40 -0400 Subject: [PATCH] add docs from debug --- include/functions.h | 6 +- include/z64.h | 19 ++++- src/code/z_play.c | 151 ++++++++++++++++++--------------- tools/disasm/functions.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 5 files changed, 104 insertions(+), 76 deletions(-) diff --git a/include/functions.h b/include/functions.h index e5e438d5d8..5420a27bd7 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2494,8 +2494,8 @@ void KaleidoScopeCall_Init(PlayState* play); void KaleidoScopeCall_Destroy(PlayState* play); void KaleidoScopeCall_Update(PlayState* play); void KaleidoScopeCall_Draw(PlayState* play); -void func_80163C90(PlayStruct_18BF0* arg0); -void func_80163D80(PlayStruct_18BF0* arg0, PlayState* play); +void func_80163C90(TransitionContext* transitionCtx); +void func_80163D80(TransitionContext* transitionCtx, PlayState* play); // void func_80163DC0(void); // void func_8016418C(void); void func_8016424C(FbDemoStruct* this); @@ -2540,7 +2540,7 @@ void func_80165690(void); // void func_80165DF0(void); // void func_80165E1C(void); // void func_80165E7C(void); -// void func_80165EC0(void); +// void Play_SetupTransition(void); // void func_80166060(void); Gfx* func_801660B8(PlayState* play, Gfx* gfx); void Play_Destroy(GameState* thisx); diff --git a/include/z64.h b/include/z64.h index bdb994280a..5844a9b46d 100644 --- a/include/z64.h +++ b/include/z64.h @@ -787,6 +787,7 @@ typedef enum { /* 19 */ TRANS_TYPE_19, /* 20 */ TRANS_TYPE_20, /* 21 */ TRANS_TYPE_21, + /* 22 */ TRANS_TYPE_22, /* 64 */ TRANS_TYPE_64 = 64, /* 70 */ TRANS_TYPE_70 = 70, /* 72 */ TRANS_TYPE_72 = 72, @@ -795,6 +796,16 @@ typedef enum { /* 86 */ TRANS_TYPE_86 = 86 } TransitionType; +typedef enum { + /* 0 */ FBDEMO_FADE, + /* 1 */ FBDEMO_TRIFORCE, + /* 2 */ FBDEMO_WIPE1, + /* 3 */ FBDEMO_WIPE3, + /* 4 */ FBDEMO_WIPE4, + /* 5 */ FBDEMO_CIRCLE, + /* 6 */ FBDEMO_WIPE5 +} FbDemoType; + #define TRANS_NEXT_TYPE_DEFAULT 0xFF typedef struct FaultAddrConvClient { @@ -1089,8 +1100,8 @@ typedef struct { } GameOverContext; // size = 0x2 typedef struct { - /* 0x000 */ s16 unk_00; - /* 0x002 */ s8 unk_02; + /* 0x000 */ s16 transitionType; + /* 0x002 */ s8 fbdemoType; /* 0x003 */ char unk03[0x5]; /* 0x008 */ s32 unk_08; /* 0x00C */ char unk0C[0x224]; @@ -1104,7 +1115,7 @@ typedef struct { /* 0x24C */ void (*unk_24C)(s32*, u32); // RGBA8 colour? /* 0x250 */ s32 (*unk_250)(s32*); /* 0x254 */ char unk254[0x4]; -} PlayStruct_18BF0; // size = 0x258 TransitionContext? +} TransitionContext; // size = 0x258 struct PlayState { /* 0x00000 */ GameState state; @@ -1188,7 +1199,7 @@ struct PlayState { /* 0x18B4A */ u8 transitionMode; /* 0x18B4C */ PreRender pauseBgPreRender; /* 0x18B9C */ char unk_18B9C[0x54]; - /* 0x18BF0 */ PlayStruct_18BF0 unk_18BF0; + /* 0x18BF0 */ TransitionContext transitionCtx; /* 0x18E48 */ TransitionFade unk_18E48; /* 0x18E54 */ SceneTableEntry* loadedScene; /* 0x18E58 */ UNK_PTR unk_18E58; diff --git a/src/code/z_play.c b/src/code/z_play.c index 4b60fa51b6..fdc3f93238 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -17,8 +17,9 @@ extern Struct_80140E80 D_801F6D38; extern Struct_80140E80* D_801F6D4C; extern HiresoStruct D_801F6D50; extern u8 D_801F6DFC; -extern u8 D_801F6DFD; +extern u8 D_801F6DFD; // motion blur "status"? +// Draw Motion Blur void func_80165460(PlayState* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; s32 alpha; @@ -71,29 +72,34 @@ void func_80165460(PlayState* this) { } } +// Motion Blur Init? void func_80165608(void) { SREG(91) = 0; SREG(93) = 0; D_801F6DFD = 0; } +// Motion Blur Destroy? void func_80165630(void) { SREG(91) = 0; SREG(93) = 0; D_801F6DFD = 0; } -void func_80165658(u32 arg0) { - SREG(90) = arg0; +// Sets Motion Blur Alpha +void func_80165658(u32 motionBlurAlpha) { + SREG(90) = motionBlurAlpha; } -void func_8016566C(u32 arg0) { - SREG(90) = arg0; - SREG(91) = 1; +// Sets Motion Blur Alpha and Enables +void func_8016566C(u32 motionBlurAlpha) { + SREG(90) = motionBlurAlpha; + SREG(91) = true; } +// Disables Motion Blur void func_80165690(void) { - SREG(91) = 0; + SREG(91) = false; } void func_801656A4(void* arg0, u16* arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7) { @@ -197,92 +203,103 @@ void func_80165E1C(PreRender* prerender) { func_801656A4(D_80780000, prerender->fbufSave, 320, 80, 64, 240 - 1, 176 - 1, 8); } -s32 func_80165E7C(PlayState* this, s32 arg1) { - s32 phi_v1 = arg1; +s32 func_80165E7C(PlayState* this, s32 transitionType) { + s32 nextTransitionType = transitionType; - if (arg1 == TRANS_TYPE_20) { + if (transitionType == TRANS_TYPE_20) { if (!gSaveContext.save.isNight) { - phi_v1 = TRANS_TYPE_03; + nextTransitionType = TRANS_TYPE_03; } else { - phi_v1 = TRANS_TYPE_02; + nextTransitionType = TRANS_TYPE_02; } } - if (phi_v1 != arg1) { - this->transitionType = phi_v1; + if (nextTransitionType != transitionType) { + this->transitionType = nextTransitionType; } - return phi_v1; + return nextTransitionType; } -void func_80165EC0(PlayState* this, s32 arg1) { - PlayStruct_18BF0* ptr = &this->unk_18BF0; - s32 sp20; +void Play_SetupTransition(PlayState* this, s32 transitionType) { + TransitionContext* transitionCtx = &this->transitionCtx; + s32 fbdemoType; - bzero(ptr, sizeof(this->unk_18BF0)); + bzero(transitionCtx, sizeof(TransitionContext)); - sp20 = -1; - if (arg1 & 0x40) { - sp20 = 3; - } else if ((arg1 & 0x78) == 0x20) { - sp20 = 4; - } else if (!(arg1 & 0x60)) { - switch (arg1) { - case 1: - sp20 = 1; + fbdemoType = -1; + if (transitionType & 0x40) { + fbdemoType = FBDEMO_WIPE3; + } else if ((transitionType & 0x78) == 0x20) { + fbdemoType = FBDEMO_WIPE4; + } else if (!(transitionType & 0x60)) { + switch (transitionType) { + case TRANS_TYPE_01: + fbdemoType = FBDEMO_TRIFORCE; break; - case 0: - case 8: - sp20 = 2; + + case TRANS_TYPE_00: + case TRANS_TYPE_08: + fbdemoType = FBDEMO_WIPE1; break; - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 13: - case 17: - case 18: - case 19: - sp20 = 0; + + case TRANS_TYPE_02: + case TRANS_TYPE_03: + case TRANS_TYPE_04: + case TRANS_TYPE_05: + case TRANS_TYPE_06: + case TRANS_TYPE_07: + case TRANS_TYPE_13: + case TRANS_TYPE_17: + case TRANS_TYPE_18: + case TRANS_TYPE_19: + fbdemoType = FBDEMO_FADE; break; - case 9: - case 10: + + case TRANS_TYPE_09: + case TRANS_TYPE_10: this->transitionMode = TRANS_MODE_04; break; - case 11: + + case TRANS_TYPE_11: this->transitionMode = TRANS_MODE_10; break; - case 12: + + case TRANS_TYPE_12: this->transitionMode = TRANS_MODE_07; break; - case 14: + + case TRANS_TYPE_14: this->transitionMode = TRANS_MODE_12; break; - case 15: + + case TRANS_TYPE_15: this->transitionMode = TRANS_MODE_14; break; - case 16: + + case TRANS_TYPE_16: this->transitionMode = TRANS_MODE_16; break; - case 21: - sp20 = 5; + + case TRANS_TYPE_21: + fbdemoType = 5; break; - case 22: - sp20 = 6; + + case TRANS_TYPE_22: + fbdemoType = 6; break; + default: - sp20 = -1; + fbdemoType = -1; __assert("../z_play.c", 1420); } } else { - sp20 = -1; + fbdemoType = -1; __assert("../z_play.c", 1423); } - ptr->unk_00 = arg1; - ptr->unk_02 = sp20; - if (sp20 != -1) { - func_80163C90(ptr); + transitionCtx->transitionType = transitionType; + transitionCtx->fbdemoType = fbdemoType; + if (fbdemoType != -1) { + func_80163C90(transitionCtx); } } @@ -351,10 +368,10 @@ const char D_801DFB24[] = "fj"; const char D_801DFB28[] = "fk"; void func_80166060(PlayState* this) { - if (this->unk_18BF0.unk_02 != -1) { - func_80163D80(&this->unk_18BF0, this); + if (this->transitionCtx.fbdemoType != -1) { + func_80163D80(&this->transitionCtx, this); } - this->unk_18BF0.unk_00 = -1; + this->transitionCtx.transitionType = -1; } Gfx* func_801660B8(PlayState* this, Gfx* gfx) { @@ -408,7 +425,7 @@ void Play_Destroy(GameState* thisx) { } if ((this->transitionMode == TRANS_MODE_03) || (D_801D0D54 != 0)) { - this->unk_18BF0.unk_234(&this->unk_18BF0.unk_08); + this->transitionCtx.unk_234(&this->transitionCtx.unk_08); func_80166060(this); this->transitionMode = TRANS_MODE_OFF; } @@ -437,10 +454,10 @@ void Play_Destroy(GameState* thisx) { f32 func_801668B4(PlayState* this, Vec3f* arg1, s32* arg2) { Player* player = GET_PLAYER(this); f32 sp38 = player->actor.world.pos.y; - WaterBox* sp34; - s32 sp30; + WaterBox* waterBox; + s32 bgId; - if (!WaterBox_GetSurfaceImpl(this, &this->colCtx, arg1->x, arg1->z, &sp38, &sp34, &sp30)) { + if (!WaterBox_GetSurfaceImpl(this, &this->colCtx, arg1->x, arg1->z, &sp38, &waterBox, &bgId)) { return BGCHECK_Y_MIN; } @@ -448,7 +465,7 @@ f32 func_801668B4(PlayState* this, Vec3f* arg1, s32* arg2) { return BGCHECK_Y_MIN; } - *arg2 = WaterBox_GetLightSettingIndex(&this->colCtx, sp34); + *arg2 = WaterBox_GetLightSettingIndex(&this->colCtx, waterBox); return sp38; } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index bea647d45f..c6d2b441c4 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2983,7 +2983,7 @@ 0x80165E04:("func_80165E04",), 0x80165E1C:("func_80165E1C",), 0x80165E7C:("func_80165E7C",), - 0x80165EC0:("func_80165EC0",), + 0x80165EC0:("Play_SetupTransition",), 0x80166060:("func_80166060",), 0x801660B8:("func_801660B8",), 0x8016613C:("Play_Destroy",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 15c5a5f60c..4774096f17 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2497,7 +2497,7 @@ asm/non_matchings/code/z_play/func_80165DF0.s,func_80165DF0,0x80165DF0,0x5 asm/non_matchings/code/z_play/func_80165E04.s,func_80165E04,0x80165E04,0x6 asm/non_matchings/code/z_play/func_80165E1C.s,func_80165E1C,0x80165E1C,0x18 asm/non_matchings/code/z_play/func_80165E7C.s,func_80165E7C,0x80165E7C,0x11 -asm/non_matchings/code/z_play/func_80165EC0.s,func_80165EC0,0x80165EC0,0x68 +asm/non_matchings/code/z_play/Play_SetupTransition.s,Play_SetupTransition,0x80165EC0,0x68 asm/non_matchings/code/z_play/func_80166060.s,func_80166060,0x80166060,0x16 asm/non_matchings/code/z_play/func_801660B8.s,func_801660B8,0x801660B8,0x21 asm/non_matchings/code/z_play/Play_Destroy.s,Play_Destroy,0x8016613C,0xA2