From 78cc957d31373e487749a643d13a72b7d567384e Mon Sep 17 00:00:00 2001 From: Gregory Heskett Date: Tue, 31 Oct 2023 18:23:15 -0400 Subject: [PATCH 01/12] Preserve vanilla reverb downsampling behavior whenever BETTER_REVERB isn't in use (#727) --- src/audio/synthesis.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/audio/synthesis.c b/src/audio/synthesis.c index 6d027440..6e38a781 100644 --- a/src/audio/synthesis.c +++ b/src/audio/synthesis.c @@ -770,9 +770,18 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateI aResample(cmd++, gSynthesisReverb.resampleFlags, (u16) gSynthesisReverb.resampleRate, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.resampleStateLeft)); aSetBuffer(cmd++, 0, t4 + DMEM_ADDR_WET_RIGHT_CH, DMEM_ADDR_RIGHT_CH, bufLen << 1); aResample(cmd++, gSynthesisReverb.resampleFlags, (u16) gSynthesisReverb.resampleRate, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.resampleStateRight)); +#ifdef BETTER_REVERB + // NOTE: Technically using an if/else here means using BETTER_REVERB vanilla presets with downsampling won't match 1-to-1 in volume with BETTER_REVERB being disabled. + // This chunk is actually preferable to what vanilla uses, but was mainly ifdef'd here as a means of documenting BETTER_REVERB changes for other non-HackerSM64 repos. + // Please use this chunk over the latter if matching BETTER_REVERB behavior ever becomes a future priority. aDMEMMove(cmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH); aSetBuffer(cmd++, 0, 0, 0, DEFAULT_LEN_2CH); aMix(cmd++, 0, /*gain*/ 0x8000 + gSynthesisReverb.reverbGain, /*in*/ DMEM_ADDR_WET_LEFT_CH, /*out*/ DMEM_ADDR_WET_LEFT_CH); +#else + aSetBuffer(cmd++, 0, 0, 0, DEFAULT_LEN_2CH); + aMix(cmd++, 0, /*gain*/ 0x8000 + gSynthesisReverb.reverbGain, /*in*/ DMEM_ADDR_LEFT_CH, /*out*/ DMEM_ADDR_LEFT_CH); + aDMEMMove(cmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH); +#endif } AUDIO_PROFILER_SWITCH(PROFILER_TIME_SUB_AUDIO_SYNTHESIS_ENVELOPE_REVERB, PROFILER_TIME_SUB_AUDIO_SYNTHESIS_PROCESSING); From 36c98b6cd1b590d05bf09d5eac2875d109d07975 Mon Sep 17 00:00:00 2001 From: Denis Kopyrin Date: Sun, 10 Dec 2023 15:28:08 +0800 Subject: [PATCH 02/12] Disable unrelated buttons controlling S&Q menu and pausing (#728) --- src/game/ingame_menu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index 1bd615ce..2f59482a 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -581,11 +581,11 @@ void handle_menu_scrolling(s8 scrollDirection, s8 *currentIndex, s8 minIndex, s8 u8 index = 0; if (scrollDirection == MENU_SCROLL_VERTICAL) { - if ((gPlayer1Controller->rawStickY > 60) || (gPlayer1Controller->buttonDown & (U_CBUTTONS | U_JPAD))) index++; - if ((gPlayer1Controller->rawStickY < -60) || (gPlayer1Controller->buttonDown & (D_CBUTTONS | D_JPAD))) index += 2; + if (gPlayer1Controller->rawStickY > 60) index++; + if (gPlayer1Controller->rawStickY < -60) index += 2; } else if (scrollDirection == MENU_SCROLL_HORIZONTAL) { - if ((gPlayer1Controller->rawStickX > 60) || (gPlayer1Controller->buttonDown & (R_CBUTTONS | R_JPAD))) index += 2; - if ((gPlayer1Controller->rawStickX < -60) || (gPlayer1Controller->buttonDown & (L_CBUTTONS | L_JPAD))) index++; + if (gPlayer1Controller->rawStickX > 60) index += 2; + if (gPlayer1Controller->rawStickX < -60) index++; } if (((index ^ gMenuHoldKeyIndex) & index) == 2) { @@ -1932,7 +1932,7 @@ s32 render_pause_courses_and_castle(void) { render_pause_castle_menu_box(160, 143); render_pause_castle_main_strings(104, 60); - if (gPlayer1Controller->buttonPressed & (A_BUTTON | START_BUTTON | Z_TRIG)) { + if (gPlayer1Controller->buttonPressed & (A_BUTTON | START_BUTTON)) { level_set_transition(0, NULL); play_sound(SOUND_MENU_PAUSE_CLOSE, gGlobalSoundSource); gMenuMode = MENU_MODE_NONE; From 72f8ea130ff21d13bcaf1c54d1dc3776148ec8a3 Mon Sep 17 00:00:00 2001 From: MisterSheeple <27652712+MisterSheeple@users.noreply.github.com> Date: Sun, 10 Dec 2023 22:40:34 -0500 Subject: [PATCH 03/12] Update Dockerfile to Ubuntu 22.04 as 18.04 is EOL (#731) * Update Dockerfile to Ubuntu 22.04 as 18.04 is EOL * Dockerfile: Use modern syntax for mounting * Add gcc-mips-linux-gnu to dockerfile --- Dockerfile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index f36f10e3..5c6d083b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,18 @@ -FROM ubuntu:18.04 as build +FROM ubuntu:22.04 as build RUN apt-get update && \ apt-get install -y \ binutils-mips-linux-gnu \ - bsdmainutils \ + bsdextrautils \ build-essential \ + gcc-mips-linux-gnu \ libcapstone-dev \ pkgconf \ python3 -RUN mkdir /sm64 -WORKDIR /sm64 -ENV PATH="/sm64/tools:${PATH}" +RUN mkdir /hackersm64 +WORKDIR /hackersm64 +ENV PATH="/hackersm64/tools:${PATH}" -CMD echo 'usage: docker run --rm --mount type=bind,source="$(pwd)",destination=/sm64 sm64 make VERSION=us -j4\n' \ - 'see https://github.com/n64decomp/sm64/blob/master/README.md for advanced usage' +CMD echo 'Usage: docker run --rm -v ${PWD}:/hackersm64 hackersm64 make VERSION=us -j4\n' \ + 'See https://github.com/HackerN64/HackerSM64/blob/master/README.md for more information' From 4f2c48c733d71fa41ae8865d0fbbde5a57dd75cd Mon Sep 17 00:00:00 2001 From: Gregory Heskett Date: Mon, 11 Dec 2023 01:58:30 -0500 Subject: [PATCH 04/12] Add DEBUG_ASSERTIONS define and enable it by default (#730) --- include/config/config_debug.h | 9 +++++++++ include/config/config_safeguards.h | 14 +++++++++++--- src/game/debug.h | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/config/config_debug.h b/include/config/config_debug.h index 86e27755..7ed67cac 100644 --- a/include/config/config_debug.h +++ b/include/config/config_debug.h @@ -14,6 +14,10 @@ */ // #define DISABLE_ALL + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** * Enables a comprehensive standalone profiler. Automatically enabled by PUPPYPRINT_DEBUG. * If not using PUPPYPRINT_DEBUG, press L + D-Pad Up to toggle the profiler. @@ -85,3 +89,8 @@ * Forces a crash when the game starts. Useful for debugging the crash screen. */ // #define DEBUG_FORCE_CRASH_ON_BOOT + +/** + * Intentionally crash the game whenever a runtime assertion fails (also invoked by the DEBUG define in the Makefile). + */ +#define DEBUG_ASSERTIONS diff --git a/include/config/config_safeguards.h b/include/config/config_safeguards.h index 3a7b9659..3ddc689b 100644 --- a/include/config/config_safeguards.h +++ b/include/config/config_safeguards.h @@ -75,21 +75,26 @@ #ifdef DISABLE_ALL #undef DEBUG_ALL + #undef USE_PROFILER #undef TEST_LEVEL #undef DEBUG_LEVEL_SELECT #undef ENABLE_DEBUG_FREE_MOVE - #undef VANILLA_DEBUG - #undef VANILLA_STYLE_CUSTOM_DEBUG #undef PUPPYPRINT_DEBUG #undef PUPPYPRINT_DEBUG_CYCLES + #undef VANILLA_STYLE_CUSTOM_DEBUG #undef VISUAL_DEBUG #undef UNLOCK_ALL #undef COMPLETE_SAVE_FILE + #undef UNLOCK_FPS + #undef VANILLA_DEBUG #undef DEBUG_FORCE_CRASH_ON_BOOT - #undef USE_PROFILER + #undef DEBUG_ASSERTIONS #endif // DISABLE_ALL #ifdef DEBUG_ALL + #undef USE_PROFILER + #define USE_PROFILER + #undef DEBUG_LEVEL_SELECT #define DEBUG_LEVEL_SELECT @@ -110,6 +115,9 @@ #undef COMPLETE_SAVE_FILE #define COMPLETE_SAVE_FILE + + #undef DEBUG_ASSERTIONS + #define DEBUG_ASSERTIONS #endif // DEBUG_ALL #ifdef PUPPYPRINT_DEBUG diff --git a/src/game/debug.h b/src/game/debug.h index 522ace2d..c8862f13 100644 --- a/src/game/debug.h +++ b/src/game/debug.h @@ -62,7 +62,7 @@ extern void __n64Assert(char *fileName, u32 lineNum, char *message); /** * Will cause a crash if cond is not true, and DEBUG is defined (allows for quick removal of littered asserts) */ -#ifdef DEBUG +#if defined(DEBUG) || defined(DEBUG_ASSERTIONS) #define assert(cond, message) do {\ if ((cond) == FALSE) { \ error(message); \ From 7df16608a77b478d9414b2cb90604f9d6facfa8b Mon Sep 17 00:00:00 2001 From: someone2639 Date: Thu, 14 Dec 2023 23:26:43 -0500 Subject: [PATCH 05/12] Add relevant model ID asserts to level script load commands (#722) Co-authored-by: someone2639 --- src/engine/level_script.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/level_script.c b/src/engine/level_script.c index 3dad0c35..927c6494 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -9,6 +9,7 @@ #include "buffers/framebuffers.h" #include "buffers/zbuffer.h" #include "game/area.h" +#include "game/debug.h" #include "game/game_init.h" #include "game/mario.h" #include "game/memory.h" @@ -431,6 +432,7 @@ static void level_cmd_load_model_from_dl(void) { s16 layer = CMD_GET(u16, 0x8); void *dl_ptr = CMD_GET(void *, 4); + assert(model < MODEL_ID_COUNT, "Tried to load an invalid model ID."); if (model < MODEL_ID_COUNT) { gLoadedGraphNodes[model] = (struct GraphNode *) init_graph_node_display_list(sLevelPool, 0, layer, dl_ptr); @@ -443,6 +445,7 @@ static void level_cmd_load_model_from_geo(void) { ModelID16 model = CMD_GET(ModelID16, 2); void *geo = CMD_GET(void *, 4); + assert(model < MODEL_ID_COUNT, "Tried to load an invalid model ID."); if (model < MODEL_ID_COUNT) { gLoadedGraphNodes[model] = process_geo_layout(sLevelPool, geo); } @@ -456,6 +459,7 @@ static void level_cmd_23(void) { void *dl = CMD_GET(void *, 4); s32 scale = CMD_GET(s32, 8); + assert(model < MODEL_ID_COUNT, "Tried to load an invalid model ID."); if (model < MODEL_ID_COUNT) { // GraphNodeScale has a GraphNode at the top. This // is being stored to the array, so cast the pointer. From 08f0e3efa4a6a90f2b8f1bbcc340bd4c50f4a093 Mon Sep 17 00:00:00 2001 From: Lilaa3 <87947656+Lilaa3@users.noreply.github.com> Date: Fri, 29 Dec 2023 23:32:19 +0000 Subject: [PATCH 06/12] Define changes for transitions, two bug fixes (#739) * Fixed one or two bugs, cleaned up a few things, put every non vanilla styled change into POLISHED_TRANSITIONS And renamed set_and_reset_transition_fade_timer * Undid the renaming of set_and_reset_transition_fade_timer as suggested --- include/config/config_graphics.h | 5 +++-- src/game/area.c | 8 +++++--- src/game/level_update.c | 7 +------ src/game/screen_transition.c | 15 +++------------ src/game/screen_transition.h | 1 + 5 files changed, 13 insertions(+), 23 deletions(-) diff --git a/include/config/config_graphics.h b/include/config/config_graphics.h index 6e8c68c1..179c833a 100644 --- a/include/config/config_graphics.h +++ b/include/config/config_graphics.h @@ -141,9 +141,10 @@ #define DEFAULT_CULLING_RADIUS 300 /** - * Eases the textured screen transitions to make them look smoother. + * Eases the textured screen transitions to make them look smoother. + * Extends the full radius for mario, bowser and the star transitions. */ -#define EASE_IN_OUT_TRANSITIONS +// #define POLISHED_TRANSITIONS /** * Uses frustratio of 2 instead of 1. diff --git a/src/game/area.c b/src/game/area.c index b917c14e..1e99763f 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -331,11 +331,13 @@ void play_transition(s16 transType, s16 time, Color red, Color green, Color blue red = gWarpTransRed, green = gWarpTransGreen, blue = gWarpTransBlue; } - if (transType < WARP_TRANSITION_TYPE_STAR) { // if transition is WARP_TRANSITION_TYPE_COLOR + if (transType & WARP_TRANSITION_TYPE_COLOR) { gWarpTransition.data.red = red; gWarpTransition.data.green = green; gWarpTransition.data.blue = blue; } else { // if transition is textured + set_and_reset_transition_fade_timer(0); // Reset transition timers by passing in 0 for time + gWarpTransition.data.red = red; gWarpTransition.data.green = green; gWarpTransition.data.blue = blue; @@ -353,8 +355,7 @@ void play_transition(s16 transType, s16 time, Color red, Color green, Color blue s16 fullRadius = GFX_DIMENSIONS_FULL_RADIUS; - // HackerSM64: this fixes the pop-in with texture transition, comment out this switch - // statement if you want to restore the original full radius. +#ifdef POLISHED_TRANSITIONS switch (transType){ case WARP_TRANSITION_TYPE_BOWSER: case WARP_TRANSITION_FADE_INTO_BOWSER: @@ -369,6 +370,7 @@ void play_transition(s16 transType, s16 time, Color red, Color green, Color blue fullRadius *= 1.5f; break; } +#endif if (transType & WARP_TRANSITION_FADE_INTO) { // Is the image fading in? gWarpTransition.data.startTexRadius = fullRadius; diff --git a/src/game/level_update.c b/src/game/level_update.c index ade15313..6674dc49 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -382,10 +382,8 @@ void init_mario_after_warp(void) { sDelayedWarpOp = WARP_OP_NONE; switch (marioSpawnType) { - case MARIO_SPAWN_PIPE: - play_transition(WARP_TRANSITION_FADE_FROM_STAR, 0x10, 0x00, 0x00, 0x00); - break; case MARIO_SPAWN_DOOR_WARP: + case MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE: play_transition(WARP_TRANSITION_FADE_FROM_CIRCLE, 0x10, 0x00, 0x00, 0x00); break; case MARIO_SPAWN_TELEPORT: @@ -394,9 +392,6 @@ void init_mario_after_warp(void) { case MARIO_SPAWN_SPIN_AIRBORNE: play_transition(WARP_TRANSITION_FADE_FROM_COLOR, 0x1A, 0xFF, 0xFF, 0xFF); break; - case MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE: - play_transition(WARP_TRANSITION_FADE_FROM_CIRCLE, 0x10, 0x00, 0x00, 0x00); - break; case MARIO_SPAWN_FADE_FROM_BLACK: play_transition(WARP_TRANSITION_FADE_FROM_COLOR, 0x10, 0x00, 0x00, 0x00); break; diff --git a/src/game/screen_transition.c b/src/game/screen_transition.c index 2376b1f7..5e17ac83 100644 --- a/src/game/screen_transition.c +++ b/src/game/screen_transition.c @@ -81,10 +81,10 @@ void make_tex_transition_vertices(Vtx *verts, f32 centerTransX, f32 centerTransY make_tex_transition_vertex(verts, 7, centerTransX, centerTransY, -SOLID_COL_RADIUS, SOLID_COL_RADIUS, 0, 0); } -f32 calc_tex_transition_radius(s8 transTime, struct WarpTransitionData *transData) { +f32 calc_tex_transition_radius(u8 transTime, struct WarpTransitionData *transData) { f32 amount = (f32) sTransitionFadeTimer / (f32) (transTime - 1); -#ifdef EASE_IN_OUT_TRANSITIONS +#ifdef POLISHED_TRANSITIONS return smoothstep(transData->startTexRadius, transData->endTexRadius, amount); #else return lerpf(transData->startTexRadius, transData->endTexRadius, amount); @@ -128,7 +128,7 @@ u16 calc_tex_transition_direction(struct WarpTransitionData *transData) { * Called during render_screen_transition. * Handles shape transitions (such as the star, circle and Mario and bowser´s heads). */ -s32 render_textured_transition(s8 transTime, struct WarpTransitionData *transData, s8 texID, s8 transTexType) { +s32 render_textured_transition(u8 transTime, struct WarpTransitionData *transData, s8 texID, s8 transTexType) { u16 texTransDir = calc_tex_transition_direction(transData); f32 posDistance = calc_tex_transition_pos_distance(transTime, transData); @@ -138,7 +138,6 @@ s32 render_textured_transition(s8 transTime, struct WarpTransitionData *transDat f32 texTransRadius = calc_tex_transition_radius(transTime, transData); Vtx *verts = alloc_display_list(8 * sizeof(Vtx)); - if (verts != NULL) { make_tex_transition_vertices(verts, centerTransX, centerTransY, texTransRadius, transTexType); gSPDisplayList(gDisplayListHead++, dl_proj_mtx_fullscreen); @@ -253,29 +252,21 @@ s32 render_screen_transition(s8 transType, u8 transTime, struct WarpTransitionDa break; case WARP_TRANSITION_FADE_FROM_STAR: - return render_textured_transition(transTime, transData, TEX_TRANS_STAR, TRANS_TYPE_MIRROR); - break; case WARP_TRANSITION_FADE_INTO_STAR: return render_textured_transition(transTime, transData, TEX_TRANS_STAR, TRANS_TYPE_MIRROR); break; case WARP_TRANSITION_FADE_FROM_CIRCLE: - return render_textured_transition(transTime, transData, TEX_TRANS_CIRCLE, TRANS_TYPE_MIRROR); - break; case WARP_TRANSITION_FADE_INTO_CIRCLE: return render_textured_transition(transTime, transData, TEX_TRANS_CIRCLE, TRANS_TYPE_MIRROR); break; case WARP_TRANSITION_FADE_FROM_MARIO: - return render_textured_transition(transTime, transData, TEX_TRANS_MARIO, TRANS_TYPE_CLAMP); - break; case WARP_TRANSITION_FADE_INTO_MARIO: return render_textured_transition(transTime, transData, TEX_TRANS_MARIO, TRANS_TYPE_CLAMP); break; case WARP_TRANSITION_FADE_FROM_BOWSER: - return render_textured_transition(transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR); - break; case WARP_TRANSITION_FADE_INTO_BOWSER: return render_textured_transition(transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR); break; diff --git a/src/game/screen_transition.h b/src/game/screen_transition.h index 0bfb092a..7dd0f1f1 100644 --- a/src/game/screen_transition.h +++ b/src/game/screen_transition.h @@ -24,6 +24,7 @@ enum ColorTransitionFade { COLOR_TRANS_FADE_FROM_COLOR, }; +s32 set_and_reset_transition_fade_timer(u8 transTime); s32 render_screen_transition(s8 transType, u8 transTime, struct WarpTransitionData *transData); Gfx *geo_cannon_circle_base(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); From b2707990f25e58ec3d14452fa5338c8f9af69036 Mon Sep 17 00:00:00 2001 From: Arceveti <73617174+Arceveti@users.noreply.github.com> Date: Mon, 1 Jan 2024 15:44:41 -0800 Subject: [PATCH 07/12] Fix silhouette occlusion layers rendering twice (#748) --- src/game/rendering_graph_node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index 4fc8c7e5..7ea44b15 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -286,7 +286,7 @@ static struct RenderPhase sRenderPhases[] = { }, [RENDER_PHASE_ZEX_AFTER_SILHOUETTE] = { - .startLayer = LAYER_OCCLUDE_SILHOUETTE_FIRST, + .startLayer = LAYER_NON_ZB_FIRST, .endLayer = LAYER_LAST, }, From 15a81037efda69f8bf37bf0a80423908c49fccce Mon Sep 17 00:00:00 2001 From: 1ted59 <24933689+1ted59@users.noreply.github.com> Date: Sat, 20 Jan 2024 13:07:45 -0500 Subject: [PATCH 08/12] Fix Boo's Accelerating Upwards During Textbox (Vanilla Bug) (#742) If a `Go On A Ghost Hunt` Boo is killed while it has a gravity of -1 (at the bottom of its oscillation), and does not hit a wall, it will keep the same negative gravity and continue moving until the textbox is closed. Boo Y speed isn't capped in this scenario, so the constant -1 gravity leads to the boo moving upwards at an increasing rate. This leads to issues in `boo_act_4`. The distance eventually increases to a point where the boo object is too far to be returned in `cur_obj_nearest_object_with_behavior`. This can have 2 buggy effects: - the wrong dialog box being brought up if the textbox is delayed (easiest to do by hanging on a ledge). - the puzzle solved jingle being played incorrectly if you wait in the textbox long enough This doesn't actually cause issues with King Boo, it just brings up the wrong text box. King Boo spawning is unaffected by this bug. The fix is to stop the boo after the death animation has finished playing, stopping the boo from accelerating upwards. I don't believe this to cause any other issues (the boo is already dead after all!) Thanks to Kyman for finding this bug. --- src/game/behaviors/boo.inc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/game/behaviors/boo.inc.c b/src/game/behaviors/boo.inc.c index 9a638c76..b9a4d8cd 100644 --- a/src/game/behaviors/boo.inc.c +++ b/src/game/behaviors/boo.inc.c @@ -278,6 +278,7 @@ static s32 boo_update_during_death(void) { if (o->oTimer > 30 || o->oMoveFlags & OBJ_MOVE_HIT_WALL) { spawn_mist_particles(); + boo_stop(); o->oBooDeathStatus = BOO_DEATH_STATUS_DEAD; if (o->oBooParentBigBoo != NULL) { From 5ba00edf20806613a4532f2c009f332a277b195f Mon Sep 17 00:00:00 2001 From: arthurtilly <32559225+arthurtilly@users.noreply.github.com> Date: Mon, 22 Jan 2024 07:38:00 +1300 Subject: [PATCH 09/12] Add assert for beginning geo layout command (#738) * geo layout assert * new idea * Change assert message, add crash screen newline support, and change debug safeguards --------- Co-authored-by: Gregory Heskett --- include/config/config_safeguards.h | 5 +++++ include/geo_commands.h | 2 ++ src/engine/geo_layout.c | 2 ++ src/game/crash_screen.c | 10 +++++++--- src/game/debug.h | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/config/config_safeguards.h b/include/config/config_safeguards.h index 3ddc689b..3c7dce3f 100644 --- a/include/config/config_safeguards.h +++ b/include/config/config_safeguards.h @@ -132,6 +132,11 @@ #define UNLOCK_ALL #endif // COMPLETE_SAVE_FILE +#ifdef DEBUG + #undef DEBUG_ASSERTIONS + #define DEBUG_ASSERTIONS +#endif // DEBUG + /***************** * config_camera.h diff --git a/include/geo_commands.h b/include/geo_commands.h index d8c0c6e4..56706cc7 100644 --- a/include/geo_commands.h +++ b/include/geo_commands.h @@ -58,6 +58,8 @@ enum GeoLayoutCommands { /*0x1E*/ GEO_CMD_NOP_1E, /*0x1F*/ GEO_CMD_NOP_1F, /*0x20*/ GEO_CMD_NODE_CULLING_RADIUS, + + GEO_CMD_COUNT, }; // geo layout macros diff --git a/src/engine/geo_layout.c b/src/engine/geo_layout.c index d91dac3d..3d81a5e6 100644 --- a/src/engine/geo_layout.c +++ b/src/engine/geo_layout.c @@ -5,6 +5,7 @@ #include "math_util.h" #include "game/memory.h" #include "graph_node.h" +#include "game/debug.h" typedef void (*GeoLayoutCommandProc)(void); @@ -771,6 +772,7 @@ struct GraphNode *process_geo_layout(struct AllocOnlyPool *pool, void *segptr) { gGeoLayoutStack[1] = 0; while (gGeoLayoutCommand != NULL) { + assert((gGeoLayoutCommand[0x00] < GEO_CMD_COUNT), "Invalid or unloaded geo layout detected."); GeoLayoutJumpTable[gGeoLayoutCommand[0x00]](); } diff --git a/src/game/crash_screen.c b/src/game/crash_screen.c index c716856d..6b199da9 100644 --- a/src/game/crash_screen.c +++ b/src/game/crash_screen.c @@ -133,6 +133,7 @@ void crash_screen_print(s32 x, s32 y, const char *fmt, ...) { char *ptr; u32 glyph; s32 size; + s32 xOffset = x; char buf[0x108]; bzero(&buf, sizeof(buf)); @@ -147,12 +148,15 @@ void crash_screen_print(s32 x, s32 y, const char *fmt, ...) { while (*ptr) { glyph = gCrashScreenCharToGlyph[*ptr & 0x7f]; - if (glyph != 0xff) { - crash_screen_draw_glyph(x, y, glyph); + if (*ptr == '\n') { + xOffset = x; + y += 10; + } else if (glyph != 0xff) { + crash_screen_draw_glyph(xOffset, y, glyph); } ptr++; - x += 6; + xOffset += 6; } } diff --git a/src/game/debug.h b/src/game/debug.h index c8862f13..9719007f 100644 --- a/src/game/debug.h +++ b/src/game/debug.h @@ -62,7 +62,7 @@ extern void __n64Assert(char *fileName, u32 lineNum, char *message); /** * Will cause a crash if cond is not true, and DEBUG is defined (allows for quick removal of littered asserts) */ -#if defined(DEBUG) || defined(DEBUG_ASSERTIONS) +#ifdef DEBUG_ASSERTIONS #define assert(cond, message) do {\ if ((cond) == FALSE) { \ error(message); \ From c39b2894412047b59bc80f9104b4cb4b49399273 Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Sun, 21 Jan 2024 20:42:50 +0200 Subject: [PATCH 10/12] * Fix weird text on Project64 GLideN64 (#715) Included in the PR will be a list of comparisons. This does two things: 1. Restores the `dl_ia_text_tex_settings` from the original Super Mario 64. Not sure why this was changed. 2. Changes the S coordinate of two vertices from `vertex_ia8_char` from 480 to 512. This is an error from the original game. --- bin/segment2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index 71339cb3..062eed45 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2374,8 +2374,8 @@ static const Vtx vertex_ia8_char[] = { #else {{{ 0, 0, 0}, 0, { 0, 256}, {0xff, 0xff, 0xff, 0xff}}}, {{{ 8, 0, 0}, 0, { 0, 0}, {0xff, 0xff, 0xff, 0xff}}}, - {{{ 8, 16, 0}, 0, { 480, 0}, {0xff, 0xff, 0xff, 0xff}}}, - {{{ 0, 16, 0}, 0, { 480, 256}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ 8, 16, 0}, 0, { 512, 0}, {0xff, 0xff, 0xff, 0xff}}}, + {{{ 0, 16, 0}, 0, { 512, 256}, {0xff, 0xff, 0xff, 0xff}}}, #endif }; @@ -2394,11 +2394,11 @@ const Gfx dl_ia_text_begin[] = { // 0x020073E8 - 0x02007418 const Gfx dl_ia_text_tex_settings[] = { - gsDPSetTile(G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, (G_TX_WRAP | G_TX_MIRROR), 3, G_TX_NOLOD, (G_TX_WRAP | G_TX_MIRROR), 4, G_TX_NOLOD), + gsDPSetTile(G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 3, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD), gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, ((((16 * 8) + G_IM_SIZ_4b_INCR) >> G_IM_SIZ_4b_SHIFT) - 1), CALC_DXT(16, G_IM_SIZ_4b_BYTES)), - gsDPSetTile(G_IM_FMT_IA, G_IM_SIZ_4b, 1, 0, G_TX_RENDERTILE, 0, (G_TX_WRAP | G_TX_MIRROR), 3, G_TX_NOLOD, (G_TX_WRAP | G_TX_MIRROR), 4, G_TX_NOLOD), - gsDPSetTileSize(0, 0, 0, ((16 - 1) << G_TEXTURE_IMAGE_FRAC), ((8 - 1) << G_TEXTURE_IMAGE_FRAC)), + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, ((16 * 8 + G_IM_SIZ_4b_INCR) >> G_IM_SIZ_4b_SHIFT) - 1, CALC_DXT(16, G_IM_SIZ_4b_BYTES)), + gsDPSetTile(G_IM_FMT_IA, G_IM_SIZ_4b, 1, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 3, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD), + gsDPSetTileSize(0, 0, 0, (16 - 1) << G_TEXTURE_IMAGE_FRAC, (8 - 1) << G_TEXTURE_IMAGE_FRAC), gsSPVertex(vertex_ia8_char, 4, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPEndDisplayList(), From 325ee7c5eceea2e8a92b1e5103ff72db0095c055 Mon Sep 17 00:00:00 2001 From: Gregory Heskett Date: Sat, 27 Jan 2024 00:20:35 -0500 Subject: [PATCH 11/12] Fix rumble Issues (#756) * Missed important use of thread6 stack define * Fix build issues with rumble --- bin/title_screen_bg.c | 3 ++- include/config/config_game.h | 2 +- levels/intro/geo.c | 4 ++-- src/game/rumble_init.c | 2 +- src/menu/intro_geo.c | 4 ++-- src/menu/intro_geo.h | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/title_screen_bg.c b/bin/title_screen_bg.c index 476ddb75..c0108aea 100644 --- a/bin/title_screen_bg.c +++ b/bin/title_screen_bg.c @@ -143,7 +143,8 @@ const Gfx title_screen_bg_dl_face_easter_egg_end[] = { }; #endif -#if defined(VERSION_SH) +// Not part of segment2, but define still covers same use case +#if (defined(COMPLETE_EN_US_SEGMENT2) && ENABLE_RUMBLE) ALIGNED8 static const Texture title_texture_rumble_pak[] = { #include "textures/title_screen_bg/title_screen_bg.06648.rgba16.inc.c" }; diff --git a/include/config/config_game.h b/include/config/config_game.h index 387c4bdd..ede580bf 100644 --- a/include/config/config_game.h +++ b/include/config/config_game.h @@ -71,7 +71,7 @@ // #define DIALOG_INDICATOR /** - * Include the English characters that were missing from US segment2 + * Include the English characters that were missing from US segment2 and the rumble pak texture if using rumble. * J, Q, V, X, Z, ¨, !, !!, ?, &, %, ., and the beta key. * [MAKE SURE TO INCLUDE EU AND JP/SH BASEROMS IN THE REPO TO OBTAIN THE ASSETS] * If this is disabled, backup assets will be used. diff --git a/levels/intro/geo.c b/levels/intro/geo.c index 0285b524..58b3cdd3 100644 --- a/levels/intro/geo.c +++ b/levels/intro/geo.c @@ -75,7 +75,7 @@ const GeoLayout intro_geo_mario_head_regular[] = { GEO_CLOSE_NODE(), GEO_CLOSE_NODE(), #endif -#ifdef ENABLE_RUMBLE +#if (defined(COMPLETE_EN_US_SEGMENT2) && ENABLE_RUMBLE) GEO_ZBUFFER(0), GEO_OPEN_NODE(), GEO_ASM(INTRO_CONTEXT_NORMAL, geo_intro_rumble_pak_graphic), @@ -111,7 +111,7 @@ const GeoLayout intro_geo_mario_head_dizzy[] = { GEO_CLOSE_NODE(), GEO_CLOSE_NODE(), #endif -#ifdef ENABLE_RUMBLE +#if (defined(COMPLETE_EN_US_SEGMENT2) && ENABLE_RUMBLE) GEO_ZBUFFER(0), GEO_OPEN_NODE(), GEO_ASM(INTRO_CONTEXT_GAME_OVER, geo_intro_rumble_pak_graphic), diff --git a/src/game/rumble_init.c b/src/game/rumble_init.c index 2ebf75d0..133b1b00 100644 --- a/src/game/rumble_init.c +++ b/src/game/rumble_init.c @@ -261,7 +261,7 @@ void cancel_rumble(void) { void create_thread_6(void) { osCreateMesgQueue(&gRumbleThreadVIMesgQueue, gRumbleThreadVIMesgBuf, 1); - osCreateThread(&gRumblePakThread, THREAD_6_RUMBLE, thread6_rumble_loop, NULL, gThread6Stack + 0x400, 30); + osCreateThread(&gRumblePakThread, THREAD_6_RUMBLE, thread6_rumble_loop, NULL, gThread6Stack + THREAD6_STACK, 30); osStartThread(&gRumblePakThread); } diff --git a/src/menu/intro_geo.c b/src/menu/intro_geo.c index 89d77e65..2b616f84 100644 --- a/src/menu/intro_geo.c +++ b/src/menu/intro_geo.c @@ -263,7 +263,7 @@ Gfx *geo_intro_gameover_backdrop(s32 callContext, struct GraphNode *node, UNUSED return dl; } -#if defined(VERSION_SH) +#if (defined(COMPLETE_EN_US_SEGMENT2) && ENABLE_RUMBLE) extern Gfx title_screen_bg_dl_rumble_pak[]; #endif #ifdef GODDARD_EASTER_EGG @@ -405,7 +405,7 @@ Gfx *geo_intro_face_easter_egg(s32 callContext, struct GraphNode *node, UNUSED v } #endif -#if defined(VERSION_SH) +#if (defined(COMPLETE_EN_US_SEGMENT2) && ENABLE_RUMBLE) Gfx *geo_intro_rumble_pak_graphic(s32 callContext, struct GraphNode *node, UNUSED void *context) { struct GraphNodeGenerated *genNode = (struct GraphNodeGenerated *)node; Gfx *dlIter; diff --git a/src/menu/intro_geo.h b/src/menu/intro_geo.h index eb534d5c..5e17323b 100644 --- a/src/menu/intro_geo.h +++ b/src/menu/intro_geo.h @@ -20,7 +20,7 @@ Gfx *geo_intro_gameover_backdrop(s32 callContext, struct GraphNode *node, UNUSED #ifdef GODDARD_EASTER_EGG Gfx *geo_intro_face_easter_egg(s32 callContext, struct GraphNode *node, UNUSED void *context); #endif -#if ENABLE_RUMBLE +#if (defined(COMPLETE_EN_US_SEGMENT2) && ENABLE_RUMBLE) Gfx *geo_intro_rumble_pak_graphic(s32 callContext, struct GraphNode *node, UNUSED void *context); #endif From 9cf3753d6e4b8ae4cc671082ae754447caa3a5aa Mon Sep 17 00:00:00 2001 From: Gregory Heskett Date: Sun, 21 Jan 2024 13:54:40 -0500 Subject: [PATCH 12/12] Update version to 2.1.3 (#754) --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 59696826..535b2f4d 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -v2.1.2 +v2.1.3