port Overlay_DrawAirBar

This commit is contained in:
Marcin Kurczewski 2023-11-17 12:26:03 +01:00
parent 82a6a54624
commit 4e74dd5ab7
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
8 changed files with 80 additions and 14 deletions

View File

@ -69,10 +69,10 @@
</g>
<g transform="translate(0 116)">
<text x="0" y="7.50">Tomb2.exe progress according to the physical function order:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">29.39% (358)</tspan> · <tspan class="known">68.14% (830)</tspan> · <tspan class="todo">0.66% (8)</tspan> · <tspan class="unused">1.81% (22)</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">29.47% (359)</tspan> · <tspan class="known">68.06% (829)</tspan> · <tspan class="todo">0.66% (8)</tspan> · <tspan class="unused">1.81% (22)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="219.56" height="6" x="0" y="0" class="decompiled"/>
<rect width="509.04" height="6" x="219.56" y="0" class="known"/>
<rect width="220.17" height="6" x="0" y="0" class="decompiled"/>
<rect width="508.43" height="6" x="220.17" y="0" class="known"/>
<rect width="4.91" height="6" x="728.60" y="0" class="todo"/>
<rect width="13.49" height="6" x="733.51" y="0" class="unused"/>
</g>
@ -395,7 +395,7 @@
<rect width="12" height="12" x="225" y="90" class="decompiled"><title>void __cdecl Overlay_DrawAssaultTimer(void);</title></rect>
<rect width="12" height="12" x="240" y="90" class="decompiled"><title>void __cdecl Overlay_DrawGameInfo(bool pickup_state);</title></rect>
<rect width="12" height="12" x="255" y="90" class="decompiled"><title>void __cdecl Overlay_DrawHealthBar(bool flash_state);</title></rect>
<rect width="12" height="12" x="270" y="90" class="known"><title>void __cdecl Overlay_DrawAirBar(bool flash_state);</title></rect>
<rect width="12" height="12" x="270" y="90" class="decompiled"><title>void __cdecl Overlay_DrawAirBar(bool flash_state);</title></rect>
<rect width="12" height="12" x="285" y="90" class="known"><title>void __cdecl Overlay_MakeAmmoString(char *string);</title></rect>
<rect width="12" height="12" x="300" y="90" class="known"><title>void __cdecl Overlay_DrawAmmoInfo(void);</title></rect>
<rect width="12" height="12" x="315" y="90" class="known"><title>void __cdecl Overlay_InitialisePickUpDisplay(void);</title></rect>
@ -1299,10 +1299,10 @@
</g>
<g transform="translate(0 546)">
<text x="0" y="7.50">Tomb2.exe progress according to the function sizes:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">27.95%</tspan> · <tspan class="known">71.72%</tspan> · <tspan class="todo">0.02%</tspan> · <tspan class="unused">0.31%</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">27.99%</tspan> · <tspan class="known">71.68%</tspan> · <tspan class="todo">0.02%</tspan> · <tspan class="unused">0.31%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="208.79" height="6" x="0" y="0" class="decompiled"/>
<rect width="535.77" height="6" x="208.79" y="0" class="known"/>
<rect width="209.12" height="6" x="0" y="0" class="decompiled"/>
<rect width="535.44" height="6" x="209.12" y="0" class="known"/>
<rect width="0.13" height="6" x="744.56" y="0" class="todo"/>
<rect width="2.31" height="6" x="744.69" y="0" class="unused"/>
</g>
@ -1857,7 +1857,7 @@
<rect width="8.17" height="8.29" x="545.84" y="277.09" class="known"><title>void __cdecl WarriorSparkleTrail(struct ITEM_INFO *item);</title></rect>
<rect width="8.17" height="8.29" x="545.84" y="288.38" class="known"><title>void __cdecl CreateBackBuffer(void);</title></rect>
<rect width="8.17" height="8.29" x="545.84" y="299.68" class="known"><title>bool __cdecl CreateTexturePageSurface(TEXPAGE_DESC *desc);</title></rect>
<rect width="8.17" height="8.22" x="545.84" y="310.97" class="known"><title>void __cdecl Overlay_DrawAirBar(bool flash_state);</title></rect>
<rect width="8.17" height="8.22" x="545.84" y="310.97" class="decompiled"><title>void __cdecl Overlay_DrawAirBar(bool flash_state);</title></rect>
<rect width="8.17" height="8.22" x="545.84" y="322.19" class="known"><title>void __cdecl AdjustTextureUVs(bool reset_uv_add);</title></rect>
<rect width="8.17" height="8.15" x="545.84" y="333.42" class="decompiled"><title>void __cdecl Output_DrawScreenSprite2D(int32_t sx, int32_t sy, int32_t sz, int32_t scale_h, int32_t scale_v, int16_t sprite_idx, int16_t shade, uint16_t flags);</title></rect>
<rect width="8.17" height="8.15" x="545.84" y="344.56" class="known"><title>void __cdecl Lara_Control_Cutscene(int16_t item_num);</title></rect>

