General Cleanup 4 (#871)

* PartTimerWorker -> PartTimer

* cleanup

* format

* objChan draw macro

* Fix macro

* Fix warning

* PR Review

* Missed 1 ull

* UINT16_MAX

* Remove todo from footmark

* Remove * from tex in AnimatedMat_DrawTexCycle
This commit is contained in:
Derek Hensley
2022-07-11 23:06:21 -04:00
committed by GitHub
parent 81ce7bebcc
commit 85b19de4ab
99 changed files with 447 additions and 438 deletions
+2 -1
View File
@@ -53,7 +53,8 @@
<Texture Name="gFsnUnusedEyeHalfTex" OutName="fsn_unused_eye_half" Format="rgba32" Width="32" Height="32" Offset="0x9640" />
<Texture Name="gFsnUnusedEyeClosedTex" OutName="fsn_unused_eye_closed" Format="rgba32" Width="32" Height="32" Offset="0xA640" />
<!-- <Blob Name="object_fsn_Blob_00B640" Size="398" Offset="0xB640" /> -->
<!-- Unused Empty Eye Texture Animation -->
<TextureAnimation Name="gFsnUnusedTexAnim" Offset="0xB664" />
<!-- Animations -->
<Animation Name="gFsnSlamCounterStartAnim" Offset="0xB9D8" />
+1 -1
View File
@@ -420,7 +420,7 @@ This leaves one piece of data unnamed, `D_80C106C8`. This is initially set to `0
What is this doing? We need to understand that to name this variable.
The N64's processors cannot use segmented addresses: they need actual RAM addresses. Therefore the segmented addresses have to be converted before being placed on a segment: this is what `Lib_SegmentedToVirtual` does. So (somewhat unusually) this loop is modifying the addresses in the actor's actual data in RAM. Having converted the addresses once, it wouldn't make any sense to convert them again, but `Init` would run every time an instantiation of the actor is created. Therefore `D_80C106C8` is present to ensure that the addresses only get converted once: it is really a boolean that indicates if the addresses have been converted. So let's call it `texturesDesegmented`, and replace its values by `true` and `false`.
The N64's processors cannot use segmented addresses: they need actual RAM addresses. Therefore the segmented addresses have to be converted before being placed on a segment: this is what `Lib_SegmentedToVirtual` does. So (somewhat unusually) this loop is modifying the addresses in the actor's actual data in RAM. Having converted the addresses once, it wouldn't make any sense to convert them again, but `Init` would run every time an instantiation of the actor is created. Therefore `D_80C106C8` is present to ensure that the addresses only get converted once: it is really a boolean that indicates if the addresses have been converted. So let's call it `sTexturesDesegmented`, and replace its values by `true` and `false`.
Finally, clearly `4` is linked to the data over which we're iterating: namely it's the size of the array. We have a macro for this, `ARRAY_COUNT(sEyeTextures)`.
-1
View File
@@ -9,7 +9,6 @@
#define FLT_MAX 340282346638528859811704183484516925440.0f
#define SHT_MAX 32767.0f
#define SHT_MINV (1.0f / SHT_MAX)
#define DEGTORAD(x) ((x) * (M_PI / 180.0f))
typedef union {
f64 d;
-1
View File
@@ -16,7 +16,6 @@
// TODO: After uintptr_t cast change should have an AVOID_UB target that just toggles the KSEG0 bit in the address rather than add/sub 0x80000000
#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) + RDRAM_CACHED)
#define PHYSICAL_TO_VIRTUAL2(addr) ((uintptr_t)(addr) - RDRAM_CACHED)
#define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr) - RDRAM_CACHED)
#define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr))
+1 -1
View File
@@ -377,7 +377,7 @@ typedef struct {
typedef struct {
/* 0x0 */ u16 keyFrameLength;
/* 0x4 */ void* textureList;
/* 0x4 */ TexturePtr* textureList;
/* 0x8 */ u8* textureIndexList;
} AnimatedMatTexCycleParams; // size = 0xC
+4 -4
View File
@@ -39,7 +39,7 @@ typedef void (*EnHyActionFunc)(struct EnHy*, PlayState*);
typedef struct EnHy {
/* 0x000 */ Actor actor;
/* 0x144 */ EnHyActionFunc actionFunc;
/* 0x148 */ EnHyActionFunc tmpActionFunc;
/* 0x148 */ EnHyActionFunc prevActionFunc;
/* 0x14C */ SkelAnime skelAnime;
/* 0x190 */ s8 headObjIndex; // Limb 15
/* 0x191 */ s8 skelUpperObjIndex; // Limbs 8-14
@@ -60,9 +60,9 @@ typedef struct EnHy {
/* 0x2C6 */ Vec3s trackTarget;
/* 0x2CC */ Vec3s headRot;
/* 0x2D2 */ Vec3s torsoRot;
/* 0x2D8 */ Vec3s tmptrackTarget;
/* 0x2DE */ Vec3s tmpHeadRot;
/* 0x2E4 */ Vec3s tmpTorsoRot;
/* 0x2D8 */ Vec3s prevTrackTarget;
/* 0x2DE */ Vec3s prevHeadRot;
/* 0x2E4 */ Vec3s prevTorsoRot;
/* 0x2EA */ s16 limbRotTableY[16];
/* 0x30A */ s16 limbRotTableZ[16];
/* 0x32C */ Vec3f bodyPartsPos[15];
+3 -2
View File
@@ -29,7 +29,7 @@ const char* sFpuExceptions[] = {
};
void Fault_SleepImpl(u32 duration) {
u64 value = (duration * OS_CPU_COUNTER) / 1000ull;
u64 value = (duration * OS_CPU_COUNTER) / 1000ULL;
Sleep_Cycles(value);
}
@@ -702,8 +702,9 @@ void Fault_ResumeThread(OSThread* t) {
osStartThread(t);
}
void Fault_CommitFB() {
void Fault_CommitFB(void) {
u16* fb;
osViSetYScale(1.0f);
osViSetMode(&osViModeNtscLan1);
osViSetSpecialFeatures(0x42); // gama_disable|dither_fliter_enable_aa_mode3_disable
+1 -1
View File
@@ -277,7 +277,7 @@ void AudioLoad_InitSampleDmaBuffers(s32 numNotes) {
} else {
AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize);
dma->size = gAudioContext.sampleDmaBufSize;
dma->devAddr = 0U;
dma->devAddr = 0;
dma->sizeUnused = 0;
dma->unused = 0;
dma->ttl = 0;
+2 -2
View File
@@ -192,7 +192,7 @@ void GameState_Realloc(GameState* gameState, size_t size) {
void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* gfxCtx) {
gameState->gfxCtx = gfxCtx;
gameState->frames = 0U;
gameState->frames = 0;
gameState->main = NULL;
gameState->destroy = NULL;
gameState->running = 1;
@@ -201,7 +201,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
gfxCtx->xScale = gViConfigXScale;
gfxCtx->yScale = gViConfigYScale;
gameState->nextGameStateInit = NULL;
gameState->nextGameStateSize = 0U;
gameState->nextGameStateSize = 0;
{
s32 requiredScopeTemp;
+2 -2
View File
@@ -172,14 +172,14 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) {
f32 alphaRatio;
if ((actor->id == ACTOR_PLAYER) && (((Player*)actor)->stateFlags3 & 0x8000)) {
f32 tmpScaleZ = actor->scale.z;
f32 prevScaleZ = actor->scale.z;
actor->scale.z += 0.03f * fabsf(Math_CosS(((Player*)actor)->unk_AAA));
actor->shape.shadowScale *= 0.2f;
alphaRatio = distToFloor * 0.03f;
actor->shape.shadowAlpha = actor->shape.shadowAlpha * CLAMP_MAX(alphaRatio, 1.0f);
ActorShadow_Draw(actor, mapper, play, gCircleShadowDL, NULL);
actor->scale.z = tmpScaleZ;
actor->scale.z = prevScaleZ;
} else {
actor->shape.shadowScale *= 0.3f;
alphaRatio = (distToFloor - 20.0f) * 0.02f;
+1 -1
View File
@@ -77,7 +77,7 @@ void EffFootmark_Update(PlayState* play) {
for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) {
if (footmark->actor != NULL) {
if ((footmark->flags & 1) == 1) {
if (footmark->age < 0xFFFFu) { // TODO replace with MAX_U16 or something
if ((u32)footmark->age < UINT16_MAX) {
footmark->age++;
}
+1 -1
View File
@@ -32,7 +32,7 @@
#include "overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.h"
#include "overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h"
void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) {
void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, TexturePtr texture) {
GraphicsContext* gfxCtx = play->state.gfxCtx;
f32 scale;
MtxF mfTrans;
+2 -2
View File
@@ -363,10 +363,10 @@ void AnimatedMat_DrawColorNonLinearInterp(PlayState* play, s32 segment, void* pa
*/
void AnimatedMat_DrawTexCycle(PlayState* play, s32 segment, void* params) {
AnimatedMatTexCycleParams* texAnimParams = params;
void** texList = Lib_SegmentedToVirtual(texAnimParams->textureList);
TexturePtr* texList = Lib_SegmentedToVirtual(texAnimParams->textureList);
u8* texId = Lib_SegmentedToVirtual(texAnimParams->textureIndexList);
s32 curFrame = sMatAnimStep % texAnimParams->keyFrameLength;
void* tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]);
TexturePtr tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]);
OPEN_DISPS(play->state.gfxCtx);
+1 -1
View File
@@ -57,7 +57,7 @@ void osInitialize(void) {
osUnmapTLBAll();
osMapTLBRdb();
osClockRate = (u64)((osClockRate * 3ll) / 4ull);
osClockRate = (u64)((osClockRate * 3LL) / 4ULL);
if (osResetType == COLD_RESET) {
bzero(osAppNmiBuffer, 64);
@@ -66,7 +66,7 @@ static Gfx* sDLists[] = { gClockTowerCeilingCogDL, gClockTowerCenterCogDL, gCloc
void BgCtowerGear_Splash(BgCtowerGear* this, PlayState* play) {
s32 i;
s32 flag40 = this->dyna.actor.flags & 0x40;
s32 flag40 = this->dyna.actor.flags & ACTOR_FLAG_40;
Vec3f splashSpawnPos;
Vec3f splashOffset;
s32 pad;
@@ -75,7 +75,7 @@ void BgIkanaDharma_SpawnEffects(BgIkanaDharma* this, PlayState* play) {
for (i = 0; i < 4; i++) {
f32 speed = (Rand_ZeroOne() * 5.0f) + 5.0f;
s16 angle = ((u32)Rand_Next() >> 0x12) + this->dyna.actor.world.rot.y + 0x6000;
s16 angle = (Rand_Next() >> 0x12) + this->dyna.actor.world.rot.y + 0x6000;
f32 dirX = Math_SinS(angle);
f32 dirZ = Math_CosS(angle);
@@ -132,7 +132,7 @@ void func_80BD599C(BgIkanaShutter* this) {
}
void func_80BD59C4(BgIkanaShutter* this, PlayState* play) {
if (BgIkanaShutter_AllSwitchesPressed(this, play) == 0) {
if (!BgIkanaShutter_AllSwitchesPressed(this, play)) {
func_80BD59F8(this);
}
}
@@ -107,7 +107,7 @@ void func_80C072D0(BgIkninside* this, PlayState* play) {
if ((this->collider.info.acHitInfo != NULL) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000)) {
for (i = 0; i < 20; i++) {
altitude = Rand_S16Offset(0x1800, 0x2800);
azimuth = (u32)Rand_Next() >> 0x10;
azimuth = Rand_Next() >> 0x10;
speed = Rand_ZeroFloat(3.0f) + 8.0f;
velocity.x = speed * Math_CosS(altitude) * Math_SinS(azimuth);
velocity.y = speed * Math_SinS(altitude) + Rand_ZeroFloat(5.0f);
+13 -14
View File
@@ -15,10 +15,10 @@ void BgLadder_Init(Actor* thisx, PlayState* play);
void BgLadder_Destroy(Actor* thisx, PlayState* play);
void BgLadder_Update(Actor* thisx, PlayState* play);
void BgLadder_Draw(Actor* thisx, PlayState* play);
void BgLadder_ActionWait(BgLadder* this, PlayState* play);
void BgLadder_ActionStartCutscene(BgLadder* this, PlayState* play);
void BgLadder_ActionFadeIn(BgLadder* this, PlayState* play);
void BgLadder_ActionIdle(BgLadder* this, PlayState* play);
void BgLadder_Wait(BgLadder* this, PlayState* play);
void BgLadder_StartCutscene(BgLadder* this, PlayState* play);
void BgLadder_FadeIn(BgLadder* this, PlayState* play);
void BgLadder_DoNothing(BgLadder* this, PlayState* play);
const ActorInit Bg_Ladder_InitVars = {
ACTOR_BG_LADDER,
@@ -49,7 +49,6 @@ void BgLadder_Init(Actor* thisx, PlayState* play) {
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
// Has to be `thisx` instead of `&this->actor` to match
this->switchFlag = GET_BGLADDER_SWITCHFLAG(thisx);
thisx->params = GET_BGLADDER_SIZE(thisx);
DynaPolyActor_Init(&this->dyna, 0);
@@ -72,13 +71,13 @@ void BgLadder_Init(Actor* thisx, PlayState* play) {
// If the flag is set, then the ladder draws immediately
this->alpha = 255;
this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off
this->action = BgLadder_ActionIdle;
this->action = BgLadder_DoNothing;
} else {
// Otherwise, the ladder doesn't draw; wait for the flag to be set
this->alpha = 5;
func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId);
this->dyna.actor.draw = NULL;
this->action = BgLadder_ActionWait;
this->action = BgLadder_Wait;
}
}
@@ -88,27 +87,27 @@ void BgLadder_Destroy(Actor* thisx, PlayState* play) {
DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId);
}
void BgLadder_ActionWait(BgLadder* this, PlayState* play) {
void BgLadder_Wait(BgLadder* this, PlayState* play) {
// Wait for the flag to be set, then trigger the cutscene
if (Flags_GetSwitch(play, this->switchFlag)) {
ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene);
this->action = BgLadder_ActionStartCutscene;
this->action = BgLadder_StartCutscene;
}
}
void BgLadder_ActionStartCutscene(BgLadder* this, PlayState* play) {
void BgLadder_StartCutscene(BgLadder* this, PlayState* play) {
// Trigger the cutscene, then make the ladder fade in
if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) {
ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor);
this->dyna.actor.draw = BgLadder_Draw;
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SECRET_LADDER_APPEAR);
this->action = BgLadder_ActionFadeIn;
this->action = BgLadder_FadeIn;
} else {
ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene);
}
}
void BgLadder_ActionFadeIn(BgLadder* this, PlayState* play) {
void BgLadder_FadeIn(BgLadder* this, PlayState* play) {
// Fade in the ladder, then stop the cutscene & go idle
this->alpha += 5;
if (this->alpha >= 255) {
@@ -116,11 +115,11 @@ void BgLadder_ActionFadeIn(BgLadder* this, PlayState* play) {
ActorCutscene_Stop(this->dyna.actor.cutscene);
func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId);
this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off
this->action = BgLadder_ActionIdle;
this->action = BgLadder_DoNothing;
}
}
void BgLadder_ActionIdle(BgLadder* this, PlayState* play) {
void BgLadder_DoNothing(BgLadder* this, PlayState* play) {
}
void BgLadder_Update(Actor* thisx, PlayState* play) {
+11 -11
View File
@@ -1661,7 +1661,7 @@ void func_809DD934(Boss02* this, PlayState* play) {
break;
case 1:
if ((this->unk_1D14 < 80U) && (D_809E0420 != 0) &&
if ((this->unk_1D14 < 80) && (D_809E0420 != 0) &&
CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button,
BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) {
this->unk_1D18++;
@@ -1669,7 +1669,7 @@ void func_809DD934(Boss02* this, PlayState* play) {
this->unk_1D14 = 0;
} else {
label1:
if (this->unk_1D14 >= 50U) {
if (this->unk_1D14 >= 50) {
if (this->unk_1D14 == (u32)(BREG(43) + 60)) {
play_sound(NA_SE_PL_TRANSFORM_GIANT);
}
@@ -1682,17 +1682,17 @@ void func_809DD934(Boss02* this, PlayState* play) {
Math_ApproachF(&this->unk_1D64, 30.0f, 0.1f, 1.0f);
}
if (this->unk_1D14 > 50U) {
if (this->unk_1D14 > 50) {
Math_ApproachZeroF(&this->unk_1D58, 1.0f, 0.06f);
} else {
Math_ApproachF(&this->unk_1D58, 0.4f, 1.0f, 0.02f);
}
if (this->unk_1D14 == 107U) {
if (this->unk_1D14 == 107) {
this->unk_1D78 = 1;
}
if (this->unk_1D14 < 121U) {
if (this->unk_1D14 < 121) {
break;
}
@@ -1703,14 +1703,14 @@ void func_809DD934(Boss02* this, PlayState* play) {
break;
case 2:
if (this->unk_1D14 < 8U) {
if (this->unk_1D14 < 8) {
break;
}
sp57 = 1;
goto block_38;
case 10:
if ((this->unk_1D14 < 30U) && (D_809E0421 != 0) &&
if ((this->unk_1D14 < 30) && (D_809E0421 != 0) &&
CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button,
BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) {
this->unk_1D18++;
@@ -1720,7 +1720,7 @@ void func_809DD934(Boss02* this, PlayState* play) {
}
label2:
if (this->unk_1D14 != 0U) {
if (this->unk_1D14 != 0) {
if (this->unk_1D14 == (u32)(BREG(44) + 10)) {
play_sound(NA_SE_PL_TRANSFORM_NORAML);
}
@@ -1731,18 +1731,18 @@ void func_809DD934(Boss02* this, PlayState* play) {
Math_ApproachF(&this->unk_1D5C, 2.0f, 1.0f, 0.01f);
}
if (this->unk_1D14 == 42U) {
if (this->unk_1D14 == 42) {
this->unk_1D78 = 1;
}
if (this->unk_1D14 > 50U) {
if (this->unk_1D14 > 50) {
D_809E0421 = 1;
goto block_38;
}
break;
case 11:
if (this->unk_1D14 < 8U) {
if (this->unk_1D14 < 8) {
break;
}

Some files were not shown because too many files have changed in this diff Show More