Skip to content

Commit

Permalink
tr2: port Output_AnimateTextures
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Dec 17, 2024
1 parent 53eb954 commit bcc9ac7
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 10 deletions.
16 changes: 8 additions & 8 deletions docs/tr2/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/tr2/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4107,7 +4107,7 @@ typedef enum {
0x00451BD0 0x00C0 + void __cdecl Output_DoAnimateTextures(int32_t ticks);
0x00451C90 0x0051 + void __cdecl Output_SetupBelowWater(bool underwater);
0x00451CF0 0x0021 + void __cdecl Output_SetupAboveWater(bool underwater);
0x00451D20 0x00B1 - void __cdecl Output_AnimateTextures(int32_t ticks);
0x00451D20 0x00B1 + void __cdecl Output_AnimateTextures(int32_t ticks);
0x00451DE0 0x0105 +R void __cdecl S_DisplayPicture(const char *file_name, BOOL is_title);
0x00451EF0 0x007E +R void __cdecl S_SyncPictureBufferPalette(void);
0x00451F70 0x001C +R void __cdecl S_DontDisplayPicture(void);
Expand Down Expand Up @@ -4856,3 +4856,4 @@ typedef enum {
0x0051A308 - ROOM_LIGHT_TABLE g_RoomLightTables[32]; // WIBBLE_SIZE
0x005251C0 - LIGHT g_DynamicLights[10]; // MAX_DYNAMIC_LIGHTS
0x0051B908 - int32_t g_RoomLightShades[4];
0x00526194 - int32_t g_SunsetTimer;
18 changes: 18 additions & 0 deletions src/tr2/game/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,3 +1137,21 @@ void __cdecl Output_SetupAboveWater(const bool is_underwater)
g_IsWaterEffect = false;
g_IsShadeEffect = is_underwater;
}

void __cdecl Output_AnimateTextures(const int32_t ticks)
{
g_WibbleOffset = (g_WibbleOffset + (ticks / TICKS_PER_FRAME)) % WIBBLE_SIZE;
g_RoomLightShades[1] = Random_GetDraw() % WIBBLE_SIZE;
g_RoomLightShades[2] = (WIBBLE_SIZE - 1)
* (Math_Sin((g_WibbleOffset * PHD_360) / WIBBLE_SIZE) + 0x4000)
>> 15;

if (g_GF_SunsetEnabled) {
g_SunsetTimer += ticks;
CLAMPG(g_SunsetTimer, SUNSET_TIMEOUT);
g_RoomLightShades[3] =
g_SunsetTimer * (WIBBLE_SIZE - 1) / SUNSET_TIMEOUT;
}

Output_DoAnimateTextures(ticks);
}
1 change: 1 addition & 0 deletions src/tr2/game/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,4 @@ void __cdecl Output_CalculateStaticMeshLight(
void __cdecl Output_LightRoom(ROOM *room);
void __cdecl Output_SetupBelowWater(bool is_underwater);
void __cdecl Output_SetupAboveWater(bool is_underwater);
void __cdecl Output_AnimateTextures(int32_t ticks);
1 change: 1 addition & 0 deletions src/tr2/global/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#define GRAVITY 6
#define MAX_FRAMES 10
#define SUNSET_TIMEOUT 40 * 60 * (FRAMES_PER_SECOND) // = 72000

#define MAX_AUDIO_SAMPLE_BUFFERS 256
#define MAX_AUDIO_SAMPLE_TRACKS 32
Expand Down
1 change: 0 additions & 1 deletion src/tr2/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,4 @@
#define DartEmitter_Control ((void __cdecl (*)(int16_t item_num))0x00442840)
#define Dart_Control ((void __cdecl (*)(int16_t item_num))0x00442980)
#define DartEffect_Control ((void __cdecl (*)(int16_t fx_num))0x00442AE0)
#define Output_AnimateTextures ((void __cdecl (*)(int32_t ticks))0x00451D20)
// clang-format on
1 change: 1 addition & 0 deletions src/tr2/global/vars_decomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@
#define g_IMMatrixPtr (*(MATRIX **)0x00526188)
#define g_Rooms (*(ROOM **)0x0052618C)
#define g_CameraUnderwater (*(BOOL*)0x00526190)
#define g_SunsetTimer (*(int32_t*)0x00526194)
#define g_OutsideRight (*(int32_t*)0x00526198)
#define g_OutsideTop (*(int32_t*)0x005261AC)
#define g_DemoPtr (*(uint32_t **)0x005261B0)
Expand Down
1 change: 1 addition & 0 deletions src/tr2/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ static void M_Output(const bool enable)
INJECT(enable, 0x00451BD0, Output_DoAnimateTextures);
INJECT(enable, 0x00451C90, Output_SetupBelowWater);
INJECT(enable, 0x00451CF0, Output_SetupAboveWater);
INJECT(enable, 0x00451D20, Output_AnimateTextures);
}

static void M_Music(const bool enable)
Expand Down

0 comments on commit bcc9ac7

Please sign in to comment.