diff --git a/data/dynos_warps.cpp b/data/dynos_warps.cpp index 046299478..ec63e2899 100644 --- a/data/dynos_warps.cpp +++ b/data/dynos_warps.cpp @@ -312,8 +312,10 @@ static void *DynOS_Warp_UpdateWarp(void *aCmd, bool aIsLevelInitDone) { #endif // Init transition - reset_camera(gCurrentArea->camera); - init_camera(gCurrentArea->camera); + if (gCurrentArea != NULL) { + reset_camera(gCurrentArea->camera); + init_camera(gCurrentArea->camera); + } sDelayedWarpOp = WARP_OP_NONE; switch (sDynosWarpSpawnType) { case MARIO_SPAWN_UNKNOWN_03: play_transition(WARP_TRANSITION_FADE_FROM_STAR, 0x10, 0x00, 0x00, 0x00); break; @@ -327,7 +329,9 @@ static void *DynOS_Warp_UpdateWarp(void *aCmd, bool aIsLevelInitDone) { // Set music if (sWarpDest.type != WARP_TYPE_SAME_AREA && sWarpDest.type != WARP_TYPE_NOT_WARPING) { - set_background_music(gCurrentArea->musicParam, gCurrentArea->musicParam2, 0); + if (gCurrentArea != NULL) { + set_background_music(gCurrentArea->musicParam, gCurrentArea->musicParam2, 0); + } if (gMarioState->flags & MARIO_METAL_CAP) play_cap_music(SEQUENCE_ARGS(4, SEQ_EVENT_METAL_CAP)); if (gMarioState->flags & MARIO_VANISH_CAP) play_cap_music(SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)); if (gMarioState->flags & MARIO_WING_CAP) play_cap_music(SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)); diff --git a/src/engine/level_script.c b/src/engine/level_script.c index a8c5c28dc..edbd932b0 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -29,6 +29,7 @@ #include "src/pc/lua/smlua.h" #include "src/pc/djui/djui.h" #include "game/hardcoded.h" +#include "menu/intro_geo.h" #define CMD_GET(type, offset) (*(type *) (CMD_PROCESS_OFFSET(offset) + (u8 *) sCurrentCmd)) @@ -332,6 +333,8 @@ static void level_cmd_load_mio0(void) { } static void level_cmd_load_mario_head(void) { + gSkipInterpolationTitleScreen = true; + gGlobalTimer = 0; // TODO: Fix these hardcoded sizes void *addr = main_pool_alloc(DOUBLE_SIZE_ON_64_BIT(0xE1000), MEMORY_POOL_LEFT); if (addr != NULL) { @@ -357,6 +360,7 @@ static void level_cmd_init_level(void) { clear_areas(); main_pool_push_state(); smlua_model_util_clear(); + gSkipInterpolationTitleScreen = false; sCurrentCmd = CMD_NEXT; } diff --git a/src/game/interaction.c b/src/game/interaction.c index cf6d375ce..1126ea299 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -2183,6 +2183,8 @@ void check_kick_or_punch_wall(struct MarioState *m) { } void mario_process_interactions(struct MarioState *m) { + if (gDjuiInMainMenu) { return; } + sDelayInvincTimer = FALSE; sInvulnerable = (m->action & ACT_FLAG_INVULNERABLE) || m->invincTimer != 0; diff --git a/src/game/level_update.c b/src/game/level_update.c index 5980ab84a..b6b6b721b 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -34,6 +34,7 @@ #include "../../include/libc/stdlib.h" #include "rumble_init.h" #include "game/interaction.h" +#include "menu/intro_geo.h" #include "pc/pc_main.h" #include "pc/cliopts.h" @@ -826,7 +827,13 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) { case WARP_OP_DEMO_NEXT: case WARP_OP_DEMO_END: sDelayedWarpTimer = 20; // Must be one line to match on -O2 val04 = FALSE; - stop_demo(NULL); + if (!gDjuiInMainMenu) { + sSourceWarpNodeId = WARP_NODE_F0; + gSavedCourseNum = COURSE_NONE; + play_transition(WARP_TRANSITION_FADE_INTO_STAR, 0x14, 0x00, 0x00, 0x00); + } else { + stop_demo(NULL); + } break; case WARP_OP_CREDITS_END: @@ -974,6 +981,9 @@ void initiate_delayed_warp(void) { break; case WARP_OP_DEMO_NEXT: + if (!gDjuiInMainMenu) { + warp_special(-2); + } break; case WARP_OP_CREDITS_START: @@ -1180,16 +1190,30 @@ void stop_demo(UNUSED struct DjuiBase* caller) { int gPressedStart = 0; s32 play_mode_normal(void) { - if (gDjuiInMainMenu && gCurrDemoInput == NULL && configMenuDemos && !inPlayerMenu) { - find_demo_number(); - if ((++gDemoCountdown) == PRESS_START_DEMO_TIMER && (demoNumber <= 6 || demoNumber > -1)) { - start_demo(); + if (!gDjuiInMainMenu) { + if (gCurrDemoInput != NULL) { + print_intro_text(); + if (gPlayer1Controller->buttonPressed & END_DEMO) { + level_trigger_warp(gMarioState, + gCurrLevelNum == LEVEL_PSS ? WARP_OP_DEMO_END : WARP_OP_DEMO_NEXT); + } else if (!gWarpTransition.isActive && sDelayedWarpOp == WARP_OP_NONE + && (gPlayer1Controller->buttonPressed & START_BUTTON)) { + gPressedStart = 1; + level_trigger_warp(gMarioState, WARP_OP_DEMO_NEXT); + } + } + } else { + if (gDjuiInMainMenu && gCurrDemoInput == NULL && configMenuDemos && !inPlayerMenu) { + find_demo_number(); + if ((++gDemoCountdown) == PRESS_START_DEMO_TIMER && (demoNumber <= 6 || demoNumber > -1)) { + start_demo(); + } } - } - if (((gCurrDemoInput != NULL) && (gPlayer1Controller->buttonPressed & END_DEMO || !isDemoActive || !gDjuiInMainMenu || gNetworkType != NT_NONE || inPlayerMenu)) || (gCurrDemoInput == NULL && isDemoActive)) { - gPlayer1Controller->buttonPressed &= ~END_DEMO; - stop_demo(NULL); + if (((gCurrDemoInput != NULL) && (gPlayer1Controller->buttonPressed & END_DEMO || !isDemoActive || !gDjuiInMainMenu || gNetworkType != NT_NONE || inPlayerMenu)) || (gCurrDemoInput == NULL && isDemoActive)) { + gPlayer1Controller->buttonPressed &= ~END_DEMO; + stop_demo(NULL); + } } warp_area(); diff --git a/src/menu/intro_geo.c b/src/menu/intro_geo.c index 634d4877e..1657ffc13 100644 --- a/src/menu/intro_geo.c +++ b/src/menu/intro_geo.c @@ -63,7 +63,7 @@ static Gfx *sIntroScalePos; static Vec3f sIntroScale; static Vec3f sIntroScalePrev; -bool skipInterpolationTitleScreen = false; +bool gSkipInterpolationTitleScreen = false; void patch_title_screen_before(void) { sIntroScalePos = NULL; diff --git a/src/menu/intro_geo.h b/src/menu/intro_geo.h index 291ef83b5..27cb44256 100644 --- a/src/menu/intro_geo.h +++ b/src/menu/intro_geo.h @@ -7,7 +7,7 @@ #include "types.h" #include "engine/graph_node.h" -extern bool skipInterpolationTitleScreen; +extern bool gSkipInterpolationTitleScreen; Gfx *geo_intro_super_mario_64_logo(s32 sp50, struct GraphNode *sp54, UNUSED void *context); Gfx *geo_intro_tm_copyright(s32 sp40, struct GraphNode *sp44, UNUSED void *context); diff --git a/src/menu/level_select_menu.c b/src/menu/level_select_menu.c index 53857160d..c4182e969 100644 --- a/src/menu/level_select_menu.c +++ b/src/menu/level_select_menu.c @@ -248,13 +248,6 @@ s32 lvl_intro_update(s16 arg1, UNUSED s32 arg2) { case 3: retVar = level_select_input_loop(); break; - case 4: - gGlobalTimer = 0; - skipInterpolationTitleScreen = true; - break; - case 5: - skipInterpolationTitleScreen = false; - break; } return retVar; } diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 026b15877..49ed0b3b8 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -20,6 +20,8 @@ #include "pc/crash_handler.h" #include "pc/debuglog.h" #include "game/camera.h" +#include "game/object_helpers.h" +#include "menu/intro_geo.h" // fix warnings when including rendering_graph_node #undef near @@ -512,6 +514,9 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup) { smlua_shutdown(); extern s16 gChangeLevel; gChangeLevel = LEVEL_CASTLE_GROUNDS; + if (gSkipInterpolationTitleScreen || find_object_with_behavior(bhvActSelector) != NULL) { + dynos_warp_to_level(LEVEL_CASTLE_GROUNDS, 1, 0); + } network_player_init(); camera_set_use_course_specific_settings(true); free_vtx_scroll_targets(); diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index bcb3e5d77..2c0b4c304 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -174,7 +174,7 @@ void produce_interpolation_frames_and_delay(void) { gfx_start_frame(); f32 delta = MIN((curTime - sFrameTimeStart) / (sFrameTargetTime - sFrameTimeStart), 1); gRenderingDelta = delta; - if (!skipInterpolationTitleScreen || configFrameLimit > 30) { patch_interpolations(delta); } + if (!gSkipInterpolationTitleScreen && configFrameLimit > 30) { patch_interpolations(delta); } send_display_list(gGfxSPTask); gfx_end_frame();