mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-04 15:04:31 +00:00
Cleanup z_debug (reg editor) (#1290)
* Cleanup z_debug * misc * pad reg names column to """allow""" 40 characters because why not * safety parentheses in regs.h * More safety parentheses, in named regs defines * sort named regs in order, except for message system regs (?) * put all regs in order (message system ones too)
This commit is contained in:
parent
79cb1f8d5c
commit
9647f50451
5 changed files with 337 additions and 277 deletions
|
@ -1700,7 +1700,7 @@ s32 DbCamera_ClearCallback(char* c) {
|
|||
return Mempak_DeleteFile(2, *c);
|
||||
}
|
||||
|
||||
void DbCamera_DrawSlotLetters(char* str, s16 y, s16 x, s32 colorId) {
|
||||
void DbCamera_DrawSlotLetters(char* str, s16 y, s16 x, s32 colorIndex) {
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(sDbCameraCuts) - 1; i++) {
|
||||
|
@ -1709,9 +1709,9 @@ void DbCamera_DrawSlotLetters(char* str, s16 y, s16 x, s32 colorId) {
|
|||
}
|
||||
|
||||
str[0x14] = str[i * 2 + 1] = '\0';
|
||||
func_8006376C(x, y, colorId, str);
|
||||
func_8006376C(x, y, colorIndex, str);
|
||||
str[0x14] = str[i * 2 + 0] = '-';
|
||||
func_8006376C(x + 0x14, y, colorId, str + 0x14);
|
||||
func_8006376C(x + 0x14, y, colorIndex, str + 0x14);
|
||||
}
|
||||
|
||||
void DbCamera_PrintAllCuts(Camera* cam) {
|
||||
|
|
|
@ -3,37 +3,96 @@
|
|||
typedef struct {
|
||||
u8 x;
|
||||
u8 y;
|
||||
u8 colorId;
|
||||
char text[0x15];
|
||||
} PrintTextBuffer;
|
||||
u8 colorIndex;
|
||||
char text[21];
|
||||
} PrintTextBufferEntry; // size = 0x18
|
||||
|
||||
typedef struct {
|
||||
u16 push;
|
||||
u16 held;
|
||||
} InputCombo;
|
||||
u16 hold;
|
||||
u16 press;
|
||||
} InputCombo; // size = 0x4
|
||||
|
||||
GameInfo* gGameInfo;
|
||||
s32 D_8015FA94; // no known symbols
|
||||
PrintTextBuffer D_8015FA98[0x16];
|
||||
|
||||
s16 D_8011E0B0 = 0; // PrintTextBuffer index
|
||||
Color_RGBA8 printTextColors[] = {
|
||||
{ 255, 255, 32, 192 }, { 255, 150, 128, 192 }, { 128, 96, 0, 64 }, { 192, 128, 16, 128 },
|
||||
{ 255, 192, 32, 128 }, { 230, 230, 220, 64 }, { 128, 150, 255, 128 }, { 128, 255, 32, 128 },
|
||||
PrintTextBufferEntry sDebugPrintTextBuffer[22];
|
||||
s16 sDebugPrintTextBufferNumUsed = 0;
|
||||
Color_RGBA8 sDebugPrintTextColors[] = {
|
||||
{ 255, 255, 32, 192 }, // 0
|
||||
{ 255, 150, 128, 192 }, // 1
|
||||
{ 128, 96, 0, 64 }, // 2
|
||||
{ 192, 128, 16, 128 }, // 3
|
||||
{ 255, 192, 32, 128 }, // 4
|
||||
{ 230, 230, 220, 64 }, // 5
|
||||
{ 128, 150, 255, 128 }, // 6
|
||||
{ 128, 255, 32, 128 }, // 7
|
||||
};
|
||||
|
||||
InputCombo inputCombos[REG_GROUPS] = {
|
||||
{ BTN_L, BTN_CUP }, { BTN_L, BTN_CLEFT }, { BTN_L, BTN_CDOWN }, { BTN_L, BTN_A }, { BTN_R, BTN_CDOWN },
|
||||
{ BTN_L, BTN_CRIGHT }, { BTN_L, BTN_R }, { BTN_L, BTN_DLEFT }, { BTN_L, BTN_DRIGHT }, { BTN_L, BTN_DUP },
|
||||
{ BTN_L, BTN_B }, { BTN_L, BTN_Z }, { BTN_L, BTN_DDOWN }, { BTN_R, BTN_A }, { BTN_R, BTN_B },
|
||||
{ BTN_R, BTN_Z }, { BTN_R, BTN_L }, { BTN_R, BTN_CUP }, { BTN_R, BTN_CRIGHT }, { BTN_R, BTN_DLEFT },
|
||||
{ BTN_R, BTN_CLEFT }, { BTN_R, BTN_START }, { BTN_L, BTN_START }, { BTN_R, BTN_DRIGHT }, { BTN_R, BTN_DUP },
|
||||
{ BTN_START, BTN_R }, { BTN_START, BTN_A }, { BTN_START, BTN_B }, { BTN_START, BTN_CRIGHT },
|
||||
InputCombo sRegGroupInputCombos[REG_GROUPS] = {
|
||||
{ BTN_L, BTN_CUP }, // REG
|
||||
{ BTN_L, BTN_CLEFT }, // SREG
|
||||
{ BTN_L, BTN_CDOWN }, // OREG
|
||||
{ BTN_L, BTN_A }, // PREG
|
||||
{ BTN_R, BTN_CDOWN }, // QREG
|
||||
{ BTN_L, BTN_CRIGHT }, // MREG
|
||||
{ BTN_L, BTN_R }, // YREG
|
||||
{ BTN_L, BTN_DLEFT }, // DREG
|
||||
{ BTN_L, BTN_DRIGHT }, // UREG
|
||||
{ BTN_L, BTN_DUP }, // IREG
|
||||
{ BTN_L, BTN_B }, // ZREG
|
||||
{ BTN_L, BTN_Z }, // CREG
|
||||
{ BTN_L, BTN_DDOWN }, // NREG
|
||||
{ BTN_R, BTN_A }, // KREG
|
||||
{ BTN_R, BTN_B }, // XREG
|
||||
{ BTN_R, BTN_Z }, // cREG
|
||||
{ BTN_R, BTN_L }, // sREG
|
||||
{ BTN_R, BTN_CUP }, // iREG
|
||||
{ BTN_R, BTN_CRIGHT }, // WREG
|
||||
{ BTN_R, BTN_DLEFT }, // AREG
|
||||
{ BTN_R, BTN_CLEFT }, // VREG
|
||||
{ BTN_R, BTN_START }, // HREG
|
||||
{ BTN_L, BTN_START }, // GREG
|
||||
{ BTN_R, BTN_DRIGHT }, // mREG
|
||||
{ BTN_R, BTN_DUP }, // nREG
|
||||
{ BTN_START, BTN_R }, // BREG
|
||||
{ BTN_START, BTN_A }, // dREG
|
||||
{ BTN_START, BTN_B }, // kREG
|
||||
{ BTN_START, BTN_CRIGHT }, // bREG
|
||||
|
||||
};
|
||||
|
||||
char regChar[] = " SOPQMYDUIZCNKXcsiWAVHGmnBdkb";
|
||||
char sRegGroupChars[REG_GROUPS] = {
|
||||
' ', // REG
|
||||
'S', // SREG
|
||||
'O', // OREG
|
||||
'P', // PREG
|
||||
'Q', // QREG
|
||||
'M', // MREG
|
||||
'Y', // YREG
|
||||
'D', // DREG
|
||||
'U', // UREG
|
||||
'I', // IREG
|
||||
'Z', // ZREG
|
||||
'C', // CREG
|
||||
'N', // NREG
|
||||
'K', // KREG
|
||||
'X', // XREG
|
||||
'c', // cREG
|
||||
's', // sREG
|
||||
'i', // iREG
|
||||
'W', // WREG
|
||||
'A', // AREG
|
||||
'V', // VREG
|
||||
'H', // HREG
|
||||
'G', // GREG
|
||||
'm', // mREG
|
||||
'n', // nREG
|
||||
'B', // BREG
|
||||
'd', // dREG
|
||||
'k', // kREG
|
||||
'b', // bREG
|
||||
};
|
||||
|
||||
// initialize GameInfo
|
||||
// Initialize GameInfo
|
||||
void func_800636C0(void) {
|
||||
s32 i;
|
||||
|
||||
|
@ -41,166 +100,168 @@ void func_800636C0(void) {
|
|||
gGameInfo->regPage = 0;
|
||||
gGameInfo->regGroup = 0;
|
||||
gGameInfo->regCur = 0;
|
||||
gGameInfo->dpadLast = 0;
|
||||
gGameInfo->repeat = 0;
|
||||
gGameInfo->dPadInputPrev = 0;
|
||||
gGameInfo->inputRepeatTimer = 0;
|
||||
for (i = 0; i < ARRAY_COUNT(gGameInfo->data); i++) {
|
||||
gGameInfo->data[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Called when free movement is active.
|
||||
// 8011D394 to enable camera debugger
|
||||
void func_8006375C(s32 arg0, s32 arg1, const char* text) {
|
||||
}
|
||||
|
||||
// Copy Camera Debugger Text
|
||||
void func_8006376C(u8 x, u8 y, u8 colorId, const char* text) {
|
||||
PrintTextBuffer* buf;
|
||||
char* bufText;
|
||||
s16 i;
|
||||
// Store text during Update, to be drawn later during Draw
|
||||
void func_8006376C(u8 x, u8 y, u8 colorIndex, const char* text) {
|
||||
PrintTextBufferEntry* entry;
|
||||
char* textDest;
|
||||
s16 charCount;
|
||||
|
||||
buf = &D_8015FA98[D_8011E0B0];
|
||||
if (D_8011E0B0 < 0x16) {
|
||||
buf->x = x;
|
||||
buf->y = y;
|
||||
buf->colorId = colorId;
|
||||
entry = &sDebugPrintTextBuffer[sDebugPrintTextBufferNumUsed];
|
||||
if (sDebugPrintTextBufferNumUsed < ARRAY_COUNT(sDebugPrintTextBuffer)) {
|
||||
entry->x = x;
|
||||
entry->y = y;
|
||||
entry->colorIndex = colorIndex;
|
||||
|
||||
i = 0;
|
||||
bufText = buf->text;
|
||||
while ((*bufText++ = *text++) != '\0') {
|
||||
if (i++ > 0x14) {
|
||||
// Copy text into the entry, truncating if needed
|
||||
charCount = 0;
|
||||
textDest = entry->text;
|
||||
while ((*textDest++ = *text++) != '\0') {
|
||||
if (charCount++ > (ARRAY_COUNT(entry->text) - 1)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*textDest = '\0';
|
||||
|
||||
*bufText = '\0';
|
||||
D_8011E0B0++;
|
||||
sDebugPrintTextBufferNumUsed++;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Text
|
||||
// Draw text previously stored by calls to `func_8006376C`
|
||||
void func_80063828(GfxPrint* printer) {
|
||||
s32 i;
|
||||
Color_RGBA8* color;
|
||||
PrintTextBuffer* buffer;
|
||||
char* text;
|
||||
PrintTextBufferEntry* entry;
|
||||
|
||||
i = 0;
|
||||
if (D_8011E0B0 > 0) {
|
||||
do {
|
||||
buffer = &D_8015FA98[i];
|
||||
text = buffer->text;
|
||||
for (i = 0; i < sDebugPrintTextBufferNumUsed; i++) {
|
||||
entry = &sDebugPrintTextBuffer[i];
|
||||
|
||||
color = &printTextColors[buffer->colorId];
|
||||
GfxPrint_SetColor(printer, color->r, color->g, color->b, color->a);
|
||||
GfxPrint_SetPos(printer, buffer->x, buffer->y);
|
||||
GfxPrint_Printf(printer, "%s", text);
|
||||
i += 1;
|
||||
} while (i < D_8011E0B0);
|
||||
color = &sDebugPrintTextColors[entry->colorIndex];
|
||||
GfxPrint_SetColor(printer, color->r, color->g, color->b, color->a);
|
||||
GfxPrint_SetPos(printer, entry->x, entry->y);
|
||||
GfxPrint_Printf(printer, "%s", entry->text);
|
||||
}
|
||||
}
|
||||
|
||||
// Edit REG
|
||||
// Process inputs to control the reg editor
|
||||
void func_8006390C(Input* input) {
|
||||
|
||||
s32 dpad;
|
||||
s32 regGroup;
|
||||
s32 dPadInputCur;
|
||||
s32 pageDataStart = ((gGameInfo->regGroup * REG_PAGES) + gGameInfo->regPage - 1) * REGS_PER_PAGE;
|
||||
s32 increment;
|
||||
InputCombo* input_combo;
|
||||
s32 i;
|
||||
|
||||
regGroup = (gGameInfo->regGroup * REG_PAGES + gGameInfo->regPage) * REG_PER_PAGE - REG_PER_PAGE;
|
||||
dpad = input->cur.button & (BTN_DUP | BTN_DLEFT | BTN_DRIGHT | BTN_DDOWN);
|
||||
dPadInputCur = input->cur.button & (BTN_DUP | BTN_DLEFT | BTN_DRIGHT | BTN_DDOWN);
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_L) || CHECK_BTN_ALL(input->cur.button, BTN_R) ||
|
||||
CHECK_BTN_ALL(input->cur.button, BTN_START)) {
|
||||
input_combo = inputCombos;
|
||||
|
||||
for (i = 0; i < REG_GROUPS; i++) {
|
||||
if (~(~input_combo->push | input->cur.button) || ~(~input_combo->held | input->press.button)) {
|
||||
input_combo++;
|
||||
} else {
|
||||
if (CHECK_BTN_ALL(input->cur.button, sRegGroupInputCombos[i].hold) &&
|
||||
CHECK_BTN_ALL(input->press.button, sRegGroupInputCombos[i].press)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If a combo corresponding to a reg group was found
|
||||
if (i < REG_GROUPS) {
|
||||
if (i == gGameInfo->regGroup) {
|
||||
// Same reg group as current, advance page index
|
||||
gGameInfo->regPage = (gGameInfo->regPage + 1) % (REG_PAGES + 1);
|
||||
return;
|
||||
} else {
|
||||
gGameInfo->regGroup = i; // Switch current reg group
|
||||
gGameInfo->regPage = 0; // Disable reg editor
|
||||
}
|
||||
gGameInfo->regGroup = i;
|
||||
gGameInfo->regPage = 0;
|
||||
}
|
||||
} else {
|
||||
switch (gGameInfo->regPage - 1) {
|
||||
case 0:
|
||||
switch (gGameInfo->regPage) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
|
||||
if (dpad == gGameInfo->dpadLast) {
|
||||
gGameInfo->repeat--;
|
||||
if (gGameInfo->repeat < 0) {
|
||||
gGameInfo->repeat = 1;
|
||||
if (dPadInputCur == gGameInfo->dPadInputPrev) {
|
||||
gGameInfo->inputRepeatTimer--;
|
||||
if (gGameInfo->inputRepeatTimer < 0) {
|
||||
gGameInfo->inputRepeatTimer = 1;
|
||||
} else {
|
||||
dpad ^= gGameInfo->dpadLast;
|
||||
dPadInputCur ^= gGameInfo->dPadInputPrev;
|
||||
}
|
||||
} else {
|
||||
gGameInfo->repeat = 0x10;
|
||||
gGameInfo->dpadLast = dpad;
|
||||
gGameInfo->inputRepeatTimer = 16;
|
||||
gGameInfo->dPadInputPrev = dPadInputCur;
|
||||
}
|
||||
|
||||
increment = CHECK_BTN_ANY(dpad, BTN_DRIGHT) ? (CHECK_BTN_ALL(input->cur.button, BTN_A | BTN_B) ? 1000
|
||||
increment =
|
||||
CHECK_BTN_ANY(dPadInputCur, BTN_DRIGHT) ? (CHECK_BTN_ALL(input->cur.button, BTN_A | BTN_B) ? 1000
|
||||
: CHECK_BTN_ALL(input->cur.button, BTN_A) ? 100
|
||||
: CHECK_BTN_ALL(input->cur.button, BTN_B) ? 10
|
||||
: 1)
|
||||
: CHECK_BTN_ANY(dpad, BTN_DLEFT) ? (CHECK_BTN_ALL(input->cur.button, BTN_A | BTN_B) ? -1000
|
||||
: CHECK_BTN_ANY(dPadInputCur, BTN_DLEFT) ? (CHECK_BTN_ALL(input->cur.button, BTN_A | BTN_B) ? -1000
|
||||
: CHECK_BTN_ALL(input->cur.button, BTN_A) ? -100
|
||||
: CHECK_BTN_ALL(input->cur.button, BTN_B) ? -10
|
||||
: -1)
|
||||
: 0;
|
||||
|
||||
gGameInfo->data[gGameInfo->regCur + regGroup] += increment;
|
||||
if (CHECK_BTN_ANY(dpad, BTN_DUP)) {
|
||||
gGameInfo->data[gGameInfo->regCur + pageDataStart] += increment;
|
||||
|
||||
if (CHECK_BTN_ANY(dPadInputCur, BTN_DUP)) {
|
||||
gGameInfo->regCur--;
|
||||
if (gGameInfo->regCur < 0) {
|
||||
gGameInfo->regCur = REG_PER_PAGE - 1;
|
||||
gGameInfo->regCur = REGS_PER_PAGE - 1;
|
||||
}
|
||||
} else if (CHECK_BTN_ANY(dpad, BTN_DDOWN)) {
|
||||
} else if (CHECK_BTN_ANY(dPadInputCur, BTN_DDOWN)) {
|
||||
gGameInfo->regCur++;
|
||||
if (gGameInfo->regCur >= REG_PER_PAGE) {
|
||||
if (gGameInfo->regCur >= REGS_PER_PAGE) {
|
||||
gGameInfo->regCur = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (iREG(0)) {
|
||||
iREG(0) = 0;
|
||||
func_800AA000(0, iREG(1), iREG(2), iREG(3));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Memory Viewer
|
||||
// Draw the reg editor
|
||||
void func_80063C04(GfxPrint* printer) {
|
||||
s32 i;
|
||||
s32 page = (gGameInfo->regPage * REG_PER_PAGE) - REG_PER_PAGE;
|
||||
s32 regGroup = (gGameInfo->regGroup * REG_PAGES + gGameInfo->regPage) * REG_PER_PAGE - REG_PER_PAGE;
|
||||
s32 pageStart = (gGameInfo->regPage - 1) * REGS_PER_PAGE;
|
||||
s32 pageDataStart = ((gGameInfo->regGroup * REG_PAGES) + gGameInfo->regPage - 1) * REGS_PER_PAGE;
|
||||
s32 pad;
|
||||
char name[3];
|
||||
char regGroupName[3];
|
||||
|
||||
regGroupName[0] = 'R';
|
||||
regGroupName[1] = sRegGroupChars[gGameInfo->regGroup];
|
||||
regGroupName[2] = '\0';
|
||||
|
||||
// set up register name string
|
||||
name[0] = 'R';
|
||||
name[1] = regChar[gGameInfo->regGroup]; // r_group type char
|
||||
name[2] = '\0';
|
||||
GfxPrint_SetColor(printer, 0, 128, 128, 128);
|
||||
|
||||
for (i = 0; i != REG_PER_PAGE; i++) {
|
||||
for (i = 0; i < REGS_PER_PAGE; i++) {
|
||||
if (i == gGameInfo->regCur) {
|
||||
GfxPrint_SetColor(printer, 0, 255, 255, 255);
|
||||
}
|
||||
|
||||
GfxPrint_SetPos(printer, 3, i + 5);
|
||||
GfxPrint_Printf(printer, "%s%02d%6d", &name, page + i, gGameInfo->data[i + regGroup]);
|
||||
GfxPrint_Printf(printer, "%s%02d%6d", regGroupName, pageStart + i, gGameInfo->data[i + pageDataStart]);
|
||||
|
||||
if (i == gGameInfo->regCur) {
|
||||
GfxPrint_SetColor(printer, 0, 128, 128, 128);
|
||||
}
|
||||
|
@ -208,18 +269,18 @@ void func_80063C04(GfxPrint* printer) {
|
|||
}
|
||||
|
||||
void func_80063D7C(GraphicsContext* gfxCtx) {
|
||||
Gfx* sp7C;
|
||||
Gfx* sp78;
|
||||
Gfx* gfx;
|
||||
Gfx* opaStart;
|
||||
GfxPrint printer;
|
||||
Gfx* tempRet;
|
||||
s32 pad;
|
||||
|
||||
OPEN_DISPS(gfxCtx, "../z_debug.c", 628);
|
||||
|
||||
GfxPrint_Init(&printer);
|
||||
sp78 = POLY_OPA_DISP;
|
||||
tempRet = Graph_GfxPlusOne(POLY_OPA_DISP);
|
||||
gSPDisplayList(OVERLAY_DISP++, tempRet);
|
||||
GfxPrint_Open(&printer, tempRet);
|
||||
opaStart = POLY_OPA_DISP;
|
||||
gfx = Graph_GfxPlusOne(POLY_OPA_DISP);
|
||||
gSPDisplayList(OVERLAY_DISP++, gfx);
|
||||
GfxPrint_Open(&printer, gfx);
|
||||
|
||||
if ((OREG(0) == 1) || (OREG(0) == 8)) {
|
||||
func_80063828(&printer);
|
||||
|
@ -229,11 +290,12 @@ void func_80063D7C(GraphicsContext* gfxCtx) {
|
|||
func_80063C04(&printer);
|
||||
}
|
||||
|
||||
D_8011E0B0 = 0;
|
||||
sp7C = GfxPrint_Close(&printer);
|
||||
gSPEndDisplayList(sp7C++);
|
||||
Graph_BranchDlist(sp78, sp7C);
|
||||
POLY_OPA_DISP = sp7C;
|
||||
sDebugPrintTextBufferNumUsed = 0;
|
||||
|
||||
gfx = GfxPrint_Close(&printer);
|
||||
gSPEndDisplayList(gfx++);
|
||||
Graph_BranchDlist(opaStart, gfx);
|
||||
POLY_OPA_DISP = gfx;
|
||||
|
||||
if (1) {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue