Merge pull request #757 from HackerN64/master

Merge HackerSM64 2.1.3 release into 2.2.0
This commit is contained in:
Gregory Heskett
2024-01-31 01:23:18 -05:00
committed by GitHub
25 changed files with 94 additions and 58 deletions

View File

@@ -444,9 +444,18 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, u32 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);
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);

View File

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

View File

@@ -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"
@@ -430,6 +431,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);
@@ -442,6 +444,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);
}
@@ -455,6 +458,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.

View File

@@ -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;

View File

@@ -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) {

View File

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

View File

@@ -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); \

View File

@@ -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;

View File

@@ -381,10 +381,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:
@@ -393,9 +391,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;

View File

@@ -220,7 +220,7 @@ static struct RenderPhase sRenderPhases[] = {
},
[RENDER_PHASE_ZEX_AFTER_SILHOUETTE] = {
.startLayer = LAYER_OCCLUDE_SILHOUETTE_FIRST,
.startLayer = LAYER_NON_ZB_FIRST,
.endLayer = LAYER_LAST,
},
#else

View File

@@ -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);
}

View File

@@ -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) {
Gfx *tempGfxHead = gDisplayListHead;
@@ -261,29 +260,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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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