From 0d05853138dc1a55d5fb04fc6c62905596c2ddd5 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 4 Aug 2021 23:56:33 -0700 Subject: [PATCH] Fix ending cutscene crash and make game playable afterward without rehosting --- levels/ending/script.c | 8 ++++++-- levels/entry.c | 4 +++- src/game/level_update.c | 6 ++++++ src/game/level_update.h | 2 ++ src/game/mario_actions_cutscene.c | 26 ++++++++++++++------------ 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/levels/ending/script.c b/levels/ending/script.c index ad3d7386..023d233f 100644 --- a/levels/ending/script.c +++ b/levels/ending/script.c @@ -32,6 +32,10 @@ const LevelScript level_ending_entry[] = { /*14*/ SLEEP(/*frames*/ 120), /*15*/ CALL(/*arg*/ 0, /*func*/ lvl_play_the_end_screen_sound), // L1: - /*17*/ SLEEP(/*frames*/ 1), - /*18*/ JUMP(level_ending_entry + 17), + /*17*/ //SLEEP(/*frames*/ 1), + /*18*/ //JUMP(level_ending_entry + 17), + SLEEP_BEFORE_EXIT(/*frames*/ 30 * 5), + /*15*/ CALL(/*arg*/ 0, /*func*/ lvl_exiting_credits), + CLEAR_LEVEL(), + EXIT(), }; diff --git a/levels/entry.c b/levels/entry.c index 0f1648ce..5ab06cdf 100644 --- a/levels/entry.c +++ b/levels/entry.c @@ -14,7 +14,9 @@ const LevelScript level_script_entry[] = { SET_REG(/*value*/ LEVEL_CASTLE_GROUNDS), - JUMP(/*target*/ level_main_scripts_entry), + //JUMP(/*target*/ level_main_scripts_entry), + EXECUTE(/*seg*/ 0x14, /*script*/ _introSegmentRomStart, /*scriptEnd*/ _introSegmentRomEnd, /*entry*/ level_main_scripts_entry), + JUMP(level_script_entry), // old behavior (intro) //INIT_LEVEL(), diff --git a/src/game/level_update.c b/src/game/level_update.c index c7d012d8..a1270026 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1437,3 +1437,9 @@ s32 lvl_play_the_end_screen_sound(UNUSED s16 arg0, UNUSED s32 arg1) { play_sound(SOUND_MENU_THANK_YOU_PLAYING_MY_GAME, gDefaultSoundArgs); return 1; } + +s32 lvl_exiting_credits(UNUSED s16 arg0, UNUSED s32 arg1) { + gCurrActStarNum = 0; + gCurrActNum = 0; + return 1; +} diff --git a/src/game/level_update.h b/src/game/level_update.h index 52f5d9a2..b9077bcc 100644 --- a/src/game/level_update.h +++ b/src/game/level_update.h @@ -153,4 +153,6 @@ s32 init_level(void); void star_select_finish_selection(void); +s32 lvl_exiting_credits(UNUSED s16 arg0, UNUSED s32 arg1); + #endif // LEVEL_UPDATE_H diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 7a05a114..08576435 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -2757,28 +2757,30 @@ static s32 act_credits_cutscene(struct MarioState *m) { m->actionState += 2; } - width = m->actionState * 640 / 100; - height = m->actionState * 480 / 100; + if (m->playerIndex == 0) { + width = m->actionState * 640 / 100; + height = m->actionState * 480 / 100; - sEndCutsceneVp.vp.vscale[0] = 640 - width; - sEndCutsceneVp.vp.vscale[1] = 480 - height; - sEndCutsceneVp.vp.vtrans[0] = - (gCurrCreditsEntry->unk02 & 0x10 ? width : -width) * 56 / 100 + 640; - sEndCutsceneVp.vp.vtrans[1] = - (gCurrCreditsEntry->unk02 & 0x20 ? height : -height) * 66 / 100 + 480; + sEndCutsceneVp.vp.vscale[0] = 640 - width; + sEndCutsceneVp.vp.vscale[1] = 480 - height; + sEndCutsceneVp.vp.vtrans[0] = + (gCurrCreditsEntry->unk02 & 0x10 ? width : -width) * 56 / 100 + 640; + sEndCutsceneVp.vp.vtrans[1] = + (gCurrCreditsEntry->unk02 & 0x20 ? height : -height) * 66 / 100 + 480; - override_viewport_and_clip(&sEndCutsceneVp, 0, 0, 0, 0); + override_viewport_and_clip(&sEndCutsceneVp, 0, 0, 0, 0); + } } - if (m->actionTimer == TIMER_CREDITS_PROGRESS) { + if (m->actionTimer == TIMER_CREDITS_PROGRESS && m->playerIndex == 0) { reset_cutscene_msg_fade(); } - if (m->actionTimer >= TIMER_CREDITS_PROGRESS) { + if (m->actionTimer >= TIMER_CREDITS_PROGRESS && m->playerIndex == 0) { sDispCreditsEntry = gCurrCreditsEntry; } - if (m->actionTimer++ == TIMER_CREDITS_WARP) { + if (m->actionTimer++ == TIMER_CREDITS_WARP && m->playerIndex == 0) { level_trigger_warp(m, 24); }