Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.1.2
v2.1.3
12 changes: 6 additions & 6 deletions bin/segment2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand All @@ -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(),
Expand Down
3 changes: 2 additions & 1 deletion bin/title_screen_bg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
Expand Down
9 changes: 9 additions & 0 deletions include/config/config_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion include/config/config_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions include/config/config_graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 16 additions & 3 deletions include/config/config_safeguards.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -110,6 +115,9 @@

#undef COMPLETE_SAVE_FILE
#define COMPLETE_SAVE_FILE

#undef DEBUG_ASSERTIONS
#define DEBUG_ASSERTIONS
#endif // DEBUG_ALL

#ifdef PUPPYPRINT_DEBUG
Expand All @@ -124,6 +132,11 @@
#define UNLOCK_ALL
#endif // COMPLETE_SAVE_FILE

#ifdef DEBUG
#undef DEBUG_ASSERTIONS
#define DEBUG_ASSERTIONS
#endif // DEBUG


/*****************
* config_camera.h
Expand Down
2 changes: 2 additions & 0 deletions include/geo_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions levels/intro/geo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
9 changes: 9 additions & 0 deletions src/audio/synthesis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/engine/geo_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "math_util.h"
#include "game/memory.h"
#include "graph_node.h"
#include "game/debug.h"

typedef void (*GeoLayoutCommandProc)(void);

Expand Down Expand Up @@ -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]]();
}

Expand Down
4 changes: 4 additions & 0 deletions src/engine/level_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions src/game/area.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/game/behaviors/boo.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 7 additions & 3 deletions src/game/crash_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
#ifdef DEBUG_ASSERTIONS
#define assert(cond, message) do {\
if ((cond) == FALSE) { \
error(message); \
Expand Down
10 changes: 5 additions & 5 deletions src/game/ingame_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 1 addition & 6 deletions src/game/level_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/game/rendering_graph_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},

Expand Down
2 changes: 1 addition & 1 deletion src/game/rumble_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading