Skip to content

Commit

Permalink
phase/pause: improve ps1 compatibility
Browse files Browse the repository at this point in the history
Resolves #2248.
  • Loading branch information
rr- committed Jan 10, 2025
1 parent 6ec0290 commit 3362551
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- fixed Lara activating triggers one frame too early (#2208, regression from 4.3)
- fixed wrong underwater caustics speed with the turbo cheat (#2231)
- fixed 1-frame UI flicker on pause screen exit confirmation
- improved pause screen compatibility with PS1 (#2248)

## [4.7.1](https://github.com/LostArtefacts/TRX/compare/tr1-4.7...tr1-4.7.1) - 2024-12-21
- changed the inventory examine UI to auto-hide if the item description is empty (#2097)
Expand Down
28 changes: 21 additions & 7 deletions src/libtrx/game/phase/phase_pause.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
#include <stddef.h>
#include <stdint.h>

#define FADE_TIME 0.4

typedef enum {
STATE_DEFAULT,
STATE_FADE_IN,
STATE_WAIT,
STATE_ASK,
STATE_CONFIRM,
STATE_FADE_OUT,
Expand Down Expand Up @@ -53,8 +56,8 @@ static void M_Draw(PHASE *phase);

static void M_FadeIn(M_PRIV *const p)
{
M_CreateText(p);
Fader_Init(&p->back_fader, FADER_TRANSPARENT, FADER_SEMI_BLACK, 0.5);
p->state = STATE_FADE_IN;
Fader_Init(&p->back_fader, FADER_TRANSPARENT, FADER_SEMI_BLACK, FADE_TIME);
}

static void M_FadeOut(M_PRIV *const p)
Expand All @@ -65,9 +68,9 @@ static void M_FadeOut(M_PRIV *const p)
p->ui = NULL;
}
if (p->action == GF_NOOP) {
Fader_Init(&p->back_fader, FADER_ANY, FADER_TRANSPARENT, 0.3);
Fader_Init(&p->back_fader, FADER_ANY, FADER_TRANSPARENT, FADE_TIME);
} else {
Fader_Init(&p->back_fader, FADER_ANY, FADER_BLACK, 0.5);
Fader_Init(&p->back_fader, FADER_ANY, FADER_BLACK, FADE_TIME);
}
p->state = STATE_FADE_OUT;
}
Expand Down Expand Up @@ -150,7 +153,6 @@ static PHASE_CONTROL M_Start(PHASE *const phase)
M_PauseGame(p);

p->is_ui_ready = false;
p->state = STATE_DEFAULT;
return (PHASE_CONTROL) { .action = PHASE_ACTION_CONTINUE };
}

Expand Down Expand Up @@ -180,7 +182,18 @@ static PHASE_CONTROL M_Control(PHASE *const phase, int32_t const num_frames)
}

switch (p->state) {
case STATE_DEFAULT:
case STATE_FADE_IN:
if (g_InputDB.pause) {
M_ReturnToGame(p);
return (PHASE_CONTROL) { .action = PHASE_ACTION_NO_WAIT };
} else if (!Fader_IsActive(&p->back_fader)) {
p->state = STATE_WAIT;
M_CreateText(p);
return (PHASE_CONTROL) { .action = PHASE_ACTION_NO_WAIT };
}
break;

case STATE_WAIT:
if (g_InputDB.pause) {
M_ReturnToGame(p);
return (PHASE_CONTROL) { .action = PHASE_ACTION_NO_WAIT };
Expand All @@ -197,6 +210,7 @@ static PHASE_CONTROL M_Control(PHASE *const phase, int32_t const num_frames)
return (PHASE_CONTROL) { .action = PHASE_ACTION_NO_WAIT };
} else if (choice == 1) {
p->state = STATE_CONFIRM;
return (PHASE_CONTROL) { .action = PHASE_ACTION_NO_WAIT };
}
break;
}
Expand Down

0 comments on commit 3362551

Please sign in to comment.