From 4c5341831c0af7573552629a76b9ef5baadc81a9 Mon Sep 17 00:00:00 2001 From: Demki Date: Fri, 1 May 2020 09:08:03 +0300 Subject: add thumb/arm macros and change makefiles to reflect that. and decompilation of FUN_020910A4.c --- arm9/src/FUN_02000DF4.c | 2 +- arm9/src/FUN_020910A4.c | 10 ++++++++++ arm9/src/main.c | 3 +-- arm9/src/script.c | 26 +++++++++++++------------- arm9/src/string_util.c | 16 ++++++++-------- 5 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 arm9/src/FUN_020910A4.c (limited to 'arm9/src') diff --git a/arm9/src/FUN_02000DF4.c b/arm9/src/FUN_02000DF4.c index 0099480c..80e80b30 100644 --- a/arm9/src/FUN_02000DF4.c +++ b/arm9/src/FUN_02000DF4.c @@ -3,7 +3,7 @@ extern struct Unk2106FA0 gBacklightTop; -void FUN_02000DF4(void) +THUMB_FUNC void FUN_02000DF4(void) { gBacklightTop.unk8 = -1; gBacklightTop.unkC = 0; diff --git a/arm9/src/FUN_020910A4.c b/arm9/src/FUN_020910A4.c new file mode 100644 index 00000000..850486d4 --- /dev/null +++ b/arm9/src/FUN_020910A4.c @@ -0,0 +1,10 @@ +#include "global.h" + +void * (* gUnk021C8C70)(u32); + +ARM_FUNC void* FUN_020910A4(u32 size) +{ + if (gUnk021C8C70 != NULL) + return gUnk021C8C70(size); + return OS_AllocFromHeap(OS_ARENA_MAIN, -1, size); +} diff --git a/arm9/src/main.c b/arm9/src/main.c index bfd6c82e..73b63332 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -3,7 +3,6 @@ extern struct Unk2106FA0 gBacklightTop; extern struct Unk2106FA0 gBacklightTop_2; // same as the first one, it's referenced twice in the constant pool... -extern struct Unk2106FA0 gUnknown2106FB8; extern struct Unk21C48B8 gUnknown21C48B8; extern s32 gUnk027FFC20; @@ -24,7 +23,7 @@ extern struct Unk21DBE18 gUnk021DBE18; extern struct Unk21DBE18 gUnk021D76C8; -void NitroMain(void) +THUMB_FUNC void NitroMain(void) { InitSystemForTheGame(); InitGraphicMemory(); diff --git a/arm9/src/script.c b/arm9/src/script.c index 7a7ae894..cb218b1a 100644 --- a/arm9/src/script.c +++ b/arm9/src/script.c @@ -3,7 +3,7 @@ u16 ScriptReadHalfword(struct ScriptContext *ctx); -void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTableEnd) +THUMB_FUNC void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTableEnd) { u32 i; @@ -23,33 +23,33 @@ void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTable ctx->unk74 = 0; } -u8 SetupBytecodeScript(struct ScriptContext *ctx, const u8 *ptr) +THUMB_FUNC u8 SetupBytecodeScript(struct ScriptContext *ctx, const u8 *ptr) { ctx->scriptPtr = ptr; ctx->mode = 1; return 1; } -void SetupNativeScript(struct ScriptContext *ctx, u8 (*ptr)(struct ScriptContext *)) +THUMB_FUNC void SetupNativeScript(struct ScriptContext *ctx, u8 (*ptr)(struct ScriptContext *)) { ctx->mode = 2; ctx->nativePtr = ptr; } -void StopScript(struct ScriptContext *ctx) +THUMB_FUNC void StopScript(struct ScriptContext *ctx) { ctx->mode = 0; ctx->scriptPtr = 0; } -void FUN_02038B6C(struct ScriptContext *ctx, int r1) +THUMB_FUNC void FUN_02038B6C(struct ScriptContext *ctx, int r1) { ctx->unk74 = r1; } extern void ErrorHandling(void); -u8 RunScriptCommand(struct ScriptContext *ctx) +THUMB_FUNC u8 RunScriptCommand(struct ScriptContext *ctx) { if (ctx->mode == 0) return FALSE; @@ -97,7 +97,7 @@ u8 RunScriptCommand(struct ScriptContext *ctx) return TRUE; } -u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr) +THUMB_FUNC u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr) { if (ctx->stackDepth + 1 >= 20) { @@ -111,7 +111,7 @@ u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr) } } -const u8 *ScriptPop(struct ScriptContext *ctx) +THUMB_FUNC const u8 *ScriptPop(struct ScriptContext *ctx) { if (ctx->stackDepth == 0) return NULL; @@ -120,31 +120,31 @@ const u8 *ScriptPop(struct ScriptContext *ctx) return ctx->stack[ctx->stackDepth]; } -void ScriptJump(struct ScriptContext *ctx, const u8 *ptr) +THUMB_FUNC void ScriptJump(struct ScriptContext *ctx, const u8 *ptr) { ctx->scriptPtr = ptr; } -u8 ScriptCall(struct ScriptContext *ctx, const u8 *ptr) +THUMB_FUNC u8 ScriptCall(struct ScriptContext *ctx, const u8 *ptr) { u8 ret = ScriptPush(ctx, ctx->scriptPtr); ctx->scriptPtr = ptr; return ret; } -void ScriptReturn(struct ScriptContext *ctx) +THUMB_FUNC void ScriptReturn(struct ScriptContext *ctx) { ctx->scriptPtr = ScriptPop(ctx); } -u16 ScriptReadHalfword(struct ScriptContext *ctx) +THUMB_FUNC u16 ScriptReadHalfword(struct ScriptContext *ctx) { u16 value = *(ctx->scriptPtr++); value += *(ctx->scriptPtr++) << 8; return value; } -u32 ScriptReadWord(struct ScriptContext *ctx) +THUMB_FUNC u32 ScriptReadWord(struct ScriptContext *ctx) { u32 value0 = *(ctx->scriptPtr++); u32 value1 = *(ctx->scriptPtr++); diff --git a/arm9/src/string_util.c b/arm9/src/string_util.c index 8f9c96ff..6c949e88 100644 --- a/arm9/src/string_util.c +++ b/arm9/src/string_util.c @@ -34,7 +34,7 @@ s32 gPowersOfTen[] = { static const u16 EOS = 0xFFFF; -void StringCopy(u16 *dest, const u16 *src) +THUMB_FUNC void StringCopy(u16 *dest, const u16 *src) { u16 c = *src; while (c != EOS) { @@ -46,7 +46,7 @@ void StringCopy(u16 *dest, const u16 *src) *dest = EOS; } -u16 *StringCopyN(u16 *dest, const u16 *src, u32 num) +THUMB_FUNC u16 *StringCopyN(u16 *dest, const u16 *src, u32 num) { u32 copied = 0; if (num > copied) { @@ -62,7 +62,7 @@ u16 *StringCopyN(u16 *dest, const u16 *src, u32 num) return dest + num; } -u32 StringLength(const u16 *s) +THUMB_FUNC u32 StringLength(const u16 *s) { u16 c = *s; u32 len = 0; @@ -74,7 +74,7 @@ u32 StringLength(const u16 *s) return len; } -BOOL StringNotEqual(const u16 *s1, const u16 *s2) +THUMB_FUNC BOOL StringNotEqual(const u16 *s1, const u16 *s2) { for (; *s1 == *s2; s1++, s2++) { if (*s1 == EOS) @@ -83,7 +83,7 @@ BOOL StringNotEqual(const u16 *s1, const u16 *s2) return TRUE; } -BOOL StringNotEqualN(const u16 *s1, const u16 *s2, u32 num) +THUMB_FUNC BOOL StringNotEqualN(const u16 *s1, const u16 *s2, u32 num) { u16 c1, c2; c2 = *s2; @@ -104,7 +104,7 @@ BOOL StringNotEqualN(const u16 *s1, const u16 *s2, u32 num) return TRUE; } -u16 *StringFill(u16 *dest, u16 value, u32 num) +THUMB_FUNC u16 *StringFill(u16 *dest, u16 value, u32 num) { u32 copied = 0; if (num > copied) { @@ -118,7 +118,7 @@ u16 *StringFill(u16 *dest, u16 value, u32 num) return dest + copied; } -u16 *StringFillEOS(u16 *dest, u32 num) +THUMB_FUNC u16 *StringFillEOS(u16 *dest, u32 num) { return StringFill(dest, EOS, num); } @@ -131,7 +131,7 @@ enum PrintingMode { const u16 NON_DIGIT = 0xE2; -u16 *ConvertUIntToDecimalString(u16 *dest, u32 value, enum PrintingMode mode, u32 n) +THUMB_FUNC u16 *ConvertUIntToDecimalString(u16 *dest, u32 value, enum PrintingMode mode, u32 n) { for (u32 x = gPowersOfTen[n - 1]; x != 0; x = x / 10) { u16 res = value / x; -- cgit v1.2.3