diff --git a/config/eur/arm9/symbols.txt b/config/eur/arm9/symbols.txt index 5e21f7a0..09cb73a8 100644 --- a/config/eur/arm9/symbols.txt +++ b/config/eur/arm9/symbols.txt @@ -685,12 +685,12 @@ _ZN18UnkStruct_02049b8013func_02013ee8Eii kind:function(arm,size=0x98) addr:0x02 func_02013f80 kind:function(arm,size=0x6c) addr:0x02013f80 func_02013fec kind:function(arm,size=0xc) addr:0x02013fec func_02013ff8 kind:function(arm,size=0x12c) addr:0x02013ff8 -_ZN12TouchControl11UpdateStateEP10TouchStateP15TouchStateFlags kind:function(arm,size=0xb8) addr:0x02014124 +_ZN12TouchControl11UpdateStateEP10TouchStatePK15TouchStateFlags kind:function(arm,size=0xb8) addr:0x02014124 _ZN12TouchControlC1Ev kind:function(thumb,size=0x3c) addr:0x020141dc _ZN12TouchControl13IncreaseSpeedEt kind:function(arm,size=0x18) addr:0x02014218 _ZN12TouchControl11UpdateFlagsEt kind:function(arm,size=0x12c) addr:0x02014230 _ZN12TouchControl20UpdateWithStateFlagsEP15TouchStateFlagst kind:function(arm,size=0x44) addr:0x0201435c -_ZN12TouchControl6UpdateEP10TouchStatet kind:function(arm,size=0x50) addr:0x020143a0 +_ZN12TouchControl6UpdateEPK10TouchStatet kind:function(arm,size=0x50) addr:0x020143a0 _ZN12TouchControl13func_020143f0Ev kind:function(arm,size=0x24) addr:0x020143f0 _ZN12TouchControl13func_02014414Etb kind:function(arm,size=0x64) addr:0x02014414 _ZN12TouchControl13func_02014478EP10TouchStatet kind:function(arm,size=0x28) addr:0x02014478 diff --git a/config/jp/arm9/symbols.txt b/config/jp/arm9/symbols.txt index a0ae58eb..5ce2db83 100644 --- a/config/jp/arm9/symbols.txt +++ b/config/jp/arm9/symbols.txt @@ -685,12 +685,12 @@ _ZN18UnkStruct_02049b8013func_02013ee8Eii kind:function(arm,size=0x98) addr:0x02 func_02013f84 kind:function(arm,size=0x6c) addr:0x02013f84 func_02013ff0 kind:function(arm,size=0xc) addr:0x02013ff0 func_02013ffc kind:function(arm,size=0x12c) addr:0x02013ffc -_ZN12TouchControl11UpdateStateEP10TouchStateP15TouchStateFlags kind:function(arm,size=0xb8) addr:0x02014128 +_ZN12TouchControl11UpdateStateEP10TouchStatePK15TouchStateFlags kind:function(arm,size=0xb8) addr:0x02014128 _ZN12TouchControlC1Ev kind:function(thumb,size=0x3c) addr:0x020141e0 _ZN12TouchControl13IncreaseSpeedEt kind:function(arm,size=0x18) addr:0x0201421c _ZN12TouchControl11UpdateFlagsEt kind:function(arm,size=0x12c) addr:0x02014234 _ZN12TouchControl20UpdateWithStateFlagsEP15TouchStateFlagst kind:function(arm,size=0x44) addr:0x02014360 -_ZN12TouchControl6UpdateEP10TouchStatet kind:function(arm,size=0x50) addr:0x020143a4 +_ZN12TouchControl6UpdateEPK10TouchStatet kind:function(arm,size=0x50) addr:0x020143a4 _ZN12TouchControl13func_020143f0Ev kind:function(arm,size=0x24) addr:0x020143f4 _ZN12TouchControl13func_02014414Etb kind:function(arm,size=0x64) addr:0x02014418 _ZN12TouchControl13func_02014478EP10TouchStatet kind:function(arm,size=0x28) addr:0x0201447c diff --git a/include/Actor/Actor.hpp b/include/Actor/Actor.hpp index e4b28eca..093e6b29 100644 --- a/include/Actor/Actor.hpp +++ b/include/Actor/Actor.hpp @@ -7,9 +7,9 @@ #include "System/SysNew.hpp" #include "flags.h" #include "global.h" +#include "math.hpp" #include "types.h" #include "versions.h" -#include // some functions use thumb mode on the japanese version (only in overlay 40?) #if IS_JP diff --git a/include/FileSelect/FileSelect.hpp b/include/FileSelect/FileSelect.hpp index 16d96c46..374c4181 100644 --- a/include/FileSelect/FileSelect.hpp +++ b/include/FileSelect/FileSelect.hpp @@ -7,9 +7,9 @@ #include "Unknown/UnkSystem1.hpp" #include "global.h" #include "iterator.hpp" +#include "math.hpp" #include "regs.h" #include "types.h" -#include extern const unk16 data_ov019_020d1bb0[]; extern "C" void func_ov001_020bd6a8(); @@ -148,7 +148,7 @@ public: /* 10 */ unk32 mUnk_10; /* 14 */ unk32 mUnk_14; /* 18 */ unk32 mUnk_18; - /* 1C */ VEC2S mUnk_1C; + /* 1C */ Vec2sC mUnk_1C; /* 20 */ volatile unk32 mUnk_20; }; diff --git a/include/FileSelect/FileSelectMain.hpp b/include/FileSelect/FileSelectMain.hpp index 3975bcb6..ab0b9665 100644 --- a/include/FileSelect/FileSelectMain.hpp +++ b/include/FileSelect/FileSelectMain.hpp @@ -6,8 +6,8 @@ #include "Unknown/UnkSystem1.hpp" #include "global.h" #include "iterator.hpp" +#include "math.hpp" #include "types.h" -#include typedef Iterator FileSlotIterator; diff --git a/include/FileSelect/FileSelectMicTest.hpp b/include/FileSelect/FileSelectMicTest.hpp index c0c65613..30550daa 100644 --- a/include/FileSelect/FileSelectMicTest.hpp +++ b/include/FileSelect/FileSelectMicTest.hpp @@ -3,8 +3,8 @@ #include "Game/GameModeManager.hpp" #include "Unknown/Common.hpp" #include "global.h" +#include "math.hpp" #include "types.h" -#include #define MAX_MIC_LEVELS 4 #define MIC_LEVEL_1 0 // green bar diff --git a/include/FileSelect/FileSelectOptionsManager.hpp b/include/FileSelect/FileSelectOptionsManager.hpp index f112ff74..bb1c7c71 100644 --- a/include/FileSelect/FileSelectOptionsManager.hpp +++ b/include/FileSelect/FileSelectOptionsManager.hpp @@ -3,8 +3,8 @@ #include "System/SysNew.hpp" #include "Unknown/Common.hpp" #include "global.h" +#include "math.hpp" #include "types.h" -#include class FileSelectOptions; class FileSelectMicTest; diff --git a/include/FileSelect/UnkSubStruct9.hpp b/include/FileSelect/UnkSubStruct9.hpp index 26cbab52..81cb1d6e 100644 --- a/include/FileSelect/UnkSubStruct9.hpp +++ b/include/FileSelect/UnkSubStruct9.hpp @@ -4,8 +4,8 @@ #include "System/SysNew.hpp" #include "global.h" #include "iterator.hpp" +#include "math.hpp" #include "types.h" -#include // file tab manager? class UnkSubStruct9 : public SysObject { diff --git a/include/Game/GameModeManager.hpp b/include/Game/GameModeManager.hpp index 06aebbfd..56945c13 100644 --- a/include/Game/GameModeManager.hpp +++ b/include/Game/GameModeManager.hpp @@ -4,9 +4,9 @@ #include "Player/TouchControl.hpp" #include "System/SysNew.hpp" #include "Unknown/UnkStruct_02049b18.hpp" +#include "math.hpp" #include "types.h" #include -#include #include class GameModeManagerBase; diff --git a/include/MainGame/MiscAdvManager.hpp b/include/MainGame/MiscAdvManager.hpp index 28537b13..ddd8c6bf 100644 --- a/include/MainGame/MiscAdvManager.hpp +++ b/include/MainGame/MiscAdvManager.hpp @@ -5,7 +5,7 @@ #include "global.h" #include "types.h" -#include +#include "math.hpp" #define MAX_PRICECARDS 99 diff --git a/include/MapObject/MapObject.hpp b/include/MapObject/MapObject.hpp index 014baac3..2473c1d3 100644 --- a/include/MapObject/MapObject.hpp +++ b/include/MapObject/MapObject.hpp @@ -7,8 +7,8 @@ #include "System/SysNew.hpp" #include "flags.h" #include "global.h" +#include "math.hpp" #include "types.h" -#include class MapObjectProfile; diff --git a/include/MapObject/MapObjectManager.hpp b/include/MapObject/MapObjectManager.hpp index f222e5fd..5ffb3946 100644 --- a/include/MapObject/MapObjectManager.hpp +++ b/include/MapObject/MapObjectManager.hpp @@ -4,7 +4,7 @@ #include "Unknown/UnkStruct_ov000_020b34c4.hpp" #include "types.h" -#include +#include "math.hpp" typedef void (*UnkCallback_func_01fff4cc)(void *, void *); diff --git a/include/Physics/Cylinder.hpp b/include/Physics/Cylinder.hpp index 5b9c4d08..3d421a24 100644 --- a/include/Physics/Cylinder.hpp +++ b/include/Physics/Cylinder.hpp @@ -2,7 +2,7 @@ #include "types.h" -#include +#include "math.hpp" struct Cylinder { Vec3p pos; diff --git a/include/Player/Player.hpp b/include/Player/Player.hpp index c2be7f72..d50cdf9a 100644 --- a/include/Player/Player.hpp +++ b/include/Player/Player.hpp @@ -1,7 +1,7 @@ #pragma once +#include "math.hpp" #include "types.h" -#include // incomplete class PlayerActor { diff --git a/include/Player/PlayerGet.hpp b/include/Player/PlayerGet.hpp index 1a2b9be7..6aabb7e3 100644 --- a/include/Player/PlayerGet.hpp +++ b/include/Player/PlayerGet.hpp @@ -7,7 +7,7 @@ #include "Unknown/Common.hpp" #include "Unknown/UnkStruct_027e0ce0.hpp" #include "Unknown/UnkStruct_ov000_0208f820.hpp" -#include +#include "math.hpp" enum GIModel_ { GIModel_None = 0, diff --git a/include/Player/PlayerSceneChange.hpp b/include/Player/PlayerSceneChange.hpp index 1b183df7..816b8fcc 100644 --- a/include/Player/PlayerSceneChange.hpp +++ b/include/Player/PlayerSceneChange.hpp @@ -6,7 +6,7 @@ #include "Unknown/UnkStruct_027e09a4.hpp" #include "Unknown/UnkStruct_ov000_0208f820.hpp" -#include +#include "math.hpp" class PlayerSceneChange : public UnkStruct_ov000_0208f820 { public: diff --git a/include/Player/TouchControl.hpp b/include/Player/TouchControl.hpp index 06664e8c..10dfd585 100644 --- a/include/Player/TouchControl.hpp +++ b/include/Player/TouchControl.hpp @@ -1,7 +1,7 @@ #pragma once +#include "math.hpp" #include "types.h" -#include #include typedef u16 TouchFlags; @@ -35,10 +35,10 @@ public: void IncreaseSpeed(u16 increase); void UpdateFlags(u16 speed); void UpdateWithStateFlags(TouchStateFlags *state, u16 speed); - void Update(TouchState *state, u16 speed); + void Update(const TouchState *state, u16 speed); void func_02014414(u16 speedIncrease, bool shouldIncrease); void func_02014478(TouchState *state, u16 speed); static bool func_020143f0(); - static void UpdateState(TouchState *state, TouchStateFlags *stateFlags); + static void UpdateState(TouchState *state, const TouchStateFlags *stateFlags); }; diff --git a/include/System/Random.hpp b/include/System/Random.hpp index 2c741b89..4d7def70 100644 --- a/include/System/Random.hpp +++ b/include/System/Random.hpp @@ -1,8 +1,8 @@ #pragma once #include "global.h" +#include "math.hpp" #include "types.h" -#include struct Random { /* 00 */ u16 mRandomValue[4]; diff --git a/include/Unknown/Common.hpp b/include/Unknown/Common.hpp index 5ab42579..83155b91 100644 --- a/include/Unknown/Common.hpp +++ b/include/Unknown/Common.hpp @@ -4,9 +4,9 @@ #include "System/SysNew.hpp" #include "Unknown/UnkFileSystem.hpp" #include "global.h" +#include "math.hpp" #include "profile.hpp" #include "types.h" -#include #include extern "C" void func_0201e8d4(void *param1, void *param2); @@ -95,9 +95,9 @@ extern "C" void func_0201e8d4(void *param1, void *param2); } \ \ void UpdatePosition(Vec2s *pOutPos) { \ - Vec2us fetch; \ + Vec2s fetch; \ func_0201e8d4(&fetch, this); \ - Vec2s_SetU(pOutPos, &fetch); \ + Vec2s_Set(&fetch, pOutPos); \ } \ \ void Update(Vec2s *pOutPos) { \ @@ -422,10 +422,10 @@ public: /* 18 */ unk32 mUnk_18; /* 1C */ unk32 mUnk_1C; /* 20 */ unk32 mUnk_20; - /* 24 */ Vec2us mPosOffset; // used to shift the button when selected - /* 28 */ bool mUnk_28; // selected highlight effect when set to true - /* 29 */ bool mUnk_29; // related to having the button selected - /* 2A */ bool mUnk_2A; // disables button action + /* 24 */ Vec2s mPosOffset; // used to shift the button when selected + /* 28 */ bool mUnk_28; // selected highlight effect when set to true + /* 29 */ bool mUnk_29; // related to having the button selected + /* 2A */ bool mUnk_2A; // disables button action /* 2A */ bool mUnk_2B; /* 2C */ bool mUnk_2C; /* 2D */ unk8 mUnk_2D; @@ -811,8 +811,8 @@ public: /* 4C */ unk32 mUnk_4C; /* 50 */ unk32 mUnk_50; /* 54 */ unk32 mUnk_54; - /* 58 */ unk32 mUnk_58; // another timer? - /* 5C */ Vec2us mUnk_5C; // position of the animated texture + /* 58 */ unk32 mUnk_58; // another timer? + /* 5C */ Vec2s mUnk_5C; // position of the animated texture /* 60 */ unk32 mUnk_60; /* 64 */ unk32 mUnk_64; /* 68 */ unk32 mUnk_68; diff --git a/include/Unknown/UnkStruct_027e0998.hpp b/include/Unknown/UnkStruct_027e0998.hpp index b8583da8..7dcf8a8a 100644 --- a/include/Unknown/UnkStruct_027e0998.hpp +++ b/include/Unknown/UnkStruct_027e0998.hpp @@ -1,8 +1,8 @@ #pragma once #include "global.h" +#include "math.hpp" #include "types.h" -#include class UnkStruct_027e0998_Base { public: diff --git a/include/Unknown/UnkStruct_027e09a8.hpp b/include/Unknown/UnkStruct_027e09a8.hpp index e5f3a8a8..67d426b0 100644 --- a/include/Unknown/UnkStruct_027e09a8.hpp +++ b/include/Unknown/UnkStruct_027e09a8.hpp @@ -1,7 +1,7 @@ #pragma once +#include "math.hpp" #include "types.h" -#include class UnkStruct_027e09a8 { public: diff --git a/include/Unknown/UnkStruct_027e09ac.hpp b/include/Unknown/UnkStruct_027e09ac.hpp index 4615c100..da9ef588 100644 --- a/include/Unknown/UnkStruct_027e09ac.hpp +++ b/include/Unknown/UnkStruct_027e09ac.hpp @@ -4,7 +4,7 @@ #include "global.h" #include "types.h" -#include +#include "math.hpp" struct UnkStruct_027e09ac_Base_00 { /* 00 */ unk16 mUnk_00[2]; diff --git a/include/Unknown/UnkStruct_027e0cd8.hpp b/include/Unknown/UnkStruct_027e0cd8.hpp index 0e88c45b..8658f0f8 100644 --- a/include/Unknown/UnkStruct_027e0cd8.hpp +++ b/include/Unknown/UnkStruct_027e0cd8.hpp @@ -1,8 +1,8 @@ #pragma once #include "files.h" +#include "math.hpp" #include "types.h" -#include #include "MapObject/MapObjectManager.hpp" #include "Unknown/UnkStruct_027e09a4.hpp" diff --git a/include/Unknown/UnkStruct_027e0cec.hpp b/include/Unknown/UnkStruct_027e0cec.hpp index d061ee56..7ace678e 100644 --- a/include/Unknown/UnkStruct_027e0cec.hpp +++ b/include/Unknown/UnkStruct_027e0cec.hpp @@ -1,8 +1,8 @@ #pragma once #include "Player/PlayerGet.hpp" +#include "math.hpp" #include "types.h" -#include class UnkStruct_027e0cec { public: diff --git a/include/Unknown/UnkStruct_ov000_0208f820.hpp b/include/Unknown/UnkStruct_ov000_0208f820.hpp index 71963700..3fc7dfcd 100644 --- a/include/Unknown/UnkStruct_ov000_0208f820.hpp +++ b/include/Unknown/UnkStruct_ov000_0208f820.hpp @@ -5,7 +5,7 @@ #include "Item/ItemManager.hpp" #include "System/SysNew.hpp" -#include +#include "math.hpp" class UnkStruct_ov000_0208f820_14 { public: diff --git a/include/math.hpp b/include/math.hpp new file mode 100644 index 00000000..a67c541b --- /dev/null +++ b/include/math.hpp @@ -0,0 +1,263 @@ +#pragma once + +#include + +extern "C" { +//! TODO: find a way to remove that +typedef union Vec2sC { + struct { + /* 0 */ s16 x; + /* 2 */ s16 y; + /* 4 */ + }; + s16 coords[2]; +} Vec2sC; +} + +union Vec2s { + struct { + /* 0 */ s16 x; + /* 2 */ s16 y; + /* 4 */ + }; + s16 coords[2]; + + void operator=(const Vec2s &from) { + this->x = from.x; + this->y = from.y; + } + + Vec2s() {} + Vec2s(s16 X, s16 Y) { + x = X; + y = Y; + } +}; + +#define Vec2s_CopyAdd(a, b, dst) Vec2_CopyAdd(Vec2s, a, b, dst) +#define Vec2s_CopySub(a, b, dst) Vec2_CopySub(Vec2s, a, b, dst) +#define Vec2s_Set(a, dst) Vec2_Set(a, dst) + +static inline void Vec2s_Clear(Vec2s *dst) { + Vec2s empty; + empty.x = 0; + empty.y = 0; + +#if __MWERKS__ + dst->coords = empty.coords; +#else + dst->x = empty.x; + dst->y = empty.y; +#endif +} + +static inline void Vec2s_Add(const Vec2s *a, const Vec2s *b, Vec2s *dst) { + s16 x = a->x + b->x; + s16 y = a->y + b->y; + + dst->x = x; + dst->y = y; +} + +static inline void Vec2s_Sub(const Vec2s *a, const Vec2s *b, Vec2s *dst) { + s16 x = a->x - b->x; + s16 y = a->y - b->y; + + dst->x = x; + dst->y = y; +} + +static inline void Vec2s_Copy(const Vec2s *a, Vec2s *dst) { +#if __MWERKS__ + dst->coords = a->coords; +#else + dst->x = a->x; + dst->y = a->y; +#endif +} + +union Vec2us { + struct { + /* 0 */ u16 x; + /* 2 */ u16 y; + /* 4 */ + }; + u16 coords[2]; + + void operator=(const Vec2us &from) { + this->x = from.x; + this->y = from.y; + } + + Vec2us() {} + Vec2us(u16 X, u16 Y) { + x = X; + y = Y; + } +}; + +#define Vec2us_CopyAdd(a, b, dst) Vec2_CopyAdd(Vec2us, a, b, dst) +#define Vec2us_CopySub(a, b, dst) Vec2_CopySub(Vec2us, a, b, dst) +#define Vec2us_Set(a, dst) Vec2_Set(a, dst) + +static inline void Vec2us_Clear(Vec2us *dst) { + Vec2us empty; + empty.x = 0; + empty.y = 0; + +#if __MWERKS__ + dst->coords = empty.coords; +#else + dst->x = empty.x; + dst->y = empty.y; +#endif +} + +static inline void Vec2us_Add(const Vec2us *a, const Vec2us *b, Vec2us *dst) { + u16 x = a->x + b->x; + u16 y = a->y + b->y; + + dst->x = x; + dst->y = y; +} + +static inline void Vec2us_Sub(const Vec2us *a, const Vec2us *b, Vec2us *dst) { + u16 x = a->x - b->x; + u16 y = a->y - b->y; + + dst->x = x; + dst->y = y; +} + +static inline void Vec2us_Copy(const Vec2us *a, Vec2us *dst) { +#if __MWERKS__ + dst->coords = a->coords; +#else + dst->x = a->x; + dst->y = a->y; +#endif +} + +union Vec2b { + struct { + /* 0 */ u8 x; + /* 2 */ u8 y; + /* 4 */ + }; + u8 coords[2]; + + void operator=(const Vec2b &from) { + this->x = from.x; + this->y = from.y; + } + + Vec2b() {} + Vec2b(u8 X, u8 Y) { + x = X; + y = Y; + } +}; + +#define Vec2b_CopyAdd(a, b, dst) Vec2_CopyAdd(Vec2b, a, b, dst) +#define Vec2b_CopySub(a, b, dst) Vec2_CopySub(Vec2b, a, b, dst) +#define Vec2b_Set(a, dst) Vec2_Set(a, dst) + +static inline void Vec2b_Clear(Vec2b *dst) { + Vec2b empty; + empty.x = 0; + empty.y = 0; + +#if __MWERKS__ + dst->coords = empty.coords; +#else + dst->x = empty.x; + dst->y = empty.y; +#endif +} + +static inline void Vec2b_Add(const Vec2b *a, const Vec2b *b, Vec2b *dst) { + u8 x = a->x + b->x; + u8 y = a->y + b->y; + + dst->x = x; + dst->y = y; +} + +static inline void Vec2b_Sub(const Vec2b *a, const Vec2b *b, Vec2b *dst) { + u8 x = a->x - b->x; + u8 y = a->y - b->y; + + dst->x = x; + dst->y = y; +} + +static inline void Vec2b_Copy(const Vec2b *a, Vec2b *dst) { +#if __MWERKS__ + dst->coords = a->coords; +#else + dst->x = a->x; + dst->y = a->y; +#endif +} + +union Vec2pCpp { + struct { + /* 0 */ q20 x; + /* 4 */ q20 y; + /* 8 */ + }; + q20 coords[2]; + + void operator=(const Vec2pCpp &from) { + this->x = from.x; + this->y = from.y; + } + + Vec2pCpp() {} + Vec2pCpp(q20 X, q20 Y) { + x = X; + y = Y; + } +}; + +#define Vec2pCpp_CopyAdd(a, b, dst) Vec2_CopyAdd(Vec2pCpp, a, b, dst) +#define Vec2pCpp_CopySub(a, b, dst) Vec2_CopySub(Vec2pCpp, a, b, dst) +#define Vec2pCpp_Set(a, dst) Vec2_Set(a, dst) + +static inline void Vec2pCpp_Clear(Vec2pCpp *dst) { + Vec2pCpp empty; + empty.x = 0; + empty.y = 0; + +#if __MWERKS__ + dst->coords = empty.coords; +#else + dst->x = empty.x; + dst->y = empty.y; +#endif +} + +static inline void Vec2pCpp_Add(const Vec2pCpp *a, const Vec2pCpp *b, Vec2pCpp *dst) { + q20 x = a->x + b->x; + q20 y = a->y + b->y; + + dst->x = x; + dst->y = y; +} + +static inline void Vec2pCpp_Sub(const Vec2pCpp *a, const Vec2pCpp *b, Vec2pCpp *dst) { + q20 x = a->x - b->x; + q20 y = a->y - b->y; + + dst->x = x; + dst->y = y; +} + +static inline void Vec2pCpp_Copy(const Vec2pCpp *a, Vec2pCpp *dst) { +#if __MWERKS__ + dst->coords = a->coords; +#else + dst->x = a->x; + dst->y = a->y; +#endif +} diff --git a/libs/nitro/include/nitro/math.h b/libs/nitro/include/nitro/math.h index f6724728..a7cbbe24 100644 --- a/libs/nitro/include/nitro/math.h +++ b/libs/nitro/include/nitro/math.h @@ -4,6 +4,30 @@ #include "global.h" #include "types.h" +#define Vec2_Set(a, dst) \ + { \ + (dst)->coords = (a)->coords; \ + } \ + ((void) 0) + +#define Vec2_CopyAdd(type, a, b, dst) \ + { \ + type temp; \ + temp.x = (a)->x + (b)->x; \ + temp.y = (a)->y + (b)->y; \ + Vec2_Set(&temp, dst); \ + } \ + ((void) 0) + +#define Vec2_CopySub(type, a, b, dst) \ + { \ + type temp; \ + temp.x = (a)->x - (b)->x; \ + temp.y = (a)->y - (b)->y; \ + Vec2_Set(&temp, dst); \ + } \ + ((void) 0) + #ifdef __cplusplus extern "C" { #endif @@ -32,115 +56,31 @@ typedef s16 q4; #define SIN2(table, n) ((table)[2 * ((n) >> 4)]) #define COS2(table, n) ((table)[2 * ((n) >> 4) + 1]) -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -union Vec2b { - struct { - /* 0 */ u8 x; - /* 1 */ u8 y; - /* 2 */ - }; - u8 coords[2]; - - void operator=(const Vec2b &from) { - this->x = from.x; - this->y = from.y; - } - - Vec2b() {} - Vec2b(u8 X, u8 Y) { - x = X; - y = Y; - } -}; - -struct Vec2s { - /* 0 */ s16 x; - /* 2 */ s16 y; - /* 4 */ - - void operator=(const Vec2s &from) { - this->x = from.x; - this->y = from.y; - } - - Vec2s() {} - Vec2s(s16 X, s16 Y) { - x = X; - y = Y; - } -}; - -struct Vec2us { - /* 0 */ u16 x; - /* 2 */ u16 y; - /* 4 */ - - void operator=(const Vec2us &from) { - this->x = from.x; - this->y = from.y; - } - - Vec2us() {} - Vec2us(u16 X, u16 Y) { - x = X; - y = Y; - } -}; - -union Vec2p { +typedef union Vec2p { struct { /* 0 */ q20 x; /* 4 */ q20 y; /* 8 */ }; q20 coords[2]; +} Vec2p; - void operator=(const Vec2p &from) { - this->x = from.x; - this->y = from.y; - } +#define Vec2p_Add(a, b, dst) Vec2_Add(Vec2p, a, b, dst) +#define Vec2p_Sub(a, b, dst) Vec2_Sub(Vec2p, a, b, dst) +#define Vec2p_Set(a, dst) Vec2_Set(Vec2p, a, dst) +#define Vec2p_Clear(dst) Vec2_Clear(q20, dst) - Vec2p() {} - Vec2p(q20 X, q20 Y) { - x = X; - y = Y; - } -}; - -union Vec3p { +typedef union Vec3p { struct { - q20 x; - q20 y; - q20 z; + /* 0 */ q20 x; + /* 4 */ q20 y; + /* 8 */ q20 z; + /* C */ }; q20 coords[3]; +} Vec3p; - void operator=(const Vec3p &from) { - this->x = from.x; - this->y = from.y; - this->z = from.z; - } - - Vec3p() {} - Vec3p(Vec3p &from) { - #if __MWERKS__ - this->coords = from.coords; - #else - *this = from; - #endif - } - Vec3p(q20 X, q20 Y, q20 Z) { - x = X; - y = Y; - z = Z; - } -}; - -union Vec4p { +typedef union Vec4p { struct { /* 00 */ q20 x; /* 04 */ q20 y; @@ -149,133 +89,6 @@ union Vec4p { /* 10 */ }; q20 coords[4]; - - void operator=(const Vec4p &from) { - this->x = from.x; - this->y = from.y; - this->z = from.z; - this->w = from.w; - } - - Vec4p() {} - Vec4p(q20 X, q20 Y, q20 Z, q20 W) { - x = X; - y = Y; - z = Z; - w = W; - } -}; - -struct Mat2p { - /* 00 */ Vec2p xColumn; - /* 08 */ Vec2p yColumn; - /* 10 */ - - Mat2p() {} - Mat2p(Vec2p X, Vec2p Y) { - xColumn = X; - yColumn = Y; - } -}; - -struct Mat3p { - /* 00 */ Vec3p xColumn; - /* 0C */ Vec3p yColumn; - /* 18 */ Vec3p zColumn; - /* 24 */ - - Mat3p() {} - Mat3p(Vec3p X, Vec3p Y, Vec3p Z) { - xColumn = X; - yColumn = Y; - zColumn = Z; - } -}; - -struct Mat4x3p { - /* 00 */ Vec3p xColumn; - /* 0C */ Vec3p yColumn; - /* 18 */ Vec3p zColumn; - /* 24 */ Vec3p wColumn; - /* 30 */ - - Mat4x3p() {} - Mat4x3p(Vec3p X, Vec3p Y, Vec3p Z, Vec3p W) { - xColumn = X; - yColumn = Y; - zColumn = Z; - wColumn = W; - } -}; - -struct Mat4p { - /* 00 */ Vec4p xColumn; - /* 10 */ Vec4p yColumn; - /* 20 */ Vec4p zColumn; - /* 30 */ Vec4p wColumn; - /* 40 */ - - Mat4p() {} - Mat4p(Vec4p X, Vec4p Y, Vec4p Z, Vec4p W) { - xColumn = X; - yColumn = Y; - zColumn = Z; - wColumn = W; - } -}; - -extern "C" static inline void Vec2s_Clear(Vec2s *pVec) { - s16 x = 0, y = 0; - - pVec->x = *(s16 *) &x; - pVec->y = *(s16 *) &y; -} - -extern "C" static inline void Vec2s_SetU(Vec2s *dest, Vec2us *src) { - u16 x = src->x; - u16 y = src->y; - - // clear current data - dest->x = 0; - dest->y = 0; - - // set new data - dest->x = x; - dest->y = y; -} -extern "C" { -#else -typedef struct Vec2b { - /* 0 */ u8 x; - /* 1 */ u8 y; - /* 2 */ -} Vec2b; - -typedef struct Vec2us { - /* 0 */ u16 x; - /* 2 */ u16 y; - /* 4 */ -} Vec2us; - -typedef struct Vec2p { - /* 0 */ q20 x; - /* 4 */ q20 y; - /* 8 */ -} Vec2p; - -typedef struct Vec3p { - /* 0 */ q20 x; - /* 4 */ q20 y; - /* 8 */ q20 z; - /* C */ -} Vec3p; - -typedef struct Vec4p { - /* 00 */ q20 x; - /* 04 */ q20 y; - /* 08 */ q20 z; - /* 0C */ q20 w; - /* 10 */ } Vec4p; typedef struct Mat2p { @@ -306,18 +119,6 @@ typedef struct Mat4p { /* 30 */ Vec4p wColumn; /* 40 */ } Mat4p; -#endif - -#ifdef __cplusplus -} -extern "C" { -#endif - -typedef struct VEC2S { - /* 0 */ s16 x; - /* 1 */ s16 y; - /* 2 */ -} VEC2S; u32 func_01ff9f3c(s32 a, s32 b); s32 Atan2(s32 x, s32 y); @@ -357,14 +158,14 @@ q20 Vec3p_DistanceSquared(Vec3p *a, Vec3p *b); void Vec3p_Scale(Vec3p *vec, q20 scale); bool Vec3p_CalculateNormal(Vec3p *vec, Vec3p *a, Vec3p *b, Vec3p *c); -inline void Vec3p_Rotate(Vec3p *vec, q20 sin, q20 cos, Vec3p *out) { +static inline void Vec3p_Rotate(Vec3p *vec, q20 sin, q20 cos, Vec3p *out) { out->x += MUL_Q20(vec->z, sin); out->z += MUL_Q20(vec->z, cos); out->x += MUL_Q20(vec->x, cos); out->z += MUL_Q20(vec->x, -sin); } -inline void Vec3p_CopyXZ(Vec3p *vec, Vec3p *out) { +static inline void Vec3p_CopyXZ(Vec3p *vec, Vec3p *out) { q20 z = vec->z; q20 x = vec->x; @@ -373,12 +174,18 @@ inline void Vec3p_CopyXZ(Vec3p *vec, Vec3p *out) { out->z = z; } -inline void Vec3p_Copy(Vec3p *vec, Vec3p *out) { +static inline void Vec3p_Copy(Vec3p *vec, Vec3p *out) { out->x = vec->x; out->y = vec->y; out->z = vec->z; } +static inline void Vec3p_Init(q20 x, q20 y, q20 z, Vec3p *dst) { + dst->x = x; + dst->y = y; + dst->z = z; +} + void Mat2p_InitIdentity(Mat2p *m); void Mat2p_InitRotation(Mat2p *m, q20 sin, q20 cos); void Mat2p_Multiply(Mat2p *a, Mat2p *b, Mat2p *out); diff --git a/libs/nitro/include/nitro/touch.h b/libs/nitro/include/nitro/touch.h index 4f508c19..bb511da3 100644 --- a/libs/nitro/include/nitro/touch.h +++ b/libs/nitro/include/nitro/touch.h @@ -9,7 +9,9 @@ extern "C" { #endif typedef struct TouchStateFlags { - /* 00 */ Vec2us touchPos; + /* 00 */ struct { + u16 x, y; + } touchPos; /* 04 */ u16 touch; /* 06 */ u16 flags; } TouchStateFlags; // size = 0x08 @@ -17,15 +19,11 @@ typedef struct TouchStateFlags { typedef struct TouchState { /* 00 */ bool touch; /* 01 */ bool unk_01; - /* 02 */ Vec2s touchPos; + /* 02 */ struct { + s16 x, y; + } touchPos; } TouchState; // size = 0x06 -typedef struct TouchStateU { - /* 00 */ bool touch; - /* 01 */ bool unk_01; - /* 02 */ Vec2us touchPos; -} TouchStateU; // size = 0x06 - void WaitForTouchUpdate(u16 param1); bool TP_GetTouchStateFlags(TouchStateFlags *pState); diff --git a/src/000_Second/Actor/Actor.cpp b/src/000_Second/Actor/Actor.cpp index 716e534b..af46a932 100644 --- a/src/000_Second/Actor/Actor.cpp +++ b/src/000_Second/Actor/Actor.cpp @@ -22,9 +22,9 @@ ARM Actor::Actor() { this->mRef.Reset(); this->mpProfile = NULL; _MI_CpuCopy(&data_ov000_020b539c_eur.mUnk_00, &this->mUnk_5C, sizeof(ActorParams)); - this->mPos = this->mUnk_5C.mInitialPos; - this->mPrevPos = this->mUnk_5C.mInitialPos; - this->mAngle = this->mUnk_5C.mInitialAngle; + Vec3p_Copy(&this->mUnk_5C.mInitialPos, &this->mPos); + Vec3p_Copy(&this->mUnk_5C.mInitialPos, &this->mPrevPos); + this->mAngle = this->mUnk_5C.mInitialAngle; SET_FLAGS(this->mFlags, ActorFlag_Alive, ActorFlag_Visible, ActorFlag_Active, ActorFlag_14); this->mUnk_44 = 0xFF; this->mUnk_46 = 0; diff --git a/src/000_Second/MapObject/MapObjectMiniBlocks.cpp b/src/000_Second/MapObject/MapObjectMiniBlocks.cpp index f06819ee..8d3d3db0 100644 --- a/src/000_Second/MapObject/MapObjectMiniBlocks.cpp +++ b/src/000_Second/MapObject/MapObjectMiniBlocks.cpp @@ -29,7 +29,6 @@ ARM MapObjectProfileMiniBlocks::MapObjectProfileMiniBlocks() : this->mUnk_1E &= ~0x01; } -// https://decomp.me/scratch/euvAz ARM MapObjectMiniBlocks::MapObjectMiniBlocks() { this->mUnk_48 = 1; } @@ -45,7 +44,10 @@ ARM bool MapObjectMiniBlocks::vfunc_00(void) { this->mPos.y = pUnkStruct_027e0cd8_0c->func_01ffedf4(&vec); } - Vec3p vec(FLOAT_TO_Q20(0.0f), FLOAT_TO_Q20(0.0f), FLOAT_TO_Q20(0.0f)); + Vec3p vec; + vec.x = FLOAT_TO_Q20(0.0f); + vec.y = FLOAT_TO_Q20(0.0f); + vec.z = FLOAT_TO_Q20(0.0f); uVar6 = 0; switch (this->mUnk_20.mUnk_00[0]) { diff --git a/src/019_MainSelect/FileSelectMain.cpp b/src/019_MainSelect/FileSelectMain.cpp index b5684462..80117dce 100644 --- a/src/019_MainSelect/FileSelectMain.cpp +++ b/src/019_MainSelect/FileSelectMain.cpp @@ -237,7 +237,7 @@ ARM void FileSelectMain::func_ov019_020c6d10() { ARM void FileSelectMain::func_ov019_020c6d48() { Vec2us auStack_2c; - volatile Vec2p local_34; + volatile Vec2pCpp local_34; int value; this->func_ov019_020c6c14(); @@ -255,7 +255,7 @@ ARM void FileSelectMain::func_ov019_020c6d48() { value = 0; } - this->mUnk_03E8[i].func_ov000_02064080(&auStack_2c, (Vec3p *) &local_34, + this->mUnk_03E8[i].func_ov000_02064080(&auStack_2c, (Vec2p *) &local_34, UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_02, value); } @@ -277,52 +277,62 @@ ARM void FileSelectMain::func_ov019_020c6e14() { // non-matching ARM void FileSelectMain::func_ov019_020c6e3c() { - Vec2s local_40; - Vec2s local_58; - Vec2p auStack_50[2]; - Vec2s local_44; - Vec2us auStack_60[2]; // c e - Vec2us local_64; // 4 6 - int fileIndex; + u16 var_r4; + int var_r5; + s32 var_r7; + s32 var_r8; + s32 var_r9; - fileIndex = this->mSaveSlotIndex == 0; - - int unaff_r9; - u16 unaff_r4; - int unaff_r7; - - if (this->mState == FileSelectState_SlotSelectToFileManager) { - unaff_r4 = 0; - UnkStruct_ov019_020d24c8_28_258 local_3c(0x8A, 0x05); - - local_40.x = local_3c.mPosU.x; - local_40.y = local_3c.mPosU.y; - - unaff_r9 = 10; - func_ov000_02062e44(auStack_50, &this->GetUnk03E0(fileIndex).mUnk_004); - func_ov000_02062e44(&local_58, &this->GetUnk03E0(fileIndex).mUnk_004); - local_44.x = local_58.x + data_ov019_020d24c0.mUnk_00.x; - local_44.y = local_58.y + data_ov019_020d24c0.mUnk_00.y; - unaff_r7 = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_0C; - } else if (this->mState == FileSelectState_SlotSelectFromFileManager) { - func_ov000_02062e44(auStack_60 + 1, &this->GetUnk03E0(mSaveSlotIndex).mUnk_004); - local_40.x = auStack_60[1].x; - local_40.y = auStack_60[1].y; - - func_ov000_02062e44(auStack_60, &this->GetUnk03E0(fileIndex).mUnk_004); - func_ov000_02062e44(&local_64, &this->GetUnk03E0(fileIndex).mUnk_004); - local_44.x = local_64.x; - local_44.y = local_64.y; - - unaff_r9 = 0; - unaff_r4 = 10; - unaff_r7 = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_20; + var_r5 = 1; + if (this->mSaveSlotIndex != 0) { + var_r5 = 0; } - this->mUnk_03E8[this->mSaveSlotIndex].func_ov000_0206415c(&local_40, 0, 0xf, unaff_r9); - auStack_50[1].x = unaff_r7; - this->mUnk_03E8[fileIndex].func_ov000_02064080(&local_44, auStack_50 + 1, - UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_02, unaff_r4); + Vec2s sp28; + Vec2s sp24; + unk32 sp1C[2]; + Vec2s sp18; + Vec2s temp; // sp14 + Vec2s sp10; + Vec2s spC; + Vec2s sp8; + Vec2s sp4; + + if (this->mState == FileSelectState_SlotSelectToFileManager) { + UnkStruct_ov019_020d24c8_28_258 sp2C(0x8A, 0x05); + + sp28.coords = sp2C.mPos.coords; + var_r9 = 0x0A; + + func_ov000_02062e44(&sp18, &this->GetUnk03E0(var_r5).mUnk_004); + func_ov000_02062e44(&sp10, &this->GetUnk03E0(var_r5).mUnk_004); + + //! TODO: use Vec2s_CopyAdd + temp.x = (&sp10)->x + (&data_ov019_020d24c0.mUnk_00)->x; + temp.y = (&sp10)->y + (&data_ov019_020d24c0.mUnk_00)->y; + var_r7 = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_18; + (&sp24)->coords = temp.coords; + var_r8 = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_14; + var_r4 = 0; + } else if (this->mState == FileSelectState_SlotSelectFromFileManager) { + func_ov000_02062e44(&spC, &this->GetUnk03E0(this->mSaveSlotIndex).mUnk_004); + + sp28.coords = spC.coords; + var_r9 = 0x00; + + func_ov000_02062e44(&sp8, &this->GetUnk03E0(var_r5).mUnk_004); + func_ov000_02062e44(&sp4, &this->GetUnk03E0(var_r5).mUnk_004); + sp4.coords = sp24.coords; + + var_r7 = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_20; + var_r8 = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_0C; + var_r4 = 0x0A; + } + + this->mUnk_03E8[this->mSaveSlotIndex].func_ov000_0206415c(&sp28, 0, 0x0F, var_r9); + sp1C[0] = var_r7; + sp1C[1] = var_r8; + this->mUnk_03E8[var_r5].func_ov000_02064080(&sp24, &sp1C, UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_02, var_r4); } ARM void FileSelectMain::func_ov019_020c7000() { @@ -834,30 +844,29 @@ ARM void FileSelectMain::func_ov019_020c7a44() { Vec2s local_50; Vec2s local_44; Vec2s local_4c; - Vec2us local_28; - Vec2us local_2c; + Vec2s local_28; + Vec2s local_2c; Vec2p local_3c; Vec2p local_34; Vec2p unaff_r5; Vec2p unaff_r11; - // Vec2p local_34; int fileIndex = this->mSaveSlotIndex == 0; u16 value1; u16 value2; if (this->mState == FileSelectState_SlotSelectToNewFile) { func_ov000_02062e44(&local_44, &this->GetUnk03E0().mUnk_004); - unaff_r11.x = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_0C; - unaff_r11.y = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_20; - local_28.x = local_44.x + data_ov019_020d1e70.mUnk_20.x; - local_28.y = local_44.y + data_ov019_020d1e70.mUnk_20.y; + Vec2s_CopyAdd(&local_44, &data_ov019_020d1e70.mUnk_20, &local_28); + + unaff_r11.x = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_14; + unaff_r11.y = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_18; value1 = 0x0F; func_ov000_02062e44(&local_4c, &this->GetUnk03E0(fileIndex).mUnk_004); - unaff_r5.x = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_0C; - unaff_r5.y = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_20; - local_2c.x = local_4c.x + data_ov019_020d24c0.mUnk_04.x; - local_2c.y = local_4c.y + data_ov019_020d24c0.mUnk_04.y; + Vec2s_CopyAdd(&local_4c, &data_ov019_020d1e70.mUnk_04, &local_2c); + + unaff_r5.x = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_14; + unaff_r5.y = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_18; value2 = 0; this->mUnk_039C.mUnk_0A = 1; @@ -870,17 +879,17 @@ ARM void FileSelectMain::func_ov019_020c7a44() { } } else if (this->mState == FileSelectState_NewFileToSlotSelect) { func_ov000_02062e44(&local_50, &this->GetUnk03E0().mUnk_004); - unaff_r11.x = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_0C; - unaff_r11.y = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_20; - local_28.x = local_50.x; - local_28.y = local_50.y; + local_28.coords = local_50.coords; + + unaff_r11.x = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_14; + unaff_r11.y = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_18; value1 = 0; func_ov000_02062e44(&local_54, &this->GetUnk03E0(fileIndex).mUnk_004); - unaff_r5.x = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_0C; - unaff_r5.y = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_20; - local_2c.x = local_54.x; - local_2c.y = local_54.y; + local_2c.coords = local_54.coords; + + unaff_r5.x = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_14; + unaff_r5.y = UnkStruct_ov019_020d1e70::data_ov019_020d1e4c.mUnk_18; value2 = 0x0F; this->mUnk_039C.mUnk_0A = 1; @@ -1263,24 +1272,34 @@ ARM void FileSelectMain::func_ov019_020c92dc() { } this->mUnk_00BC.Update(&this->mUnk_005C.mPos); - this->mUnk_1078.Update(&this->mUnk_0DA4.mPos); + UnkStruct_ov019_020d24c8_28_258 local_30(0x8B, 0x06); Vec2s local_5c; Vec2s local_58; func_ov000_02062e44(&local_5c, &this->mUnk_0DA4); - func_0201e8d4(&local_58, &this->mUnk_1100); - this->mUnk_1144.mUnk_5C.x = local_58.x + local_30.mPos.x - local_5c.x; - this->mUnk_1144.mUnk_5C.y = local_58.y + local_30.mPos.y - local_5c.y; + func_0201e8d4(&local_58, &this->mUnk_1078); + + { + s16 temp_x = local_58.x + local_30.mPos.x; + s16 temp_y = local_58.y + local_30.mPos.y; + this->mUnk_1144.mUnk_5C.x = temp_x - local_5c.x; + this->mUnk_1144.mUnk_5C.y = temp_y - local_5c.y; + } this->mUnk_1490.Update(&this->mUnk_11BC.mPos); UnkStruct_ov019_020d24c8_28_258 local_48(0x8B, 0x06); Vec2s local_60; Vec2s local_64; func_ov000_02062e44(&local_60, &this->mUnk_0DA4); - func_0201e8d4(&local_64, &this->mUnk_1100); - this->mUnk_1144.mUnk_5C.x = local_64.x + local_48.mPos.x - local_60.x; - this->mUnk_1144.mUnk_5C.y = local_64.y + local_48.mPos.y - local_60.y; + func_0201e8d4(&local_64, &this->mUnk_1490); + + { + s16 temp_x = local_64.x + local_48.mPos.x; + s16 temp_y = local_64.y + local_48.mPos.y; + this->mUnk_1144.mUnk_5C.x = temp_x - local_60.x; + this->mUnk_1144.mUnk_5C.y = temp_y - local_60.y; + } this->mUnk_18A8.Update(&this->mUnk_15D4.mPos); this->mUnk_1BC0.Update(&this->mUnk_18EC.mPos); @@ -1558,8 +1577,8 @@ ARM void FileSelectMain::func_ov019_020cb324() { Vec2s local_34; Vec2s local_30; stack_struct auStack_24; - volatile Vec2s sStack_1c; - volatile Vec2s sStack_18; + Vec2s sStack_1c; + Vec2s sStack_18; this->mUnk_0160.func_ov000_02062f30(); this->GetUnk03E0().func_ov019_020cbc0c(); @@ -1571,15 +1590,13 @@ ARM void FileSelectMain::func_ov019_020cb324() { sStack_18.x = 0; sStack_18.y = 0; if (this->mUnk_0DA4.mUnk_28) { - sStack_18.x = this->mUnk_0DA4.mPosOffset.x; - sStack_18.y = this->mUnk_0DA4.mPosOffset.y; + sStack_18.coords = this->mUnk_0DA4.mPosOffset.coords; } sStack_1c.x = 0; sStack_1c.y = 0; if (this->mUnk_11BC.mUnk_28) { - sStack_1c.x = this->mUnk_11BC.mPosOffset.x; - sStack_1c.y = this->mUnk_11BC.mPosOffset.y; + sStack_1c.coords = this->mUnk_11BC.mPosOffset.coords; } auStack_24.mUnk_06 = 0; @@ -1587,15 +1604,17 @@ ARM void FileSelectMain::func_ov019_020cb324() { auStack_24.mUnk_05 = -1; auStack_24.mUnk_06 |= 0x04; - local_30.x = this->mUnk_1144.mUnk_5C.x + sStack_18.x; - local_30.y = this->mUnk_1144.mUnk_5C.y + sStack_18.y; + s16 temp_x1 = this->mUnk_1144.mUnk_5C.x + sStack_18.x; + s16 temp_y1 = this->mUnk_1144.mUnk_5C.y + sStack_18.y; + local_30.x = temp_x1; + local_30.y = temp_y1; data_0204af1c.func_0201aad0(&this->mUnk_1144, (void *) &local_30, 0, &auStack_24); - // data_0204af1c.func_0201aad0(&this->mUnk_1144,&local_30,0, 0); - local_34.x = this->mUnk_155C.mUnk_5C.x + sStack_1c.x; - local_34.y = this->mUnk_155C.mUnk_5C.y + sStack_1c.y; + s16 temp_x2 = this->mUnk_155C.mUnk_5C.x + sStack_1c.x; + s16 temp_y2 = this->mUnk_155C.mUnk_5C.y + sStack_1c.y; + local_34.x = temp_x2; + local_34.y = temp_y2; data_0204af1c.func_0201aad0(&this->mUnk_155C, (void *) &local_34, 0, &auStack_24); - // data_0204af1c.func_0201aad0(&this->mUnk_155C,&local_34,0, 0); } ARM void FileSelectMain::func_ov019_020cb4bc() { diff --git a/src/019_MainSelect/FileSelectMicTest.cpp b/src/019_MainSelect/FileSelectMicTest.cpp index b661d458..ed301f88 100644 --- a/src/019_MainSelect/FileSelectMicTest.cpp +++ b/src/019_MainSelect/FileSelectMicTest.cpp @@ -60,17 +60,13 @@ ARM FileSelectMicTest::FileSelectMicTest() : this->mUnk_3F8.mUnk_14E = 1; this->mUnk_3F8.func_0201f730(BMG_ID(BMGGroup_select, 0x43)); - volatile Vec2us result; + Vec2s temp; Vec2s fetch; - Vec2s *pFetch = (Vec2s *) &fetch; // yes the cast is required because why not after all... - - func_ov000_02062e44(pFetch, &this->mUnk_304.mUnk_044); - - result.x = pFetch->x + data_ov019_020d2248.mUnk_02.x; - result.y = pFetch->y + data_ov019_020d2248.mUnk_02.y; - - this->mUnk_304.mUnk_044.mPos.x = result.x; - this->mUnk_304.mUnk_044.mPos.y = result.y; + func_ov000_02062e44(&fetch, &this->mUnk_304.mUnk_044); + Vec2s *pFetch = (Vec2s *) &fetch; // yes the cast is required because why not after all... + temp.x = (pFetch)->x + (&data_ov019_020d2248.mUnk_02)->x; + temp.y = (pFetch)->y + (&data_ov019_020d2248.mUnk_02)->y; + this->mUnk_304.mUnk_044.mPos.coords = temp.coords; this->func_ov019_020cea74(); } @@ -94,9 +90,9 @@ ARM void FileSelectMicTest::func_ov019_020ceaac() { Vec2s local_38; local_34.x = data_ov019_020d2248.mUnk_10.x; - local_38.x = 0; - local_34.y = data_ov019_020d2248.mUnk_10.y; + + local_38.x = 0; local_38.y = 0; this->mUnk_304.func_0201e874(0x0C, (void *) &local_34, (void *) &local_38, 0); @@ -113,7 +109,7 @@ ARM void FileSelectMicTest::func_ov019_020ceaac() { { UnkStruct_ov019_020d24c8_28_258 local_30(0x8D, 0x01); - volatile Vec2us result; + Vec2s result; Vec2s fetch; func_0201e8d4(&fetch, &this->mUnk_304); @@ -121,8 +117,7 @@ ARM void FileSelectMicTest::func_ov019_020ceaac() { result.x = local_30.mPos.x + fetch.x; result.y = local_30.mPos.y + fetch.y; - this->mUnk_270.mUnk_8E.x = result.x; - this->mUnk_270.mUnk_8E.y = result.y; + this->mUnk_270.mUnk_8E.coords = result.coords; } Vec2s local_44; @@ -142,14 +137,12 @@ ARM void FileSelectMicTest::func_ov019_020cebcc() { this->mUnk_270.func_ov019_020cf130(); - volatile Vec2s result; // not necessary, here for consistency + Vec2s result; Vec2s fetch; Vec2s *pFetch = (Vec2s *) &fetch; func_ov000_02062e44(pFetch, &this->mUnk_304.mUnk_044); - - result.y = pFetch->y + data_ov019_020d2248.mUnk_02.y; - result.x = pFetch->x + data_ov019_020d2248.mUnk_02.x; + Vec2s_Add(pFetch, &data_ov019_020d2248.mUnk_02, &result); this->mUnk_304.mUnk_0A4.func_ov000_0206415c((void *) &result, 7, data_ov019_020d2248.mUnk_00, 0); } @@ -183,15 +176,12 @@ ARM void FileSelectMicTest::vfunc_08(Input *pButtons, TouchControl *pTouchContro this->mUnk_304.mUnk_000.UpdateLogic(); UnkStruct_ov019_020d24c8_28_258 local_2c(0x8D, 0x01); - volatile Vec2us result; + Vec2s result; Vec2s fetch; func_0201e8d4(&fetch, &this->mUnk_304); - result.x = local_2c.mPos.x + fetch.x; - result.y = local_2c.mPos.y + fetch.y; - - this->mUnk_270.mUnk_8E.x = result.x; - this->mUnk_270.mUnk_8E.y = result.y; + Vec2s_Add(&local_2c.mPos, &fetch, &result); + Vec2s_Copy(&result, &this->mUnk_270.mUnk_8E); this->mUnk_304.mUnk_0A4.func_ov000_02063f64(); } diff --git a/src/019_MainSelect/FileSelectOptions.cpp b/src/019_MainSelect/FileSelectOptions.cpp index 68ba4f6e..dd693888 100644 --- a/src/019_MainSelect/FileSelectOptions.cpp +++ b/src/019_MainSelect/FileSelectOptions.cpp @@ -17,11 +17,11 @@ void func_ov000_020623d8(void *param1, unk32 param2); class UnkStruct_ov019_020d215c { public: - /* 00 */ VEC2S mUnk_00; - /* 04 */ VEC2S mUnk_04; - /* 08 */ VEC2S mUnk_08; - /* 0C */ VEC2S mUnk_0C; - /* 10 */ VEC2S mUnk_10; + /* 00 */ Vec2sC mUnk_00; + /* 04 */ Vec2sC mUnk_04; + /* 08 */ Vec2sC mUnk_08; + /* 0C */ Vec2sC mUnk_0C; + /* 10 */ Vec2sC mUnk_10; /* 14 */ }; diff --git a/src/019_MainSelect/FileSelectSubScreen.cpp b/src/019_MainSelect/FileSelectSubScreen.cpp index c21170d3..69317329 100644 --- a/src/019_MainSelect/FileSelectSubScreen.cpp +++ b/src/019_MainSelect/FileSelectSubScreen.cpp @@ -177,7 +177,8 @@ ARM FileSelect_UnkClass7::FileSelect_UnkClass7() { pos.y = pRandom->Next32(0, SUBSCREEN_HEIGHT); Vec2us *pVec = &this->mUnk_004.mUnk_E10[i]; - *pVec = pos; + pVec->x = pos.x; + pVec->y = pos.y; } } @@ -193,7 +194,8 @@ ARM void FileSelect_UnkClass7::vfunc_00() { pos.y = gRandom.Next32(0, SUBSCREEN_HEIGHT); Vec2us *pVec = &this->mUnk_004.mUnk_E10[i]; - *pVec = pos; + pVec->x = pos.x; + pVec->y = pos.y; } } } diff --git a/src/031_Land/Actor/ActorRupee.cpp b/src/031_Land/Actor/ActorRupee.cpp index c20318cb..0a4e99a3 100644 --- a/src/031_Land/Actor/ActorRupee.cpp +++ b/src/031_Land/Actor/ActorRupee.cpp @@ -100,10 +100,12 @@ ARM bool ActorRupee::vfunc_18(unk32 param1) { this->mUnk_94 = 0; { Vec3p vel; - vel.x = 0; - vel.y = 0; - vel.z = 0; - this->mVel = vel; + vel.x = 0; + vel.y = 0; + vel.z = 0; + this->mVel.x = vel.x; + this->mVel.y = vel.y; + this->mVel.z = vel.z; } this->func_ov031_020e9904(0); break; @@ -123,7 +125,9 @@ ARM bool ActorRupee::vfunc_18(unk32 param1) { q20 vz = gRandom.Next32(0, 0x223) - 0x111; vel.z = vz; - this->mVel = vel; + this->mVel.x = vel.x; + this->mVel.y = vel.y; + this->mVel.z = vel.z; } this->func_ov031_020e9904(0); break; @@ -133,10 +137,12 @@ ARM bool ActorRupee::vfunc_18(unk32 param1) { this->mUnk_94 = 0; { Vec3p vel; - vel.x = 0; - vel.y = 0x800; - vel.z = 0; - this->mVel = vel; + vel.x = 0; + vel.y = 0x800; + vel.z = 0; + this->mVel.x = vel.x; + this->mVel.y = vel.y; + this->mVel.z = vel.z; } this->func_ov031_020e9904(0); break; @@ -337,7 +343,7 @@ ARM void ActorRupee::func_ov031_020e9438() { ARM void ActorRupee::func_ov031_020e9450() { this->func_ov017_020bf9c8(gpActorManager->func_01fff3b4(this->mUnk_BC)); - this->mPrevPos = this->mPos; + Vec3p_Copy(&this->mPos, &this->mPrevPos); Vec3p_Add(&this->mPos, &this->mVel, &this->mPos); if (!GET_FLAG(this->mFlags, ActorFlag_5)) { diff --git a/src/031_Land/MapObject/MapObjectChestBase.cpp b/src/031_Land/MapObject/MapObjectChestBase.cpp index 36a16d27..b78e33a2 100644 --- a/src/031_Land/MapObject/MapObjectChestBase.cpp +++ b/src/031_Land/MapObject/MapObjectChestBase.cpp @@ -11,7 +11,16 @@ extern "C" void func_0200b58c(void *); extern "C" void func_01ffb714(Vec3p *, Vec3p *, void *); extern "C" void func_01ffcfcc(Vec3p *, Vec3p *, Vec3p *); -static const Vec2p data_ov031_02115830(0x800, 0x800); +struct UnkStruct_ov031_02117c84 { + u16 mUnk_00; + + UnkStruct_ov031_02117c84(u16 x) { + this->mUnk_00 = x; + } +}; + +static const Vec2pCpp data_ov031_02115830(0x800, 0x800); +static const UnkStruct_ov031_02117c84 data_ov031_02117c84(0x3C); static const UnkSubStruct19 data_ov031_02115c84; ARM MapObjectTreasureSpawned_74::MapObjectTreasureSpawned_74(unk32 param1) : @@ -242,7 +251,8 @@ ARM bool MapObjectChestBase::vfunc_44() { } ARM void MapObjectChestBase::func_ov031_02103f48() { - Vec3p local_10(this->mPos.x, this->mPos.y + 0x800, this->mPos.z); + Vec3p local_10; + Vec3p_Init(this->mPos.x, this->mPos.y + 0x800, this->mPos.z, &local_10); data_027e0cec->func_ov000_0209feac(0x81f, &local_10, 4, 0, 0); } diff --git a/src/031_Land/MapObject/MapObjectDoorDangerSpawn.cpp b/src/031_Land/MapObject/MapObjectDoorDangerSpawn.cpp index 3392d074..ab2eff8a 100644 --- a/src/031_Land/MapObject/MapObjectDoorDangerSpawn.cpp +++ b/src/031_Land/MapObject/MapObjectDoorDangerSpawn.cpp @@ -739,8 +739,11 @@ ARM void MapObjectDoorDangerSpawn::func_ov031_020fe5fc(Vec3p *param1, MapObjectD Vec3p *piVar2 = data_027e0ce0->func_01fff148(1); Vec3p *piVar3 = data_027e0ce0->func_01fff148(0); - Vec3p temp(piVar3->x, piVar3->y, piVar3->z); - Vec3p pos(temp.x + piVar2->x, temp.y + piVar2->y, temp.z + piVar2->z); + Vec3p temp; + Vec3p_Init(piVar3->x, piVar3->y, piVar3->z, &temp); + + Vec3p pos; + Vec3p_Init(temp.x + piVar2->x, temp.y + piVar2->y, temp.z + piVar2->z, &pos); func_01ff93c0(&pos, FLOAT_TO_Q20(0.5f)); param1->coords = pos.coords; diff --git a/src/031_Land/MapObject/MapObjectDoorSwitch.cpp b/src/031_Land/MapObject/MapObjectDoorSwitch.cpp index e9e14281..1c1b93d8 100644 --- a/src/031_Land/MapObject/MapObjectDoorSwitch.cpp +++ b/src/031_Land/MapObject/MapObjectDoorSwitch.cpp @@ -128,8 +128,10 @@ ARM void MapObjectDoorSwitch::vfunc_18(s8 *param1, s8 param2) { } ARM void MapObjectDoorSwitch::vfunc_74(void) { - Vec3p local_20(this->mPos); - Vec3p local_2c(0, 0, 0x666); + Vec3p local_20 = this->mPos; + Vec3p local_2c; + Vec3p_Init(0, 0, 0x666, &local_2c); + Mat4x3p m; u16 angle = this->mUnk_14; diff --git a/src/031_Land/MapObject/MapObjectTreasureSpawned.cpp b/src/031_Land/MapObject/MapObjectTreasureSpawned.cpp index 101ab86e..a30e6b2d 100644 --- a/src/031_Land/MapObject/MapObjectTreasureSpawned.cpp +++ b/src/031_Land/MapObject/MapObjectTreasureSpawned.cpp @@ -3,7 +3,7 @@ #include "Unknown/Common.hpp" #include "Unknown/UnkStruct_027e0cd8.hpp" -static const Vec2p data_ov031_021157b0(0x96B, 0x99A); +static const Vec2pCpp data_ov031_021157b0(0x96B, 0x99A); ARM DECL_PROFILE(MapObjectProfileTreasureSpawned); diff --git a/src/110_PlayerGet/PlayerGet.cpp b/src/110_PlayerGet/PlayerGet.cpp index dbbf06dc..cedfc868 100644 --- a/src/110_PlayerGet/PlayerGet.cpp +++ b/src/110_PlayerGet/PlayerGet.cpp @@ -22,7 +22,7 @@ #include "Unknown/UnkStruct_ov000_020b51c0.hpp" #include "versions.h" -#include +#include "math.hpp" struct UnkStruct_02186240 { /* 0000 */ unk8 mUnk_0000[0x3F68]; diff --git a/src/112_PlayerSceneChange/PlayerSceneChange.cpp b/src/112_PlayerSceneChange/PlayerSceneChange.cpp index effefcf2..0498cb0e 100644 --- a/src/112_PlayerSceneChange/PlayerSceneChange.cpp +++ b/src/112_PlayerSceneChange/PlayerSceneChange.cpp @@ -7,7 +7,7 @@ #include "Unknown/UnkStruct_027e0cd8.hpp" #include "Unknown/UnkStruct_027e0cdc.hpp" -#include +#include "math.hpp" extern "C" void func_ov000_0205ca74(unk32); extern "C" void func_ov000_0205d65c(void *, Vec3p *, Vec3p *, u32); diff --git a/src/Main/Player/TouchControl.cpp b/src/Main/Player/TouchControl.cpp index 1027e9b0..db7c32bb 100644 --- a/src/Main/Player/TouchControl.cpp +++ b/src/Main/Player/TouchControl.cpp @@ -2,16 +2,15 @@ #include "Unknown/UnkMemFuncs.h" // non-matching -ARM void TouchControl::UpdateState(TouchState *state, TouchStateFlags *stateFlags) { +ARM void TouchControl::UpdateState(TouchState *state, const TouchStateFlags *stateFlags) { if (stateFlags->touch == 1) { if (stateFlags->flags == 0) { - Vec2us pos; - pos.y = stateFlags->touchPos.y; - pos.x = stateFlags->touchPos.x; + state->touch = true; - state->touch = true; - state->touchPos.x = pos.x; - state->touchPos.y = pos.y; + u16 x = stateFlags->touchPos.x; + u16 y = stateFlags->touchPos.y; + state->touchPos.x = x; + state->touchPos.y = y; } else { if ((stateFlags->flags & 1) == 0) { state->touchPos.x = stateFlags->touchPos.x; @@ -125,27 +124,14 @@ ARM void TouchControl::UpdateFlags(u16 speed) { } ARM void TouchControl::UpdateWithStateFlags(TouchStateFlags *state, u16 speed) { - *(TouchStateU *) &this->mPrevState = *(TouchStateU *) &this->mState; + this->mPrevState = this->mState; this->UpdateState(&this->mState, state); this->UpdateFlags(speed); } -ARM void TouchControl::Update(TouchState *state, u16 speed) { - TouchStateU curState = *(TouchStateU *) &this->mState; - TouchStateU newState = *(TouchStateU *) &*state; - - this->mPrevState.touch = curState.touch; - - this->mPrevState.touch = curState.touch; - this->mPrevState.unk_01 = curState.unk_01; - this->mPrevState.touchPos.x = curState.touchPos.x; - this->mPrevState.touchPos.y = curState.touchPos.y; - - this->mState.touch = newState.touch; - this->mState.unk_01 = newState.unk_01; - this->mState.touchPos.x = newState.touchPos.x; - this->mState.touchPos.y = newState.touchPos.y; - +ARM void TouchControl::Update(const TouchState *state, u16 speed) { + this->mPrevState = this->mState; + this->mState = *state; this->UpdateFlags(speed); }