summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
Diffstat (limited to 'src/code')
-rw-r--r--src/code/code_0x800A5AC0.c46
-rw-r--r--src/code/code_0x800BF9A0.c16
-rw-r--r--src/code/code_0x800CAAD0.c104
-rw-r--r--src/code/code_0x800CAAD0.c.ignore99
-rw-r--r--src/code/z_effect_soft_sprite.c24
-rw-r--r--src/code/z_lib.c462
6 files changed, 368 insertions, 383 deletions
diff --git a/src/code/code_0x800A5AC0.c b/src/code/code_0x800A5AC0.c
index ae76b71d9..801763c66 100644
--- a/src/code/code_0x800A5AC0.c
+++ b/src/code/code_0x800A5AC0.c
@@ -1,53 +1,51 @@
#include <ultra64.h>
#include <global.h>
-// TODO this file looks like an actor, it should be cleaned up as such
+// This file is most likely z_en_a_obj.c
-// This file is most likely En_A_Obj
-
-UNK_RET EnAObj_Init(ActorEnAObj* a0, GlobalContext* a1) {
- ActorEnAObj* s0 = (ActorEnAObj*)a0;
+void EnAObj_Init(ActorEnAObj* this, GlobalContext* ctxt) {
+ ActorEnAObj* s0 = (ActorEnAObj*)this;
s0->base.textId = ((s0->base.variable >> 8) & 0xFF) | 0x300;
s0->base.variable = (s0->base.variable & 0xFF) - 9;
Lib_ApplyActorInitVars((Actor*)s0, (ActorInitVar*)&enAObjInitVar);
Actor_SetPostDrawParams(&s0->base.postDrawParams, 0, (actor_post_draw_func*)func_800B3FC0, 12);
- Collision_InitCylinder(a1, &s0->collision, (Actor*)s0, &enAObjCylinderInit);
+ Collision_InitCylinder(ctxt, &s0->collision, (Actor*)s0, &enAObjCylinderInit);
Collision_CylinderMoveToActor((Actor*)s0, &s0->collision);
s0->base.unkA0.unk16 = 255;
s0->update = (actor_func)EnAObj_Update1;
}
-UNK_RET EnAObj_Fini(ActorEnAObj* a0, GlobalContext* a1) {
- ColCylinder* a2 = &a0->collision;
- Collision_FiniCylinder(a1, a2);
+void EnAObj_Fini(ActorEnAObj* this, GlobalContext* ctxt) {
+ ColCylinder* a2 = &this->collision;
+ Collision_FiniCylinder(ctxt, a2);
}
-UNK_RET EnAObj_Update1(ActorEnAObj* a0, GlobalContext* a1) {
+void EnAObj_Update1(ActorEnAObj* this, GlobalContext* ctxt) {
s16 v0;
s32 v1;
- if (func_800B84D0((Actor*)a0, a1) != 0) {
- a0->update = (actor_func)EnAObj_Update2;
+ if (func_800B84D0((Actor*)this, ctxt) != 0) {
+ this->update = (actor_func)EnAObj_Update2;
} else {
- v0 = a0->base.unk92 - a0->base.postDrawParams.rotation.y;
+ v0 = this->base.unk92 - this->base.postDrawParams.rotation.y;
v1 = (v0 < 0)? -v0 : v0;
- if ((v1 < 10240) || ((a0->base.variable == 1) && (v1 > 22528))) {
- func_800B863C((Actor*)a0, a1);
+ if ((v1 < 10240) || ((this->base.variable == 1) && (v1 > 22528))) {
+ func_800B863C((Actor*)this, ctxt);
}
}
}
-UNK_RET EnAObj_Update2(ActorEnAObj* a0, GlobalContext* a1) {
- if (func_800B867C((Actor*)a0, a1) != 0) {
- a0->update = (actor_func)EnAObj_Update1;
+void EnAObj_Update2(ActorEnAObj* this, GlobalContext* ctxt) {
+ if (func_800B867C((Actor*)this, ctxt) != 0) {
+ this->update = (actor_func)EnAObj_Update1;
}
}
-UNK_RET EnAObj_Main(ActorEnAObj* a0, GlobalContext* a1) {
- (a0->update)((Actor*)a0, (GlobalContext*)a1);
- func_800B675C((Actor*)a0, 45.0f);
- Collision_AddOT(a1, &a1->collisionContext, (ColCommon*)&a0->collision);
+void EnAObj_Main(ActorEnAObj* this, GlobalContext* ctxt) {
+ (this->update)((Actor*)this, (GlobalContext*)ctxt);
+ func_800B675C((Actor*)this, 45.0f);
+ Collision_AddOT(ctxt, &ctxt->collisionContext, (ColCommon*)&this->collision);
}
-UNK_RET EnAObj_Draw(ActorEnAObj* a0, GlobalContext* a1) {
- func_800BDFC0(a1, enAObjDisplayLists[a0->base.variable]);
+void EnAObj_Draw(ActorEnAObj* this, GlobalContext* ctxt) {
+ func_800BDFC0(ctxt, enAObjDisplayLists[this->base.variable]);
}
diff --git a/src/code/code_0x800BF9A0.c b/src/code/code_0x800BF9A0.c
index a1edaf92b..31294e559 100644
--- a/src/code/code_0x800BF9A0.c
+++ b/src/code/code_0x800BF9A0.c
@@ -1,10 +1,10 @@
#include <ultra64.h>
#include <global.h>
-UNK_RET func_800BF9A0(UNK_TYPE a0, UNK_TYPE a1) {
+void func_800BF9A0(s32 a0, s32 a1) {
s32 i;
ActorOverlayTableEntry* s0;
- UNK_TYPE v1;
+ s32 v1;
func_8008439C(-2, 0);
func_800847CC(D_801DCBB0, D_801B4610);
@@ -17,12 +17,12 @@ UNK_RET func_800BF9A0(UNK_TYPE a0, UNK_TYPE a1) {
}
}
-UNK_TYPE func_800BFA78(UNK_TYPE a0, UNK_TYPE a1) {
+s32 func_800BFA78(s32 a0, s32 a1) {
s32 i;
ActorOverlayTableEntry* v0 = &actorOverlayTable[0];
- UNK_TYPE t1;
- UNK_TYPE a2;
- UNK_TYPE a0_2 = a0;
+ s32 t1;
+ s32 a2;
+ s32 a0_2 = a0;
for (i = 0; i < D_801B4610; i++, v0++) {
t1 = v0->vramStart - v0->ramAddr;
@@ -39,13 +39,13 @@ UNK_TYPE func_800BFA78(UNK_TYPE a0, UNK_TYPE a1) {
return 0;
}
-UNK_RET func_800BFAE8(UNK_ARGS) {
+void func_800BFAE8(void) {
D_801B4610 = 690;
func_800819F0(&D_801ED930, (u32)func_800BF9A0, 0, 0);
func_80081BCC(&D_801ED940, (u32)func_800BFA78, 0);
}
-UNK_RET func_800BFB40(UNK_ARGS) {
+void func_800BFB40(void) {
func_80081AD4(&D_801ED930);
func_80081CA4(&D_801ED940);
D_801B4610 = 0;
diff --git a/src/code/code_0x800CAAD0.c b/src/code/code_0x800CAAD0.c
new file mode 100644
index 000000000..544792c37
--- /dev/null
+++ b/src/code/code_0x800CAAD0.c
@@ -0,0 +1,104 @@
+#include <ultra64.h>
+#include <global.h>
+
+// This file comes after z_bgcheck.c and contains functions to manage actors attached to Bg Actors.
+// Perhaps it is called something like z_bgcheck_attach.c
+// The functions will use the BgCheck2 prefix for now.
+
+void BgCheck2_UpdateActorPosition(BgCheckContext* bgCtxt, s32 index, Actor* actor) {
+ z_Matrix prevMatrix;
+ z_Matrix prevMatrixInv;
+ z_Matrix currMatrix;
+ Vector3f newPos;
+ Vector3f posWithInv;
+
+ if (BgCheck_IsActorMeshIndexValid(index) == 0) return;
+
+ Matrix_MakeTranslationRotationYXZScale(&prevMatrix,
+ bgCtxt->dyna.actorMeshes[index].prevParams.scale.x,
+ bgCtxt->dyna.actorMeshes[index].prevParams.scale.y,
+ bgCtxt->dyna.actorMeshes[index].prevParams.scale.z,
+ bgCtxt->dyna.actorMeshes[index].prevParams.rotation.x,
+ bgCtxt->dyna.actorMeshes[index].prevParams.rotation.y,
+ bgCtxt->dyna.actorMeshes[index].prevParams.rotation.z,
+ bgCtxt->dyna.actorMeshes[index].prevParams.pos.x,
+ bgCtxt->dyna.actorMeshes[index].prevParams.pos.y,
+ bgCtxt->dyna.actorMeshes[index].prevParams.pos.z);
+
+ if (invert_matrix(&prevMatrix, &prevMatrixInv) == 2) return;
+
+ Matrix_MakeTranslationRotationYXZScale(&currMatrix,
+ bgCtxt->dyna.actorMeshes[index].currParams.scale.x,
+ bgCtxt->dyna.actorMeshes[index].currParams.scale.y,
+ bgCtxt->dyna.actorMeshes[index].currParams.scale.z,
+ bgCtxt->dyna.actorMeshes[index].currParams.rotation.x,
+ bgCtxt->dyna.actorMeshes[index].currParams.rotation.y,
+ bgCtxt->dyna.actorMeshes[index].currParams.rotation.z,
+ bgCtxt->dyna.actorMeshes[index].currParams.pos.x,
+ bgCtxt->dyna.actorMeshes[index].currParams.pos.y,
+ bgCtxt->dyna.actorMeshes[index].currParams.pos.z);
+
+ Matrix_MultiplyByVectorXYZ(&prevMatrixInv, &actor->unk24.pos, &posWithInv);
+ Matrix_MultiplyByVectorXYZ(&currMatrix, &posWithInv, &newPos);
+
+ actor->unk24.pos = newPos;
+}
+
+void BgCheck2_UpdateActorYRotation(BgCheckContext* bgCtxt, s32 index, Actor* actor) {
+ s16 angleChange;
+
+ if (BgCheck_IsActorMeshIndexValid(index) == 0) return;
+
+ angleChange = bgCtxt->dyna.actorMeshes[index].currParams.rotation.y - bgCtxt->dyna.actorMeshes[index].prevParams.rotation.y;
+
+ if (actor->id == 0) {
+ ((ActorPlayer*)actor)->unkAD4 += angleChange;
+ }
+
+ actor->postDrawParams.rotation.y += angleChange;
+ actor->unk24.rot.y += angleChange;
+}
+
+void BgCheck2_AttachToMesh(BgCheckContext* bgCtxt, Actor* actor, s32 index) {
+ BgActor *meshActor;
+
+ if (BgCheck_IsActorMeshIndexValid(index) == 0) return;
+
+ meshActor = BgCheck_GetActorOfMesh(bgCtxt,index);
+ if (meshActor != NULL) {
+ func_800CAE88(meshActor);
+
+ if ((actor->flags & 0x4000000) == 0x4000000) {
+ func_800CAF24(meshActor);
+ }
+ if ((actor->flags & 0x20000) == 0x20000) {
+ func_800CAF38(meshActor);
+ }
+ }
+}
+
+u32 BgCheck2_UpdateActorAttachedToMesh(BgCheckContext* bgCtxt, s32 index, Actor* actor) {
+ u32 wasUpdated = 0;
+ BgActor *meshActor;
+
+ if (BgCheck_IsActorMeshIndexValid(index) == 0) return 0;
+
+ if (((bgCtxt->dyna.meshParams[index] & 2) != 0) || ((bgCtxt->dyna.meshParams[index] & 1) == 0)) return 0;
+
+ meshActor = BgCheck_GetActorOfMesh(bgCtxt,index);
+
+ if (meshActor == NULL) return 0;
+
+ if ((meshActor->unk154 & 1) != 0) {
+ BgCheck2_UpdateActorPosition(bgCtxt,index,actor);
+ wasUpdated = 1;
+ }
+
+ if ((meshActor->unk154 & 2) != 0) {
+ BgCheck2_UpdateActorYRotation(bgCtxt,index,actor);
+ wasUpdated = 1;
+ }
+
+ return wasUpdated;
+}
+
diff --git a/src/code/code_0x800CAAD0.c.ignore b/src/code/code_0x800CAAD0.c.ignore
deleted file mode 100644
index de931d94e..000000000
--- a/src/code/code_0x800CAAD0.c.ignore
+++ /dev/null
@@ -1,99 +0,0 @@
-#include <ultra64.h>
-#include <global.h>
-
-UNK_RET func_800CAAD0(UNK_TYPE a0, UNK_TYPE a1, UNK_TYPE a2) {
- UNK_TYPE spD0;
- UNK_TYPE sp90;
- UNK_TYPE sp50;
- UNK_TYPE sp44;
- UNK_TYPE sp38;
- UNK_TYPE sp24;
-
- s800CAAD0* v1;
-
- if (func_800C6024(a1) == 0) return;
-
- v1 = (s800CAAD0*)(a0 + a1 * 100);
-
- func_80139894(&spD0, v1->unk68, v1->unk6C, v1->unk70, v1->unk74, v1->unk76,
- v1->unk78, v1->unk7C, v1->unk80, v1->unk84);
-
- if (func_80139188(&spD0, &sp90) == 2) return;
-
- func_80139894(&sp50, v1->unk88, v1->unk8C, v1->unk90, v1->unk94, v1->unk96,
- v1->unk98, v1->unk9C, v1->unkA0, v1->unkA4);
-
- func_80138C88(&sp90, (UNK_PTR)(a2 + 36), &sp24);
- func_80138C88(&sp50, &sp38, &sp44);
-
- v1->unk0 = *(UNK_TYPE*)((u8*)sp24 + 0);
- v1->unk4 = *(UNK_TYPE*)((u8*)sp24 + 4);
- v1->unk8 = *(UNK_TYPE*)((u8*)sp24 + 8);
-}
-
-UNK_RET func_800CAC0C(UNK_TYPE a0, UNK_TYPE a1, UNK_TYPE a2) {
- UNK_TYPE v0;
- s16 v1;
-
- if (func_800C6024(a0) == 0) return;
-
- v0 = a0 + a1 * 100;
-
- v1 = *(s16*)(v0 + 150) - *(s16*)(v0 + 118);
-
- if (*(s16*)a2 == 0) {
- *(s16*)(a2 + 2772) += v1;
- }
-
- *(s16*)(a2 + 190) += v1;
- *(s16*)(a2 + 50) += v1;
-}
-
-UNK_RET func_800CACA0(UNK_TYPE a0, UNK_TYPE a1, UNK_TYPE a2) {
- UNK_TYPE sp1C;
-
- if (func_800C6024(a2) == 0) return;
-
- sp1C = func_800C6248(a0, a2);
-
- if (sp1C == 0) return;
-
- func_800CAE88(sp1C);
-
- if ((*(u32*)(a1 + 4) & 0x04000000) == 0x0400) {
- func_800CAF24(sp1C);
- }
-
- if ((*(u32*)(a1 + 4) & 0x20000) == 0x20000) {
- func_800CAF38(sp1C);
- }
-}
-
-UNK_TYPE func_800CAD2C(UNK_TYPE a0, UNK_TYPE a1, UNK_TYPE a2) {
- UNK_TYPE v1;
- UNK_TYPE sp24 = 0;
-
- if (func_800C6024(a1) == 0) return;
-
- if (((*(u16*)(a0 + a1*2 + 5084) & 0x2) != 0) ||
- ((*(u16*)(a0 + a1*2 + 5084) & 0x1) == 0)) {
- return 0;
- }
-
- v1 = func_800C6248(a0, a1);
- if (v1 == 0) {
- return 0;
- }
-
- if ((*(u32*)(v1 + 340) & 0x1) != 0) {
- func_800CAAD0(a0, a1, a2);
- sp24 = 1;
- }
-
- if ((*(u32*)(v1 + 340) & 0x2) != 0) {
- func_800CAC0C(a0, a1, a2);
- sp24 = 1;
- }
-
- return sp24;
-}
diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c
index 9d7e03dad..f721b864f 100644
--- a/src/code/z_effect_soft_sprite.c
+++ b/src/code/z_effect_soft_sprite.c
@@ -219,10 +219,7 @@ GLOBAL_ASM("./asm/nonmatching/z_effect_soft_sprite/EffectSS_LoadParticle.asm")
#endif
-// XXX regalloc is wrong
-#ifdef NONMATCHING
-
-void EffectSS_UpdateParticle(GlobalContext* ctxt, u32 index) {
+void EffectSS_UpdateParticle(GlobalContext* ctxt, s32 index) {
LoadedParticleEntry* particle = &EffectSS2Info.data_table[index];
if (particle->update != NULL) {
@@ -234,16 +231,10 @@ void EffectSS_UpdateParticle(GlobalContext* ctxt, u32 index) {
particle->position.y += particle->velocity.y;
particle->position.z += particle->velocity.z;
- (*particle->update)(ctxt);
+ (*particle->update)(ctxt, index, particle);
}
}
-#else
-
-GLOBAL_ASM("./asm/nonmatching/z_effect_soft_sprite/EffectSS_UpdateParticle.asm")
-
-#endif
-
void EffectSS_UpdateAllParticles(GlobalContext* ctxt) {
s32 i;
@@ -262,22 +253,13 @@ void EffectSS_UpdateAllParticles(GlobalContext* ctxt) {
}
}
-// XXX regalloc is wrong
-#ifdef NONMATCHING
-
void EffectSS_DrawParticle(GlobalContext* ctxt, s32 index) {
LoadedParticleEntry* entry = &EffectSS2Info.data_table[index];
if (entry->draw != 0) {
- (*entry->draw)(ctxt);
+ (*entry->draw)(ctxt, index, entry);
}
}
-#else
-
-GLOBAL_ASM("./asm/nonmatching/z_effect_soft_sprite/EffectSS_DrawParticle.asm")
-
-#endif
-
void EffectSS_DrawAllParticles(GlobalContext* ctxt) {
LightMapper* s0;
s32 i;
diff --git a/src/code/z_lib.c b/src/code/z_lib.c
index e9eb805eb..f8124709b 100644
--- a/src/code/z_lib.c
+++ b/src/code/z_lib.c
@@ -5,10 +5,10 @@
extern float fabsf(float);
#pragma intrinsic (fabsf)
-void* Lib_bcopy(void* dst, void* src, size_t n) {
- _bcopy(src, dst, n);
+void* Lib_bcopy(void* dest, void* src, size_t n) {
+ _bcopy(src, dest, n);
- return dst;
+ return dest;
}
#ifdef NONMATCHING
@@ -36,99 +36,99 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/Lib_memset.asm")
#endif
-f32 Lib_cos(s16 a0) {
- return coss(a0) * D_801DDA80;
+f32 Lib_cos(s16 angle) {
+ return coss(angle) * D_801DDA80;
}
-f32 Lib_sin(s16 a0) {
- return sins(a0) * D_801DDA84;
+f32 Lib_sin(s16 angle) {
+ return sins(angle) * D_801DDA84;
}
-s32 Lib_StepTowardsGet_i(s32 a0, s32 a1, s32 a2) {
+s32 Lib_StepTowardsGet_i(s32 start, s32 value, s32 step) {
s32 v1;
- if (a1 >= a0) {
- v1 = a0 + a2;
- if (a1 >= v1) {
+ if (value >= start) {
+ v1 = start + step;
+ if (value >= v1) {
return v1;
}
} else {
- v1 = a0 - a2;
- if (v1 >= a1) {
+ v1 = start - step;
+ if (v1 >= value) {
return v1;
}
}
- return a1;
+ return value;
}
-void Lib_StepTowards_i(s32* a0, s32 a1, s32 a2) {
- *a0 = Lib_StepTowardsGet_i(*a0, a1, a2);
+void Lib_StepTowards_i(s32* start, s32 value, s32 step) {
+ *start = Lib_StepTowardsGet_i(*start, value, step);
}
-UNK_TYPE Lib_StepTowardsCheck_i(s32* a0, s32 a1, s32 a2) {
- Lib_StepTowards_i(a0, a1, a2);
+s32 Lib_StepTowardsCheck_i(s32* start, s32 value, s32 step) {
+ Lib_StepTowards_i(start, value, step);
- return a1 == *a0;
+ return value == *start;
}
-UNK_TYPE Lib_StepTowardsCheckFramerateScaled_s(s16* a0, s16 a1, s16 a2) {
+s32 Lib_StepTowardsCheckFramerateScaled_s(s16* start, s16 target, s16 step) {
f32 f0;
- if (a2 != 0) {
+ if (step != 0) {
f0 = D_801D1508;
- if ((s16)(*a0 - a1) > 0) {
- a2 = -a2;
+ if ((s16)(*start - target) > 0) {
+ step = -step;
}
- *a0 += (s16)(a2 * f0);
+ *start += (s16)(step * f0);
- if (((s16)(*a0 - a1) * a2) >= 0) {
- *a0 = a1;
+ if (((s16)(*start - target) * step) >= 0) {
+ *start = target;
return 1;
}
- } else if (a1 == *a0) {
+ } else if (target == *start) {
return 1;
}
return 0;
}
-UNK_TYPE Lib_StepTowardsCheck_s(s16* a0, s16 a1, s16 a2) {
- if (a2 != 0) {
- if (a1 < *a0) {
- a2 = -a2;
+s32 Lib_StepTowardsCheck_s(s16* start, s16 target, s16 step) {
+ if (step != 0) {
+ if (target < *start) {
+ step = -step;
}
- *a0 += a2;
+ *start += step;
- if (((*a0 - a1) * a2) >= 0) {
- *a0 = a1;
+ if (((*start - target) * step) >= 0) {
+ *start = target;
return 1;
}
- } else if (a1 == *a0) {
+ } else if (target == *start) {
return 1;
}
return 0;
}
-UNK_TYPE Lib_StepTowardsCheck_c(s8* a0, s8 a1, s8 a2) {
- if (a2 != 0) {
- if (a1 < *a0) {
- a2 = -a2;
+s32 Lib_StepTowardsCheck_c(s8* start, s8 target, s8 step) {
+ if (step != 0) {
+ if (target < *start) {
+ step = -step;
}
- *a0 += a2;
+ *start += step;
- if (((*a0 - a1) * a2) >= 0) {
- *a0 = a1;
+ if (((*start - target) * step) >= 0) {
+ *start = target;
return 1;
}
- } else if (a1 == *a0) {
+ } else if (target == *start) {
return 1;
}
@@ -137,21 +137,21 @@ UNK_TYPE Lib_StepTowardsCheck_c(s8* a0, s8 a1, s8 a2) {
#ifdef NONMATCHING
-UNK_TYPE Lib_StepTowardsCheck_f(f32* a0, f32 a1, f32 a2) {
- if (a2 != 0) {
+s32 Lib_StepTowardsCheck_f(f32* start, f32 target, f32 step) {
+ if (step != 0) {
// XXX: regalloc is messed up
- if (a1 < *a0) {
- a2 = -a2;
+ if (target < *start) {
+ step = -step;
}
- *a0 += a2;
+ *start += step;
- if (((*a0 - a1) * a2) >= 0) {
- *a0 = a1;
+ if (((*start - target) * step) >= 0) {
+ *start = target;
return 1;
}
- } else if (a1 != *a0) {
+ } else if (target != *start) {
return 1;
}
@@ -166,7 +166,7 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/Lib_StepTowardsCheck_f.asm")
#ifdef NONMATCHING
-UNK_TYPE func_800FF0D0(s16* a0, s16 a1, s16 a2) {
+s32 func_800FF0D0(s16* a0, s16 a1, s16 a2) {
s32 v0 = *a0;
// XXX: regalloc is messed up
@@ -189,7 +189,7 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/func_800FF0D0.asm")
#ifdef NONMATCHING
-UNK_RET func_800FF138() {
+void func_800FF138() {
}
@@ -201,7 +201,7 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/func_800FF138.asm")
#ifdef NONMATCHING
-UNK_RET func_800FF1FC() {
+void func_800FF1FC(void) {
}
@@ -213,7 +213,7 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/func_800FF1FC.asm")
#ifdef NONMATCHING
-UNK_RET func_800FF2A8() {
+void func_800FF2A8(void) {
}
@@ -225,7 +225,7 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/func_800FF2A8.asm")
#ifdef NONMATCHING
-UNK_RET func_800FF2F8() {
+void func_800FF2F8(void) {
}
@@ -237,7 +237,7 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/func_800FF2F8.asm")
#ifdef NONMATCHING
-UNK_RET func_800FF3A0() {
+void func_800FF3A0(void) {
}
@@ -247,156 +247,156 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/func_800FF3A0.asm")
#endif
-s16 Lib_rand_s(s16 a0, s16 a1) {
- return (s16)(randZeroOne() * a1) + a0;
+s16 Lib_rand_s(s16 base, s16 range) {
+ return (s16)(randZeroOne() * range) + base;
}
-s16 Lib_randStride_s(s16 a0, s16 a1, s16 a2) {
- return (s16)(randZeroOne() * a2) * a1 + a0;
+s16 Lib_randestride_s(s16 base, s16 stride, s16 range) {
+ return (s16)(randZeroOne() * range) * stride + base;
}
-UNK_RET Lib_CopyVec3f(Vector3f* dst, Vector3f* src) {
+void Lib_CopyVec3f(Vector3f* dest, Vector3f* src) {
f32 x = src->x;
f32 y = src->y;
f32 z = src->z;
- dst->x = x;
- dst->y = y;
- dst->z = z;
+ dest->x = x;
+ dest->y = y;
+ dest->z = z;
}
-UNK_RET Lib_CopyVec3s(Vector3s* dst, Vector3s* src) {
+void Lib_CopyVec3s(Vector3s* dest, Vector3s* src) {
s16 x = src->x;
s16 y = src->y;
s16 z = src->z;
- dst->x = x;
- dst->y = y;
- dst->z = z;
+ dest->x = x;
+ dest->y = y;
+ dest->z = z;
}
-UNK_RET Lib_ToVec3f(Vector3f* dst, Vector3s* src) {
+void Lib_ToVec3f(Vector3f* dest, Vector3s* src) {
f32 x = src->x;
f32 y = src->y;
f32 z = src->z;
- dst->x = x;
- dst->y = y;
- dst->z = z;
+ dest->x = x;
+ dest->y = y;
+ dest->z = z;
}
-UNK_RET Lib_ToVec3s(Vector3s* dst, Vector3f* src) {
+void Lib_ToVec3s(Vector3s* dest, Vector3f* src) {
f32 x = src->x;
f32 y = src->y;
f32 z = src->z;
- dst->x = x;
- dst->y = y;
- dst->z = z;
+ dest->x = x;
+ dest->y = y;
+ dest->z = z;
}
-UNK_RET Lib_AddVec3f(Vector3f* a0, Vector3f* a1, Vector3f* a2) {
- a2->x = a0->x + a1->x;
- a2->y = a0->y + a1->y;
- a2->z = a0->z + a1->z;
+void Lib_AddVec3f(Vector3f* l, Vector3f* r, Vector3f* dest) {
+ dest->x = l->x + r->x;
+ dest->y = l->y + r->y;
+ dest->z = l->z + r->z;
}
-UNK_RET Lib_SubVec3f(Vector3f* a0, Vector3f* a1, Vector3f* a2) {
- a2->x = a0->x - a1->x;
- a2->y = a0->y - a1->y;
- a2->z = a0->z - a1->z;
+void Lib_SubVec3f(Vector3f* l, Vector3f* r, Vector3f* dest) {
+ dest->x = l->x - r->x;
+ dest->y = l->y - r->y;
+ dest->z = l->z - r->z;
}
-UNK_RET Lib_SubVec3sToVec3f(Vector3f* a0, Vector3s* a1, Vector3s* a2) {
- a0->x = a1->x - a2->x;
- a0->y = a1->y - a2->y;
- a0->z = a1->z - a2->z;
+void Lib_SubVec3sToVec3f(Vector3f* dest, Vector3s* l, Vector3s* r) {
+ dest->x = l->x - r->x;
+ dest->y = l->y - r->y;
+ dest->z = l->z - r->z;
}
-UNK_RET Lib_ScaleInPlaceVec3f(Vector3f* a0, f32 a1) {
- a0->x *= a1;
- a0->y *= a1;
- a0->z *= a1;
+void Lib_ScaleInPlaceVec3f(Vector3f* vec, f32 scale) {
+ vec->x *= scale;
+ vec->y *= scale;
+ vec->z *= scale;
}
-UNK_RET Lib_ScaleVec3f(Vector3f* a0, f32 a1, Vector3f* a2) {
- a2->x = a0->x * a1;
- a2->y = a0->y * a1;
- a2->z = a0->z * a1;
+void Lib_ScaleVec3f(Vector3f* vec, f32 scale, Vector3f* dest) {
+ dest->x = vec->x * scale;
+ dest->y = vec->y * scale;
+ dest->z = vec->z * scale;
}
-UNK_RET Lib_LerpVec3f(Vector3f* a0, Vector3f* a1, f32 a2, Vector3f* a3) {
- a3->x = (a1->x - a0->x) * a2 + a0->x;
- a3->y = (a1->y - a0->y) * a2 + a0->y;
- a3->z = (a1->z - a0->z) * a2 + a0->z;
+void Lib_LerpVec3f(Vector3f* a, Vector3f* b, f32 t, Vector3f* dest) {
+ dest->x = (b->x - a->x) * t + a->x;
+ dest->y = (b->y - a->y) * t + a->y;
+ dest->z = (b->z - a->z) * t + a->z;
}
-UNK_RET Lib_AddScaledVec3f(Vector3f* a0, Vector3f* a1, f32 a2, Vector3f* a3) {
- a3->x = a1->x * a2 + a0->x;
- a3->y = a1->y * a2 + a0->y;
- a3->z = a1->z * a2 + a0->z;
+void Lib_AddScaledVec3f(Vector3f* a, Vector3f* b, f32 scale, Vector3f* dest) {
+ dest->x = b->x * scale + a->x;
+ dest->y = b->y * scale + a->y;
+ dest->z = b->z * scale + a->z;
}
-UNK_RET Lib_ModifyRandScaled(Vector3f* a0, f32 a1, Vector3f* a2) {
- a2->x = randPlusMinusPoint5Scaled(a1) + a0->x;
- a2->y = randPlusMinusPoint5Scaled(a1) + a0->y;
- a2->z = randPlusMinusPoint5Scaled(a1) + a0->z;
+void Lib_ModifyRandScaled(Vector3f* orig, f32 scale, Vector3f* dest) {
+ dest->x = randPlusMinusPoint5Scaled(scale) + orig->x;
+ dest->y = randPlusMinusPoint5Scaled(scale) + orig->y;
+ dest->z = randPlusMinusPoint5Scaled(scale) + orig->z;
}
-void Lib_ScaledNormalizedDifferenceVec3f(Vector3f* a0, Vector3f* a1, f32 a2, Vector3f* a3) {
- f32 f0 = Lib_DistanceAndDifferenceVec3f(a0, a1, a3);
+void Lib_ScaledNormalizedDifferenceVec3f(Vector3f* a, Vector3f* b, f32 scale, Vector3f* dest) {
+ f32 f0 = Lib_DistanceAndDifferenceVec3f(a, b, dest);
f32 f2;
if (f0 == 0) {
return;
}
- f2 = a2 / f0;
+ f2 = scale / f0;
- a3->x *= f2;
- a3->y *= f2;
- a3->z *= f2;
+ dest->x *= f2;
+ dest->y *= f2;
+ dest->z *= f2;
}
-f32 Lib_DistanceVec3f(Vector3f* a0, Vector3f* a1) {
+f32 Lib_DistanceVec3f(Vector3f* a, Vector3f* b) {
Vector3f sp1C;
- Lib_SubVec3f(a1, a0, &sp1C);
+ Lib_SubVec3f(b, a, &sp1C);
return sqrtf((sp1C.x * sp1C.x) + (sp1C.y * sp1C.y) + (sp1C.z * sp1C.z));
}
-f32 Lib_DistanceAndDifferenceVec3f(Vector3f* a0, Vector3f* a1, Vector3f* a2) {
- Lib_SubVec3f(a1, a0, a2);
- return sqrtf((a2->x * a2->x) + (a2->y * a2->y) + (a2->z * a2->z));
+f32 Lib_DistanceAndDifferenceVec3f(Vector3f* a, Vector3f* b, Vector3f* difference) {
+ Lib_SubVec3f(b, a, difference);
+ return sqrtf((difference->x * difference->x) + (difference->y * difference->y) + (difference->z * difference->z));
}
-f32 Lib_DistanceXZVec3f(Vector3f* a0, Vector3f* a1) {
- f32 dx = a1->x - a0->x;
- f32 dz = a1->z - a0->z;
+f32 Lib_DistanceXZVec3f(Vector3f* a, Vector3f* b) {
+ f32 dx = b->x - a->x;
+ f32 dz = b->z - a->z;
return sqrtf((dx * dx) + (dz * dz));
}
-f32 Lib_DistanceAndDifferenceXZVec3f(Vector3f* a0, Vector3f* a1, f32* a2, f32* a3) {
- *a2 = a1->x - a0->x;
- *a3 = a1->z - a0->z;
- return sqrtf((*a2 * *a2) + (*a3 * *a3));
+f32 Lib_DistanceAndDifferenceXZVec3f(Vector3f* a, Vector3f* b, f32* xDiff, f32* zDiff) {
+ *xDiff = b->x - a->x;
+ *zDiff = b->z - a->z;
+ return sqrtf((*xDiff * *xDiff) + (*zDiff * *zDiff));
}
#ifdef NONMATCHING
-UNK_RET Lib_PushAwayXZVec3f(Vector3f* a0, Vector3f* a1, f32 a2) {
+void Lib_PushAwayXZVec3f(Vector3f* start, Vector3f* pusher, f32 distanceToApproach) {
f32 sp24;
f32 sp20;
- f32 f0 = Lib_DistanceAndDifferenceXZVec3f(a1, a0, &sp24, &sp20);
- f32 f2 = f0 - a2;
+ f32 f0 = Lib_DistanceAndDifferenceXZVec3f(pusher, start, &sp24, &sp20);
+ f32 f2 = f0 - distanceToApproach;
- if ((f0 >= a2) && (f2 != 0)) {
+ if ((f0 >= distanceToApproach) && (f2 != 0)) {
f2 /= f0;
} else {
f2 = 0;
}
- a0->x = a1->x + sp24 * f2;
- a0->z = a1->z + sp20 * f2;
+ start->x = pusher->x + sp24 * f2;
+ start->z = pusher->z + sp20 * f2;
}
#else
@@ -405,79 +405,79 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/Lib_PushAwayXZVec3f.asm")
#endif
-f32 Lib_DistanceYVec3f(Vector3f* a0, Vector3f* a1) {
- return a1->y - a0->y;
+f32 Lib_DistanceYVec3f(Vector3f* a, Vector3f* b) {
+ return b->y - a->y;
}
-UNK_TYPE Lib_YawVec3f(Vector3f* a0, Vector3f* a1) {
- f32 f14 = a1->x - a0->x;
- f32 f12 = a1->z - a0->z;
+s32 Lib_YawVec3f(Vector3f* from, Vector3f* to) {
+ f32 f14 = to->x - from->x;
+ f32 f12 = to->z - from->z;
return atans_flip(f12, f14);
}
-UNK_TYPE Lib_PitchVec3f(Vector3f* a0, Vector3f* a1) {
- return atans_flip(Lib_DistanceXZVec3f(a0, a1), a0->y - a1->y);
+s32 Lib_PitchVec3f(Vector3f* from, Vector3f* to) {
+ return atans_flip(Lib_DistanceXZVec3f(from, to), from->y - to->y);
}
-void Lib_ApplyActorInitVars(Actor* a0, ActorInitVar* a1) {
+void Lib_ApplyActorInitVars(Actor* actor, ActorInitVar* init) {
do {
- actorInitVarFuncs[a1->type]((u8*)a0, a1);
- } while ((a1++)->cont);
+ actorInitVarFuncs[init->type]((u8*)actor, init);
+ } while ((init++)->cont);
}
-UNK_RET Lib_ApplyActorInitVarByte1(u8* a0, ActorInitVar* a1) {
- *(u8*)(a0 + a1->offset) = (u8)(a1->value);
+void Lib_ApplyActorInitVarByte1(u8* actor, ActorInitVar* init) {
+ *(u8*)(actor + init->offset) = (u8)(init->value);
}
-UNK_RET Lib_ApplyActorInitVarByte2(u8* a0, ActorInitVar* a1) {
- *(u8*)(a0 + a1->offset) = (u8)(a1->value);
+void Lib_ApplyActorInitVarByte2(u8* actor, ActorInitVar* init) {
+ *(u8*)(actor + init->offset) = (u8)(init->value);
}
-UNK_RET Lib_ApplyActorInitVarShort1(u8* a0, ActorInitVar* a1) {
- *(u16*)(a0 + a1->offset) = (u16)(a1->value);
+void Lib_ApplyActorInitVarShort1(u8* actor, ActorInitVar* init) {
+ *(u16*)(actor + init->offset) = (u16)(init->value);
}
-UNK_RET Lib_ApplyActorInitVarShort2(u8* a0, ActorInitVar* a1) {
- *(u16*)(a0 + a1->offset) = (u16)(a1->value);
+void Lib_ApplyActorInitVarShort2(u8* actor, ActorInitVar* init) {
+ *(u16*)(actor + init->offset) = (u16)(init->value);
}
-UNK_RET Lib_ApplyActorInitVarWord1(u8* a0, ActorInitVar* a1) {
- *(u32*)(a0 + a1->offset) = (u32)(a1->value);
+void Lib_ApplyActorInitVarWord1(u8* actor, ActorInitVar* init) {
+ *(u32*)(actor + init->offset) = (u32)(init->value);
}
-UNK_RET Lib_ApplyActorInitVarWord2(u8* a0, ActorInitVar* a1) {
- *(u32*)(a0 + a1->offset) = (u32)(a1->value);
+void Lib_ApplyActorInitVarWord2(u8* actor, ActorInitVar* init) {
+ *(u32*)(actor + init->offset) = (u32)(init->value);
}
-UNK_RET Lib_ApplyActorInitVarFloat(u8* a0, ActorInitVar* a1) {
- *(f32*)(a0 + a1->offset) = (f32)(a1->value);
+void Lib_ApplyActorInitVarFloat(u8* actor, ActorInitVar* init) {
+ *(f32*)(actor + init->offset) = (f32)(init->value);
}
-UNK_RET Lib_ApplyActorInitVarFloat1000th(u8* a0, ActorInitVar* a1) {
- *(f32*)(a0 + a1->offset) = (f32)(a1->value) / 1000;
+void Lib_ApplyActorInitVarFloat1000th(u8* actor, ActorInitVar* init) {
+ *(f32*)(actor + init->offset) = (f32)(init->value) / 1000;
}
-UNK_RET Lib_ApplyActorInitVarVector3f(u8* a0, ActorInitVar* a1) {
- Vector3f* v0 = (Vector3f*)(a0 + a1->offset);
- f32 f0 = (f32)(a1->value);
+void Lib_ApplyActorInitVarVector3f(u8* actor, ActorInitVar* init) {
+ Vector3f* v0 = (Vector3f*)(actor + init->offset);
+ f32 f0 = (f32)(init->value);
v0->z = f0;
v0->y = f0;
v0->x = f0;
}
-UNK_RET Lib_ApplyActorInitVarVector3f1000th(u8* a0, ActorInitVar* a1) {
- Vector3f* v0 = (Vector3f*)(a0 + a1->offset);
- f32 f0 = (f32)(a1->value) / 1000;
+void Lib_ApplyActorInitVarVector3f1000th(u8* actor, ActorInitVar* init) {
+ Vector3f* v0 = (Vector3f*)(actor + init->offset);
+ f32 f0 = (f32)(init->value) / 1000;
v0->z = f0;
v0->y = f0;
v0->x = f0;
}
-UNK_RET Lib_ApplyActorInitVarVector3s(u8* a0, ActorInitVar* a1) {
- Vector3s* v0 = (Vector3s*)(a0 + a1->offset);
- s16 v1 = (s16)(a1->value);
+void Lib_ApplyActorInitVarVector3s(u8* actor, ActorInitVar* init) {
+ Vector3s* v0 = (Vector3s*)(actor + init->offset);
+ s16 v1 = (s16)(init->value);
v0->z = v1;
v0->y = v1;
@@ -524,37 +524,37 @@ f32 func_800FFCD8(f32* a0, f32 a1, f32 a2, f32 a3, f32 a4) {
return fabsf(a1 - *a0);
}
-void Lib_ScaleMax_f(f32* a0, f32 a1, f32 a2, f32 a3) {
+void Lib_ScaleMax_f(f32* start, f32 target, f32 scale, f32 maxStep) {
f32 f2;
- if (*a0 != a1) {
- f2 = (a1 - *a0) * a2;
+ if (*start != target) {
+ f2 = (target - *start) * scale;
- if (f2 > a3) {
- f2 = a3;
- } else if (f2 < -a3) {
- f2 = -a3;
+ if (f2 > maxStep) {
+ f2 = maxStep;
+ } else if (f2 < -maxStep) {
+ f2 = -maxStep;
}
- *a0 += f2;
+ *start += f2;
}
}
-void Lib_Scale_f(f32* a0, f32 a1, f32 a2) {
- f32 f0 = *a0 * a1;
+void Lib_Scale_f(f32* start, f32 scale, f32 maxStep) {
+ f32 f0 = *start * scale;
- if (a2 < f0) {
- f0 = a2;
- } else if (f0 < -a2) {
- f0 = -a2;
+ if (maxStep < f0) {
+ f0 = maxStep;
+ } else if (f0 < -maxStep) {
+ f0 = -maxStep;
}
- *a0 = *a0 - f0;
+ *start = *start - f0;
}
#ifdef NONMATCHING
-s16 Lib_ScaleMaxMin_s(s16* a0, s16 a1, s16 a2, s16 a3, s16 a4) {
+s32 Lib_ScaleMaxMin_s(s16* start, s16 target, s16 scale, s16 maxStep, s16 minStep) {
}
@@ -564,60 +564,60 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/Lib_ScaleMaxMin_s.asm")
#endif
-void Lib_ScaleMax_s(s16* a0, s16 a1, s16 a2, s16 a3) {
- s16 v0 = a1 - *a0;
- v0 /= a2;
+void Lib_ScaleMax_s(s16* start, s16 target, s16 scale, s16 maxStep) {
+ s16 v0 = target - *start;
+ v0 /= scale;
- if (v0 > a3) {
- *a0 += a3;
+ if (v0 > maxStep) {
+ *start += maxStep;
return;
}
- if (v0 < -a3) {
- *a0 -= a3;
+ if (v0 < -maxStep) {
+ *start -= maxStep;
return;
}
- *a0 += v0;
+ *start += v0;
}
-UNK_RET Lib_CopyColor(ColorRGBA8* a0, ColorRGBA8* a1) {
- a0->red = a1->red;
- a0->green = a1->green;
- a0->blue = a1->blue;
- a0->alpha = a1->alpha;
+void Lib_CopyColor(ColorRGBA8* dst, ColorRGBA8* src) {
+ dst->red = src->red;
+ dst->green = src->green;
+ dst->blue = src->blue;
+ dst->alpha = src->alpha;
}
-UNK_RET func_801000A4(u16 a0) {
+void func_801000A4(u16 a0) {
play_sound(a0);
}
-UNK_RET func_801000CC(u16 a0) {
+void func_801000CC(u16 a0) {
func_8019F128(a0);
}
-UNK_RET func_801000F4(UNK_TYPE a0, u16 a1) {
+void func_801000F4(s32 a0, u16 a1) {
func_8019F1C0(a0, a1);
}
-void Lib_TranslateAndRotateYVec3f(Vector3f* a0, s16 a1, Vector3f* a2, Vector3f* a3) {
+void Lib_TranslateAndRotateYVec3f(Vector3f* translation, s16 rotation, Vector3f* src, Vector3f* dst) {
f32 sp1C;
f32 f0;
- sp1C = Lib_cos(a1);
- f0 = Lib_sin(a1);
- a3->x = a0->x + (a2->x * sp1C + a2->z * f0);
- a3->y = a0->y + a2->y;
- a3->z = a0->z + (a2->z * sp1C - a2->x * f0);
+ sp1C = Lib_cos(rotation);
+ f0 = Lib_sin(rotation);
+ dst->x = translation->x + (src->x * sp1C + src->z * f0);
+ dst->y = translation->y + src->y;
+ dst->z = translation->z + (src->z * sp1C - src->x * f0);
}
#ifdef NONMATCHING
-void Lib_LerpRGB(RGB* a0, RGB* a1, f32 a2, RGB* a3) {
+void Lib_LerpRGB(RGB* a, RGB* b, f32 t, RGB* dst) {
// XXX regalloc is slightly off
- a3->red = (f32)a0->red + ((f32)a1->red - (f32)a0->red) * a2;
- a3->green = (f32)a0->green + ((f32)a1->green - (f32)a0->green) * a2;
- a3->blue = (f32)a0->blue + ((f32)a1->blue - (f32)a0->blue) * a2;
+ dst->red = (f32)a->red + ((f32)b->red - (f32)a->red) * t;
+ dst->green = (f32)a->green + ((f32)b->green - (f32)a->green) * t;
+ dst->blue = (f32)a->blue + ((f32)b->blue - (f32)a->blue) * t;
}
#else
@@ -626,21 +626,21 @@ GLOBAL_ASM("./asm/nonmatching/z_lib/Lib_LerpRGB.asm")
#endif
-f32 Lib_PushAwayVec3f(Vector3f* a0, Vector3f* a1, f32 a2) {
+f32 Lib_PushAwayVec3f(Vector3f* start, Vector3f* pusher, f32 distanceToApproach) {
Vector3f sp24;
f32 f2;
f32 f0;
- Lib_SubVec3f(a1, a0, &sp24);
+ Lib_SubVec3f(pusher, start, &sp24);
f0 = Math3D_Length(&sp24);
- if (a2 < f0) {
- f2 = a2 / f0;
- f0 = f0 - a2;
- a0->x = a0->x + f2 * sp24.x;
- a0->y = a0->y + f2 * sp24.y;
- a0->z = a0->z + f2 * sp24.z;
+ if (distanceToApproach < f0) {
+ f2 = distanceToApproach / f0;
+ f0 = f0 - distanceToApproach;
+ start->x = start->x + f2 * sp24.x;
+ start->y = start->y + f2 * sp24.y;
+ start->z = start->z + f2 * sp24.z;
} else {
- Lib_CopyVec3f(a0, a1);
+ Lib_CopyVec3f(start, pusher);
f0 = 0;
}
@@ -649,30 +649,30 @@ f32 Lib_PushAwayVec3f(Vector3f* a0, Vector3f* a1, f32 a2) {
void Lib_Nop801004FC(void) {}
-u32 Lib_PtrSegToVirt(u32 a0) {
- return(gRspSegmentPhysAddrs[(a0 << 4) >> 28] + (a0 & 0xFFFFFF)) + 0x80000000;
+u32 Lib_PtrSegToVirt(u32 ptr) {
+ return(gRspSegmentPhysAddrs[(ptr << 4) >> 28] + (ptr & 0xFFFFFF)) + 0x80000000;
}
-u32 Lib_PtrSegToVirtNull(u32 a0) {
- if ((a0 >> 28) == 0) {
- return a0;
+u32 Lib_PtrSegToVirtNull(u32 ptr) {
+ if ((ptr >> 28) == 0) {
+ return ptr;
}
- return(gRspSegmentPhysAddrs[(a0 << 4) >> 28] + (a0 & 0xFFFFFF)) + 0x80000000;
+ return(gRspSegmentPhysAddrs[(ptr << 4) >> 28] + (ptr & 0xFFFFFF)) + 0x80000000;
}
-u32 Lib_PtrSegToK0(u32 a0) {
- if (a0 == 0) {
+u32 Lib_PtrSegToK0(u32 ptr) {
+ if (ptr == 0) {
return 0;
} else {
- return a0 + 0x80000000;
+ return ptr + 0x80000000;
}
}
-u32 Lib_PtrSegToK0Null(u32 a0) {
- if (a0 == 0) {
+u32 Lib_PtrSegToK0Null(u32 ptr) {
+ if (ptr == 0) {
return 0;
} else {
- return a0 + 0x80000000;
+ return ptr + 0x80000000;
}
} \ No newline at end of file