2#if DX_DEBUG_MENU || defined(DX_QUICK_LAUNCH_BATTLE)
14const s32 MainMenuPosX = 26;
15const s32 MainMenuPosY = 60;
17const s32 RowHeight = 15;
18const s32 BottomRowY = 222;
20const s32 SubmenuPosX = 140;
21const s32 SubmenuPosY = MainMenuPosY;
23const s32 SubBoxPosX = SubmenuPosX - 10;
24const s32 SubBoxPosY = SubmenuPosY - 4;
47 DBM_INV_EDIT_STAR_POINTS,
48 DBM_INV_EDIT_STAR_PIECES,
54s32 DebugMenuState = DBM_NONE;
55b32 DebugStateChanged = FALSE;
65char LastStageName[16];
69void dx_debug_set_map_info(
char* mapName, s32 entryID) {
70 strcpy(LastMapName, mapName);
71 LastMapEntry = entryID;
74void dx_debug_set_battle_info(s32 battleID,
char* stageName) {
75 s32 len = strlen(stageName);
77 strcpy(LastStageName, stageName);
80 LastStageName[len - 6] =
'\0';
82 LastBattleID = battleID;
91u32 DebugButtonsRelease;
93typedef struct DebugHold {
98DebugHold DebugHoldU = { 0 };
99DebugHold DebugHoldD = { 0 };
100DebugHold DebugHoldL = { 0 };
101DebugHold DebugHoldR = { 0 };
103#define PRESSED(but) (DebugButtonsPress & (but))
104#define RELEASED(but) (DebugButtonsRelease & (but))
105#define HELD(but) (DebugButtonsHold & (but))
107#define INIT_HOLD_RATE 6
108#define SLOW_HOLD_RATE 4
109#define FAST_HOLD_RATE 2
111void dx_debug_update_hold_frames(DebugHold* hold, u32 but) {
113 hold->delay = INIT_HOLD_RATE;
115 }
else if (HELD(but)) {
117 if (hold->delay < 0) {
120 if (hold->triggers < 5) {
121 hold->delay = SLOW_HOLD_RATE;
122 }
else if (hold->triggers < 15) {
123 hold->delay = FAST_HOLD_RATE;
134void dx_debug_update_buttons() {
135 DebugButtonsPrev = DebugButtonsCur;
137 DebugButtonsHold = DebugButtonsCur & DebugButtonsPrev;
138 DebugButtonsPress = DebugButtonsCur & (DebugButtonsCur ^ DebugButtonsPrev);
139 DebugButtonsRelease = DebugButtonsPrev & (DebugButtonsCur ^ DebugButtonsPrev);
141 dx_debug_update_hold_frames(&DebugHoldU,
BUTTON_D_UP);
147#define NAV_UP (PRESSED(BUTTON_D_UP) || DebugHoldU.delay == 0)
148#define NAV_DOWN (PRESSED(BUTTON_D_DOWN) || DebugHoldD.delay == 0)
149#define NAV_LEFT (PRESSED(BUTTON_D_LEFT) || DebugHoldL.delay == 0)
150#define NAV_RIGHT (PRESSED(BUTTON_D_RIGHT) || DebugHoldR.delay == 0)
154void dx_debug_draw_box(s32 posX, s32 posY, s32 sizeX, s32 sizeY,
int style, s32 opacity) {
156 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, NULL, 0, NULL,
SCREEN_WIDTH,
SCREEN_HEIGHT, NULL);
159void dx_debug_draw_ascii(
char* text, s32 color, s32 posX, s32 posY) {
164 draw_msg((s32)buf, posX, posY, 255, color, 0);
167void dx_debug_draw_ascii_with_effect(
char* text, s32 color, s32 posX, s32 posY, s32 effect) {
172 draw_msg((s32)buf, posX, posY, 255, color, effect);
175void dx_debug_draw_msg(s32 msgID, s32 color, s32 alpha, s32 posX, s32 posY) {
180 draw_msg((s32)buf, posX, posY, alpha, color, 0);
183void dx_debug_draw_number(s32 number,
char* fmt, s32 color, s32 alpha, s32 posX, s32 posY) {
188 sprintf(fmtBuf, fmt, number);
190 draw_msg((s32)buf, posX, posY, alpha, color, 0);
194void dx_debug_draw_editable_number(s32 number,
char* fmt, s32 selectedDigit,
b32 hasSelected, s32 posX, s32 posY) {
202 s32 len = sprintf(fmtBuf, fmt, number);
205 for (idx = 0; idx < len; idx++) {
206 if (hasSelected && selectedDigit == idx) {
211 msgBuf[
pos++] = HighlightColor;
214 if (hasSelected && selectedDigit == idx) {
221 if (hasSelected && selectedDigit == -1) {
222 draw_msg((s32)msgBuf, posX, posY, 255, HighlightColor, 0);
224 draw_msg((s32)msgBuf, posX, posY, 255, DefaultColor, 0);
230s32 dx_debug_clamp(s32 v, s32 min, s32 max) {
231 const s32 u = v < min ? min : v;
232 return u > max ? max : u;
235s32 dx_debug_wrap(s32 v, s32 min, s32 max) {
236 const s32 u = v < min ? v + (max - min + 1) : v;
237 return u > max ? u - (max - min + 1) : u;
241s32 dx_debug_menu_nav_1D_vertical(s32 cur, s32 min, s32 max,
b32 flip) {
258 cur += (1 + max - min);
261 cur -= (1 + max - min);
267s32 dx_debug_menu_nav_1D_horizontal(s32 cur, s32 min, s32 max,
b32 flip) {
284 cur += (1 + max - min);
287 cur -= (1 + max - min);
292s32 dx_debug_menu_nav_2D(s32 cur, s32 max, s32 nrows) {
293 s32 ncols = max / nrows;
294 if ((max % nrows) != 0) {
303 else if (cur % nrows == nrows - 1) {
313 cur = (cur / nrows) * nrows;
315 else if (cur % nrows == 0) {
322 cur += (nrows * ncols);
331 cur -= (nrows * ncols);
342typedef struct DebugEditableNumber {
347} DebugEditableNumber;
349void dx_debug_nav_editable_num(DebugEditableNumber* num) {
350 s32 max = num->isHex ? 0xF : 9;
353 num->pos = dx_debug_menu_nav_1D_horizontal(num->pos, 0, num->size - 1, FALSE);
355 num->digits[num->pos] = dx_debug_menu_nav_1D_vertical(num->digits[num->pos], 0, max, TRUE);
358void dx_debug_draw_editable_num(DebugEditableNumber* num, s32 posX, s32 posY) {
359 char* fmt = num->isHex ?
"%X" :
"%d";
362 for (idx = 0; idx < num->size; idx++) {
363 s32 color = (num->pos == idx) ? HighlightColor : DefaultColor;
364 dx_debug_draw_number(num->digits[idx], fmt, color, 255, posX + (7 * idx), posY);
368s32 dx_debug_get_editable_num(DebugEditableNumber* num) {
373 for (idx = 0; idx < num->size; idx++) {
375 out |= (num->digits[idx] & 0xF);
378 for (idx = 0; idx < num->size; idx++) {
380 out += num->digits[idx];
387void dx_debug_set_editable_num(DebugEditableNumber* num, s32 in) {
391 for (idx = num->size - 1; idx >= 0; idx--) {
392 num->digits[idx] = (in & 0xF);
396 for (idx = num->size - 1; idx >= 0; idx--) {
397 num->digits[idx] = in % 10;
405void dx_debug_draw_main_menu();
407b32 dx_debug_menu_is_open() {
408 return DebugMenuState != DBM_NONE;
411void dx_debug_exec_full_restore() {
418typedef struct DebugMenuEntry {
424DebugMenuEntry DebugMainMenu[] = {
425 {
"Full Restore", dx_debug_exec_full_restore },
426 {
"Save/Load", NULL, DBM_QUICK_SAVE },
427 {
"Map Select", NULL, DBM_SELECT_AREA },
428 {
"Battle Select", NULL, DBM_SELECT_BATTLE },
429 {
"Set Story Byte", NULL, DBM_SET_STORY },
430 {
"Sound Player", NULL, DBM_SOUND_PLAYER },
431 {
"Edit Partners", NULL, DBM_EDIT_PARTNERS },
432 {
"Edit Inventory", NULL, DBM_EDIT_INVENTORY },
434 {
"View Collision", NULL, DBM_VIEW_COLLISION },
435 {
"Cheats", NULL, DBM_CHEAT_MENU },
440const s32 MainBoxPosX = MainMenuPosX - 10;
441const s32 MainBoxPosY = MainMenuPosY - 4;
442const s32 MainBoxWidth = 96;
443const s32 MainBoxHeight =
ARRAY_COUNT(DebugMainMenu) * RowHeight + 8;
445f32 ArrowAnimOffset = 0;
446f32 DebugArrowPhase = 0.0f;
447#define DEBUG_ARROW_ANIM_RATE 6
449void dx_debug_update_banner();
450void dx_debug_update_main_menu();
451void dx_debug_update_quick_save();
452void dx_debug_update_select_area();
453void dx_debug_update_select_map();
454void dx_debug_update_select_entry();
455void dx_debug_update_select_battle();
456void dx_debug_update_edit_progress();
457void dx_debug_update_sound_player();
458void dx_debug_update_select_sound();
459void dx_debug_update_edit_partners();
460void dx_debug_update_edit_inventory();
461void dx_debug_update_edit_items();
462void dx_debug_update_edit_items();
463void dx_debug_update_edit_items();
464void dx_debug_update_edit_gear();
465void dx_debug_update_edit_stats();
466void dx_debug_update_edit_coins();
467void dx_debug_update_edit_star_points();
468void dx_debug_update_edit_star_pieces();
469void dx_debug_update_view_collision();
470void dx_debug_update_cheat_menu();
472void dx_debug_menu_main() {
473 s32 initialMenuState = DebugMenuState;
475 dx_debug_update_buttons();
477 HighlightColor = HELD(
BUTTON_R) ? SelectColor : HoverColor;
479 DebugArrowPhase += DEBUG_ARROW_ANIM_RATE;
480 if (DebugArrowPhase >= 360.0f) {
481 DebugArrowPhase -= 360.0f;
483 ArrowAnimOffset =
cos_deg(DebugArrowPhase);
485 dx_debug_update_banner();
488 if (DebugMenuState == DBM_NONE) {
490 DebugMenuState = DBM_MAIN_MENU;
492 }
else if (DebugMenuState == DBM_MAIN_MENU) {
494 DebugMenuState = DBM_NONE;
498 if (DebugMenuState != DBM_NONE) {
500 dx_debug_draw_main_menu();
502 switch(DebugMenuState) {
504 dx_debug_update_main_menu();
507 dx_debug_update_quick_save();
509 case DBM_SELECT_AREA:
510 dx_debug_update_select_area();
513 dx_debug_update_select_map();
515 case DBM_SELECT_ENTRY:
516 dx_debug_update_select_entry();
518 case DBM_SELECT_BATTLE:
519 dx_debug_update_select_battle();
522 dx_debug_update_edit_progress();
524 case DBM_SOUND_PLAYER:
525 dx_debug_update_sound_player();
527 case DBM_SELECT_SOUND:
528 dx_debug_update_select_sound();
530 case DBM_EDIT_PARTNERS:
531 dx_debug_update_edit_partners();
533 case DBM_EDIT_INVENTORY:
534 dx_debug_update_edit_inventory();
536 case DBM_INV_EDIT_ITEMS:
537 dx_debug_update_edit_items();
539 case DBM_INV_EDIT_BADGES:
540 dx_debug_update_edit_items();
542 case DBM_INV_EDIT_KEYS:
543 dx_debug_update_edit_items();
545 case DBM_INV_EDIT_GEAR:
546 dx_debug_update_edit_gear();
548 case DBM_INV_EDIT_STATS:
549 dx_debug_update_edit_stats();
551 case DBM_INV_EDIT_COINS:
552 dx_debug_update_edit_coins();
554 case DBM_INV_EDIT_STAR_POINTS:
555 dx_debug_update_edit_star_points();
557 case DBM_INV_EDIT_STAR_PIECES:
558 dx_debug_update_edit_star_pieces();
560 case DBM_EDIT_MEMORY:
562 case DBM_VIEW_COLLISION:
563 dx_debug_update_view_collision();
566 dx_debug_update_cheat_menu();
571 DebugStateChanged = (initialMenuState != DebugMenuState);
574void dx_debug_update_main_menu() {
575 MainMenuPos = dx_debug_menu_nav_1D_vertical(MainMenuPos, 0,
ARRAY_COUNT(DebugMainMenu) - 1, FALSE);
577 if (DebugMainMenu[MainMenuPos].onSelect != NULL) {
578 DebugMainMenu[MainMenuPos].onSelect();
580 DebugMenuState = DebugMainMenu[MainMenuPos].nextState;
585void dx_debug_draw_main_menu() {
588 dx_debug_draw_box(MainBoxPosX, MainBoxPosY, MainBoxWidth, MainBoxHeight,
WINDOW_STYLE_4, 192);
590 for (idx = 0; idx <
ARRAY_COUNT(DebugMainMenu); idx++) {
591 s32 color = DefaultColor;
592 if (MainMenuPos == idx) {
593 color = (DebugMenuState == DBM_MAIN_MENU) ? HighlightColor : HoverColor;
595 dx_debug_draw_ascii(DebugMainMenu[idx].text, color, MainMenuPosX, MainMenuPosY + idx * RowHeight);
603void dx_debug_exec_quick_save() {
609 DebugMenuState = DBM_MAIN_MENU;
612void dx_debug_exec_quick_load() {
616 DebugMenuState = DBM_MAIN_MENU;
619DebugMenuEntry DebugQuickSaveMenu[] = {
620 {
"Cancel", NULL, DBM_MAIN_MENU },
621 {
"Quick Save", dx_debug_exec_quick_save },
622 {
"Quick Load", dx_debug_exec_quick_load },
624s32 QuickSaveMenuPos = 0;
626void dx_debug_update_quick_save() {
630 QuickSaveMenuPos = dx_debug_menu_nav_1D_vertical(QuickSaveMenuPos, 0,
ARRAY_COUNT(DebugQuickSaveMenu) - 1, FALSE);
632 DebugMenuState = DBM_MAIN_MENU;
634 if (DebugQuickSaveMenu[QuickSaveMenuPos].onSelect != NULL) {
635 DebugQuickSaveMenu[QuickSaveMenuPos].onSelect();
637 DebugMenuState = DebugQuickSaveMenu[QuickSaveMenuPos].nextState;
642 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 75,
ARRAY_COUNT(DebugQuickSaveMenu) * RowHeight + 8,
WINDOW_STYLE_20, 192);
644 for (idx = 0; idx <
ARRAY_COUNT(DebugQuickSaveMenu); idx++) {
645 s32 color = (QuickSaveMenuPos == idx) ? HighlightColor : DefaultColor;
646 dx_debug_draw_ascii(DebugQuickSaveMenu[idx].text, color, SubmenuPosX, SubmenuPosY + (idx + 1) * RowHeight);
653s32 SelectAreaMenuPos = 0;
654s32 SelectMapMenuPos = 0;
655s32 SelectedEntryValue = 0;
657const s32 AreaSizeX = 30;
658const s32 MapSizeX = 50;
660void dx_debug_update_select_area() {
664 s32 prev = SelectAreaMenuPos;
672 }
else if (numAreas <= 12) {
675 }
else if (numAreas <= 18) {
678 }
else if (numAreas <= 24) {
681 }
else if (numAreas <= 30) {
684 }
else if (numAreas <= 35) {
687 }
else if (numAreas <= 40) {
697 SelectAreaMenuPos = dx_debug_menu_nav_2D(SelectAreaMenuPos, numAreas, nrows);
698 if (SelectAreaMenuPos != prev) {
699 SelectMapMenuPos = 0;
700 SelectedEntryValue = 0;
703 DebugMenuState = DBM_MAIN_MENU;
705 DebugMenuState = DBM_SELECT_MAP;
710 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, AreaSizeX * ncols + 8, RowHeight * nrows + 8,
WINDOW_STYLE_20, 192);
713 for (i = 0; i < ncols; i++) {
714 for (j = 0; j < nrows; j++) {
715 if (idx < numAreas) {
716 s32 color = (SelectAreaMenuPos == idx) ? HighlightColor : DefaultColor;
718 dx_debug_draw_ascii(name, color, SubmenuPosX + i * AreaSizeX, SubmenuPosY + (j + 1) * RowHeight);
725void dx_debug_update_select_map() {
727 s32 numRows, numCols;
728 s32 curCol, maxCol, startCol;
731 s32 prev = SelectMapMenuPos;
738 }
else if (numMaps <= 12) {
748 SelectMapMenuPos = dx_debug_menu_nav_2D(SelectMapMenuPos, numMaps, numRows);
749 if (SelectMapMenuPos != prev) {
750 SelectedEntryValue = 0;
753 DebugMenuState = DBM_SELECT_AREA;
755 DebugMenuState = DBM_SELECT_ENTRY;
760 curCol = SelectMapMenuPos / numRows;
761 maxCol = numMaps / numRows;
764 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, MapSizeX * numCols + 8, RowHeight * (numRows + 1) + 8,
WINDOW_STYLE_20, 192);
766 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, MapSizeX * numCols + 8, RowHeight * numRows + 8,
WINDOW_STYLE_20, 192);
771 }
else if (curCol == 0) {
773 }
else if (curCol == maxCol) {
774 startCol = maxCol - 2;
776 startCol = curCol - 1;
779 idx = numRows * startCol;
780 for (i = startCol; i <= startCol + 2; i++) {
781 for (j = 0; j < numRows; j++) {
783 s32 color = (SelectMapMenuPos == idx) ? HighlightColor : DefaultColor;
784 char* name = maps[idx].
id;
785 dx_debug_draw_ascii(name, color, SubmenuPosX + (i - startCol) * MapSizeX, SubmenuPosY + (j + 1) * RowHeight);
794 char msgLeftArrow[] = {
797 draw_msg((s32)msgLeftArrow, SubmenuPosX - 2 -
round(3.0f * ArrowAnimOffset), SubmenuPosY + 104, 255, DefaultColor, 0);
800 if (curCol < maxCol - 1) {
801 char msgRightArrow[] = {
804 draw_msg((s32)msgRightArrow, SubmenuPosX + 128 +
round(3.0f * ArrowAnimOffset), SubmenuPosY + 104, 255, DefaultColor, 0);
809void dx_debug_update_select_entry() {
810 s32 idx, areaID, mapID;
815 DebugMenuState = DBM_SELECT_MAP;
823 DebugMenuState = DBM_NONE;
827 SelectedEntryValue++;
830 SelectedEntryValue--;
833 if (SelectedEntryValue < 0) {
834 SelectedEntryValue = 0;
836 if (SelectedEntryValue > 0x7F) {
837 SelectedEntryValue = 0x7F;
841 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 80, 2 * RowHeight + 8,
WINDOW_STYLE_20, 192);
843 for (idx = 0; idx <
ARRAY_COUNT(DebugQuickSaveMenu); idx++) {
845 dx_debug_draw_ascii(map.
id, DefaultColor, SubmenuPosX, SubmenuPosY + RowHeight);
846 dx_debug_draw_ascii(
"Entry:", DefaultColor, SubmenuPosX, SubmenuPosY + 2 * RowHeight);
847 sprintf(fmtBuf,
"%2X", SelectedEntryValue);
848 dx_debug_draw_ascii(fmtBuf, HighlightColor, SubmenuPosX + 40, SubmenuPosY + 2 * RowHeight);
855enum DebugBattleValues {
856 DEBUG_BATTLE_AREA_TENS,
857 DEBUG_BATTLE_AREA_ONES,
858 DEBUG_BATTLE_FORMATION_TENS,
859 DEBUG_BATTLE_FORMATION_ONES,
863s32 DebugBattleNum[] = {
864 [DEBUG_BATTLE_AREA_TENS] 0,
865 [DEBUG_BATTLE_AREA_ONES] 0,
866 [DEBUG_BATTLE_FORMATION_TENS] 0,
867 [DEBUG_BATTLE_FORMATION_ONES] 0,
868 [DEBUG_BATTLE_STAGE] -1,
871s32 BattleDigitOffsets[] = {
872 [DEBUG_BATTLE_AREA_TENS] 10,
873 [DEBUG_BATTLE_AREA_ONES] 17,
874 [DEBUG_BATTLE_FORMATION_TENS] 35,
875 [DEBUG_BATTLE_FORMATION_ONES] 42,
876 [DEBUG_BATTLE_STAGE] 63,
879s32 DebugBattleColumn = 0;
883Enemy DebugDummyEnemy = {
884 .
npcID = DX_DEBUG_DUMMY_ID,
885 .drops = &DebugDummyDrops,
890 .enemy = &DebugDummyEnemy,
896void dx_debug_begin_battle_with_IDs(s16 battle, s16 stage) {
899 DebugDummyEncounter.
battle = battle;
900 DebugDummyEncounter.
stage = stage;
921void dx_debug_begin_battle() {
922 s16 battle = (DebugBattleNum[DEBUG_BATTLE_AREA_TENS] & 0xF) << 12
923 | (DebugBattleNum[DEBUG_BATTLE_AREA_ONES] & 0xF) << 8
924 | (DebugBattleNum[DEBUG_BATTLE_FORMATION_TENS] & 0xF) << 4
925 | (DebugBattleNum[DEBUG_BATTLE_FORMATION_ONES] & 0xF);
926 s16 stage = DebugBattleNum[DEBUG_BATTLE_STAGE] & 0xFFFF;
928 dx_debug_begin_battle_with_IDs(battle, stage);
931void dx_debug_update_select_battle() {
938 DebugMenuState = DBM_MAIN_MENU;
940 dx_debug_begin_battle();
941 DebugMenuState = DBM_NONE;
944 DebugBattleColumn = dx_debug_menu_nav_1D_horizontal(DebugBattleColumn, 0, 4, FALSE);
946 s32 value = DebugBattleNum[DebugBattleColumn] + 1;
947 if (DebugBattleColumn == DEBUG_BATTLE_STAGE) {
948 value = dx_debug_clamp(value, -1, 0x7F);
949 }
else if (DebugBattleColumn == DEBUG_BATTLE_AREA_TENS) {
950 value = dx_debug_wrap(value, 0, maxAreaTens);
952 value = dx_debug_wrap(value, 0, 0xF);
954 DebugBattleNum[DebugBattleColumn] = value;
957 s32 value = DebugBattleNum[DebugBattleColumn] - 1;
958 if (DebugBattleColumn == DEBUG_BATTLE_STAGE) {
959 value = dx_debug_clamp(value, -1, 0x7F);
960 }
else if (DebugBattleColumn == DEBUG_BATTLE_AREA_TENS) {
961 value = dx_debug_wrap(value, 0, maxAreaTens);
963 value = dx_debug_wrap(value, 0, 0xF);
965 DebugBattleNum[DebugBattleColumn] = value;
969 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 104, 2 * RowHeight + 8,
WINDOW_STYLE_20, 192);
970 dx_debug_draw_ascii(
"Start Battle:", DefaultColor, SubmenuPosX, SubmenuPosY + 1 * RowHeight);
971 dx_debug_draw_ascii(
"-", DefaultColor, SubmenuPosX + 26, SubmenuPosY + 2 * RowHeight);
972 dx_debug_draw_ascii(
"(", DefaultColor, SubmenuPosX + 55, SubmenuPosY + 2 * RowHeight);
973 dx_debug_draw_ascii(
")", DefaultColor, SubmenuPosX + 77, SubmenuPosY + 2 * RowHeight);
975 for (idx = 0; idx < 5; idx++) {
976 s32 color = (DebugBattleColumn == idx) ? HighlightColor : DefaultColor;
977 s32 offset = BattleDigitOffsets[idx];
978 char* fmt = (idx == 4) ?
"%02X" :
"%X";
980 dx_debug_draw_number(DebugBattleNum[idx] & 0xFF, fmt, color, 255, SubmenuPosX + offset, SubmenuPosY + 2 * RowHeight);
987DebugEditableNumber DebugStoryProgress = {
994void dx_debug_update_edit_progress() {
995 if (DebugStateChanged) {
997 dx_debug_set_editable_num(&DebugStoryProgress, val);
1002 DebugMenuState = DBM_MAIN_MENU;
1004 s32 val = dx_debug_get_editable_num(&DebugStoryProgress);
1009 dx_debug_nav_editable_num(&DebugStoryProgress);
1012 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 104, 2 * RowHeight + 8,
WINDOW_STYLE_20, 192);
1013 dx_debug_draw_ascii(
"Set Progress:", DefaultColor, SubmenuPosX, SubmenuPosY + RowHeight);
1014 dx_debug_draw_editable_num(&DebugStoryProgress, SubmenuPosX + 35, SubmenuPosY + 2 * RowHeight);
1020DebugMenuEntry DebugSoundPlayerMenu[] = {
1021 {
"Play Sound", NULL, DBM_SELECT_SOUND },
1022 {
"Stop Sound", NULL, DBM_SELECT_SOUND },
1024s32 SoundPlayerMenuPos = 0;
1026void dx_debug_draw_sound_player(
b32 activeMenu) {
1029 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 75,
ARRAY_COUNT(DebugSoundPlayerMenu) * RowHeight + 8,
WINDOW_STYLE_20, 192);
1031 for (idx = 0; idx <
ARRAY_COUNT(DebugSoundPlayerMenu); idx++) {
1034 color = (SoundPlayerMenuPos == idx) ? HighlightColor : DefaultColor;
1036 color = (SoundPlayerMenuPos == idx) ? HoverColor : DefaultColor;
1038 dx_debug_draw_ascii(DebugSoundPlayerMenu[idx].text, color, SubmenuPosX, SubmenuPosY + (idx + 1) * RowHeight);
1042void dx_debug_update_sound_player() {
1044 SoundPlayerMenuPos = dx_debug_menu_nav_1D_vertical(SoundPlayerMenuPos, 0,
ARRAY_COUNT(DebugSoundPlayerMenu) - 1, FALSE);
1046 DebugMenuState = DBM_MAIN_MENU;
1048 DebugMenuState = DBM_SELECT_SOUND;
1051 dx_debug_draw_sound_player(TRUE);
1054DebugEditableNumber DebugSoundID = {
1056 .digits = { 0, 0, 0, 0 },
1061void dx_debug_update_select_sound() {
1064 DebugMenuState = DBM_SOUND_PLAYER;
1066 if (SoundPlayerMenuPos == 0) {
1067 sfx_play_sound(dx_debug_get_editable_num(&DebugSoundID) & 0xFFFF);
1069 sfx_stop_sound(dx_debug_get_editable_num(&DebugSoundID) & 0xFFFF);
1073 dx_debug_nav_editable_num(&DebugSoundID);
1075 dx_debug_draw_sound_player(FALSE);
1076 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + (4 * RowHeight), 75, 2 * RowHeight + 8,
WINDOW_STYLE_20, 192);
1077 dx_debug_draw_ascii(
"Sound ID:", DefaultColor, SubmenuPosX, SubmenuPosY + 4 * RowHeight);
1078 dx_debug_draw_editable_num(&DebugSoundID, SubmenuPosX, SubmenuPosY + 5 * RowHeight);
1085s32 SelectPartnerMenuPos = 1;
1087void dx_debug_update_edit_partners() {
1090 if (DebugStateChanged) {
1098 DebugPartnerLevels[SelectPartnerMenuPos] = dx_debug_menu_nav_1D_horizontal(DebugPartnerLevels[SelectPartnerMenuPos], -1, 2, FALSE);
1100 DebugMenuState = DBM_MAIN_MENU;
1103 s32 val = DebugPartnerLevels[idx];
1116 dx_debug_draw_box(SubBoxPosX, SubBoxPosY, 120, 14 * 11 + 8,
WINDOW_STYLE_20, 192);
1119 b32 isSelected = (SelectPartnerMenuPos == idx);
1120 s32 color = isSelected ? HighlightColor : DefaultColor;
1121 s32 posY = SubmenuPosY + (idx - 1) * 14;
1122 s32 level = DebugPartnerLevels[idx];
1123 s32 alpha = (isSelected || level >= 0) ? 254 : 120;
1126 dx_debug_draw_number(level,
"%d", color, alpha, SubmenuPosX - 3, posY);
1128 dx_debug_draw_number(level,
"%d", color, alpha, SubmenuPosX + 3, posY);
1136 }
else if (level == 2) {
1146DebugMenuEntry DebugInventoryMenu[] = {
1147 {
"Items", NULL, DBM_INV_EDIT_ITEMS },
1148 {
"Badges", NULL, DBM_INV_EDIT_BADGES },
1149 {
"Key Items", NULL, DBM_INV_EDIT_KEYS },
1150 {
"Equipment", NULL, DBM_INV_EDIT_GEAR },
1151 {
"Stats", NULL, DBM_INV_EDIT_STATS },
1152 {
"Coins", NULL, DBM_INV_EDIT_COINS },
1153 {
"Star Points", NULL, DBM_INV_EDIT_STAR_POINTS },
1154 {
"Star Pieces", NULL, DBM_INV_EDIT_STAR_PIECES },
1156s32 InventoryMenuPos = 0;
1158void dx_debug_update_edit_inventory() {
1162 InventoryMenuPos = dx_debug_menu_nav_1D_vertical(InventoryMenuPos, 0,
ARRAY_COUNT(DebugInventoryMenu) - 1, FALSE);
1164 DebugMenuState = DBM_MAIN_MENU;
1166 if (DebugInventoryMenu[InventoryMenuPos].onSelect != NULL) {
1167 DebugInventoryMenu[InventoryMenuPos].onSelect();
1169 DebugMenuState = DebugInventoryMenu[InventoryMenuPos].nextState;
1174 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 75,
ARRAY_COUNT(DebugInventoryMenu) * RowHeight + 8,
WINDOW_STYLE_20, 192);
1176 for (idx = 0; idx <
ARRAY_COUNT(DebugInventoryMenu); idx++) {
1177 s32 color = (InventoryMenuPos == idx) ? HighlightColor : DefaultColor;
1178 dx_debug_draw_ascii(DebugInventoryMenu[idx].text, color, SubmenuPosX, SubmenuPosY + (idx + 1) * RowHeight);
1182b32 DebugEditingItem = FALSE;
1184#define _MAX_INV_SIZE(a,b,c) MAX(MAX(ARRAY_COUNT(a), ARRAY_COUNT(b)), ARRAY_COUNT(c))
1187typedef struct DebugItemsMenu {
1193DebugItemsMenu DebugItems = {
1199DebugItemsMenu DebugKeys = {
1205DebugItemsMenu DebugBadges = {
1211void dx_debug_set_item_id(s32 idx, s16 itemID) {
1214 for (j = 2; j >= 0; j--) {
1215 DebugItemDigits[idx][j] = (itemID & 0xF);
1220s16 dx_debug_get_item_id(s32 idx) {
1224 for (j = 0; j < 3; j++) {
1226 val |= (DebugItemDigits[idx][j] & 0xF);
1231void dx_debug_update_edit_items() {
1232 DebugItemsMenu* menu;
1237 switch (DebugMenuState) {
1238 case DBM_INV_EDIT_ITEMS:
1243 case DBM_INV_EDIT_KEYS:
1248 case DBM_INV_EDIT_BADGES:
1249 menu = &DebugBadges;
1255 if (DebugStateChanged) {
1256 for (i = 0; i < invSize; i++) {
1257 dx_debug_set_item_id(i, invItems[i]);
1262 if (DebugEditingItem) {
1263 DebugEditingItem = FALSE;
1265 DebugMenuState = DBM_EDIT_INVENTORY;
1268 if (!DebugEditingItem) {
1269 DebugEditingItem = TRUE;
1271 for (i = 0; i < invSize; i++) {
1272 invItems[i] = dx_debug_get_item_id(i);
1278 if (DebugEditingItem) {
1280 menu->col = dx_debug_menu_nav_1D_horizontal(menu->col, 0, 2, FALSE);
1281 digit = DebugItemDigits[menu->pos][menu->col];
1282 digit = dx_debug_menu_nav_1D_vertical(digit, 0, 0xF, TRUE);
1283 DebugItemDigits[menu->pos][menu->col] = digit;
1287 if (menu->pos < 0) {
1288 menu->pos = invSize - 1;
1289 menu->startPos = menu->pos - 9;
1291 menu->startPos = MIN(menu->startPos, menu->pos);
1296 if (menu->pos >= invSize) {
1300 menu->startPos = MAX(menu->startPos, menu->pos - 9);
1306 dx_debug_draw_box(SubBoxPosX, SubBoxPosY, 160, 10 * RowHeight + 8,
WINDOW_STYLE_20, 192);
1308 for (i = menu->startPos; i <= menu->startPos + 9; i++) {
1309 s32 posY = SubmenuPosY + (i - menu->startPos) * RowHeight;
1310 s32 itemID = dx_debug_get_item_id(i);
1311 b32 isSelectedRow = (menu->pos == i);
1313 if (DebugEditingItem) {
1314 dx_debug_draw_editable_number(i,
"%02X", -1, FALSE, SubmenuPosX, posY);
1315 dx_debug_draw_editable_number(itemID,
"%03X", menu->col, isSelectedRow, SubmenuPosX + 20, posY);
1317 dx_debug_draw_editable_number(i,
"%02X", -1, isSelectedRow, SubmenuPosX, posY);
1318 dx_debug_draw_editable_number(itemID,
"%03X", -1, FALSE, SubmenuPosX + 20, posY);
1321 s32 itemMsg = MSG_NONE;
1322 if (itemID > 0 && itemID < NUM_ITEMS) {
1325 if (itemMsg != MSG_NONE) {
1326 dx_debug_draw_msg(itemMsg, DefaultColor, 255, SubmenuPosX + 50, posY);
1333 draw_msg((s32)msgBuf, SubmenuPosX + 50, posY, 255, DefaultColor, 0);
1338 if (menu->startPos > 0) {
1342 draw_msg((s32)msgArrow, SubmenuPosX + 132, SubmenuPosY +
round(3.0f * ArrowAnimOffset), 255, DefaultColor, 0);
1345 if (menu->startPos + 10 < invSize) {
1349 draw_msg((s32)msgArrow, SubmenuPosX + 132, SubmenuPosY + 134 -
round(3.0f * ArrowAnimOffset), 255, DefaultColor, 0);
1356 DEBUG_GEAR_LUCKY_STAR,
1357 DEBUG_GEAR_STAR_BEAM,
1360s32 DebugGearValues[] = {
1361 [DEBUG_GEAR_BOOTS] 0,
1362 [DEBUG_GEAR_HAMMER] 0,
1363 [DEBUG_GEAR_LUCKY_STAR] 0,
1364 [DEBUG_GEAR_STAR_BEAM] 0,
1366s32 DebugGearPos = 0;
1368void dx_debug_update_edit_gear() {
1372 if (DebugStateChanged) {
1380 DebugMenuState = DBM_EDIT_INVENTORY;
1400 DebugGearPos = dx_debug_menu_nav_1D_vertical(DebugGearPos, 0,
ARRAY_COUNT(DebugGearValues) - 1, FALSE);
1413 switch (DebugGearPos) {
1414 case DEBUG_GEAR_BOOTS:
1418 case DEBUG_GEAR_HAMMER:
1422 case DEBUG_GEAR_LUCKY_STAR:
1426 case DEBUG_GEAR_STAR_BEAM:
1432 DebugGearValues[DebugGearPos] = dx_debug_clamp(DebugGearValues[DebugGearPos] + dx, min, max);
1436 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 95, 5 * RowHeight + 8,
WINDOW_STYLE_20, 192);
1437 dx_debug_draw_ascii(
"Gear:", DefaultColor, SubmenuPosX, SubmenuPosY + RowHeight);
1438 dx_debug_draw_ascii(
"Boots", DefaultColor, SubmenuPosX, SubmenuPosY + 2 * RowHeight);
1439 dx_debug_draw_ascii(
"Hammer", DefaultColor, SubmenuPosX, SubmenuPosY + 3 * RowHeight);
1440 dx_debug_draw_ascii(
"Lucky Star", DefaultColor, SubmenuPosX, SubmenuPosY + 4 * RowHeight);
1441 dx_debug_draw_ascii(
"Star Beam", DefaultColor, SubmenuPosX, SubmenuPosY + 5 * RowHeight);
1443 for (idx = 0; idx <
ARRAY_COUNT(DebugGearValues); idx++) {
1444 s32 color = (DebugGearPos == idx) ? HighlightColor : DefaultColor;
1445 dx_debug_draw_number(DebugGearValues[idx],
"%2d", color, 255, SubmenuPosX + 63, SubmenuPosY + (idx + 2) * RowHeight);
1457s32 DebugStatValues[] = {
1461 [DEBUG_STAT_LEVEL] 0,
1462 [DEBUG_STAT_SPIRITS] 0,
1464s32 DebugStatPos = 0;
1466void dx_debug_update_edit_stats() {
1470 if (DebugStateChanged) {
1479 DebugMenuState = DBM_EDIT_INVENTORY;
1490 DebugStatPos = dx_debug_menu_nav_1D_vertical(DebugStatPos, 0,
ARRAY_COUNT(DebugStatValues) - 1, FALSE);
1500 switch (DebugStatPos) {
1502 val = DebugStatValues[DEBUG_STAT_HP] + 5 * dx;
1503 DebugStatValues[DEBUG_STAT_HP] = dx_debug_clamp(val, 5, 50);
1506 val = DebugStatValues[DEBUG_STAT_FP] + 5 * dx;
1507 DebugStatValues[DEBUG_STAT_FP] = dx_debug_clamp(val, 0, 50);
1510 val = DebugStatValues[DEBUG_STAT_BP] + 3 * dx;
1511 DebugStatValues[DEBUG_STAT_BP] = dx_debug_clamp(val, 3, 30);
1513 case DEBUG_STAT_LEVEL:
1514 val = DebugStatValues[DEBUG_STAT_LEVEL] + dx;
1515 DebugStatValues[DEBUG_STAT_LEVEL] = dx_debug_clamp(val, 1, 27);
1517 case DEBUG_STAT_SPIRITS:
1518 val = DebugStatValues[DEBUG_STAT_SPIRITS] + dx;
1519 DebugStatValues[DEBUG_STAT_SPIRITS] = dx_debug_clamp(val, 0, 7);
1525 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 88, 6 * RowHeight + 8,
WINDOW_STYLE_20, 192);
1526 dx_debug_draw_ascii(
"Stats:", DefaultColor, SubmenuPosX, SubmenuPosY + RowHeight);
1527 dx_debug_draw_ascii(
"Max HP", DefaultColor, SubmenuPosX, SubmenuPosY + 2 * RowHeight);
1528 dx_debug_draw_ascii(
"Max FP", DefaultColor, SubmenuPosX, SubmenuPosY + 3 * RowHeight);
1529 dx_debug_draw_ascii(
"Max BP", DefaultColor, SubmenuPosX, SubmenuPosY + 4 * RowHeight);
1530 dx_debug_draw_ascii(
"Level", DefaultColor, SubmenuPosX, SubmenuPosY + 5 * RowHeight);
1531 dx_debug_draw_ascii(
"Spirits", DefaultColor, SubmenuPosX, SubmenuPosY + 6 * RowHeight);
1533 for (idx = 0; idx <
ARRAY_COUNT(DebugStatValues); idx++) {
1534 s32 color = (DebugStatPos == idx) ? HighlightColor : DefaultColor;
1535 dx_debug_draw_number(DebugStatValues[idx],
"%2d", color, 255, SubmenuPosX + 55, SubmenuPosY + (idx + 2) * RowHeight);
1539DebugEditableNumber DebugCoins = {
1541 .digits = { 0, 0, 0 },
1546void dx_debug_update_edit_coins() {
1547 if (DebugStateChanged) {
1553 DebugMenuState = DBM_EDIT_INVENTORY;
1559 dx_debug_nav_editable_num(&DebugCoins);
1562 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 50, 2 * RowHeight + 8,
WINDOW_STYLE_20, 192);
1563 dx_debug_draw_ascii(
"Coins:", DefaultColor, SubmenuPosX, SubmenuPosY + RowHeight);
1564 dx_debug_draw_editable_num(&DebugCoins, SubmenuPosX, SubmenuPosY + 2 * RowHeight);
1567DebugEditableNumber DebugStarPoints = {
1574void dx_debug_update_edit_star_points() {
1575 if (DebugStateChanged) {
1581 DebugMenuState = DBM_EDIT_INVENTORY;
1587 dx_debug_nav_editable_num(&DebugStarPoints);
1590 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 86, 2 * RowHeight + 8,
WINDOW_STYLE_20, 192);
1591 dx_debug_draw_ascii(
"Star Points:", DefaultColor, SubmenuPosX, SubmenuPosY + RowHeight);
1592 dx_debug_draw_editable_num(&DebugStarPoints, SubmenuPosX, SubmenuPosY + 2 * RowHeight);
1595DebugEditableNumber DebugStarPieces = {
1597 .digits = { 0, 0, 0 },
1602void dx_debug_update_edit_star_pieces() {
1603 if (DebugStateChanged) {
1609 DebugMenuState = DBM_EDIT_INVENTORY;
1615 dx_debug_nav_editable_num(&DebugStarPieces);
1618 if (dx_debug_get_editable_num(&DebugStarPieces) > 255) {
1619 dx_debug_set_editable_num(&DebugStarPieces, 255);
1623 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 86, 2 * RowHeight + 8,
WINDOW_STYLE_20, 192);
1624 dx_debug_draw_ascii(
"Star Pieces:", DefaultColor, SubmenuPosX, SubmenuPosY + RowHeight);
1625 dx_debug_draw_editable_num(&DebugStarPieces, SubmenuPosX, SubmenuPosY + 2 * RowHeight);
1631typedef struct DebugCollisionEntry {
1634} DebugCollisionEntry;
1642 DBC_HIGHLIGHT_FLOOR,
1647DebugCollisionEntry DebugCollisionMenu[] = {
1648 [DBC_SHOW_COLLISION] {
"Show Collision", FALSE },
1649 [DBC_CULL_BACK] {
"Cull Back", TRUE },
1650 [DBC_SHOW_DISABLED] {
"Show Disabled", TRUE },
1651 [DBC_HIDE_MODELS] {
"Hide Models", FALSE },
1652 [DBC_EXTRUDE_FACES] {
"Extrude Faces", FALSE },
1653 [DBC_HIGHLIGHT_FLOOR] {
"Highlight Floor", FALSE },
1654 [DBC_HIGHLIGHT_WALL] {
"Highlight Wall", FALSE },
1655 [DBC_FADE_DIST] {
"Near Fade Dist", 1 },
1658s32 DebugCollisionPos = 0;
1660void dx_debug_update_view_collision() {
1665 DebugMenuState = DBM_MAIN_MENU;
1668 if (DebugCollisionPos != DBC_FADE_DIST) {
1669 if (NAV_LEFT || NAV_RIGHT) {
1670 DebugCollisionMenu[DebugCollisionPos].state = !DebugCollisionMenu[DebugCollisionPos].state;
1673 s32 fadeDist = DebugCollisionMenu[DebugCollisionPos].state;
1674 fadeDist = dx_debug_menu_nav_1D_horizontal(fadeDist, 0, 9, FALSE);
1675 DebugCollisionMenu[DebugCollisionPos].state = fadeDist;
1677 DebugCollisionPos = dx_debug_menu_nav_1D_vertical(DebugCollisionPos, 0,
ARRAY_COUNT(DebugCollisionMenu) - 1, FALSE);
1680 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 120, 8 * RowHeight + 8,
WINDOW_STYLE_20, 192);
1682 for (idx = 0; idx <
ARRAY_COUNT(DebugCollisionMenu); idx++) {
1683 s32 color = (DebugCollisionPos == idx) ? HighlightColor : DefaultColor;
1684 if (idx != DBC_FADE_DIST) {
1685 char* onoff = DebugCollisionMenu[idx].state ?
"On" :
"Off";
1686 dx_debug_draw_ascii(onoff, color, SubmenuPosX, SubmenuPosY + (idx + 1) * RowHeight);
1688 s32 fadeDist = DebugCollisionMenu[idx].state;
1689 dx_debug_draw_number(fadeDist,
"%d", color, 255, SubmenuPosX, SubmenuPosY + (idx + 1) * RowHeight);
1691 dx_debug_draw_ascii(DebugCollisionMenu[idx].text, DefaultColor, SubmenuPosX + 28, SubmenuPosY + (idx + 1) * RowHeight);
1695void dx_debug_add_collision_vtx(Vtx_t* vtxBuffer,
Vec3f* vert,
Vec3f* normal, s32 r, s32 g, s32 b, s32 a) {
1696 if (DebugCollisionMenu[DBC_EXTRUDE_FACES].state) {
1697 vtxBuffer->ob[0] = vert->
x + normal->
x;
1698 vtxBuffer->ob[1] = vert->
y + normal->
y;
1699 vtxBuffer->ob[2] = vert->
z + normal->
z;
1701 vtxBuffer->ob[0] = vert->
x;
1702 vtxBuffer->ob[1] = vert->
y;
1703 vtxBuffer->ob[2] = vert->
z;
1705 vtxBuffer->tc[0] = 0;
1706 vtxBuffer->tc[1] = 0;
1707 vtxBuffer->cn[0] = r;
1708 vtxBuffer->cn[1] = g;
1709 vtxBuffer->cn[2] = b;
1710 vtxBuffer->cn[3] = a;
1713#define MAX_DEBUG_TRIS 1024
1715typedef struct DebugTriangle {
1721DebugTriangle DebugTris[MAX_DEBUG_TRIS];
1724Vtx_t DebugVtxBuf[3 * MAX_DEBUG_TRIS];
1727void dx_debug_draw_collision() {
1737 if (!DebugCollisionMenu[DBC_SHOW_COLLISION].state) {
1751 if (DebugTriPos < MAX_DEBUG_TRIS) {
1753 f32 outX, outY, outZ, outW;
1754 f32 cX = (tri->
v1->
x + tri->
v2->
x + tri->
v3->
x) / 3;
1755 f32 cY = (tri->
v1->
y + tri->
v2->
y + tri->
v3->
y) / 3;
1756 f32 cZ = (tri->
v1->
z + tri->
v2->
z + tri->
v3->
z) / 3;
1764 DebugTris[DebugTriPos].tri = tri;
1765 DebugTris[DebugTriPos].depth = outZ;
1766 DebugTris[DebugTriPos].colliderID = i;
1773 ASSERT(DebugTriPos < MAX_DEBUG_TRIS)
1776#define LESS(i, j) DebugTris[i].depth > DebugTris[j].depth
1777#define SWAP(i, j) temp = DebugTris[i], DebugTris[i] = DebugTris[j], DebugTris[j] = temp
1784 gDPSetRenderMode(
gMainGfxPos++, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2);
1785 gDPSetCombineMode(
gMainGfxPos++, G_CC_SHADE, G_CC_SHADE);
1786 gSPTexture(
gMainGfxPos++, 0x0080, 0x0080, 0, G_TX_RENDERTILE, G_OFF);
1787 gSPClearGeometryMode(
gMainGfxPos++, G_LIGHTING | G_CULL_BACK);
1789 if (DebugCollisionMenu[DBC_CULL_BACK].state) {
1790 gSPSetGeometryMode(
gMainGfxPos++, G_CULL_BACK | G_SHADING_SMOOTH);
1793 gSPSetGeometryMode(
gMainGfxPos++, G_SHADING_SMOOTH);
1801 for (i = 0; i < DebugTriPos; i++) {
1802 DebugTriangle* debugTri = &DebugTris[i];
1806 b32 highlight = FALSE;
1814 if (rdpBufPos == 0) {
1816 gSPVertex(
gMainGfxPos++, &DebugVtxBuf[DebugVtxPos], 30, 0);
1820 if (DebugCollisionMenu[DBC_CULL_BACK].state) {
1825 }
else if (tri->
oneSided && !culling) {
1834 gSP1Triangle(
gMainGfxPos++, rdpBufPos, rdpBufPos + 1, rdpBufPos + 2, 0);
1838 if (rdpBufPos == 30) {
1852 fadeDist = DebugCollisionMenu[DBC_FADE_DIST].state;
1854 dist = debugTri->depth - (fadeDist - 1) * 25;
1857 a = dx_debug_clamp((dist + 100) / 6, 0, 20);
1859 a = dx_debug_clamp(dist, 20, 180);
1864 dx_debug_add_collision_vtx(&DebugVtxBuf[DebugVtxPos++], tri->
v1, &tri->
normal, r, g, b, a);
1865 dx_debug_add_collision_vtx(&DebugVtxBuf[DebugVtxPos++], tri->
v2, &tri->
normal, r, g, b, a);
1866 dx_debug_add_collision_vtx(&DebugVtxBuf[DebugVtxPos++], tri->
v3, &tri->
normal, r, g, b, a);
1873b32 dx_debug_should_hide_models() {
1874 return DebugCollisionMenu[DBC_HIDE_MODELS].state;
1880typedef struct DebugCheatEntry {
1885DebugCheatEntry DebugCheatMenu[] = {
1886 [DEBUG_CHEAT_GOD_MODE] {
"God Mode", FALSE },
1887 [DEBUG_CHEAT_SPEED_MODE] {
"Speed Mode", FALSE },
1888 [DEBUG_CHEAT_FLY] {
"Fly With L", FALSE },
1889 [DEBUG_CHEAT_HIGH_JUMP] {
"High Jump", FALSE },
1890 [DEBUG_CHEAT_IGNORE_WALLS] {
"Ignore Walls", FALSE },
1893s32 DebugCheatPos = 0;
1895void dx_debug_update_cheat_menu() {
1900 DebugMenuState = DBM_MAIN_MENU;
1902 if (NAV_LEFT || NAV_RIGHT) {
1903 DebugCheatMenu[DebugCheatPos].enabled = !DebugCheatMenu[DebugCheatPos].enabled;
1906 switch (DebugCheatPos) {
1907 case DEBUG_CHEAT_GOD_MODE:
1908 case DEBUG_CHEAT_FLY:
1909 case DEBUG_CHEAT_HIGH_JUMP:
1910 case DEBUG_CHEAT_IGNORE_WALLS:
1912 case DEBUG_CHEAT_SPEED_MODE:
1913 if (!DebugCheatMenu[DebugCheatPos].enabled) {
1926 DebugCheatPos = dx_debug_menu_nav_1D_vertical(DebugCheatPos, 0,
ARRAY_COUNT(DebugCheatMenu) - 1, FALSE);
1929 dx_debug_draw_box(SubBoxPosX, SubBoxPosY + RowHeight, 120,
ARRAY_COUNT(DebugCheatMenu) * RowHeight + 8,
WINDOW_STYLE_20, 192);
1931 for (idx = 0; idx <
ARRAY_COUNT(DebugCheatMenu); idx++) {
1932 s32 color = (DebugCheatPos == idx) ? HighlightColor : DefaultColor;
1933 char* onoff = DebugCheatMenu[idx].enabled ?
"On" :
"Off";
1935 dx_debug_draw_ascii(onoff, color, SubmenuPosX, SubmenuPosY + (idx + 1) * RowHeight);
1936 dx_debug_draw_ascii(DebugCheatMenu[idx].text, DefaultColor, SubmenuPosX + 28, SubmenuPosY + (idx + 1) * RowHeight);
1940b32 dx_debug_is_cheat_enabled(DebugCheat cheat) {
1941 return DebugCheatMenu[cheat].enabled;
1947void dx_debug_update_banner() {
1952 sprintf(fmtBuf,
"Map: %7s (%X)", LastMapName, LastMapEntry);
1953 dx_debug_draw_ascii(fmtBuf, DefaultColor, 220, BottomRowY);
1955 dx_debug_draw_ascii(
"Pos:", DefaultColor, 20, BottomRowY);
1960 dx_debug_draw_ascii_with_effect(fmtBuf, DefaultColor, 48, BottomRowY, effect);
1963 dx_debug_draw_ascii_with_effect(fmtBuf, DefaultColor, 80, BottomRowY, effect);
1966 dx_debug_draw_ascii_with_effect(fmtBuf, DefaultColor, 112, BottomRowY, effect);
1968 if (dx_debug_is_cheat_enabled(DEBUG_CHEAT_GOD_MODE)) {
1969 dx_debug_draw_ascii(
"(GOD MODE)",
MSG_PAL_YELLOW, 151, BottomRowY);
1972 s32 areaID = (LastBattleID >> 24) & 0xFF;
1973 s32 battleID = (LastBattleID >> 16) & 0xFF;
1974 s32 stageID = LastBattleID & 0xFFFF;
1976 sprintf(fmtBuf,
"Battle: %02X-%02X (%X)", areaID, battleID, stageID);
1977 dx_debug_draw_ascii(fmtBuf, DefaultColor, 200, BottomRowY);
1979 sprintf(fmtBuf,
"Stage: %-15s", LastStageName);
1980 dx_debug_draw_ascii(fmtBuf, DefaultColor, 20, BottomRowY);
1982 if (dx_debug_is_cheat_enabled(DEBUG_CHEAT_GOD_MODE)) {
1983 dx_debug_draw_ascii(
"(GOD MODE)",
MSG_PAL_YELLOW, 128, BottomRowY);
1991#define DEBUG_CONSOLE_DEFAULT_TIMELEFT 60
1992#define DEBUG_CONSOLE_MSG_BUF_SIZE 85
1994typedef struct DebugConsoleLine {
1997 u8 buf[DEBUG_CONSOLE_MSG_BUF_SIZE];
2000DebugConsoleLine DebugConsoleLine0 = { 0 };
2001DebugConsoleLine DebugConsoleLine1 = { 0 };
2002DebugConsoleLine DebugConsoleLine2 = { 0 };
2003DebugConsoleLine DebugConsoleLine3 = { 0 };
2004DebugConsoleLine DebugConsoleLine4 = { 0 };
2005DebugConsoleLine DebugConsoleLine5 = { 0 };
2006DebugConsoleLine DebugConsoleLine6 = { 0 };
2007DebugConsoleLine DebugConsoleLine7 = { 0 };
2009DebugConsoleLine *DebugConsole[8] = {
2020u32 dx_debug_hash_location(
char* filename, s32 line) {
2024 while (c = *filename++) {
2025 hash = ((hash << 5) + hash) + c;
2028 hash = ((hash << 5) + hash) + line;
2033static char *proutSprintf(
char *dst,
const char *src,
size_t count) {
2034 return (
char *)memcpy((u8 *)dst, (u8 *)src, count) + count;
2037void dx_hashed_debug_printf(
const char* filename, s32 line,
const char* fmt, ...) {
2040 va_start(args, fmt);
2041 s32 len = _Printf(&proutSprintf, fmtBuf, fmt, args);
2047 u32 hash = dx_debug_hash_location(filename, line);
2048 s32 matchedLine = -1;
2052 for (idx = 0; idx <
ARRAY_COUNT(DebugConsole); idx++) {
2053 if (DebugConsole[idx]->hash == hash) {
2060 if (matchedLine == -1) {
2061 s32 minTimeLeft = DEBUG_CONSOLE_DEFAULT_TIMELEFT;
2063 for (idx = 0; idx <
ARRAY_COUNT(DebugConsole); idx++) {
2064 if (DebugConsole[idx]->timeLeft == 0) {
2068 if (DebugConsole[idx]->timeLeft < minTimeLeft) {
2069 minTimeLeft = DebugConsole[idx]->timeLeft;
2076 if (matchedLine != -1) {
2079 DebugConsole[matchedLine]->buf[2] = 12;
2080 DebugConsole[matchedLine]->buf[3] = 12;
2084 DebugConsole[matchedLine]->hash = hash;
2085 DebugConsole[matchedLine]->timeLeft = DEBUG_CONSOLE_DEFAULT_TIMELEFT;
2089API_CALLABLE(_dxDebugIntPrintf) {
2090 Bytecode* args = script->ptrReadPos;
2095 char* filename = *args++;
2097 char* fmt = *args++;
2099 for (idx = 0; idx < 8; idx++) {
2109 case 0: dx_hashed_debug_printf(filename, line, fmt);
break;
2110 case 1: dx_hashed_debug_printf(filename, line, fmt, i[0]);
break;
2111 case 2: dx_hashed_debug_printf(filename, line, fmt, i[0], i[1]);
break;
2112 case 3: dx_hashed_debug_printf(filename, line, fmt, i[0], i[1], i[2]);
break;
2113 case 4: dx_hashed_debug_printf(filename, line, fmt, i[0], i[1], i[2], i[3]);
break;
2114 case 5: dx_hashed_debug_printf(filename, line, fmt, i[0], i[1], i[2], i[3], i[4]);
break;
2115 case 6: dx_hashed_debug_printf(filename, line, fmt, i[0], i[1], i[2], i[3], i[4], i[5]);
break;
2116 case 7: dx_hashed_debug_printf(filename, line, fmt, i[0], i[1], i[2], i[3], i[4], i[5], i[6]);
break;
2122API_CALLABLE(_dxDebugFloatPrintf) {
2123 Bytecode* args = script->ptrReadPos;
2128 char* filename = *args++;
2130 char* fmt = *args++;
2132 for (idx = 0; idx < 8; idx++) {
2142 case 0: dx_hashed_debug_printf(filename, line, fmt);
break;
2143 case 1: dx_hashed_debug_printf(filename, line, fmt, f[0]);
break;
2144 case 2: dx_hashed_debug_printf(filename, line, fmt, f[0], f[1]);
break;
2145 case 3: dx_hashed_debug_printf(filename, line, fmt, f[0], f[1], f[2]);
break;
2146 case 4: dx_hashed_debug_printf(filename, line, fmt, f[0], f[1], f[2], f[3]);
break;
2147 case 5: dx_hashed_debug_printf(filename, line, fmt, f[0], f[1], f[2], f[3], f[4]);
break;
2148 case 6: dx_hashed_debug_printf(filename, line, fmt, f[0], f[1], f[2], f[3], f[4], f[5]);
break;
2149 case 7: dx_hashed_debug_printf(filename, line, fmt, f[0], f[1], f[2], f[3], f[4], f[5], f[6]);
break;
2155void dx_debug_console_main() {
2156 DebugConsoleLine* temp;
2159#define LESS(i, j) DebugConsole[i]->timeLeft > DebugConsole[j]->timeLeft
2160#define SWAP(i, j) temp = DebugConsole[i], DebugConsole[i] = DebugConsole[j], DebugConsole[j] = temp
2165 for (idx = 0; idx <
ARRAY_COUNT(DebugConsole); idx++) {
2166 s32 timeLeft = DebugConsole[idx]->timeLeft;
2170 if (timeLeft < 20) {
2171 alpha =
round(254 * (timeLeft / 20.0f));
2174 draw_msg(DebugConsole[idx]->buf, 32, 200 - 15 * idx, alpha, DefaultColor, 0);
2175 DebugConsole[idx]->timeLeft--;
PartnerPopupProperties gPartnerPopupProperties[]
BattleArea gBattleAreas[]
struct ColliderTriangle * triangleTable
#define ASSERT(condition)
@ MSG_READ_FUNC_RESTORE_COLOR
@ MSG_READ_FUNC_SAVE_COLOR
@ DEBUG_CONTACT_CANT_TOUCH
@ COLLIDER_FLAG_IGNORE_PLAYER
@ ENCOUNTER_SUBSTATE_PRE_BATTLE_INIT
@ SOUND_STAR_PIECE_BOUNCE
@ SOUND_UNUSED_STAR_SPIRIT_APPEARS
@ SOUND_STAR_POINT_PICKUP
@ ENCOUNTER_STATE_PRE_BATTLE
b32 fio_load_game(s32 saveSlot)
void fio_save_game(s32 saveSlot)
s32 evt_get_variable(Evt *script, Bytecode var)
s32 play_ambient_sounds(s32 fadeInTime, s32 fadeOutTime)
void partner_disable_input(void)
void set_map_transition_effect(ScreenTransition)
s32 disable_player_input(void)
void open_status_bar_quickly(void)
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
f32 evt_get_float_variable(Evt *script, Bytecode var)
void set_game_mode(s32 modeID)
void dma_load_msg(u32 msgID, void *dest)
s8 scriptedBattle
battle started by StartBattle but not by encounter
EncounterStatus gCurrentEncounter
void sfx_stop_sound(s32 soundID)
void sfx_play_sound(s32 soundID)
#define QSORT(Q_N, Q_LESS, Q_SWAP)
AreaConfig gAreas[29]
Zero-terminated.
u8 dx_ascii_char_to_msg(u8 in)
u8 * dx_string_to_msg(u8 *msg, const u8 *str)
PlayerStatus * gPlayerStatusPtr
CollisionStatus gCollisionStatus
GameStatus * gGameStatusPtr
PlayerStatus gPlayerStatus
CollisionData gCollisionData
b32 EncounterStateChanged