port Overlay_FlashCounter

This commit is contained in:
Marcin Kurczewski 2023-11-17 10:26:21 +01:00
parent 1b6dd2085d
commit 6eb5bee09a
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
7 changed files with 45 additions and 10 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.06% (354)</tspan> · <tspan class="known">68.47% (834)</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.15% (355)</tspan> · <tspan class="known">68.39% (833)</tspan> · <tspan class="todo">0.66% (8)</tspan> · <tspan class="unused">1.81% (22)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="217.11" height="6" x="0" y="0" class="decompiled"/>
<rect width="511.49" height="6" x="217.11" y="0" class="known"/>
<rect width="217.72" height="6" x="0" y="0" class="decompiled"/>
<rect width="510.88" height="6" x="217.72" 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>
@ -391,7 +391,7 @@
<rect width="12" height="12" x="165" y="90" class="known"><title>void __cdecl InitialiseHair(void);</title></rect>
<rect width="12" height="12" x="180" y="90" class="known"><title>void __cdecl HairControl(int32_t in_cutscene);</title></rect>
<rect width="12" height="12" x="195" y="90" class="known"><title>void __cdecl DrawHair(void);</title></rect>
<rect width="12" height="12" x="210" y="90" class="known"><title>int32_t __cdecl Overlay_FlashCounter(void);</title></rect>
<rect width="12" height="12" x="210" y="90" class="decompiled"><title>int32_t __cdecl Overlay_FlashCounter(void);</title></rect>
<rect width="12" height="12" x="225" y="90" class="known"><title>void __cdecl Overlay_DrawAssaultTimer(void);</title></rect>
<rect width="12" height="12" x="240" y="90" class="known"><title>void __cdecl Overlay_DrawGameInfo(int32_t timed);</title></rect>
<rect width="12" height="12" x="255" y="90" class="known"><title>void __cdecl Overlay_DrawHealthBar(int32_t flash_state);</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.77%</tspan> · <tspan class="known">71.90%</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.78%</tspan> · <tspan class="known">71.89%</tspan> · <tspan class="todo">0.02%</tspan> · <tspan class="unused">0.31%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="207.46" height="6" x="0" y="0" class="decompiled"/>
<rect width="537.10" height="6" x="207.46" y="0" class="known"/>
<rect width="207.55" height="6" x="0" y="0" class="decompiled"/>
<rect width="537.01" height="6" x="207.55" 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>
@ -2305,7 +2305,7 @@
<rect width="3.24" height="3.12" x="675.50" y="365.77" class="decompiled"><title>void __cdecl S_Audio_Sample_CloseAllTracks(void);</title></rect>
<rect width="3.24" height="3.12" x="675.50" y="371.88" class="known"><title>void __cdecl S_DrawScreenFBox(int32_t sx, int32_t sy, int32_t z, int32_t width, int32_t height, BYTE color_idx, const struct GOURAUD_FILL *gour, uint16_t flags);</title></rect>
<rect width="3.31" height="2.92" x="681.74" y="309.52" class="known"><title>void __cdecl Demo_GetInput(void);</title></rect>
<rect width="3.31" height="2.92" x="688.05" y="309.52" class="known"><title>int32_t __cdecl Overlay_FlashCounter(void);</title></rect>
<rect width="3.31" height="2.92" x="688.05" y="309.52" class="decompiled"><title>int32_t __cdecl Overlay_FlashCounter(void);</title></rect>
<rect width="3.31" height="2.92" x="694.36" y="309.52" class="known"><title>void __cdecl WinInStart(void);</title></rect>
<rect width="3.17" height="2.92" x="700.66" y="309.52" class="known"><title>void __cdecl ChandelierFX(struct ITEM_INFO *item);</title></rect>
<rect width="3.17" height="2.92" x="706.83" y="309.52" class="known"><title>void __cdecl Overlay_DrawModeInfo(void);</title></rect>

Before

Width:  |  Height:  |  Size: 367 KiB

After

Width:  |  Height:  |  Size: 367 KiB

View File

@ -1969,7 +1969,7 @@ typedef enum GAME_OBJECT_ID {
00421920 00000076 -R void __cdecl DrawHair(void);
# game/health.c
004219A0 0000002D - int32_t __cdecl Overlay_FlashCounter(void);
004219A0 0000002D + int32_t __cdecl Overlay_FlashCounter(void);
004219D0 00000145 - void __cdecl Overlay_DrawAssaultTimer(void);
00421B20 00000045 - void __cdecl Overlay_DrawGameInfo(int32_t timed);
00421B70 000000AB - void __cdecl Overlay_DrawHealthBar(int32_t flash_state);
@ -3046,6 +3046,8 @@ typedef enum GAME_OBJECT_ID {
004D77A0 - int32_t g_LOSNumRooms = 0;
004D77AC - int32_t g_IsDemoLevelType;
004D780C - int8_t g_GF_StartGame;
004D7920 + BOOL g_FlashState;
004D7924 + int32_t g_FlashCounter;
004D7978 - uint16_t g_IsInventoryActive;
004D7C38 - int32_t g_LevelItemCount;
004D7C80 - int32_t g_SoundTrackIds[128];

View File

@ -91,6 +91,7 @@ dll_sources = [
'src/game/matrix.c',
'src/game/music.c',
'src/game/output.c',
'src/game/overlay.c',
'src/game/random.c',
'src/game/shell.c',
'src/game/sound.c',

18
src/game/overlay.c Normal file
View File

@ -0,0 +1,18 @@
#include "game/overlay.h"
#define FLASH_FRAMES 5
static bool m_FlashState = false;
static int32_t m_FlashCounter = 0;
bool __cdecl Overlay_FlashCounter(void)
{
if (m_FlashCounter > 0) {
m_FlashCounter--;
return m_FlashState;
} else {
m_FlashCounter = FLASH_FRAMES;
m_FlashState = !m_FlashState;
}
return m_FlashState;
}

5
src/game/overlay.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include "global/types.h"
bool __cdecl Overlay_FlashCounter(void);

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_FlashCounter ((int32_t __cdecl (*)(void))0x004219A0)
#define Overlay_DrawAssaultTimer ((void __cdecl (*)(void))0x004219D0)
#define Overlay_DrawGameInfo ((void __cdecl (*)(int32_t timed))0x00421B20)
#define Overlay_DrawHealthBar ((void __cdecl (*)(int32_t flash_state))0x00421B70)

View File

@ -15,6 +15,7 @@
#include "game/matrix.h"
#include "game/music.h"
#include "game/output.h"
#include "game/overlay.h"
#include "game/random.h"
#include "game/shell.h"
#include "game/sound.h"
@ -34,6 +35,8 @@ static void Inject_Output(void);
static void Inject_Music(void);
static void Inject_Sound(void);
static void Inject_Overlay(void);
static void Inject_Random(void);
static void Inject_Items(void);
static void Inject_Effects(void);
static void Inject_LOS(void);
@ -229,6 +232,11 @@ static void Inject_Sound(void)
INJECT(1, 0x00455380, Sound_SetMasterVolume);
}
static void Inject_Overlay(void)
{
INJECT(1, 0x004219A0, Overlay_FlashCounter);
}
static void Inject_Random(void)
{
INJECT(1, 0x0044C970, Random_GetControl);
@ -489,6 +497,8 @@ void Inject_Exec(void)
Inject_Music();
Inject_Sound();
Inject_Overlay();
Inject_Random();
Inject_Items();
Inject_Effects();
Inject_LOS();