1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-02 07:46:01 +00:00
oot/src/code/code_800FC620.c
Dragorn421 4c75260097
Fix misc 21 (#1573)
* Make `sNew` in (unused) `code_800FC620.c` a string

It is passed as a filename to `__osMallocDebug` so should be a nul-terminated string, not a char[3] missing an explicit \0

* Fix gcc warning in `JpegDecoder_ParseNextSymbol` about SLL on negative value

-1U is an unsigned value, aka 0xFFFFFFFF
I keep -1 because it seems that's what a jpeg standard has too

References:
https://stackoverflow.com/questions/40508958/shifting-a-negative-signed-value-is-undefined
https://www.w3.org/Graphics/JPEG/itu-t81.pdf (page 105, figure F.12)

* Small cleanup

* Fix few mistakes (thanks gcc warnings)

* Add `@bug` in file select settings draw code, using the wrong array

* format

* format main

* rename arg for a happy formatter

* Move important function call out of a printf
2023-11-12 16:59:52 -05:00

117 lines
2.7 KiB
C

#include "global.h"
typedef void (*arg3_800FC868)(void*);
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);
typedef struct InitFunc {
s32 nextOffset;
void (*func)(void);
} InitFunc;
// .data
void* sInitFuncs = NULL;
char sNew[] = "new";
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,
};
// possibly some kind of new() function
void* func_800FC800(u32 size) {
if (size == 0) {
size = 1;
}
return __osMallocDebug(&gSystemArena, size, sNew, 0);
}
// possibly some kind of delete() function
void func_800FC83C(void* ptr) {
if (ptr != NULL) {
__osFree(&gSystemArena, ptr);
}
}
void func_800FC868(void* blk, u32 nBlk, u32 blkSize, arg3_800FC868 arg3) {
u32 pos;
for (pos = (u32)blk; pos < (u32)blk + (nBlk * blkSize); pos = (u32)pos + (blkSize & ~0)) {
arg3((void*)pos);
}
}
void func_800FC8D8(void* blk, u32 nBlk, s32 blkSize, arg3_800FC8D8 arg3) {
u32 pos;
for (pos = (u32)blk; pos < (u32)blk + (nBlk * blkSize); pos = (u32)pos + (blkSize & ~0)) {
arg3((void*)pos, 2);
}
}
void* func_800FC948(void* blk, u32 nBlk, u32 blkSize, arg3_800FC948 arg3) {
u32 pos;
if (blk == NULL) {
blk = func_800FC800(nBlk * blkSize);
}
if (blk != NULL && arg3 != NULL) {
pos = (u32)blk;
while (pos < (u32)blk + (nBlk * blkSize)) {
arg3((void*)pos, 0, 0, 0, 0, 0, 0, 0, 0);
pos = (u32)pos + (blkSize & ~0);
}
}
return blk;
}
void func_800FCA18(void* blk, u32 nBlk, u32 blkSize, arg3_800FCA18 arg3, s32 arg4) {
u32 pos;
u32 end;
if (blk == NULL) {
return;
}
if (arg3 != NULL) {
end = (u32)blk;
pos = (u32)end + (nBlk * blkSize);
while (pos > end) {
pos -= (s32)(blkSize & ~0);
arg3((void*)pos, 2);
}
}
if (arg4 != 0) {
func_800FC83C(blk);
}
}
void func_800FCB34(void) {
InitFunc* initFunc = (InitFunc*)&sInitFuncs;
u32 nextOffset = initFunc->nextOffset;
InitFunc* prev = NULL;
while (nextOffset != 0) {
initFunc = (InitFunc*)((s32)initFunc + nextOffset);
if (initFunc->func != NULL) {
initFunc->func();
}
nextOffset = initFunc->nextOffset;
initFunc->nextOffset = (s32)prev;
prev = initFunc;
}
sInitFuncs = prev;
}
void SystemHeap_Init(void* start, u32 size) {
SystemArena_Init(start, size);
func_800FCB34();
}