2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
typedef void (*arg3_800FC868)(void*);
|
2020-03-22 21:19:43 +00:00
|
|
|
typedef void (*arg3_800FC8D8)(void*, u32);
|
|
|
|
typedef void (*arg3_800FC948)(void*, u32, u32, u32, u32, u32, u32, u32, u32);
|
|
|
|
typedef void (*arg3_800FCA18)(void*, u32);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
typedef struct InitFunc {
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 nextOffset;
|
|
|
|
void (*func)(void);
|
|
|
|
} InitFunc;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
// .data
|
|
|
|
void* sInitFuncs = NULL;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2023-11-12 21:59:52 +00:00
|
|
|
char sNew[] = "new";
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
char D_80134488[0x18] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00,
|
|
|
|
0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
|
2020-03-17 04:31:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// possibly some kind of new() function
|
2020-03-22 21:19:43 +00:00
|
|
|
void* func_800FC800(u32 size) {
|
|
|
|
if (size == 0) {
|
2020-03-17 04:31:30 +00:00
|
|
|
size = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return __osMallocDebug(&gSystemArena, size, sNew, 0);
|
|
|
|
}
|
|
|
|
|
2022-05-15 14:38:31 +00:00
|
|
|
// possibly some kind of delete() function
|
2020-03-22 21:19:43 +00:00
|
|
|
void func_800FC83C(void* ptr) {
|
|
|
|
if (ptr != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
__osFree(&gSystemArena, ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void func_800FC868(void* blk, u32 nBlk, u32 blkSize, arg3_800FC868 arg3) {
|
2020-03-17 04:31:30 +00:00
|
|
|
u32 pos;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
for (pos = (u32)blk; pos < (u32)blk + (nBlk * blkSize); pos = (u32)pos + (blkSize & ~0)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
arg3((void*)pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void func_800FC8D8(void* blk, u32 nBlk, s32 blkSize, arg3_800FC8D8 arg3) {
|
2020-03-17 04:31:30 +00:00
|
|
|
u32 pos;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
for (pos = (u32)blk; pos < (u32)blk + (nBlk * blkSize); pos = (u32)pos + (blkSize & ~0)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
arg3((void*)pos, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void* func_800FC948(void* blk, u32 nBlk, u32 blkSize, arg3_800FC948 arg3) {
|
2020-03-17 04:31:30 +00:00
|
|
|
u32 pos;
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (blk == NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
blk = func_800FC800(nBlk * blkSize);
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (blk != NULL && arg3 != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
pos = (u32)blk;
|
2020-03-22 21:19:43 +00:00
|
|
|
while (pos < (u32)blk + (nBlk * blkSize)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
arg3((void*)pos, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
pos = (u32)pos + (blkSize & ~0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return blk;
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void func_800FCA18(void* blk, u32 nBlk, u32 blkSize, arg3_800FCA18 arg3, s32 arg4) {
|
2020-03-17 04:31:30 +00:00
|
|
|
u32 pos;
|
2020-03-22 21:19:43 +00:00
|
|
|
u32 end;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-10-04 05:18:50 +00:00
|
|
|
if (blk == NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-10-04 05:18:50 +00:00
|
|
|
if (arg3 != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
end = (u32)blk;
|
|
|
|
pos = (u32)end + (nBlk * blkSize);
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
while (pos > end) {
|
2022-05-15 14:38:31 +00:00
|
|
|
pos -= (s32)(blkSize & ~0);
|
2021-09-05 18:41:02 +00:00
|
|
|
arg3((void*)pos, 2);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (arg4 != 0) {
|
2020-03-17 04:31:30 +00:00
|
|
|
func_800FC83C(blk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void func_800FCB34(void) {
|
2021-02-14 00:49:40 +00:00
|
|
|
InitFunc* initFunc = (InitFunc*)&sInitFuncs;
|
|
|
|
u32 nextOffset = initFunc->nextOffset;
|
|
|
|
InitFunc* prev = NULL;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
while (nextOffset != 0) {
|
2020-03-17 04:31:30 +00:00
|
|
|
initFunc = (InitFunc*)((s32)initFunc + nextOffset);
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (initFunc->func != NULL) {
|
2023-11-12 21:59:52 +00:00
|
|
|
initFunc->func();
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nextOffset = initFunc->nextOffset;
|
|
|
|
initFunc->nextOffset = (s32)prev;
|
|
|
|
prev = initFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
sInitFuncs = prev;
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void SystemHeap_Init(void* start, u32 size) {
|
2020-03-17 04:31:30 +00:00
|
|
|
SystemArena_Init(start, size);
|
|
|
|
func_800FCB34();
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|