Skip to content

Commit

Permalink
Compatibility fix for GetDisplayMode
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuanx committed Aug 3, 2024
1 parent e10f1a3 commit 7bb3158
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Tip: If the game does not utilize DirectDraw at all, or if the game already supp

# Revisions:

v.2024.08.04
- Compatibility fix for GetDisplayMode.

v.2023.08.04
- Export DirectDrawEnumerateExA.

Expand Down
10 changes: 10 additions & 0 deletions dd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ namespace dd
{
PROLOGUE;
HRESULT hResult = This->dd1->lpVtbl->GetDisplayMode( This->dd1, lpDDSurfaceDesc );
if (dx::enabled && (lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT)) {
lpDDSurfaceDesc->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = dx::bpp == 8 ? DDPF_RGB | DDPF_PALETTEINDEXED8 : DDPF_RGB;
lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = dx::bpp;
lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = dx::bpp == 8 ? 0 : (dx::bpp == 16 ? 0xF800 : 0xFF0000);
lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = dx::bpp == 8 ? 0 : (dx::bpp == 16 ? 0x07E0 : 0x00FF00);
lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = dx::bpp == 8 ? 0 : (dx::bpp == 16 ? 0x001F : 0x0000FF);
lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask = 0;
}
// TODO: May need to fix lPitch too.
INFO("GetDisplayMode %08X\n", This->dd1);
EPILOGUE( hResult );
}
Expand Down

0 comments on commit 7bb3158

Please sign in to comment.