summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcadmic <cadmic24@gmail.com>2024-09-04 02:10:14 -0700
committerGitHub <noreply@github.com>2024-09-04 11:10:14 +0200
commitc6d7cc7697c67989b1f018ae2bc934f6677c09b7 (patch)
treecadb909a8c2adde978320b8505fc1bda48e3342c /include
parentaf24970d8919e4e6bb8356fd5672c938582dfcb8 (diff)
[ntsc-1.2] Match __osMalloc.c and code_800FC620.c (new/delete) (#2106)
* Match __osMalloc * Match src/code/code_800FC620.c (new/delete) * Wrap versions-specific files in ifdefs to fix compilation * Fix bss * Remove {FAULT,RAND,OSMALLOC}_VERSION in favor of PLATFORM_N64 * Fix __osMalloc data splits, add unused strings * __osMalloc.h -> osMalloc.h * Fix merge
Diffstat (limited to 'include')
-rw-r--r--include/fault.h15
-rw-r--r--include/functions.h24
-rw-r--r--include/padmgr.h2
-rw-r--r--include/rand.h3
-rw-r--r--include/variables.h4
-rw-r--r--include/versions.h16
-rw-r--r--include/z64.h27
7 files changed, 13 insertions, 78 deletions
diff --git a/include/fault.h b/include/fault.h
index 4ecb17aea..ac63a234d 100644
--- a/include/fault.h
+++ b/include/fault.h
@@ -4,9 +4,8 @@
#include "ultra64.h"
#include "attributes.h"
#include "padmgr.h"
-#include "versions.h"
-#if FAULT_VERSION == FAULT_GC
+#if PLATFORM_GC
// These are the same as the 3-bit ansi color codes
#define FAULT_COLOR_BLACK 0
#define FAULT_COLOR_RED 1
@@ -34,7 +33,7 @@ typedef struct FaultClient {
/* 0x0C */ void* arg1;
} FaultClient; // size = 0x10
-#if FAULT_VERSION == FAULT_GC
+#if PLATFORM_GC
typedef struct FaultAddrConvClient {
/* 0x00 */ struct FaultAddrConvClient* next;
/* 0x04 */ void* callback;
@@ -56,7 +55,7 @@ NORETURN void Fault_AddHungupAndCrash(const char* file, int line);
void Fault_AddClient(FaultClient* client, void* callback, void* arg0, void* arg1);
void Fault_RemoveClient(FaultClient* client);
-#if FAULT_VERSION == FAULT_GC
+#if PLATFORM_GC
void Fault_AddAddrConvClient(FaultAddrConvClient* client, void* callback, void* arg);
void Fault_RemoveAddrConvClient(FaultAddrConvClient* client);
#endif
@@ -71,13 +70,13 @@ void Fault_SetCursor(s32 x, s32 y);
s32 Fault_Printf(const char* fmt, ...);
void Fault_DrawText(s32 x, s32 y, const char* fmt, ...);
-#if FAULT_VERSION == FAULT_N64
+#if PLATFORM_N64
// Not implemented. Silently noop-ing is fine, these are not essential for functionality.
#define Fault_SetFontColor(color) (void)0
#define Fault_SetCharPad(padW, padH) (void)0
-#elif FAULT_VERSION == FAULT_GC
+#else
void Fault_InitDrawer(void);
void Fault_SetForeColor(u16 color);
@@ -88,13 +87,13 @@ s32 Fault_VPrintf(const char* fmt, va_list args);
#endif
-#if FAULT_VERSION == FAULT_N64
+#if PLATFORM_N64
extern vs32 gFaultMsgId;
#define FAULT_MSG_ID gFaultMsgId
-#elif FAULT_VERSION == FAULT_GC
+#else
typedef struct FaultMgr {
/* 0x000 */ OSThread thread;
diff --git a/include/functions.h b/include/functions.h
index 7ca8a2ae2..6ad09a447 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -862,7 +862,7 @@ void ZeldaArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc);
void ZeldaArena_Check(void);
void ZeldaArena_Init(void* start, u32 size);
void ZeldaArena_Cleanup(void);
-u8 ZeldaArena_IsInitialized(void);
+s32 ZeldaArena_IsInitialized(void);
#if OOT_DEBUG
void ZeldaArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action);
void* ZeldaArena_MallocDebug(u32 size, const char* file, int line);
@@ -1323,7 +1323,7 @@ void DebugArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc);
void DebugArena_Check(void);
void DebugArena_Init(void* start, u32 size);
void DebugArena_Cleanup(void);
-u8 DebugArena_IsInitialized(void);
+s32 DebugArena_IsInitialized(void);
#if OOT_DEBUG
void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action);
void* DebugArena_MallocDebug(u32 size, const char* file, int line);
@@ -1593,7 +1593,7 @@ void SystemArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc);
void SystemArena_Check(void);
void SystemArena_Init(void* start, u32 size);
void SystemArena_Cleanup(void);
-u8 SystemArena_IsInitialized(void);
+s32 SystemArena_IsInitialized(void);
#if OOT_DEBUG
void* SystemArena_MallocDebug(u32 size, const char* file, int line);
void* SystemArena_MallocRDebug(u32 size, const char* file, int line);
@@ -1601,24 +1601,6 @@ void* SystemArena_ReallocDebug(void* ptr, u32 newSize, const char* file, int lin
void SystemArena_FreeDebug(void* ptr, const char* file, int line);
void SystemArena_Display(void);
#endif
-
-void __osMallocInit(Arena* arena, void* start, u32 size);
-void __osMallocAddBlock(Arena* arena, void* start, s32 size);
-void __osMallocCleanup(Arena* arena);
-u8 __osMallocIsInitialized(Arena* arena);
-void* __osMalloc(Arena* arena, u32 size);
-void* __osMallocR(Arena* arena, u32 size);
-void __osFree(Arena* arena, void* ptr);
-void* __osRealloc(Arena* arena, void* ptr, u32 newSize);
-void ArenaImpl_GetSizes(Arena* arena, u32* outMaxFree, u32* outFree, u32* outAlloc);
-u32 __osCheckArena(Arena* arena);
-#if OOT_DEBUG
-void* __osMallocDebug(Arena* arena, u32 size, const char* file, int line);
-void* __osMallocRDebug(Arena* arena, u32 size, const char* file, int line);
-void __osFreeDebug(Arena* arena, void* ptr, const char* file, int line);
-void* __osReallocDebug(Arena* arena, void* ptr, u32 newSize, const char* file, int line);
-void __osDisplayArena(Arena* arena);
-#endif
s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args);
s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...);
void Sleep_Cycles(OSTime cycles);
diff --git a/include/padmgr.h b/include/padmgr.h
index efd245c7d..7078c9007 100644
--- a/include/padmgr.h
+++ b/include/padmgr.h
@@ -53,7 +53,7 @@ void PadMgr_Init(PadMgr* padMgr, OSMesgQueue* serialEventQueue, IrqMgr* irqMgr,
// This function cannot be prototyped here in all configurations because it is called incorrectly in fault_gc.c
// (see bug in `Fault_PadCallback`)
-#if FAULT_VERSION == FAULT_N64 || defined(AVOID_UB)
+#if PLATFORM_N64 || defined(AVOID_UB)
void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 gameRequest);
#endif
diff --git a/include/rand.h b/include/rand.h
index a1a6a7c16..79ced24ea 100644
--- a/include/rand.h
+++ b/include/rand.h
@@ -2,7 +2,6 @@
#define RAND_H
#include "ultra64.h"
-#include "versions.h"
u32 Rand_Next(void);
void Rand_Seed(u32 seed);
@@ -11,7 +10,7 @@ void Rand_Seed_Variable(u32* rndNum, u32 seed);
u32 Rand_Next_Variable(u32* rndNum);
f32 Rand_ZeroOne_Variable(u32* rndNum);
-#if RAND_VERSION == RAND_GC
+#if PLATFORM_GC
f32 Rand_Centered(void);
f32 Rand_Centered_Variable(u32* rndNum);
#endif
diff --git a/include/variables.h b/include/variables.h
index 739a76818..fa09f0f54 100644
--- a/include/variables.h
+++ b/include/variables.h
@@ -2,6 +2,7 @@
#define VARIABLES_H
#include "z64.h"
+#include "osMalloc.h"
#include "segment_symbols.h"
extern Mtx D_01000000;
@@ -234,7 +235,6 @@ extern ActiveSequence gActiveSeqs[4];
extern AudioContext gAudioCtx;
extern AudioCustomUpdateFunction gAudioCustomUpdateFunction;
-extern u32 __osMalloc_FreeBlockTest_Enable;
extern Arena gSystemArena;
extern OSPifRam __osContPifRam;
extern u8 __osContLastCmd;
@@ -248,6 +248,4 @@ extern u64 gGfxSPTaskStack[SP_DRAM_STACK_SIZE64]; // 0x400 bytes
extern GfxPool gGfxPools[2]; // 0x24820 bytes
extern u8 gAudioHeap[0x38000]; // 0x38000 bytes
-extern u32 gTotalAllocFailures;
-
#endif
diff --git a/include/versions.h b/include/versions.h
index 1112ac01f..b135ae390 100644
--- a/include/versions.h
+++ b/include/versions.h
@@ -16,20 +16,4 @@
#define GC_EU_MQ 12
#define GC_JP_CE 13
-#define FAULT_N64 1 // in OoT N64
-#define FAULT_GC 2 // in OoT GC
-#if PLATFORM_N64
-#define FAULT_VERSION FAULT_N64
-#else
-#define FAULT_VERSION FAULT_GC
-#endif
-
-#define RAND_N64 1 // in OoT N64
-#define RAND_GC 2 // in OoT GC
-#if PLATFORM_N64
-#define RAND_VERSION RAND_N64
-#else
-#define RAND_VERSION RAND_GC
-#endif
-
#endif
diff --git a/include/z64.h b/include/z64.h
index 6b6cfb284..02cdafb49 100644
--- a/include/z64.h
+++ b/include/z64.h
@@ -439,33 +439,6 @@ typedef struct Yaz0Header {
/* 0x0C */ u32 uncompDataOffset; // only used in mio0
} Yaz0Header; // size = 0x10
-struct ArenaNode;
-
-typedef struct Arena {
- /* 0x00 */ struct ArenaNode* head;
- /* 0x04 */ void* start;
- /* 0x08 */ OSMesgQueue lockQueue;
- /* 0x20 */ u8 allocFailures; // only used in non-debug builds
- /* 0x21 */ u8 isInit;
- /* 0x22 */ u8 flag;
-} Arena; // size = 0x24
-
-typedef struct ArenaNode {
- /* 0x00 */ s16 magic;
- /* 0x02 */ s16 isFree;
- /* 0x04 */ u32 size;
- /* 0x08 */ struct ArenaNode* next;
- /* 0x0C */ struct ArenaNode* prev;
-#if OOT_DEBUG // TODO: This debug info is also present in N64 retail builds
- /* 0x10 */ const char* filename;
- /* 0x14 */ int line;
- /* 0x18 */ OSId threadId;
- /* 0x1C */ Arena* arena;
- /* 0x20 */ OSTime time;
- /* 0x28 */ u8 unk_28[0x30-0x28]; // probably padding
-#endif
-} ArenaNode; // size = 0x30
-
/* Relocation entry field getters */
#define RELOC_SECTION(reloc) ((reloc) >> 30)
#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF)