Vector improvements (#67)

* clean up math.h and attempt to improve existing vector maths

* fix broken matches and match new stuff
This commit is contained in:
Yanis
2026-05-24 01:33:53 +02:00
committed by GitHub
parent 90203403dd
commit 0698c28bb0
42 changed files with 536 additions and 448 deletions
+1 -1
View File
@@ -7,9 +7,9 @@
#include "System/SysNew.hpp"
#include "flags.h"
#include "global.h"
#include "math.hpp"
#include "types.h"
#include "versions.h"
#include <nitro/math.h>
// some functions use thumb mode on the japanese version (only in overlay 40?)
#if IS_JP
+2 -2
View File
@@ -7,9 +7,9 @@
#include "Unknown/UnkSystem1.hpp"
#include "global.h"
#include "iterator.hpp"
#include "math.hpp"
#include "regs.h"
#include "types.h"
#include <nitro/math.h>
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;
};
+1 -1
View File
@@ -6,8 +6,8 @@
#include "Unknown/UnkSystem1.hpp"
#include "global.h"
#include "iterator.hpp"
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
typedef Iterator<UnkSubStruct9, MAX_SAVE_SLOTS> FileSlotIterator;
+1 -1
View File
@@ -3,8 +3,8 @@
#include "Game/GameModeManager.hpp"
#include "Unknown/Common.hpp"
#include "global.h"
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
#define MAX_MIC_LEVELS 4
#define MIC_LEVEL_1 0 // green bar
@@ -3,8 +3,8 @@
#include "System/SysNew.hpp"
#include "Unknown/Common.hpp"
#include "global.h"
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
class FileSelectOptions;
class FileSelectMicTest;
+1 -1
View File
@@ -4,8 +4,8 @@
#include "System/SysNew.hpp"
#include "global.h"
#include "iterator.hpp"
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
// file tab manager?
class UnkSubStruct9 : public SysObject {
+1 -1
View File
@@ -4,9 +4,9 @@
#include "Player/TouchControl.hpp"
#include "System/SysNew.hpp"
#include "Unknown/UnkStruct_02049b18.hpp"
#include "math.hpp"
#include "types.h"
#include <nitro/button.h>
#include <nitro/math.h>
#include <nitro/touch.h>
class GameModeManagerBase;
+1 -1
View File
@@ -5,7 +5,7 @@
#include "global.h"
#include "types.h"
#include <nitro/math.h>
#include "math.hpp"
#define MAX_PRICECARDS 99
+1 -1
View File
@@ -7,8 +7,8 @@
#include "System/SysNew.hpp"
#include "flags.h"
#include "global.h"
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
class MapObjectProfile;
+1 -1
View File
@@ -4,7 +4,7 @@
#include "Unknown/UnkStruct_ov000_020b34c4.hpp"
#include "types.h"
#include <nitro/math.h>
#include "math.hpp"
typedef void (*UnkCallback_func_01fff4cc)(void *, void *);
+1 -1
View File
@@ -2,7 +2,7 @@
#include "types.h"
#include <nitro/math.h>
#include "math.hpp"
struct Cylinder {
Vec3p pos;
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
// incomplete
class PlayerActor {
+1 -1
View File
@@ -7,7 +7,7 @@
#include "Unknown/Common.hpp"
#include "Unknown/UnkStruct_027e0ce0.hpp"
#include "Unknown/UnkStruct_ov000_0208f820.hpp"
#include <nitro/math.h>
#include "math.hpp"
enum GIModel_ {
GIModel_None = 0,
+1 -1
View File
@@ -6,7 +6,7 @@
#include "Unknown/UnkStruct_027e09a4.hpp"
#include "Unknown/UnkStruct_ov000_0208f820.hpp"
#include <nitro/math.h>
#include "math.hpp"
class PlayerSceneChange : public UnkStruct_ov000_0208f820 {
public:
+3 -3
View File
@@ -1,7 +1,7 @@
#pragma once
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
#include <nitro/touch.h>
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);
};
+1 -1
View File
@@ -1,8 +1,8 @@
#pragma once
#include "global.h"
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
struct Random {
/* 00 */ u16 mRandomValue[4];
+9 -9
View File
@@ -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 <nitro/math.h>
#include <nns/text.h>
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;
+1 -1
View File
@@ -1,8 +1,8 @@
#pragma once
#include "global.h"
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
class UnkStruct_027e0998_Base {
public:
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
class UnkStruct_027e09a8 {
public:
+1 -1
View File
@@ -4,7 +4,7 @@
#include "global.h"
#include "types.h"
#include <nitro/math.h>
#include "math.hpp"
struct UnkStruct_027e09ac_Base_00 {
/* 00 */ unk16 mUnk_00[2];
+1 -1
View File
@@ -1,8 +1,8 @@
#pragma once
#include "files.h"
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
#include "MapObject/MapObjectManager.hpp"
#include "Unknown/UnkStruct_027e09a4.hpp"
+1 -1
View File
@@ -1,8 +1,8 @@
#pragma once
#include "Player/PlayerGet.hpp"
#include "math.hpp"
#include "types.h"
#include <nitro/math.h>
class UnkStruct_027e0cec {
public:
+1 -1
View File
@@ -5,7 +5,7 @@
#include "Item/ItemManager.hpp"
#include "System/SysNew.hpp"
#include <nitro/math.h>
#include "math.hpp"
class UnkStruct_ov000_0208f820_14 {
public:
+263
View File
@@ -0,0 +1,263 @@
#pragma once
#include <nitro/math.h>
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
}