From 27ae64893aec81af4c78036f309b9aa9e7874c2e Mon Sep 17 00:00:00 2001 From: Yanis002 <35189056+Yanis002@users.noreply.github.com> Date: Wed, 12 Feb 2025 12:50:35 +0100 Subject: [PATCH 1/7] started debug display/error --- config/eur/arm9/delinks.txt | 7 + config/eur/arm9/symbols.txt | 28 +-- include/DTCM/UnkStruct_027e02a0.hpp | 10 + include/DTCM/UnkStruct_027e05f8.hpp | 4 + include/DTCM/UnkStruct_027e0618.hpp | 9 + include/DTCM/UnkStruct_027e08f8.hpp | 9 + include/Unknown/UnkStruct_02063220.hpp | 48 ++++ include/Unknown/UnkStruct_0206322c.hpp | 39 ++++ include/Unknown/UnkStruct_020ee734.hpp | 7 + include/global.h | 3 +- include/types.h | 1 + libs/c/include/stdarg.h | 24 ++ libs/nds/include/nds/button.h | 12 + src/Main/Unknown/UnkStruct_02063220.cpp | 292 ++++++++++++++++++++++++ src/Main/Unknown/UnkStruct_0206322c.cpp | 105 +++++++++ 15 files changed, 583 insertions(+), 15 deletions(-) create mode 100644 include/DTCM/UnkStruct_027e02a0.hpp create mode 100644 include/DTCM/UnkStruct_027e0618.hpp create mode 100644 include/DTCM/UnkStruct_027e08f8.hpp create mode 100644 include/Unknown/UnkStruct_02063220.hpp create mode 100644 include/Unknown/UnkStruct_0206322c.hpp create mode 100644 include/Unknown/UnkStruct_020ee734.hpp create mode 100644 libs/c/include/stdarg.h create mode 100644 libs/nds/include/nds/button.h create mode 100644 src/Main/Unknown/UnkStruct_02063220.cpp create mode 100644 src/Main/Unknown/UnkStruct_0206322c.cpp diff --git a/config/eur/arm9/delinks.txt b/config/eur/arm9/delinks.txt index 97a31c17..db4525c5 100644 --- a/config/eur/arm9/delinks.txt +++ b/config/eur/arm9/delinks.txt @@ -14,3 +14,10 @@ libs/cpp/src/__register_global_object.cpp: complete .text start:0x0204f8d4 end:0x0204f8f4 .bss start:0x02076da8 end:0x02076dac + +src/Main/Unknown/UnkStruct_0206322c.cpp: + .text start:0x02030354 end:0x020306c0 + +src/Main/Unknown/UnkStruct_02063220.cpp: + .text start:0x0202f3f0 end:0x0202f8e8 + .rodata start:0x020562e2 end:0x02056300 diff --git a/config/eur/arm9/symbols.txt b/config/eur/arm9/symbols.txt index 55963541..cb1185e3 100644 --- a/config/eur/arm9/symbols.txt +++ b/config/eur/arm9/symbols.txt @@ -1474,13 +1474,13 @@ func_0202f2f8 kind:function(arm,size=0x30) addr:0x202f2f8 func_0202f328 kind:function(arm,size=0x38) addr:0x202f328 func_0202f360 kind:function(thumb,size=0x14) addr:0x202f360 func_0202f374 kind:function(thumb,size=0x7c) addr:0x202f374 -func_0202f3f0 kind:function(thumb,size=0x10) addr:0x202f3f0 -func_0202f400 kind:function(thumb,size=0x18) addr:0x202f400 -DisplayAssertError kind:function(thumb,size=0x9c) addr:0x202f418 -func_0202f4b4 kind:function(thumb,size=0x4c) addr:0x202f4b4 -func_0202f500 kind:function(thumb,size=0x2c) addr:0x202f500 -DisplayException kind:function(thumb,size=0x228) addr:0x202f52c -func_0202f754 kind:function(thumb,size=0x194) addr:0x202f754 +_ZN18UnkStruct_0206322013func_0202f3f0Ei kind:function(thumb,size=0x10) addr:0x202f3f0 +_ZN18UnkStruct_0206322013func_0202f400Ei kind:function(thumb,size=0x18) addr:0x202f400 +_ZN18UnkStruct_0206322018DisplayAssertErrorEPctS0_z kind:function(thumb,size=0x9c) addr:0x202f418 +_ZN18UnkStruct_0206322013func_0202f4b4Ev kind:function(thumb,size=0x4c) addr:0x202f4b4 +_ZN18UnkStruct_0206322013func_0202f500Ev kind:function(thumb,size=0x2c) addr:0x202f500 +_ZN18UnkStruct_0206322016DisplayExceptionEP9Registers kind:function(thumb,size=0x228) addr:0x202f52c +_ZN18UnkStruct_0206322013func_0202f754Ei kind:function(thumb,size=0x194) addr:0x202f754 func_0202f8e8 kind:function(thumb,size=0x30) addr:0x202f8e8 func_0202f918 kind:function(thumb,size=0x88) addr:0x202f918 func_0202f9a0 kind:function(arm,size=0x88) addr:0x202f9a0 @@ -1539,16 +1539,16 @@ _ZN18DebugHierarchyBase8vfunc_2cEv kind:function(thumb,size=0x4) addr:0x2030344 _ZN18DebugHierarchyBase8vfunc_30Ev kind:function(thumb,size=0x4) addr:0x2030348 _ZN18DebugHierarchyBase8vfunc_38Ev kind:function(thumb,size=0x4) addr:0x203034c _ZN18DebugHierarchyBase8vfunc_3cEv kind:function(thumb,size=0x4) addr:0x2030350 -func_02030354 kind:function(thumb,size=0xb4) addr:0x2030354 -func_02030408 kind:function(thumb,size=0x18) addr:0x2030408 +_ZN18UnkStruct_0206322c13func_02030354Ebb kind:function(thumb,size=0xb4) addr:0x2030354 +_ZN18UnkStruct_0206322c13func_02030408Ev kind:function(thumb,size=0x18) addr:0x2030408 func_02030420 kind:function(thumb,size=0x44) addr:0x2030420 -func_02030464 kind:function(thumb,size=0x44) addr:0x2030464 -func_020304a8 kind:function(thumb,size=0x2c) addr:0x20304a8 +_ZN18UnkStruct_0206322c13func_02030464Ebb kind:function(thumb,size=0x44) addr:0x2030464 +_ZN18UnkStruct_0206322c13func_020304a8Ebb kind:function(thumb,size=0x2c) addr:0x20304a8 DisplayDebugText kind:function(thumb,size=0xd8) addr:0x20304d4 func_020305ac kind:function(thumb,size=0x88) addr:0x20305ac -DisplayDebugTextFormat kind:function(thumb,size=0x30) addr:0x2030634 -DisplayDebugTextFormat_thunk kind:function(thumb,size=0x28) addr:0x2030664 -DisplayDebugTextF kind:function(thumb,size=0x34) addr:0x203068c +_Z22DisplayDebugTextFormatiiiiiPcS_ kind:function(thumb,size=0x30) addr:0x2030634 +_Z28DisplayDebugTextFormat_thunkiiiiiPcz kind:function(thumb,size=0x28) addr:0x2030664 +_Z17DisplayDebugTextFiiiiPcz kind:function(thumb,size=0x34) addr:0x203068c func_020306c0 kind:function(thumb,size=0x70) addr:0x20306c0 func_02030730 kind:function(thumb,size=0x28) addr:0x2030730 func_02030758 kind:function(thumb,size=0x84) addr:0x2030758 diff --git a/include/DTCM/UnkStruct_027e02a0.hpp b/include/DTCM/UnkStruct_027e02a0.hpp new file mode 100644 index 00000000..d533bb4f --- /dev/null +++ b/include/DTCM/UnkStruct_027e02a0.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include "types.h" + +struct UnkStruct_027e02a0 { + unk8 mUnk_00[0x94]; + unk32 mUnk_94[23]; +}; + +extern UnkStruct_027e02a0* data_027e02a0; diff --git a/include/DTCM/UnkStruct_027e05f8.hpp b/include/DTCM/UnkStruct_027e05f8.hpp index 43e83540..40d8d731 100644 --- a/include/DTCM/UnkStruct_027e05f8.hpp +++ b/include/DTCM/UnkStruct_027e05f8.hpp @@ -5,6 +5,8 @@ struct UnkStruct_027e05f8 { // TODO: Add fields + unk16 mUnk_00; + u16 mUnk_02; void func_0202adf4(unk32 param1, s32 param2); ~UnkStruct_027e05f8(); @@ -15,3 +17,5 @@ struct UnkStruct_027e05f8 { void func_02037480(); static unk32 func_02037490(unk32 param1); }; + +extern UnkStruct_027e05f8 data_027e05f8; diff --git a/include/DTCM/UnkStruct_027e0618.hpp b/include/DTCM/UnkStruct_027e0618.hpp new file mode 100644 index 00000000..7489cee5 --- /dev/null +++ b/include/DTCM/UnkStruct_027e0618.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include "types.h" + +struct UnkStruct_027e0618 { + void func_0202cf34(void); +}; + +extern UnkStruct_027e0618 data_027e0618; diff --git a/include/DTCM/UnkStruct_027e08f8.hpp b/include/DTCM/UnkStruct_027e08f8.hpp new file mode 100644 index 00000000..c4f91b86 --- /dev/null +++ b/include/DTCM/UnkStruct_027e08f8.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include "types.h" + +struct UnkStruct_027e08f8 { + void func_0202f9a0(unk32); +}; + +extern UnkStruct_027e08f8 data_027e08f8; diff --git a/include/Unknown/UnkStruct_02063220.hpp b/include/Unknown/UnkStruct_02063220.hpp new file mode 100644 index 00000000..ccdaea85 --- /dev/null +++ b/include/Unknown/UnkStruct_02063220.hpp @@ -0,0 +1,48 @@ +#pragma once + +#include "global.h" +#include "types.h" + +struct Registers { + /* 00 */ unk32 mUnk_00; // CPSR + /* 04 */ unk32 mUnk_04[12]; + /* 08 */ unk32 mUnk_08; + /* 0C */ unk32 mUnk_0C; // SP + /* 10 */ unk32 mUnk_10; // LR + /* 14 */ unk32 mUnk_14; // PC + /* 18 */ unk32 mUnk_18; + /* 1C */ unk32 mUnk_1C; + /* 20 */ unk32 mUnk_20; + /* 24 */ unk32 mUnk_24; + /* 28 */ unk32 mUnk_28; + /* 2C */ unk32 mUnk_2C; + /* 30 */ unk32 mUnk_30; + /* 34 */ unk32 mUnk_34; + /* 38 */ unk32 mUnk_38; // CP15 + /* 3C */ unk32 mUnk_3C; // SPSR +}; + +struct UnkStruct_02063220_08 { + unk32 mUnk_00; + + void func_0202fd9c(unk32); +}; + +class UnkStruct_02063220 { +public: + /* 00 */ char* path; + /* 04 */ u8 mUnk_04; + /* 05 */ u8 mUnk_05; + /* 06 */ unk16 mUnk_06; + /* 08 */ UnkStruct_02063220_08 mUnk_08; + + void DisplayAssertError(char* file, u16 line, char* msg, ...); + void DisplayException(Registers* param1); + static bool func_0202f3f0(unk32 param1); + static unk32 func_0202f400(unk32 param1); + void func_0202f4b4(void); + void func_0202f500(void); + void func_0202f754(unk32); +}; + +extern UnkStruct_02063220 data_02063220; diff --git a/include/Unknown/UnkStruct_0206322c.hpp b/include/Unknown/UnkStruct_0206322c.hpp new file mode 100644 index 00000000..d28cd0f4 --- /dev/null +++ b/include/Unknown/UnkStruct_0206322c.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include "types.h" + +#define SCREEN_WIDTH 32 +#define SCREEN_HEIGHT 24 + +struct Screen { + /* 000 */ unk16 mUnk_00; + /* 002 */ unk16 mUnk_02; + /* 004 */ unk16 mUnk_04; + /* 004 */ unk16 mUnk_06; + /* 008 */ unk32 mUnk_08; + /* 00c */ u16 data[SCREEN_WIDTH * SCREEN_HEIGHT]; + /* 60c */ +}; + +class UnkStruct_0206322c { +public: + /* 000 */ UNK_PTR mUnk_00; // tile + /* 004 */ UNK_PTR mUnk_04; // palette + /* 008 */ Screen topScreen; + /* 614 */ Screen bottomScreen; + /* c20 */ + + // loads the debug font (palette and tile files) + void func_02030354(bool doTopScreen, bool doBottomScreen); + + // ctor? + void* func_02030408(void); + + // copy the screen data to VRAM + void func_02030464(bool doTopScreen, bool doBottomScreen); + + // reset screen data + void func_020304a8(bool doTopScreen, bool doBottomScreen); +}; + +extern UnkStruct_0206322c data_0206322c; diff --git a/include/Unknown/UnkStruct_020ee734.hpp b/include/Unknown/UnkStruct_020ee734.hpp new file mode 100644 index 00000000..18e24d39 --- /dev/null +++ b/include/Unknown/UnkStruct_020ee734.hpp @@ -0,0 +1,7 @@ +#pragma once + +struct UnkStruct_020ee734 { + void func_ov000_020d6620(void); +}; + +extern UnkStruct_020ee734 data_ov000_020ee734; diff --git a/include/global.h b/include/global.h index 593c720b..ca961164 100644 --- a/include/global.h +++ b/include/global.h @@ -5,7 +5,8 @@ #define SET_FLAG(arr, pos) ((arr)[((u32) (pos)) >> 5] |= 1 << ((pos) & 0x1f)) #define RESET_FLAG(arr, pos) ((arr)[((u32) (pos)) >> 5] &= ~(1 << ((pos) & 0x1f))) -#define ARRAY_LEN(arr) ((sizeof(arr) / sizeof(*arr))) +#define ARRAY_LEN_U(arr) (u32)((sizeof(arr) / sizeof(*arr))) +#define ARRAY_LEN(arr) (s32)(sizeof(arr) / sizeof(*arr)) // Prevent the IDE from reporting errors that the compiler/linker won't report #ifdef __INTELLISENSE__ diff --git a/include/types.h b/include/types.h index 03e8352f..4d6bc6c1 100644 --- a/include/types.h +++ b/include/types.h @@ -22,5 +22,6 @@ typedef s32 bool; #endif #define CEIL_DIV(a, b) (((a) + (b) - 1) / (b)) +#define UNK_PTR unk32* #endif diff --git a/libs/c/include/stdarg.h b/libs/c/include/stdarg.h new file mode 100644 index 00000000..a47e0f01 --- /dev/null +++ b/libs/c/include/stdarg.h @@ -0,0 +1,24 @@ +#ifndef _C_STDARG_H +#define _C_STDARG_H + +extern "C" { + typedef char* va_list; + + #define __std(ref) ::std::ref + #define __fourbytealign(n) ((((unsigned long)(n)) + 3U) & ~3U) + #define __va_start(parm) ((__std(va_list)) ((char *)((unsigned long)(&parm) & ~3U) + __fourbytealign(sizeof(parm)))) + + #define va_start(ap, parm) ((ap) = __va_start(parm)) + #define va_arg(ap, type) (*(type *)((ap += __fourbytealign(sizeof(type))) - __fourbytealign(sizeof(type)))) + #define va_end(ap) ((void)0) +} + +#if defined(__cplusplus) +namespace std { + using ::va_list; +}; + +using std::va_list; +#endif + +#endif diff --git a/libs/nds/include/nds/button.h b/libs/nds/include/nds/button.h new file mode 100644 index 00000000..90ee060d --- /dev/null +++ b/libs/nds/include/nds/button.h @@ -0,0 +1,12 @@ +#pragma once + +#define BTN_A (1 << 0) // 0x0001 +#define BTN_B (1 << 1) // 0x0002 +#define BTN_SELECT (1 << 2) // 0x0004 +#define BTN_START (1 << 3) // 0x0008 +#define BTN_DRIGHT (1 << 4) // 0x0010 +#define BTN_DLEFT (1 << 5) // 0x0020 +#define BTN_DUP (1 << 6) // 0x0040 +#define BTN_DDOWN (1 << 7) // 0x0080 +#define BTN_R (1 << 8) // 0x0100 +#define BTN_L (1 << 9) // 0x0200 diff --git a/src/Main/Unknown/UnkStruct_02063220.cpp b/src/Main/Unknown/UnkStruct_02063220.cpp new file mode 100644 index 00000000..80760330 --- /dev/null +++ b/src/Main/Unknown/UnkStruct_02063220.cpp @@ -0,0 +1,292 @@ +#include +#include +#include "nds/math.h" +#include "nds/button.h" +#include "System/OverlayManager.hpp" +#include "DTCM/UnkStruct_027e02a0.hpp" +#include "DTCM/UnkStruct_027e05f8.hpp" +#include "DTCM/UnkStruct_027e0618.hpp" +#include "DTCM/UnkStruct_027e08f8.hpp" +#include "Unknown/UnkStruct_02063220.hpp" +#include "Unknown/UnkStruct_020ee734.hpp" +#include "Unknown/UnkStruct_0206322c.hpp" + +void DisplayDebugText(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char*, unk32); +void DisplayDebugTextFormat(unk32 param1, unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char* fmt, va_list args); +void DisplayDebugTextFormat_thunk(unk32 param1, unk32 param2, unk32 param3, unk32 param4, unk32 param5, char* fmt, ...); +void DisplayDebugTextF(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char* fmt, ...); +extern u8 data_02075ebc; + +extern "C" { + void func_0200f248(); + void func_0202bac4(); + void func_0202c5e8(void); + void func_0202cf34(unk32); + void func_0202d164(); + void func_0202e6a4(void); + void func_0203e8a0(void); + void func_0202f374(); + + // probably GX/GXS functions? + void func_02003ce4(unk32); + void func_02004730(unk32); + void func_02003a9c(unk32, unk32, unk32); + void func_02003b04(unk32); + void SetBrightColor(u16*, unk32); +} + +#define ITCM_END ((s8*)0x01FFFFFF) +#define ARM9_RAM_START ((s8*)0x02000000) +#define ARM9_RAM_END ((s8*)0x0219B1C0) + +#define REG_A_DISPCNT (*(u32*)0x04000000) +#define REG_A_2D_ENGINE (*(u16*)0x04000008) +#define REG_A_MASTER_BRIGHT ((u16*)0x0400006C) +#define REG_B_DISPCNT_ADDR (0x04001000) +#define REG_B_DISPCNT (*(u32*)REG_B_DISPCNT_ADDR) +#define REG_B_2D_ENGINE (*(u16*)0x04001008) +#define REG_B_MASTER_BRIGHT ((u16*)0x0400106C) + +u16 data_020562e2[] = { + BTN_DUP, + BTN_DDOWN, + BTN_DDOWN, + BTN_DUP, + BTN_SELECT, + BTN_B, + BTN_R, + BTN_START, + BTN_DLEFT, + BTN_DLEFT, + BTN_DRIGHT, + BTN_DLEFT, + BTN_START, + BTN_DUP, +}; + +THUMB bool UnkStruct_02063220::func_0202f3f0(unk32 param1) { + switch (param1) { + case 2: + case 3: + return true; + default: + break; + } + + return false; +} + +THUMB unk32 UnkStruct_02063220::func_0202f400(unk32 param1) { + unk32 ret = 0; + + switch (param1) { + case 2: + ret = 1; + break; + case 3: + ret = 2; + break; + default: + break; + } + + return ret; +} + +THUMB void UnkStruct_02063220::DisplayAssertError(char* file, u16 line, char* msg, ...) { + va_list args; + + data_0206322c.func_020304a8(true, true); + DisplayDebugText(0, 0, false, true, "Assert", 0); + DisplayDebugTextF(0, 2, false, true, "FILE:%s", file); + DisplayDebugTextF(0, 3, false, true, "LINE:%d", line); + va_start(args, msg); + DisplayDebugTextFormat(0, 0, 5, false, true, msg, args); + va_end(args); + func_0202f374(); + func_0202d164(); + this->func_0202f4b4(); + this->func_0202f754(0); +} + +// non-matching +THUMB void UnkStruct_02063220::func_0202f4b4(void) { + char buffer[0x40]; + + if (this->path != NULL) { + DisplayDebugText(0, 21, 0, 0, "(LastFile)", 1); + strncpy(buffer, this->path, sizeof(buffer) - 1); + buffer[0] = '\0'; + DisplayDebugText(0, 22, 0, 0, buffer, 1); + } +} + +THUMB void UnkStruct_02063220::func_0202f500(void) { + DisplayDebugTextF(16, 0, 0, 1, "レイガイチュウ(%d,%d)", data_02075ebc, this->mUnk_05); +} + +// non-matching +THUMB void UnkStruct_02063220::DisplayException(Registers* param1) { + int iVar1; + s8 *pbVar2; + int iVar3; + s32 *puVar4; + int *piVar5; + + if (this->mUnk_05 != 0) { + this->func_0202f500(); + } else { + this->mUnk_05++; + this->mUnk_05++; + + data_0206322c.func_020304a8(true, true); + this->mUnk_05++; + + DisplayDebugText(0, 0, false, false, "レイガイ_ハセイ", 0); + this->mUnk_05++; + + if (data_02075ebc != 0) { + this->func_0202f500(); + this->mUnk_05++; + } + + for (iVar3 = 0; iVar3 < ARRAY_LEN(param1->mUnk_04); iVar3++) { + DisplayDebugTextF(0, iVar3 + 2, 0, 0, "R%02d__=_0x%08X", iVar3, param1->mUnk_04[iVar3]); + this->mUnk_05++; + } + + DisplayDebugTextF(0, 15, 0, 0, "SP___=_0x%08X", param1->mUnk_0C); + this->mUnk_05++; + + DisplayDebugTextF(0, 16, 0, 1, "LR___=_0x%08X", param1->mUnk_10); + this->mUnk_05++; + + DisplayDebugTextF(0, 17, 0, 1, "PC___=_0x%08X", param1->mUnk_14); + this->mUnk_05++; + + DisplayDebugTextF(0, 18, 0, 0, "CPSR_=_0x%08X", param1->mUnk_00); + this->mUnk_05++; + + DisplayDebugTextF(0, 19, 0, 0, "SPSR_=_0x%08X", param1->mUnk_3C); + this->mUnk_05++; + + DisplayDebugTextF(0, 20, 0, 0, "CP15_=_0x%08X", param1->mUnk_38); + this->mUnk_05++; + + func_0202f374(); + this->mUnk_05++; + + func_0203e8a0(); + this->mUnk_05++; + + func_0202d164(); + this->mUnk_05++; + + func_0202e6a4(); + this->mUnk_05++; + + this->func_0202f4b4(); + this->mUnk_05++; + + puVar4 = param1->mUnk_04; + DisplayDebugText(21, 0, 0, 0, "SP", 1); + DisplayDebugTextFormat_thunk(1, 23, 0, 0, 0, "%08X", puVar4); + + iVar3 = 1; + + for (iVar3 = 1; puVar4 < data_027e02a0[1].mUnk_94; puVar4++) { + pbVar2 = (s8*)puVar4; + + if ((ITCM_END < pbVar2 && pbVar2 < ARM9_RAM_END) || pbVar2 < ARM9_RAM_START) { + DisplayDebugTextFormat_thunk(1, 23, iVar3, 0, 0, "%08X", pbVar2); + iVar3++; + if (iVar3 > 0x17) { + break; + } + } + } + + this->mUnk_05++; + } + + this->func_0202f754(1); +} + +THUMB void UnkStruct_02063220::func_0202f754(unk32 param1) { + u16 uVar1; + int iVar3; + u16 uVar4; + bool bVar5; + bool bVar6; + + func_0202c5e8(); + this->mUnk_04 = 0; + this->mUnk_05 = 0; + + if (this->func_0202f3f0(param1) != 0) { + this->mUnk_08.func_0202fd9c(this->func_0202f400(param1)); + } else { + func_02003ce4(2); + func_02004730(4); + func_02003a9c(1, 0, 0); + func_02003b04(0); + + REG_A_DISPCNT = (REG_A_DISPCNT & 0xFFFFE0FF) | 0x100; + REG_B_DISPCNT = (REG_B_DISPCNT & 0xFFFFE0FF) | (REG_B_DISPCNT_ADDR >> 0x12); + REG_A_2D_ENGINE = (REG_A_2D_ENGINE & 0x43) | 0x4; + REG_B_2D_ENGINE = (REG_B_2D_ENGINE & 0x43) | 0x4; + data_0206322c.func_02030354(1, 1); + } + + do { + if (this->func_0202f3f0(param1)) { + bVar6 = true; + } else { + data_027e05f8.func_0202adf4(1, 0); + + if (param1 != 1) { + data_027e08f8.func_0202f9a0(1); + } + + uVar1 = data_027e05f8.mUnk_02; + uVar4 = data_020562e2[this->mUnk_04]; + bVar5 = (uVar1 & uVar4) != 0; + + if (bVar5) { + bVar6 = false; + + if (((~uVar4 & 0xFFF) & (~uVar1 & 0xFFFF)) != 0 && (uVar1 & 0xFFF) != 0) { + this->mUnk_04 = 0; + } + } + } + + this->mUnk_04++; + if (this->mUnk_04 >= 0xC ? 1 : 0) { + this->func_0202f3f0(param1); + } + + func_0202bac4(); + + if (bVar6) { + SetBrightColor(REG_A_MASTER_BRIGHT, 0); + SetBrightColor(REG_B_MASTER_BRIGHT, 0); + + if (this->func_0202f3f0(param1) == 0) { + data_0206322c.func_02030464(1, 1); + } + + data_027e0618.func_0202cf34(); + + if (gOverlayManager.mLoadedOverlays[OverlayIndex_Core] != -1) { + data_ov000_020ee734.func_ov000_020d6620(); + } + + for (iVar3 = 0; iVar3 < 0x3C; iVar3++) { + func_0202bac4(); + } + + func_0200f248(); + } + } while(true); +} diff --git a/src/Main/Unknown/UnkStruct_0206322c.cpp b/src/Main/Unknown/UnkStruct_0206322c.cpp new file mode 100644 index 00000000..67338a78 --- /dev/null +++ b/src/Main/Unknown/UnkStruct_0206322c.cpp @@ -0,0 +1,105 @@ +#include +#include "global.h" +#include "types.h" +#include "Unknown/UnkStruct_0206322c.hpp" + +void func_02027ab4(unk32, Screen*, UNK_PTR, UNK_PTR, unk32, unk32, unk32, unk32); + +extern "C" { + unk32* MountCompressedNarc(char*, char*, unk8*, unk32, unk32); + unk8 data_020691a0[0xCC00]; + UNK_PTR func_02032054(char*, unk32); + UNK_PTR func_0203206c(char*, unk32); + void func_02016fcc(unk32*); + + void GX_LoadBG0Scr(u16 *data, unk32, u32 size); + void GXS_LoadBG0Scr(u16 *data, unk32, u32 size); + void CleanAndInvalidateDataCacheLines(void*, u32 size); // DC_FlushRange? + void Fill16(unk32, void*, u32 size); + int vsnprintf(char* s, size_t n, const char* format, va_list arg); +} + +THUMB void UnkStruct_0206322c::func_02030354(bool doTopScreen, bool doBottomScreen) { + Screen* pScreen; + unk32* uVar1; + + uVar1 = MountCompressedNarc("BGF", "Menu/UI_main/DbgFntM.bin", data_020691a0, sizeof(data_020691a0), 1); + this->mUnk_00 = func_02032054("BGF:DbgFntM.ncgr", 1); + this->mUnk_04 = func_0203206c("BGF:UIM.nclr", 1); + + if (doTopScreen) { + pScreen = &this->topScreen; + pScreen->mUnk_00 = 0x100; + pScreen->mUnk_02 = 0xC0; + pScreen->mUnk_04 = 0; + pScreen->mUnk_06 = 0; + pScreen->mUnk_08 = 0xC00; + func_02027ab4(0, pScreen, this->mUnk_00, this->mUnk_04, 0, 0, 0, 2); + } + + if (doBottomScreen) { + pScreen = &this->bottomScreen; + pScreen->mUnk_00 = 0x100; + pScreen->mUnk_02 = 0xC0; + pScreen->mUnk_04 = 0; + pScreen->mUnk_06 = 0; + pScreen->mUnk_08 = 0xC00; + func_02027ab4(4, pScreen, this->mUnk_00, this->mUnk_04, 0, 0, 0, 2); + } + + func_02016fcc(uVar1); +} + +THUMB void* UnkStruct_0206322c::func_02030408(void) { + this->mUnk_00 = NULL; + this->mUnk_04 = NULL; + this->func_020304a8(true, true); + return this; +} + +THUMB void UnkStruct_0206322c::func_02030464(bool doTopScreen, bool doBottomScreen) { + if (doTopScreen) { + CleanAndInvalidateDataCacheLines(&this->topScreen.data, sizeof(this->topScreen.data)); + GX_LoadBG0Scr(this->topScreen.data, 0, sizeof(this->topScreen.data)); + } + + if (doBottomScreen) { + CleanAndInvalidateDataCacheLines(&this->bottomScreen.data, sizeof(this->bottomScreen.data)); + GXS_LoadBG0Scr(this->bottomScreen.data, 0, sizeof(this->bottomScreen.data)); + } +} + +THUMB void UnkStruct_0206322c::func_020304a8(bool doTopScreen, bool doBottomScreen) { + if (doTopScreen) { + Fill16(0, this->topScreen.data, sizeof(this->topScreen.data)); + } + + if (doBottomScreen) { + Fill16(0, this->bottomScreen.data, sizeof(this->bottomScreen.data)); + } +} + +void DisplayDebugText(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char*, unk32); + +THUMB void DisplayDebugTextFormat(unk32 param1, unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char* fmt, va_list args) { + char buffer[0x100]; + + vsnprintf(buffer, sizeof(buffer), fmt, args); + DisplayDebugText(x, y, unkVal1, unkVal2, buffer, param1); +} + +THUMB void DisplayDebugTextFormat_thunk(unk32 param1, unk32 param2, unk32 param3, unk32 param4, unk32 param5, char* fmt, ...) { + va_list args; + + va_start(args, fmt); + DisplayDebugTextFormat(param1, param2, param3, param4, param5, fmt, args); + va_end(args); +} + +THUMB void DisplayDebugTextF(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char* fmt, ...) { + va_list args; + + va_start(args, fmt); + DisplayDebugTextFormat(0, x, y, unkVal1, unkVal2, fmt, args); + va_end(args); +} From 53cc55fb20d3526dd9181781216a341df5e53f63 Mon Sep 17 00:00:00 2001 From: Yanis002 <35189056+Yanis002@users.noreply.github.com> Date: Wed, 12 Feb 2025 20:20:59 +0100 Subject: [PATCH 2/7] format --- include/DTCM/UnkStruct_027e02a0.hpp | 2 +- include/Unknown/UnkStruct_02063220.hpp | 6 +- include/Unknown/UnkStruct_0206322c.hpp | 2 +- include/types.h | 2 +- libs/c/include/stdarg.h | 16 ++-- libs/nds/include/nds/button.h | 20 ++-- src/Main/Unknown/UnkStruct_02063220.cpp | 119 ++++++++++-------------- src/Main/Unknown/UnkStruct_0206322c.cpp | 48 +++++----- 8 files changed, 98 insertions(+), 117 deletions(-) diff --git a/include/DTCM/UnkStruct_027e02a0.hpp b/include/DTCM/UnkStruct_027e02a0.hpp index d533bb4f..2cfcf4f7 100644 --- a/include/DTCM/UnkStruct_027e02a0.hpp +++ b/include/DTCM/UnkStruct_027e02a0.hpp @@ -7,4 +7,4 @@ struct UnkStruct_027e02a0 { unk32 mUnk_94[23]; }; -extern UnkStruct_027e02a0* data_027e02a0; +extern UnkStruct_027e02a0 *data_027e02a0; diff --git a/include/Unknown/UnkStruct_02063220.hpp b/include/Unknown/UnkStruct_02063220.hpp index ccdaea85..5a07303b 100644 --- a/include/Unknown/UnkStruct_02063220.hpp +++ b/include/Unknown/UnkStruct_02063220.hpp @@ -30,14 +30,14 @@ struct UnkStruct_02063220_08 { class UnkStruct_02063220 { public: - /* 00 */ char* path; + /* 00 */ char *path; /* 04 */ u8 mUnk_04; /* 05 */ u8 mUnk_05; /* 06 */ unk16 mUnk_06; /* 08 */ UnkStruct_02063220_08 mUnk_08; - void DisplayAssertError(char* file, u16 line, char* msg, ...); - void DisplayException(Registers* param1); + void DisplayAssertError(char *file, u16 line, char *msg, ...); + void DisplayException(Registers *param1); static bool func_0202f3f0(unk32 param1); static unk32 func_0202f400(unk32 param1); void func_0202f4b4(void); diff --git a/include/Unknown/UnkStruct_0206322c.hpp b/include/Unknown/UnkStruct_0206322c.hpp index d28cd0f4..534fc26b 100644 --- a/include/Unknown/UnkStruct_0206322c.hpp +++ b/include/Unknown/UnkStruct_0206322c.hpp @@ -27,7 +27,7 @@ public: void func_02030354(bool doTopScreen, bool doBottomScreen); // ctor? - void* func_02030408(void); + void *func_02030408(void); // copy the screen data to VRAM void func_02030464(bool doTopScreen, bool doBottomScreen); diff --git a/include/types.h b/include/types.h index 4d6bc6c1..5d42ab41 100644 --- a/include/types.h +++ b/include/types.h @@ -22,6 +22,6 @@ typedef s32 bool; #endif #define CEIL_DIV(a, b) (((a) + (b) - 1) / (b)) -#define UNK_PTR unk32* +#define UNK_PTR unk32 * #endif diff --git a/libs/c/include/stdarg.h b/libs/c/include/stdarg.h index a47e0f01..4ace4037 100644 --- a/libs/c/include/stdarg.h +++ b/libs/c/include/stdarg.h @@ -2,19 +2,19 @@ #define _C_STDARG_H extern "C" { - typedef char* va_list; +typedef char *va_list; - #define __std(ref) ::std::ref - #define __fourbytealign(n) ((((unsigned long)(n)) + 3U) & ~3U) - #define __va_start(parm) ((__std(va_list)) ((char *)((unsigned long)(&parm) & ~3U) + __fourbytealign(sizeof(parm)))) +#define __std(ref) ::std::ref +#define __fourbytealign(n) ((((unsigned long) (n)) + 3U) & ~3U) +#define __va_start(parm) ((__std(va_list))((char *) ((unsigned long) (&parm) & ~3U) + __fourbytealign(sizeof(parm)))) - #define va_start(ap, parm) ((ap) = __va_start(parm)) - #define va_arg(ap, type) (*(type *)((ap += __fourbytealign(sizeof(type))) - __fourbytealign(sizeof(type)))) - #define va_end(ap) ((void)0) +#define va_start(ap, parm) ((ap) = __va_start(parm)) +#define va_arg(ap, type) (*(type *) ((ap += __fourbytealign(sizeof(type))) - __fourbytealign(sizeof(type)))) +#define va_end(ap) ((void) 0) } #if defined(__cplusplus) -namespace std { +namespace std { using ::va_list; }; diff --git a/libs/nds/include/nds/button.h b/libs/nds/include/nds/button.h index 90ee060d..a2e665a6 100644 --- a/libs/nds/include/nds/button.h +++ b/libs/nds/include/nds/button.h @@ -1,12 +1,12 @@ #pragma once -#define BTN_A (1 << 0) // 0x0001 -#define BTN_B (1 << 1) // 0x0002 -#define BTN_SELECT (1 << 2) // 0x0004 -#define BTN_START (1 << 3) // 0x0008 -#define BTN_DRIGHT (1 << 4) // 0x0010 -#define BTN_DLEFT (1 << 5) // 0x0020 -#define BTN_DUP (1 << 6) // 0x0040 -#define BTN_DDOWN (1 << 7) // 0x0080 -#define BTN_R (1 << 8) // 0x0100 -#define BTN_L (1 << 9) // 0x0200 +#define BTN_A (1 << 0) // 0x0001 +#define BTN_B (1 << 1) // 0x0002 +#define BTN_SELECT (1 << 2) // 0x0004 +#define BTN_START (1 << 3) // 0x0008 +#define BTN_DRIGHT (1 << 4) // 0x0010 +#define BTN_DLEFT (1 << 5) // 0x0020 +#define BTN_DUP (1 << 6) // 0x0040 +#define BTN_DDOWN (1 << 7) // 0x0080 +#define BTN_R (1 << 8) // 0x0100 +#define BTN_L (1 << 9) // 0x0200 diff --git a/src/Main/Unknown/UnkStruct_02063220.cpp b/src/Main/Unknown/UnkStruct_02063220.cpp index 80760330..f1edc32a 100644 --- a/src/Main/Unknown/UnkStruct_02063220.cpp +++ b/src/Main/Unknown/UnkStruct_02063220.cpp @@ -1,76 +1,62 @@ -#include -#include -#include "nds/math.h" -#include "nds/button.h" -#include "System/OverlayManager.hpp" +#include "Unknown/UnkStruct_02063220.hpp" #include "DTCM/UnkStruct_027e02a0.hpp" #include "DTCM/UnkStruct_027e05f8.hpp" #include "DTCM/UnkStruct_027e0618.hpp" #include "DTCM/UnkStruct_027e08f8.hpp" -#include "Unknown/UnkStruct_02063220.hpp" -#include "Unknown/UnkStruct_020ee734.hpp" +#include "System/OverlayManager.hpp" #include "Unknown/UnkStruct_0206322c.hpp" +#include "Unknown/UnkStruct_020ee734.hpp" +#include "nds/button.h" +#include "nds/math.h" +#include +#include -void DisplayDebugText(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char*, unk32); -void DisplayDebugTextFormat(unk32 param1, unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char* fmt, va_list args); -void DisplayDebugTextFormat_thunk(unk32 param1, unk32 param2, unk32 param3, unk32 param4, unk32 param5, char* fmt, ...); -void DisplayDebugTextF(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char* fmt, ...); +void DisplayDebugText(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char *, unk32); +void DisplayDebugTextFormat(unk32 param1, unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char *fmt, va_list args); +void DisplayDebugTextFormat_thunk(unk32 param1, unk32 param2, unk32 param3, unk32 param4, unk32 param5, char *fmt, ...); +void DisplayDebugTextF(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char *fmt, ...); extern u8 data_02075ebc; extern "C" { - void func_0200f248(); - void func_0202bac4(); - void func_0202c5e8(void); - void func_0202cf34(unk32); - void func_0202d164(); - void func_0202e6a4(void); - void func_0203e8a0(void); - void func_0202f374(); +void func_0200f248(); +void func_0202bac4(); +void func_0202c5e8(void); +void func_0202cf34(unk32); +void func_0202d164(); +void func_0202e6a4(void); +void func_0203e8a0(void); +void func_0202f374(); // probably GX/GXS functions? - void func_02003ce4(unk32); - void func_02004730(unk32); - void func_02003a9c(unk32, unk32, unk32); - void func_02003b04(unk32); - void SetBrightColor(u16*, unk32); +void func_02003ce4(unk32); +void func_02004730(unk32); +void func_02003a9c(unk32, unk32, unk32); +void func_02003b04(unk32); +void SetBrightColor(u16 *, unk32); } -#define ITCM_END ((s8*)0x01FFFFFF) -#define ARM9_RAM_START ((s8*)0x02000000) -#define ARM9_RAM_END ((s8*)0x0219B1C0) +#define ITCM_END ((s8 *) 0x01FFFFFF) +#define ARM9_RAM_START ((s8 *) 0x02000000) +#define ARM9_RAM_END ((s8 *) 0x0219B1C0) -#define REG_A_DISPCNT (*(u32*)0x04000000) -#define REG_A_2D_ENGINE (*(u16*)0x04000008) -#define REG_A_MASTER_BRIGHT ((u16*)0x0400006C) +#define REG_A_DISPCNT (*(u32 *) 0x04000000) +#define REG_A_2D_ENGINE (*(u16 *) 0x04000008) +#define REG_A_MASTER_BRIGHT ((u16 *) 0x0400006C) #define REG_B_DISPCNT_ADDR (0x04001000) -#define REG_B_DISPCNT (*(u32*)REG_B_DISPCNT_ADDR) -#define REG_B_2D_ENGINE (*(u16*)0x04001008) -#define REG_B_MASTER_BRIGHT ((u16*)0x0400106C) +#define REG_B_DISPCNT (*(u32 *) REG_B_DISPCNT_ADDR) +#define REG_B_2D_ENGINE (*(u16 *) 0x04001008) +#define REG_B_MASTER_BRIGHT ((u16 *) 0x0400106C) u16 data_020562e2[] = { - BTN_DUP, - BTN_DDOWN, - BTN_DDOWN, - BTN_DUP, - BTN_SELECT, - BTN_B, - BTN_R, - BTN_START, - BTN_DLEFT, - BTN_DLEFT, - BTN_DRIGHT, - BTN_DLEFT, - BTN_START, - BTN_DUP, + BTN_DUP, BTN_DDOWN, BTN_DDOWN, BTN_DUP, BTN_SELECT, BTN_B, BTN_R, + BTN_START, BTN_DLEFT, BTN_DLEFT, BTN_DRIGHT, BTN_DLEFT, BTN_START, BTN_DUP, }; THUMB bool UnkStruct_02063220::func_0202f3f0(unk32 param1) { switch (param1) { case 2: - case 3: - return true; - default: - break; + case 3: return true; + default: break; } return false; @@ -80,20 +66,15 @@ THUMB unk32 UnkStruct_02063220::func_0202f400(unk32 param1) { unk32 ret = 0; switch (param1) { - case 2: - ret = 1; - break; - case 3: - ret = 2; - break; - default: - break; + case 2: ret = 1; break; + case 3: ret = 2; break; + default: break; } return ret; } -THUMB void UnkStruct_02063220::DisplayAssertError(char* file, u16 line, char* msg, ...) { +THUMB void UnkStruct_02063220::DisplayAssertError(char *file, u16 line, char *msg, ...) { va_list args; data_0206322c.func_020304a8(true, true); @@ -126,13 +107,13 @@ THUMB void UnkStruct_02063220::func_0202f500(void) { } // non-matching -THUMB void UnkStruct_02063220::DisplayException(Registers* param1) { +THUMB void UnkStruct_02063220::DisplayException(Registers *param1) { int iVar1; s8 *pbVar2; int iVar3; s32 *puVar4; int *piVar5; - + if (this->mUnk_05 != 0) { this->func_0202f500(); } else { @@ -195,7 +176,7 @@ THUMB void UnkStruct_02063220::DisplayException(Registers* param1) { iVar3 = 1; for (iVar3 = 1; puVar4 < data_027e02a0[1].mUnk_94; puVar4++) { - pbVar2 = (s8*)puVar4; + pbVar2 = (s8 *) puVar4; if ((ITCM_END < pbVar2 && pbVar2 < ARM9_RAM_END) || pbVar2 < ARM9_RAM_START) { DisplayDebugTextFormat_thunk(1, 23, iVar3, 0, 0, "%08X", pbVar2); @@ -218,7 +199,7 @@ THUMB void UnkStruct_02063220::func_0202f754(unk32 param1) { u16 uVar4; bool bVar5; bool bVar6; - + func_0202c5e8(); this->mUnk_04 = 0; this->mUnk_05 = 0; @@ -231,8 +212,8 @@ THUMB void UnkStruct_02063220::func_0202f754(unk32 param1) { func_02003a9c(1, 0, 0); func_02003b04(0); - REG_A_DISPCNT = (REG_A_DISPCNT & 0xFFFFE0FF) | 0x100; - REG_B_DISPCNT = (REG_B_DISPCNT & 0xFFFFE0FF) | (REG_B_DISPCNT_ADDR >> 0x12); + REG_A_DISPCNT = (REG_A_DISPCNT & 0xFFFFE0FF) | 0x100; + REG_B_DISPCNT = (REG_B_DISPCNT & 0xFFFFE0FF) | (REG_B_DISPCNT_ADDR >> 0x12); REG_A_2D_ENGINE = (REG_A_2D_ENGINE & 0x43) | 0x4; REG_B_2D_ENGINE = (REG_B_2D_ENGINE & 0x43) | 0x4; data_0206322c.func_02030354(1, 1); @@ -254,13 +235,13 @@ THUMB void UnkStruct_02063220::func_0202f754(unk32 param1) { if (bVar5) { bVar6 = false; - + if (((~uVar4 & 0xFFF) & (~uVar1 & 0xFFFF)) != 0 && (uVar1 & 0xFFF) != 0) { this->mUnk_04 = 0; } } } - + this->mUnk_04++; if (this->mUnk_04 >= 0xC ? 1 : 0) { this->func_0202f3f0(param1); @@ -288,5 +269,5 @@ THUMB void UnkStruct_02063220::func_0202f754(unk32 param1) { func_0200f248(); } - } while(true); + } while (true); } diff --git a/src/Main/Unknown/UnkStruct_0206322c.cpp b/src/Main/Unknown/UnkStruct_0206322c.cpp index 67338a78..b1c17748 100644 --- a/src/Main/Unknown/UnkStruct_0206322c.cpp +++ b/src/Main/Unknown/UnkStruct_0206322c.cpp @@ -1,34 +1,34 @@ -#include +#include "Unknown/UnkStruct_0206322c.hpp" #include "global.h" #include "types.h" -#include "Unknown/UnkStruct_0206322c.hpp" +#include -void func_02027ab4(unk32, Screen*, UNK_PTR, UNK_PTR, unk32, unk32, unk32, unk32); +void func_02027ab4(unk32, Screen *, UNK_PTR, UNK_PTR, unk32, unk32, unk32, unk32); extern "C" { - unk32* MountCompressedNarc(char*, char*, unk8*, unk32, unk32); - unk8 data_020691a0[0xCC00]; - UNK_PTR func_02032054(char*, unk32); - UNK_PTR func_0203206c(char*, unk32); - void func_02016fcc(unk32*); +unk32 *MountCompressedNarc(char *, char *, unk8 *, unk32, unk32); +unk8 data_020691a0[0xCC00]; +UNK_PTR func_02032054(char *, unk32); +UNK_PTR func_0203206c(char *, unk32); +void func_02016fcc(unk32 *); - void GX_LoadBG0Scr(u16 *data, unk32, u32 size); - void GXS_LoadBG0Scr(u16 *data, unk32, u32 size); - void CleanAndInvalidateDataCacheLines(void*, u32 size); // DC_FlushRange? - void Fill16(unk32, void*, u32 size); - int vsnprintf(char* s, size_t n, const char* format, va_list arg); +void GX_LoadBG0Scr(u16 *data, unk32, u32 size); +void GXS_LoadBG0Scr(u16 *data, unk32, u32 size); +void CleanAndInvalidateDataCacheLines(void *, u32 size); // DC_FlushRange? +void Fill16(unk32, void *, u32 size); +int vsnprintf(char *s, size_t n, const char *format, va_list arg); } THUMB void UnkStruct_0206322c::func_02030354(bool doTopScreen, bool doBottomScreen) { - Screen* pScreen; - unk32* uVar1; + Screen *pScreen; + unk32 *uVar1; - uVar1 = MountCompressedNarc("BGF", "Menu/UI_main/DbgFntM.bin", data_020691a0, sizeof(data_020691a0), 1); + uVar1 = MountCompressedNarc("BGF", "Menu/UI_main/DbgFntM.bin", data_020691a0, sizeof(data_020691a0), 1); this->mUnk_00 = func_02032054("BGF:DbgFntM.ncgr", 1); this->mUnk_04 = func_0203206c("BGF:UIM.nclr", 1); if (doTopScreen) { - pScreen = &this->topScreen; + pScreen = &this->topScreen; pScreen->mUnk_00 = 0x100; pScreen->mUnk_02 = 0xC0; pScreen->mUnk_04 = 0; @@ -38,7 +38,7 @@ THUMB void UnkStruct_0206322c::func_02030354(bool doTopScreen, bool doBottomScre } if (doBottomScreen) { - pScreen = &this->bottomScreen; + pScreen = &this->bottomScreen; pScreen->mUnk_00 = 0x100; pScreen->mUnk_02 = 0xC0; pScreen->mUnk_04 = 0; @@ -50,7 +50,7 @@ THUMB void UnkStruct_0206322c::func_02030354(bool doTopScreen, bool doBottomScre func_02016fcc(uVar1); } -THUMB void* UnkStruct_0206322c::func_02030408(void) { +THUMB void *UnkStruct_0206322c::func_02030408(void) { this->mUnk_00 = NULL; this->mUnk_04 = NULL; this->func_020304a8(true, true); @@ -73,22 +73,22 @@ THUMB void UnkStruct_0206322c::func_020304a8(bool doTopScreen, bool doBottomScre if (doTopScreen) { Fill16(0, this->topScreen.data, sizeof(this->topScreen.data)); } - + if (doBottomScreen) { Fill16(0, this->bottomScreen.data, sizeof(this->bottomScreen.data)); } } -void DisplayDebugText(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char*, unk32); +void DisplayDebugText(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char *, unk32); -THUMB void DisplayDebugTextFormat(unk32 param1, unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char* fmt, va_list args) { +THUMB void DisplayDebugTextFormat(unk32 param1, unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char *fmt, va_list args) { char buffer[0x100]; vsnprintf(buffer, sizeof(buffer), fmt, args); DisplayDebugText(x, y, unkVal1, unkVal2, buffer, param1); } -THUMB void DisplayDebugTextFormat_thunk(unk32 param1, unk32 param2, unk32 param3, unk32 param4, unk32 param5, char* fmt, ...) { +THUMB void DisplayDebugTextFormat_thunk(unk32 param1, unk32 param2, unk32 param3, unk32 param4, unk32 param5, char *fmt, ...) { va_list args; va_start(args, fmt); @@ -96,7 +96,7 @@ THUMB void DisplayDebugTextFormat_thunk(unk32 param1, unk32 param2, unk32 param3 va_end(args); } -THUMB void DisplayDebugTextF(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char* fmt, ...) { +THUMB void DisplayDebugTextF(unk32 x, unk32 y, unk32 unkVal1, unk32 unkVal2, char *fmt, ...) { va_list args; va_start(args, fmt); From 1c9bf116969f08fbca76f1b8630f17f683519c7f Mon Sep 17 00:00:00 2001 From: Yanis002 <35189056+Yanis002@users.noreply.github.com> Date: Sat, 28 Jun 2025 18:56:44 +0200 Subject: [PATCH 3/7] comments --- src/Main/Unknown/UnkStruct_02063220.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Main/Unknown/UnkStruct_02063220.cpp b/src/Main/Unknown/UnkStruct_02063220.cpp index f1edc32a..b61fc49c 100644 --- a/src/Main/Unknown/UnkStruct_02063220.cpp +++ b/src/Main/Unknown/UnkStruct_02063220.cpp @@ -77,16 +77,25 @@ THUMB unk32 UnkStruct_02063220::func_0202f400(unk32 param1) { THUMB void UnkStruct_02063220::DisplayAssertError(char *file, u16 line, char *msg, ...) { va_list args; + // reset screen data data_0206322c.func_020304a8(true, true); + + // "draw" strings to the screen array DisplayDebugText(0, 0, false, true, "Assert", 0); DisplayDebugTextF(0, 2, false, true, "FILE:%s", file); DisplayDebugTextF(0, 3, false, true, "LINE:%d", line); va_start(args, msg); DisplayDebugTextFormat(0, 0, 5, false, true, msg, args); va_end(args); + + // unknown but other "draw" stuff func_0202f374(); func_0202d164(); + + // "draw" last file this->func_0202f4b4(); + + // actual draw of the screen this->func_0202f754(0); } From bc0f222f68b170111c96a0e1997e084019123c2d Mon Sep 17 00:00:00 2001 From: Yanis002 <35189056+Yanis002@users.noreply.github.com> Date: Sun, 29 Jun 2025 21:52:12 +0200 Subject: [PATCH 4/7] build issues fix attempt --- config/eur/arm9/delinks.txt | 1 + config/eur/arm9/symbols.txt | 2 +- config/usa/arm9/symbols.txt | 28 ++++++++++++------------- src/Main/Unknown/UnkStruct_02063220.cpp | 20 ++++++++++-------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/config/eur/arm9/delinks.txt b/config/eur/arm9/delinks.txt index 1e92a4e7..e1b18079 100644 --- a/config/eur/arm9/delinks.txt +++ b/config/eur/arm9/delinks.txt @@ -24,3 +24,4 @@ src/Main/Unknown/UnkStruct_0206322c.cpp: src/Main/Unknown/UnkStruct_02063220.cpp: .text start:0x0202f3f0 end:0x0202f8e8 .rodata start:0x020562e2 end:0x02056300 + .data start:0x0205772c end:0x02057808 diff --git a/config/eur/arm9/symbols.txt b/config/eur/arm9/symbols.txt index d523188f..8cccb2b0 100644 --- a/config/eur/arm9/symbols.txt +++ b/config/eur/arm9/symbols.txt @@ -1544,7 +1544,7 @@ _ZN18UnkStruct_0206322c13func_02030408Ev kind:function(thumb,size=0x16) addr:0x2 func_02030420 kind:function(thumb,size=0x44) addr:0x2030420 _ZN18UnkStruct_0206322c13func_02030464Ebb kind:function(thumb,size=0x42) addr:0x2030464 _ZN18UnkStruct_0206322c13func_020304a8Ebb kind:function(thumb,size=0x2c) addr:0x20304a8 -DisplayDebugText kind:function(thumb,size=0xd8) addr:0x20304d4 +_Z16DisplayDebugTextiiiiPci kind:function(thumb,size=0xd8) addr:0x20304d4 func_020305ac kind:function(thumb,size=0x88) addr:0x20305ac _Z22DisplayDebugTextFormatiiiiiPcS_ kind:function(thumb,size=0x30) addr:0x2030634 _Z28DisplayDebugTextFormat_thunkiiiiiPcz kind:function(thumb,size=0x26) addr:0x2030664 diff --git a/config/usa/arm9/symbols.txt b/config/usa/arm9/symbols.txt index fe14219e..c973128f 100644 --- a/config/usa/arm9/symbols.txt +++ b/config/usa/arm9/symbols.txt @@ -1474,13 +1474,13 @@ func_0202f2f8 kind:function(arm,size=0x30) addr:0x202f2f4 func_0202f328 kind:function(arm,size=0x38) addr:0x202f324 func_0202f360 kind:function(thumb,size=0x14) addr:0x202f35c func_0202f374 kind:function(thumb,size=0x7c) addr:0x202f370 -func_0202f3f0 kind:function(thumb,size=0x10) addr:0x202f3ec -func_0202f400 kind:function(thumb,size=0x16) addr:0x202f3fc -DisplayAssertError kind:function(thumb,size=0x9c) addr:0x202f414 -func_0202f4b4 kind:function(thumb,size=0x4c) addr:0x202f4b0 -func_0202f500 kind:function(thumb,size=0x2c) addr:0x202f4fc -DisplayException kind:function(thumb,size=0x228) addr:0x202f528 -func_0202f754 kind:function(thumb,size=0x194) addr:0x202f750 +_ZN18UnkStruct_0206322013func_0202f3f0Ei kind:function(thumb,size=0x10) addr:0x202f3ec +_ZN18UnkStruct_0206322013func_0202f400Ei kind:function(thumb,size=0x16) addr:0x202f3fc +_ZN18UnkStruct_0206322018DisplayAssertErrorEPctS0_z kind:function(thumb,size=0x9c) addr:0x202f414 +_ZN18UnkStruct_0206322013func_0202f4b4Ev kind:function(thumb,size=0x4c) addr:0x202f4b0 +_ZN18UnkStruct_0206322013func_0202f500Ev kind:function(thumb,size=0x2c) addr:0x202f4fc +_ZN18UnkStruct_0206322016DisplayExceptionEP9Registers kind:function(thumb,size=0x228) addr:0x202f528 +_ZN18UnkStruct_0206322013func_0202f754Ei kind:function(thumb,size=0x194) addr:0x202f750 func_0202f8e8 kind:function(thumb,size=0x30) addr:0x202f8e4 func_0202f918 kind:function(thumb,size=0x88) addr:0x202f914 func_0202f9a0 kind:function(arm,size=0x88) addr:0x202f99c @@ -1539,16 +1539,16 @@ _ZN18DebugHierarchyBase8vfunc_2cEv kind:function(thumb,size=0x2) addr:0x2030340 _ZN18DebugHierarchyBase8vfunc_30Ev kind:function(thumb,size=0x2) addr:0x2030344 _ZN18DebugHierarchyBase8vfunc_38Ev kind:function(thumb,size=0x2) addr:0x2030348 _ZN18DebugHierarchyBase8vfunc_3cEv kind:function(thumb,size=0x2) addr:0x203034c -func_02030354 kind:function(thumb,size=0xb4) addr:0x2030350 -func_02030408 kind:function(thumb,size=0x16) addr:0x2030404 +_ZN18UnkStruct_0206322c13func_02030354Ebb kind:function(thumb,size=0xb4) addr:0x2030350 +_ZN18UnkStruct_0206322c13func_02030408Ev kind:function(thumb,size=0x16) addr:0x2030404 func_02030420 kind:function(thumb,size=0x44) addr:0x203041c -func_02030464 kind:function(thumb,size=0x42) addr:0x2030460 -func_020304a8 kind:function(thumb,size=0x2c) addr:0x20304a4 +_ZN18UnkStruct_0206322c13func_02030464Ebb kind:function(thumb,size=0x42) addr:0x2030460 +_ZN18UnkStruct_0206322c13func_020304a8Ebb kind:function(thumb,size=0x2c) addr:0x20304a4 DisplayDebugText kind:function(thumb,size=0xd8) addr:0x20304d0 func_020305ac kind:function(thumb,size=0x88) addr:0x20305a8 -DisplayDebugTextFormat kind:function(thumb,size=0x30) addr:0x2030630 -DisplayDebugTextFormat_thunk kind:function(thumb,size=0x26) addr:0x2030660 -DisplayDebugTextF kind:function(thumb,size=0x32) addr:0x2030688 +_Z22DisplayDebugTextFormatiiiiiPcS_ kind:function(thumb,size=0x30) addr:0x2030630 +_Z28DisplayDebugTextFormat_thunkiiiiiPcz kind:function(thumb,size=0x26) addr:0x2030660 +_Z17DisplayDebugTextFiiiiPcz kind:function(thumb,size=0x32) addr:0x2030688 func_020306c0 kind:function(thumb,size=0x70) addr:0x20306bc func_02030730 kind:function(thumb,size=0x28) addr:0x203072c func_02030758 kind:function(thumb,size=0x84) addr:0x2030754 diff --git a/src/Main/Unknown/UnkStruct_02063220.cpp b/src/Main/Unknown/UnkStruct_02063220.cpp index 76d62651..4e2ddbfe 100644 --- a/src/Main/Unknown/UnkStruct_02063220.cpp +++ b/src/Main/Unknown/UnkStruct_02063220.cpp @@ -26,8 +26,9 @@ void func_0202d164(); void func_0202e6a4(void); void func_0203e8a0(void); void func_0202f374(); +char* strncpy(char*, char const*, unsigned int); - // probably GX/GXS functions? +// probably GX/GXS functions? void func_02003ce4(unk32); void func_02004730(unk32); void func_02003a9c(unk32, unk32, unk32); @@ -47,7 +48,7 @@ void SetBrightColor(u16 *, unk32); #define REG_B_2D_ENGINE (*(u16 *) 0x04001008) #define REG_B_MASTER_BRIGHT ((u16 *) 0x0400106C) -u16 data_020562e2[] = { +const u16 data_020562e2[] = { BTN_DUP, BTN_DDOWN, BTN_DDOWN, BTN_DUP, BTN_SELECT, BTN_B, BTN_R, BTN_START, BTN_DLEFT, BTN_DLEFT, BTN_DRIGHT, BTN_DLEFT, BTN_START, BTN_DUP, }; @@ -112,6 +113,7 @@ THUMB void UnkStruct_02063220::func_0202f4b4(void) { } THUMB void UnkStruct_02063220::func_0202f500(void) { + // "reigaichuu(%d,%d)" DisplayDebugTextF(16, 0, 0, 1, "レイガイチュウ(%d,%d)", data_02075ebc, this->mUnk_05); } @@ -141,26 +143,26 @@ THUMB void UnkStruct_02063220::DisplayException(Registers *param1) { } for (iVar3 = 0; iVar3 < ARRAY_LEN(param1->mUnk_04); iVar3++) { - DisplayDebugTextF(0, iVar3 + 2, 0, 0, "R%02d__=_0x%08X", iVar3, param1->mUnk_04[iVar3]); + DisplayDebugTextF(0, iVar3 + 2, 0, 0, "R%02d = 0x%08X", iVar3, param1->mUnk_04[iVar3]); this->mUnk_05++; } - DisplayDebugTextF(0, 15, 0, 0, "SP___=_0x%08X", param1->mUnk_0C); + DisplayDebugTextF(0, 15, 0, 0, "SP = 0x%08X", param1->mUnk_0C); this->mUnk_05++; - DisplayDebugTextF(0, 16, 0, 1, "LR___=_0x%08X", param1->mUnk_10); + DisplayDebugTextF(0, 16, 0, 1, "LR = 0x%08X", param1->mUnk_10); this->mUnk_05++; - DisplayDebugTextF(0, 17, 0, 1, "PC___=_0x%08X", param1->mUnk_14); + DisplayDebugTextF(0, 17, 0, 1, "PC = 0x%08X", param1->mUnk_14); this->mUnk_05++; - DisplayDebugTextF(0, 18, 0, 0, "CPSR_=_0x%08X", param1->mUnk_00); + DisplayDebugTextF(0, 18, 0, 0, "CPSR = 0x%08X", param1->mUnk_00); this->mUnk_05++; - DisplayDebugTextF(0, 19, 0, 0, "SPSR_=_0x%08X", param1->mUnk_3C); + DisplayDebugTextF(0, 19, 0, 0, "SPSR = 0x%08X", param1->mUnk_3C); this->mUnk_05++; - DisplayDebugTextF(0, 20, 0, 0, "CP15_=_0x%08X", param1->mUnk_38); + DisplayDebugTextF(0, 20, 0, 0, "CP15 = 0x%08X", param1->mUnk_38); this->mUnk_05++; func_0202f374(); From 7580d62123164425d33c47170f5710226d7a5b87 Mon Sep 17 00:00:00 2001 From: Yanis002 <35189056+Yanis002@users.noreply.github.com> Date: Tue, 1 Jul 2025 01:03:50 +0200 Subject: [PATCH 5/7] fixed build issues --- config/eur/arm9/delinks.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/eur/arm9/delinks.txt b/config/eur/arm9/delinks.txt index 388053c0..81ef62d3 100644 --- a/config/eur/arm9/delinks.txt +++ b/config/eur/arm9/delinks.txt @@ -57,5 +57,5 @@ src/Main/Unknown/UnkStruct_0206322c.cpp: src/Main/Unknown/UnkStruct_02063220.cpp: .text start:0x0202f3f0 end:0x0202f8e8 - .rodata start:0x020562e2 end:0x02056300 + .rodata start:0x020562e0 end:0x02056300 .data start:0x0205772c end:0x02057808 From a32e727fedb44618ae5938d9e3d2bad7cdb66cb0 Mon Sep 17 00:00:00 2001 From: Yanis002 <35189056+Yanis002@users.noreply.github.com> Date: Tue, 1 Jul 2025 01:11:08 +0200 Subject: [PATCH 6/7] port usa splits --- config/usa/arm9/delinks.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/usa/arm9/delinks.txt b/config/usa/arm9/delinks.txt index 3913ca13..25601a31 100644 --- a/config/usa/arm9/delinks.txt +++ b/config/usa/arm9/delinks.txt @@ -51,3 +51,11 @@ src/Main/Message/func_0203c72c.cpp: src/Main/Unknown/UnkStruct_0203dae0.cpp: .text start:0x0203da9c end:0x0203e740 + +src/Main/Unknown/UnkStruct_0206322c.cpp: + .text start:0x02030350 end:0x020306bc + +src/Main/Unknown/UnkStruct_02063220.cpp: + .text start:0x0202f3ec end:0x0202f8e4 + .rodata start:0x0205629c end:0x020562bc + .data start:0x020576e4 end:0x020577c0 From 74312a0630f5d1f782e2176ea1845e7978e0933d Mon Sep 17 00:00:00 2001 From: Yanis002 <35189056+Yanis002@users.noreply.github.com> Date: Tue, 1 Jul 2025 01:13:50 +0200 Subject: [PATCH 7/7] format --- src/Main/Unknown/UnkStruct_02063220.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Main/Unknown/UnkStruct_02063220.cpp b/src/Main/Unknown/UnkStruct_02063220.cpp index 4e2ddbfe..fe026560 100644 --- a/src/Main/Unknown/UnkStruct_02063220.cpp +++ b/src/Main/Unknown/UnkStruct_02063220.cpp @@ -26,7 +26,7 @@ void func_0202d164(); void func_0202e6a4(void); void func_0203e8a0(void); void func_0202f374(); -char* strncpy(char*, char const*, unsigned int); +char *strncpy(char *, char const *, unsigned int); // probably GX/GXS functions? void func_02003ce4(unk32);