diff --git a/README.md b/README.md index 3c835b5c..fd104249 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ This is a fork of the ultrasm64 repo by CrashOveride which includes the followin **Hacker QOL:** - Global, non-level based, star IDs (off by default) * -- FPS counter (use the function `print_fps(x,y)` anywhere that runs code every frame) +- Debug mode: prints mario's coordinates, angle and speed, and a FPS counter. - Automatic console/emulator detection. If emulator is detected, LODs are disabled. * - Ability to configure whether there's a 100 coin star at all and how many coins are required to spawn it * - Ability to easily change the warp that EXIT COURSE takes you to via config.h, or disable it entirely. * diff --git a/bin/segment2.c b/bin/segment2.c index 188932f1..0e0fdbd9 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -204,11 +204,9 @@ ALIGNED8 static const Texture texture_hud_char_star[] = { #include "textures/segment2/segment2.05C00.rgba16.inc.c" }; -#if defined(VERSION_JP) || defined(VERSION_SH) ALIGNED8 static const Texture texture_hud_char_decimal_point[] = { #include "textures/segment2/segment2.05E00.rgba16.inc.c" }; -#endif #if defined(VERSION_JP) || defined(VERSION_SH) ALIGNED8 static const Texture texture_hud_char_beta_key[] = { @@ -1824,7 +1822,7 @@ const Texture *const main_hud_lut[] = { texture_hud_char_percent, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, texture_hud_char_multiply, texture_hud_char_coin, - texture_hud_char_mario_head, texture_hud_char_star, 0x0, 0x0, + texture_hud_char_mario_head, texture_hud_char_star, texture_hud_char_decimal_point, 0x0, texture_hud_char_apostrophe, texture_hud_char_double_quote, #else texture_hud_char_0, texture_hud_char_1, texture_hud_char_2, texture_hud_char_3, diff --git a/include/config.h b/include/config.h index c9002a94..9e26e408 100644 --- a/include/config.h +++ b/include/config.h @@ -109,6 +109,8 @@ #define EXPAND_AUDIO_HEAP // Allow all surfaces types to have force, (doesn't require setting force, just allows it to be optional). #define ALL_SURFACES_HAVE_FORCE +// Custom debug mode. Press DPAD left to show the debug UI. Press DPAD right to enter the noclip mode. +//#define CUSTOM_DEBUG // BUG/GAME QOL FIXES // Fix instant warp offset not working when warping across different areas diff --git a/src/game/game_init.c b/src/game/game_init.c index 83a90626..86935075 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -46,6 +46,9 @@ OSContPad gControllerPads[4]; u8 gControllerBits; u8 gIsConsole = TRUE; // Needs to be initialized before audio_reset_session is called u8 gBorderHeight; +#ifdef CUSTOM_DEBUG +u8 gCustomDebugMode; +#endif #ifdef EEP s8 gEepromProbe; #endif diff --git a/src/game/game_init.h b/src/game/game_init.h index 87386cea..f3f650c3 100644 --- a/src/game/game_init.h +++ b/src/game/game_init.h @@ -46,6 +46,9 @@ extern u8 gIsConsole; extern u8 gWidescreen; #endif extern u8 gBorderHeight; +#ifdef CUSTOM_DEBUG +extern u8 gCustomDebugMode; +#endif #ifdef EEP extern s8 gEepromProbe; #endif diff --git a/src/game/hud.c b/src/game/hud.c index 42fd1554..cfbd0f0f 100644 --- a/src/game/hud.c +++ b/src/game/hud.c @@ -15,6 +15,8 @@ #include "print.h" #include "engine/surface_load.h" +#include "config.h" + /* @file hud.c * This file implements HUD rendering and power meter animations. * That includes stars, lives, coins, camera status, power meter, timer @@ -48,9 +50,9 @@ f32 calculate_and_update_fps() void print_fps(s32 x, s32 y) { f32 fps = calculate_and_update_fps(); - char text[10]; + char text[14]; - sprintf(text, "%2.2f", fps); + sprintf(text, "FPS %2.2f", fps); print_text(x, y, text); } @@ -308,6 +310,18 @@ void render_hud_mario_lives(void) { print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(54), HUD_TOP_Y, "%d", gHudDisplay.lives); } +#ifdef CUSTOM_DEBUG +void render_debug_mode(void) { + print_text(180, 40, "DEBUG MODE"); + print_text_fmt_int(5, 20, "Z %d", gMarioState->pos[2]); + print_text_fmt_int(5, 40, "Y %d", gMarioState->pos[1]); + print_text_fmt_int(5, 60, "X %d", gMarioState->pos[0]); + print_text_fmt_int(10, 100, "SPD %d", (s32) gMarioState->forwardVel); + print_text_fmt_int(10, 120, "ANG 0*%04x", (u16) gMarioState->faceAngle[1]); + print_fps(10,80); +} +#endif + /** * Renders the amount of coins collected. */ @@ -521,5 +535,10 @@ void render_hud(void) { { print_text(10, 60, "SURFACE NODE POOL FULL"); } + #ifdef CUSTOM_DEBUG + if (gCustomDebugMode) { + render_debug_mode(); + } + #endif } } diff --git a/src/game/mario.c b/src/game/mario.c index b381afa8..c0b5f763 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1283,6 +1283,23 @@ void update_mario_button_inputs(struct MarioState *m) { m->input |= INPUT_A_DOWN; } +#ifdef CUSTOM_DEBUG + if (m->controller->buttonPressed & L_JPAD) { + gCustomDebugMode ^= 1; + } + if (gCustomDebugMode) { + if (m->controller->buttonPressed & R_JPAD) { + if (gMarioState->action == ACT_DEBUG_FREE_MOVE) { + set_mario_action(gMarioState, ACT_IDLE, 0); + } else { + set_mario_action(gMarioState, ACT_DEBUG_FREE_MOVE, 0); + } + } + } else if (gMarioState->action == ACT_DEBUG_FREE_MOVE) { + set_mario_action(gMarioState, ACT_IDLE, 0); + } +#endif + // Don't update for these buttons if squished. if (m->squishTimer == 0) { if (m->controller->buttonPressed & B_BUTTON) {