From 02dc7fc7af3b39e44b9b030235f1dd66e7644efe Mon Sep 17 00:00:00 2001 From: Prakxo <87568477+Prakxo@users.noreply.github.com> Date: Wed, 27 Sep 2023 20:03:11 +0200 Subject: [PATCH] m_lib OK (#103) * m_lib OK * fixes * rename segmented2virtual macro --- include/c_keyframe.h | 52 +- include/m_actor.h | 38 +- include/m_collision_bg.h | 8 +- include/m_collision_obj.h | 4 +- include/m_field_info.h | 14 +- include/m_lib.h | 138 ++-- include/m_lights.h | 12 +- include/m_npc.h | 4 +- include/m_rcp.h | 2 +- include/m_scene.h | 4 +- include/m_skin_matrix.h | 2 +- include/m_snowman.h | 2 +- include/m_submenu.h | 2 +- include/m_view.h | 2 +- include/macros.h | 5 + include/sys_math3d.h | 16 +- include/sys_matrix.h | 22 +- include/z64math.h | 4 +- linker_scripts/jp/symbol_addrs_code.txt | 2 +- src/code/c_keyframe.c | 74 +- src/code/m_actor.c | 40 +- src/code/m_collision_obj.c | 38 +- src/code/m_lib.c | 760 +++++++++++++++++++++ src/code/m_lights.c | 8 +- src/code/m_mail.c | 10 +- src/code/m_scene.c | 2 +- src/code/m_snowman.c | 2 +- src/code/sys_matrix.c | 22 +- src/overlays/actors/ovl_Mbg/ac_mbg.c | 2 +- src/overlays/actors/ovl_Mbg/ac_mbg.h | 2 +- src/overlays/actors/ovl_Toudai/ac_toudai.c | 6 +- src/overlays/actors/ovl_Toudai/ac_toudai.h | 4 +- yamls/jp/code.yaml | 6 +- 33 files changed, 1044 insertions(+), 265 deletions(-) create mode 100644 src/code/m_lib.c diff --git a/include/c_keyframe.h b/include/c_keyframe.h index d375efa9..26a00c75 100644 --- a/include/c_keyframe.h +++ b/include/c_keyframe.h @@ -24,7 +24,7 @@ typedef struct { /* 0x0 */ Gfx* shape; /* 0x4 */ u8 numberOfChildren; /* 0x5 */ u8 displayBufferFlag; - /* 0x6 */ Vec3s translation; + /* 0x6 */ s_xyz translation; } JointElemR; // size = 0xC typedef struct { @@ -51,13 +51,13 @@ typedef struct { typedef struct { /* 0x00 */ s32 transformationFlag; - /* 0x04 */ Vec3f baseWorldPosition; + /* 0x04 */ xyz_t baseWorldPosition; /* 0x10 */ s16 baseAngleY; - /* 0x14 */ Vec3f baseShapeTranslation; - /* 0x20 */ Vec3s baseShapeRotation; - /* 0x26 */ Vec3s updatedBaseShapeRotation; + /* 0x14 */ xyz_t baseShapeTranslation; + /* 0x20 */ s_xyz baseShapeRotation; + /* 0x26 */ s_xyz updatedBaseShapeRotation; /* 0x2C */ f32 counter; - /* 0x30 */ Vec3f shapeWorldPositionCorrection; + /* 0x30 */ xyz_t shapeWorldPositionCorrection; /* 0x3C */ s16 shapeAngleCorrection; } AnimationMove; // size = 0x40 @@ -66,9 +66,9 @@ typedef struct { /* 0x18 */ BaseSkeletonR* skeleton; /* 0x1C */ BaseAnimationR* animation; /* 0x20 */ f32 morphCounter; - /* 0x24 */ Vec3s* jointTable; - /* 0x28 */ Vec3s* morphTable; - /* 0x2C */ Vec3s* diffRotTable; + /* 0x24 */ s_xyz* jointTable; + /* 0x28 */ s_xyz* morphTable; + /* 0x2C */ s_xyz* diffRotTable; /* 0x30 */ AnimationMove animationMove; } SkeletonInfoR; // size = 0x70 @@ -83,7 +83,7 @@ typedef struct { /* 0x1C */ s32 keyframeStartIndex; } SkeletonInfoRCombineWork; // size = 0x20 -typedef s32 (*DrawCallback)(struct Game_Play* game_play, SkeletonInfoR* skeletonInfo, s32 jointIndex, Gfx** dlist, u8* displayBufferFlag, void*, Vec3s* rotation, Vec3f* translation); +typedef s32 (*DrawCallback)(struct Game_Play* game_play, SkeletonInfoR* skeletonInfo, s32 jointIndex, Gfx** dlist, u8* displayBufferFlag, void*, s_xyz* rotation, xyz_t* translation); void cKF_FrameControl_zeroClear(FrameControl* frameControl); void cKF_FrameControl_ct(FrameControl* frameControl); @@ -100,22 +100,22 @@ void cKF_SkeletonInfo_subRotInterpolation(f32 t, s16* out, s16 jointRotation, s1 void cKF_SkeletonInfo_morphST(s16* joint, s16* morph, f32 t); 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); void cKF_SkeletonInfo_R_dt(SkeletonInfoR* skeletonInfo); -void cKF_SkeletonInfo_R_init_standard_stop(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation, Vec3s* diffRotTable); +void cKF_SkeletonInfo_R_init_standard_stop(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation, s_xyz* diffRotTable); void cKF_SkeletonInfo_R_init_standard_stop_speedset(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation, - Vec3s* diffRotTable, f32 speed); + s_xyz* diffRotTable, f32 speed); void cKF_SkeletonInfo_R_init_standard_stop_morph(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation, - Vec3s* diffRotTable, f32 morphCounter); + s_xyz* diffRotTable, f32 morphCounter); void cKF_SkeletonInfo_R_init_standard_repeat(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation, - Vec3s* diffRotTable); + s_xyz* diffRotTable); void cKF_SkeletonInfo_R_init_standard_repeat_speedset(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation, - Vec3s* diffRotTable, f32 speed); + s_xyz* diffRotTable, f32 speed); void cKF_SkeletonInfo_R_init_standard_repeat_morph(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation, - Vec3s* diffRotTable, f32 morphCounter); + s_xyz* diffRotTable, f32 morphCounter); 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); void cKF_SkeletonInfo_R_setAnim(SkeletonInfoR* skeletonInfo, BaseAnimationR* animation); void cKF_SkeletonInfo_R_morphJoint(SkeletonInfoR* skeletonInfo); s32 cKF_SkeletonInfo_R_play(SkeletonInfoR* skeletonInfo); @@ -124,16 +124,16 @@ void cKF_Si3_draw_SV_R_child(struct Game_Play* game_play, SkeletonInfoR* skeleto void cKF_Si3_draw_R_SV(struct Game_Play* game_play, SkeletonInfoR* skeletonInfo, Mtx* mtx, DrawCallback beforeCallback, DrawCallback afterCallback, void* arg); 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); 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); 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); 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); void func_80053384_jp(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, UNK_PTR* arg6, UNK_PTR* arg7, UNK_PTR* arg8); @@ -147,12 +147,12 @@ void cKF_SkeletonInfo_R_T_combine_play(s32* arg0, s32* arg1, s32* arg2, Skeleton s32 arg8, s32 arg9, s32 argA, s32 argB, s8* flag); void cKF_SkeletonInfo_R_Animation_Set_base_shape_trs(SkeletonInfoR* skeletonInfo, f32 translationX, f32 translationY, f32 translationZ, s16 rotX, s16 rotY, s16 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); void cKF_SkeletonInfo_R_AnimationMove_dt(SkeletonInfoR* skeletonInfo); -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); -void cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4, s16 arg5, - Vec3f* arg6, SkeletonInfoR* skeleton, s32 arg8); +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); #endif diff --git a/include/m_actor.h b/include/m_actor.h index a2eeb2f6..1293e104 100644 --- a/include/m_actor.h +++ b/include/m_actor.h @@ -65,14 +65,14 @@ typedef struct ActorProfile { } ActorProfile; // size = 0x24 typedef struct PosRot { - /* 0x00 */ Vec3f pos; - /* 0x0C */ Vec3s rot; + /* 0x00 */ xyz_t pos; + /* 0x0C */ s_xyz rot; } PosRot; // size = 0x14 typedef void (*Shape_Info_unk_0C)(struct Actor*, struct LightsN*, struct Game_Play*); typedef struct Shape_Info { - /* 0x00 */ Vec3s rot; + /* 0x00 */ s_xyz rot; /* 0x08 */ f32 unk_08; /* 0x0C */ Shape_Info_unk_0C unk_0C; /* 0x10 */ f32 unk_10; @@ -80,13 +80,13 @@ typedef struct Shape_Info { /* 0x18 */ f32 unk_18; /* 0x1C */ f32 unk_1C; /* 0x20 */ s32 unk_20; - /* 0x24 */ Vec3f* unk_24; // maybe PosRot* + /* 0x24 */ xyz_t* unk_24; // maybe PosRot* /* 0x28 */ s32 unk_28; /* 0x2C */ s8 unk_2C; /* 0x2D */ s8 unk_2D; /* 0x2E */ s8 unk_2E; /* 0x2F */ UNK_TYPE1 unk_2F[0x1]; - /* 0x30 */ Vec3f feetPos[FOOT_MAX]; + /* 0x30 */ xyz_t feetPos[FOOT_MAX]; } Shape_Info; // size = 0x48 typedef struct Actor { @@ -103,10 +103,10 @@ typedef struct Actor { /* 0x024 */ s16 params; /* 0x026 */ s16 unk_026; // objBankIndex /* 0x028 */ PosRot world; - /* 0x03C */ Vec3f prevPos; + /* 0x03C */ xyz_t prevPos; /* 0x048 */ PosRot eye; // focus - /* 0x05C */ Vec3f scale; - /* 0x068 */ Vec3f velocity; + /* 0x05C */ xyz_t scale; + /* 0x068 */ xyz_t velocity; /* 0x074 */ f32 speed; /* 0x078 */ f32 gravity; /* 0x07C */ f32 terminalVelocity; @@ -119,7 +119,7 @@ typedef struct Actor { /* 0x0C0 */ f32 playerHeightRel; /* 0x0C4 */ CollisionCheck_Status colStatus; // made-up name /* 0x0DC */ Shape_Info shape; - /* 0x124 */ Vec3f projectedPos; + /* 0x124 */ xyz_t projectedPos; /* 0x130 */ f32 projectedW; /* 0x134 */ f32 uncullZoneScale; /* 0x138 */ f32 uncullZoneDownward; @@ -229,7 +229,7 @@ typedef struct ActorInfo { #define ACTOR_FGNAME_GET_F000(fgName) (((fgName) & 0xF000) >> 12) -void projection_pos_set(struct Game_Play* game_play, Vec3f* worldPos, Vec3f* projectedPos, f32* invW); +void projection_pos_set(struct Game_Play* game_play, xyz_t* worldPos, xyz_t* projectedPos, f32* invW); void Actor_world_to_eye(Actor* actor, f32 arg1); void Actor_position_move(Actor* actor); void Actor_position_speed_set(Actor* actor); @@ -237,10 +237,10 @@ void Actor_position_moveF(Actor* actor); s32 Actor_player_look_direction_check(Actor* actor, s16 maxAngleDiff, struct Game_Play* game_play); void Actor_display_position_set(struct Game_Play* game_play, Actor* actor, s16* x, s16* y); void Shape_Info_init(Actor* actor, f32 arg1, Shape_Info_unk_0C arg2, f32 arg3, f32 arg4); -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); void Actor_delete(Actor* actor); s32 Actor_draw_actor_no_culling_check(Actor* actor); -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); void Actor_cull_check(Actor* actor); void Actor_delete_check(Actor* actor, struct Game_Play* game_play); void Actor_info_ct(struct Game_Play* game_play2, ActorInfo* actorInfo, struct ActorEntry* actorEntry); @@ -260,12 +260,12 @@ Actor* Actor_info_delete(ActorInfo* actorInfo, Actor* actor, struct Game_Play* g Actor* Actor_info_name_search(ActorInfo* actorInfo, s16 name, ActorPart part); Actor* Actor_info_fgName_search(ActorInfo* actorInfo, u16 fgName, ActorPart part); void Part_Break_init(Part_Break* partBreak, s32 count, UNK_TYPE arg2); -Gfx* HiliteReflect_new(Vec3f* object, Vec3f* eye, Vec3f* lightDir, struct GraphicsContext* gfxCtx, Gfx* gfx, Hilite** hilite); -Hilite* HiliteReflect_init(Vec3f* object, Vec3f* eye, Vec3f* lightDir, struct GraphicsContext* gfxCtx); -Hilite* HiliteReflect_xlu_init(Vec3f* object, Vec3f* eye, Vec3f* lightDir, struct GraphicsContext* gfxCtx); -Hilite* HiliteReflect_light_init(Vec3f* object, Vec3f* eye, Vec3f* lightDir, struct GraphicsContext* gfxCtx); -Hilite* Setpos_HiliteReflect_init(Vec3f* object, struct Game_Play* game_play); -Hilite* Setpos_HiliteReflect_xlu_init(Vec3f* object, struct Game_Play* game_play); -Hilite* Setpos_HiliteReflect_light_init(Vec3f* object, struct Game_Play* game_play); +Gfx* HiliteReflect_new(xyz_t* object, xyz_t* eye, xyz_t* lightDir, struct GraphicsContext* gfxCtx, Gfx* gfx, Hilite** hilite); +Hilite* HiliteReflect_init(xyz_t* object, xyz_t* eye, xyz_t* lightDir, struct GraphicsContext* gfxCtx); +Hilite* HiliteReflect_xlu_init(xyz_t* object, xyz_t* eye, xyz_t* lightDir, struct GraphicsContext* gfxCtx); +Hilite* HiliteReflect_light_init(xyz_t* object, xyz_t* eye, xyz_t* lightDir, struct GraphicsContext* gfxCtx); +Hilite* Setpos_HiliteReflect_init(xyz_t* object, struct Game_Play* game_play); +Hilite* Setpos_HiliteReflect_xlu_init(xyz_t* object, struct Game_Play* game_play); +Hilite* Setpos_HiliteReflect_light_init(xyz_t* object, struct Game_Play* game_play); #endif diff --git a/include/m_collision_bg.h b/include/m_collision_bg.h index 0fb4a074..896da7c6 100644 --- a/include/m_collision_bg.h +++ b/include/m_collision_bg.h @@ -99,7 +99,7 @@ typedef struct mCoBG_OffsetTable { // void func_8006B5C0_jp(); // void func_8006B664_jp(); // void func_8006B92C_jp(); -s32 mCoBG_RegistMoveBg(s8 *arg0, PosRot *arg1, Vec3f *arg2, s16 *arg3, f32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9, s32 argA, f32 argB); +s32 mCoBG_RegistMoveBg(s8 *arg0, PosRot *arg1, xyz_t *arg2, s16 *arg3, f32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9, s32 argA, f32 argB); // void func_8006BAA8_jp(); void mCoBG_CrossOffMoveBg(s32 arg0, struct Actor *actor); void func_8006BB64_jp(void); @@ -180,7 +180,7 @@ void func_8006C8D0_jp(void); // void func_80071884_jp(); // void func_80071A08_jp(); // void func_80071AB8_jp(); -f32 mCoBG_GetBgY_OnlyCenter_FromWpos2(Vec3f arg0, f32 arg1); +f32 mCoBG_GetBgY_OnlyCenter_FromWpos2(xyz_t arg0, f32 arg1); // void func_80071C1C_jp(); // void func_80071DB4_jp(); // void func_800721C8_jp(); @@ -207,7 +207,7 @@ f32 mCoBG_GetBgY_OnlyCenter_FromWpos2(Vec3f arg0, f32 arg1); // void func_80072B24_jp(); // void func_80072BE8_jp(); // void func_80072C60_jp(); -s32 mCoBG_SearchWaterLimitDistN(UNK_TYPE* arg0, Vec3f arg1, s16 arg4, f32 arg5, s32 arg6); +s32 mCoBG_SearchWaterLimitDistN(UNK_TYPE* arg0, xyz_t arg1, s16 arg4, f32 arg5, s32 arg6); // void func_80072E70_jp(); // void func_80072F9C_jp(); // void func_800730C8_jp(); @@ -225,7 +225,7 @@ s32 mCoBG_SearchWaterLimitDistN(UNK_TYPE* arg0, Vec3f arg1, s16 arg4, f32 arg5, // void func_800739FC_jp(); // void func_80073C38_jp(); // void func_80073CC0_jp(); -void mCoBG_SetPluss5PointOffset_file(Vec3f pos, mCoBG_OffsetTable offsetData, char* file, s32 line); +void mCoBG_SetPluss5PointOffset_file(xyz_t pos, mCoBG_OffsetTable offsetData, char* file, s32 line); // void func_80074090_jp(); // void func_80074174_jp(); // void func_800741DC_jp(); diff --git a/include/m_collision_obj.h b/include/m_collision_obj.h index 62ba5eed..62c552e9 100644 --- a/include/m_collision_obj.h +++ b/include/m_collision_obj.h @@ -110,7 +110,7 @@ typedef struct ClObjTrisElemAttr_Init { typedef struct ClObjTrisElemAttr { /* 0x00 */ Triangle3 unk_00; - /* 0x34 */ Vec3f unk_34; + /* 0x34 */ xyz_t unk_34; } ClObjTrisElemAttr; // size = 0x40 @@ -154,7 +154,7 @@ typedef struct CollisionCheck_Status_Init { } CollisionCheck_Status_Init; // size = 0xA typedef struct CollisionCheck_Status { - /* 0x00 */ Vec3f displacement; + /* 0x00 */ xyz_t displacement; /* 0x0C */ s16 unk_0C; /* 0x0E */ s16 unk_0E; /* 0x10 */ s16 unk_10; diff --git a/include/m_field_info.h b/include/m_field_info.h index 758931e8..755c7c2e 100644 --- a/include/m_field_info.h +++ b/include/m_field_info.h @@ -30,7 +30,7 @@ struct Game_Play; // void func_80088458_jp(); // void func_800884E0_jp(); // void func_800885A8_jp(); -s32 mFI_Wpos2BlockNum(s32*, s32*, Vec3f); +s32 mFI_Wpos2BlockNum(s32*, s32*, xyz_t); // void func_80088780_jp(); // void func_8008883C_jp(); // void func_800888AC_jp(); @@ -88,13 +88,13 @@ void mFI_BlockKind2BkNum(s32*,s32*,s32); // void func_8008A3BC_jp(); // void func_8008A410_jp(); // void func_8008A4F8_jp(); -u16* mFI_GetUnitFG(Vec3f); +u16* mFI_GetUnitFG(xyz_t); // void func_8008A608_jp(); // void func_8008A670_jp(); // void func_8008A74C_jp(); // void func_8008A81C_jp(); // void func_8008A960_jp(); -UNK_TYPE mFI_SetFG_common(u16 fgName, Vec3f arg1, s32 arg2); +UNK_TYPE mFI_SetFG_common(u16 fgName, xyz_t arg1, s32 arg2); // void func_8008AA98_jp(); // void func_8008AB14_jp(); // void func_8008AC74_jp(); @@ -111,8 +111,8 @@ UNK_TYPE mFI_SetFG_common(u16 fgName, Vec3f arg1, s32 arg2); // void func_8008B2D0_jp(); // void func_8008B300_jp(); // void func_8008B318_jp(); -void mFI_SetBearActor(struct Game_Play* game_play, Vec3f arg1, s32 arg2); -s32 func_8008B3E8_jp(Vec3f* arg0, UNK_TYPE arg1); +void mFI_SetBearActor(struct Game_Play* game_play, xyz_t arg1, s32 arg2); +s32 func_8008B3E8_jp(xyz_t* arg0, UNK_TYPE arg1); // void func_8008B4C0_jp(); // void func_8008B598_jp(); // void func_8008B66C_jp(); @@ -154,7 +154,7 @@ void func_8008C478_jp(u16* deposit, int ut_x, int ut_z); // void func_8008C610_jp(); // void func_8008C630_jp(); // void func_8008C650_jp(); -void mFI_Wpos2DepositOFF(Vec3f); +void mFI_Wpos2DepositOFF(xyz_t); // void func_8008C708_jp(); // void func_8008C764_jp(); // void func_8008C798_jp(); @@ -189,7 +189,7 @@ void func_8008DCF8_jp(void); // void func_8008DF04_jp(); // void func_8008E058_jp(); // void func_8008E514_jp(); -void func_8008E5F4_jp(Vec3f arg0); +void func_8008E5F4_jp(xyz_t arg0); // void mFI_PrintNowBGNum(); // void mFI_PrintFgAttr(); // void func_8008E8E0_jp(); diff --git a/include/m_lib.h b/include/m_lib.h index 1fdaecd8..d411a96f 100644 --- a/include/m_lib.h +++ b/include/m_lib.h @@ -3,71 +3,85 @@ #include "ultra64.h" #include "z64math.h" -#include "unk.h" +#include "overlays/gamestates/ovl_play/m_play.h" +#include "color.h" +#include "sys_math.h" -struct Game_Play; -void mem_copy(void* dst, void* src, u32 size); -s32 mem_clear(void* ptr, size_t size, u8 value); -// void mem_cmp(); +typedef struct { + u32 cont: 1; + u32 type: 4; + u32 offset: 11; + s32 value: 16; +} ValueSet; + + +typedef void (*ValueSetProc)(u8*, ValueSet*); + + +extern ValueSetProc D_80107B00_jp[]; + +void mem_copy(u8* dest, u8* src, size_t len); +void mem_clear(u8* ptr, size_t len, u8 value); +s32 mem_cmp(u8* ptr1, u8* ptr2, size_t len); f32 cos_s(s16 angle); f32 sin_s(s16 angle); -// void chase_angle(); -// void chase_s(); -s32 chase_f(f32* arg0, f32 arg1, f32 arg2); -// void chase_angle2(); -// void chase_s2(); -// void chase_s3(); -// void chase_f2(); -// void chase_f3(); -// void inter_float(); -// void stick_ratio_set(); -// void get_random_timer(); -// void get_random_pattern_timer(); -void xyz_t_move(Vec3f* dst, Vec3f* src); -void xyz_t_move_s_xyz(Vec3f* dst, Vec3s* src); -// void xyz_t_add(); -// void xyz_t_sub(); -// void xyz_t_sub_ss(); -// void xyz_t_mult_v(); -// void search_position_distance(); -// void search_position_distance2(); -f32 search_position_distanceXZ(Vec3f* arg0, Vec3f* arg1); -// void search_position_high(); -s16 search_position_angleY(Vec3f* arg0, Vec3f* arg1); -// void search_position_angleX(); -// void ValueSet_process(); -// void ValueSet__s_char(); -// void ValueSet__u_char(); -// void ValueSet__s_short(); -// void ValueSet__u_short(); -// void ValueSet__s_int(); -// void ValueSet__u_int(); -// void ValueSet__float(); -// void ValueSet__float_x1000(); -// void ValueSet__xyz_t(); -// void ValueSet__xyz_t_x1000(); -// void ValueSet__s_xyz(); -f32 add_calc(f32* pValue, f32 target, f32 fraction, f32 maxStep, f32 minStep); -// void add_calc2(); -// void add_calc0(); -// void add_calc_a(); -// void add_calc_short_angle2(); -// void add_calc_short_angle3(); -// void adds(); -// void rgba_t_move(); -UNK_RET none_proc1(void); -// void none_proc2(); -// void Cheap_gfx_display(); -// void Cheap_gfx_display_xlu(); -s32 _Game_play_isPause(struct Game_Play* game_play); -void *Lib_SegmentedToVirtual(void *ptr); //original name unknown, taken from majora's mask -// void func_8009ADE0_jp(); -// void func_8009AE28_jp(); -// void func_8009AE44_jp(); -f32 check_percent_abs(f32 x, f32 min, f32 max, f32 scale, int shift_by_min); -// void get_percent_forAccelBrake(); -// void Game_play_Projection_Trans(); -// void get_percent(); +s32 chase_angle(s16* pValue, s16 target, s16 step); +s32 chase_s(s16* pValue, s16 target, s16 step); +s32 chase_f(f32* pValue, f32 target, f32 step); +s32 chase_angle2(s16* pValue, s16 limit, s16 step); +s32 chase_s2(s16* pValue, s16 limit, s16 step); +s32 chase_s3(s16* pValue, s16 target, s16 step); +s32 chase_f2(f32* pValue, f32 limit, f32 step); +s32 chase_f3(f32* pValue, f32 target, f32 incrStep, f32 decrStep); +void inter_float(f32* pValue, f32 arg1, s32 stepCount); +void stick_ratio_set(f32* radius, s16* angle, Input* input); +s16 get_random_timer(s16 base, s16 range); +s16 get_random_pattern_timer(s16 base, s16 stride, s16 range); +void xyz_t_move(xyz_t* dest, xyz_t* src); +void xyz_t_move_s_xyz(xyz_t* dest, s_xyz* src); +void xyz_t_add(xyz_t* augend, xyz_t* addend, xyz_t* total); +void xyz_t_sub(xyz_t* minuend, xyz_t* subtrahend, xyz_t* diff); +void xyz_t_sub_ss(xyz_t* dest, s_xyz* minuend, s_xyz* subtrahend); +void xyz_t_mult_v(xyz_t* multiplicand, f32 multiplier); +f32 search_position_distance(xyz_t* subtrahend, xyz_t* minuend); +f32 search_position_distance2(xyz_t* subtrahend, xyz_t* minuend, xyz_t* dest); +f32 search_position_distanceXZ(xyz_t* subtrahend, xyz_t* minuend); +f32 search_position_high(xyz_t* subtrahend, xyz_t* minuend); +s16 search_position_angleY(xyz_t* subtrahend, xyz_t* minuend); +s16 search_position_angleX(xyz_t* subtrahend, xyz_t* minuend); +void ValueSet_process(u8* ptr, ValueSet* values); +void ValueSet__s_char(u8* ptr, ValueSet* value_set); +void ValueSet__u_char(u8* ptr, ValueSet* value_set); +void ValueSet__s_short(u8* ptr, ValueSet* value_set); +void ValueSet__u_short(u8* ptr, ValueSet* value_set); +void ValueSet__s_int(u8* ptr, ValueSet* value_set); +void ValueSet__u_int(u8* ptr, ValueSet* value_set); +void ValueSet__float(u8* ptr, ValueSet* value_set); +void ValueSet__float_x1000(u8* ptr, ValueSet* value_set); +void ValueSet__xyz_t(u8* ptr, ValueSet* value_set); +void ValueSet__xyz_t_x1000(u8* ptr, ValueSet* value_set); +void ValueSet__s_xyz(u8* ptr, ValueSet* value_set); +f32 add_calc(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); +void add_calc2(f32* pValue, f32 target, f32 fraction, f32 step); +void add_calc0(f32* pValue, f32 fraction, f32 step); +f32 add_calc_a(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); +s16 add_calc_short_angle2(s16* pValue, s16 target, f32 fraction, s16 step, s16 minStep); +s16 add_calc_short_angle3(s16* pValue, s16 target, f32 fraction, s16 maxStep, s16 minStep); +void adds(s16* pValue, s16 target, s16 scale, s16 maxStep); +void rgba_t_move(Color_RGBA8* dest, Color_RGBA8* src); +s32 none_proc1(); +void none_proc2(Actor* actor, struct Game_Play* play); +void Cheap_gfx_display(struct Game_Play* play, Gfx* dl); +void Cheap_gfx_display_xlu(struct Game_Play* play, Gfx* dl); +s32 _Game_play_isPause(struct Game_Play* play); +void* Lib_SegmentedToVirtual(void* ptr); +void* Lib_SegmentedToVirtualNull(void* ptr); +void* PhysicalToVirtual(uintptr_t ptr); +void* PhysicalToVirtualNull(uintptr_t ptr); +f32 check_percent_abs(f32 x, f32 min, f32 max, f32 scale, s32 shiftMin); +f32 get_percent_forAccelBrake(f32 x, f32 min, f32 max, f32 accelRange, f32 brakeRange); +void Game_play_Projection_Trans(struct Game_Play* play, xyz_t* src, xyz_t* dst); +f32 get_percent(s32 max, s32 min, s32 x); #endif diff --git a/include/m_lights.h b/include/m_lights.h index 740b5e27..95e5a3ce 100644 --- a/include/m_lights.h +++ b/include/m_lights.h @@ -61,8 +61,8 @@ typedef struct Global_light { /* 0xC */ s16 fogFar; } Global_light; // size = 0x10 -typedef void (*light_point_proc)(LightsN*, LightParams*, Vec3f*); -typedef void (*light_P_point_proc)(LightsN*, LightParams*, Vec3f*); +typedef void (*light_point_proc)(LightsN*, LightParams*, xyz_t*); +typedef void (*light_P_point_proc)(LightsN*, LightParams*, xyz_t*); void point_data_set(Lights* lights, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type); void Light_point_ct(Lights* lights, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius); @@ -72,10 +72,10 @@ void Light_diffuse_ct(Lights* lights, s8 x, s8 y, s8 z, u8 r, u8 g, u8 b); void LightsN_ct(LightsN* lights, u8 r, u8 g, u8 b); void LightsN_disp(LightsN* lights, struct GraphicsContext* gfxCtx); Light* LightsN_new_diffuse(LightsN* lights); -void LightsN__point_proc(LightsN* lights, LightParams* lightInfo, Vec3f* point); -void LightsN__P_point_proc(LightsN* lights, LightParams* lightInfo, Vec3f* pos); -void LightsN__diffuse_proc(LightsN* lights, LightParams* lightInfo, Vec3f* pos); -void LightsN_list_check(LightsN* lights, LightNode* node, Vec3f* pos); +void LightsN__point_proc(LightsN* lights, LightParams* lightInfo, xyz_t* point); +void LightsN__P_point_proc(LightsN* lights, LightParams* lightInfo, xyz_t* pos); +void LightsN__diffuse_proc(LightsN* lights, LightParams* lightInfo, xyz_t* pos); +void LightsN_list_check(LightsN* lights, LightNode* node, xyz_t* pos); LightNode* Light_list_buf_new(void); void Light_list_buf_delete(LightNode* lightNode); void Global_light_ct(Global_light* glight); diff --git a/include/m_npc.h b/include/m_npc.h index e55c6e73..4fb13035 100644 --- a/include/m_npc.h +++ b/include/m_npc.h @@ -12,7 +12,7 @@ typedef struct NpcList { /* 0x00 */ char unk00[0x10]; - /* 0x10 */ Vec3f position; + /* 0x10 */ xyz_t position; /* 0x14 */ char unk14[0x1C]; } NpcList; // size = 0x38 @@ -198,7 +198,7 @@ void mNpc_GetNpcWorldNameAnm(PlayerName* arg0, struct mMl_get_npcinfo_from_mail_ // void func_800ACD74_jp(); // void func_800ACDF8_jp(); // void func_800ACE90_jp(); -void mNpc_GetAnimalPlateName(char* arg0, Vec3f arg1); +void mNpc_GetAnimalPlateName(char* arg0, xyz_t arg1); // void func_800AD084_jp(); // void func_800AD0B8_jp(); // void func_800AD104_jp(); diff --git a/include/m_rcp.h b/include/m_rcp.h index 57d180c6..d58dce47 100644 --- a/include/m_rcp.h +++ b/include/m_rcp.h @@ -17,7 +17,7 @@ Gfx* gfx_set_fog_nosync(Gfx* gfx, u8 arg1, u8 arg2, u8 arg3, s32 arg4, s16 arg5, void _texture_z_light_fog_prim(struct GraphicsContext *gfxCtx); // void _texture_z_light_fog_prim_shadow(); // void func_800BD538_jp(); -void func_800BD598_jp(Gfx* gfx); +void _texture_z_light_fog_prim_xlu(struct GraphicsContext *gfxCtx); void func_800BD5C0_jp(struct GraphicsContext* gfxCtx); void func_800BD5E8_jp(Gfx* gfx); // void func_800BD648_jp(); diff --git a/include/m_scene.h b/include/m_scene.h index c8097333..1cb1da77 100644 --- a/include/m_scene.h +++ b/include/m_scene.h @@ -8,8 +8,8 @@ struct Game_Play; typedef struct ActorEntry { /* 0x0 */ s16 id; - /* 0x2 */ Vec3s pos; - /* 0x8 */ Vec3s rot; + /* 0x2 */ s_xyz pos; + /* 0x8 */ s_xyz rot; /* 0xE */ s16 params; } ActorEntry; // size = 0x10 diff --git a/include/m_skin_matrix.h b/include/m_skin_matrix.h index 224a8f5a..272f89d8 100644 --- a/include/m_skin_matrix.h +++ b/include/m_skin_matrix.h @@ -4,7 +4,7 @@ #include "ultra64.h" #include "z64math.h" -void Skin_Matrix_PrjMulVector(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); +void Skin_Matrix_PrjMulVector(MtxF* mf, xyz_t* src, xyz_t* xyzDest, f32* wDest); // void Skin_Matrix_MulVector(); void Skin_Matrix_MulMatrix(MtxF* mfB, MtxF* mfA, MtxF* dest); // void Skin_Matrix_getUnitMatrixPointer(); diff --git a/include/m_snowman.h b/include/m_snowman.h index b2c9a158..dd041aca 100644 --- a/include/m_snowman.h +++ b/include/m_snowman.h @@ -15,7 +15,7 @@ typedef struct SnowmanData { typedef struct SnowmanInfo { /* 0x00 */ s32 unk0; //scale - /* 0x04 */ Vec3f position; + /* 0x04 */ xyz_t position; } SnowmanInfo; // size = 0x10 s32 mSN_check_life(u16* name, s32 daysElapsed); diff --git a/include/m_submenu.h b/include/m_submenu.h index 95d2b51a..b1a8d05c 100644 --- a/include/m_submenu.h +++ b/include/m_submenu.h @@ -92,7 +92,7 @@ typedef struct Submenu { /* 0xE0 */ u16 unk_E0; /* 0xE2 */ u8 unk_E2; /* 0xE3 */ u8 unk_E3; - /* 0xE4 */ Vec3f unk_E4; + /* 0xE4 */ xyz_t unk_E4; } Submenu; // size = 0xF0 s32 SubmenuArea_IsPlayer(void); diff --git a/include/m_view.h b/include/m_view.h index 177232c2..346c2bcf 100644 --- a/include/m_view.h +++ b/include/m_view.h @@ -15,7 +15,7 @@ typedef struct Game_Play1938 { /* 0x010 */ s32 unk_010; /* 0x018 */ s32 unk_014; /* 0x01C */ UNK_TYPE1 unk_018[0x10]; - /* 0x028 */ Vec3f unk_028; + /* 0x028 */ xyz_t unk_028; /* 0x034 */ UNK_TYPE1 unk_034[0x1C]; /* 0x050 */ Vp vp; /* 0x060 */ Mtx unk_060; diff --git a/include/macros.h b/include/macros.h index a420d5c6..7b4df6b1 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,6 +1,9 @@ #ifndef MACROS_H #define MACROS_H +#include "ultra64.h" +#include "code_variables.h" + #if defined(__GNUC__) || defined(__clang__) #define UNREACHABLE __builtin_unreachable() #else @@ -16,6 +19,8 @@ #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) #define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0])) +#define SEGMENTED_TO_K0(addr) (void*)((gSegments[SEGMENT_NUMBER(addr)] + K0BASE) + SEGMENT_OFFSET(addr)) + #define ABS(x) (((x) >= 0) ? (x): -(x)) #define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) diff --git a/include/sys_math3d.h b/include/sys_math3d.h index 52e5322d..525a89f5 100644 --- a/include/sys_math3d.h +++ b/include/sys_math3d.h @@ -6,17 +6,17 @@ #include "unk.h" typedef struct Sphere { - /* 0x0 */ Vec3s center; + /* 0x0 */ s_xyz center; /* 0x6 */ s16 radius; } Sphere; // size = 0x6 typedef struct Triangle { - /* 0x00 */ Vec3f vertices[3]; + /* 0x00 */ xyz_t vertices[3]; } Triangle; // size = 0x24 typedef struct Triangle3 { /* 0x00 */ Triangle unk_00; - /* 0x24 */ Vec3f unk_24; + /* 0x24 */ xyz_t unk_24; /* 0x30 */ f32 unk_30; } Triangle3; // size = 0x34 @@ -24,7 +24,7 @@ typedef struct Pipe { /* 0x0 */ s16 radius; /* 0x2 */ s16 unk_2; /* 0x4 */ s16 yShift; - /* 0x6 */ Vec3s pos; + /* 0x6 */ s_xyz pos; } Pipe; // size = 0xC // void Math3d_normalizeXyz_t(); @@ -62,7 +62,7 @@ typedef struct Pipe { // void func_800DB4E4_jp(); // void func_800DBF5C_jp(); // void func_800DC0C8_jp(); -void Math3DPlane(Vec3f* arg0, Vec3f* arg1, Vec3f* arg2, f32* arg3, f32* arg4, f32* arg5, f32* arg6); +void Math3DPlane(xyz_t* arg0, xyz_t* arg1, xyz_t* arg2, f32* arg3, f32* arg4, f32* arg5, f32* arg6); // void func_800DC268_jp(); // void func_800DC2A8_jp(); // void Math3DLengthPlaneAndPos(); @@ -95,10 +95,10 @@ void Math3DPlane(Vec3f* arg0, Vec3f* arg1, Vec3f* arg2, f32* arg3, f32* arg4, f3 // void func_800DDCAC_jp(); // void Math3D_sphereCrossLineSegment(); // void Math3D_sphereCrossTriangleCalc_cp(); -s32 Math3D_sphereCrossTriangle3_cp(Sphere* sphere, Triangle3* triangle3, Vec3f* arg2); +s32 Math3D_sphereCrossTriangle3_cp(Sphere* sphere, Triangle3* triangle3, xyz_t* arg2); // void func_800DE55C_jp(); // void func_800DE618_jp(); -s32 Math3D_pipeCrossTriangle_cp(Pipe* pipe, Triangle* arg1, Vec3f* arg2); +s32 Math3D_pipeCrossTriangle_cp(Pipe* pipe, Triangle* arg1, xyz_t* arg2); // void func_800DF46C_jp(); // void func_800DF48C_jp(); s32 Math3D_sphereCrossSphere_cl(Sphere* sphere1, Sphere* sphere2, f32* arg2); @@ -115,6 +115,6 @@ s32 Math3D_pipeVsPipe_cl(Pipe* pipe1, Pipe* pipe2, f32* arg2); // void sMath_RotateX(); // void sMath_RotateZ(); -extern Vec3f ZeroVec; +extern xyz_t ZeroVec; #endif diff --git a/include/sys_matrix.h b/include/sys_matrix.h index 21b0e6dc..c33504e7 100644 --- a/include/sys_matrix.h +++ b/include/sys_matrix.h @@ -25,25 +25,25 @@ void Matrix_RotateX(s16 x, MatrixMode mode); void Matrix_RotateY(s16 y, MatrixMode mode); void Matrix_RotateZ(s16 z, MatrixMode mode); void Matrix_rotateXYZ(s16 x, s16 y, s16 z, MatrixMode mode); -void Matrix_softcv3_mult(Vec3f* translation, Vec3s* rot); -void Matrix_softcv3_load(f32 x, f32 y, f32 z, Vec3s* rot); +void Matrix_softcv3_mult(xyz_t* translation, s_xyz* rot); +void Matrix_softcv3_load(f32 x, f32 y, f32 z, s_xyz* rot); Mtx* _MtxF_to_Mtx(MtxF* src, Mtx* dest); Mtx* _Matrix_to_Mtx(Mtx* dest); Mtx* _Matrix_to_Mtx_new(struct GraphicsContext* gfxCtx); void _MtxF_to_Mtx_new(MtxF* src, struct GraphicsContext* gfxCtx); -void Matrix_Position(Vec3f* src, Vec3f* dest); -void Matrix_Position_Zero(Vec3f* dest); -void Matrix_Position_VecX(f32 x, Vec3f* dest); -void Matrix_Position_VecY(f32 y, Vec3f* dest); -void Matrix_Position_VecZ(f32 z, Vec3f* dest); +void Matrix_Position(xyz_t* src, xyz_t* dest); +void Matrix_Position_Zero(xyz_t* dest); +void Matrix_Position_VecX(f32 x, xyz_t* dest); +void Matrix_Position_VecY(f32 y, xyz_t* dest); +void Matrix_Position_VecZ(f32 z, xyz_t* dest); void Matrix_copy_MtxF(MtxF* dest, MtxF* src); void Matrix_MtxtoMtxF(Mtx* src, MtxF* dest); -void Matrix_MtxF_Position2(Vec3f* src, Vec3f* dest, MtxF* mf); +void Matrix_MtxF_Position2(xyz_t* src, xyz_t* dest, MtxF* mf); void Matrix_reverse(MtxF* mf); void Matrix_rotate_scale_exchange(MtxF* mf); -void Matrix_to_rotate_new(MtxF* src, Vec3s* dest, s32 nonUniformScale); -void Matrix_to_rotate2_new(MtxF* src, Vec3s* dest, s32 nonUniformScale); -void Matrix_RotateVector(s16 angle, Vec3f* axis, u8 mode); +void Matrix_to_rotate_new(MtxF* src, s_xyz* dest, s32 nonUniformScale); +void Matrix_to_rotate2_new(MtxF* src, s_xyz* dest, s32 nonUniformScale); +void Matrix_RotateVector(s16 angle, xyz_t* axis, u8 mode); void suMtxMakeTS(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, f32 translateZ); void suMtxMakeSRT(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 rotY, s16 rotZ, f32 translateX, f32 translateY, f32 translateZ); diff --git a/include/z64math.h b/include/z64math.h index 33bab3ac..02deb0c3 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -22,7 +22,7 @@ typedef struct { /* 0x0 */ f32 x; /* 0x4 */ f32 y; /* 0x8 */ f32 z; -} Vec3f; // size = 0xC +} xyz_t; // size = 0xC typedef struct { /* 0x0 */ u16 x; @@ -34,7 +34,7 @@ typedef struct { /* 0x0 */ s16 x; /* 0x2 */ s16 y; /* 0x4 */ s16 z; -} Vec3s; // size = 0x6 +} s_xyz; // size = 0x6 typedef struct { /* 0x0 */ s32 x; diff --git a/linker_scripts/jp/symbol_addrs_code.txt b/linker_scripts/jp/symbol_addrs_code.txt index 149aba0b..5279e012 100644 --- a/linker_scripts/jp/symbol_addrs_code.txt +++ b/linker_scripts/jp/symbol_addrs_code.txt @@ -2883,7 +2883,7 @@ func_800BD4C0_jp = 0x800BD4C0; // type:func _texture_z_light_fog_prim = 0x800BD4E8; // type:func _texture_z_light_fog_prim_shadow = 0x800BD510; // type:func func_800BD538_jp = 0x800BD538; // type:func -func_800BD598_jp = 0x800BD598; // type:func +_texture_z_light_fog_prim_xlu = 0x800BD598; // type:func func_800BD5C0_jp = 0x800BD5C0; // type:func func_800BD5E8_jp = 0x800BD5E8; // type:func func_800BD648_jp = 0x800BD648; // type:func diff --git a/src/code/c_keyframe.c b/src/code/c_keyframe.c index 385de5ef..8af8bd09 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 382d7756..ea4ee9c0 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 4a30e15b..260acead 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 00000000..3c7d927b --- /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 664d53b5..8de578a5 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 2960de86..d816fe21 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 87df0c3b..21b2f5c8 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 a60ac1f1..3075c240 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 ab7d1cf9..05f5a876 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; diff --git a/src/overlays/actors/ovl_Mbg/ac_mbg.c b/src/overlays/actors/ovl_Mbg/ac_mbg.c index 887c65c5..edd96ed8 100644 --- a/src/overlays/actors/ovl_Mbg/ac_mbg.c +++ b/src/overlays/actors/ovl_Mbg/ac_mbg.c @@ -48,7 +48,7 @@ void Mbg_Actor_dt(Actor* thisx, Game_Play* game_play UNUSED) { } void Mbg_Actor_draw(Actor* thisx, Game_Play* game_play) { - Vec3f sp3C; + xyz_t sp3C; s16 sp3A; sp3C = thisx->world.pos; diff --git a/src/overlays/actors/ovl_Mbg/ac_mbg.h b/src/overlays/actors/ovl_Mbg/ac_mbg.h index 50d878b8..1a5afb33 100644 --- a/src/overlays/actors/ovl_Mbg/ac_mbg.h +++ b/src/overlays/actors/ovl_Mbg/ac_mbg.h @@ -14,7 +14,7 @@ typedef struct Mbg { /* 0x000 */ Actor actor; /* 0x174 */ UNK_TYPE1 unk_174[0x28]; /* 0x19C */ s32 unk_19C; - /* 0x1A0 */ Vec3f unk_1A0; + /* 0x1A0 */ xyz_t unk_1A0; /* 0x1AC */ f32 unk_1AC; } Mbg; // size = 0x1B0 diff --git a/src/overlays/actors/ovl_Toudai/ac_toudai.c b/src/overlays/actors/ovl_Toudai/ac_toudai.c index 05270967..4da10938 100644 --- a/src/overlays/actors/ovl_Toudai/ac_toudai.c +++ b/src/overlays/actors/ovl_Toudai/ac_toudai.c @@ -83,7 +83,7 @@ f32 addZ_363[] = { -40.0f, 0.0f }; void aTOU_set_bgOffset(Toudai* this, s32 heightTableIndex) { s32 i; - Vec3f pos; + xyz_t pos; mCoBG_OffsetTable* offsetTable = height_table_361[heightTableIndex]; for (i = 0; i < 2; i++) { @@ -214,7 +214,7 @@ Color_RGBA8 prmcol_520 = { 255, 255, 150, 120 }; #ifdef NON_EQUIVALENT s32 aTOU_actor_draw_after(Game_Play* game_play, SkeletonInfoR* skeletonInfo, s32 jointIndex, Gfx** dlist, - u8* displayBufferFlag, Toudai* arg5, Vec3s* rotation, Vec3f* translation) { + u8* displayBufferFlag, Toudai* arg5, s_xyz* rotation, xyz_t* translation) { s32 type; // sp24 s32 object; // sp20 s32 palette; // sp1C @@ -281,7 +281,7 @@ void aTOU_actor_draw(Actor* thisx, Game_Play* game_play) { gSegments[6] = OS_K0_TO_PHYSICAL(sp68); gSPSegment(gfx++, 0x06, sp68); POLY_OPA_DISP = gfx; - func_800BD598_jp(gfx); + _texture_z_light_fog_prim_xlu(gfx); gfx = POLY_XLU_DISP; gSPSegment(gfx++, 0x08, sp64); diff --git a/src/overlays/actors/ovl_Toudai/ac_toudai.h b/src/overlays/actors/ovl_Toudai/ac_toudai.h index b77b364f..5095c477 100644 --- a/src/overlays/actors/ovl_Toudai/ac_toudai.h +++ b/src/overlays/actors/ovl_Toudai/ac_toudai.h @@ -17,8 +17,8 @@ typedef struct Toudai { /* 0x174 */ s32 unk174; /* 0x178 */ SkeletonInfoR skeletonInfo; /* 0x1E8 */ s32 unk1E8; - /* 0x1EC */ Vec3s jointTable[15]; - /* 0x246 */ Vec3s morphTable[15]; + /* 0x1EC */ s_xyz jointTable[15]; + /* 0x246 */ s_xyz morphTable[15]; /* 0x2A0 */ ToudaiActionFunc unk2A0; /* 0x2A4 */ UNK_TYPE1 unk2A4[0x10]; /* 0x2B4 */ UNK_TYPE unk2B4; diff --git a/yamls/jp/code.yaml b/yamls/jp/code.yaml index 5951d132..79a35883 100644 --- a/yamls/jp/code.yaml +++ b/yamls/jp/code.yaml @@ -45,7 +45,7 @@ - [0x6BA3B0, asm, code/m_item_name] - [0x6BA500, asm, code/6BA500] - [0x6BA930, asm, code/m_kankyo] - - [0x6BD560, asm, code/m_lib] + - [0x6BD560, c, code/m_lib] - [0x6BEE80, c, code/m_lights] - [0x6BFC60, c, code/m_malloc] - [0x6BFE60, c, code/m_mail] @@ -145,7 +145,7 @@ - [0x728430, data, code/728430] - [0x72AAC0, .data, code/m_game_dlftbls] - [0x72ACB0, data, code/72ACB0] - - [0x72B7A0, data, code/m_lib] + - [0x72B7A0, .data, code/m_lib] - [0x72B7D0, .data, code/m_lights] - [0x72B7F0, data, code/72B7F0] - [0x72F610, .data, code/m_npc_schedule] @@ -200,7 +200,7 @@ - [0x73AD50, rodata, code/73AD50] - [0x73AD70, rodata, code/73AD70] - [0x73AD90, rodata, code/m_kankyo] - - [0x73AED0, rodata, code/m_lib] + - [0x73AED0, .rodata, code/m_lib] - [0x73AEE0, .rodata, code/m_lights] - [0x73AEF0, rodata, code/m_msg_main] - [0x73AF40, rodata, code/73AF40]