From 164650b82acc62e47fede23fd53e6efb57e88442 Mon Sep 17 00:00:00 2001 From: Fazana <52551480+FazanaJ@users.noreply.github.com> Date: Wed, 22 Sep 2021 17:33:34 +0100 Subject: [PATCH] Vanilla ending credits bugfixes The black border's a bit hacky because I don't remember where the original game did it lol, so ideally write over it with the original implementation if possible. --- src/game/camera.c | 62 ------------------------------- src/game/ingame_menu.c | 15 +++++++- src/game/level_update.c | 4 ++ src/game/mario_actions_cutscene.c | 42 +++++---------------- src/game/mario_actions_cutscene.h | 2 + src/game/rendering_graph_node.c | 15 +++++++- 6 files changed, 42 insertions(+), 98 deletions(-) diff --git a/src/game/camera.c b/src/game/camera.c index 19dffee6..930644b2 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -3725,18 +3725,6 @@ s32 move_point_along_spline(Vec3f p, struct CutsceneSplinePoint spline[], s16 *s } progressChange = (secondSpeed - firstSpeed) * *progress + firstSpeed; -#ifdef VERSION_EU - if (gCamera->cutscene == CUTSCENE_INTRO_PEACH) { - progressChange += progressChange * 0.19f; - } - if (gCamera->cutscene == CUTSCENE_CREDITS) { - progressChange += progressChange * 0.15f; - } - if (gCamera->cutscene == CUTSCENE_ENDING) { - progressChange += progressChange * 0.1f; - } -#endif - if (1 <= (*progress += progressChange)) { (*splineSegment)++; if (spline[*splineSegment + 3].index == -1) { @@ -6490,15 +6478,6 @@ struct CutsceneSplinePoint sIntroPipeToDialogPosition[] = { /** * Describes the spline that the camera's focus follows, during the same part of the intro as the above. */ -#ifdef VERSION_EU -struct CutsceneSplinePoint sIntroPipeToDialogFocus[] = { - { 0, 25, { -1248, 450, 4596 } }, { 1, 71, { -1258, 485, 4606 } }, { 2, 71, { -1379, 344, 4769 } }, - { 3, 22, { -1335, 366, 4815 } }, { 4, 23, { -1315, 370, 4450 } }, { 5, 40, { -1322, 333, 4591 } }, - { 6, 25, { -1185, 329, 4616 } }, { 7, 21, { -1059, 380, 4487 } }, { 8, 14, { -1086, 421, 4206 } }, - { 9, 21, { -1321, 346, 4098 } }, { 0, 0, { -1328, 385, 4354 } }, { 0, 0, { -1328, 385, 4354 } }, - { 0, 0, { -1328, 385, 4354 } }, { -1, 0, { -1328, 385, 4354 } } -}; -#else struct CutsceneSplinePoint sIntroPipeToDialogFocus[] = { { 0, 20, { -1248, 450, 4596 } }, { 1, 59, { -1258, 485, 4606 } }, { 2, 59, { -1379, 344, 4769 } }, { 3, 20, { -1335, 366, 4815 } }, { 4, 23, { -1315, 370, 4450 } }, { 5, 40, { -1322, 333, 4591 } }, @@ -6506,7 +6485,6 @@ struct CutsceneSplinePoint sIntroPipeToDialogFocus[] = { { 9, 21, { -1321, 346, 4098 } }, { 0, 0, { -1328, 385, 4354 } }, { 0, 0, { -1328, 385, 4354 } }, { 0, 0, { -1328, 385, 4354 } }, { -1, 0, { -1328, 385, 4354 } } }; -#endif struct CutsceneSplinePoint sEndingFlyToWindowPos[] = { { 0, 0, { -86, 876, 640 } }, { 1, 0, { -86, 876, 610 } }, { 2, 0, { -66, 945, 393 } }, @@ -6551,11 +6529,7 @@ struct CutsceneSplinePoint sEndingLookUpAtCastle[] = { }; struct CutsceneSplinePoint sEndingLookAtSkyFocus[] = { -#ifdef VERSION_EU - { 0, 50, { 484, 1368, -868 } }, { 0, 72, { 479, 1372, -872 } }, { 0, 50, { 351, 1817, -918 } }, -#else { 0, 50, { 484, 1368, -888 } }, { 0, 72, { 479, 1372, -892 } }, { 0, 50, { 351, 1817, -918 } }, -#endif { 0, 50, { 351, 1922, -598 } }, { 0, 0, { 636, 2027, -415 } }, { 0, 0, { 636, 2027, -415 } }, { -1, 0, { 636, 2027, -415 } } }; @@ -7448,15 +7422,9 @@ BAD_RETURN(s32) cutscene_ending_look_up_at_castle(UNUSED struct Camera *c) { BAD_RETURN(s32) cutscene_ending_peach_wakeup(struct Camera *c) { cutscene_event(cutscene_ending_reset_spline, c, 0, 0); cutscene_event(cutscene_ending_look_up_at_castle, c, 0, 0); -#ifdef VERSION_EU - cutscene_event(cutscene_ending_look_up_at_castle, c, 265, -1); - cutscene_spawn_obj(7, 315); - cutscene_spawn_obj(9, 355); -#else cutscene_event(cutscene_ending_look_up_at_castle, c, 250, -1); cutscene_spawn_obj(7, 300); cutscene_spawn_obj(9, 340); -#endif vec3f_set(c->pos, -163.f, 978.f, -1082.f); player2_rotate_cam(c, -0x800, 0x2000, -0x2000, 0x2000); } @@ -7498,11 +7466,7 @@ BAD_RETURN(s32) cutscene_ending_kiss_here_we_go(struct Camera *c) { */ BAD_RETURN(s32) cutscene_ending_kiss(struct Camera *c) { cutscene_event(cutscene_ending_kiss_closeup, c, 0, 0); -#ifdef VERSION_EU - cutscene_event(cutscene_ending_kiss_here_we_go, c, 185, -1); -#else cutscene_event(cutscene_ending_kiss_here_we_go, c, 155, -1); -#endif player2_rotate_cam(c, -0x800, 0x2000, -0x2000, 0x2000); } @@ -9667,19 +9631,11 @@ BAD_RETURN(s32) play_sound_intro_turn_on_hud(UNUSED struct Camera *c) { * Fly to the pipe. Near the end, the camera jumps to Lakitu's position and the hud turns on. */ BAD_RETURN(s32) cutscene_intro_peach_fly_to_pipe(struct Camera *c) { -#if defined(VERSION_US) || defined(VERSION_SH) cutscene_event(play_sound_intro_turn_on_hud, c, 818, 818); -#elif defined(VERSION_EU) - cutscene_event(play_sound_intro_turn_on_hud, c, 673, 673); -#endif cutscene_spawn_obj(6, 1); cutscene_event(cutscene_intro_peach_start_flying_music, c, 0, 0); cutscene_event(cutscene_intro_peach_start_to_pipe_spline, c, 0, -1); -#ifdef VERSION_EU - cutscene_event(cutscene_intro_peach_clear_cutscene_status, c, 572, 572); -#else cutscene_event(cutscene_intro_peach_clear_cutscene_status, c, 717, 717); -#endif clamp_pitch(c->pos, c->focus, 0x3B00, -0x3B00); sCutsceneVars[1].point[1] = 400.f; } @@ -9721,9 +9677,6 @@ BAD_RETURN(s32) cutscene_intro_peach_letter(struct Camera *c) { cutscene_spawn_obj(5, 0); cutscene_event(cutscene_intro_peach_zoom_fov, c, 0, 0); cutscene_event(cutscene_intro_peach_start_letter_music, c, 65, 65); -#ifdef VERSION_EU - cutscene_event(cutscene_intro_peach_eu_lower_volume, c, 68, 68); -#endif cutscene_event(cutscene_intro_peach_start_to_pipe_spline, c, 0, 0); cutscene_event(peach_letter_text, c, 65, 65); #ifndef VERSION_JP @@ -10437,16 +10390,6 @@ BAD_RETURN(s32) cutscene_door_mode(struct Camera *c) { struct Cutscene sCutsceneEnding[] = { { cutscene_ending_mario_fall, 170 }, { cutscene_ending_mario_land, 70 }, -#ifdef VERSION_EU - { cutscene_ending_mario_land_closeup, 0x44 }, - { cutscene_ending_stars_free_peach, 0x15c }, - { cutscene_ending_peach_appears, 0x6d }, - { cutscene_ending_peach_descends, 0x212 }, - { cutscene_ending_mario_to_peach, 0x69 }, - { cutscene_ending_peach_wakeup, 0x1a4 }, - { cutscene_ending_dialog, 0x114 }, - { cutscene_ending_kiss, 0x10b }, -#else { cutscene_ending_mario_land_closeup, 75 }, #ifdef VERSION_SH { cutscene_ending_stars_free_peach, 431 }, @@ -10464,7 +10407,6 @@ struct Cutscene sCutsceneEnding[] = { { cutscene_ending_dialog, 236 }, #endif { cutscene_ending_kiss, 245 }, -#endif { cutscene_ending_cake_for_mario, CUTSCENE_LOOP }, { cutscene_ending_stop, 0 } }; @@ -10608,11 +10550,7 @@ struct Cutscene sCutsceneUnusedExit[] = { struct Cutscene sCutsceneIntroPeach[] = { { cutscene_intro_peach_letter, CUTSCENE_LOOP }, { cutscene_intro_peach_reset_fov, 35 }, -#ifdef VERSION_EU - { cutscene_intro_peach_fly_to_pipe, 675 }, -#else { cutscene_intro_peach_fly_to_pipe, 820 }, -#endif { cutscene_intro_peach_mario_appears, 270 }, { cutscene_intro_peach_dialog, CUTSCENE_LOOP } }; diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index ff23c907..0292ebf7 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -1369,13 +1369,24 @@ void set_cutscene_message(s16 xOffset, s16 yOffset, s16 msgIndex, s16 msgDuratio void do_cutscene_handler(void) { s16 x; + create_dl_ortho_matrix(); + + if (gMarioState->action == ACT_CREDITS_CUTSCENE || gMarioState->action == ACT_END_PEACH_CUTSCENE || gMarioState->action == ACT_END_WAVING_CUTSCENE) + { + gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); + gDPSetCycleType(gDisplayListHead++, G_CYC_FILL); + + gDPSetFillColor(gDisplayListHead++, GPACK_RGBA5551(0, 0, 0, 0) << 16 | GPACK_RGBA5551(0, 0, 0, 0)); + gDPFillRectangle(gDisplayListHead++, GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(0), 0, GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(0) - 1, 32 - 1); + gDPFillRectangle(gDisplayListHead++, GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(0), SCREEN_HEIGHT - 32, GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(0) - 1, SCREEN_HEIGHT - 1); + gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE); + } + // is a cutscene playing? do not perform this handler's actions if so. if (gCutsceneMsgIndex == -1) { return; } - create_dl_ortho_matrix(); - gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gCutsceneMsgFade); diff --git a/src/game/level_update.c b/src/game/level_update.c index 91253bb7..d449c5b8 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -500,6 +500,10 @@ void warp_credits(void) { break; case WARP_NODE_CREDITS_NEXT: + sEndCutsceneVp.vp.vscale[0] = 640; + sEndCutsceneVp.vp.vscale[1] = 360; + sEndCutsceneVp.vp.vtrans[0] = 640; + sEndCutsceneVp.vp.vtrans[1] = 480; marioAction = ACT_CREDITS_CUTSCENE; break; diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index d4f2775f..76fb96f3 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -38,8 +38,8 @@ static UNUSED s32 sUnused; static s16 sEndPeachAnimation; static s16 sEndToadAnims[2]; -static Vp sEndCutsceneVp = { { { 640, 480, 511, 0 }, { 640, 480, 511, 0 } } }; -static struct CreditsEntry *sDispCreditsEntry = NULL; +Vp sEndCutsceneVp = { { { 640, 480, 511, 0 }, { 640, 480, 511, 0 } } }; +struct CreditsEntry *sDispCreditsEntry = NULL; // related to peach gfx? static s8 sPeachManualBlinkTime = 0; @@ -1667,11 +1667,7 @@ static void intro_cutscene_hide_hud_and_mario(struct MarioState *m) { advance_cutscene_step(m); } -#ifdef VERSION_EU - #define TIMER_SPAWN_PIPE 47 -#else - #define TIMER_SPAWN_PIPE 37 -#endif +#define TIMER_SPAWN_PIPE 37 static void intro_cutscene_peach_lakitu_scene(struct MarioState *m) { if ((s16) m->statusForCamera->cameraEvent != CAM_EVENT_START_INTRO) { @@ -1685,11 +1681,7 @@ static void intro_cutscene_peach_lakitu_scene(struct MarioState *m) { } #undef TIMER_SPAWN_PIPE -#ifdef VERSION_EU - #define TIMER_RAISE_PIPE 28 -#else - #define TIMER_RAISE_PIPE 38 -#endif +#define TIMER_RAISE_PIPE 38 static void intro_cutscene_raise_pipe(struct MarioState *m) { sIntroWarpPipeObj->oPosY = camera_approach_f32_symmetric(sIntroWarpPipeObj->oPosY, 260.0f, 10.0f); @@ -2049,10 +2041,7 @@ static void end_peach_cutscene_summon_jumbo_star(struct MarioState *m) { play_sound(SOUND_AIR_PEACH_TWINKLE, sEndJumboStarObj->header.gfx.cameraToObject); } -#if defined(VERSION_EU) - #define TIMER_FADE_IN_PEACH 201 - #define TIMER_DESCEND_PEACH 280 -#elif defined(VERSION_SH) +#if defined(VERSION_SH) #define TIMER_FADE_IN_PEACH 276 #define TIMER_DESCEND_PEACH 400 #else @@ -2111,11 +2100,7 @@ static void end_peach_cutscene_spawn_peach(struct MarioState *m) { } } -#ifdef VERSION_EU - #define TIMER_RUN_TO_PEACH 531 -#else - #define TIMER_RUN_TO_PEACH 584 -#endif +#define TIMER_RUN_TO_PEACH 584 // descend peach static void end_peach_cutscene_descend_peach(struct MarioState *m) { @@ -2192,7 +2177,7 @@ static void end_peach_cutscene_dialog_1(struct MarioState *m) { #endif sEndPeachAnimation = 6; break; - + #ifdef VERSION_SH case 111: #else @@ -2260,10 +2245,7 @@ static void end_peach_cutscene_dialog_1(struct MarioState *m) { } } -#if defined(VERSION_EU) - #define TIMER_SOMETHING_SPECIAL 150 - #define TIMER_PEACH_KISS 260 -#elif defined(VERSION_SH) +#if defined(VERSION_SH) #define TIMER_SOMETHING_SPECIAL 170 #define TIMER_PEACH_KISS 250 #else @@ -2292,7 +2274,7 @@ static void end_peach_cutscene_dialog_2(struct MarioState *m) { #ifdef VERSION_SH case 65: -#else +#else case 45: #endif sPeachIsBlinking = 1; @@ -2564,11 +2546,7 @@ static s32 act_end_peach_cutscene(struct MarioState *m) { return FALSE; } -#if defined(VERSION_EU) - #define TIMER_CREDITS_SHOW 51 - #define TIMER_CREDITS_PROGRESS 80 - #define TIMER_CREDITS_WARP 160 -#elif defined(VERSION_SH) +#if defined(VERSION_SH) #define TIMER_CREDITS_SHOW 61 #define TIMER_CREDITS_PROGRESS 90 #define TIMER_CREDITS_WARP 204 diff --git a/src/game/mario_actions_cutscene.h b/src/game/mario_actions_cutscene.h index ff42031d..75a62929 100644 --- a/src/game/mario_actions_cutscene.h +++ b/src/game/mario_actions_cutscene.h @@ -24,5 +24,7 @@ Gfx *geo_switch_peach_eyes(s32 callContext, struct GraphNode *node, UNUSED s32 c s32 mario_ready_to_speak(void); s32 set_mario_npc_dialog(s32 actionArg); s32 mario_execute_cutscene_action(struct MarioState *m); +extern Vp sEndCutsceneVp; +extern struct CreditsEntry *sDispCreditsEntry; #endif // MARIO_ACTIONS_CUTSCENE_H diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index 253ea0d4..5e707191 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -14,6 +14,7 @@ #include "engine/extended_bounds.h" #include "puppyprint.h" #include "debug_box.h" +#include "level_update.h" #include "config.h" @@ -226,6 +227,14 @@ LookAt lookAt; u8 ucodeTestSwitch = 1; +void reset_clipping(void) +{ + if (gMarioState->action == ACT_CREDITS_CUTSCENE) + make_viewport_clip_rect(&sEndCutsceneVp); + else + gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, gBorderHeight, SCREEN_WIDTH, SCREEN_HEIGHT - gBorderHeight); +} + /** * Process a master list node. This has been modified, so now it runs twice, for each microcode. It iterates through the first 5 layers of if the first index using F3DLX2.Rej, then it switches @@ -236,8 +245,8 @@ u8 ucodeTestSwitch = 1; static void geo_process_master_list_sub(struct GraphNodeMasterList *node) { struct DisplayListNode *currList; s32 startLayer, endLayer, currLayer = LAYER_FORCE; - s32 headsIndex = 1; - s32 renderPhase = 0; + s32 headsIndex = LIST_HEADS_REJ; + s32 renderPhase = RENDER_PHASE_REJ_ZB; s32 enableZBuffer = (node->node.flags & GRAPH_RENDER_Z_BUFFER) != 0; struct RenderModeContainer *mode1List = &renderModeTable_1Cycle[enableZBuffer]; struct RenderModeContainer *mode2List = &renderModeTable_2Cycle[enableZBuffer]; @@ -283,6 +292,7 @@ static void geo_process_master_list_sub(struct GraphNodeMasterList *node) { gSPClipRatio(gDisplayListHead++, FRUSTRATIO_1); } gSPLookAt(gDisplayListHead++, &lookAt); + reset_clipping(); #endif if (enableZBuffer) { gDPPipeSync(gDisplayListHead++); @@ -324,6 +334,7 @@ static void geo_process_master_list_sub(struct GraphNodeMasterList *node) { gSPLoadUcodeL(gDisplayListHead++, gspF3DZEX2_PosLight_fifo); init_rcp(KEEP_ZBUFFER); gSPClipRatio(gDisplayListHead++, FRUSTRATIO_1); + reset_clipping(); #endif #ifdef VISUAL_DEBUG