Before

Width:  |  Height:  |  Size: 367 KiB

After

Width:  |  Height:  |  Size: 367 KiB

View File

@ -433,6 +433,12 @@ typedef struct __unaligned REQUEST_INFO {
uint32_t render_height;
} REQUEST_INFO;
typedef struct ASSAULT_STATS {
uint32_t best_time[10];
uint32_t best_finish[10];
uint32_t finish_count;
} ASSAULT_STATS;
typedef struct SORT_ITEM {
int32_t _0;
int32_t _1;
@ -1982,7 +1988,7 @@ typedef enum GAME_OBJECT_ID {
004219D0 00000145 + void __cdecl Overlay_DrawAssaultTimer(void);
00421B20 00000045 + void __cdecl Overlay_DrawGameInfo(bool pickup_state);
00421B70 000000AB + void __cdecl Overlay_DrawHealthBar(bool flash_state);
00421C20 00000097 * void __cdecl Overlay_DrawAirBar(bool flash_state);
00421C20 00000097 + void __cdecl Overlay_DrawAirBar(bool flash_state);
00421CC0 00000028 - void __cdecl Overlay_MakeAmmoString(char *string);
00421CF0 00000132 * void __cdecl Overlay_DrawAmmoInfo(void);
00421E40 00000015 - void __cdecl Overlay_InitialisePickUpDisplay(void);
@ -3082,8 +3088,30 @@ typedef enum GAME_OBJECT_ID {
004D780C - int8_t g_GF_StartGame;
004D7920 + BOOL g_FlashState;
004D7924 + int32_t g_FlashCounter;
004D7928 + int32_t g_OldHitPoints;
004D792C - TEXTSTRING *g_AmmoTextInfo;
004D7930 - TEXTSTRING *g_DisplayModeTextInfo;
004D7934 - DWORD g_DisplayModeInfoTimer;
004D7938 - UINT16 g_InvMainCurrent;
004D793C - UINT16 g_InvKeyObjectsCount;
004D7940 - UINT16 g_InvKeysCurrent;
004D7944 - UINT16 g_InvOptionCurrent;
004D7954 - TEXTSTRING* g_InvRingText;
004D795C - TEXTSTRING* g_InvUpArrow1;
004D7960 - TEXTSTRING* g_InvUpArrow2;
004D7964 - TEXTSTRING* g_InvDownArrow1;
004D7968 - TEXTSTRING* g_InvDownArrow2;
004D796C - uint32_t g_InputDB;
004D7978 - uint16_t g_IsInventoryActive;
004D7978 - uint16_t g_IsInventoryActive;
004D79A0 - BOOL g_InvDemoMode;
004D79B4 - BOOL g_IsInvOptionsDelay;
004D79B8 - int32_t g_InvOptionsDelayCounter;
004D79BC - uint16_t g_SoundOptionLine;
004D79C0 - struct REQUEST_INFO g_StatsRequester;
004D7BD8 - struct ASSAULT_STATS g_Assault;
004D7C38 - int32_t g_LevelItemCount;
004D7C3C - int32_t g_HealthBarTimer;
004D7C80 - int32_t g_SoundTrackIds[128];
004D7EBC - LPDIRECT3DDEVICE2 g_D3DDev;
004D7EE4 - bool g_IsGameWindowCreated;
@ -3200,5 +3228,3 @@ typedef enum GAME_OBJECT_ID {
00526314 - int16_t g_CineFrameIdx;
00526320 - struct CAMERA_INFO g_Camera;
005263CC - struct BOX_INFO *g_Boxes;
004D7928 + int32_t g_OldHitPoints;
004D7C3C - int32_t g_HealthBarTimer;

View File

@ -10,6 +10,8 @@
#include <stdio.h>
#define FLASH_FRAMES 5
#define AMMO_X (-10)
#define AMMO_Y 35
static int32_t m_OldHitPoints = -1;
static bool m_FlashState = false;
@ -114,5 +116,21 @@ void __cdecl Overlay_DrawHealthBar(const bool flash_state)
if (timer <= 0 && g_Lara.gun_status != LGS_READY) {
return;
}
S_DrawHealthBar(hit_points / 10);
S_DrawHealthBar(hit_points * 100 / LARA_MAX_HITPOINTS);
}
void __cdecl Overlay_DrawAirBar(const bool flash_state)
{
if (g_Lara.water_status != LWS_UNDERWATER
&& g_Lara.water_status != LWS_SURFACE) {
return;
}
int32_t air = g_Lara.air;
CLAMP(air, 0, LARA_MAX_AIR);
if (air <= 450 && !flash_state) {
S_DrawAirBar(0);
} else {
S_DrawAirBar(air * 100 / LARA_MAX_AIR);
}
}

View File

@ -6,3 +6,4 @@ bool __cdecl Overlay_FlashCounter(void);
void __cdecl Overlay_DrawAssaultTimer(void);
void __cdecl Overlay_DrawGameInfo(bool pickup_state);
void __cdecl Overlay_DrawHealthBar(bool flash_state);
void __cdecl Overlay_DrawAirBar(bool flash_state);

View File

@ -79,6 +79,7 @@
#define LARA_DEFLECT_ANGLE (5 * PHD_DEGREE) // = 910
#define LARA_HANG_ANGLE (35 * PHD_DEGREE) // = 6370
#define LARA_VAULT_ANGLE (30 * PHD_DEGREE) // = 5460
#define LARA_MAX_AIR 1800
#define LARA_MAX_HITPOINTS 1000
#define CAM_HANG_ANGLE 0

View File

@ -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_DrawAirBar ((void __cdecl (*)(bool flash_state))0x00421C20)
#define Overlay_MakeAmmoString ((void __cdecl (*)(char *string))0x00421CC0)
#define Overlay_DrawAmmoInfo ((void __cdecl (*)(void))0x00421CF0)
#define Overlay_InitialisePickUpDisplay ((void __cdecl (*)(void))0x00421E40)

View File

@ -8,7 +8,7 @@
// clang-format off
#define g_PerspectiveDistance (*(uint32_t*)0x00464060) // = 0x3000000
#define g_PolyDrawRoutines (*((void(__cdecl *(*)[9])(const int16_t *))0x00464068))
#define g_RhwFactor (*(float*)0x0046408C) // = 0x14000000.p0
#define g_RhwFactor (*(float*)0x0046408C) // = 335544320.0f
#define g_CineTrackID (*(int32_t*)0x004640B0) // = 1
#define g_CineTickRate (*(int32_t*)0x004640B8) // = 0x8000
#define g_CD_TrackID (*(int16_t*)0x004640BC) // = -1
@ -131,7 +131,27 @@
#define g_IsAssaultTimerActive (*(BOOL*)0x004D77E4)
#define g_IsMonkAngry (*(BOOL*)0x004D77E8)
#define g_GF_StartGame (*(int8_t*)0x004D780C)
#define g_AmmoTextInfo (*(TEXTSTRING **)0x004D792C)
#define g_DisplayModeTextInfo (*(TEXTSTRING **)0x004D7930)
#define g_DisplayModeInfoTimer (*(DWORD*)0x004D7934)
#define g_InvMainCurrent (*(UINT16*)0x004D7938)
#define g_InvKeyObjectsCount (*(UINT16*)0x004D793C)
#define g_InvKeysCurrent (*(UINT16*)0x004D7940)
#define g_InvOptionCurrent (*(UINT16*)0x004D7944)
#define g_InvRingText (*(TEXTSTRING**)0x004D7954)
#define g_InvUpArrow1 (*(TEXTSTRING**)0x004D795C)
#define g_InvUpArrow2 (*(TEXTSTRING**)0x004D7960)
#define g_InvDownArrow1 (*(TEXTSTRING**)0x004D7964)
#define g_InvDownArrow2 (*(TEXTSTRING**)0x004D7968)
#define g_InputDB (*(uint32_t*)0x004D796C)
#define g_IsInventoryActive (*(uint16_t*)0x004D7978)
#define g_IsInventoryActive (*(uint16_t*)0x004D7978)
#define g_InvDemoMode (*(BOOL*)0x004D79A0)
#define g_IsInvOptionsDelay (*(BOOL*)0x004D79B4)
#define g_InvOptionsDelayCounter (*(int32_t*)0x004D79B8)
#define g_SoundOptionLine (*(uint16_t*)0x004D79BC)
#define g_StatsRequester (*(struct REQUEST_INFO*)0x004D79C0)
#define g_Assault (*(struct ASSAULT_STATS*)0x004D7BD8)
#define g_LevelItemCount (*(int32_t*)0x004D7C38)
#define g_HealthBarTimer (*(int32_t*)0x004D7C3C)
#define g_SoundTrackIds (*(int32_t(*)[128])0x004D7C80)

View File

@ -238,6 +238,7 @@ static void Inject_Overlay(void)
INJECT(1, 0x004219D0, Overlay_DrawAssaultTimer);
INJECT(1, 0x00421B20, Overlay_DrawGameInfo);
INJECT(1, 0x00421B70, Overlay_DrawHealthBar);
INJECT(1, 0x00421C20, Overlay_DrawAirBar);
}
static void Inject_Random(void)