port DInputCreate

This commit is contained in:
Marcin Kurczewski 2024-03-17 23:25:38 +01:00
parent 892b9c81de
commit 9b067938a2
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
8 changed files with 28 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">30.87% (376)</tspan> · <tspan class="known">66.67% (812)</tspan> · <tspan class="todo">0.57% (7)</tspan> · <tspan class="unused">1.89% (23)</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">30.95% (377)</tspan> · <tspan class="known">66.58% (811)</tspan> · <tspan class="todo">0.57% (7)</tspan> · <tspan class="unused">1.89% (23)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="230.60" height="6" x="0" y="0" class="decompiled"/>
<rect width="498" height="6" x="230.60" y="0" class="known"/>
<rect width="231.21" height="6" x="0" y="0" class="decompiled"/>
<rect width="497.39" height="6" x="231.21" y="0" class="known"/>
<rect width="4.29" height="6" x="728.60" y="0" class="todo"/>
<rect width="14.11" height="6" x="732.89" y="0" class="unused"/>
</g>
@ -959,7 +959,7 @@
<rect width="12" height="12" x="435" y="255" class="unused"><title>sub_447160</title></rect>
<rect width="12" height="12" x="450" y="255" class="unused"><title>sub_447170</title></rect>
<rect width="12" height="12" x="465" y="255" class="unused"><title>sub_4471C0</title></rect>
<rect width="12" height="12" x="480" y="255" class="known"><title>bool __cdecl DInputCreate(void);</title></rect>
<rect width="12" height="12" x="480" y="255" class="decompiled"><title>bool __cdecl DInputCreate(void);</title></rect>
<rect width="12" height="12" x="495" y="255" class="known"><title>void __cdecl DInputRelease(void);</title></rect>
<rect width="12" height="12" x="510" y="255" class="known"><title>void __cdecl WinInReadKeyboard(LPVOID lpInputData);</title></rect>
<rect width="12" height="12" x="525" y="255" class="known"><title>DWORD __cdecl WinInReadJoystick(int32_t *x, int32_t *y);</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">28.83%</tspan> · <tspan class="known">70.85%</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">28.84%</tspan> · <tspan class="known">70.84%</tspan> · <tspan class="todo">0.02%</tspan> · <tspan class="unused">0.31%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="215.33" height="6" x="0" y="0" class="decompiled"/>
<rect width="529.23" height="6" x="215.33" y="0" class="known"/>
<rect width="215.40" height="6" x="0" y="0" class="decompiled"/>
<rect width="529.16" height="6" x="215.40" y="0" class="known"/>
<rect width="0.12" height="6" x="744.56" y="0" class="todo"/>
<rect width="2.32" height="6" x="744.68" y="0" class="unused"/>
</g>
@ -2373,7 +2373,7 @@
<rect width="2.57" height="2.07" x="698.40" y="347.76" class="known"><title>void __cdecl Inv_RingMotionRotation(struct RING_INFO *ring, int16_t rotation, int16_t target);</title></rect>
<rect width="2.57" height="2.07" x="698.40" y="352.82" class="known"><title>void __cdecl DrawMovableBlock(struct ITEM_INFO *item);</title></rect>
<rect width="2.57" height="2.07" x="698.40" y="357.89" class="known"><title>void __cdecl WinVidFreeWindow(void);</title></rect>
<rect width="2.57" height="2.07" x="698.40" y="362.95" class="known"><title>bool __cdecl DInputCreate(void);</title></rect>
<rect width="2.57" height="2.07" x="698.40" y="362.95" class="decompiled"><title>bool __cdecl DInputCreate(void);</title></rect>
<rect width="2.57" height="2.07" x="698.40" y="368.02" class="known"><title>bool __cdecl HWR_Init(void);</title></rect>
<rect width="2.57" height="1.92" x="698.40" y="373.08" class="known"><title>void __cdecl Lara_InitialiseLoad(int16_t item_num);</title></rect>
<rect width="2.33" height="2.14" x="703.97" y="327.05" class="known"><title>void __cdecl init_game_malloc(void);</title></rect>

Before

Width:  |  Height:  |  Size: 368 KiB

After

Width:  |  Height:  |  Size: 368 KiB

View File

@ -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;

View File

@ -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 <dinput.h>
#include <stdio.h>
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));
}

View File

@ -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);

View File

@ -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)

View File

@ -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)

View File

@ -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);

8
src/lib/dinput.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
#include <windows.h>
#define DirectInputCreate \
((HRESULT(__stdcall *)( \
HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT * lplpDirectInput, \
LPUNKNOWN punkOuter))0x00457CC0)