diff --git a/docs/tr1/CHANGELOG.md b/docs/tr1/CHANGELOG.md index 23d30d190..875b975f6 100644 --- a/docs/tr1/CHANGELOG.md +++ b/docs/tr1/CHANGELOG.md @@ -1,5 +1,6 @@ ## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr1-4.5.1...develop) - ××××-××-×× - added support for wading, similar to TR2+ (#1537) +- added the ability to pause during cutscenes (#1673) - fixed missing pushblock SFX in Natla's Mines (#1714) - fixed crash reports not working in certain circumstances (#1738) - fixed missing trapdoor triggers in City of Khamoon (#1744) diff --git a/src/tr1/game/phase/phase_cutscene.c b/src/tr1/game/phase/phase_cutscene.c index b8968da37..503d26cc6 100644 --- a/src/tr1/game/phase/phase_cutscene.c +++ b/src/tr1/game/phase/phase_cutscene.c @@ -12,6 +12,7 @@ #include "game/level.h" #include "game/music.h" #include "game/output.h" +#include "game/phase/phase_pause.h" #include "game/phase/phase_photo_mode.h" #include "game/shell.h" #include "game/sound.h" @@ -25,7 +26,7 @@ #include #include -static bool m_ExitingToPhotoMode = false; +static bool m_PauseCutscene = false; static void M_InitialiseHair(int32_t level_num); @@ -69,7 +70,7 @@ static void M_InitialiseHair(int32_t level_num) static void M_Start(const PHASE_CUTSCENE_ARGS *const args) { - m_ExitingToPhotoMode = false; + m_PauseCutscene = false; // The cutscene is already playing and it's to be resumed. if (args->resume_existing) { @@ -106,7 +107,7 @@ static void M_Start(const PHASE_CUTSCENE_ARGS *const args) static void M_End(void) { - if (m_ExitingToPhotoMode) { + if (m_PauseCutscene) { return; } @@ -152,18 +153,27 @@ static PHASE_CONTROL M_Control(int32_t nframes) g_CineFrame++; - if (g_InputDB.toggle_photo_mode) { + if (g_InputDB.toggle_photo_mode || g_InputDB.pause) { PHASE_CUTSCENE_ARGS *const cutscene_args = Memory_Alloc(sizeof(PHASE_CUTSCENE_ARGS)); cutscene_args->resume_existing = true; cutscene_args->level_num = g_CurrentLevel; - PHASE_PHOTO_MODE_ARGS *const args = - Memory_Alloc(sizeof(PHASE_PHOTO_MODE_ARGS)); - args->phase_to_return_to = PHASE_CUTSCENE; - args->phase_arg = cutscene_args; - Phase_Set(PHASE_PHOTO_MODE, args); - m_ExitingToPhotoMode = true; + if (g_InputDB.toggle_photo_mode) { + PHASE_PHOTO_MODE_ARGS *const args = + Memory_Alloc(sizeof(PHASE_PHOTO_MODE_ARGS)); + args->phase_to_return_to = PHASE_CUTSCENE; + args->phase_arg = cutscene_args; + Phase_Set(PHASE_PHOTO_MODE, args); + } else if (g_InputDB.pause) { + PHASE_PAUSE_ARGS *const args = + Memory_Alloc(sizeof(PHASE_PAUSE_ARGS)); + args->phase_to_return_to = PHASE_CUTSCENE; + args->phase_arg = cutscene_args; + Phase_Set(PHASE_PAUSE, args); + } + + m_PauseCutscene = true; return (PHASE_CONTROL) { .end = false }; } } diff --git a/src/tr1/game/phase/phase_pause.c b/src/tr1/game/phase/phase_pause.c index 992f708cc..e4362e8a7 100644 --- a/src/tr1/game/phase/phase_pause.c +++ b/src/tr1/game/phase/phase_pause.c @@ -31,7 +31,7 @@ typedef enum { static STATE m_PauseState = STATE_DEFAULT; static bool m_IsTextReady = false; - +static PHASE_PAUSE_ARGS m_Args; static TEXTSTRING *m_PausedText = NULL; static REQUEST_INFO m_PauseRequester = { @@ -55,7 +55,7 @@ static void M_UpdateText(void); static int32_t M_DisplayRequester( const char *header, const char *option1, const char *option2, int16_t requested); -static void M_Start(const void *args); +static void M_Start(const PHASE_PAUSE_ARGS *args); static void M_End(void); static PHASE_CONTROL M_Control(int32_t nframes); static void M_Draw(void); @@ -108,8 +108,15 @@ static int32_t M_DisplayRequester( return select; } -static void M_Start(const void *const args) +static void M_Start(const PHASE_PAUSE_ARGS *const args) { + if (args != NULL) { + m_Args = *args; + } else { + m_Args.phase_to_return_to = PHASE_GAME; + m_Args.phase_arg = NULL; + } + g_OldInputDB = g_Input; Overlay_HideGameInfo(); @@ -145,7 +152,7 @@ static PHASE_CONTROL M_Control(int32_t nframes) if (g_InputDB.pause) { Music_Unpause(); Sound_UnpauseAll(); - Phase_Set(PHASE_GAME, NULL); + Phase_Set(m_Args.phase_to_return_to, m_Args.phase_arg); } else if (g_InputDB.option) { m_PauseState = STATE_ASK; } @@ -157,7 +164,7 @@ static PHASE_CONTROL M_Control(int32_t nframes) if (choice == 1) { Music_Unpause(); Sound_UnpauseAll(); - Phase_Set(PHASE_GAME, NULL); + Phase_Set(m_Args.phase_to_return_to, m_Args.phase_arg); } else if (choice == 2) { m_PauseState = STATE_CONFIRM; } @@ -175,7 +182,7 @@ static PHASE_CONTROL M_Control(int32_t nframes) } else if (choice == 2) { Music_Unpause(); Sound_UnpauseAll(); - Phase_Set(PHASE_GAME, NULL); + Phase_Set(m_Args.phase_to_return_to, m_Args.phase_arg); } break; } @@ -194,7 +201,7 @@ static void M_Draw(void) } PHASER g_PausePhaser = { - .start = M_Start, + .start = (PHASER_START)M_Start, .end = M_End, .control = M_Control, .draw = M_Draw, diff --git a/src/tr1/game/phase/phase_pause.h b/src/tr1/game/phase/phase_pause.h index 375a287da..6a7a095ae 100644 --- a/src/tr1/game/phase/phase_pause.h +++ b/src/tr1/game/phase/phase_pause.h @@ -2,4 +2,9 @@ #include "game/phase/phase.h" +typedef struct { + PHASE phase_to_return_to; + void *phase_arg; +} PHASE_PAUSE_ARGS; + extern PHASER g_PausePhaser;