From afb0fab27533c81e6fb41cf3c1c6ae877e80f851 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 18 Dec 2024 11:39:36 -0800 Subject: [PATCH 1/8] kaleido_map double parens --- src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c index 5f99e096c3..6b0d42c593 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c @@ -770,7 +770,7 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { // Find the region that player is currently in // Loop over region (n) and regionIndex (j) while (true) { - if ((gSceneIdsPerRegion[n][j] == 0xFFFF)) { + if (gSceneIdsPerRegion[n][j] == 0xFFFF) { n++; j = 0; if (n == REGION_MAX) { From 0e0bdaa44430f1a383eac6a9d5ed037036d971a8 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 18 Dec 2024 11:41:08 -0800 Subject: [PATCH 2/8] ObjUm PostLimbDraw fake match --- src/overlays/actors/ovl_Obj_Um/z_obj_um.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c index 75bf7083d1..7b1aec6232 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -1876,10 +1876,10 @@ void ObjUm_SpawnFragments(PlayState* play, Vec3f* potPos) { } } -void ObjUm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void ObjUm_PostLimbDraw(PlayState* play2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + PlayState* play = play2; ObjUm* this = (ObjUm*)thisx; - GraphicsContext* gfxCtx = play->state.gfxCtx; - Mtx* mtx; + GraphicsContext* gfxCtx = play2->state.gfxCtx; Gfx* spFC[] = { NULL, gUmBrokenMinigamePotDL, gUmMinigamePotDL, gUmMinigamePotDL, gUmMinigamePotDL, object_um_DL_0067C0 }; @@ -1905,15 +1905,11 @@ void ObjUm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, } if (limbIndex == UM_LIMB_WAGON_CART_BED) { - Vec3f* potPos; + Mtx* mtx; Vec3f sp88; Vec3s sp80; s32 i; f32 sp70[] = { 2000.0f, 0.0f, -2000.0f }; - s32 pad; - - //! FAKE: - if (i) {} sp80.x = 0; sp80.z = 0; @@ -1934,9 +1930,8 @@ void ObjUm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Matrix_Push(); Matrix_TranslateRotateZYX(&sp88, &sp80); mtx = Matrix_Finalize(gfxCtx); - potPos = &this->potPos[i]; Matrix_MultVec3f(&spC0, &calcPotPos); - SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &calcPotPos, potPos, &spB0); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &calcPotPos, &this->potPos[i], &spB0); if (this->wasPotHit[i]) { this->wasPotHit[i] = false; @@ -1953,9 +1948,6 @@ void ObjUm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, return; } - //! FAKE: - if (play) {} - gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (spFC[this->potsLife[i]] != NULL) { From ac64cca52f86595667a00141859b17fccb09d208 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 18 Dec 2024 11:41:51 -0800 Subject: [PATCH 3/8] z_parameter double parens --- src/code/z_parameter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 7171a661b2..4c6ac58e5d 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2161,7 +2161,7 @@ void Interface_UpdateButtonsPart2(PlayState* play) { (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_MASK_GIANT)) && (GET_CUR_FORM_BTN_ITEM(i) != ITEM_PICTOGRAPH_BOX)) { - if ((gSaveContext.buttonStatus[i] == BTN_ENABLED)) { + if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { restoreHudVisibility = true; gSaveContext.buttonStatus[i] = BTN_DISABLED; } @@ -2176,7 +2176,7 @@ void Interface_UpdateButtonsPart2(PlayState* play) { (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_MASK_GIANT)) && (GET_CUR_FORM_BTN_ITEM(i) != ITEM_PICTOGRAPH_BOX)) { - if ((gSaveContext.buttonStatus[i] == BTN_DISABLED)) { + if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { restoreHudVisibility = true; gSaveContext.buttonStatus[i] = BTN_ENABLED; } From 25ed0c643ef483456c91a2f6052fb8854d9afb05 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 18 Dec 2024 11:44:40 -0800 Subject: [PATCH 4/8] voice_internal func_801A541C return type --- src/audio/voice_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/voice_internal.c b/src/audio/voice_internal.c index 3bef9b2f7d..22a77ede91 100644 --- a/src/audio/voice_internal.c +++ b/src/audio/voice_internal.c @@ -143,7 +143,7 @@ void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 } // Unused -s32 func_801A541C(s32 analog, s32 digital) { +void func_801A541C(s32 analog, s32 digital) { s32 errorCode; OSMesgQueue* serialEventQueue; From 048207447b47e1e47997abe3dff8f5eadb734555 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 18 Dec 2024 11:45:08 -0800 Subject: [PATCH 5/8] audio load missing return comments --- src/audio/lib/load.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/audio/lib/load.c b/src/audio/lib/load.c index d4a3b9d813..98d820ecd3 100644 --- a/src/audio/lib/load.c +++ b/src/audio/lib/load.c @@ -442,6 +442,8 @@ s32 AudioLoad_SyncLoadSample(Sample* sample, s32 fontId) { sample->sampleAddr = sampleAddr; } } + //! @bug Missing return, but the return value is never used so it's fine. + } s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { @@ -458,7 +460,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { if (instrument->normalRangeHi != 0x7F) { return AudioLoad_SyncLoadSample(instrument->highPitchTunedSample.sample, fontId); } - // TODO: is this missing return UB? + //! @bug Missing return, but the return value is never used so it's fine. } else if (instId == 0x7F) { Drum* drum = AudioPlayback_GetDrum(fontId, drumId); @@ -468,7 +470,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { AudioLoad_SyncLoadSample(drum->tunedSample.sample, fontId); return 0; } - // TODO: is this missing return UB? + //! @bug Missing return, but the return value is never used so it's fine. } void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { @@ -561,10 +563,10 @@ s32 AudioLoad_SyncInitSeqPlayer(s32 playerIndex, s32 seqId, s32 arg2) { gAudioCtx.seqPlayers[playerIndex].skipTicks = 0; AudioLoad_SyncInitSeqPlayerInternal(playerIndex, seqId, arg2); - // Intentionally missing return. Returning the result of the above function - // call matches but is UB because it too is missing a return, and using the - // result of a non-void function that has failed to return a value is UB. - // The callers of this function do not use the return value, so it's fine. + //! @bug missing return. Returning the result of the above function + //! call matches but is UB because it too is missing a return, and using the + //! result of a non-void function that has failed to return a value is UB. + //! The callers of this function do not use the return value, so it's fine. } s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIndex, s32 seqId, s32 skipTicks) { @@ -574,7 +576,7 @@ s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIndex, s32 seqId, s32 skipTic gAudioCtx.seqPlayers[playerIndex].skipTicks = skipTicks; AudioLoad_SyncInitSeqPlayerInternal(playerIndex, seqId, 0); - // Missing return, see above. + //! @bug Missing return, see comment in AudioLoad_SyncInitSeqPlayer above. } s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2) { From 85fe5d5c583c11304a58e9af56473475ce93af7a Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Mon, 23 Dec 2024 16:57:07 -0800 Subject: [PATCH 6/8] EnTest7_DrawFeathers --- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 f3b81587dc..a8218b2e3d 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -306,12 +306,8 @@ void EnTest7_UpdateFeathers(PlayState* play, OwlWarpFeather* feathers, EnTest7* } void EnTest7_DrawFeathers(PlayState* play2, OwlWarpFeather* feathers) { - s32 pad[3]; PlayState* play = play2; - Mtx* mtx; - OwlWarpFeather* feather; s32 i; - MtxF sp6C; OPEN_DISPS(play->state.gfxCtx); @@ -322,8 +318,11 @@ void EnTest7_DrawFeathers(PlayState* play2, OwlWarpFeather* feathers) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - for (i = 0, feather = feathers; i < (OWL_WARP_NUM_FEATHERS * sizeof(OwlWarpFeather)); - i += sizeof(OwlWarpFeather), feather++) { + for (i = 0; i < OWL_WARP_NUM_FEATHERS; i++) { + Mtx* mtx; + MtxF sp6C; + OwlWarpFeather* feather = &feathers[i]; + if (feather->type == OWL_WARP_FEATHER_TYPE_DISABLED) { continue; } From 3764358775166d0231579e420d73336482adb0bc Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Mon, 23 Dec 2024 17:07:20 -0800 Subject: [PATCH 7/8] EnTest7_UpdateFeathers --- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 a8218b2e3d..a18a5f8986 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -233,20 +233,20 @@ void EnTest7_UpdateFeatherType2(PlayState* play, OwlWarpFeather* feather) { } void EnTest7_UpdateFeathers(PlayState* play, OwlWarpFeather* feathers, EnTest7* this, s32 arg3, s32 arg4) { - s32 pad[4]; - OwlWarpFeather* feather; - s16 phi_s1; + s32 pad; s32 i; f32 temp_f28; - Vec3f sp8C; f32 temp_f0; f32 temp_f22; f32 temp_f24; f32 temp_f26; f32 temp_f2; + Vec3f sp8C; + OwlWarpFeather* feather; + s16 phi_s1; - for (i = 0, feather = feathers; i < (OWL_WARP_NUM_FEATHERS * sizeof(OwlWarpFeather)); - i += sizeof(OwlWarpFeather), feather++) { + for (i = 0; i < OWL_WARP_NUM_FEATHERS; i++) { + feather = &feathers[i]; if (feather->type == OWL_WARP_FEATHER_TYPE_DISABLED) { continue; From 757723f28487f7f119f25a906a6b81c4285e4082 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Mon, 23 Dec 2024 19:45:35 -0800 Subject: [PATCH 8/8] format --- src/audio/lib/load.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/audio/lib/load.c b/src/audio/lib/load.c index 98d820ecd3..7b36af6a39 100644 --- a/src/audio/lib/load.c +++ b/src/audio/lib/load.c @@ -443,7 +443,6 @@ s32 AudioLoad_SyncLoadSample(Sample* sample, s32 fontId) { } } //! @bug Missing return, but the return value is never used so it's fine. - } s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) {