From 257210383f2429a7fe9755729cb546fb04c76d1b Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 17 Nov 2023 12:41:12 +0100 Subject: [PATCH] port Overlay_AddDisplayPickup --- docs/progress.svg | 16 ++++++++-------- docs/progress.txt | 2 +- src/game/overlay.c | 18 ++++++++++++++++++ src/game/overlay.h | 1 + src/global/funcs.h | 1 - src/inject_exec.c | 1 + 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/docs/progress.svg b/docs/progress.svg index 9dec025..255c485 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -69,10 +69,10 @@ Tomb2.exe progress according to the physical function order: -29.80% (363) · 67.73% (825) · 0.66% (8) · 1.81% (22) +29.89% (364) · 67.65% (824) · 0.66% (8) · 1.81% (22) - - + + @@ -400,7 +400,7 @@ void __cdecl Overlay_DrawAmmoInfo(void); void __cdecl Overlay_InitialisePickUpDisplay(void); void __cdecl Overlay_DrawPickups(bool pickup_state); -void __cdecl Overlay_AddDisplayPickup(int16_t obj_num); +void __cdecl Overlay_AddDisplayPickup(int16_t obj_num); void __cdecl Overlay_DisplayModeInfo(char* string); void __cdecl Overlay_DrawModeInfo(void); int32_t __cdecl Display_Inventory(int32_t inventory_mode); @@ -1299,10 +1299,10 @@ Tomb2.exe progress according to the function sizes: -28.18% · 71.50% · 0.02% · 0.31% +28.21% · 71.47% · 0.02% · 0.31% - - + + @@ -1991,7 +1991,7 @@ BOOL __cdecl UT_CenterWindow(HWND hWnd); void __cdecl UT_MemBlt(BYTE *dstBuf, DWORD dstX, DWORD dstY, DWORD width, DWORD height, DWORD dstPitch, BYTE *srcBuf, DWORD srcX, DWORD srcY, DWORD srcPitch); int32_t __cdecl Output_VisibleZClip(const struct PHD_VBUF *vtx0, const struct PHD_VBUF *vtx1, const struct PHD_VBUF *vtx2); -void __cdecl Overlay_AddDisplayPickup(int16_t obj_num); +void __cdecl Overlay_AddDisplayPickup(int16_t obj_num); int16_t __cdecl Effect_Create(int16_t room_num); void *__cdecl game_malloc(uint32_t alloc_size, uint32_t buf_index); void __cdecl Output_SetFarZ(int32_t far_z); diff --git a/docs/progress.txt b/docs/progress.txt index e6f6713..cbb6d9d 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -1993,7 +1993,7 @@ typedef enum GAME_OBJECT_ID { 00421CF0 00000132 + void __cdecl Overlay_DrawAmmoInfo(void); 00421E40 00000015 + void __cdecl Overlay_InitialisePickUpDisplay(void); 00421E60 000000FD + void __cdecl Overlay_DrawPickups(bool pickup_state); -00421F60 0000006C - void __cdecl Overlay_AddDisplayPickup(int16_t obj_num); +00421F60 0000006C + void __cdecl Overlay_AddDisplayPickup(int16_t obj_num); 00421FD0 0000007A * void __cdecl Overlay_DisplayModeInfo(char* string); 00422050 0000002C * void __cdecl Overlay_DrawModeInfo(void); diff --git a/src/game/overlay.c b/src/game/overlay.c index 4622452..bf61209 100644 --- a/src/game/overlay.c +++ b/src/game/overlay.c @@ -1,5 +1,6 @@ #include "game/overlay.h" +#include "game/music.h" #include "game/output.h" #include "game/text.h" #include "global/const.h" @@ -245,3 +246,20 @@ void __cdecl Overlay_DrawPickups(const bool pickup_state) x -= cell_h; } } + +void __cdecl Overlay_AddDisplayPickup(const int16_t obj_num) +{ + if (obj_num == O_SECRET_1 || obj_num == O_SECRET_2 + || obj_num == O_SECRET_3) { + Music_Play(g_GameFlow.secret_track, false); + } + + for (int i = 0; i < MAX_PICKUPS; i++) { + struct PICKUP_INFO *const pickup = &g_Pickups[i]; + if (pickup->timer <= 0) { + pickup->timer = 2.5 * FRAMES_PER_SECOND; + pickup->sprite = g_Objects[obj_num].mesh_idx; + return; + } + } +} diff --git a/src/game/overlay.h b/src/game/overlay.h index 3e4e6c7..2d38de2 100644 --- a/src/game/overlay.h +++ b/src/game/overlay.h @@ -11,3 +11,4 @@ void __cdecl Overlay_MakeAmmoString(char *string); void __cdecl Overlay_DrawAmmoInfo(void); void __cdecl Overlay_InitialisePickUpDisplay(void); void __cdecl Overlay_DrawPickups(const bool pickup_state); +void __cdecl Overlay_AddDisplayPickup(int16_t obj_num); diff --git a/src/global/funcs.h b/src/global/funcs.h index 85d8238..53b44f4 100644 --- a/src/global/funcs.h +++ b/src/global/funcs.h @@ -203,7 +203,6 @@ #define InitialiseHair ((void __cdecl (*)(void))0x00420EA0) #define HairControl ((void __cdecl (*)(int32_t in_cutscene))0x00420F20) #define DrawHair ((void __cdecl (*)(void))0x00421920) -#define Overlay_AddDisplayPickup ((void __cdecl (*)(int16_t obj_num))0x00421F60) #define Overlay_DisplayModeInfo ((void __cdecl (*)(char* string))0x00421FD0) #define Overlay_DrawModeInfo ((void __cdecl (*)(void))0x00422050) #define Display_Inventory ((int32_t __cdecl (*)(int32_t inventory_mode))0x00422080) diff --git a/src/inject_exec.c b/src/inject_exec.c index dde38ab..32775e7 100644 --- a/src/inject_exec.c +++ b/src/inject_exec.c @@ -243,6 +243,7 @@ static void Inject_Overlay(void) INJECT(1, 0x00421CF0, Overlay_DrawAmmoInfo); INJECT(1, 0x00421E40, Overlay_InitialisePickUpDisplay); INJECT(1, 0x00421E60, Overlay_DrawPickups); + INJECT(1, 0x00421F60, Overlay_AddDisplayPickup); } static void Inject_Random(void)