Skip to content

Commit

Permalink
tr1/output: remove legacy fade API
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Jan 8, 2025
1 parent 40fe75a commit 01ca136
Show file tree
Hide file tree
Showing 20 changed files with 18 additions and 131 deletions.
5 changes: 5 additions & 0 deletions src/libtrx/game/fader.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ bool Fader_IsActive(const FADER *const fader)
const double target_time = fader->args.duration + fader->args.debuff;
return elapsed_time < target_time;
}

void Fader_Draw(const FADER *const fader)
{
Output_DrawBlackRectangle(Fader_GetCurrentValue(fader));
}
2 changes: 1 addition & 1 deletion src/libtrx/game/phase/phase_picture.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static void M_Draw(PHASE *const phase)
M_PRIV *const p = phase->priv;
Output_DrawBackground();
Output_DrawPolyList();
Output_DrawBlackRectangle(Fader_GetCurrentValue(&p->fader));
Fader_Draw(&p->fader);
Console_Draw();
Text_Draw();
Output_DrawPolyList();
Expand Down
1 change: 1 addition & 0 deletions src/libtrx/include/libtrx/game/fader.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ void Fader_InitEx(FADER *fader, FADER_ARGS args);
void Fader_Init(FADER *fader, int32_t initial, int32_t target, double duration);
bool Fader_IsActive(const FADER *fader);
int32_t Fader_GetCurrentValue(const FADER *fader);
void Fader_Draw(const FADER *fader);
1 change: 0 additions & 1 deletion src/tr1/game/game/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
Game_DrawScene(true); \
Input_Update(); \
Output_EndScene(); \
Output_AnimateFades(); \
Clock_WaitTick(); \
} while (g_Input.key);

Expand Down
2 changes: 0 additions & 2 deletions src/tr1/game/game/game_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,4 @@ void Game_DrawScene(bool draw_overlay)
Lara_Hair_Draw();
Output_FlushTranslucentObjects();
}

Output_DrawBackdropScreen();
}
6 changes: 0 additions & 6 deletions src/tr1/game/gameflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,9 +1137,6 @@ GameFlow_InterpretSequence(int32_t level_num, GAME_FLOW_LEVEL_TYPE level_type)
break;
}

// TODO: do not call me here once everything moves to libtrx faders
Output_FadeReset();

