summaryrefslogtreecommitdiff
path: root/include/libu64
diff options
context:
space:
mode:
authorDragorn421 <Dragorn421@users.noreply.github.com>2024-11-08 02:27:19 +0100
committerGitHub <noreply@github.com>2024-11-07 17:27:19 -0800
commitfcc5cf828ded5d362b2e63a8868374a50df405ed (patch)
tree530d7d6d8690599593f6588b04d10441e364b5c7 /include/libu64
parent9cd9099a0431b369be39f111bf57051f544bead3 (diff)
libu64 (#1705)
* libu64 * libu64 -O2 * Add libu64.md
Diffstat (limited to 'include/libu64')
-rw-r--r--include/libu64/debug.h7
-rw-r--r--include/libu64/gfxprint.h52
-rw-r--r--include/libu64/loadfragment.h42
-rw-r--r--include/libu64/pad.h17
-rw-r--r--include/libu64/padsetup.h8
-rw-r--r--include/libu64/stackcheck.h26
-rw-r--r--include/libu64/system_heap.h11
7 files changed, 163 insertions, 0 deletions
diff --git a/include/libu64/debug.h b/include/libu64/debug.h
new file mode 100644
index 000000000..5bcae690c
--- /dev/null
+++ b/include/libu64/debug.h
@@ -0,0 +1,7 @@
+#ifndef LIBU64_DEBUG_H
+#define LIBU64_DEBUG_H
+
+void _dbg_hungup(const char* file, int lineNum);
+void Reset(void);
+
+#endif
diff --git a/include/libu64/gfxprint.h b/include/libu64/gfxprint.h
new file mode 100644
index 000000000..78819151e
--- /dev/null
+++ b/include/libu64/gfxprint.h
@@ -0,0 +1,52 @@
+#ifndef LIBU64_GFXPRINT_H
+#define LIBU64_GFXPRINT_H
+
+#include "ultra64.h"
+
+#include "libc64/aprintf.h"
+#include "PR/xstdio.h"
+
+#include "color.h"
+#include "unk.h"
+
+#define GFXP_UNUSED "\x8E"
+#define GFXP_UNUSED_CHAR 0x8E
+#define GFXP_HIRAGANA "\x8D"
+#define GFXP_HIRAGANA_CHAR 0x8D
+#define GFXP_KATAKANA "\x8C"
+#define GFXP_KATAKANA_CHAR 0x8C
+#define GFXP_RAINBOW_ON "\x8B"
+#define GFXP_RAINBOW_ON_CHAR 0x8B
+#define GFXP_RAINBOW_OFF "\x8A"
+#define GFXP_RAINBOW_OFF_CHAR 0x8A
+
+typedef struct GfxPrint {
+ /* 0x00 */ PrintCallback callback;
+ /* 0x04 */ Gfx* dList;
+ /* 0x08 */ u16 posX;
+ /* 0x0A */ u16 posY;
+ /* 0x0C */ u16 baseX;
+ /* 0x0E */ u8 baseY;
+ /* 0x0F */ u8 flags;
+ /* 0x10 */ Color_RGBA8_u32 color;
+ /* 0x14 */ UNK_TYPE1 unk_14[0x1C]; // unused
+} GfxPrint; // size = 0x30
+
+void GfxPrint_Setup(GfxPrint* this);
+void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a);
+void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y);
+void GfxPrint_SetPos(GfxPrint* this, s32 x, s32 y);
+void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y);
+void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c);
+void GfxPrint_PrintChar(GfxPrint* this, u8 c);
+void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, size_t charSize, size_t charCount);
+void GfxPrint_PrintString(GfxPrint* this, const char* str);
+void* GfxPrint_Callback(void* arg, const char* str, size_t size);
+void GfxPrint_Init(GfxPrint* this);
+void GfxPrint_Destroy(GfxPrint* printer);
+void GfxPrint_Open(GfxPrint* this, Gfx* dList);
+Gfx* GfxPrint_Close(GfxPrint* this);
+s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args);
+s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...);
+
+#endif
diff --git a/include/libu64/loadfragment.h b/include/libu64/loadfragment.h
new file mode 100644
index 000000000..7a3e5a7d9
--- /dev/null
+++ b/include/libu64/loadfragment.h
@@ -0,0 +1,42 @@
+#ifndef LIBU64_LOADFRAGMENT_H
+#define LIBU64_LOADFRAGMENT_H
+
+#include "PR/ultratypes.h"
+#include "stdint.h"
+#include "stddef.h"
+
+extern s32 gOverlayLogSeverity;
+
+#define RELOC_SECTION(reloc) ((reloc) >> 30)
+#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF)
+#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000)
+#define RELOC_TYPE_SHIFT 24
+
+/* MIPS Relocation Types */
+#define R_MIPS_32 2
+#define R_MIPS_26 4
+#define R_MIPS_HI16 5
+#define R_MIPS_LO16 6
+
+typedef enum {
+ /* 0 */ RELOC_SECTION_NULL,
+ /* 1 */ RELOC_SECTION_TEXT,
+ /* 2 */ RELOC_SECTION_DATA,
+ /* 3 */ RELOC_SECTION_RODATA,
+ /* 4 */ RELOC_SECTION_MAX
+} RelocSectionId;
+
+typedef struct OverlayRelocationSection {
+ /* 0x00 */ size_t textSize;
+ /* 0x04 */ size_t dataSize;
+ /* 0x08 */ size_t rodataSize;
+ /* 0x0C */ size_t bssSize;
+ /* 0x10 */ u32 numRelocations;
+ /* 0x14 */ u32 relocations[1]; // array count is numRelocations
+} OverlayRelocationSection; // size >= 0x18
+
+// Fragment overlay load functions
+size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd, void* allocatedRamAddr);
+void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd);
+
+#endif
diff --git a/include/libu64/pad.h b/include/libu64/pad.h
new file mode 100644
index 000000000..db9e6e419
--- /dev/null
+++ b/include/libu64/pad.h
@@ -0,0 +1,17 @@
+#ifndef LIBU64_PAD_H
+#define LIBU64_PAD_H
+
+#include "PR/os_cont.h"
+
+
+typedef struct Input {
+ /* 0x00 */ OSContPad cur;
+ /* 0x06 */ OSContPad prev;
+ /* 0x0C */ OSContPad press; // X/Y store delta from last frame
+ /* 0x12 */ OSContPad rel; // X/Y store adjusted
+} Input; // size = 0x18
+
+
+void PadUtils_UpdateRelXY(Input* input);
+
+#endif
diff --git a/include/libu64/padsetup.h b/include/libu64/padsetup.h
new file mode 100644
index 000000000..0aab4a729
--- /dev/null
+++ b/include/libu64/padsetup.h
@@ -0,0 +1,8 @@
+#ifndef LIBU64_PADSETUP_H
+#define LIBU64_PADSETUP_H
+
+#include "ultra64.h"
+
+s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status);
+
+#endif
diff --git a/include/libu64/stackcheck.h b/include/libu64/stackcheck.h
new file mode 100644
index 000000000..7bf5b78fb
--- /dev/null
+++ b/include/libu64/stackcheck.h
@@ -0,0 +1,26 @@
+#ifndef LIBU64_STACKCHECK_H
+#define LIBU64_STACKCHECK_H
+
+#include "ultra64.h"
+
+typedef enum StackStatus {
+ /* 0 */ STACK_STATUS_OK,
+ /* 1 */ STACK_STATUS_WARNING,
+ /* 2 */ STACK_STATUS_OVERFLOW
+} StackStatus;
+
+typedef struct StackEntry {
+ /* 0x00 */ struct StackEntry* next;
+ /* 0x04 */ struct StackEntry* prev;
+ /* 0x08 */ void* head;
+ /* 0x0C */ void* tail;
+ /* 0x10 */ u32 initValue;
+ /* 0x14 */ s32 minSpace;
+ /* 0x18 */ const char* name;
+} StackEntry; // size = 0x1C
+
+void StackCheck_Init(StackEntry* entry, void* stackBottom, void* stackTop, u32 initValue, s32 minSpace, const char* name);
+void StackCheck_Cleanup(StackEntry* entry);
+u32 StackCheck_Check(StackEntry* entry);
+
+#endif
diff --git a/include/libu64/system_heap.h b/include/libu64/system_heap.h
new file mode 100644
index 000000000..7f8aa9d7e
--- /dev/null
+++ b/include/libu64/system_heap.h
@@ -0,0 +1,11 @@
+#ifndef LIBU64_SYSTEM_HEAP_H
+#define LIBU64_SYSTEM_HEAP_H
+
+#include "stddef.h"
+#include "PR/ultratypes.h"
+
+void* SystemHeap_Malloc(size_t size);
+void SystemHeap_Free(void* ptr);
+void SystemHeap_Init(void* start, size_t size);
+
+#endif