port S_Audio_Sample_GetAdapter

This commit is contained in:
Marcin Kurczewski 2023-10-04 21:28:11 +02:00
parent 704162f430
commit e018fd2310
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
8 changed files with 57 additions and 28 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">2.67% (32)</tspan> · <tspan class="known">94.92% (1139)</tspan> · <tspan class="todo">0.67% (8)</tspan> · <tspan class="unused">1.75% (21)</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">2.75% (33)</tspan> · <tspan class="known">94.83% (1138)</tspan> · <tspan class="todo">0.67% (8)</tspan> · <tspan class="unused">1.75% (21)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="19.92" height="6" x="0" y="0" class="decompiled"/>
<rect width="709.03" height="6" x="19.92" y="0" class="known"/>
<rect width="20.54" height="6" x="0" y="0" class="decompiled"/>
<rect width="708.40" height="6" x="20.54" y="0" class="known"/>
<rect width="4.98" height="6" x="728.95" y="0" class="todo"/>
<rect width="13.07" height="6" x="733.93" y="0" class="unused"/>
</g>
@ -970,7 +970,7 @@
<rect width="12" height="12" x="600" y="255" class="unused"><title>sub_447B30</title></rect>
<rect width="12" height="12" x="615" y="255" class="unused"><title>sub_447B40</title></rect>
<rect width="12" height="12" x="630" y="255" class="unused"><title>sub_447B90</title></rect>
<rect width="12" height="12" x="645" y="255" class="known"><title>struct SOUND_ADAPTER_NODE *__cdecl S_Audio_Sample_GetAdapter(GUID *guid);</title></rect>
<rect width="12" height="12" x="645" y="255" class="decompiled"><title>const struct SOUND_ADAPTER_NODE *__cdecl S_Audio_Sample_GetAdapter(GUID *guid);</title></rect>
<rect width="12" height="12" x="660" y="255" class="known"><title>void __cdecl S_Audio_Sample_CloseAllTracks(void);</title></rect>
<rect width="12" height="12" x="675" y="255" class="known"><title>bool __cdecl S_Audio_Sample_Load(int32_t sample_id, LPWAVEFORMATEX format, const void *data, int32_t data_size);</title></rect>
<rect width="12" height="12" x="690" y="255" class="known"><title>bool __cdecl S_Audio_Sample_IsTrackPlaying(int32_t track_id);</title></rect>
@ -1281,10 +1281,10 @@
</g>
<g transform="translate(0 531)">
<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">2.94%</tspan> · <tspan class="known">96.73%</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">2.96%</tspan> · <tspan class="known">96.71%</tspan> · <tspan class="todo">0.02%</tspan> · <tspan class="unused">0.31%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="21.98" height="6" x="0" y="0" class="decompiled"/>
<rect width="722.56" height="6" x="21.98" y="0" class="known"/>
<rect width="22.14" height="6" x="0" y="0" class="decompiled"/>
<rect width="722.40" height="6" x="22.14" y="0" class="known"/>
<rect width="0.13" height="6" x="744.54" y="0" class="todo"/>
<rect width="2.33" height="6" x="744.67" y="0" class="unused"/>
</g>
@ -2105,7 +2105,7 @@
<rect width="4.53" height="4.70" x="632.93" y="339.91" class="known"><title>int32_t __cdecl CalculateWindowWidth(int32_t width, int32_t height);</title></rect>
<rect width="4.53" height="4.70" x="632.93" y="347.60" class="known"><title>DISPLAY_ADAPTER_NODE *__cdecl WinVidGetDisplayAdapter(GUID *lpGuid);</title></rect>
<rect width="4.53" height="4.70" x="632.93" y="355.30" class="known"><title>DISPLAY_MODE *__thiscall InsertDisplayModeInListHead(DISPLAY_MODE_LIST *modeList);</title></rect>
<rect width="4.47" height="4.76" x="640.46" y="253.42" class="known"><title>struct SOUND_ADAPTER_NODE *__cdecl S_Audio_Sample_GetAdapter(GUID *guid);</title></rect>
<rect width="4.47" height="4.76" x="640.46" y="253.42" class="decompiled"><title>const struct SOUND_ADAPTER_NODE *__cdecl S_Audio_Sample_GetAdapter(GUID *guid);</title></rect>
<rect width="4.47" height="4.76" x="647.93" y="253.42" class="known"><title>void __cdecl WinStopFMV(bool isPlayback);</title></rect>
<rect width="4.47" height="4.76" x="655.40" y="253.42" class="decompiled"><title>int32_t __fastcall Math_Atan(int32_t x, int32_t y);</title></rect>
<rect width="4.36" height="4.76" x="662.87" y="253.42" class="known"><title>int32_t __cdecl Creature_Activate(int16_t item_num);</title></rect>

