From c048ec3ee3964faf96da46e62a6d24936b19916e Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 17 Oct 2020 18:03:00 -0400 Subject: rename code_801DAA30's static initializer in ctors.s, and match code_801DAA30.cpp. Does not link because the __sinit_ function is not global --- asm/code_801DAA30.s | 4 ++-- asm/code_801DAAE0.s | 1 + asm/ctors.s | 2 +- include/types.h | 2 ++ obj_files.mk | 2 +- src/code_801DAA30.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 src/code_801DAA30.cpp diff --git a/asm/code_801DAA30.s b/asm/code_801DAA30.s index 05d7f52..11c870b 100644 --- a/asm/code_801DAA30.s +++ b/asm/code_801DAA30.s @@ -54,8 +54,8 @@ __dl__FPv: __dla__FPv: /* 801DAABC 001D671C 48 00 03 E8 */ b func_801DAEA4 -.global func_801DAAC0 -func_801DAAC0: +.global __sinit_$3code_801DAA30_cpp +__sinit_$3code_801DAA30_cpp: /* 801DAAC0 001D6720 38 A0 00 01 */ li r5, 1 /* 801DAAC4 001D6724 38 6D A0 08 */ addi r3, r13, lbl_8063F2C8-_SDA_BASE_ /* 801DAAC8 001D6728 38 80 00 04 */ li r4, 4 diff --git a/asm/code_801DAAE0.s b/asm/code_801DAAE0.s index 8967364..eef5524 100644 --- a/asm/code_801DAAE0.s +++ b/asm/code_801DAAE0.s @@ -144,6 +144,7 @@ func_801DAC90: func_801DAC94: /* 801DAC94 001D68F4 38 A0 00 20 */ li r5, 0x20 /* 801DAC98 001D68F8 48 0B C2 90 */ b MEMAllocFromExpHeapEx + lbl_801DAC9C: /* 801DAC9C 001D68FC 94 21 FF E0 */ stwu r1, -0x20(r1) /* 801DACA0 001D6900 7C 08 02 A6 */ mflr r0 diff --git a/asm/ctors.s b/asm/ctors.s index cdc9625..71b7934 100644 --- a/asm/ctors.s +++ b/asm/ctors.s @@ -33,7 +33,7 @@ lbl_803E1E60: .4byte func_8016A08C, func_8016E298, func_8016EFAC, func_801708BC .4byte func_80176E94, func_80177C04, func_8017B498, func_8017C568 .4byte func_8017C960, func_8017CC78, func_8017E3E0, func_8017E940 - .4byte func_80185ACC, func_80187768, func_8019BEA4, func_801DAAC0 + .4byte func_80185ACC, func_80187768, func_8019BEA4, __sinit_$3code_801DAA30_cpp .4byte func_801DB020, func_801DB7FC, func_801DBB1C, func_801DBE70 .4byte func_801DCE4C, func_801DD5A8, func_801DD8A0, func_801DDF58 .4byte func_801DF020, func_801E07C8, func_801E07F0, func_801E0A34 diff --git a/include/types.h b/include/types.h index 01c7fbf..7df137c 100644 --- a/include/types.h +++ b/include/types.h @@ -25,6 +25,8 @@ typedef volatile s64 vs64; typedef float f32; typedef volatile f32 vf32; +typedef unsigned long size_t; + typedef int BOOL; #define TRUE 1 #define FALSE 0 diff --git a/obj_files.mk b/obj_files.mk index 88b0b1a..918db55 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -214,7 +214,7 @@ TEXT_O_FILES := \ $(BUILD_DIR)/asm/MetroTRK/MWCriticalSection_gc.o \ $(BUILD_DIR)/asm/SDK/NdevExi2A/DebuggerDriver.o \ $(BUILD_DIR)/asm/SDK/NdevExi2A/exi2.o \ - $(BUILD_DIR)/asm/code_801DAA30.o \ + $(BUILD_DIR)/src/code_801DAA30.o \ $(BUILD_DIR)/asm/code_801DAAE0.o \ $(BUILD_DIR)/asm/code_801DB040.o \ $(BUILD_DIR)/asm/code_801DB81C.o \ diff --git a/src/code_801DAA30.cpp b/src/code_801DAA30.cpp new file mode 100644 index 0000000..348f4e8 --- /dev/null +++ b/src/code_801DAA30.cpp @@ -0,0 +1,49 @@ +#include "types.h" + +extern "C" +{ + BOOL func_801DAB28(void); + void *func_801DAD64(size_t); + void func_801DAEA4(void *); +} + +class unkStruct +{ + u8 unk0; + u16 unk2; + u8 unk4; + u8 unk5; + u8 unk6; + u8 unk7; +public: + unkStruct(u8 p1, u16 p2, u8 p3) + : unk0(p1), unk2(p2), unk4(p3) { } +}; + +unkStruct unk(1, 4, 0); + +void* operator new(size_t sz) +{ + if (func_801DAB28()) + return func_801DAD64(sz); + else + return NULL; +} + +void* operator new[](size_t sz) +{ + if (func_801DAB28()) + return func_801DAD64(sz); + else + return NULL; +} + +void operator delete(void* ptr) +{ + func_801DAEA4(ptr); +} + +void operator delete[](void* ptr) +{ + func_801DAEA4(ptr); +} -- cgit v1.2.3