Merge pull request #1 from foxtacles/implement-getprimarybitdepth

implement GetPrimaryBitDepth
This commit is contained in:
MS 2023-06-17 16:52:30 -04:00 committed by GitHub
commit c4dc66a3ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 9 deletions

View File

@ -2,11 +2,14 @@
#include "mxdirectdraw.h"
BOOL g_paletteIndexed8 = 0;
BOOL DAT_10100c70 = 0;
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) {
@ -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 = sizeof(ddsd);
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)
@ -69,7 +85,7 @@ int MxDirectDraw::Pause(int param_1)
return 0;
}
if (m_unk84c) {
if (m_fullScreen) {
if (!FlipToGDISurface()) {
return 0;
}
@ -96,7 +112,7 @@ HRESULT MxDirectDraw::FUN_1009e750()
{
HRESULT ret;
if (m_unk84c && m_unk848) {
if (m_fullScreen && m_paletteIndexed8) {
if (m_ddpal) {
ret = m_ddpal->SetEntries(0, 0, 256, m_pal0);
if (ret != DD_OK) {

View File

@ -24,14 +24,12 @@ class MxDirectDraw
PALETTEENTRY m_pal0[256]; // +0x2c
PALETTEENTRY m_pal1[256]; // +0x42c
HWND hWindow; // +0x83c
long m_unk848;
long m_unk84c;
BOOL m_paletteIndexed8;
BOOL m_fullScreen;
void (*m_unk85c)(char *, HRESULT, long); // error handler or logger?
long m_unk864;
long m_unk86c;
};
BOOL DAT_10100c70 = 0;
#endif // MXDIRECTDRAW_H