From 8be8848f8561602eac92e0e8c3dbd15fa21c1859 Mon Sep 17 00:00:00 2001 From: fig02 Date: Tue, 30 Jan 2024 18:52:04 -0500 Subject: [PATCH] z_demo retail code matched (#1655) * match all functions * format * clarify between 'dest' and 'skip' debug features * format * better match for CutsceneHandler_RunScript * review * format * remove macro --- include/z64save.h | 2 +- src/code/z_demo.c | 55 +++++++++++-------- .../actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c | 4 +- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index 9ffc2c1f23..03ae2d1475 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -438,7 +438,7 @@ typedef enum { #define EVENTCHKINF_4C 0x4C #define EVENTCHKINF_4D 0x4D #define EVENTCHKINF_4E 0x4E -#define EVENTCHKINF_4F 0x4F +#define EVENTCHKINF_WATCHED_SHEIK_AFTER_MASTER_SWORD_CS 0x4F // Cutscene in Temple of Time as adult after pulling the Master Sword for the first time #define EVENTCHKINF_50 0x50 #define EVENTCHKINF_51 0x51 #define EVENTCHKINF_52 0x52 diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 95c15ea705..97833dd22b 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -130,6 +130,7 @@ s16 sQuakeIndex; void Cutscene_SetupScripted(PlayState* play, CutsceneContext* csCtx); +#if OOT_DEBUG void Cutscene_DrawDebugInfo(PlayState* play, Gfx** dlist, CutsceneContext* csCtx) { GfxPrint printer; s32 pad[2]; @@ -149,6 +150,7 @@ void Cutscene_DrawDebugInfo(PlayState* play, Gfx** dlist, CutsceneContext* csCtx *dlist = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); } +#endif void Cutscene_InitContext(PlayState* play, CutsceneContext* csCtx) { csCtx->state = CS_STATE_IDLE; @@ -173,20 +175,24 @@ void Cutscene_UpdateManual(PlayState* play, CutsceneContext* csCtx) { } void Cutscene_UpdateScripted(PlayState* play, CutsceneContext* csCtx) { - Input* input = &play->state.input[0]; +#if OOT_DEBUG + { + Input* input = &play->state.input[0]; - if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT) && (csCtx->state == CS_STATE_IDLE) && IS_CUTSCENE_LAYER) { - gUseCutsceneCam = false; - gSaveContext.save.cutsceneIndex = 0xFFFD; - gSaveContext.cutsceneTrigger = 1; - } + if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT) && (csCtx->state == CS_STATE_IDLE) && IS_CUTSCENE_LAYER) { + gUseCutsceneCam = false; + gSaveContext.save.cutsceneIndex = 0xFFFD; + gSaveContext.cutsceneTrigger = 1; + } - if (CHECK_BTN_ALL(input->press.button, BTN_DUP) && (csCtx->state == CS_STATE_IDLE) && IS_CUTSCENE_LAYER && - !gDebugCamEnabled) { - gUseCutsceneCam = true; - gSaveContext.save.cutsceneIndex = 0xFFFD; - gSaveContext.cutsceneTrigger = 1; + if (CHECK_BTN_ALL(input->press.button, BTN_DUP) && (csCtx->state == CS_STATE_IDLE) && IS_CUTSCENE_LAYER && + !gDebugCamEnabled) { + gUseCutsceneCam = true; + gSaveContext.save.cutsceneIndex = 0xFFFD; + gSaveContext.cutsceneTrigger = 1; + } } +#endif if ((gSaveContext.cutsceneTrigger != 0) && (play->transitionTrigger == TRANS_TRIGGER_START)) { gSaveContext.cutsceneTrigger = 0; @@ -562,7 +568,7 @@ void CutsceneCmd_Destination(PlayState* play, CutsceneContext* csCtx, CsCmdDesti } if ((csCtx->curFrame == cmd->startFrame) || titleDemoSkipped || - ((csCtx->curFrame > 20) && CHECK_BTN_ALL(play->state.input[0].press.button, BTN_START) && + (OOT_DEBUG && (csCtx->curFrame > 20) && CHECK_BTN_ALL(play->state.input[0].press.button, BTN_START) && (gSaveContext.fileNum != 0xFEDC))) { csCtx->state = CS_STATE_RUN_UNSTOPPABLE; Audio_SetCutsceneFlag(0); @@ -717,7 +723,9 @@ void CutsceneCmd_Destination(PlayState* play, CutsceneContext* csCtx, CsCmdDesti break; case CS_DEST_TEMPLE_OF_TIME_AFTER_LIGHT_MEDALLION: - SET_EVENTCHKINF(EVENTCHKINF_4F); +#if OOT_DEBUG + SET_EVENTCHKINF(EVENTCHKINF_WATCHED_SHEIK_AFTER_MASTER_SWORD_CS); +#endif play->nextEntranceIndex = ENTR_TEMPLE_OF_TIME_4; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_FADE_BLACK; @@ -886,7 +894,9 @@ void CutsceneCmd_Destination(PlayState* play, CutsceneContext* csCtx, CsCmdDesti break; case CS_DEST_TEMPLE_OF_TIME_AFTER_LIGHT_MEDALLION_ALT: - SET_EVENTCHKINF(EVENTCHKINF_4F); +#if OOT_DEBUG + SET_EVENTCHKINF(EVENTCHKINF_WATCHED_SHEIK_AFTER_MASTER_SWORD_CS); +#endif play->nextEntranceIndex = ENTR_TEMPLE_OF_TIME_4; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; @@ -941,8 +951,10 @@ void CutsceneCmd_Destination(PlayState* play, CutsceneContext* csCtx, CsCmdDesti break; case CS_DEST_GERUDO_VALLEY_CREDITS: +#if OOT_DEBUG gSaveContext.gameMode = GAMEMODE_END_CREDITS; Audio_SetSfxBanksMute(0x6F); +#endif play->linkAgeOnLoad = LINK_AGE_CHILD; play->nextEntranceIndex = ENTR_GERUDO_VALLEY_0; gSaveContext.save.cutsceneIndex = 0xFFF2; @@ -1779,10 +1791,12 @@ void Cutscene_ProcessScript(PlayState* play, CutsceneContext* csCtx, u8* script) return; } +#if OOT_DEBUG if (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_DRIGHT)) { csCtx->state = CS_STATE_STOP; return; } +#endif for (i = 0; i < totalEntries; i++) { MemCpy(&cmdType, script, sizeof(cmdType)); @@ -2189,15 +2203,11 @@ void Cutscene_ProcessScript(PlayState* play, CutsceneContext* csCtx, u8* script) } void CutsceneHandler_RunScript(PlayState* play, CutsceneContext* csCtx) { - Gfx* displayList; - Gfx* prevDisplayList; - - if (0) {} // Necessary to match - if (gSaveContext.save.cutsceneIndex >= 0xFFF0) { - if (0) {} // Also necessary to match + if (OOT_DEBUG && BREG(0) != 0) { + Gfx* displayList; + Gfx* prevDisplayList; - if (BREG(0) != 0) { OPEN_DISPS(play->state.gfxCtx, "../z_demo.c", 4101); prevDisplayList = POLY_OPA_DISP; @@ -2210,10 +2220,9 @@ void CutsceneHandler_RunScript(PlayState* play, CutsceneContext* csCtx) { CLOSE_DISPS(play->state.gfxCtx, "../z_demo.c", 4108); } - csCtx->curFrame++; - if (R_USE_DEBUG_CUTSCENE) { + if (OOT_DEBUG && R_USE_DEBUG_CUTSCENE) { Cutscene_ProcessScript(play, csCtx, gDebugCutsceneScript); } else { Cutscene_ProcessScript(play, csCtx, play->csCtx.script); diff --git a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c index 20f6b63c39..ce21d366ae 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c +++ b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c @@ -93,9 +93,9 @@ void BgTokiSwd_Destroy(Actor* thisx, PlayState* play) { } void func_808BAF40(BgTokiSwd* this, PlayState* play) { - if (!GET_EVENTCHKINF(EVENTCHKINF_4F) && !IS_CUTSCENE_LAYER && + if (!GET_EVENTCHKINF(EVENTCHKINF_WATCHED_SHEIK_AFTER_MASTER_SWORD_CS) && !IS_CUTSCENE_LAYER && Actor_IsFacingAndNearPlayer(&this->actor, 800.0f, 0x7530) && !Play_InCsMode(play)) { - SET_EVENTCHKINF(EVENTCHKINF_4F); + SET_EVENTCHKINF(EVENTCHKINF_WATCHED_SHEIK_AFTER_MASTER_SWORD_CS); play->csCtx.script = D_808BBD90; gSaveContext.cutsceneTrigger = 1; }