Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tr1/output: use tr2 Output_AnimateTextures method #2242

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 28 additions & 31 deletions src/tr1/game/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static int m_BackdropDstAlpha = 0;
static RGB_888 *m_ColorPalette = NULL;

static int32_t m_WibbleOffset = 0;
static double m_WibbleOffsetDbl = 0.0;
static int32_t m_AnimatedTexturesOffset = 0;
static CLOCK_TIMER m_WibbleTimer = { .type = CLOCK_TIMER_SIM };
static CLOCK_TIMER m_AnimatedTexturesTimer = { .type = CLOCK_TIMER_SIM };
static CLOCK_TIMER m_FadeTimer = { .type = CLOCK_TIMER_SIM };
Expand Down Expand Up @@ -1167,41 +1167,38 @@ void Output_SetupAboveWater(bool underwater)
m_IsShadeEffect = underwater;
}

void Output_AnimateTextures(void)
void Output_AnimateTextures(const int32_t num_frames)
{
m_WibbleOffsetDbl += ClockTimer_TakeElapsed(&m_WibbleTimer) * LOGIC_FPS;
m_WibbleOffset = (int32_t)(m_WibbleOffsetDbl) % WIBBLE_SIZE;

if (!ClockTimer_CheckElapsedAndTake(
&m_AnimatedTexturesTimer, 5.0 / (double)LOGIC_FPS)) {
return;
}

const TEXTURE_RANGE *range = g_AnimTextureRanges;
while (range) {
int32_t i = 0;
const PHD_TEXTURE temp = g_PhdTextureInfo[range->textures[i]];
for (; i < range->num_textures - 1; i++) {
g_PhdTextureInfo[range->textures[i]] =
g_PhdTextureInfo[range->textures[i + 1]];
m_WibbleOffset = (m_WibbleOffset + num_frames) % WIBBLE_SIZE;
m_AnimatedTexturesOffset += num_frames;
while (m_AnimatedTexturesOffset > 5) {
const TEXTURE_RANGE *range = g_AnimTextureRanges;
while (range) {
int32_t i = 0;
const PHD_TEXTURE temp = g_PhdTextureInfo[range->textures[i]];
for (; i < range->num_textures - 1; i++) {
g_PhdTextureInfo[range->textures[i]] =
g_PhdTextureInfo[range->textures[i + 1]];
}
g_PhdTextureInfo[range->textures[i]] = temp;
range = range->next_range;
}
g_PhdTextureInfo[range->textures[i]] = temp;
range = range->next_range;
}

for (int32_t i = 0; i < STATIC_NUMBER_OF; i++) {
const STATIC_INFO *const static_info = &g_StaticObjects[i];
if (!static_info->loaded || static_info->mesh_count >= -1) {
continue;
}
for (int32_t i = 0; i < STATIC_NUMBER_OF; i++) {
const STATIC_INFO *const static_info = &g_StaticObjects[i];
if (!static_info->loaded || static_info->mesh_count >= -1) {
continue;
}

const int32_t num_meshes = -static_info->mesh_count;
const PHD_SPRITE temp = g_PhdSpriteInfo[static_info->mesh_num];
for (int32_t j = 0; j < num_meshes - 1; j++) {
g_PhdSpriteInfo[static_info->mesh_num + j] =
g_PhdSpriteInfo[static_info->mesh_num + j + 1];
const int32_t num_meshes = -static_info->mesh_count;
const PHD_SPRITE temp = g_PhdSpriteInfo[static_info->mesh_num];
for (int32_t j = 0; j < num_meshes - 1; j++) {
g_PhdSpriteInfo[static_info->mesh_num + j] =
g_PhdSpriteInfo[static_info->mesh_num + j + 1];
}
g_PhdSpriteInfo[static_info->mesh_num + num_meshes - 1] = temp;
}
g_PhdSpriteInfo[static_info->mesh_num + num_meshes - 1] = temp;
m_AnimatedTexturesOffset -= 5;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void Output_DrawUISprite(

void Output_SetupBelowWater(bool underwater);
void Output_SetupAboveWater(bool underwater);
void Output_AnimateTextures(void);
void Output_AnimateTextures(int32_t num_frames);

void Output_ApplyFOV(void);
void Output_ApplyTint(float *r, float *g, float *b);
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/phase/phase_cutscene.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ static PHASE_CONTROL M_Control(int32_t nframes)
}
}

Output_AnimateTextures(nframes);
return (PHASE_CONTROL) { .action = PHASE_ACTION_CONTINUE };
}

static void M_Draw(void)
{
Game_Draw(true);
Output_AnimateTextures();
}

PHASER g_CutscenePhaser = {
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/phase/phase_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ static PHASE_CONTROL M_ControlFadeOut(void)

static PHASE_CONTROL M_Control(int32_t nframes)
{
Output_AnimateTextures(nframes);
switch (m_State) {
case STATE_INVALID:
return (PHASE_CONTROL) {
Expand Down Expand Up @@ -398,7 +399,6 @@ static void M_Draw(void)
Interpolation_Enable();
}

Output_AnimateTextures();
Text_Draw();
Fader_Draw(&m_Fader);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/phase/phase_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ static PHASE_CONTROL M_Control(int32_t nframes)
}
}

Output_AnimateTextures(nframes);
return (PHASE_CONTROL) { .action = PHASE_ACTION_CONTINUE };
}

static void M_Draw(void)
{
Game_Draw(true);
Output_AnimateTextures();
Text_Draw();
}

Expand Down
Loading