From 027a0f83dc46721d5d9452444f2e61fe49a07949 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 9 Jun 2024 14:18:18 +0200 Subject: [PATCH] port WinVidGetDisplayModes --- docs/progress.svg | 16 ++++++++-------- docs/progress.txt | 2 +- src/decomp/decomp.c | 15 +++++++++++++++ src/decomp/decomp.h | 1 + src/global/funcs.h | 1 - src/inject_exec.c | 1 + 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/docs/progress.svg b/docs/progress.svg index 81fd682..e7cbc7e 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -69,10 +69,10 @@ Tomb2.exe progress according to the physical function order: -41.13% (501) · 56.40% (687) · 0% (0) · 2.46% (30) +41.22% (502) · 56.32% (686) · 0% (0) · 2.46% (30) - - + + @@ -929,7 +929,7 @@ bool __cdecl WinVidGoWindowed(int32_t width, int32_t height, DISPLAY_MODE *dispMode); void __cdecl WinVidSetDisplayAdapter(DISPLAY_ADAPTER *disp_adapter); bool __thiscall CompareVideoModes(const DISPLAY_MODE *mode1, const DISPLAY_MODE *mode2); -bool __cdecl WinVidGetDisplayModes(void); +bool __cdecl WinVidGetDisplayModes(void); HRESULT __stdcall EnumDisplayModesCallback(LPDDSDESC lpDDSurfaceDesc, LPVOID lpContext); bool __cdecl WinVidInit(void); bool __cdecl WinVidGetDisplayAdapters(void); @@ -1298,10 +1298,10 @@ Tomb2.exe progress according to the function sizes: -38.07% · 61.60% · 0% · 0.33% +38.10% · 61.58% · 0% · 0.33% - - + + @@ -2084,7 +2084,7 @@ bool __cdecl DDrawCreate(LPGUID lpGUID); void __cdecl Lara_State_UWDeath(ITEM_INFO *item, COLL_INFO *coll); void __cdecl InitialiseLOTarray(void); -bool __cdecl WinVidGetDisplayModes(void); +bool __cdecl WinVidGetDisplayModes(void); void __cdecl Item_InitialiseArray(int32_t num_items); void __cdecl Lara_State_Extra_DinoKill(ITEM_INFO *item, COLL_INFO *coll); int32_t __cdecl Lara_Fallen(ITEM_INFO *item, COLL_INFO *coll); diff --git a/docs/progress.txt b/docs/progress.txt index eb50768..4f203e2 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -3041,7 +3041,7 @@ typedef struct { 0x004457B0 0x010B +R bool __cdecl WinVidGoWindowed(int32_t width, int32_t height, DISPLAY_MODE *dispMode); 0x004458C0 0x00D5 +R void __cdecl WinVidSetDisplayAdapter(DISPLAY_ADAPTER *disp_adapter); 0x004459A0 0x0045 +R bool __thiscall CompareVideoModes(const DISPLAY_MODE *mode1, const DISPLAY_MODE *mode2); -0x004459F0 0x0053 -R bool __cdecl WinVidGetDisplayModes(void); +0x004459F0 0x0053 +R bool __cdecl WinVidGetDisplayModes(void); 0x00445A50 0x03B1 -R HRESULT __stdcall EnumDisplayModesCallback(LPDDSDESC lpDDSurfaceDesc, LPVOID lpContext); 0x00445E10 0x0040 -R bool __cdecl WinVidInit(void); 0x00445E50 0x00AF -R bool __cdecl WinVidGetDisplayAdapters(void); diff --git a/src/decomp/decomp.c b/src/decomp/decomp.c index bc23a33..b66f4b2 100644 --- a/src/decomp/decomp.c +++ b/src/decomp/decomp.c @@ -2199,3 +2199,18 @@ bool __thiscall CompareVideoModes( } return false; } + +bool __cdecl WinVidGetDisplayModes(void) +{ + for (DISPLAY_ADAPTER_NODE *adapter = g_DisplayAdapterList.head; adapter; + adapter = adapter->next) { + DDrawCreate(adapter->body.adapter_guid_ptr); + ShowDDrawGameWindow(false); + g_DDraw->lpVtbl->EnumDisplayModes( + g_DDraw, DDEDM_STANDARDVGAMODES, NULL, (LPVOID)&adapter->body, + EnumDisplayModesCallback); + HideDDrawGameWindow(); + DDrawRelease(); + } + return true; +} diff --git a/src/decomp/decomp.h b/src/decomp/decomp.h index 4a311c6..d51a673 100644 --- a/src/decomp/decomp.h +++ b/src/decomp/decomp.h @@ -106,3 +106,4 @@ void __cdecl GameWindowCalculateSizeFromClient(int *width, int *height); void __cdecl GameWindowCalculateSizeFromClientByZero(int *width, int *height); bool __thiscall CompareVideoModes( const DISPLAY_MODE *mode1, const DISPLAY_MODE *mode2); +bool __cdecl WinVidGetDisplayModes(void); diff --git a/src/global/funcs.h b/src/global/funcs.h index 9950213..304bf0f 100644 --- a/src/global/funcs.h +++ b/src/global/funcs.h @@ -443,7 +443,6 @@ #define ControlLavaBlob ((void __cdecl (*)(int16_t fx_num))0x00442F40) #define GiantYetiControl ((void __cdecl (*)(int16_t item_num))0x00443050) #define YetiControl ((void __cdecl (*)(int16_t item_num))0x00443350) -#define WinVidGetDisplayModes ((bool __cdecl (*)(void))0x004459F0) #define EnumDisplayModesCallback ((HRESULT __stdcall (*)(LPDDSDESC lpDDSurfaceDesc, LPVOID lpContext))0x00445A50) #define WinVidInit ((bool __cdecl (*)(void))0x00445E10) #define WinVidGetDisplayAdapters ((bool __cdecl (*)(void))0x00445E50) diff --git a/src/inject_exec.c b/src/inject_exec.c index c5e83cd..f6acd68 100644 --- a/src/inject_exec.c +++ b/src/inject_exec.c @@ -150,6 +150,7 @@ static void Inject_Decomp(const bool enable) INJECT(enable, 0x00444C70, GameWindowCalculateSizeFromClient); INJECT(enable, 0x00444CF0, GameWindowCalculateSizeFromClientByZero); INJECT(enable, 0x004459A0, CompareVideoModes); + INJECT(enable, 0x004459F0, WinVidGetDisplayModes); } static void Inject_Background(const bool enable)