GAME_FLOW_DISPLAY_PICTURE_DATA *data = seq->data;
PHASE *const phase = Phase_Picture_Create((PHASE_PICTURE_ARGS) {
.file_name = data->path,
Expand Down Expand Up @@ -1518,9 +1515,6 @@ GAME_FLOW_COMMAND GameFlow_PlayAvailableStory(int32_t slot_num)

GAME_FLOW_COMMAND GF_ShowInventory(const INVENTORY_MODE inv_mode)
{
// TODO: do not call me here once everything moves to libtrx faders
Output_FadeReset();

PHASE *const phase = Phase_Inventory_Create(inv_mode);
const GAME_FLOW_COMMAND gf_cmd = PhaseExecutor_Run(phase);
Phase_Inventory_Destroy(phase);
Expand Down
5 changes: 2 additions & 3 deletions src/tr1/game/inventory_ring/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ void InvRing_Draw(INV_RING *const ring)
ring->camera.pos.z = ring->radius + CAMERA_2_RING;

if (g_InvMode == INV_TITLE_MODE) {
Output_DrawBackdropScreen();
Interpolation_Commit();
} else {
Matrix_LookAt(
Expand All @@ -172,7 +171,7 @@ void InvRing_Draw(INV_RING *const ring)
Game_DrawScene(false);
Interpolation_Enable();

Output_DrawBlackRectangle(Fader_GetCurrentValue(&ring->back_fader));
Fader_Draw(&ring->back_fader);

int32_t width = Screen_GetResWidth();
int32_t height = Screen_GetResHeight();
Expand Down Expand Up @@ -250,5 +249,5 @@ void InvRing_Draw(INV_RING *const ring)
}
}

Output_DrawBlackRectangle(Fader_GetCurrentValue(&ring->top_fader));
Fader_Draw(&ring->top_fader);
}
91 changes: 0 additions & 91 deletions src/tr1/game/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ void Output_BeginScene(void)

void Output_EndScene(void)
{
Output_DrawOverlayScreen();
S_Output_DisableDepthTest();
S_Output_ClearDepthBuffer();
Overlay_DrawFPSInfo();
Expand Down Expand Up @@ -1168,30 +1167,6 @@ void Output_SetupAboveWater(bool underwater)
m_IsShadeEffect = underwater;
}

void Output_AnimateFades(void)
{
if (!g_Config.visuals.enable_fade_effects) {
return;
}

const double delta =
ClockTimer_TakeElapsed(&m_FadeTimer) * LOGIC_FPS * 10.0;
if (m_OverlayCurAlpha + delta <= m_OverlayDstAlpha) {
m_OverlayCurAlpha += delta;
} else if (m_OverlayCurAlpha - delta >= m_OverlayDstAlpha) {
m_OverlayCurAlpha -= delta;
} else {
m_OverlayCurAlpha = m_OverlayDstAlpha;
}
if (m_BackdropCurAlpha + delta <= m_BackdropDstAlpha) {
m_BackdropCurAlpha += delta;
} else if (m_BackdropCurAlpha - delta >= m_BackdropDstAlpha) {
m_BackdropCurAlpha -= delta;
} else {
m_BackdropCurAlpha = m_BackdropDstAlpha;
}
}

void Output_AnimateTextures(void)
{
m_WibbleOffsetDbl += ClockTimer_TakeElapsed(&m_WibbleTimer) * LOGIC_FPS;
Expand Down Expand Up @@ -1275,72 +1250,6 @@ void Output_DrawPolyList(void)
S_Output_ClearDepthBuffer();
}

void Output_DrawBackdropScreen(void)
{
Output_DrawBlackRectangle(m_BackdropCurAlpha);
}

void Output_DrawOverlayScreen(void)
{
Output_DrawBlackRectangle(m_OverlayCurAlpha);
}

void Output_FadeReset(void)
{
m_BackdropCurAlpha = 0;
m_OverlayCurAlpha = 0;
m_BackdropDstAlpha = 0;
m_OverlayDstAlpha = 0;
ClockTimer_Sync(&m_FadeTimer);
}

void Output_FadeResetToBlack(void)
{
m_OverlayCurAlpha = 255;
m_OverlayDstAlpha = 255;
ClockTimer_Sync(&m_FadeTimer);
}

void Output_FadeToBlack(bool allow_immediate)
{
if (g_Config.visuals.enable_fade_effects) {
m_OverlayDstAlpha = 255;
} else if (allow_immediate) {
m_OverlayCurAlpha = 255;
}
}

void Output_FadeToSemiBlack(bool allow_immediate)
{
if (g_Config.visuals.enable_fade_effects) {
m_BackdropDstAlpha = 128;
m_OverlayDstAlpha = 0;
} else if (allow_immediate) {
m_BackdropCurAlpha = 128;
m_OverlayCurAlpha = 0;
}
}

void Output_FadeToTransparent(bool allow_immediate)
{
if (g_Config.visuals.enable_fade_effects) {
m_BackdropDstAlpha = 0;
m_OverlayDstAlpha = 0;
} else if (allow_immediate) {
m_BackdropCurAlpha = 0;
m_OverlayCurAlpha = 0;
}
}

bool Output_FadeIsAnimating(void)
{
if (!g_Config.visuals.enable_fade_effects) {
return false;
}
return m_OverlayCurAlpha != m_OverlayDstAlpha
|| m_BackdropCurAlpha != m_BackdropDstAlpha;
}

void Output_ApplyFOV(void)
{
int32_t fov = Viewport_GetFOV();
Expand Down
10 changes: 0 additions & 10 deletions src/tr1/game/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ void Output_SetDrawDistFade(int32_t dist);
void Output_SetDrawDistMax(int32_t dist);
void Output_SetWaterColor(const RGB_F *color);

void Output_FadeReset(void);
void Output_FadeResetToBlack(void);
void Output_FadeToBlack(bool allow_immediate);
void Output_FadeToSemiBlack(bool allow_immediate);
void Output_FadeToTransparent(bool allow_immediate);
bool Output_FadeIsAnimating(void);
void Output_DrawBackdropScreen(void);
void Output_DrawOverlayScreen(void);

void Output_BeginScene(void);
void Output_EndScene(void);

Expand Down Expand Up @@ -99,7 +90,6 @@ void Output_DrawUISprite(
void Output_SetupBelowWater(bool underwater);
void Output_SetupAboveWater(bool underwater);
void Output_AnimateTextures(void);
void Output_AnimateFades(void);

void Output_ApplyFOV(void);
void Output_ApplyTint(float *r, float *g, float *b);
Expand Down
3 changes: 0 additions & 3 deletions src/tr1/game/phase/phase_cutscene.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ static void M_Start(const PHASE_CUTSCENE_ARGS *const args)
return;
}

Output_FadeReset();

if (!Level_Initialise(args->level_num)) {
return;
}
Expand Down Expand Up @@ -198,7 +196,6 @@ static void M_Draw(void)
{
Game_DrawScene(true);
Output_AnimateTextures();
Output_AnimateFades();
}

PHASER g_CutscenePhaser = {
Expand Down
3 changes: 1 addition & 2 deletions src/tr1/game/phase/phase_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ static void M_Start(const PHASE_DEMO_ARGS *const args)
Input_Update();

Interpolation_Remember();
Output_FadeReset();

M_PrepareConfig();
M_PrepareResumeInfo();
Expand Down Expand Up @@ -398,7 +397,7 @@ static void M_Draw(void)

Output_AnimateTextures();
Text_Draw();
Output_DrawBlackRectangle(Fader_GetCurrentValue(&m_Fader));
Fader_Draw(&m_Fader);
}

PHASER g_DemoPhaser = {
Expand Down
2 changes: 0 additions & 2 deletions src/tr1/game/phase/phase_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ static void M_Start(const void *const args)
{
Interpolation_Remember();
Stats_StartTimer();
Output_FadeReset();
Game_SetIsPlaying(true);
}

Expand Down Expand Up @@ -179,7 +178,6 @@ static void M_Draw(void)
{
Game_DrawScene(true);
Output_AnimateTextures();
Output_AnimateFades();
Text_Draw();
}

Expand Down
1 change: 0 additions & 1 deletion src/tr1/game/phase/phase_inventory.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ static void M_Draw(PHASE *const phase)
M_PRIV *const p = phase->priv;
ASSERT(p->ring != NULL);
InvRing_Draw(p->ring);
Output_AnimateFades();
Text_Draw();
}

Expand Down
3 changes: 1 addition & 2 deletions src/tr1/game/phase/phase_pause.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,8 @@ static void M_Draw(PHASE *const phase)
M_PRIV *const p = phase->priv;
Interpolation_Disable();
Game_DrawScene(false);
Output_DrawBlackRectangle(Fader_GetCurrentValue(&p->back_fader));
Fader_Draw(&p->back_fader);
Interpolation_Enable();
Output_AnimateFades();
if (p->ui != NULL) {
p->ui->draw(p->ui);
}
Expand Down
4 changes: 2 additions & 2 deletions src/tr1/game/phase/phase_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ static void M_Draw(PHASE *const phase)
Interpolation_Disable();
Game_DrawScene(false);
Interpolation_Enable();
Output_DrawBlackRectangle(Fader_GetCurrentValue(&p->back_fader));
Fader_Draw(&p->back_fader);
}
Text_Draw();
Output_DrawBlackRectangle(Fader_GetCurrentValue(&p->top_fader));
Fader_Draw(&p->top_fader);
}

PHASE *Phase_Stats_Create(const PHASE_STATS_ARGS args)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/phase/phase_cutscene.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static void M_Draw(PHASE *const phase)
Console_Draw();
Text_Draw();
Output_DrawPolyList();
Output_DrawBlackRectangle(Fader_GetCurrentValue(&p->exit_fader));
Fader_Draw(&p->exit_fader);
}

