summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorPrakxo <87568477+Prakxo@users.noreply.github.com>2023-09-27 20:03:11 +0200
committerGitHub <noreply@github.com>2023-09-27 11:03:11 -0700
commit02dc7fc7af3b39e44b9b030235f1dd66e7644efe (patch)
treea2dd820938746fa8ca56384f5919b679def35cf0 /src/code
parent4ba08394238a50c9dd5c049a80cb6ae2c04da481 (diff)
m_lib OK (#103)
* m_lib OK * fixes * rename segmented2virtual macro
Diffstat (limited to 'src/code')
-rw-r--r--src/code/c_keyframe.c74
-rw-r--r--src/code/m_actor.c40
-rw-r--r--src/code/m_collision_obj.c38
-rw-r--r--src/code/m_lib.c760
-rw-r--r--src/code/m_lights.c8
-rw-r--r--src/code/m_mail.c10
-rw-r--r--src/code/m_scene.c2
-rw-r--r--src/code/m_snowman.c2
-rw-r--r--src/code/sys_matrix.c22
9 files changed, 858 insertions, 98 deletions
diff --git a/src/code/c_keyframe.c b/src/code/c_keyframe.c
index 385de5e..8af8bd0 100644
--- a/src/code/c_keyframe.c
+++ b/src/code/c_keyframe.c
@@ -14,7 +14,7 @@
* Joint: A display list that represents a small section of the overall model. Joints have a hierarchal structure, where
* joints can specify child joints, and each joint inherits it's parent's transformation. Joints are represented in two
* places. A JointElemR struct stores the joint's display list. There's also a jointTable gets passed in from an actor.
- * This is a Vec3s array, with the first vector storing the root translation, the second vector is the root rotation,
+ * This is a s_xyz array, with the first vector storing the root translation, the second vector is the root rotation,
* and each vector after that is a joint's rotation.
*
* Morph: Normally switching from the previous animation to a new animation produces jarring motion as the joints jump
@@ -309,7 +309,7 @@ void cKF_SkeletonInfo_R_zeroClear(SkeletonInfoR* skeletonInfo) {
}
void cKF_SkeletonInfo_R_ct(SkeletonInfoR* skeletonInfo, BaseSkeletonR* skeleton, BaseAnimationR* animation,
- Vec3s* jointTable, Vec3s* morphTable) {
+ s_xyz* jointTable, s_xyz* morphTable) {
cKF_SkeletonInfo_R_zeroClear(skeletonInfo);
cKF_FrameControl_ct(&skeletonInfo->frameControl);
skeletonInfo->skeleton = Lib_SegmentedToVirtual(skeleton);
@@ -322,7 +322,7 @@ void cKF_SkeletonInfo_R_dt(SkeletonInfoR* skeletonInfo UNUSED) {
}
void cKF_SkeletonInfo_R_init_standard_stop(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation,
- Vec3s* diffRotTable) {
+ s_xyz* diffRotTable) {
BaseAnimationR* animationPtr = Lib_SegmentedToVirtual(animation);
cKF_SkeletonInfo_R_init(skeletonInfo, skeletonInfo->skeleton, animation, 1.0f, animationPtr->duration, 1.0f, 1.0,
@@ -330,7 +330,7 @@ void cKF_SkeletonInfo_R_init_standard_stop(SkeletonInfoR* skeletonInfo, BaseAnim
}
void cKF_SkeletonInfo_R_init_standard_stop_speedset(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation,
- Vec3s* diffRotTable, f32 speed) {
+ s_xyz* diffRotTable, f32 speed) {
BaseAnimationR* animationPtr = Lib_SegmentedToVirtual(animation);
cKF_SkeletonInfo_R_init(skeletonInfo, skeletonInfo->skeleton, animation, 1.0f, animationPtr->duration, 1.0f, speed,
@@ -338,7 +338,7 @@ void cKF_SkeletonInfo_R_init_standard_stop_speedset(SkeletonInfoR* skeletonInfo,
}
void cKF_SkeletonInfo_R_init_standard_stop_morph(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation,
- Vec3s* diffRotTable, f32 morphCounter) {
+ s_xyz* diffRotTable, f32 morphCounter) {
BaseAnimationR* animationPtr = Lib_SegmentedToVirtual(animation);
cKF_SkeletonInfo_R_init(skeletonInfo, skeletonInfo->skeleton, animation, 1.0f, animationPtr->duration, 1.0f, 1.0,
@@ -346,7 +346,7 @@ void cKF_SkeletonInfo_R_init_standard_stop_morph(SkeletonInfoR* skeletonInfo, Ba
}
void cKF_SkeletonInfo_R_init_standard_repeat(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation,
- Vec3s* diffRotTable) {
+ s_xyz* diffRotTable) {
BaseAnimationR* animationPtr = Lib_SegmentedToVirtual(animation);
cKF_SkeletonInfo_R_init(skeletonInfo, skeletonInfo->skeleton, animation, 1.0f, animationPtr->duration, 1.0f, 1.0,
@@ -354,7 +354,7 @@ void cKF_SkeletonInfo_R_init_standard_repeat(SkeletonInfoR* skeletonInfo, BaseAn
}
void cKF_SkeletonInfo_R_init_standard_repeat_speedset(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation,
- Vec3s* diffRotTable, f32 speed) {
+ s_xyz* diffRotTable, f32 speed) {
BaseAnimationR* animationPtr = Lib_SegmentedToVirtual(animation);
cKF_SkeletonInfo_R_init(skeletonInfo, skeletonInfo->skeleton, animation, 1.0f, animationPtr->duration, 1.0f, speed,
@@ -362,7 +362,7 @@ void cKF_SkeletonInfo_R_init_standard_repeat_speedset(SkeletonInfoR* skeletonInf
}
void cKF_SkeletonInfo_R_init_standard_repeat_morph(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation,
- Vec3s* diffRotTable, f32 morphCounter) {
+ s_xyz* diffRotTable, f32 morphCounter) {
BaseAnimationR* animationPtr = Lib_SegmentedToVirtual(animation);
cKF_SkeletonInfo_R_init(skeletonInfo, skeletonInfo->skeleton, animation, 1.0f, animationPtr->duration, 1.0f, 1.0,
@@ -371,7 +371,7 @@ void cKF_SkeletonInfo_R_init_standard_repeat_morph(SkeletonInfoR* skeletonInfo,
void cKF_SkeletonInfo_R_init(SkeletonInfoR* skeletonInfo, BaseSkeletonR* skeleton, BaseAnimationR* animation,
f32 startFrame, f32 endFrame, f32 currentFrame, f32 speed, f32 morphCounter,
- AnimationMode mode, Vec3s* diffRotTable) {
+ AnimationMode mode, s_xyz* diffRotTable) {
skeletonInfo->morphCounter = morphCounter;
skeletonInfo->skeleton = Lib_SegmentedToVirtual(skeleton);
skeletonInfo->animation = Lib_SegmentedToVirtual(animation);
@@ -389,19 +389,19 @@ void cKF_SkeletonInfo_R_setAnim(SkeletonInfoR* skeletonInfo, BaseAnimationR* ani
void cKF_SkeletonInfo_R_morphJoint(SkeletonInfoR* skeletonInfo) {
// the current position of the joints
- Vec3s* joint = skeletonInfo->jointTable;
+ s_xyz* joint = skeletonInfo->jointTable;
// the animation's current position
- Vec3s* morph = skeletonInfo->morphTable;
+ s_xyz* morph = skeletonInfo->morphTable;
// Represents the position between joint 1 and joint 2 to interpolate.
f32 parameter = !IS_ZERO(skeletonInfo->morphCounter) ? 1.0f / fabsf(skeletonInfo->morphCounter) : 0.0f;
- Vec3s jointTemp;
- Vec3s morphTemp;
- Vec3s temp_vec;
+ s_xyz jointTemp;
+ s_xyz morphTemp;
+ s_xyz temp_vec;
s32 i;
f32 new_var;
f32 new_var2;
- // the first Vec3s is the root joint's translation
+ // the first s_xyz is the root joint's translation
cKF_SkeletonInfo_morphST((s16*)joint, (s16*)morph, parameter);
joint++;
@@ -464,7 +464,7 @@ s32 cKF_SkeletonInfo_R_play(SkeletonInfoR* skeletonInfo) {
Keyframe* dataSource;
s16* keyframeNumberTable;
u32 ckcbIndex;
- Vec3s* joint;
+ s_xyz* joint;
constValueTable = Lib_SegmentedToVirtual(skeletonInfo->animation->constValueTable);
keyframeNumberTable = Lib_SegmentedToVirtual(skeletonInfo->animation->keyframeNumber);
@@ -570,9 +570,9 @@ void cKF_Si3_draw_SV_R_child(Game_Play* game_play, SkeletonInfoR* skeletonInfo,
Gfx* newDlist;
Gfx* shape;
u8 displayBufferFlag;
- Vec3s rotation;
- Vec3s* joint = &skeletonInfo->jointTable[*jointIndex];
- Vec3f translation;
+ s_xyz rotation;
+ s_xyz* joint = &skeletonInfo->jointTable[*jointIndex];
+ xyz_t translation;
// if this is not the root joint.
if (*jointIndex != 0) {
@@ -582,7 +582,7 @@ void cKF_Si3_draw_SV_R_child(Game_Play* game_play, SkeletonInfoR* skeletonInfo,
} else {
s32 transformationFlag = skeletonInfo->animationMove.transformationFlag;
- Vec3f* baseTranslation = &skeletonInfo->animationMove.baseShapeTranslation;
+ xyz_t* baseTranslation = &skeletonInfo->animationMove.baseShapeTranslation;
// Translate the root joint.
// The AnimationMove struct can specify an override translation.
@@ -601,7 +601,7 @@ void cKF_Si3_draw_SV_R_child(Game_Play* game_play, SkeletonInfoR* skeletonInfo,
}
}
- // jointIndex increases by 1 each recursive call, but because the root joint uses the first 2 Vec3s in jointTable,
+ // jointIndex increases by 1 each recursive call, but because the root joint uses the first 2 s_xyz in jointTable,
// the index of the current joint is actually jointIndex + 1.
joint++;
rotation = *joint;
@@ -681,7 +681,7 @@ void cKF_Si3_draw_R_SV(Game_Play* game_play, SkeletonInfoR* skeletonInfo, Mtx* m
}
void cKF_SkeletonInfo_R_init_standard_repeat_speedsetandmorph(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation,
- Vec3s* diffRotTable, f32 speed, f32 morphCounter) {
+ s_xyz* diffRotTable, f32 speed, f32 morphCounter) {
BaseAnimationR* animationPtr = Lib_SegmentedToVirtual(animation);
cKF_SkeletonInfo_R_init(skeletonInfo, skeletonInfo->skeleton, animation, 1.0f, animationPtr->duration, 1.0f, speed,
@@ -689,7 +689,7 @@ void cKF_SkeletonInfo_R_init_standard_repeat_speedsetandmorph(SkeletonInfoR* ske
}
void cKF_SkeletonInfo_R_init_standard_repeat_setframeandspeedandmorph(SkeletonInfoR* skeletonInfo,
- BaseAnimationR* animation, Vec3s* diffRotTable,
+ BaseAnimationR* animation, s_xyz* diffRotTable,
f32 currentFrame, f32 speed, f32 morphCounter) {
BaseAnimationR* animationPtr = Lib_SegmentedToVirtual(animation);
@@ -698,7 +698,7 @@ void cKF_SkeletonInfo_R_init_standard_repeat_setframeandspeedandmorph(SkeletonIn
}
void cKF_SkeletonInfo_R_init_standard_setframeandspeedandmorphandmode(SkeletonInfoR* skeletonInfo,
- BaseAnimationR* animation, Vec3s* diffRotTable,
+ BaseAnimationR* animation, s_xyz* diffRotTable,
f32 currentFrame, f32 speed, f32 morphCounter,
AnimationMode mode) {
BaseAnimationR* animationPtr = Lib_SegmentedToVirtual(animation);
@@ -708,7 +708,7 @@ void cKF_SkeletonInfo_R_init_standard_setframeandspeedandmorphandmode(SkeletonIn
}
void cKF_SkeletonInfo_R_init_reverse_setspeedandmorphandmode(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation,
- Vec3s* diffRotTable, f32 currentFrame, f32 speed,
+ s_xyz* diffRotTable, f32 currentFrame, f32 speed,
AnimationMode mode) {
cKF_SkeletonInfo_R_init(
skeletonInfo, skeletonInfo->skeleton, animation, ((BaseAnimationR*)Lib_SegmentedToVirtual(animation))->duration,
@@ -868,7 +868,7 @@ void cKF_SkeletonInfo_R_combine_rotation(s16** joint, u32* flag, SkeletonInfoRCo
s32 cKF_SkeletonInfo_R_combine_play(SkeletonInfoR* skeletonInfo1, SkeletonInfoR* skeletonInfo2, s32 arg2, s32 arg3,
s32 arg4, s32 arg5, s8* flag) {
- Vec3s* var_v0;
+ s_xyz* var_v0;
u32 spB0;
s16* joint;
SkeletonInfoRCombineWork combine1;
@@ -955,7 +955,7 @@ void cKF_SkeletonInfo_R_T_combine_play(s32* arg0, s32* arg1, s32* arg2, Skeleton
UNK_PTR* sp48 = NULL;
UNK_PTR* sp44 = NULL;
UNK_PTR* sp40 = NULL;
- Vec3s* var_v0;
+ s_xyz* var_v0;
if ((skeletonInfo1 == NULL) || (skeletonInfo2 == NULL) || (skeletonInfo3 == NULL) || (arg6 < 0) || (arg6 >= 0x10) ||
(arg7 < 0) || (arg7 >= 0x10) || (arg8 < 0) || (arg8 >= 0x10) || (flag == NULL)) {
@@ -1032,7 +1032,7 @@ void cKF_SkeletonInfo_R_Animation_Set_base_shape_trs(SkeletonInfoR* skeletonInfo
skeletonInfo->animationMove.updatedBaseShapeRotation.z = skeletonInfo->animationMove.baseShapeRotation.z = rotZ;
}
-void cKF_SkeletonInfo_R_AnimationMove_ct_base(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, f32 arg4,
+void cKF_SkeletonInfo_R_AnimationMove_ct_base(xyz_t* arg0, xyz_t* arg1, s16 arg2, s16 arg3, f32 arg4,
SkeletonInfoR* skeletonInfo, s32 transformationFlag) {
s32 var_v0;
@@ -1071,8 +1071,8 @@ void cKF_SkeletonInfo_R_AnimationMove_ct_base(Vec3f* arg0, Vec3f* arg1, s16 arg2
void cKF_SkeletonInfo_R_AnimationMove_dt(SkeletonInfoR* skeletonInfo) {
s32 transformationFlag = skeletonInfo->animationMove.transformationFlag;
- Vec3s* rootJointTranslation = &skeletonInfo->jointTable[0];
- Vec3f* baseShapeTranslation = &skeletonInfo->animationMove.baseShapeTranslation;
+ s_xyz* rootJointTranslation = &skeletonInfo->jointTable[0];
+ xyz_t* baseShapeTranslation = &skeletonInfo->animationMove.baseShapeTranslation;
if (transformationFlag & 1) {
rootJointTranslation->x = baseShapeTranslation->x;
@@ -1082,7 +1082,7 @@ void cKF_SkeletonInfo_R_AnimationMove_dt(SkeletonInfoR* skeletonInfo) {
rootJointTranslation->y = baseShapeTranslation->y;
}
if (transformationFlag & 4) {
- Vec3s* rootJointRotation = &skeletonInfo->jointTable[1];
+ s_xyz* rootJointRotation = &skeletonInfo->jointTable[1];
rootJointRotation->x = skeletonInfo->animationMove.baseShapeRotation.x;
rootJointRotation->y = skeletonInfo->animationMove.baseShapeRotation.y;
@@ -1091,7 +1091,7 @@ void cKF_SkeletonInfo_R_AnimationMove_dt(SkeletonInfoR* skeletonInfo) {
skeletonInfo->animationMove.transformationFlag = 0;
}
-void cKF_SkeletonInfo_R_AnimationMove_base(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, s16 arg3,
+void cKF_SkeletonInfo_R_AnimationMove_base(xyz_t* arg0, s_xyz* arg1, xyz_t* arg2, s16 arg3,
SkeletonInfoR* skeletonInfo) {
u32 transformationFlag = skeletonInfo->animationMove.transformationFlag;
f32 counter = skeletonInfo->animationMove.counter;
@@ -1146,7 +1146,7 @@ void cKF_SkeletonInfo_R_AnimationMove_base(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2
if ((arg1 != NULL) && (transformationFlag & 4)) {
s32 sp8C = skeletonInfo->animationMove.baseAngleY;
s32 sp88 = skeletonInfo->animationMove.shapeAngleCorrection;
- Vec3s* sp28 = &skeletonInfo->animationMove.updatedBaseShapeRotation;
+ s_xyz* sp28 = &skeletonInfo->animationMove.updatedBaseShapeRotation;
s32 sp80 = skeletonInfo->animationMove.baseShapeRotation.x;
s32 temp;
@@ -1160,7 +1160,7 @@ void cKF_SkeletonInfo_R_AnimationMove_base(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2
}
if (arg0 != NULL) {
- Vec3s* sp78 = skeletonInfo->jointTable;
+ s_xyz* sp78 = skeletonInfo->jointTable;
s16 var_a0 = 0;
if (arg1 != NULL) {
@@ -1204,9 +1204,9 @@ void cKF_SkeletonInfo_R_AnimationMove_base(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2
skeletonInfo->animationMove.counter = counter;
}
-void cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4, s16 arg5,
- Vec3f* arg6, SkeletonInfoR* skeleton, s32 arg8) {
- Vec3s* temp_v0 = &skeleton->jointTable[0];
+void cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(xyz_t* arg0, xyz_t* arg1, f32 arg2, f32 arg3, f32 arg4, s16 arg5,
+ xyz_t* arg6, SkeletonInfoR* skeleton, s32 arg8) {
+ s_xyz* temp_v0 = &skeleton->jointTable[0];
f32 sp20;
f32 sp1C;
f32 sp18;
diff --git a/src/code/m_actor.c b/src/code/m_actor.c
index 382d775..ea4ee9c 100644
--- a/src/code/m_actor.c
+++ b/src/code/m_actor.c
@@ -39,7 +39,7 @@ void func_80056380_jp(void* arg0, void* arg1 UNUSED) {
FaultDrawer_Printf("ACTOR NAME %08x:%s", actor, name);
}
-void projection_pos_set(Game_Play* game_play, Vec3f* worldPos, Vec3f* projectedPos, f32* invW) {
+void projection_pos_set(Game_Play* game_play, xyz_t* worldPos, xyz_t* projectedPos, f32* invW) {
Skin_Matrix_PrjMulVector(&game_play->viewProjectionMtxF, worldPos, projectedPos, invW);
*invW = (*invW < 1.0f) ? 1.0f : (1.0f / *invW);
@@ -86,7 +86,7 @@ s32 Actor_player_look_direction_check(Actor* actor, s16 maxAngleDiff, Game_Play*
}
void Actor_display_position_set(Game_Play* game_play, Actor* actor, s16* x, s16* y) {
- Vec3f projectedPos;
+ xyz_t projectedPos;
f32 invW;
projection_pos_set(game_play, &actor->world.pos, &projectedPos, &invW);
@@ -128,8 +128,8 @@ void Shape_Info_init(Actor* actor, f32 arg1, Shape_Info_unk_0C arg2, f32 arg3, f
actor->shape.unk_2D = 0;
}
-void Actor_foot_shadow_pos_set(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex,
- Vec3f* rightFootPos) {
+void Actor_foot_shadow_pos_set(Actor* actor, s32 limbIndex, s32 leftFootIndex, xyz_t* leftFootPos, s32 rightFootIndex,
+ xyz_t* rightFootPos) {
if (limbIndex == leftFootIndex) {
Matrix_Position(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]);
} else if (limbIndex == rightFootIndex) {
@@ -295,7 +295,7 @@ s32 Actor_draw_actor_no_culling_check(Actor* actor) {
return Actor_draw_actor_no_culling_check2(actor, &actor->projectedPos, actor->projectedW);
}
-s32 Actor_draw_actor_no_culling_check2(Actor* actor, Vec3f* arg1, f32 arg2) {
+s32 Actor_draw_actor_no_culling_check2(Actor* actor, xyz_t* arg1, f32 arg2) {
s32 ret = 0;
if ((-actor->unk_140 < arg1->z) && (arg1->z < (actor->unk_13C + actor->unk_140))) {
@@ -773,7 +773,7 @@ s32 Actor_malloc_actor_class(Actor** actorP, ActorProfile* profile, ActorOverlay
void Actor_init_actor_class(Actor* actor, ActorProfile* profile, ActorOverlay* overlayEntry, Game_Play* game_play,
s32 arg4, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s8 argB, s8 argC, s16 argD,
u16 fgName, s16 params) {
- mem_clear(actor, profile->instanceSize, 0);
+ mem_clear((u8*)actor, profile->instanceSize, 0);
actor->overlayEntry = overlayEntry;
@@ -864,7 +864,7 @@ Actor* Actor_info_make_child_actor(ActorInfo* actorInfo, Actor* arg1, Game_Play*
}
void restore_fgdata(Actor* actor, Game_Play* game_play UNUSED) {
- Vec3f sp34;
+ xyz_t sp34;
if ((actor->fgName == 0) || (actor->unk_00A != -1)) {
return;
@@ -1043,9 +1043,9 @@ void Part_Break_init(Part_Break* partBreak, s32 count, s32 arg2 UNUSED) {
goto cleanup;
}
- mem_clear(partBreak->matrices, matricesSize, 0);
- mem_clear(partBreak->dLists, dListsSize, 0);
- mem_clear(partBreak->objectIds, objectIdsSize, 0);
+ mem_clear((u8*)partBreak->matrices, matricesSize, 0);
+ mem_clear((u8*)partBreak->dLists, dListsSize, 0);
+ mem_clear((u8*)partBreak->objectIds, objectIdsSize, 0);
partBreak->val = 1;
return;
@@ -1064,7 +1064,7 @@ cleanup:
Mtx B_8011B850_jp;
-Gfx* HiliteReflect_new(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx, Gfx* gfx, Hilite** hilite) {
+Gfx* HiliteReflect_new(xyz_t* object, xyz_t* eye, xyz_t* lightDir, GraphicsContext* gfxCtx, Gfx* gfx, Hilite** hilite) {
LookAt* sp64 = GRAPH_ALLOC(gfxCtx, sizeof(LookAt));
f32 var_fa1 = ((eye->x == object->x) && (eye->z == object->z)) ? (eye->x + 0.001f) : eye->x;
@@ -1081,7 +1081,7 @@ Gfx* HiliteReflect_new(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsConte
return gfx;
}
-Hilite* HiliteReflect_init(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx) {
+Hilite* HiliteReflect_init(xyz_t* object, xyz_t* eye, xyz_t* lightDir, GraphicsContext* gfxCtx) {
Hilite* hilite;
OPEN_DISPS(gfxCtx);
@@ -1093,7 +1093,7 @@ Hilite* HiliteReflect_init(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsC
return hilite;
}
-Hilite* HiliteReflect_xlu_init(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx) {
+Hilite* HiliteReflect_xlu_init(xyz_t* object, xyz_t* eye, xyz_t* lightDir, GraphicsContext* gfxCtx) {
Hilite* hilite;
OPEN_DISPS(gfxCtx);
@@ -1105,7 +1105,7 @@ Hilite* HiliteReflect_xlu_init(Vec3f* object, Vec3f* eye, Vec3f* lightDir, Graph
return hilite;
}
-Hilite* HiliteReflect_light_init(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx) {
+Hilite* HiliteReflect_light_init(xyz_t* object, xyz_t* eye, xyz_t* lightDir, GraphicsContext* gfxCtx) {
Hilite* hilite;
OPEN_DISPS(gfxCtx);
@@ -1117,8 +1117,8 @@ Hilite* HiliteReflect_light_init(Vec3f* object, Vec3f* eye, Vec3f* lightDir, Gra
return hilite;
}
-Hilite* Setpos_HiliteReflect_init(Vec3f* object, Game_Play* game_play) {
- Vec3f sp24;
+Hilite* Setpos_HiliteReflect_init(xyz_t* object, Game_Play* game_play) {
+ xyz_t sp24;
sp24.x = game_play->kankyo.unk_02;
sp24.y = game_play->kankyo.unk_03;
@@ -1126,8 +1126,8 @@ Hilite* Setpos_HiliteReflect_init(Vec3f* object, Game_Play* game_play) {
return HiliteReflect_init(object, &game_play->unk_1938.unk_028, &sp24, game_play->state.gfxCtx);
}
-Hilite* Setpos_HiliteReflect_xlu_init(Vec3f* object, Game_Play* game_play) {
- Vec3f sp24;
+Hilite* Setpos_HiliteReflect_xlu_init(xyz_t* object, Game_Play* game_play) {
+ xyz_t sp24;
sp24.x = game_play->kankyo.unk_02;
sp24.y = game_play->kankyo.unk_03;
@@ -1135,8 +1135,8 @@ Hilite* Setpos_HiliteReflect_xlu_init(Vec3f* object, Game_Play* game_play) {
return HiliteReflect_xlu_init(object, &game_play->unk_1938.unk_028, &sp24, game_play->state.gfxCtx);
}
-Hilite* Setpos_HiliteReflect_light_init(Vec3f* object, Game_Play* game_play) {
- Vec3f sp24;
+Hilite* Setpos_HiliteReflect_light_init(xyz_t* object, Game_Play* game_play) {
+ xyz_t sp24;
sp24.x = game_play->kankyo.unk_02;
sp24.y = game_play->kankyo.unk_03;
diff --git a/src/code/m_collision_obj.c b/src/code/m_collision_obj.c
index 4a30e15..260acea 100644
--- a/src/code/m_collision_obj.c
+++ b/src/code/m_collision_obj.c
@@ -17,7 +17,7 @@ typedef void (*CollisionVsFunc)(struct Game_Play*, CollisionCheck*, ClObj*, ClOb
typedef s32 (*ClearFunc)(struct Game_Play*, ClObj*);
-void CollisionCheck_workTrisElemCenter(ClObjTrisElem* arg0, Vec3f* arg1) {
+void CollisionCheck_workTrisElemCenter(ClObjTrisElem* arg0, xyz_t* arg1) {
arg1->x = (arg0->attr.unk_00.unk_00.vertices[0].x + arg0->attr.unk_00.unk_00.vertices[1].x +
arg0->attr.unk_00.unk_00.vertices[2].x) *
(1.0f / 3.0f);
@@ -243,8 +243,8 @@ s32 ClObjTrisElemAttr_dt(UNUSED struct Game_Play* game_play, UNUSED ClObjTrisEle
}
s32 ClObjTrisElemAttr_set(UNUSED struct Game_Play* game_play, ClObjTrisElemAttr* attr, ClObjTrisElemAttr_Init* init) {
- Vec3f* var_v0;
- Vec3f* var_v1;
+ xyz_t* var_v0;
+ xyz_t* var_v1;
f32 sp44;
f32 sp40;
f32 sp3C;
@@ -418,8 +418,8 @@ ColMassType get_type(u8 mass) {
return MASSTYPE_NORMAL;
}
-void CollisionCheck_setOC_HitInfo(ClObj* cl1, ClObjElem* clElem1, Vec3f* pos1, ClObj* cl2, ClObjElem* clElem2,
- Vec3f* pos2, f32 overlap) {
+void CollisionCheck_setOC_HitInfo(ClObj* cl1, ClObjElem* clElem1, xyz_t* pos1, ClObj* cl2, ClObjElem* clElem2,
+ xyz_t* pos2, f32 overlap) {
f32 zDelta;
f32 massInverse;
f32 xDelta;
@@ -549,8 +549,8 @@ void CollisionCheck_OC_JntSph_Vs_JntSph(UNUSED struct Game_Play* game_play, UNUS
}
if (Math3D_sphereCrossSphere_cl(&elem1->attr.unk_08, &elem2->attr.unk_08, &overlap) == 1) {
- Vec3f pos1;
- Vec3f pos2;
+ xyz_t pos1;
+ xyz_t pos2;
xyz_t_move_s_xyz(&pos1, &elem1->attr.unk_08.center);
xyz_t_move_s_xyz(&pos2, &elem2->attr.unk_08.center);
@@ -584,8 +584,8 @@ void CollisionCheck_OC_JntSph_Vs_Pipe(UNUSED struct Game_Play* game_play, UNUSED
}
if (Math3D_sphereVsPipe_cl(&sphElem->attr.unk_08, &colPipe->attribute.dim, &overlap) == 1) {
- Vec3f sphPos;
- Vec3f pipePos;
+ xyz_t sphPos;
+ xyz_t pipePos;
xyz_t_move_s_xyz(&sphPos, &sphElem->attr.unk_08.center);
xyz_t_move_s_xyz(&pipePos, &colPipe->attribute.dim.pos);
@@ -604,8 +604,8 @@ void CollisionCheck_OC_Pipe_Vs_Pipe(UNUSED struct Game_Play* game_play, UNUSED C
ClObjPipe* pipe1 = (ClObjPipe*)cl1;
ClObjPipe* pipe2 = (ClObjPipe*)cl2;
f32 overlap;
- Vec3f pos1;
- Vec3f pos2;
+ xyz_t pos1;
+ xyz_t pos2;
if ((!(pipe1->base.prop.ocFlags1 & OC1_1) || !(pipe2->base.prop.ocFlags1 & OC1_1) ||
!(pipe1->element.flags & ELEM_FLAG_1) || !(pipe2->element.flags & ELEM_FLAG_1))) {
@@ -676,8 +676,8 @@ void CollisionCheck_OC(struct Game_Play* game_play, CollisionCheck* colCheck) {
}
void CollisionCheck_setOCC_HitInfo(UNUSED struct Game_Play* game_play, ClObj* cl1, ClObjTrisElem* trisElem,
- UNUSED Vec3f* arg3, ClObj* cl2, UNUSED ClObjElem* arg5, UNUSED Vec3f* arg6,
- Vec3f* arg7) {
+ UNUSED xyz_t* arg3, ClObj* cl2, UNUSED ClObjElem* arg5, UNUSED xyz_t* arg6,
+ xyz_t* arg7) {
cl1->oc = cl2->actor;
cl1->prop.ocFlags2 |= OC2_4;
@@ -699,7 +699,7 @@ void CollisionCheck_OCC_Tris_Vs_JntSph(struct Game_Play* game_play, UNUSED Colli
for (sphElem = colJntSph->elements; sphElem < &colJntSph->elements[colJntSph->count]; sphElem++) {
ClObjTrisElem* trisElem;
- Vec3f sp74;
+ xyz_t sp74;
if (!(sphElem->elem.flags & ELEM_FLAG_1)) {
continue;
@@ -707,8 +707,8 @@ void CollisionCheck_OCC_Tris_Vs_JntSph(struct Game_Play* game_play, UNUSED Colli
for (trisElem = colTris->elements; trisElem < &colTris->elements[colTris->count]; trisElem++) {
if (Math3D_sphereCrossTriangle3_cp(&sphElem->attr.unk_08, &trisElem->attr.unk_00, &sp74) != 0) {
- Vec3f sphPos;
- Vec3f trisPos;
+ xyz_t sphPos;
+ xyz_t trisPos;
xyz_t_move_s_xyz(&sphPos, &sphElem->attr.unk_08.center);
CollisionCheck_workTrisElemCenter(trisElem, &trisPos);
@@ -735,11 +735,11 @@ void CollisionCheck_OCC_Tris_Vs_Pipe(struct Game_Play* game_play, UNUSED Collisi
}
for (elem = colTris->elements; elem < &colTris->elements[colTris->count]; elem++) {
- Vec3f sp68;
+ xyz_t sp68;
if (Math3D_pipeCrossTriangle_cp(&colPipe->attribute.dim, &elem->attr.unk_00.unk_00, &sp68) != 0) {
- Vec3f pipePos;
- Vec3f trisPos;
+ xyz_t pipePos;
+ xyz_t trisPos;
CollisionCheck_workTrisElemCenter(elem, &trisPos);
xyz_t_move_s_xyz(&pipePos, &colPipe->attribute.dim.pos);
diff --git a/src/code/m_lib.c b/src/code/m_lib.c
new file mode 100644
index 0000000..3c7d927
--- /dev/null
+++ b/src/code/m_lib.c
@@ -0,0 +1,760 @@
+#include "m_lib.h"
+#include "game.h"
+#include "libc/math.h"
+#include "m_rcp.h"
+#include "macros.h"
+#include "sys_math.h"
+#include "sys_math_atan.h"
+
+ValueSetProc D_80107B00_jp[] = {
+ ValueSet__s_char, ValueSet__u_char, ValueSet__s_short, ValueSet__u_short, ValueSet__s_int, ValueSet__u_int,
+ ValueSet__float, ValueSet__float_x1000, ValueSet__xyz_t, ValueSet__xyz_t_x1000, ValueSet__s_xyz,
+};
+
+void mem_copy(u8* dest, u8* src, size_t len) {
+ while (len != 0) {
+ *dest = *src;
+ src++;
+ dest++;
+ len--;
+ }
+}
+
+void mem_clear(u8* ptr, size_t len, u8 value) {
+ size_t i;
+
+ // clang-format off
+ for (i = 0; i < len; i++) {*ptr++ = value;}
+ // clang-format on
+}
+
+s32 mem_cmp(u8* ptr1, u8* ptr2, size_t len) {
+ while (len != 0) {
+ if (*ptr1 != *ptr2) {
+ return 0;
+ }
+ ptr1++;
+ ptr2++;
+ len--;
+ }
+ return 1;
+}
+
+f32 cos_s(s16 angle) {
+ return coss(angle) * SHT_MINV;
+}
+
+f32 sin_s(s16 angle) {
+ return sins(angle) * SHT_MINV;
+}
+
+s32 chase_angle(s16* pValue, s16 target, s16 step) {
+ if (step != 0) {
+ f32 updateScale = game_GameFrame_2F;
+
+ if ((s16)(*pValue - target) > 0) {
+ step = -step;
+ }
+
+ *pValue += (s16)(step * updateScale);
+
+ if (((s16)(*pValue - target) * step) >= 0) {
+ *pValue = target;
+ return TRUE;
+ }
+ } else if (*pValue == target) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+s32 chase_s(s16* pValue, s16 target, s16 step) {
+ if (step) {
+ if (*pValue > target) {
+ step = -step;
+ }
+
+ *pValue += step;
+
+ if ((step * (*pValue - target)) >= 0) {
+ *pValue = target;
+ return TRUE;
+ }
+ } else {
+ if (*pValue == target) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+s32 chase_f(f32* pValue, f32 target, f32 step) {
+ if (step) {
+ if (*pValue > target) {
+ step = -step;
+ }
+
+ *pValue += step;
+
+ if ((step * (*pValue - target)) >= 0.0f) {
+ *pValue = target;
+ return TRUE;
+ }
+ } else {
+ if (*pValue == target) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+s32 chase_angle2(s16* pValue, s16 limit, s16 step) {
+ s16 prev = *pValue;
+
+ *pValue += step;
+ if (((s16)(*pValue - limit) * (s16)(prev - limit)) <= 0) {
+ *pValue = limit;
+ return 1;
+ }
+
+ return 0;
+}
+
+s32 chase_s2(s16* pValue, s16 limit, s16 step) {
+ s16 prev = *pValue;
+
+ *pValue += step;
+ if ((*pValue - limit) * (prev - limit) <= 0) {
+ *pValue = limit;
+ return 1;
+ }
+ return 0;
+}
+
+s32 chase_s3(s16* pValue, s16 target, s16 step) {
+ if (step) {
+ s32 diff = target - *pValue;
+
+ if (diff < 0) {
+ step = -step;
+ }
+
+ if (diff >= 0x8000) {
+ step = -step;
+ diff = -0xFFFF - -diff;
+ } else if (diff <= -0x8000) {
+ step = -step;
+ diff += 0xFFFF;
+ }
+
+ *pValue += step;
+
+ if ((diff * step) <= 0) {
+ *pValue = target;
+ return TRUE;
+ }
+
+ } else if (target == *pValue) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+s32 chase_f2(f32* pValue, f32 limit, f32 step) {
+ f32 prev = *pValue;
+
+ *pValue += step;
+ if ((*pValue - limit) * (prev - limit) <= 0.0f) {
+ *pValue = limit;
+ return 1;
+ }
+ return 0;
+}
+
+s32 chase_f3(f32* pValue, f32 target, f32 incrStep, f32 decrStep) {
+ f32 step = (target >= *pValue) ? incrStep : decrStep;
+
+ if (step != 0.0f) {
+ if (target < *pValue) {
+ step = -step;
+ }
+
+ *pValue += step;
+
+ if (((*pValue - target) * step) >= 0) {
+ *pValue = target;
+ return 1;
+ }
+ } else if (target == *pValue) {
+ return 1;
+ }
+
+ return 0;
+}
+
+void inter_float(f32* pValue, f32 arg1, s32 stepCount) {
+ if (stepCount <= 0) {
+ *pValue = arg1;
+ } else {
+ f32 diff = arg1 - *pValue;
+
+ *pValue += diff / stepCount;
+ }
+}
+
+void stick_ratio_set(f32* radius, s16* angle, Input* input) {
+ f32 relX = input->rel.stick_x;
+ f32 relY = input->rel.stick_y;
+
+ *radius = sqrtf(SQ(relX) + SQ(relY));
+ *radius = (*radius > 60.0f) ? 60.0f : *radius;
+
+ *angle = atans_table(relY, -relX);
+}
+
+s16 get_random_timer(s16 base, s16 range) {
+ return base + (s16)(RANDOM_F(range));
+}
+
+s16 get_random_pattern_timer(s16 base, s16 stride, s16 range) {
+ return base + (s16)(RANDOM_F(range)) * stride;
+}
+
+void xyz_t_move(xyz_t* dest, xyz_t* src) {
+ dest->x = src->x;
+ dest->y = src->y;
+ dest->z = src->z;
+}
+
+void xyz_t_move_s_xyz(xyz_t* dest, s_xyz* src) {
+ dest->x = src->x;
+ dest->y = src->y;
+ dest->z = src->z;
+}
+
+void xyz_t_add(xyz_t* augend, xyz_t* addend, xyz_t* total) {
+ total->x = augend->x + addend->x;
+ total->y = augend->y + addend->y;
+ total->z = augend->z + addend->z;
+}
+
+void xyz_t_sub(xyz_t* minuend, xyz_t* subtrahend, xyz_t* diff) {
+ diff->x = minuend->x - subtrahend->x;
+ diff->y = minuend->y - subtrahend->y;
+ diff->z = minuend->z - subtrahend->z;
+}
+
+void xyz_t_sub_ss(xyz_t* dest, s_xyz* minuend, s_xyz* subtrahend) {
+ dest->x = minuend->x - subtrahend->x;
+ dest->y = minuend->y - subtrahend->y;
+ dest->z = minuend->z - subtrahend->z;
+}
+
+void xyz_t_mult_v(xyz_t* multiplicand, f32 multiplier) {
+ multiplicand->x *= multiplier;
+ multiplicand->y *= multiplier;
+ multiplicand->z *= multiplier;
+}
+
+f32 search_position_distance(xyz_t* subtrahend, xyz_t* minuend) {
+ f32 diffX = minuend->x - subtrahend->x;
+ f32 diffY = minuend->y - subtrahend->y;
+ f32 diffZ = minuend->z - subtrahend->z;
+
+ return sqrtf(SQ(diffX) + SQ(diffY) + SQ(diffZ));
+}
+
+f32 search_position_distance2(xyz_t* subtrahend, xyz_t* minuend, xyz_t* dest) {
+ dest->x = minuend->x - subtrahend->x;
+ dest->y = minuend->y - subtrahend->y;
+ dest->z = minuend->z - subtrahend->z;
+
+ return sqrtf(SQ(dest->x) + SQ(dest->y) + SQ(dest->z));
+}
+
+f32 search_position_distanceXZ(xyz_t* subtrahend, xyz_t* minuend) {
+ f32 diffX = minuend->x - subtrahend->x;
+ f32 diffZ = minuend->z - subtrahend->z;
+
+ return sqrtf(SQ(diffX) + SQ(diffZ));
+}
+
+f32 search_position_high(xyz_t* subtrahend, xyz_t* minuend) {
+ return minuend->y - subtrahend->y;
+}
+
+s16 search_position_angleY(xyz_t* subtrahend, xyz_t* minuend) {
+ f32 diffX = minuend->x - subtrahend->x;
+ f32 diffZ = minuend->z - subtrahend->z;
+
+ return atans_table(diffZ, diffX);
+}
+
+s16 search_position_angleX(xyz_t* subtrahend, xyz_t* minuend) {
+ f32 distXZ = search_position_distanceXZ(subtrahend, minuend);
+ f32 diffY = subtrahend->y - minuend->y;
+
+ return atans_table(distXZ, diffY);
+}
+
+void ValueSet_process(u8* ptr, ValueSet* values) {
+ do {
+ D_80107B00_jp[values->type](ptr, values);
+ } while ((values++)->cont);
+}
+
+void ValueSet__s_char(u8* ptr, ValueSet* value_set) {
+ *(s8*)(ptr + value_set->offset) = value_set->value;
+}
+
+void ValueSet__u_char(u8* ptr, ValueSet* value_set) {
+ *(u8*)(ptr + value_set->offset) = value_set->value;
+}
+
+void ValueSet__s_short(u8* ptr, ValueSet* value_set) {
+ *(s16*)(ptr + value_set->offset) = value_set->value;
+}
+
+void ValueSet__u_short(u8* ptr, ValueSet* value_set) {
+ *(u16*)(ptr + value_set->offset) = value_set->value;
+}
+
+void ValueSet__s_int(u8* ptr, ValueSet* value_set) {
+ *(s32*)(ptr + value_set->offset) = value_set->value;
+}
+
+void ValueSet__u_int(u8* ptr, ValueSet* value_set) {
+ *(u32*)(ptr + value_set->offset) = value_set->value;
+}
+
+void ValueSet__float(u8* ptr, ValueSet* value_set) {
+ *(f32*)(ptr + value_set->offset) = value_set->value;
+}
+
+void ValueSet__float_x1000(u8* ptr, ValueSet* value_set) {
+ *(f32*)(ptr + value_set->offset) = value_set->value / 1000.0f;
+}
+
+void ValueSet__xyz_t(u8* ptr, ValueSet* value_set) {
+ xyz_t* vec = (xyz_t*)(ptr + value_set->offset);
+ f32 val = value_set->value;
+
+ vec->z = val;
+ vec->y = val;
+ vec->x = val;
+}
+
+void ValueSet__xyz_t_x1000(u8* ptr, ValueSet* value_set) {
+ xyz_t* vec = (xyz_t*)(ptr + value_set->offset);
+ f32 val = value_set->value / 1000.0f;
+
+ vec->z = val;
+ vec->y = val;
+ vec->x = val;
+}
+
+void ValueSet__s_xyz(u8* ptr, ValueSet* value_set) {
+ s_xyz* vec = (s_xyz*)(ptr + value_set->offset);
+ s16 val = value_set->value;
+
+ vec->z = val;
+ vec->y = val;
+ vec->x = val;
+}
+
+f32 add_calc(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep) {
+ f32 negMinStep;
+ f32 stepSize;
+
+ if (*pValue != target) {
+ stepSize = fraction * (target - *pValue);
+ negMinStep = -minStep;
+
+ if ((stepSize <= negMinStep) || (minStep <= stepSize)) {
+ if (stepSize > step) {
+ stepSize = step;
+ } else if (stepSize < -step) {
+ stepSize = -step;
+ }
+
+ *pValue += stepSize;
+
+ if (stepSize > 0.0f) {
+ if (*pValue > target) {
+ *pValue = target;
+ }
+ } else {
+ if (*pValue < target) {
+ *pValue = target;
+ }
+ }
+ } else {
+ if (stepSize > 0.0f) {
+ *pValue += minStep;
+ if (*pValue > target) {
+ *pValue = target;
+ }
+ } else {
+ *pValue += negMinStep;
+ if (*pValue < target) {
+ *pValue = target;
+ }
+ }
+ }
+ }
+
+ return target - *pValue;
+}
+
+void add_calc2(f32* pValue, f32 target, f32 fraction, f32 step) {
+ f32 stepSize;
+ if (*pValue != target) {
+ stepSize = fraction * (target - *pValue);
+
+ if (stepSize > step) {
+ stepSize = step;
+ } else if (stepSize < -step) {
+ stepSize = -step;
+ }
+
+ *pValue += stepSize;
+ }
+}
+
+void add_calc0(f32* pValue, f32 fraction, f32 step) {
+ f32 stepSize = *pValue * fraction;
+
+ if (stepSize > step) {
+ stepSize = step;
+ } else if (stepSize < -step) {
+ stepSize = -step;
+ }
+
+ *pValue -= stepSize;
+}
+
+f32 add_calc_a(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep) {
+ f32 stepSize = 0.0f;
+ f32 diff = target - *pValue;
+
+ if (target != *pValue) {
+ if (diff > 180.0f) {
+ diff = -(360.0f - diff);
+ } else if (diff < -180.0f) {
+ diff = 360.0f + diff;
+ }
+
+ stepSize = diff * fraction;
+
+ if ((stepSize >= minStep) || (stepSize <= -minStep)) {
+ if (step < stepSize) {
+ stepSize = step;
+ } else if (stepSize < -step) {
+ stepSize = -step;
+ }
+
+ *pValue += stepSize;
+
+ if (stepSize > 0.0f) {
+ if (target < *pValue) {
+ *pValue = target;
+ }
+ } else if (*pValue < target) {
+ *pValue = target;
+ }
+ } else {
+ if (stepSize > 0.0f) {
+ stepSize = minStep;
+ *pValue += stepSize;
+ if (target < *pValue) {
+ *pValue = target;
+ }
+ } else {
+ stepSize = -minStep;
+ *pValue += -minStep;
+ if (*pValue < target) {
+ *pValue = target;
+ }
+ }
+ }
+ }
+ if (*pValue >= 360.0f) {
+ *pValue -= 360.0f;
+ }
+ if (*pValue < 0.0f) {
+ *pValue += 360.0f;
+ }
+ return stepSize;
+}
+
+s16 add_calc_short_angle2(s16* pValue, s16 target, f32 fraction, s16 step, s16 minStep) {
+ s16 stepSize = 0;
+ s16 diff = target - *pValue;
+
+ if (*pValue != target) {
+ stepSize = (s32)(diff * fraction);
+
+ if ((minStep < stepSize) || (stepSize < -minStep)) {
+ if (step < stepSize) {
+ stepSize = step;
+ } else if (stepSize < -step) {
+ stepSize = -step;
+ }
+
+ *pValue += stepSize;
+
+ if (stepSize > 0) {
+ if ((s16)(target - *pValue) < 0) {
+ *pValue = target;
+ }
+ } else {
+ if ((s16)(target - *pValue) > 0) {
+ *pValue = target;
+ }
+ }
+ } else {
+ if (diff >= 0) {
+ *pValue += minStep;
+ if ((s16)(target - *pValue) < 0) {
+ *pValue = target;
+ }
+ } else {
+ *pValue -= minStep;
+ if ((s16)(target - *pValue) > 0) {
+ *pValue = target;
+ }
+ }
+ }
+ }
+ return target - *pValue;
+}
+
+s16 add_calc_short_angle3(s16* pValue, s16 target, f32 fraction, s16 maxStep, s16 minStep) {
+ f32 stepSize;
+ s32 uTarget;
+ s32 newValue;
+ s32 uValue;
+
+ if (target != *pValue) {
+ uValue = (u16)*pValue;
+ uTarget = (u16)target;
+
+ if (uValue > uTarget) {
+ uTarget += 0x10000;
+ }
+
+ stepSize = (uTarget - uValue) * fraction;
+
+ if (stepSize > maxStep) {
+ stepSize = maxStep;
+ } else if (stepSize < minStep) {
+ stepSize = minStep;
+ }
+
+ newValue = uValue + (s32)stepSize;
+ if (newValue > uTarget) {
+ newValue = uTarget;
+ }
+ *pValue = newValue;
+ }
+
+ return target - *pValue;
+}
+
+void adds(s16* pValue, s16 target, s16 scale, s16 maxStep) {
+ s16 diff = target - *pValue;
+ diff /= scale;
+
+ if (diff > maxStep) {
+ *pValue += maxStep;
+ return;
+ }
+
+ if (diff < -maxStep) {
+ *pValue -= maxStep;
+ return;
+ }
+
+ *pValue += diff;
+}
+
+void rgba_t_move(Color_RGBA8* dest, Color_RGBA8* src) {
+ dest->r = src->r;
+ dest->g = src->g;
+ dest->b = src->b;
+ dest->a = src->a;
+}
+
+s32 none_proc1() {
+ return 0;
+}
+
+void none_proc2(Actor* actor UNUSED, Game_Play* play UNUSED) {
+}
+
+void Cheap_gfx_display(Game_Play* play, Gfx* dl) {
+ //! FAKE
+ if ((!(&play->state)) && (!(&play->state))) {}
+
+ OPEN_DISPS(play->state.gfxCtx);
+
+ _texture_z_light_fog_prim(play->state.gfxCtx);
+
+ gSPMatrix(POLY_OPA_DISP++, _Matrix_to_Mtx_new(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+
+ gSPDisplayList(POLY_OPA_DISP++, dl);
+
+ CLOSE_DISPS(play->state.gfxCtx);
+}
+
+void Cheap_gfx_display_xlu(Game_Play* play, Gfx* dl) {
+ //! FAKE
+ if ((!(&play->state)) && (!(&play->state))) {}
+
+ OPEN_DISPS(play->state.gfxCtx);
+
+ _texture_z_light_fog_prim_xlu(play->state.gfxCtx);
+
+ gSPMatrix(POLY_XLU_DISP++, _Matrix_to_Mtx_new(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+
+ gSPDisplayList(POLY_XLU_DISP++, dl);
+
+ CLOSE_DISPS(play->state.gfxCtx);
+}
+
+s32 _Game_play_isPause(Game_Play* play) {
+ return play->pause.enabled != 0;
+}
+
+void* Lib_SegmentedToVirtual(void* ptr) {
+ return SEGMENTED_TO_K0(ptr);
+}
+
+void* Lib_SegmentedToVirtualNull(void* ptr) {
+ if (((uintptr_t)ptr >> 28) == 0) {
+ return ptr;
+ } else {
+ return SEGMENTED_TO_K0(ptr);
+ }
+}
+
+void* PhysicalToVirtual(uintptr_t ptr) {
+ if (ptr == 0) {
+ return 0;
+ }
+
+ return OS_PHYSICAL_TO_K0(ptr);
+}
+
+void* PhysicalToVirtualNull(uintptr_t ptr) {
+ if (ptr == 0) {
+ return 0;
+ }
+
+ return OS_PHYSICAL_TO_K0(ptr);
+}
+
+f32 check_percent_abs(f32 x, f32 min, f32 max, f32 scale, s32 shiftMin) {
+ if ((-min <= x) && (x <= min)) {
+ return 0.0f;
+ }
+ if (x >= max) {
+ return 1.0f;
+ }
+ if (x <= -max) {
+ return -1.0f;
+ }
+ if (shiftMin) {
+ if (x > 0.0f) {
+ return (x - min) * scale;
+ } else {
+ return (x + min) * scale;
+ }
+ } else {
+ return x * scale;
+ }
+}
+
+f32 get_percent_forAccelBrake(f32 x, f32 min, f32 max, f32 accelRange, f32 brakeRange) {
+ f32 percent;
+ f32 range;
+ f32 cur;
+ f32 scale;
+
+ if (x >= max) {
+ return 1.0f;
+ }
+ if (x <= min) {
+ return 0.0f;
+ }
+
+ cur = x - min;
+ range = max - min;
+
+ if (range < accelRange + brakeRange) {
+ return 0.0f;
+ }
+
+ scale = 1.0f / (2.0f * range - accelRange - brakeRange);
+
+ if (accelRange != 0.0f) {
+ if (cur <= accelRange) {
+ percent = scale * cur * cur;
+ percent /= accelRange;
+ return percent;
+ } else {
+ percent = scale * accelRange;
+ }
+ } else {
+ percent = 0.0f;
+ }
+
+ if (cur <= range - brakeRange) {
+ percent += (scale * 2.0f) * (cur - accelRange);
+ return percent;
+ }
+
+ percent += 2.0f * scale * (range - accelRange - brakeRange);
+
+ if (brakeRange != 0.0f) {
+ percent += scale * brakeRange;
+ if (cur < range) {
+ f32 left = range - cur;
+
+ percent -= scale * left * left / brakeRange;
+ }
+ }
+ return percent;
+}
+
+void Game_play_Projection_Trans(Game_Play* play, xyz_t* src, xyz_t* dst) {
+ f32 temp_f0;
+
+ Matrix_mult(&play->viewProjectionMtxF, 0);
+ Matrix_Position(src, dst);
+ temp_f0 =
+ play->viewProjectionMtxF.ww + ((play->viewProjectionMtxF.wx * src->x) + (play->viewProjectionMtxF.wy * src->y) +
+ (play->viewProjectionMtxF.wz * src->z));
+ dst->x = ((dst->x / temp_f0) * 160.0f) + 160.0f;
+ dst->y = 120.0f - ((dst->y / temp_f0) * 120.0f);
+}
+
+f32 get_percent(s32 max, s32 min, s32 x) {
+ f32 denom;
+ f32 percent;
+
+ percent = 1.0f;
+ if (x < min) {
+ percent = 0.0f;
+ } else if (x < max) {
+ denom = (f32)(max - min);
+ if (denom != 0.0f) {
+ percent = (f32)(x - min) / denom;
+ if (percent > 1.0f) {
+ percent = 1.0f;
+ }
+ }
+ }
+ return percent;
+}
diff --git a/src/code/m_lights.c b/src/code/m_lights.c
index 664d53b..8de578a 100644
--- a/src/code/m_lights.c
+++ b/src/code/m_lights.c
@@ -92,7 +92,7 @@ Light* LightsN_new_diffuse(LightsN* lights) {
return &lights->lights.l[lights->diffuse_count++];
}
-void LightsN__point_proc(LightsN* lights, LightParams* lightInfo, Vec3f* point) {
+void LightsN__point_proc(LightsN* lights, LightParams* lightInfo, xyz_t* point) {
f32 xdiff;
f32 ydiff;
f32 zdiff;
@@ -130,7 +130,7 @@ void LightsN__point_proc(LightsN* lights, LightParams* lightInfo, Vec3f* point)
}
}
-void LightsN__P_point_proc(LightsN* lights, LightParams* lightInfo, UNUSED Vec3f* pos) {
+void LightsN__P_point_proc(LightsN* lights, LightParams* lightInfo, UNUSED xyz_t* pos) {
if (lightInfo->point.radius > 0) {
Light* light = LightsN_new_diffuse(lights);
@@ -164,7 +164,7 @@ void LightsN__P_point_proc(LightsN* lights, LightParams* lightInfo, UNUSED Vec3f
}
}
-void LightsN__diffuse_proc(LightsN* lights, LightParams* lightInfo, UNUSED Vec3f* pos) {
+void LightsN__diffuse_proc(LightsN* lights, LightParams* lightInfo, UNUSED xyz_t* pos) {
Light* light = LightsN_new_diffuse(lights);
if (light != NULL) {
@@ -177,7 +177,7 @@ void LightsN__diffuse_proc(LightsN* lights, LightParams* lightInfo, UNUSED Vec3f
}
}
-void LightsN_list_check(LightsN* lights, LightNode* node, Vec3f* pos) {
+void LightsN_list_check(LightsN* lights, LightNode* node, xyz_t* pos) {
static light_point_proc poslight_type_proc[] = {
LightsN__point_proc,
LightsN__diffuse_proc,
diff --git a/src/code/m_mail.c b/src/code/m_mail.c
index 2960de8..d816fe2 100644
--- a/src/code/m_mail.c
+++ b/src/code/m_mail.c
@@ -60,7 +60,7 @@ void mMl_clear_mail_header(Mail* mail) {
void mMl_clear_mail(Mail* mail) {
bzero(mail, sizeof(Mail));
mMl_clear_mail_header(mail);
- mem_clear(&mail->unk_2A, sizeof(mMl_unk_2A), 0x20);
+ mem_clear((u8*)&mail->unk_2A, sizeof(mMl_unk_2A), 0x20);
mail->unk_26 = 0xFF;
}
@@ -147,18 +147,18 @@ s32 mMl_count_use_mail_space(Mail mail[], s32 arg1) {
}
void mMl_copy_mail(Mail* dst, Mail* src) {
- mem_copy(dst, src, sizeof(Mail));
+ mem_copy((u8*)dst, (u8*)src, sizeof(Mail));
}
void mMl_clear_mail_header_common(MailHeaderCommon* arg0) {
arg0->unk_00 = -1;
arg0->unk_01 = 0;
- mem_clear(arg0->unk_02, 0xA, 0x20);
- mem_clear(arg0->unk_0C, 0x10, 0x20);
+ mem_clear((u8*)arg0->unk_02, 0xA, 0x20);
+ mem_clear((u8*)arg0->unk_0C, 0x10, 0x20);
}
void mMl_copy_mail_header_common(MailHeaderCommon* arg0, MailHeaderCommon* arg1) {
- mem_copy(arg0, arg1, sizeof(MailHeaderCommon));
+ mem_copy((u8*)arg0, (u8*)arg1, sizeof(MailHeaderCommon));
}
void mMl_set_mail_name_npcinfo(mMl_unk_00* arg0, mMl_get_npcinfo_from_mail_name_arg0* arg1) {
diff --git a/src/code/m_scene.c b/src/code/m_scene.c
index 87df0c3..21b2f5c 100644
--- a/src/code/m_scene.c
+++ b/src/code/m_scene.c
@@ -358,7 +358,7 @@ void Scene_Proc_Sound(UNK_TYPE arg0 UNUSED, UNK_TYPE arg1 UNUSED) {
#pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_scene/func_800C6D5C_jp.s")
void return_emu_game(Game* game) {
- mem_copy(&common_data.unk_10754, &common_data.unk_107A0, 0x14);
+ mem_copy((u8*)&common_data.unk_10754, (u8*)&common_data.unk_107A0, 0x14);
common_data.unk_10754 = common_data.unk_107A0 + 1;
game->unk_74 = 0;
game_goto_next_game_play(game);
diff --git a/src/code/m_snowman.c b/src/code/m_snowman.c
index a60ac1f..3075c24 100644
--- a/src/code/m_snowman.c
+++ b/src/code/m_snowman.c
@@ -121,7 +121,7 @@ void mSN_regist_snowman_society(SnowmanInfo* snowmanInfo) {
u16 name;
if (snowmanIndex != -1) {
- mem_copy(&common_data.snowmanData[snowmanIndex], snowmanInfo, sizeof(SnowmanData));
+ mem_copy((u8*)&common_data.snowmanData[snowmanIndex], (u8*)snowmanInfo, sizeof(SnowmanData));
if (sp2E) {
mPB_keep_item(sp2E);
diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c
index ab7d1cf..05f5a87 100644
--- a/src/code/sys_matrix.c
+++ b/src/code/sys_matrix.c
@@ -600,7 +600,7 @@ void Matrix_rotateXYZ(s16 x, s16 y, s16 z, MatrixMode mode) {
* @param translation vector by which to translate.
* @param rot vector of rotation angles.
*/
-void Matrix_softcv3_mult(Vec3f* translation, Vec3s* rot) {
+void Matrix_softcv3_mult(xyz_t* translation, s_xyz* rot) {
MtxF* top = Matrix_now;
f32 sin = sin_s(rot->z);
f32 cos = cos_s(rot->z);
@@ -695,7 +695,7 @@ void Matrix_softcv3_mult(Vec3f* translation, Vec3s* rot) {
* @param z amount to translate in Z direction.
* @param rot vector of rotation angles.
*/
-void Matrix_softcv3_load(f32 x, f32 y, f32 z, Vec3s* rot) {
+void Matrix_softcv3_load(f32 x, f32 y, f32 z, s_xyz* rot) {
MtxF* top = Matrix_now;
f32 sinY = sin_s(rot->y);
f32 cosY = cos_s(rot->y);
@@ -908,7 +908,7 @@ void _MtxF_to_Mtx_new(MtxF* src, GraphicsContext* gfxCtx) {
* @param[in] src input vector
* @param[out] dest output vector
*/
-void Matrix_Position(Vec3f* src, Vec3f* dest) {
+void Matrix_Position(xyz_t* src, xyz_t* dest) {
MtxF* top = Matrix_now;
dest->x = top->xw + (top->xx * src->x + top->xy * src->y + top->xz * src->z);
@@ -926,7 +926,7 @@ void Matrix_Position(Vec3f* src, Vec3f* dest) {
*
* @param[out] dest output vector.
*/
-void Matrix_Position_Zero(Vec3f* dest) {
+void Matrix_Position_Zero(xyz_t* dest) {
MtxF* top = Matrix_now;
dest->x = top->xw;
@@ -944,7 +944,7 @@ void Matrix_Position_Zero(Vec3f* dest) {
* @param[in] x multiplier of unit vector in x direction.
* @param[out] dest output vector.
*/
-void Matrix_Position_VecX(f32 x, Vec3f* dest) {
+void Matrix_Position_VecX(f32 x, xyz_t* dest) {
MtxF* top = Matrix_now;
dest->x = top->xw + top->xx * x;
@@ -962,7 +962,7 @@ void Matrix_Position_VecX(f32 x, Vec3f* dest) {
* @param[in] y multiplier of unit vector in y direction.
* @param[out] dest output vector.
*/
-void Matrix_Position_VecY(f32 y, Vec3f* dest) {
+void Matrix_Position_VecY(f32 y, xyz_t* dest) {
MtxF* top = Matrix_now;
dest->x = top->xw + top->xy * y;
@@ -980,7 +980,7 @@ void Matrix_Position_VecY(f32 y, Vec3f* dest) {
* @param[in] z multiplier of unit vector in z direction.
* @param[out] dest output vector.
*/
-void Matrix_Position_VecZ(f32 z, Vec3f* dest) {
+void Matrix_Position_VecZ(f32 z, xyz_t* dest) {
MtxF* top = Matrix_now;
dest->x = top->xw + top->xz * z;
@@ -1045,7 +1045,7 @@ void Matrix_MtxtoMtxF(Mtx* src, MtxF* dest) {
* @param[out] dest output vector
* @param[in] mf matrix to multiply by
*/
-void Matrix_MtxF_Position2(Vec3f* src, Vec3f* dest, MtxF* mf) {
+void Matrix_MtxF_Position2(xyz_t* src, xyz_t* dest, MtxF* mf) {
dest->x = mf->xw + (mf->xx * src->x + mf->xy * src->y + mf->xz * src->z);
dest->y = mf->yw + (mf->yx * src->x + mf->yy * src->y + mf->yz * src->z);
dest->z = mf->zw + (mf->zx * src->x + mf->zy * src->y + mf->zz * src->z);
@@ -1155,7 +1155,7 @@ void Matrix_rotate_scale_exchange(MtxF* mf) {
* @param[out] dest vector to write angles to.
* @param[in] nonUniformScale boolean: true enables handling matrices with differently-scaled columns.
*/
-void Matrix_to_rotate_new(MtxF* src, Vec3s* dest, s32 nonUniformScale) {
+void Matrix_to_rotate_new(MtxF* src, s_xyz* dest, s32 nonUniformScale) {
f32 temp;
f32 temp2;
f32 temp3;
@@ -1224,7 +1224,7 @@ void Matrix_to_rotate_new(MtxF* src, Vec3s* dest, s32 nonUniformScale) {
*
* See Matrix_to_rotate_new() for full inline documentation.
*/
-void Matrix_to_rotate2_new(MtxF* src, Vec3s* dest, s32 nonUniformScale) {
+void Matrix_to_rotate2_new(MtxF* src, s_xyz* dest, s32 nonUniformScale) {
f32 temp;
f32 temp2;
f32 temp3;
@@ -1274,7 +1274,7 @@ void Matrix_to_rotate2_new(MtxF* src, Vec3s* dest, s32 nonUniformScale) {
* @param axis axis about which to rotate, must be a unit vector.
* @param mode APPLY or NEW.
*/
-void Matrix_RotateVector(s16 angle, Vec3f* axis, u8 mode) {
+void Matrix_RotateVector(s16 angle, xyz_t* axis, u8 mode) {
MtxF* top;
f32 sin;
f32 cos;