From 94afdc378b7b132b3a6ad08a8fb20f4a10c68677 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 16 Oct 2023 01:02:42 +0200 Subject: [PATCH] #253 add preset for Jedi Knight Dark Forces 2 --- inc/config.h | 1 + src/IDirectDraw/IDirectDraw.c | 9 +++++---- src/config.c | 6 ++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/inc/config.h b/inc/config.h index e0d6a72..381df22 100644 --- a/inc/config.h +++ b/inc/config.h @@ -67,6 +67,7 @@ typedef struct CNCDDRAWCONFIG int custom_width; int custom_height; int min_font_size; + BOOL direct3d_passthrough; /* Hotkeys */ diff --git a/src/IDirectDraw/IDirectDraw.c b/src/IDirectDraw/IDirectDraw.c index 3bf3861..35cd482 100644 --- a/src/IDirectDraw/IDirectDraw.c +++ b/src/IDirectDraw/IDirectDraw.c @@ -8,6 +8,7 @@ #include "ddsurface.h" #include "debug.h" #include "hook.h" +#include "config.h" HRESULT __stdcall IDirectDraw__QueryInterface(IDirectDrawImpl* This, REFIID riid, LPVOID FAR* ppvObj) @@ -50,7 +51,7 @@ HRESULT __stdcall IDirectDraw__QueryInterface(IDirectDrawImpl* This, REFIID riid ret = S_OK; } - else if (IsEqualGUID(&IID_IDirect3D, riid)) + else if (IsEqualGUID(&IID_IDirect3D, riid) && !g_config.direct3d_passthrough) { IDirect3DImpl* d3d = (IDirect3DImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DImpl)); @@ -64,7 +65,7 @@ HRESULT __stdcall IDirectDraw__QueryInterface(IDirectDrawImpl* This, REFIID riid ret = S_OK; } - else if (IsEqualGUID(&IID_IDirect3D2, riid)) + else if (IsEqualGUID(&IID_IDirect3D2, riid) && !g_config.direct3d_passthrough) { IDirect3D2Impl* d3d = (IDirect3D2Impl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D2Impl)); @@ -78,7 +79,7 @@ HRESULT __stdcall IDirectDraw__QueryInterface(IDirectDrawImpl* This, REFIID riid ret = S_OK; } - else if (IsEqualGUID(&IID_IDirect3D3, riid)) + else if (IsEqualGUID(&IID_IDirect3D3, riid) && !g_config.direct3d_passthrough) { IDirect3D3Impl* d3d = (IDirect3D3Impl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D3Impl)); @@ -92,7 +93,7 @@ HRESULT __stdcall IDirectDraw__QueryInterface(IDirectDrawImpl* This, REFIID riid ret = S_OK; } - else if (IsEqualGUID(&IID_IDirect3D7, riid)) + else if (IsEqualGUID(&IID_IDirect3D7, riid) && !g_config.direct3d_passthrough) { IDirect3D7Impl* d3d = (IDirect3D7Impl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D7Impl)); diff --git a/src/config.c b/src/config.c index 9eea32d..55b0e0a 100644 --- a/src/config.c +++ b/src/config.c @@ -85,6 +85,7 @@ void cfg_load() GET_INT(g_config.custom_width, "custom_width", 0); GET_INT(g_config.custom_height, "custom_height", 0); GET_INT(g_config.min_font_size, "min_font_size", 0); + GET_BOOL(g_config.direct3d_passthrough, "direct3d_passthrough", FALSE); /* Hotkeys */ @@ -290,6 +291,7 @@ static void cfg_create_ini() "custom_width=0\n" "custom_height=0\n" "min_font_size=0\n" + "direct3d_passthrough=false\n" "\n" "\n" "\n" @@ -804,6 +806,10 @@ static void cfg_create_ini() "noactivateapp=true\n" "releasealt=true\n" "\n" + "; Jedi Knight Dark Forces 2\n" + "[JK]\n" + "direct3d_passthrough=true\n" + "\n" "; Kings Quest 8\n" "[Mask]\n" "renderer=opengl\n"