mirror of
https://github.com/zeldaret/ph
synced 2026-07-11 06:34:51 -04:00
started debug display/error
This commit is contained in:
@@ -0,0 +1,292 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#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);
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
#include <stdarg.h>
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user