diff --git a/src/libtrx/game/fader.c b/src/libtrx/game/fader.c index 660086e70..87edc2d5a 100644 --- a/src/libtrx/game/fader.c +++ b/src/libtrx/game/fader.c @@ -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)); +} diff --git a/src/libtrx/game/phase/phase_picture.c b/src/libtrx/game/phase/phase_picture.c index da592f618..c912c29da 100644 --- a/src/libtrx/game/phase/phase_picture.c +++ b/src/libtrx/game/phase/phase_picture.c @@ -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(); diff --git a/src/libtrx/include/libtrx/game/fader.h b/src/libtrx/include/libtrx/game/fader.h index 58b4187ae..80847b835 100644 --- a/src/libtrx/include/libtrx/game/fader.h +++ b/src/libtrx/include/libtrx/game/fader.h @@ -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); diff --git a/src/tr1/game/game/game.c b/src/tr1/game/game/game.c index 909184818..6f7a67957 100644 --- a/src/tr1/game/game/game.c +++ b/src/tr1/game/game/game.c @@ -26,7 +26,6 @@ Game_DrawScene(true); \ Input_Update(); \ Output_EndScene(); \ - Output_AnimateFades(); \ Clock_WaitTick(); \ } while (g_Input.key); diff --git a/src/tr1/game/game/game_draw.c b/src/tr1/game/game/game_draw.c index 8275c7138..1f42d7373 100644 --- a/src/tr1/game/game/game_draw.c +++ b/src/tr1/game/game/game_draw.c @@ -59,6 +59,4 @@ void Game_DrawScene(bool draw_overlay) Lara_Hair_Draw(); Output_FlushTranslucentObjects(); } - - Output_DrawBackdropScreen(); } diff --git a/src/tr1/game/gameflow.c b/src/tr1/game/gameflow.c index 2414e03d2..0f2dbfe64 100644 --- a/src/tr1/game/gameflow.c +++ b/src/tr1/game/gameflow.c @@ -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, @@ -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); diff --git a/src/tr1/game/inventory_ring/draw.c b/src/tr1/game/inventory_ring/draw.c index 39c59ad43..5a3c318cf 100644 --- a/src/tr1/game/inventory_ring/draw.c +++ b/src/tr1/game/inventory_ring/draw.c @@ -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( @@ -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(); @@ -250,5 +249,5 @@ void InvRing_Draw(INV_RING *const ring) } } - Output_DrawBlackRectangle(Fader_GetCurrentValue(&ring->top_fader)); + Fader_Draw(&ring->top_fader); } diff --git a/src/tr1/game/output.c b/src/tr1/game/output.c index 03caf9dcb..c83f9f98f 100644 --- a/src/tr1/game/output.c +++ b/src/tr1/game/output.c @@ -617,7 +617,6 @@ void Output_BeginScene(void) void Output_EndScene(void) { - Output_DrawOverlayScreen(); S_Output_DisableDepthTest(); S_Output_ClearDepthBuffer(); Overlay_DrawFPSInfo(); @@ -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; @@ -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(); diff --git a/src/tr1/game/output.h b/src/tr1/game/output.h index a8b3d0de5..8849dc988 100644 --- a/src/tr1/game/output.h +++ b/src/tr1/game/output.h @@ -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); @@ -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); diff --git a/src/tr1/game/phase/phase_cutscene.c b/src/tr1/game/phase/phase_cutscene.c index 22d1f1a57..f829aeb31 100644 --- a/src/tr1/game/phase/phase_cutscene.c +++ b/src/tr1/game/phase/phase_cutscene.c @@ -77,8 +77,6 @@ static void M_Start(const PHASE_CUTSCENE_ARGS *const args) return; } - Output_FadeReset(); - if (!Level_Initialise(args->level_num)) { return; } @@ -198,7 +196,6 @@ static void M_Draw(void) { Game_DrawScene(true); Output_AnimateTextures(); - Output_AnimateFades(); } PHASER g_CutscenePhaser = { diff --git a/src/tr1/game/phase/phase_demo.c b/src/tr1/game/phase/phase_demo.c index 61def451a..737ac8871 100644 --- a/src/tr1/game/phase/phase_demo.c +++ b/src/tr1/game/phase/phase_demo.c @@ -235,7 +235,6 @@ static void M_Start(const PHASE_DEMO_ARGS *const args) Input_Update(); Interpolation_Remember(); - Output_FadeReset(); M_PrepareConfig(); M_PrepareResumeInfo(); @@ -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 = { diff --git a/src/tr1/game/phase/phase_game.c b/src/tr1/game/phase/phase_game.c index 267c6c8b6..2fe78ebaf 100644 --- a/src/tr1/game/phase/phase_game.c +++ b/src/tr1/game/phase/phase_game.c @@ -38,7 +38,6 @@ static void M_Start(const void *const args) { Interpolation_Remember(); Stats_StartTimer(); - Output_FadeReset(); Game_SetIsPlaying(true); } @@ -179,7 +178,6 @@ static void M_Draw(void) { Game_DrawScene(true); Output_AnimateTextures(); - Output_AnimateFades(); Text_Draw(); } diff --git a/src/tr1/game/phase/phase_inventory.c b/src/tr1/game/phase/phase_inventory.c index 6b1d42152..0a4a5e522 100644 --- a/src/tr1/game/phase/phase_inventory.c +++ b/src/tr1/game/phase/phase_inventory.c @@ -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(); } diff --git a/src/tr1/game/phase/phase_pause.c b/src/tr1/game/phase/phase_pause.c index fab6160cc..14a8ad138 100644 --- a/src/tr1/game/phase/phase_pause.c +++ b/src/tr1/game/phase/phase_pause.c @@ -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); } diff --git a/src/tr1/game/phase/phase_stats.c b/src/tr1/game/phase/phase_stats.c index 355db9726..dc015c8d6 100644 --- a/src/tr1/game/phase/phase_stats.c +++ b/src/tr1/game/phase/phase_stats.c @@ -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) diff --git a/src/tr2/game/phase/phase_cutscene.c b/src/tr2/game/phase/phase_cutscene.c index 4922b62c7..5cb4ec80b 100644 --- a/src/tr2/game/phase/phase_cutscene.c +++ b/src/tr2/game/phase/phase_cutscene.c @@ -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) diff --git a/src/tr2/game/phase/phase_demo.c b/src/tr2/game/phase/phase_demo.c index d83935db5..d664c4e75 100644 --- a/src/tr2/game/phase/phase_demo.c +++ b/src/tr2/game/phase/phase_demo.c @@ -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) diff --git a/src/tr2/game/phase/phase_game.c b/src/tr2/game/phase/phase_game.c index 79a9a2430..de4db3ada 100644 --- a/src/tr2/game/phase/phase_game.c +++ b/src/tr2/game/phase/phase_game.c @@ -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( diff --git a/src/tr2/game/phase/phase_inventory.c b/src/tr2/game/phase/phase_inventory.c index 4f23bbb61..cf8a75bbf 100644 --- a/src/tr2/game/phase/phase_inventory.c +++ b/src/tr2/game/phase/phase_inventory.c @@ -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(); diff --git a/src/tr2/game/phase/phase_stats.c b/src/tr2/game/phase/phase_stats.c index e157434ea..799db6b75 100644 --- a/src/tr2/game/phase/phase_stats.c +++ b/src/tr2/game/phase/phase_stats.c @@ -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();