From aae173486070968da8e29a3c8d29a83c3868f7ea Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 17 Jun 2023 13:49:25 +0200 Subject: [PATCH 1/5] implement GetPrimaryBitDepth --- LEGO1/mxdirectdraw.cpp | 20 ++++++++++++++++++-- LEGO1/mxdirectdraw.h | 2 -- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/LEGO1/mxdirectdraw.cpp b/LEGO1/mxdirectdraw.cpp index 2cd60b55..635c7bd8 100644 --- a/LEGO1/mxdirectdraw.cpp +++ b/LEGO1/mxdirectdraw.cpp @@ -2,6 +2,9 @@ #include "mxdirectdraw.h" +int g_paletteIndexed8 = 0; +BOOL DAT_10100c70 = 0; + HRESULT MxDirectDraw::SetEntries() { HRESULT ret; @@ -49,11 +52,24 @@ void MxDirectDraw::FUN_1009e830(char *error_msg, HRESULT ret) int MxDirectDraw::GetPrimaryBitDepth() { + DWORD dwRGBBitCount; LPDIRECTDRAW pDDraw; + DDSURFACEDESC ddsd; - DirectDrawCreate(NULL, &pDDraw, NULL); + HRESULT result = DirectDrawCreate(NULL, &pDDraw, NULL); + dwRGBBitCount = 0; + if (!result) + { + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = 108; - return 0; + pDDraw->GetDisplayMode(&ddsd); + dwRGBBitCount = ddsd.ddpfPixelFormat.dwRGBBitCount; + g_paletteIndexed8 = (ddsd.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) != 0; + pDDraw->Release(); + } + + return dwRGBBitCount; } int MxDirectDraw::Pause(int param_1) diff --git a/LEGO1/mxdirectdraw.h b/LEGO1/mxdirectdraw.h index 4f69de01..e2c70c95 100644 --- a/LEGO1/mxdirectdraw.h +++ b/LEGO1/mxdirectdraw.h @@ -32,6 +32,4 @@ class MxDirectDraw }; -BOOL DAT_10100c70 = 0; - #endif // MXDIRECTDRAW_H From 3a8cb2a50c6f48f17a7bc89314dd96b49dbf8f9f Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 17 Jun 2023 13:57:53 +0200 Subject: [PATCH 2/5] use sizeof(ddsd) instead --- LEGO1/mxdirectdraw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGO1/mxdirectdraw.cpp b/LEGO1/mxdirectdraw.cpp index 635c7bd8..b68968bc 100644 --- a/LEGO1/mxdirectdraw.cpp +++ b/LEGO1/mxdirectdraw.cpp @@ -61,7 +61,7 @@ int MxDirectDraw::GetPrimaryBitDepth() if (!result) { memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = 108; + ddsd.dwSize = sizeof(ddsd); pDDraw->GetDisplayMode(&ddsd); dwRGBBitCount = ddsd.ddpfPixelFormat.dwRGBBitCount; From d9f10fe67b52bde8591e8b199dc45eb4804bb4af Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 17 Jun 2023 15:03:59 +0200 Subject: [PATCH 3/5] name m_unk84c --- LEGO1/mxdirectdraw.cpp | 4 ++-- LEGO1/mxdirectdraw.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LEGO1/mxdirectdraw.cpp b/LEGO1/mxdirectdraw.cpp index b68968bc..fbf2b4c3 100644 --- a/LEGO1/mxdirectdraw.cpp +++ b/LEGO1/mxdirectdraw.cpp @@ -85,7 +85,7 @@ int MxDirectDraw::Pause(int param_1) return 0; } - if (m_unk84c) { + if (m_fullScreen) { if (!FlipToGDISurface()) { return 0; } @@ -112,7 +112,7 @@ HRESULT MxDirectDraw::FUN_1009e750() { HRESULT ret; - if (m_unk84c && m_unk848) { + if (m_fullScreen && m_unk848) { if (m_ddpal) { ret = m_ddpal->SetEntries(0, 0, 256, m_pal0); if (ret != DD_OK) { diff --git a/LEGO1/mxdirectdraw.h b/LEGO1/mxdirectdraw.h index e2c70c95..bf31d5ad 100644 --- a/LEGO1/mxdirectdraw.h +++ b/LEGO1/mxdirectdraw.h @@ -25,7 +25,7 @@ class MxDirectDraw PALETTEENTRY m_pal1[256]; // +0x42c HWND hWindow; // +0x83c long m_unk848; - long m_unk84c; + BOOL m_fullScreen; void (*m_unk85c)(char *, HRESULT, long); // error handler or logger? long m_unk864; long m_unk86c; From ab0f319ef40f53a533774829f8d05f80c4ca9263 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 17 Jun 2023 15:15:04 +0200 Subject: [PATCH 4/5] use BOOL --- LEGO1/mxdirectdraw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGO1/mxdirectdraw.cpp b/LEGO1/mxdirectdraw.cpp index fbf2b4c3..a2b22779 100644 --- a/LEGO1/mxdirectdraw.cpp +++ b/LEGO1/mxdirectdraw.cpp @@ -2,7 +2,7 @@ #include "mxdirectdraw.h" -int g_paletteIndexed8 = 0; +BOOL g_paletteIndexed8 = 0; BOOL DAT_10100c70 = 0; HRESULT MxDirectDraw::SetEntries() From 779be534641149de2731299accaed398b37530bd Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 17 Jun 2023 15:24:32 +0200 Subject: [PATCH 5/5] name m_unk848; it's also ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8 --- LEGO1/mxdirectdraw.cpp | 4 ++-- LEGO1/mxdirectdraw.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LEGO1/mxdirectdraw.cpp b/LEGO1/mxdirectdraw.cpp index a2b22779..2afabda9 100644 --- a/LEGO1/mxdirectdraw.cpp +++ b/LEGO1/mxdirectdraw.cpp @@ -9,7 +9,7 @@ HRESULT MxDirectDraw::SetEntries() { HRESULT ret; - if (m_unk848) { + if (m_paletteIndexed8) { if (m_ddpal) { ret = m_ddpal->SetEntries(0, 0, 256, m_pal1); if (ret != DD_OK) { @@ -112,7 +112,7 @@ HRESULT MxDirectDraw::FUN_1009e750() { HRESULT ret; - if (m_fullScreen && m_unk848) { + if (m_fullScreen && m_paletteIndexed8) { if (m_ddpal) { ret = m_ddpal->SetEntries(0, 0, 256, m_pal0); if (ret != DD_OK) { diff --git a/LEGO1/mxdirectdraw.h b/LEGO1/mxdirectdraw.h index bf31d5ad..b372cc83 100644 --- a/LEGO1/mxdirectdraw.h +++ b/LEGO1/mxdirectdraw.h @@ -24,7 +24,7 @@ class MxDirectDraw PALETTEENTRY m_pal0[256]; // +0x2c PALETTEENTRY m_pal1[256]; // +0x42c HWND hWindow; // +0x83c - long m_unk848; + BOOL m_paletteIndexed8; BOOL m_fullScreen; void (*m_unk85c)(char *, HRESULT, long); // error handler or logger? long m_unk864;