summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorAetias <144526980+AetiasHax@users.noreply.github.com>2025-02-03 23:53:59 +0100
committerGitHub <noreply@github.com>2025-02-03 23:53:59 +0100
commit66fa3f0623820bc4fb099289a398453cd28e4ed9 (patch)
tree49de846e0516c9490ea31fd14a867cc14253f7e4 /libs
parent48bbd8bb7f008ac913cabb6f7faf4a47ad86878b (diff)
parent2bd1bbd10b1ba5a595372a3313e80e4274a4e912 (diff)
Merge pull request #59 from AetiasHax/ghidra-symbols
Import documentation from Ghidra server
Diffstat (limited to 'libs')
-rw-r--r--libs/c/include/assert.h8
-rw-r--r--libs/c/include/stddef.h8
-rw-r--r--libs/c/include/stdlib.h1
-rw-r--r--libs/c/include/string.h10
-rw-r--r--libs/cpp/include/cxxabi.h11
-rw-r--r--libs/cpp/include/vector36
-rw-r--r--libs/nds/include/nds/Overlay.h30
-rw-r--r--libs/nds/include/nds/math.h188
-rw-r--r--libs/nds/src/itcm/math_1.c64
-rw-r--r--libs/nds/src/itcm/math_2.c7
10 files changed, 359 insertions, 4 deletions
diff --git a/libs/c/include/assert.h b/libs/c/include/assert.h
new file mode 100644
index 00000000..22cdf7dc
--- /dev/null
+++ b/libs/c/include/assert.h
@@ -0,0 +1,8 @@
+#ifndef _C_ASSERT_H
+#define _C_ASSERT_H
+
+#define assert(condition) (void) ((condition) || __assert_failed(#condition, __FILE__, __FUNCTION__, __LINE__));
+
+void __assert_failed(char *condition, char *fileName, char *functionName, s32 lineNumber);
+
+#endif
diff --git a/libs/c/include/stddef.h b/libs/c/include/stddef.h
new file mode 100644
index 00000000..4986043a
--- /dev/null
+++ b/libs/c/include/stddef.h
@@ -0,0 +1,8 @@
+#ifndef _C_STDDEF_H
+#define _C_STDDEF_H
+
+#define NULL 0
+
+typedef unsigned int size_t;
+
+#endif
diff --git a/libs/c/include/stdlib.h b/libs/c/include/stdlib.h
index 0f078d8a..fbc4dce0 100644
--- a/libs/c/include/stdlib.h
+++ b/libs/c/include/stdlib.h
@@ -2,5 +2,6 @@
#define _C_STRLIB_H
int abs(int n);
+long labs(long n);
#endif
diff --git a/libs/c/include/string.h b/libs/c/include/string.h
index 6c1c86a7..bd27c855 100644
--- a/libs/c/include/string.h
+++ b/libs/c/include/string.h
@@ -1,7 +1,15 @@
#ifndef _C_STRING_H
#define _C_STRING_H
-typedef unsigned int size_t;
+#include <stddef.h>
+
+void memcpy(void *dest, void *src, size_t count);
+void memmove(void *dest, void *src, size_t count);
+void memset(void *dest, int ch, size_t count);
+void *memchr(const void *ptr, int ch, size_t count);
+void *memrchr(const void *ptr, int ch, size_t count);
+int memcmp(const void *ptr1, const void *ptr2, size_t count);
+void __memset_impl(void *dest, int ch, size_t count);
size_t strlen(const char *str);
char *strcpy(char *dest, const char *src);
diff --git a/libs/cpp/include/cxxabi.h b/libs/cpp/include/cxxabi.h
new file mode 100644
index 00000000..be49baba
--- /dev/null
+++ b/libs/cpp/include/cxxabi.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include <stddef.h>
+
+namespace __cxxabiv1 {
+ extern "C" {
+ typedef void (*__cxa_cdtor_type)(void *);
+
+ void __cxa_vec_cleanup(void *array, size_t count, size_t elementSize, __cxa_cdtor_type dtor);
+ }
+} // namespace __cxxabiv1
diff --git a/libs/cpp/include/vector b/libs/cpp/include/vector
index 7d78e50c..37e7a4d8 100644
--- a/libs/cpp/include/vector
+++ b/libs/cpp/include/vector
@@ -1,10 +1,40 @@
#pragma once
+#include <string.h>
+
namespace std {
template <class T> class vector {
public:
- T *elements;
- int size;
- int capacity;
+ T *mElements;
+ int mSize;
+ int mCapacity;
+
+ ~vector() {
+ if (mElements != NULL) {
+ decrease_size(mSize);
+ delete mElements;
+ }
+ }
+
+ void push_back(T &value) {
+ get_new_capacity(1);
+ append_back(1, &value);
+ }
+
+ T *erase(T *first, T *last) {
+ if (first != last) {
+ int bytesToMove = (int) mElements + mSize * sizeof(T) - (int) last;
+ memmove(first, last, bytesToMove);
+ mSize -= (int) last - (int) first;
+ }
+ return first;
+ }
+
+ private:
+ void decrease_size(int amount);
+
+ int get_new_capacity(int growth);
+
+ void append_back(int length, T *items);
};
} // namespace std
diff --git a/libs/nds/include/nds/Overlay.h b/libs/nds/include/nds/Overlay.h
new file mode 100644
index 00000000..7a8c6fa9
--- /dev/null
+++ b/libs/nds/include/nds/Overlay.h
@@ -0,0 +1,30 @@
+#ifndef _NDS_OVERLAY_H
+#define _NDS_OVERLAY_H
+
+typedef struct Overlay {
+ /* 00 */ unk32 mId;
+ /* 04 */ void *mBaseAddress;
+ /* 08 */ u32 mTextSize;
+ /* 0c */ s32 mBssSize;
+ /* 10 */ unk32 mCtorStart;
+ /* 14 */ unk32 mCtorEnd;
+ /* 18 */ unk32 mFileId;
+ /* 1c */ u32 mFileSize;
+ /* 20 */
+} Overlay;
+
+u32 Overlay_FileSize(Overlay *overlay);
+void Overlay_ClearCacheAndBss(Overlay *overlay);
+void Overlay_func_02042238(unk32 *param1, Overlay *overlay);
+bool Overlay_func_02042250(Overlay *param1, Overlay *param2, s32 param3, unk32 param4, s32 param5, u32 param6, s32 param7,
+ u32 param8);
+bool Overlay_func_020422ec(Overlay *param1, Overlay *param2, s32 param3);
+bool Overlay_func_0204238c(Overlay *overlay);
+bool Overlay_func_020423e8(s32 param1, unk32 param2, unk32 param3);
+void Overlay_Init(Overlay *overlay);
+void Overlay_RunGlobalDestructors(Overlay *overlay);
+bool Overlay_Destroy(Overlay *overlay);
+bool Overlay_Load(Overlay *overlay, unk32 param2);
+bool Overlay_Unload(Overlay *overlay, unk32 param2);
+
+#endif
diff --git a/libs/nds/include/nds/math.h b/libs/nds/include/nds/math.h
new file mode 100644
index 00000000..517cbde2
--- /dev/null
+++ b/libs/nds/include/nds/math.h
@@ -0,0 +1,188 @@
+#ifndef _NDS_MATH_H
+#define _NDS_MATH_H
+
+#include "global.h"
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Q20.12 fixed point number
+typedef s32 q20;
+// Q4.12 fixed point number
+typedef s16 q4;
+
+#define INT_TO_Q20(n) ((s32) ((n) << 12))
+#define FLOAT_TO_Q21(n) ((s32) (((n) * 8192 + 1) / 4))
+#define FLOAT_TO_Q20(n) ((s32) (((n) * 8192 + 1) / 2))
+#define FLOAT_TO_Q19(n) ((s32) (((n) * 8192 + 1)))
+#define ROUND_Q20(n) (((s32) (n) + 0x800) >> 12)
+#define MUL_Q20(a, b) (q20)((((s64) (a)) * ((s64) (b)) + 0x800) >> 12)
+
+#define DEG_TO_ANG(n) ((n) * 0x10000 / 360)
+#define SIN(n) (gSinCosTable[2 * ((n) >> 4)])
+#define COS(n) (gSinCosTable[2 * ((n) >> 4) + 1])
+
+u32 func_01ff9f3c(s32 a, s32 b);
+s32 Atan2(s32 x, s32 y);
+
+u32 SoftDivide(u32 a, u32 b);
+u32 CoDivide64By32(u32 a, u32 b);
+u32 func_01ff98f0(u32 a, u32 b);
+u32 CoReciprocal(u32 x);
+u32 func_01ff992c(u32 x);
+u32 CoSqrt(u32 x);
+u32 CoInvSqrt(u32 x);
+u32 AwaitDivisionResult();
+u32 GetDivisionResult();
+void StartReciprocal(u32 x);
+void StartSqrt(u32 x);
+void func_01ff9ac4(u32 x);
+u32 AwaitSqrtResult();
+void StartDivision64By32(u32 a, u32 b);
+u32 CoDivide32(u32 a, u32 b);
+u32 CoRemainder(u32 a, u32 b);
+
+bool Approach(unk32 *src, unk32 dest, unk32 step);
+bool Approach_thunk(unk32 *src, unk32 dest, unk32 step);
+extern q4 gSinCosTable[];
+
+typedef struct {
+ /* 0 */ s8 x;
+ /* 1 */ s8 y;
+ /* 2 */
+} Vec2b;
+
+typedef struct {
+ /* 0 */ s16 x;
+ /* 1 */ s16 y;
+ /* 2 */
+} Vec2s;
+
+typedef struct {
+ /* 0 */ q20 x;
+ /* 4 */ q20 y;
+ /* 8 */
+} Vec2p;
+
+typedef struct {
+ /* 0 */ q20 x;
+ /* 4 */ q20 y;
+ /* 8 */ q20 z;
+ /* c */
+} Vec3p;
+
+typedef struct {
+ /* 00 */ q20 x;
+ /* 04 */ q20 y;
+ /* 08 */ q20 z;
+ /* 0c */ q20 w;
+ /* 10 */
+} Vec4p;
+
+typedef struct {
+ /* 00 */ Vec2p xColumn;
+ /* 08 */ Vec2p yColumn;
+ /* 10 */
+} Mat2p;
+
+typedef struct {
+ /* 00 */ Vec3p xColumn;
+ /* 0c */ Vec3p yColumn;
+ /* 18 */ Vec3p zColumn;
+ /* 24 */
+} Mat3p;
+
+typedef struct {
+ /* 00 */ Vec3p xColumn;
+ /* 0c */ Vec3p yColumn;
+ /* 18 */ Vec3p zColumn;
+ /* 24 */ Vec3p wColumn;
+ /* 30 */
+} Mat4x3p;
+
+typedef struct {
+ /* 00 */ Vec4p xColumn;
+ /* 10 */ Vec4p yColumn;
+ /* 20 */ Vec4p zColumn;
+ /* 30 */ Vec4p wColumn;
+ /* 40 */
+} Mat4p;
+
+extern const Vec3p gVec3p_ZERO;
+
+void Vec3p_Add(Vec3p *a, Vec3p *b, Vec3p *out);
+void Vec3p_Sub(Vec3p *a, Vec3p *b, Vec3p *out);
+q20 Vec3p_Dot(Vec3p *a, Vec3p *b);
+void Vec3p_Cross(Vec3p *a, Vec3p *b, Vec3p *out);
+q20 Vec3p_Length(Vec3p *a);
+void Vec3p_Normalize(Vec3p *vec, Vec3p *out);
+void Vec3p_Axpy(q20 a, Vec3p *x, Vec3p *y, Vec3p *out);
+q20 Vec3p_Distance(Vec3p *a, Vec3p *b);
+bool Vec3p_TryNormalize(Vec3p *vec);
+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) {
+ 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) {
+ q20 z = vec->z;
+ q20 x = vec->x;
+
+ out->x = x;
+ out->y = 0;
+ out->z = z;
+}
+
+inline void Vec3p_Copy(Vec3p *vec, Vec3p *out) {
+ out->x = vec->x;
+ out->y = vec->y;
+ out->z = vec->z;
+}
+
+void Mat2p_InitIdentity(Mat2p *m);
+void Mat2p_InitRotation(Mat2p *m, q20 sin, q20 cos);
+void Mat2p_Multiply(Mat2p *a, Mat2p *b, Mat2p *out);
+
+void Mat3p_InitIdentity(Mat3p *m);
+void Mat3p_CopyToMat4x3p(Mat3p *m, Mat4x3p *out);
+void Mat3p_InitScale(Mat3p *m, q20 x, q20 y, q20 z);
+void Mat3p_ScaleColumns(Mat3p *m, Mat3p *out, q20 x, q20 y, q20 z);
+void Mat3p_InitXRotation(Mat3p *m, q20 sin, q20 cos);
+void Mat3p_InitYRotation(Mat3p *m, q20 sin, q20 cos);
+void Mat3p_InitZRotation(Mat3p *m, q20 sin, q20 cos);
+void Mat3p_func_01ff8248(Mat3p *m, Vec3p *v, q20 scale, q20 offset);
+void Mat3p_func_01ff83a0(Mat3p *a, Mat3p *b);
+void Mat3p_Multiply(Mat3p *a, Mat3p *b, Mat3p *out);
+void Mat3p_MultiplyVec(Vec3p *v, Mat3p *m, Vec3p *out);
+
+void Mat4x3p_InitIdentity(Mat4x3p *m);
+void Mat4x3p_CopyToMat4p(Mat4x3p *m, Mat4p *out);
+void Mat4x3p_func_01ff8988(Mat4x3p *m, Mat4x3p *out, q20 x, q20 y, q20 z);
+void Mat4x3p_InitScale(Mat4x3p *m, q20 x, q20 y, q20 z);
+void Mat4x3p_ScaleColumns(Mat4x3p *m, Mat4x3p *out, q20 x, q20 y, q20 z);
+void Mat4x3p_InitXRotation(Mat4x3p *m, q20 sin, q20 cos);
+void Mat4x3p_InitYRotation(Mat4x3p *m, q20 sin, q20 cos);
+void Mat4x3p_InitZRotation(Mat4x3p *m, q20 sin, q20 cos);
+void Mat4x3p_func_01ff8ad8(Mat4x3p *m, Vec3p *v, q20 scale, q20 offset);
+void Mat4x3p_func_01ff8af8(Mat4x3p *a, Mat4x3p *b);
+void Mat4x3p_Multiply(Mat4x3p *a, Mat4x3p *b, Mat4x3p *out);
+void Mat4x3p_MultiplyVec(Vec3p *v, Mat4x3p *m, Vec3p *out);
+
+void Mat4p_InitIdentity(Mat4p *m);
+void Mat4p_CopyToMat4x3p(Mat4p *m, Mat4x3p *out);
+void Mat4p_InitZRotation(Mat4p *m, q20 sin, q20 cos);
+void Mat4p_Multiply(Mat4p *a, Mat4p *b, Mat4p *out);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/nds/src/itcm/math_1.c b/libs/nds/src/itcm/math_1.c
new file mode 100644
index 00000000..ee452869
--- /dev/null
+++ b/libs/nds/src/itcm/math_1.c
@@ -0,0 +1,64 @@
+#include "nds/math.h"
+
+void Mat2p_InitIdentity(Mat2p *m) {}
+void Mat2p_InitRotation(Mat2p *m, q20 sin, q20 cos) {}
+void Mat2p_Multiply(Mat2p *a, Mat2p *b, Mat2p *out) {}
+
+void Mat3p_InitIdentity(Mat3p *m) {}
+void Mat3p_CopyToMat4x3p(Mat3p *m, Mat4x3p *out) {}
+void Mat3p_InitScale(Mat3p *m, q20 x, q20 y, q20 z) {}
+void Mat3p_ScaleColumns(Mat3p *m, Mat3p *out, q20 x, q20 y, q20 z) {}
+void Mat3p_InitXRotation(Mat3p *m, q20 sin, q20 cos) {}
+void Mat3p_InitYRotation(Mat3p *m, q20 sin, q20 cos) {}
+void Mat3p_InitZRotation(Mat3p *m, q20 sin, q20 cos) {}
+void Mat3p_func_01ff8248(Mat3p *m, Vec3p *v, q20 scale, q20 offset) {}
+void Mat3p_func_01ff83a0(Mat3p *a, Mat3p *b) {}
+void Mat3p_Multiply(Mat3p *a, Mat3p *b, Mat3p *out) {}
+void Mat3p_MultiplyVec(Vec3p *v, Mat3p *m, Vec3p *out) {}
+
+void Mat4x3p_InitIdentity(Mat4x3p *m) {}
+void Mat4x3p_CopyToMat4p(Mat4x3p *m, Mat4p *out) {}
+void Mat4x3p_func_01ff8988(Mat4x3p *m, Mat4x3p *out, q20 x, q20 y, q20 z) {}
+void Mat4x3p_InitScale(Mat4x3p *m, q20 x, q20 y, q20 z) {}
+void Mat4x3p_ScaleColumns(Mat4x3p *m, Mat4x3p *out, q20 x, q20 y, q20 z) {}
+void Mat4x3p_InitXRotation(Mat4x3p *m, q20 sin, q20 cos) {}
+void Mat4x3p_InitYRotation(Mat4x3p *m, q20 sin, q20 cos) {}
+void Mat4x3p_InitZRotation(Mat4x3p *m, q20 sin, q20 cos) {}
+void Mat4x3p_func_01ff8ad8(Mat4x3p *m, Vec3p *v, q20 scale, q20 offset) {}
+void Mat4x3p_func_01ff8af8(Mat4x3p *a, Mat4x3p *b) {}
+void Mat4x3p_Multiply(Mat4x3p *a, Mat4x3p *b, Mat4x3p *out) {}
+void Mat4x3p_MultiplyVec(Vec3p *v, Mat4x3p *m, Vec3p *out) {}
+
+void Mat4p_InitIdentity(Mat4p *m) {}
+void Mat4p_CopyToMat4x3p(Mat4p *m, Mat4x3p *out) {}
+void Mat4p_InitZRotation(Mat4p *m, q20 sin, q20 cos) {}
+void Mat4p_Multiply(Mat4p *a, Mat4p *b, Mat4p *out) {}
+
+u32 CoDivide64By32(u32 a, u32 b) {}
+u32 func_01ff98f0(u32 a, u32 b) {}
+u32 CoReciprocal(u32 x) {}
+u32 func_01ff992c(u32 x) {}
+u32 CoSqrt(u32 x) {}
+u32 CoInvSqrt(u32 x) {}
+u32 AwaitDivisionResult() {}
+u32 GetDivisionResult() {}
+void StartReciprocal(u32 x) {}
+void StartSqrt(u32 x) {}
+void func_01ff9ac4(u32 x) {}
+u32 AwaitSqrtResult() {}
+void StartDivision64By32(u32 a, u32 b) {}
+u32 CoDivide32(u32 a, u32 b) {}
+u32 CoRemainder(u32 a, u32 b) {}
+
+void Vec3p_Add(Vec3p *a, Vec3p *b, Vec3p *out) {}
+void Vec3p_Sub(Vec3p *a, Vec3p *b, Vec3p *out) {}
+q20 Vec3p_Dot(Vec3p *a, Vec3p *b) {}
+void Vec3p_Cross(Vec3p *a, Vec3p *b, Vec3p *out) {}
+q20 Vec3p_Length(Vec3p *a) {}
+void Vec3p_Normalize(Vec3p *vec, Vec3p *out) {}
+void Vec3p_Axpy(q20 a, Vec3p *x, Vec3p *y, Vec3p *out) {}
+q20 Vec3p_Distance(Vec3p *a, Vec3p *b) {}
+void Vec3p_func_01fffc94(Vec3p *a, Vec3p *b);
+
+u32 func_01ff9f3c(s32 a, s32 b) {}
+s32 Atan2(s32 x, s32 y) {}
diff --git a/libs/nds/src/itcm/math_2.c b/libs/nds/src/itcm/math_2.c
new file mode 100644
index 00000000..b63286fb
--- /dev/null
+++ b/libs/nds/src/itcm/math_2.c
@@ -0,0 +1,7 @@
+#include "nds/math.h"
+
+bool Vec3p_TryNormalize(Vec3p *vec) {}
+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) {}
+void Vec3p_func_01fffc94(Vec3p *a, Vec3p *b) {}