PHASE *Phase_Cutscene_Create(const int32_t level_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/phase/phase_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static void M_Draw(PHASE *const phase)
{
M_PRIV *const p = phase->priv;
Game_Draw();
Output_DrawBlackRectangle(Fader_GetCurrentValue(&p->exit_fader));
Fader_Draw(&p->exit_fader);
}

PHASE *Phase_Demo_Create(const int32_t level_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/phase/phase_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static void M_Draw(PHASE *const phase)
{
M_PRIV *const p = phase->priv;
Game_Draw();
Output_DrawBlackRectangle(Fader_GetCurrentValue(&p->exit_fader));
Fader_Draw(&p->exit_fader);
}

PHASE *Phase_Game_Create(
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/phase/phase_inventory.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static void M_Draw(PHASE *const phase)
Text_Draw();
Output_DrawPolyList();

Output_DrawBlackRectangle(Fader_GetCurrentValue(&p->fader));
Fader_Draw(&p->fader);

Console_Draw();
Text_Draw();
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/phase/phase_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void M_Draw(PHASE *const phase)
p->dialog->draw(p->dialog);
Text_Draw();
Output_DrawPolyList();
Output_DrawBlackRectangle(Fader_GetCurrentValue(&p->fader));
Fader_Draw(&p->fader);
Console_Draw();
Text_Draw();
Output_DrawPolyList();
Expand Down

0 comments on commit 01ca136

Please sign in to comment.