diff --git a/Makefile b/Makefile index 0fda4ab..11deb4e 100644 --- a/Makefile +++ b/Makefile @@ -429,16 +429,23 @@ MIPSISET := -mips2 MIPSBIT := -32 ifeq ($(TARGET_N64),1) -ifeq ($(COMPILER_N64),gcc) + ifeq ($(COMPILER_N64),gcc) MIPSISET := -mips3 - OPT_FLAGS := -O2 -endif -endif + ifeq ($(DEBUG),1) + OPT_FLAGS := -O2 -g3 + else + OPT_FLAGS := -O2 + endif + endif -ifeq ($(DEBUG),1) - OPT_FLAGS := -g else - OPT_FLAGS := -O2 + + ifeq ($(DEBUG),1) + OPT_FLAGS := -g + else + OPT_FLAGS := -O2 + endif + endif # Set BITS (32/64) to compile for @@ -633,25 +640,30 @@ ifeq ($(TARGET_PORT_CONSOLE),0) CUSTOM_C_DEFINES += -DDISCORDRPC endif - # Check for PC text save format - ifeq ($(TEXTSAVES),1) - CUSTOM_C_DEFINES += -DTEXTSAVES - endif + # Check for PC text save format + ifeq ($(TEXTSAVES),1) + CUSTOM_C_DEFINES += -DTEXTSAVES + endif - # Check for Mouse Option - ifeq ($(EXT_OPTIONS_MENU),1) - CUSTOM_C_DEFINES += -DMOUSE_ACTIONS - endif + # Check for Mouse Option + ifeq ($(EXT_OPTIONS_MENU),1) + CUSTOM_C_DEFINES += -DMOUSE_ACTIONS + endif - # Check for Command Line Options - ifeq ($(COMMAND_LINE_OPTIONS),1) - CUSTOM_C_DEFINES += -DCOMMAND_LINE_OPTIONS - endif + # Check for Command Line Options + ifeq ($(COMMAND_LINE_OPTIONS),1) + CUSTOM_C_DEFINES += -DCOMMAND_LINE_OPTIONS + endif endif endif +# Check for Debug option +ifeq ($(DEBUG),1) + CUSTOM_C_DEFINES += -DDEBUG +endif + # Check for Puppycam option ifeq ($(BETTERCAMERA),1) CUSTOM_C_DEFINES += -DBETTERCAMERA @@ -1202,6 +1214,12 @@ $(BUILD_DIR)/include/text_cheats_strings.h: include/text_cheats_strings.h.in $(V)$(TEXTCONV) charmap.txt $< $@ endif +ifeq ($(CHEATS_ACTIONS),1) +$(BUILD_DIR)/include/text_debug_strings.h: include/text_debug_strings.h.in + $(call print,Encoding:,$<,$@) + $(V)$(TEXTCONV) charmap.txt $< $@ +endif + endif ifeq ($(VERSION),eu) @@ -1261,6 +1279,7 @@ $(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_menu_strings.h ifeq ($(EXT_OPTIONS_MENU),1) $(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_options_strings.h $(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_cheats_strings.h +$(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_debug_strings.h endif ifeq ($(VERSION),eu) @@ -1286,6 +1305,10 @@ ifeq ($(EXT_OPTIONS_MENU),1) ifeq ($(CHEATS_ACTIONS),1) $(BUILD_DIR)/src/extras/cheats.o: $(BUILD_DIR)/include/text_strings.h $(LANG_O_FILES) endif + + ifeq ($(DEBUG),1) + $(BUILD_DIR)/src/extras/debug_menu.o: $(BUILD_DIR)/include/text_strings.h $(LANG_O_FILES) + endif $(BUILD_DIR)/src/extras/options_menu.o: $(BUILD_DIR)/include/text_strings.h $(LANG_O_FILES) endif diff --git a/include/sm64.h b/include/sm64.h index f846c01..7e570fa 100644 --- a/include/sm64.h +++ b/include/sm64.h @@ -351,7 +351,11 @@ void *memmove(void *str1, const void *str2, size_t n); #define ACT_READING_SIGN 0x00001308 // (0x108 | ACT_FLAG_STATIONARY | ACT_FLAG_INTANGIBLE) #define ACT_JUMBO_STAR_CUTSCENE 0x00001909 // (0x109 | ACT_FLAG_AIR | ACT_FLAG_INTANGIBLE) #define ACT_WAITING_FOR_DIALOG 0x0000130A // (0x10A | ACT_FLAG_STATIONARY | ACT_FLAG_INTANGIBLE) +#ifdef DEBUG +#define ACT_DEBUG_FREE_MOVE 0x0000190F // (0x10F | ACT_FLAG_AIR | ACT_FLAG_INTANGIBLE) +#else #define ACT_DEBUG_FREE_MOVE 0x0000130F // (0x10F | ACT_FLAG_STATIONARY | ACT_FLAG_INTANGIBLE) +#endif #define ACT_STANDING_DEATH 0x00021311 // (0x111 | ACT_FLAG_STATIONARY | ACT_FLAG_INTANGIBLE | ACT_FLAG_INVULNERABLE) #define ACT_QUICKSAND_DEATH 0x00021312 // (0x112 | ACT_FLAG_STATIONARY | ACT_FLAG_INTANGIBLE | ACT_FLAG_INVULNERABLE) #define ACT_ELECTROCUTION 0x00021313 // (0x113 | ACT_FLAG_STATIONARY | ACT_FLAG_INTANGIBLE | ACT_FLAG_INVULNERABLE) diff --git a/include/text_debug_strings.h.in b/include/text_debug_strings.h.in new file mode 100644 index 0000000..85ca8e9 --- /dev/null +++ b/include/text_debug_strings.h.in @@ -0,0 +1,23 @@ +#ifndef TEXT_DEBUG_STRINGS_H +#define TEXT_DEBUG_STRINGS_H + +#define TEXT_OPT_DEBUG _("DEBUG") + +#if defined(VERSION_JP) || defined(VERSION_SH) +// TODO: Actually translate this to JP +#define TEXT_OPT_DEBUG0 _("SIMPLE DEBUG DISPLAY") +#define TEXT_OPT_DEBUG1 _("COMPLEX DEBUG DISPLAY") +#define TEXT_OPT_DEBUG2 _("LEVEL SELECT") +#define TEXT_OPT_DEBUG3 _("FREE MOVEMENT (PRESS L)") +#define TEXT_OPT_DEBUG4 _("DEBUG CAP CHANGER") +#define TEXT_OPT_DEBUG5 _("SHOW PROFILER") +#else +#define TEXT_OPT_DEBUG0 _("Simple Debug Display") +#define TEXT_OPT_DEBUG1 _("Complex Debug Display") +#define TEXT_OPT_DEBUG2 _("Level Select") +#define TEXT_OPT_DEBUG3 _("Free Movement (Press L)") +#define TEXT_OPT_DEBUG4 _("Debug Cap Changer") +#define TEXT_OPT_DEBUG5 _("Show Profiler") +#endif + +#endif // TEXT_DEBUG_STRINGS_H diff --git a/include/text_strings.h.in b/include/text_strings.h.in index dc1aabd..8a49027 100644 --- a/include/text_strings.h.in +++ b/include/text_strings.h.in @@ -11,6 +11,10 @@ #include "text_cheats_strings.h" #endif +#ifdef DEBUG +#include "text_debug_strings.h" +#endif + /** * Global Symbols */ diff --git a/src/extras/cheats.c b/src/extras/cheats.c index bae82c3..db038b3 100644 --- a/src/extras/cheats.c +++ b/src/extras/cheats.c @@ -3,16 +3,20 @@ #include "sm64.h" #include "text_strings.h" #include "gfx_dimensions.h" -#include "engine/math_util.h" + #include "audio/external.h" +#include "engine/math_util.h" +#include "engine/surface_collision.h" #include "game/camera.h" +#include "game/ingame_menu.h" #include "game/level_update.h" +#include "game/mario.h" +#include "game/mario_misc.h" +#include "game/object_list_processor.h" #include "game/print.h" #include "game/segment2.h" #include "game/save_file.h" -#include "game/mario_misc.h" #include "game/game_init.h" -#include "game/ingame_menu.h" #include "options_menu.h" #include "cheats.h" diff --git a/src/extras/cheats.h b/src/extras/cheats.h index a81de39..a89fa0f 100644 --- a/src/extras/cheats.h +++ b/src/extras/cheats.h @@ -1,47 +1,22 @@ #ifndef CHEATS_H #define CHEATS_H -#include - #include "sm64.h" - -#include "audio/data.h" -#include "audio/external.h" - -#include "engine/behavior_script.h" -#include "engine/graph_node.h" -#include "engine/level_script.h" +#include "text_strings.h" +#include "gfx_dimensions.h" #include "engine/math_util.h" -#include "engine/surface_collision.h" - -#include "game/area.h" -#include "game/behavior_actions.h" +#include "audio/external.h" #include "game/camera.h" -#include "game/debug.h" -#include "game/game_init.h" -#include "game/interaction.h" #include "game/level_update.h" -#include "game/main.h" -#include "game/mario.h" -#include "game/mario_actions_airborne.h" -#include "game/mario_actions_automatic.h" -#include "game/mario_actions_cutscene.h" -#include "game/mario_actions_moving.h" -#include "game/mario_actions_object.h" -#include "game/mario_actions_stationary.h" -#include "game/mario_actions_submerged.h" -#include "game/mario_misc.h" -#include "game/mario_step.h" -#include "game/memory.h" -#include "game/object_helpers.h" -#include "game/object_list_processor.h" #include "game/print.h" -#include "game/rendering_graph_node.h" -#include "game/rumble_init.h" +#include "game/segment2.h" #include "game/save_file.h" -#include "game/sound_init.h" +#include "game/mario_misc.h" +#include "game/game_init.h" +#include "game/ingame_menu.h" #include "options_menu.h" +#include "cheats.h" #ifndef TARGET_N64 #include diff --git a/src/extras/debug_menu.c b/src/extras/debug_menu.c new file mode 100644 index 0000000..006bb1c --- /dev/null +++ b/src/extras/debug_menu.c @@ -0,0 +1,98 @@ +#ifdef DEBUG + +#include "sm64.h" +#include "text_strings.h" +#include "gfx_dimensions.h" +#include "seq_ids.h" + +#include "audio/external.h" +#include "engine/math_util.h" +#include "game/camera.h" +#include "game/debug.h" +#include "game/level_update.h" +#include "game/mario.h" +#include "game/mario_misc.h" +#include "game/object_list_processor.h" +#include "game/print.h" +#include "game/segment2.h" +#include "game/save_file.h" +#include "game/mario_misc.h" +#include "game/game_init.h" +#include "game/ingame_menu.h" + +#include "options_menu.h" + +#ifndef TARGET_N64 +#include +#else +#define bool int +#endif + +extern s8 gShowDebugText; +extern s8 gDebugLevelSelect; +extern s8 gShowProfiler; +extern void try_modify_debug_controls(void); +extern void try_change_debug_page(void); +extern void debug_update_mario_cap(u16 button, s32 flags, u16 capTimer, u16 capMusic); + +bool gShowComplexDebugText; +bool gDebugFreeMoveAct; +bool gDebugCapChanger; + +const u8 optDebugMenuStr[][32] = { + { TEXT_OPT_DEBUG }, +}; + +static const u8 optsDebugStr[][64] = { + { TEXT_OPT_DEBUG0 }, + { TEXT_OPT_DEBUG1 }, + { TEXT_OPT_DEBUG2 }, + { TEXT_OPT_DEBUG3 }, + { TEXT_OPT_DEBUG4 }, + { TEXT_OPT_DEBUG5 }, +}; + +struct Option optsDebug[] = { + DEF_OPT_TOGGLE( optsDebugStr[0], (bool *) &gShowDebugText ), + DEF_OPT_TOGGLE( optsDebugStr[1], &gShowComplexDebugText ), + DEF_OPT_TOGGLE( optsDebugStr[2], (bool *) &gDebugLevelSelect ), + DEF_OPT_TOGGLE( optsDebugStr[3], &gDebugFreeMoveAct ), + DEF_OPT_TOGGLE( optsDebugStr[4], &gDebugCapChanger ), + DEF_OPT_TOGGLE( optsDebugStr[5], (bool *) &gShowProfiler ), +}; + +struct SubMenu menuDebug = DEF_SUBMENU( optDebugMenuStr[0], optsDebug ); + +void activate_complex_debug_display(void) { + if (gShowComplexDebugText) { + gDebugInfoFlags |= 0xFF; // DEBUG_INFO_FLAG_ALL + try_modify_debug_controls(); + try_change_debug_page(); + } else { + gDebugInfoFlags = ~0xFF; + } +} + +void set_debug_free_move_action(struct MarioState *m) { + if (m->controller->buttonPressed & L_TRIG) { + set_mario_action(m, ACT_DEBUG_FREE_MOVE, 0); + } +} + +void set_debug_cap_changer(void) { + debug_update_mario_cap(CONT_LEFT, MARIO_WING_CAP, 1800, SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)); + debug_update_mario_cap(CONT_UP, MARIO_METAL_CAP, 600, SEQUENCE_ARGS(4, SEQ_EVENT_METAL_CAP)); + debug_update_mario_cap(CONT_RIGHT, MARIO_VANISH_CAP, 600, SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)); +} + +void set_debug_mario_action(struct MarioState *m) { + if (gDebugFreeMoveAct) { + set_debug_free_move_action(m); + } + + if (gDebugCapChanger) { + set_debug_cap_changer(); + } +} + +#endif diff --git a/src/extras/debug_menu.h b/src/extras/debug_menu.h new file mode 100644 index 0000000..f6a42cf --- /dev/null +++ b/src/extras/debug_menu.h @@ -0,0 +1,30 @@ +#ifndef DEBUG_MENU_OPT_H +#define DEBUG_MENU_OPT_H + +#include "sm64.h" +#include "text_strings.h" +#include "gfx_dimensions.h" +#include "engine/math_util.h" +#include "audio/external.h" +#include "game/camera.h" +#include "game/level_update.h" +#include "game/mario.h" +#include "game/mario_misc.h" +#include "game/print.h" +#include "game/segment2.h" +#include "game/save_file.h" +#include "game/mario_misc.h" +#include "game/game_init.h" +#include "game/ingame_menu.h" + +#include "options_menu.h" +#include "cheats.h" + +extern const u8 optDebugMenuStr[][32]; + +extern struct SubMenu menuDebug; + +void activate_complex_debug_display(void); +void set_debug_mario_action(struct MarioState *m); + +#endif // DEBUG_MENU_OPT_H diff --git a/src/extras/misc_functions.c b/src/extras/misc_functions.c index 59f7239..075e796 100644 --- a/src/extras/misc_functions.c +++ b/src/extras/misc_functions.c @@ -1,7 +1,6 @@ #include #include "sm64.h" -#include "text_strings.h" #include "gfx_dimensions.h" #include "engine/math_util.h" #include "audio/external.h" diff --git a/src/extras/options_menu.c b/src/extras/options_menu.c index a63c00b..7912002 100644 --- a/src/extras/options_menu.c +++ b/src/extras/options_menu.c @@ -16,24 +16,28 @@ #include "options_menu.h" -#ifdef BETTERCAMERA -#include "bettercamera.h" -#endif - #ifndef TARGET_N64 #include "pc/pc_main.h" #include "pc/controller/controller_api.h" +#include "pc/configfile.h" #include #include "../../include/libc/stdlib.h" #endif -#include "pc/configfile.h" + +#ifdef BETTERCAMERA +#include "bettercamera.h" +#endif #ifdef CHEATS_ACTIONS #include "cheats.h" #endif +#ifdef DEBUG +#include "debug_menu.h" +#endif + u8 optmenu_open = 0; #if !defined(TARGET_N64) && !defined(TARGET_PORT_CONSOLE) @@ -247,13 +251,18 @@ static struct Option optsMain[] = { DEF_OPT_SUBMENU( optMainStr[3], &menuAudio ), DEF_OPT_SUBMENU( optMainStr[4], &menuSettings ), +#ifdef DEBUG + // NOTE: always keep cheats the last option here because of the half-assed way I toggle them + DEF_OPT_SUBMENU( optDebugMenuStr[0], &menuDebug ), +#endif + #if !defined(TARGET_N64) && !defined(TARGET_PORT_CONSOLE) DEF_OPT_BUTTON ( optMainStr[5], optmenu_act_exit ), #endif #ifdef CHEATS_ACTIONS // NOTE: always keep cheats the last option here because of the half-assed way I toggle them - DEF_OPT_SUBMENU( optCheatMenuStr[0], &menuCheats ) + DEF_OPT_SUBMENU( optCheatMenuStr[0], &menuCheats ), #endif }; diff --git a/src/game/camera.c b/src/game/camera.c index af35695..eaa65b0 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -671,7 +671,7 @@ BAD_RETURN(f32) calc_y_to_curr_floor(f32 *posOff, f32 posMul, f32 posBound, f32 #if QOL_FIX_CAMERA_WATER_HEIGHT f32 waterHeight = sMarioGeometry.waterHeight; #else - f32 waterHeight + f32 waterHeight; #endif UNUSED s32 filler; diff --git a/src/game/debug.c b/src/game/debug.c index 528a5e3..b30f8aa 100644 --- a/src/game/debug.c +++ b/src/game/debug.c @@ -14,6 +14,10 @@ #include "sm64.h" #include "types.h" +#ifdef DEBUG +#include "extras/debug_menu.h" +#endif + #define DEBUG_INFO_NOFLAGS (0 << 0) #define DEBUG_INFO_FLAG_DPRINT (1 << 0) #define DEBUG_INFO_FLAG_LSELECT (1 << 1) @@ -162,7 +166,6 @@ void print_debug_top_down_normal(const char *str, s32 number) { } } -#ifndef VERSION_EU void print_mapinfo(void) { struct Surface *pfloor; f32 bgY; @@ -199,41 +202,6 @@ void print_mapinfo(void) { print_debug_top_down_mapinfo("water %d", water); } } -#else -void print_mapinfo(void) { - // EU mostly stubbed this function out. - struct Surface *pfloor; - UNUSED f32 bgY; - UNUSED f32 water; - UNUSED s32 area; - // s32 angY; - // - // angY = gCurrentObject->oMoveAngleYaw / 182.044000; - // area = ((s32)gCurrentObject->oPosX + 0x2000) / 1024 - // + ((s32)gCurrentObject->oPosZ + 0x2000) / 1024 * 16; - // - bgY = find_floor(gCurrentObject->oPosX, gCurrentObject->oPosY, gCurrentObject->oPosZ, &pfloor); - water = find_water_level(gCurrentObject->oPosX, gCurrentObject->oPosZ); - - print_debug_top_down_normal("mapinfo", 0); - // print_debug_top_down_mapinfo("area %x", area); - // print_debug_top_down_mapinfo("wx %d", gCurrentObject->oPosX); - // print_debug_top_down_mapinfo("wy\t %d", gCurrentObject->oPosY); - // print_debug_top_down_mapinfo("wz %d", gCurrentObject->oPosZ); - // print_debug_top_down_mapinfo("bgY %d", bgY); - // print_debug_top_down_mapinfo("angY %d", angY); - // - // if(pfloor) // not null - //{ - // print_debug_top_down_mapinfo("bgcode %d", pfloor->type); - // print_debug_top_down_mapinfo("bgstatus %d", pfloor->flags); - // print_debug_top_down_mapinfo("bgarea %d", pfloor->room); - //} - // - // if(gCurrentObject->oPosY < water) - // print_debug_top_down_mapinfo("water %d", water); -} -#endif void print_checkinfo(void) { print_debug_top_down_normal("checkinfo", 0); @@ -367,7 +335,7 @@ static void check_debug_button_seq(void) { * Poll the debug info flags and controller for appropriate presses that * control sDebugPage's range. (unused) */ -static void try_change_debug_page(void) { +void try_change_debug_page(void) { if (gDebugInfoFlags & DEBUG_INFO_FLAG_DPRINT) { if ((gPlayer1Controller->buttonPressed & L_JPAD) && (gPlayer1Controller->buttonDown & (L_TRIG | R_TRIG))) { @@ -392,9 +360,6 @@ static void try_change_debug_page(void) { * sDebugSysCursor. This is used to adjust enemy and effect behaviors * on the fly. (unused) */ -#ifdef VERSION_SH -static -#endif void try_modify_debug_controls(void) { s32 sp4; @@ -496,6 +461,10 @@ void try_print_debug_mario_level_info(void) { default: break; } + +#ifdef DEBUG + activate_complex_debug_display(); +#endif } /* diff --git a/src/game/mario.c b/src/game/mario.c index 92dd7bd..fb9332c 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -34,12 +34,16 @@ #include "sound_init.h" #include "pc/configfile.h" +#ifdef BETTERCAMERA +#include "extras/bettercamera.h" +#endif + #ifdef CHEATS_ACTIONS #include "extras/cheats.h" #endif -#ifdef BETTERCAMERA -#include "extras/bettercamera.h" +#ifdef DEBUG +#include "extras/debug_menu.h" #endif u32 unused80339F10; @@ -1699,7 +1703,7 @@ void mario_update_hitbox_and_cap_model(struct MarioState *m) { * An unused and possibly a debug function. Z + another button input * sets Mario with a different cap. */ -static void debug_update_mario_cap(u16 button, s32 flags, u16 capTimer, u16 capMusic) { +void debug_update_mario_cap(u16 button, s32 flags, u16 capTimer, u16 capMusic) { // This checks for Z_TRIG instead of Z_DOWN flag // (which is also what other debug functions do), // so likely debug behavior rather than unused behavior. @@ -1740,6 +1744,10 @@ s32 execute_mario_action(UNUSED struct Object *o) { cheats_mario_action(gMarioState); #endif +#ifdef DEBUG + set_debug_mario_action(gMarioState); +#endif + if (gMarioState->action) { gMarioState->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; mario_reset_bodystate(gMarioState);