From 06412c070f0240eacfaa860eee99b9c723245b7f Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 7 Apr 2022 12:39:11 -0700 Subject: [PATCH] Cleanup 3 (#778) * lights * D_801D88A0 -> gScarecrowSpawnSongPtr * Misc fixes * CHECK_FLAG_ALL * Trailing commas in enums * matches * Remove todo from lights bss * Update src/overlays/actors/ovl_En_In/z_en_in.c Co-authored-by: Anghelo Carvajal * thisx -> this2 * fix * Todos Co-authored-by: Anghelo Carvajal --- include/variables.h | 4 +- include/z64.h | 2 +- include/z64audio.h | 2 +- include/z64item.h | 2 +- include/z64light.h | 1 - include/z64ocarina.h | 2 +- spec | 1 - src/code/z_lights.c | 7 ++- src/code/z_sram_NES.c | 3 +- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 8 +-- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 2 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 35 +++++------- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 2 +- src/overlays/actors/ovl_En_Door/z_en_door.c | 2 +- .../actors/ovl_En_Floormas/z_en_floormas.c | 2 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 4 +- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 18 +++--- .../actors/ovl_En_Minislime/z_en_minislime.c | 8 +-- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 55 ++++++++----------- src/overlays/actors/ovl_En_Tru/z_en_tru.h | 2 + src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c | 3 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 20 +++---- tools/disasm/functions.txt | 6 +- 24 files changed, 93 insertions(+), 100 deletions(-) diff --git a/include/variables.h b/include/variables.h index 1ce8e336d1..605b63939f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1736,7 +1736,7 @@ extern UNK_PTR D_801D84F0; // extern UNK_TYPE2 D_801D853E; // extern UNK_TYPE1 D_801D8544; extern UNK_PTR D_801D889C; -extern UNK_PTR D_801D88A0; +extern u8* gScarecrowSpawnSongPtr; extern UNK_PTR D_801D88A4; // extern UNK_TYPE1 D_801D88A8; // extern UNK_TYPE1 D_801D88B8; @@ -3200,7 +3200,7 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F4F66; // extern UNK_TYPE1 D_801F4F68; // extern UNK_TYPE1 D_801F4F6A; -extern LightsBuffer sLightsBuffer; +// extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F5130; // extern UNK_TYPE1 D_801F5270; // extern UNK_TYPE1 D_801F528E; diff --git a/include/z64.h b/include/z64.h index 6f8067136d..3a7c7ea324 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1156,7 +1156,7 @@ typedef struct { typedef enum { /* 0 */ DISTORTION_INACTIVE, /* 1 */ DISTORTION_ACTIVE, - /* 2 */ DISTORTION_SETUP, + /* 2 */ DISTORTION_SETUP } DistortionState; typedef struct { diff --git a/include/z64audio.h b/include/z64audio.h index ec0fcd7979..5dd78f73ad 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -32,7 +32,7 @@ typedef enum { /* 1 */ AUDIO_MODE_HEADSET, /* 2 */ AUDIO_MODE_UNK, /* 3 */ AUDIO_MODE_MONO, - /* 4 */ AUDIO_MODE_SURROUND, + /* 4 */ AUDIO_MODE_SURROUND } AudioSoundMode; typedef enum { diff --git a/include/z64item.h b/include/z64item.h index 77ceb240cb..a3c8a7c705 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -386,7 +386,7 @@ typedef enum { /* 0x6A */ GID_6A = 0x6A, /* 0x6B */ GID_6B, /* 0x70 */ GID_70 = 0x70, - /* 0x71 */ GID_71, + /* 0x71 */ GID_71 } GetItemDrawID; // TODO: fill diff --git a/include/z64light.h b/include/z64light.h index 8154ca4018..0c90be7134 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -63,7 +63,6 @@ typedef struct LightNode { /* 0x8 */ struct LightNode* next; } LightNode; // size = 0xC -// TODO move LightsBuffer to .c file once .bss has been split #define LIGHTS_BUFFER_SIZE 32 typedef struct LightsBuffer { diff --git a/include/z64ocarina.h b/include/z64ocarina.h index ed634f520e..56ab483127 100644 --- a/include/z64ocarina.h +++ b/include/z64ocarina.h @@ -81,7 +81,7 @@ typedef enum { /* 13 */ OCARINA_INSTRUMENT_PIANO, /* 14 */ OCARINA_INSTRUMENT_BASS_GUITAR, /* 15 */ OCARINA_INSTRUMENT_BABY_SINGING, - /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR, // Related to (gSaveContext.weekEventReg[41] & 0x20) + /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR // Related to (gSaveContext.weekEventReg[41] & 0x20) } OcarinaInstrumentId; typedef enum { diff --git a/spec b/spec index e102d8d2a6..b974bd390b 100644 --- a/spec +++ b/spec @@ -486,7 +486,6 @@ beginseg include "build/src/code/z_lib.o" include "build/src/code/z_lifemeter.o" include "build/src/code/z_lights.o" - include "build/data/code/z_lights.bss.o" include "build/src/code/z_malloc.o" include "build/src/code/z_map_disp.o" include "build/data/code/z_map_disp.data.o" diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 615e11e690..2b0db8ad4e 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -1,6 +1,8 @@ #include "global.h" #include "objects/gameplay_keep/gameplay_keep.h" +LightsBuffer sLightsBuffer; + void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type) { info->type = type; info->params.point.x = x; @@ -128,6 +130,7 @@ void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* global Vec3f posF; Vec3f adjustedPos; u32 pad; + if (radiusF > 0) { posF.x = params->point.x; posF.y = params->point.y; @@ -373,7 +376,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { LightNode* light = globalCtx->lightCtx.listHead; while (light != NULL) { - LightPoint* params = (LightPoint*)&light->info->params; + LightPoint* params = &light->info->params.point; if (light->info->type == LIGHT_POINT_GLOW) { Vec3f pos; @@ -422,7 +425,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { do { if (light->info->type == LIGHT_POINT_GLOW) { - params = (LightPoint*)&light->info->params; + params = &light->info->params.point; if (params->drawGlow) { f32 scale = SQ((f32)params->radius) * 2e-6f; diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index b1dbdb1fe6..52acc9379e 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -979,7 +979,8 @@ void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { } if (gSaveContext.save.unk_F65) { - Lib_MemCpy(D_801D88A0, gSaveContext.save.scarecrowsSong, sizeof(gSaveContext.save.scarecrowsSong)); + Lib_MemCpy(gScarecrowSpawnSongPtr, gSaveContext.save.scarecrowsSong, + sizeof(gSaveContext.save.scarecrowsSong)); for (i = 0; i != ARRAY_COUNT(gSaveContext.save.scarecrowsSong); i++) {} } diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 9020f368ca..8c55cc2f34 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -164,7 +164,7 @@ void func_80953F14(BgIngate* this, GlobalContext* globalCtx) { player->actor.focus.rot.y = player->actor.shape.rot.y; this->unk160 |= 0x10; func_80953DA8(this, globalCtx); - if (this->unk164 != 0) { + if (this->unk164 != NULL) { func_80953B40(this); } this->unk16E = -1; @@ -259,7 +259,7 @@ void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { void func_80954340(BgIngate* this, GlobalContext* globalCtx) { if (!DECR(this->unk16A)) { - if (this->unk164 != 0) { + if (this->unk164 != NULL) { func_800B7298(globalCtx, &this->dyna.actor, 6); this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; func_80953F14(this, globalCtx); @@ -285,7 +285,7 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { func_800FE498(); func_8019F208(); } else { - if (this->unk164 != 0) { + if (this->unk164 != NULL) { this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; } func_80953F14(this, globalCtx); @@ -351,7 +351,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { } } this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); - if (this->unk164 != 0) { + if (this->unk164 != NULL) { sp38 = Lib_SegmentedToVirtual(this->unk164->points); Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); Math_Vec3s_ToVec3f(&sp20, &sp38[1]); diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index e151226886..b51fc64eca 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -633,7 +633,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, MTXMODE_APPLY); alphaScale = Math_Vec3f_DistXYZ(&worldPos, &globalCtx->view.eye) / 300.0f; - alphaScale = (alphaScale > 1.0f) ? 0.0f : (1.0f - alphaScale) > 1.0f ? 1.0f : 1.0f - alphaScale; + alphaScale = CLAMP(1.0f - alphaScale, 0.0f, 1.0f); if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { this->particles[i].alpha = 255.0f * alphaScale; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index ac5b19ecff..38ab1c5d2e 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -1014,7 +1014,6 @@ void EnBigpo_RevealedFireIdle(EnBigpo* this, GlobalContext* globalCtx) { if (this->idleTimer == 0) { //! @bug: unreachable code this->actor.params = ENBIGPO_UNK5; - return; } } else { if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.001f)) { @@ -1089,7 +1088,7 @@ void EnBigpo_UpdateColor(EnBigpo* this) { // this might be a triple ternary but it matches and is easier to read spread out bplus5 = this->mainColor.b + 5; - if (this->mainColor.b >= 211) { + if (this->mainColor.b > 210) { bminus5 = this->mainColor.b - 5; if (bminus5 < 210) { this->mainColor.b = 210; @@ -1097,7 +1096,7 @@ void EnBigpo_UpdateColor(EnBigpo* this) { this->mainColor.b = bminus5; } } else { - if (bplus5 >= 211) { + if (bplus5 > 210) { this->mainColor.b = 210; } else { this->mainColor.b = bplus5; @@ -1153,7 +1152,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ColliderCylinder* thisCollider; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->hoverHeightCycleTimer = 0; this->savedHeight = this->actor.world.pos.y; } @@ -1265,25 +1264,20 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbByte != -1) { if (limbByte < 3) { Matrix_GetStateTranslation(&this->limbPos[limbByte]); - return; - } - if (limbByte == 3) { + } else if (limbByte == 3) { Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[limbByte]); - return; - } - if (limbByte == 4) { + } else if (limbByte == 4) { Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[limbByte]); - return; - } + } else { + v2ptr = &this->limbPos[limbByte + 1]; + v1ptr = D_80B65084; + Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); - v2ptr = &this->limbPos[limbByte + 1]; - v1ptr = D_80B65084; - Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); - - for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(v1ptr, v2ptr); - v2ptr++; - v1ptr++; + for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { + Matrix_MultiplyVector3fByState(v1ptr, v2ptr); + v2ptr++; + v1ptr++; + } } } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1443,6 +1437,7 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->fires); i++) { EnBigpoFireEffect* firePtr = &this->fires[i]; + Lights_PointNoGlowSetInfo(&this->fires[i].info, this->fires[i].pos.x, this->fires[i].pos.y, this->fires[i].pos.z, 170, 255, 255, fireRadius); mtfxPtr->wx = firePtr->pos.x; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index c0c1326a3b..5428e701a5 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -2176,7 +2176,7 @@ void EnBigslime_SetupDamageGekko(EnBigslime* this, s32 isNotFrozen) { } EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DAMAGE); - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index 1fdbbd32f2..bb1c574e2d 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -514,7 +514,7 @@ s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList *dList = dl[dlIndex]; } } - return 0; + return false; } void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index 489d464413..de7d340249 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -558,7 +558,7 @@ void func_808D19D4(EnFloormas* this) { this->drawDmgEffAlpha = 0.0f; Actor_SetScale(&this->actor, 0.004f); this->actor.flags |= ACTOR_FLAG_10; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { this->actor.draw = func_808D3754; } else { this->actor.draw = EnFloormas_Draw; diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.c b/src/overlays/actors/ovl_En_Gg/z_en_gg.c index d889bc7a06..3d80cc8474 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -230,7 +230,7 @@ void func_80B35450(EnGg* this, GlobalContext* globalCtx) { } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { func_800B90F4(globalCtx); } this->unk_308 = 1; @@ -239,7 +239,7 @@ void func_80B35450(EnGg* this, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[19] & 0x80) { func_800B863C(&this->actor, globalCtx); this->actor.textId = 0xCEE; - } else if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { func_800B863C(&this->actor, globalCtx); this->actor.textId = 0xCE5; } diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c index 2f68a1a1d2..e15e3adb3c 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -261,7 +261,7 @@ void func_8095345C(EnHs* this, GlobalContext* globalCtx) { } else if (this->actor.home.rot.x >= 20) { this->actionFunc = func_80953354; this->unk_2A2 = 40; - } else if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_10000) { + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); this->unk_2A0 |= 1; } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 57c4bfe475..758543f452 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -295,9 +295,10 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { } void func_808F374C(EnIn* this, GlobalContext* globalCtx) { - AnimationHeader* animations[] = { &object_in_Anim_015E38, &object_in_Anim_016A60, &object_in_Anim_0177AC, - &object_in_Anim_016484, &object_in_Anim_0170DC, &object_in_Anim_018240, - &object_in_Anim_0187C8, &object_in_Anim_0198A8 }; + AnimationHeader* sAnimations[] = { + &object_in_Anim_015E38, &object_in_Anim_016A60, &object_in_Anim_0177AC, &object_in_Anim_016484, + &object_in_Anim_0170DC, &object_in_Anim_018240, &object_in_Anim_0187C8, &object_in_Anim_0198A8, + }; if (this->skelAnime.animation == &object_in_Anim_016484 || this->skelAnime.animation == &object_in_Anim_0170DC) { if (Animation_OnFrame(&this->skelAnime, 8.0f)) { @@ -312,9 +313,10 @@ void func_808F374C(EnIn* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_CRY_0); } if (SkelAnime_Update(&this->skelAnime)) { - this->unk486 = this->unk488 %= 8; - Animation_Change(&this->skelAnime, animations[this->unk488], 1.0f, 0.0f, - Animation_GetLastFrame(animations[this->unk488]), 2, -10.0f); + this->unk488 %= ARRAY_COUNT(sAnimations); + this->unk486 = this->unk488; + Animation_Change(&this->skelAnime, sAnimations[this->unk488], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[this->unk488]), 2, -10.0f); } } @@ -1365,7 +1367,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk4AC = 0; type = ENIN_GET_TYPE(thisx); this->unk4B0 = GET_RACE_FLAGS; - if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == 4) { + if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == ENIN_BLUE_SHIRT) { this->unk4AC |= 8; } if (type == ENIN_HORSE_RIDER_YELLOW_SHIRT || type == ENIN_HORSE_RIDER_BLUE_SHIRT) { @@ -1385,7 +1387,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->path = SubS_GetPathByIndex(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { - if (GET_RACE_FLAGS == RACE_FLAG_2 || (GET_RACE_FLAGS) == RACE_FLAG_3) { + if (GET_RACE_FLAGS == RACE_FLAG_2 || GET_RACE_FLAGS == RACE_FLAG_3) { gSaveContext.save.weekEventReg[56] &= (u8)~8; this->unk4A8 = 0; this->unk4AC |= 2; diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index ea43899175..4efc187144 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -506,7 +506,7 @@ void EnMinislime_SetupMoveToBigslime(EnMinislime* this) { } this->frozenAlpha = 0; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnMinislime_MoveToBigslime; @@ -562,7 +562,7 @@ void EnMinislime_SetupDefeatIdle(EnMinislime* this) { } this->frozenAlpha = 0; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } @@ -630,7 +630,7 @@ void EnMinislime_SetupMoveToGekko(EnMinislime* this) { this->actor.velocity.y = 0.0f; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 &= ~OC1_ON; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } @@ -720,7 +720,7 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { } else if ((this->actor.params == MINISLIME_FORM_BIGSLIME) && (this->actionFunc != EnMinislime_MoveToBigslime)) { EnMinislime_SetupMoveToBigslime(this); } else { - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->collider.base.acFlags &= ~AC_HIT; return; } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 909cc2f99e..ea0e8ae44e 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -807,42 +807,33 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80A8777C(Actor* thisx, GlobalContext* globalCtx) { - s32 temp_v0; + EnTru* this = THIS; s32 ret = 0; - - temp_v0 = Message_GetState(&globalCtx->msgCtx); + s32 temp_v0 = Message_GetState(&globalCtx->msgCtx); switch (temp_v0) { - default: - if (temp_v0 != 0x10) { - break; - } - if (0) { - - case 4: - case 5: - if (!Message_ShouldAdvance(globalCtx)) { - break; + case 4: + case 5: + if (Message_ShouldAdvance(globalCtx)) { + case 16: + temp_v0 = func_80123810(globalCtx); + if ((temp_v0 == 35) || (temp_v0 == 36)) { + this->unk_34E |= 8; + if (temp_v0 == 35) { + this->unk_390 = 1; + } else { + this->unk_390 = 2; + } + this->unk_378 = func_80A87880; + this->unk_364 = 0; + ret = 1; + } else if (temp_v0 < 0) { + ret = 3; + } else if (temp_v0 != 0) { + ret = 2; } + break; } - - temp_v0 = func_80123810(globalCtx); - if ((temp_v0 == 35) || (temp_v0 == 36)) { - ((EnTru*)thisx)->unk_34E |= 8; - if (temp_v0 == 35) { - ((EnTru*)thisx)->unk_390 = 1; - } else { - ((EnTru*)thisx)->unk_390 = 2; - } - ((EnTru*)thisx)->unk_378 = func_80A87880; - ((EnTru*)thisx)->unk_364 = 0; - ret = 1; - } else if (temp_v0 < 0) { - ret = 3; - } else if (temp_v0 != 0) { - ret = 2; - } - break; } return ret; @@ -1127,7 +1118,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); this->unk_37C = -1; func_80A86924(this, 0); - this->path = SubS_GetDayDependentPath(globalCtx, this->actor.params & 0xFF, 255, &this->unk_384); + this->path = SubS_GetDayDependentPath(globalCtx, ENTRU_GET_PATH(&this->actor), 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.h b/src/overlays/actors/ovl_En_Tru/z_en_tru.h index 4127fcdff8..d1090cec44 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -8,6 +8,8 @@ struct EnTru; typedef void (*EnTruActionFunc)(struct EnTru*, GlobalContext*); typedef s32 (*EnTruUnkFunc)(Actor*, GlobalContext*); +#define ENTRU_GET_PATH(thisx) ((thisx)->params & 0xFF) + typedef struct { /* 0x00 */ u8 unk_00; /* 0x01 */ u8 unk_01; diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index 18aafc07ad..c6de60ce2b 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -465,7 +465,8 @@ void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayS // Remove reflections that are in the same position and are sufficiently near to the same plane void MirRay_RemoveSimilarReflections(MirRayShieldReflection* reflection) { - s32 i, j; + s32 i; + s32 j; for (i = 0; i < 6; i++) { for (j = i + 1; j < 6; j++) { diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 2d84030f1f..8a822bea4b 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -64,7 +64,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void ObjChan_InitChandelier(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx); void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx); void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx); void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx); @@ -150,8 +150,9 @@ void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* childRotOut->y += childAngle; } -void ObjChan_InitChandelier(ObjChan* this, GlobalContext* globalCtx) { - s32 j; +//! @TODO: Possibly takes actor and recasts +void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx) { + ObjChan* this = this2; s32 i; ObjChan* temp_v0; Vec3f childPos; @@ -173,13 +174,11 @@ void ObjChan_InitChandelier(ObjChan* this, GlobalContext* globalCtx) { } for (i = 0; i < 5; i++) { - temp_v0 = (ObjChan*)&globalCtx->actorCtx; // strange cast needed for matching ObjChan_CalculatePotPosition(&childPos, &childRot, &this->actor.world.pos, &this->actor.shape.rot, (s32)(i * 360.0f / 5.0f * (65536.0f / 360.0f)) + this->rotation); - temp_v0 = (ObjChan*)Actor_SpawnAsChildAndCutscene((ActorContext*)temp_v0, globalCtx, ACTOR_OBJ_CHAN, childPos.x, - childPos.y, childPos.z, childRot.x, childRot.y, childRot.z, - (this->actor.params & 0xFFF) | 0x1000, this->actor.cutscene, - this->actor.unk20, &this->actor); + temp_v0 = (ObjChan*)Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_OBJ_CHAN, childPos.x, childPos.y, childPos.z, childRot.x, childRot.y, + childRot.z, (this->actor.params & 0xFFF) | 0x1000, this->actor.cutscene, this->actor.unk20, &this->actor); if (temp_v0 != NULL) { this->pots[i] = temp_v0; temp_v0->myPotIndex = i; @@ -210,8 +209,9 @@ void ObjChan_InitChandelier(ObjChan* this, GlobalContext* globalCtx) { this->actionFunc = ObjChan_ChandelierAction; } -void ObjChan_ChandelierAction(ObjChan* thisx, GlobalContext* globalCtx) { - ObjChan* this = thisx; +//! @TODO: More descriptive name than Action? +void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { + ObjChan* this = this2; ObjChan* temp; s32 i; Vec3f sp60; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index d1bc43e784..bed963c7a2 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15376,11 +15376,11 @@ 0x80BB99F0:("ObjChan_Destroy",), 0x80BB9A1C:("func_80BB9A1C",), 0x80BB9B40:("ObjChan_CalculatePotPosition",), - 0x80BB9C08:("ObjChan_InitMain",), - 0x80BB9F24:("ObjChan_MainAction",), + 0x80BB9C08:("ObjChan_InitChandelier",), + 0x80BB9F24:("ObjChan_ChandelierAction",), 0x80BBA2FC:("ObjChan_InitPot",), 0x80BBA314:("ObjChan_PotAction",), - 0x80BBA488:("func_80BBA488",), + 0x80BBA488:("ObjChan_CreateSmashParticles",), 0x80BBA738:("ObjChan_Update",), 0x80BBA78C:("ObjChan_Draw",), 0x80BBA894:("ObjChan_DrawPot",),