diff --git a/docs/progress.svg b/docs/progress.svg
index 0e6a8d8..22127ca 100644
--- a/docs/progress.svg
+++ b/docs/progress.svg
@@ -69,10 +69,10 @@
Tomb2.exe progress according to the physical function order:
-30.87% (376) · 66.67% (812) · 0.57% (7) · 1.89% (23)
+30.95% (377) · 66.58% (811) · 0.57% (7) · 1.89% (23)
-
-
+
+
@@ -959,7 +959,7 @@
sub_447160
sub_447170
sub_4471C0
-bool __cdecl DInputCreate(void);
+bool __cdecl DInputCreate(void);
void __cdecl DInputRelease(void);
void __cdecl WinInReadKeyboard(LPVOID lpInputData);
DWORD __cdecl WinInReadJoystick(int32_t *x, int32_t *y);
@@ -1299,10 +1299,10 @@
Tomb2.exe progress according to the function sizes:
-28.83% · 70.85% · 0.02% · 0.31%
+28.84% · 70.84% · 0.02% · 0.31%
-
-
+
+
@@ -2373,7 +2373,7 @@
void __cdecl Inv_RingMotionRotation(struct RING_INFO *ring, int16_t rotation, int16_t target);
void __cdecl DrawMovableBlock(struct ITEM_INFO *item);
void __cdecl WinVidFreeWindow(void);
-bool __cdecl DInputCreate(void);
+bool __cdecl DInputCreate(void);
bool __cdecl HWR_Init(void);
void __cdecl Lara_InitialiseLoad(int16_t item_num);
void __cdecl init_game_malloc(void);
diff --git a/docs/progress.txt b/docs/progress.txt
index 4a29882..c98e90c 100644
--- a/docs/progress.txt
+++ b/docs/progress.txt
@@ -2613,7 +2613,7 @@ typedef enum GAME_OBJECT_ID {
00447160 00000018 x sub_447160
00447170 00000039 x sub_447170
004471C0 0000002F x sub_4471C0
-004471F0 00000022 -R bool __cdecl DInputCreate(void);
+004471F0 00000022 +R bool __cdecl DInputCreate(void);
00447220 0000001A -R void __cdecl DInputRelease(void);
00447240 0000005A -R void __cdecl WinInReadKeyboard(LPVOID lpInputData);
004472A0 000000F3 -R DWORD __cdecl WinInReadJoystick(int32_t *x, int32_t *y);
@@ -3233,3 +3233,4 @@ typedef enum GAME_OBJECT_ID {
00526314 - int16_t g_CineFrameIdx;
00526320 - struct CAMERA_INFO g_Camera;
005263CC - struct BOX_INFO *g_Boxes;
+004D855C - LPDIRECTINPUT g_DInput;
diff --git a/src/decomp/decomp.c b/src/decomp/decomp.c
index 00151c0..2704c9c 100644
--- a/src/decomp/decomp.c
+++ b/src/decomp/decomp.c
@@ -5,8 +5,10 @@
#include "global/const.h"
#include "global/funcs.h"
#include "global/vars.h"
+#include "lib/dinput.h"
#include "specific/s_audio_sample.h"
+#include
#include
int32_t __cdecl GameInit(void)
@@ -343,3 +345,8 @@ void __cdecl Screenshot(LPDDS screen)
}
}
}
+
+bool __cdecl DInputCreate(void)
+{
+ return SUCCEEDED(DirectInputCreate(g_GameModule, 1280, &g_DInput, NULL));
+}
diff --git a/src/decomp/decomp.h b/src/decomp/decomp.h
index 90a3ca8..61cb0ea 100644
--- a/src/decomp/decomp.h
+++ b/src/decomp/decomp.h
@@ -18,3 +18,4 @@ size_t __cdecl CompPCX(
size_t __cdecl EncodeLinePCX(const uint8_t *src, int32_t width, uint8_t *dst);
size_t __cdecl EncodePutPCX(uint8_t value, uint8_t num, uint8_t *buffer);
void __cdecl Screenshot(LPDDS screen);
+bool __cdecl DInputCreate(void);
diff --git a/src/global/funcs.h b/src/global/funcs.h
index 03e510e..2d6edd3 100644
--- a/src/global/funcs.h
+++ b/src/global/funcs.h
@@ -563,7 +563,6 @@
#define InsertDisplayMode ((DISPLAY_MODE *__thiscall (*)(DISPLAY_MODE_LIST *modeList, DISPLAY_MODE_NODE *before))0x00446FF0)
#define InsertDisplayModeInListHead ((DISPLAY_MODE *__thiscall (*)(DISPLAY_MODE_LIST *modeList))0x00447010)
#define InsertDisplayModeInListTail ((DISPLAY_MODE *__thiscall (*)(DISPLAY_MODE_LIST *modeList))0x00447060)
-#define DInputCreate ((bool __cdecl (*)(void))0x004471F0)
#define DInputRelease ((void __cdecl (*)(void))0x00447220)
#define WinInReadKeyboard ((void __cdecl (*)(LPVOID lpInputData))0x00447240)
#define WinInReadJoystick ((DWORD __cdecl (*)(int32_t *x, int32_t *y))0x004472A0)
diff --git a/src/global/vars.h b/src/global/vars.h
index 487ee5b..dca2975 100644
--- a/src/global/vars.h
+++ b/src/global/vars.h
@@ -186,6 +186,7 @@
#define g_FullScreenBPP (*(int32_t*)0x004D8370)
#define g_FullScreenVGA (*(int32_t*)0x004D8374)
#define g_IsGameToExit (*(uint8_t*)0x004D8378)
+#define g_DInput (*(LPDIRECTINPUT*)0x004D855C)
#define g_ScreenSizer (*(int32_t*)0x004D8568)
#define g_IsVidSizeLock (*(int32_t*)0x004D856C)
#define g_SampleFreqs (*(DWORD(*)[256])0x004D8570)
diff --git a/src/inject_exec.c b/src/inject_exec.c
index b3ebaf8..1deffee 100644
--- a/src/inject_exec.c
+++ b/src/inject_exec.c
@@ -53,6 +53,7 @@ static void Inject_S_FlaggedString(void);
static void Inject_Decomp(void)
{
+ INJECT(1, 0x004471F0, DInputCreate);
INJECT(1, 0x004498C0, DecodeErrorMessage);
INJECT(1, 0x0044E4E0, RenderErrorBox);
INJECT(1, 0x0044E520, WinMain);
diff --git a/src/lib/dinput.h b/src/lib/dinput.h
new file mode 100644
index 0000000..f3bb875
--- /dev/null
+++ b/src/lib/dinput.h
@@ -0,0 +1,8 @@
+#pragma once
+
+#include
+
+#define DirectInputCreate \
+ ((HRESULT(__stdcall *)( \
+ HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT * lplpDirectInput, \
+ LPUNKNOWN punkOuter))0x00457CC0)