Before

Width:  |  Height:  |  Size: 356 KiB

After

Width:  |  Height:  |  Size: 356 KiB

View File

@ -42,7 +42,7 @@ typedef struct DISPLAY_MODE_NODE {
typedef struct DISPLAY_MODE_LIST {
struct DISPLAY_MODE_NODE *head;
struct DISPLAY_MODE_NODE *tail;
DWORD dwCount;
DWORD count;
} DISPLAY_MODE_LIST;
typedef struct STRING_FLAGGED {
@ -85,12 +85,12 @@ typedef struct DISPLAY_ADAPTER_NODE {
typedef struct DISPLAY_ADAPTER_LIST {
struct DISPLAY_ADAPTER_NODE *head;
struct DISPLAY_ADAPTER_NODE *tail;
DWORD dwCount;
DWORD count;
} DISPLAY_ADAPTER_LIST;
typedef struct SOUND_ADAPTER {
GUID *lpAdapterGuid;
GUID adapterGuid;
GUID *adapter_guid_ptr;
GUID adapter_guid;
STRING_FLAGGED description;
STRING_FLAGGED module;
} SOUND_ADAPTER;
@ -104,7 +104,7 @@ typedef struct SOUND_ADAPTER_NODE {
typedef struct SOUND_ADAPTER_LIST {
struct SOUND_ADAPTER_NODE *head;
struct SOUND_ADAPTER_NODE *tail;
DWORD dwCount;
DWORD count;
} SOUND_ADAPTER_LIST;
typedef struct JOYSTICK {
@ -123,7 +123,7 @@ typedef struct JOYSTICK_NODE {
typedef struct JOYSTICK_LIST {
struct JOYSTICK_LIST *head;
struct JOYSTICK_LIST *tail;
DWORD dwCount;
DWORD count;
} JOYSTICK_LIST;
typedef enum RENDER_MODE {
@ -1854,7 +1854,7 @@ typedef struct CINE_FRAME {
00447B30 00000018 x sub_447B30
00447B40 00000039 x sub_447B40
00447B90 0000002F x sub_447B90
00447BC0 00000048 - struct SOUND_ADAPTER_NODE *__cdecl S_Audio_Sample_GetAdapter(GUID *guid);
00447BC0 00000048 + const struct SOUND_ADAPTER_NODE *__cdecl S_Audio_Sample_GetAdapter(GUID *guid);
00447C10 0000002E - void __cdecl S_Audio_Sample_CloseAllTracks(void);
00447C40 0000010E - bool __cdecl S_Audio_Sample_Load(int32_t sample_id, LPWAVEFORMATEX format, const void *data, int32_t data_size);
00447D50 00000045 - bool __cdecl S_Audio_Sample_IsTrackPlaying(int32_t track_id);

View File

@ -84,6 +84,7 @@ dll_sources = [
'src/log.c',
'src/main_dll.c',
'src/memory.c',
'src/specific/s_audio_sample.c',
'src/specific/s_filesystem.c',
'src/specific/s_flagged_string.c',
]

View File

@ -852,7 +852,6 @@
#define TempVideoRemove ((void __cdecl (*)(void))0x004479D0)
#define S_FadeInInventory ((void __cdecl (*)(BOOL isFade))0x00447A10)
#define S_FadeOutInventory ((void __cdecl (*)(BOOL isFade))0x00447A50)
#define S_Audio_Sample_GetAdapter ((struct SOUND_ADAPTER_NODE *__cdecl (*)(GUID *guid))0x00447BC0)
#define S_Audio_Sample_CloseAllTracks ((void __cdecl (*)(void))0x00447C10)
#define S_Audio_Sample_Load ((bool __cdecl (*)(int32_t sample_id, LPWAVEFORMATEX format, const void *data, int32_t data_size))0x00447C40)
#define S_Audio_Sample_IsTrackPlaying ((bool __cdecl (*)(int32_t track_id))0x00447D50)

View File

@ -75,7 +75,7 @@ typedef struct DISPLAY_MODE_NODE {
typedef struct DISPLAY_MODE_LIST {
struct DISPLAY_MODE_NODE *head;
struct DISPLAY_MODE_NODE *tail;
DWORD dwCount;
DWORD count;
} DISPLAY_MODE_LIST;
typedef struct STRING_FLAGGED {
@ -116,28 +116,28 @@ typedef struct DISPLAY_ADAPTER_NODE {
} DISPLAY_ADAPTER_NODE;
typedef struct DISPLAY_ADAPTER_LIST {
struct DisplayAdapterNode_t *head;
struct DisplayAdapterNode_t *tail;
DWORD dwCount;
struct DISPLAY_ADAPTER_NODE *head;
struct DISPLAY_ADAPTER_NODE *tail;
DWORD count;
} DISPLAY_ADAPTER_LIST;
typedef struct SOUND_ADAPTER {
GUID *lpAdapterGuid;
GUID adapterGuid;
GUID *adapter_guid_ptr;
GUID adapter_guid;
STRING_FLAGGED description;
STRING_FLAGGED module;
} SOUND_ADAPTER;
typedef struct SOUND_ADAPTER_NODE {
struct SoundAdapterNode_t *next;
struct SoundAdapterNode_t *previous;
struct SOUND_ADAPTER_NODE *next;
struct SOUND_ADAPTER_NODE *previous;
SOUND_ADAPTER body;
} SOUND_ADAPTER_NODE;
typedef struct SOUND_ADAPTER_LIST {
struct SoundAdapterNode_t *head;
struct SoundAdapterNode_t *tail;
DWORD dwCount;
struct SOUND_ADAPTER_NODE *head;
struct SOUND_ADAPTER_NODE *tail;
DWORD count;
} SOUND_ADAPTER_LIST;
typedef struct JOYSTICK {
@ -156,7 +156,7 @@ typedef struct JOYSTICK_NODE {
typedef struct JOYSTICK_LIST {
struct JOYSTICK_LIST *head;
struct JOYSTICK_LIST *tail;
DWORD dwCount;
DWORD count;
} JOYSTICK_LIST;
typedef enum RENDER_MODE {

View File

@ -6,6 +6,7 @@
#include "game/shell.h"
#include "game/sound.h"
#include "inject_util.h"
#include "specific/s_audio_sample.h"
#include "specific/s_flagged_string.h"
static void Inject_Camera(void);
@ -13,6 +14,7 @@ static void Inject_Math(void);
static void Inject_Matrix(void);
static void Inject_Shell(void);
static void Inject_Sound(void);
static void Inject_S_Audio_Sample(void);
static void Inject_S_FlaggedString(void);
static void Inject_Camera(void)
@ -70,6 +72,11 @@ static void Inject_S_FlaggedString(void)
INJECT(1, 0x00446100, S_FlaggedString_InitAdapter);
}
static void Inject_S_Audio_Sample(void)
{
INJECT(1, 0x00447BC0, S_Audio_Sample_GetAdapter);
}
void Inject_Exec(void)
{
Inject_Camera();
@ -78,5 +85,6 @@ void Inject_Exec(void)
Inject_Shell();
Inject_Sound();
Inject_S_Audio_Sample();
Inject_S_FlaggedString();
}

View File

@ -0,0 +1,16 @@
#include "global/vars.h"
#include "specific/s_audio_sample.h"
const struct SOUND_ADAPTER_NODE *__cdecl S_Audio_Sample_GetAdapter(GUID *guid)
{
if (guid != NULL) {
for (const struct SOUND_ADAPTER_NODE *adapter = g_SoundAdapterList.head;
adapter; adapter = adapter->next) {
if (!memcmp(&adapter->body.adapter_guid, guid, sizeof(GUID))) {
return adapter;
}
}
}
return g_PrimarySoundAdapter;
}

View File

@ -0,0 +1,5 @@
#pragma once
#include "global/types.h"
const struct SOUND_ADAPTER_NODE *__cdecl S_Audio_Sample_GetAdapter(GUID *guid);