From 32fe030b42bc001b71d6edcf0530f60e6ecd73cc Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 18 Mar 2020 10:27:49 -0400 Subject: new repo, OK++ --- src/code/z_debug.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 276 insertions(+), 6 deletions(-) (limited to 'src/code') diff --git a/src/code/z_debug.c b/src/code/z_debug.c index b5d078985..74f3965eb 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -1,20 +1,290 @@ #include #include +#include +#include +#include -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_800636C0.s") +#define BUTTON_C_RIGHT 0x0001 +#define BUTTON_C_LEFT 0x0002 +#define BUTTON_C_DOWN 0x0004 +#define BUTTON_C_UP 0x0008 +#define BUTTON_R 0x0010 +#define BUTTON_L 0x0020 +#define BUTTON_D_RIGHT 0x0100 +#define BUTTON_D_LEFT 0x0200 +#define BUTTON_D_DOWN 0x0400 +#define BUTTON_D_UP 0x0800 +#define BUTTON_START 0x1000 +#define BUTTON_Z 0x2000 +#define BUTTON_B 0x4000 +#define BUTTON_A 0x8000 -void func_8006375C(UNK_TYPE arg0, UNK_TYPE arg1, UNK_TYPE arg2) +#define REG_GROUP_TOTAL 29 +#define REG_N 96 +#define PAGE_N 16 + +GameInfo* gGameInfo; +int D_8015FA94; //no known symbols + +typedef struct +{ + u8 x; + u8 y; + u8 colorId; + char text[0x15]; +} PrintTextBuffer; + +PrintTextBuffer D_8015FA98[0x16]; +//s16 D_8011E0B0 //PrintTextBuffer index + +//#define D_8015FC18 D_8015FA98[0x10] +typedef struct +{ + u16 push; + u16 held; +} InputCombo; + +extern InputCombo D_8011E0D4[REG_GROUP_TOTAL]; //register button combos + +extern char D_8011E148[]; + +//initialize GameInfo +void func_800636C0() +{ + s32 i; + + gGameInfo = (GameInfo*)SystemArena_MallocDebug(sizeof(GameInfo), "../z_debug.c", 0x104); + gGameInfo->reg_page = 0; + gGameInfo->reg_group = 0; + gGameInfo->reg_cur = 0; + gGameInfo->dpad_last = 0; + gGameInfo->repeat = 0; + for (i = 0; i < 0xAE0; i++) + { + gGameInfo->data[i] = 0; + } +} + +//Called when free movement is active +void func_8006375C(s32 arg0, s32 arg1, float* d_80855320) { } +//8011D394 enable camera debugger + +#ifdef NON_MATCHING //regalloc +//Copy Camera Debugger Text +void func_8006376C(u8 x, u8 y, u8 colorId, const char* text) +{ + PrintTextBuffer* buf; + char* next_text; + s16 i; //v1 + + buf = &D_8015FA98[D_8011E0B0]; + if (D_8011E0B0 < 0x16) { + + buf->x = x; + buf->y = y; + buf->colorId = colorId; + + i = 0; + next_text = buf->text + 1; + + if (*buf->text = *text++) { + do if (i++ > 0x14) { + break; + } while (*next_text++ = *text++); + } + + *next_text = '\0'; + D_8011E0B0++; + } +} + +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_8006376C.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_80063828.s") +//Draw Text +void func_80063828(GfxPrint* gfxPrint) +{ + s32 i; + Color_RGBA8* color; + PrintTextBuffer* buffer; + char* text; + + i = 0; + if (D_8011E0B0 > 0) + { + do + { + buffer = &D_8015FA98[i]; + text = buffer->text; + + color = &D_8011E0B4[buffer->colorId]; + GfxPrint_SetColor(gfxPrint, color->r, color->g, color->b, color->a); + GfxPrint_SetPos(gfxPrint, buffer->x, buffer->y); + GfxPrint_Printf(gfxPrint, "%s", text); + i += 1; + } while (i < D_8011E0B0); + } +} + +//Edit REG +void func_8006390C(Input* input) { + + s32 dpad; + s32 reg_group; + s32 increment; + InputCombo* input_combo; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_8006390C.s") + reg_group = (gGameInfo->reg_group * (REG_N / PAGE_N) + gGameInfo->reg_page) * PAGE_N - PAGE_N; + dpad = input->raw.pad & 0xF00; + if (!~(input->raw.pad | ~BUTTON_L) || + !~(input->raw.pad | ~BUTTON_R) || + !~(input->raw.pad | ~BUTTON_START)) { + input_combo = D_8011E0D4; + for (i = 0; i < REG_GROUP_TOTAL; i++) + { + if (~(~input_combo->push | input->raw.pad) || + ~(~input_combo->held | input->padPressed)) { + input_combo++; + } + else + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_80063C04.s") + if (i < REG_GROUP_TOTAL) { + if (i == gGameInfo->reg_group) { + gGameInfo->reg_page = (gGameInfo->reg_page + 1) % 7; + return; + } + gGameInfo->reg_group = i; + gGameInfo->reg_page = 0; + } + } + else { + switch (gGameInfo->reg_page - 1) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_80063D7C.s") + if (dpad == gGameInfo->dpad_last) { + gGameInfo->repeat--; + if (gGameInfo->repeat < 0) { + gGameInfo->repeat = 1; + } + else { + dpad ^= gGameInfo->dpad_last; + } + } + else { + gGameInfo->repeat = 0x10; + gGameInfo->dpad_last = dpad; + } + increment = + (dpad & BUTTON_D_RIGHT) ? ( + !~(input->raw.pad | ~(BUTTON_A | BUTTON_B)) ? 1000 : + !~(input->raw.pad | ~BUTTON_A) ? 100 : + !~(input->raw.pad | ~BUTTON_B) ? 10 : 1) : + (dpad & BUTTON_D_LEFT) ? ( + !~(input->raw.pad | ~(BUTTON_A | BUTTON_B)) ? -1000 : + !~(input->raw.pad | ~BUTTON_A) ? -100 : + !~(input->raw.pad | ~BUTTON_B) ? -10 : -1) : + 0; + + gGameInfo->data[gGameInfo->reg_cur + reg_group] += increment; + if (dpad & BUTTON_D_UP) { + gGameInfo->reg_cur--; + if (gGameInfo->reg_cur < 0) { + gGameInfo->reg_cur = PAGE_N - 1; + } + } + else if (dpad & BUTTON_D_DOWN) { + gGameInfo->reg_cur++; + if (gGameInfo->reg_cur >= PAGE_N) { + gGameInfo->reg_cur = 0; + } + } + if (iREG(0)) { + iREG(0) = 0; + func_800AA000(0, iREG(1), iREG(2), iREG(3)); + } + + } + } +} + +//Draw Memory Viewer +void func_80063C04(GfxPrint* gfxPrint) +{ + s32 i; + s32 page; + s32 reg_group; + s32 test; //removing affects stack + char reg_name[3]; + + page = (gGameInfo->reg_page * PAGE_N) - PAGE_N; + reg_group = (gGameInfo->reg_group * (REG_N / PAGE_N) + gGameInfo->reg_page) * PAGE_N - PAGE_N; + + //set up register name string + reg_name[0] = 'R'; + reg_name[1] = D_8011E148[gGameInfo->reg_group]; //r_group type char + reg_name[2] = '\0'; + GfxPrint_SetColor(gfxPrint, 0, 0x80, 0x80, 0x80); + + for (i = 0; i != PAGE_N; i++) + { + if (i == gGameInfo->reg_cur) + { + GfxPrint_SetColor(gfxPrint, 0, 0xff, 0xff, 0xff); + } + GfxPrint_SetPos(gfxPrint, 3, i + 5); + GfxPrint_Printf(gfxPrint, "%s%02d%6d", ®_name, page + i, gGameInfo->data[i + reg_group]); + if (i == gGameInfo->reg_cur) + { + GfxPrint_SetColor(gfxPrint, 0, 0x80, 0x80, 0x80); + } + } +} + +void func_80063D7C(GraphicsContext* gfxCtx) { + Gfx* sp7C; + Gfx* sp78; + Gfx* temp_ret; + void* unk2[6]; + GfxPrint gfxPrint; + void* unk[2]; + Gfx* dl_frame[4];//stores state of GfxCtx next ptrs + + func_800C6AC4(&dl_frame, gfxCtx, "../z_debug.c", 0x274); + GfxPrint_Ctor(&gfxPrint); + sp78 = gfxCtx->polyOpa.p; + temp_ret = func_800C6C20(gfxCtx->polyOpa.p); + gSPDisplayList(gfxCtx->overlay.p++, temp_ret); + GfxPrint_Open(&gfxPrint, temp_ret); + + if ((OREG(0) == 1) || (OREG(0) == 8)) { + func_80063828(&gfxPrint); + } + + if (gGameInfo->reg_page != 0) { + func_80063C04(&gfxPrint); + } + + D_8011E0B0 = 0; + sp7C = GfxPrint_Close(&gfxPrint); + gSPEndDisplayList(sp7C++); + func_800C6C28(sp78, sp7C); + gfxCtx->polyOpa.p = sp7C; + if (0); + func_800C6B54(&dl_frame, gfxCtx, "../z_debug.c", 0x298); + GfxPrint_Dtor(&gfxPrint); +} -- cgit v1.2.3 From dd4f67c3f51eba222060449972783951beedff9b Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 18 Mar 2020 12:31:36 -0400 Subject: convert z_debug.data --- src/code/z_debug.c | 71 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 17 deletions(-) (limited to 'src/code') diff --git a/src/code/z_debug.c b/src/code/z_debug.c index 74f3965eb..f0971cfbf 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -23,9 +23,6 @@ #define REG_N 96 #define PAGE_N 16 -GameInfo* gGameInfo; -int D_8015FA94; //no known symbols - typedef struct { u8 x; @@ -34,19 +31,61 @@ typedef struct char text[0x15]; } PrintTextBuffer; -PrintTextBuffer D_8015FA98[0x16]; -//s16 D_8011E0B0 //PrintTextBuffer index - -//#define D_8015FC18 D_8015FA98[0x10] typedef struct { u16 push; u16 held; } InputCombo; -extern InputCombo D_8011E0D4[REG_GROUP_TOTAL]; //register button combos +GameInfo* gGameInfo; +int D_8015FA94; //no known symbols +PrintTextBuffer D_8015FA98[0x16]; -extern char D_8011E148[]; +s16 D_8011E0B0 = 0; //PrintTextBuffer index +Color_RGBA8 printTextColors[] = { + { 0xFF, 0xFF, 0x20, 0xC0 }, + { 0xFF, 0x96, 0x80, 0xC0 }, + { 0x80, 0x60, 0x00, 0x40 }, + { 0xC0, 0x80, 0x10, 0x80 }, + { 0xFF, 0xC0, 0x20, 0x80 }, + { 0xE6, 0xE6, 0xDC, 0x40 }, + { 0x80, 0x96, 0xFF, 0x80 }, + { 0x80, 0xFF, 0x20, 0x80 }, +}; + +InputCombo inputCombos[REG_GROUP_TOTAL] = { + { BUTTON_L, BUTTON_C_UP }, + { BUTTON_L, BUTTON_C_LEFT }, + { BUTTON_L, BUTTON_C_DOWN }, + { BUTTON_L, BUTTON_A }, + { BUTTON_R, BUTTON_C_DOWN }, + { BUTTON_L, BUTTON_C_RIGHT }, + { BUTTON_L, BUTTON_R }, + { BUTTON_L, BUTTON_D_LEFT }, + { BUTTON_L, BUTTON_D_RIGHT }, + { BUTTON_L, BUTTON_D_UP }, + { BUTTON_L, BUTTON_B }, + { BUTTON_L, BUTTON_Z }, + { BUTTON_L, BUTTON_D_DOWN }, + { BUTTON_R, BUTTON_A }, + { BUTTON_R, BUTTON_B }, + { BUTTON_R, BUTTON_Z }, + { BUTTON_R, BUTTON_L }, + { BUTTON_R, BUTTON_C_UP }, + { BUTTON_R, BUTTON_C_RIGHT }, + { BUTTON_R, BUTTON_D_LEFT }, + { BUTTON_R, BUTTON_C_LEFT }, + { BUTTON_R, BUTTON_START }, + { BUTTON_L, BUTTON_START }, + { BUTTON_R, BUTTON_D_RIGHT }, + { BUTTON_R, BUTTON_D_UP }, + { BUTTON_START, BUTTON_R }, + { BUTTON_START, BUTTON_A }, + { BUTTON_START, BUTTON_B }, + { BUTTON_START, BUTTON_C_RIGHT }, +}; + +char regChar[] = " SOPQMYDUIZCNKXcsiWAVHGmnBdkb"; //initialize GameInfo void func_800636C0() @@ -65,14 +104,13 @@ void func_800636C0() } } -//Called when free movement is active +//Called when free movement is active. +//8011D394 to enable camera debugger void func_8006375C(s32 arg0, s32 arg1, float* d_80855320) { } -//8011D394 enable camera debugger - #ifdef NON_MATCHING //regalloc //Copy Camera Debugger Text void func_8006376C(u8 x, u8 y, u8 colorId, const char* text) @@ -122,7 +160,7 @@ void func_80063828(GfxPrint* gfxPrint) buffer = &D_8015FA98[i]; text = buffer->text; - color = &D_8011E0B4[buffer->colorId]; + color = &printTextColors[buffer->colorId]; GfxPrint_SetColor(gfxPrint, color->r, color->g, color->b, color->a); GfxPrint_SetPos(gfxPrint, buffer->x, buffer->y); GfxPrint_Printf(gfxPrint, "%s", text); @@ -145,7 +183,7 @@ void func_8006390C(Input* input) { if (!~(input->raw.pad | ~BUTTON_L) || !~(input->raw.pad | ~BUTTON_R) || !~(input->raw.pad | ~BUTTON_START)) { - input_combo = D_8011E0D4; + input_combo = inputCombos; for (i = 0; i < REG_GROUP_TOTAL; i++) { if (~(~input_combo->push | input->raw.pad) || @@ -217,7 +255,6 @@ void func_8006390C(Input* input) { iREG(0) = 0; func_800AA000(0, iREG(1), iREG(2), iREG(3)); } - } } } @@ -236,7 +273,7 @@ void func_80063C04(GfxPrint* gfxPrint) //set up register name string reg_name[0] = 'R'; - reg_name[1] = D_8011E148[gGameInfo->reg_group]; //r_group type char + reg_name[1] = regChar[gGameInfo->reg_group]; //r_group type char reg_name[2] = '\0'; GfxPrint_SetColor(gfxPrint, 0, 0x80, 0x80, 0x80); @@ -262,7 +299,7 @@ void func_80063D7C(GraphicsContext* gfxCtx) { void* unk2[6]; GfxPrint gfxPrint; void* unk[2]; - Gfx* dl_frame[4];//stores state of GfxCtx next ptrs + Gfx* dl_frame[4]; //stores state of GfxCtx next ptrs func_800C6AC4(&dl_frame, gfxCtx, "../z_debug.c", 0x274); GfxPrint_Ctor(&gfxPrint); -- cgit v1.2.3 From 8063249af48736010d909cefd33aa8f194c223ce Mon Sep 17 00:00:00 2001 From: mzxrules Date: Thu, 19 Mar 2020 18:06:41 -0400 Subject: changes --- src/code/z_debug.c | 198 ++++++++++++++++++++++++----------------------------- 1 file changed, 91 insertions(+), 107 deletions(-) (limited to 'src/code') diff --git a/src/code/z_debug.c b/src/code/z_debug.c index f0971cfbf..489636d41 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -3,24 +3,8 @@ #include #include #include +#include -#define BUTTON_C_RIGHT 0x0001 -#define BUTTON_C_LEFT 0x0002 -#define BUTTON_C_DOWN 0x0004 -#define BUTTON_C_UP 0x0008 -#define BUTTON_R 0x0010 -#define BUTTON_L 0x0020 -#define BUTTON_D_RIGHT 0x0100 -#define BUTTON_D_LEFT 0x0200 -#define BUTTON_D_DOWN 0x0400 -#define BUTTON_D_UP 0x0800 -#define BUTTON_START 0x1000 -#define BUTTON_Z 0x2000 -#define BUTTON_B 0x4000 -#define BUTTON_A 0x8000 - -#define REG_GROUP_TOTAL 29 -#define REG_N 96 #define PAGE_N 16 typedef struct @@ -53,36 +37,36 @@ Color_RGBA8 printTextColors[] = { { 0x80, 0xFF, 0x20, 0x80 }, }; -InputCombo inputCombos[REG_GROUP_TOTAL] = { - { BUTTON_L, BUTTON_C_UP }, - { BUTTON_L, BUTTON_C_LEFT }, - { BUTTON_L, BUTTON_C_DOWN }, - { BUTTON_L, BUTTON_A }, - { BUTTON_R, BUTTON_C_DOWN }, - { BUTTON_L, BUTTON_C_RIGHT }, - { BUTTON_L, BUTTON_R }, - { BUTTON_L, BUTTON_D_LEFT }, - { BUTTON_L, BUTTON_D_RIGHT }, - { BUTTON_L, BUTTON_D_UP }, - { BUTTON_L, BUTTON_B }, - { BUTTON_L, BUTTON_Z }, - { BUTTON_L, BUTTON_D_DOWN }, - { BUTTON_R, BUTTON_A }, - { BUTTON_R, BUTTON_B }, - { BUTTON_R, BUTTON_Z }, - { BUTTON_R, BUTTON_L }, - { BUTTON_R, BUTTON_C_UP }, - { BUTTON_R, BUTTON_C_RIGHT }, - { BUTTON_R, BUTTON_D_LEFT }, - { BUTTON_R, BUTTON_C_LEFT }, - { BUTTON_R, BUTTON_START }, - { BUTTON_L, BUTTON_START }, - { BUTTON_R, BUTTON_D_RIGHT }, - { BUTTON_R, BUTTON_D_UP }, - { BUTTON_START, BUTTON_R }, - { BUTTON_START, BUTTON_A }, - { BUTTON_START, BUTTON_B }, - { BUTTON_START, BUTTON_C_RIGHT }, +InputCombo inputCombos[REG_GROUPS] = { + { L_TRIG, U_CBUTTONS }, + { L_TRIG, L_CBUTTONS }, + { L_TRIG, D_CBUTTONS }, + { L_TRIG, A_BUTTON }, + { R_TRIG, D_CBUTTONS }, + { L_TRIG, R_CBUTTONS }, + { L_TRIG, R_TRIG }, + { L_TRIG, L_JPAD }, + { L_TRIG, R_JPAD }, + { L_TRIG, U_JPAD }, + { L_TRIG, B_BUTTON }, + { L_TRIG, Z_TRIG }, + { L_TRIG, D_JPAD }, + { R_TRIG, A_BUTTON }, + { R_TRIG, B_BUTTON }, + { R_TRIG, Z_TRIG }, + { R_TRIG, L_TRIG }, + { R_TRIG, U_CBUTTONS }, + { R_TRIG, R_CBUTTONS }, + { R_TRIG, L_JPAD }, + { R_TRIG, L_CBUTTONS }, + { R_TRIG, START_BUTTON }, + { L_TRIG, START_BUTTON }, + { R_TRIG, R_JPAD }, + { R_TRIG, U_JPAD }, + { START_BUTTON, R_TRIG }, + { START_BUTTON, A_BUTTON }, + { START_BUTTON, B_BUTTON }, + { START_BUTTON, R_CBUTTONS }, }; char regChar[] = " SOPQMYDUIZCNKXcsiWAVHGmnBdkb"; @@ -92,13 +76,13 @@ void func_800636C0() { s32 i; - gGameInfo = (GameInfo*)SystemArena_MallocDebug(sizeof(GameInfo), "../z_debug.c", 0x104); - gGameInfo->reg_page = 0; - gGameInfo->reg_group = 0; - gGameInfo->reg_cur = 0; - gGameInfo->dpad_last = 0; + gGameInfo = (GameInfo*)SystemArena_MallocDebug(sizeof(GameInfo), "../z_debug.c", 260); + gGameInfo->regPage = 0; + gGameInfo->regGroup = 0; + gGameInfo->regCur = 0; + gGameInfo->dpadLast = 0; gGameInfo->repeat = 0; - for (i = 0; i < 0xAE0; i++) + for (i = 0; i < ARRAY_COUNT(gGameInfo->data); i++) { gGameInfo->data[i] = 0; } @@ -116,7 +100,7 @@ void func_8006375C(s32 arg0, s32 arg1, float* d_80855320) void func_8006376C(u8 x, u8 y, u8 colorId, const char* text) { PrintTextBuffer* buf; - char* next_text; + char* bufText; s16 i; //v1 buf = &D_8015FA98[D_8011E0B0]; @@ -127,15 +111,15 @@ void func_8006376C(u8 x, u8 y, u8 colorId, const char* text) buf->colorId = colorId; i = 0; - next_text = buf->text + 1; + bufText = buf->text + 1; if (*buf->text = *text++) { do if (i++ > 0x14) { break; - } while (*next_text++ = *text++); + } while (*bufText++ = *text++); } - *next_text = '\0'; + *bufText = '\0'; D_8011E0B0++; } } @@ -173,18 +157,18 @@ void func_80063828(GfxPrint* gfxPrint) void func_8006390C(Input* input) { s32 dpad; - s32 reg_group; + s32 regGroup; s32 increment; InputCombo* input_combo; s32 i; - reg_group = (gGameInfo->reg_group * (REG_N / PAGE_N) + gGameInfo->reg_page) * PAGE_N - PAGE_N; + regGroup = (gGameInfo->regGroup * (REG_PER_GROUP / PAGE_N) + gGameInfo->regPage) * PAGE_N - PAGE_N; dpad = input->raw.pad & 0xF00; - if (!~(input->raw.pad | ~BUTTON_L) || - !~(input->raw.pad | ~BUTTON_R) || - !~(input->raw.pad | ~BUTTON_START)) { + if (!~(input->raw.pad | ~L_TRIG) || + !~(input->raw.pad | ~R_TRIG) || + !~(input->raw.pad | ~START_BUTTON)) { input_combo = inputCombos; - for (i = 0; i < REG_GROUP_TOTAL; i++) + for (i = 0; i < REG_GROUPS; i++) { if (~(~input_combo->push | input->raw.pad) || ~(~input_combo->held | input->padPressed)) { @@ -194,17 +178,17 @@ void func_8006390C(Input* input) { break; } - if (i < REG_GROUP_TOTAL) { - if (i == gGameInfo->reg_group) { - gGameInfo->reg_page = (gGameInfo->reg_page + 1) % 7; + if (i < REG_GROUPS) { + if (i == gGameInfo->regGroup) { + gGameInfo->regPage = (gGameInfo->regPage + 1) % 7; return; } - gGameInfo->reg_group = i; - gGameInfo->reg_page = 0; + gGameInfo->regGroup = i; + gGameInfo->regPage = 0; } } else { - switch (gGameInfo->reg_page - 1) + switch (gGameInfo->regPage - 1) { case 0: case 1: @@ -213,42 +197,42 @@ void func_8006390C(Input* input) { case 4: case 5: - if (dpad == gGameInfo->dpad_last) { + if (dpad == gGameInfo->dpadLast) { gGameInfo->repeat--; if (gGameInfo->repeat < 0) { gGameInfo->repeat = 1; } else { - dpad ^= gGameInfo->dpad_last; + dpad ^= gGameInfo->dpadLast; } } else { gGameInfo->repeat = 0x10; - gGameInfo->dpad_last = dpad; + gGameInfo->dpadLast = dpad; } increment = - (dpad & BUTTON_D_RIGHT) ? ( - !~(input->raw.pad | ~(BUTTON_A | BUTTON_B)) ? 1000 : - !~(input->raw.pad | ~BUTTON_A) ? 100 : - !~(input->raw.pad | ~BUTTON_B) ? 10 : 1) : - (dpad & BUTTON_D_LEFT) ? ( - !~(input->raw.pad | ~(BUTTON_A | BUTTON_B)) ? -1000 : - !~(input->raw.pad | ~BUTTON_A) ? -100 : - !~(input->raw.pad | ~BUTTON_B) ? -10 : -1) : + (dpad & R_JPAD) ? ( + !~(input->raw.pad | ~(A_BUTTON | B_BUTTON)) ? 1000 : + !~(input->raw.pad | ~A_BUTTON) ? 100 : + !~(input->raw.pad | ~B_BUTTON) ? 10 : 1) : + (dpad & L_JPAD) ? ( + !~(input->raw.pad | ~(A_BUTTON | B_BUTTON)) ? -1000 : + !~(input->raw.pad | ~A_BUTTON) ? -100 : + !~(input->raw.pad | ~B_BUTTON) ? -10 : -1) : 0; - gGameInfo->data[gGameInfo->reg_cur + reg_group] += increment; - if (dpad & BUTTON_D_UP) { - gGameInfo->reg_cur--; - if (gGameInfo->reg_cur < 0) { - gGameInfo->reg_cur = PAGE_N - 1; + gGameInfo->data[gGameInfo->regCur + regGroup] += increment; + if (dpad & U_JPAD) { + gGameInfo->regCur--; + if (gGameInfo->regCur < 0) { + gGameInfo->regCur = PAGE_N - 1; } } - else if (dpad & BUTTON_D_DOWN) { - gGameInfo->reg_cur++; - if (gGameInfo->reg_cur >= PAGE_N) { - gGameInfo->reg_cur = 0; + else if (dpad & D_JPAD) { + gGameInfo->regCur++; + if (gGameInfo->regCur >= PAGE_N) { + gGameInfo->regCur = 0; } } if (iREG(0)) { @@ -264,28 +248,28 @@ void func_80063C04(GfxPrint* gfxPrint) { s32 i; s32 page; - s32 reg_group; + s32 regGroup; s32 test; //removing affects stack - char reg_name[3]; + char name[3]; - page = (gGameInfo->reg_page * PAGE_N) - PAGE_N; - reg_group = (gGameInfo->reg_group * (REG_N / PAGE_N) + gGameInfo->reg_page) * PAGE_N - PAGE_N; + page = (gGameInfo->regPage * PAGE_N) - PAGE_N; + regGroup = (gGameInfo->regGroup * (REG_PER_GROUP / PAGE_N) + gGameInfo->regPage) * PAGE_N - PAGE_N; //set up register name string - reg_name[0] = 'R'; - reg_name[1] = regChar[gGameInfo->reg_group]; //r_group type char - reg_name[2] = '\0'; + name[0] = 'R'; + name[1] = regChar[gGameInfo->regGroup]; //r_group type char + name[2] = '\0'; GfxPrint_SetColor(gfxPrint, 0, 0x80, 0x80, 0x80); for (i = 0; i != PAGE_N; i++) { - if (i == gGameInfo->reg_cur) + if (i == gGameInfo->regCur) { GfxPrint_SetColor(gfxPrint, 0, 0xff, 0xff, 0xff); } GfxPrint_SetPos(gfxPrint, 3, i + 5); - GfxPrint_Printf(gfxPrint, "%s%02d%6d", ®_name, page + i, gGameInfo->data[i + reg_group]); - if (i == gGameInfo->reg_cur) + GfxPrint_Printf(gfxPrint, "%s%02d%6d", &name, page + i, gGameInfo->data[i + regGroup]); + if (i == gGameInfo->regCur) { GfxPrint_SetColor(gfxPrint, 0, 0x80, 0x80, 0x80); } @@ -295,24 +279,24 @@ void func_80063C04(GfxPrint* gfxPrint) void func_80063D7C(GraphicsContext* gfxCtx) { Gfx* sp7C; Gfx* sp78; - Gfx* temp_ret; + Gfx* tempRet; void* unk2[6]; GfxPrint gfxPrint; void* unk[2]; - Gfx* dl_frame[4]; //stores state of GfxCtx next ptrs + Gfx* dlFrame[4]; //stores state of GfxCtx next ptrs - func_800C6AC4(&dl_frame, gfxCtx, "../z_debug.c", 0x274); + func_800C6AC4(&dlFrame, gfxCtx, "../z_debug.c", 628); GfxPrint_Ctor(&gfxPrint); sp78 = gfxCtx->polyOpa.p; - temp_ret = func_800C6C20(gfxCtx->polyOpa.p); - gSPDisplayList(gfxCtx->overlay.p++, temp_ret); - GfxPrint_Open(&gfxPrint, temp_ret); + tempRet = func_800C6C20(gfxCtx->polyOpa.p); + gSPDisplayList(gfxCtx->overlay.p++, tempRet); + GfxPrint_Open(&gfxPrint, tempRet); if ((OREG(0) == 1) || (OREG(0) == 8)) { func_80063828(&gfxPrint); } - if (gGameInfo->reg_page != 0) { + if (gGameInfo->regPage != 0) { func_80063C04(&gfxPrint); } @@ -322,6 +306,6 @@ void func_80063D7C(GraphicsContext* gfxCtx) { func_800C6C28(sp78, sp7C); gfxCtx->polyOpa.p = sp7C; if (0); - func_800C6B54(&dl_frame, gfxCtx, "../z_debug.c", 0x298); + func_800C6B54(&dlFrame, gfxCtx, "../z_debug.c", 664); GfxPrint_Dtor(&gfxPrint); } -- cgit v1.2.3 From 858e937519558f1de85baecb8630fa60b9cd9387 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Thu, 19 Mar 2020 20:10:32 -0400 Subject: tweak defines --- src/code/z_debug.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/code') diff --git a/src/code/z_debug.c b/src/code/z_debug.c index 489636d41..451443a6b 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -5,8 +5,6 @@ #include #include -#define PAGE_N 16 - typedef struct { u8 x; @@ -162,7 +160,7 @@ void func_8006390C(Input* input) { InputCombo* input_combo; s32 i; - regGroup = (gGameInfo->regGroup * (REG_PER_GROUP / PAGE_N) + gGameInfo->regPage) * PAGE_N - PAGE_N; + regGroup = (gGameInfo->regGroup * REG_PAGES + gGameInfo->regPage) * REG_PER_PAGE - REG_PER_PAGE; dpad = input->raw.pad & 0xF00; if (!~(input->raw.pad | ~L_TRIG) || !~(input->raw.pad | ~R_TRIG) || @@ -180,7 +178,7 @@ void func_8006390C(Input* input) { if (i < REG_GROUPS) { if (i == gGameInfo->regGroup) { - gGameInfo->regPage = (gGameInfo->regPage + 1) % 7; + gGameInfo->regPage = (gGameInfo->regPage + 1) % (REG_PAGES + 1); return; } gGameInfo->regGroup = i; @@ -190,12 +188,12 @@ void func_8006390C(Input* input) { else { switch (gGameInfo->regPage - 1) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: if (dpad == gGameInfo->dpadLast) { gGameInfo->repeat--; @@ -226,12 +224,12 @@ void func_8006390C(Input* input) { if (dpad & U_JPAD) { gGameInfo->regCur--; if (gGameInfo->regCur < 0) { - gGameInfo->regCur = PAGE_N - 1; + gGameInfo->regCur = REG_PER_PAGE - 1; } } else if (dpad & D_JPAD) { gGameInfo->regCur++; - if (gGameInfo->regCur >= PAGE_N) { + if (gGameInfo->regCur >= REG_PER_PAGE) { gGameInfo->regCur = 0; } } @@ -252,8 +250,8 @@ void func_80063C04(GfxPrint* gfxPrint) s32 test; //removing affects stack char name[3]; - page = (gGameInfo->regPage * PAGE_N) - PAGE_N; - regGroup = (gGameInfo->regGroup * (REG_PER_GROUP / PAGE_N) + gGameInfo->regPage) * PAGE_N - PAGE_N; + page = (gGameInfo->regPage * REG_PER_PAGE) - REG_PER_PAGE; + regGroup = (gGameInfo->regGroup * REG_PAGES + gGameInfo->regPage) * REG_PER_PAGE - REG_PER_PAGE; //set up register name string name[0] = 'R'; @@ -261,7 +259,7 @@ void func_80063C04(GfxPrint* gfxPrint) name[2] = '\0'; GfxPrint_SetColor(gfxPrint, 0, 0x80, 0x80, 0x80); - for (i = 0; i != PAGE_N; i++) + for (i = 0; i != REG_PER_PAGE; i++) { if (i == gGameInfo->regCur) { -- cgit v1.2.3