From db7781473a15c434067552b8bd6f79ac56a2ccd8 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 15 May 2025 04:51:41 +0200 Subject: [PATCH] miniwin: Clean up headers and make bitflags and enums strict (#90) --- CONFIG/MainDlg.cpp | 8 +- CONFIG/config.cpp | 8 +- .../lego/legoomni/include/legovideomanager.h | 2 +- LEGO1/mxdirectx/legodxinfo.cpp | 4 +- LEGO1/mxdirectx/mxdirect3d.cpp | 2 +- LEGO1/mxdirectx/mxdirectdraw.cpp | 2 +- LEGO1/mxdirectx/mxdirectdraw.h | 2 +- LEGO1/tgl/d3drm/mesh.cpp | 2 +- LEGO1/tgl/d3drm/meshbuilder.cpp | 2 +- miniwin/miniwin/include/bitflags.h | 48 ++++ miniwin/miniwin/include/miniwin.h | 17 +- miniwin/miniwin/include/miniwin_d3d.h | 46 ++-- miniwin/miniwin/include/miniwin_d3drm.h | 130 ++++++----- miniwin/miniwin/include/miniwin_ddraw.h | 211 ++++++++++-------- miniwin/miniwin/src/miniwin_d3drm.cpp | 14 +- miniwin/miniwin/src/miniwin_ddraw.cpp | 8 +- util/compat.h | 7 + 17 files changed, 308 insertions(+), 205 deletions(-) create mode 100644 miniwin/miniwin/include/bitflags.h diff --git a/CONFIG/MainDlg.cpp b/CONFIG/MainDlg.cpp index 853698b5..7988de56 100644 --- a/CONFIG/MainDlg.cpp +++ b/CONFIG/MainDlg.cpp @@ -140,7 +140,7 @@ void CMainDialog::OnList3DevicesSelectionChanged() LegoDeviceEnumerate* device_enumerator = currentConfigApp->m_device_enumerator; int selected = ::SendMessage(GetDlgItem(IDC_LIST_3DDEVICES)->m_hWnd, LB_GETCURSEL, 0, 0); device_enumerator->GetDevice(selected, currentConfigApp->m_driver, currentConfigApp->m_device); - if (currentConfigApp->GetHardwareDeviceColorModel()) { + if (currentConfigApp->GetHardwareDeviceColorModel() != D3DCOLOR_NONE) { GetDlgItem(IDC_CHK_DRAW_CURSOR)->EnableWindow(TRUE); } else { @@ -179,12 +179,14 @@ void CMainDialog::UpdateInterface() { currentConfigApp->ValidateSettings(); GetDlgItem(IDC_CHK_3D_VIDEO_MEMORY) - ->EnableWindow(!currentConfigApp->m_flip_surfaces && !currentConfigApp->GetHardwareDeviceColorModel()); + ->EnableWindow( + !currentConfigApp->m_flip_surfaces && currentConfigApp->GetHardwareDeviceColorModel() == D3DCOLOR_NONE + ); CheckDlgButton(IDC_CHK_FLIP_VIDEO_MEM_PAGES, currentConfigApp->m_flip_surfaces); CheckDlgButton(IDC_CHK_3D_VIDEO_MEMORY, currentConfigApp->m_3d_video_ram); BOOL full_screen = currentConfigApp->m_full_screen; currentConfigApp->AdjustDisplayBitDepthBasedOnRenderStatus(); - if (currentConfigApp->GetHardwareDeviceColorModel()) { + if (currentConfigApp->GetHardwareDeviceColorModel() != D3DCOLOR_NONE) { CheckDlgButton(IDC_CHK_DRAW_CURSOR, TRUE); } else { diff --git a/CONFIG/config.cpp b/CONFIG/config.cpp index 24339ace..134b3c5e 100644 --- a/CONFIG/config.cpp +++ b/CONFIG/config.cpp @@ -210,7 +210,7 @@ BOOL CConfigApp::IsDeviceInBasicRGBMode() const * BUG: should be: * return !GetHardwareDeviceColorModel() && (m_device->m_HELDesc.dcmColorModel & D3DCOLOR_RGB); */ - return !GetHardwareDeviceColorModel() && m_device->m_HELDesc.dcmColorModel == D3DCOLOR_RGB; + return GetHardwareDeviceColorModel() == D3DCOLOR_NONE && m_device->m_HELDesc.dcmColorModel == D3DCOLOR_RGB; } // FUNCTION: CONFIG 0x00403400 @@ -306,7 +306,7 @@ BOOL CConfigApp::ValidateSettings() is_modified = TRUE; } } - if (!GetHardwareDeviceColorModel()) { + if (GetHardwareDeviceColorModel() == D3DCOLOR_NONE) { m_draw_cursor = FALSE; is_modified = TRUE; } @@ -351,7 +351,7 @@ DWORD CConfigApp::GetConditionalDeviceRenderBitDepth() const if (IsDeviceInBasicRGBMode()) { return 0; } - if (GetHardwareDeviceColorModel()) { + if (GetHardwareDeviceColorModel() != D3DCOLOR_NONE) { return 0; } return m_device->m_HELDesc.dwDeviceRenderBitDepth & DDBD_8; @@ -360,7 +360,7 @@ DWORD CConfigApp::GetConditionalDeviceRenderBitDepth() const // FUNCTION: CONFIG 0x004037e0 DWORD CConfigApp::GetDeviceRenderBitStatus() const { - if (GetHardwareDeviceColorModel()) { + if (GetHardwareDeviceColorModel() != D3DCOLOR_NONE) { return m_device->m_HWDesc.dwDeviceRenderBitDepth & DDBD_16; } else { diff --git a/LEGO1/lego/legoomni/include/legovideomanager.h b/LEGO1/lego/legoomni/include/legovideomanager.h index 985c96f0..cd7b8973 100644 --- a/LEGO1/lego/legoomni/include/legovideomanager.h +++ b/LEGO1/lego/legoomni/include/legovideomanager.h @@ -121,7 +121,7 @@ class LegoVideoManager : public MxVideoManager { D3DRMRENDERQUALITY m_quality; // 0x578 DWORD m_shades; // 0x57c D3DRMTEXTUREQUALITY m_textureQuality; // 0x580 - DWORD m_rendermode; // 0x584 + D3DRMRENDERMODE m_rendermode; // 0x584 BOOL m_dither; // 0x588 DWORD m_bufferCount; // 0x58c }; diff --git a/LEGO1/mxdirectx/legodxinfo.cpp b/LEGO1/mxdirectx/legodxinfo.cpp index b81c2888..a00c97dc 100644 --- a/LEGO1/mxdirectx/legodxinfo.cpp +++ b/LEGO1/mxdirectx/legodxinfo.cpp @@ -180,7 +180,7 @@ int LegoDeviceEnumerate::GetBestDevice() MxDriver& driver = *it; for (list::iterator it2 = driver.m_devices.begin(); it2 != driver.m_devices.end(); it2++) { - if ((*it2).m_HWDesc.dcmColorModel) { + if ((*it2).m_HWDesc.dcmColorModel != D3DCOLOR_NONE) { return j; } else { @@ -341,7 +341,7 @@ unsigned char LegoDeviceEnumerate::FUN_1009d3d0(Direct3DDeviceInfo& p_device) return FALSE; } - if (p_device.m_HWDesc.dcmColorModel) { + if (p_device.m_HWDesc.dcmColorModel != D3DCOLOR_NONE) { if (p_device.m_HWDesc.dwDeviceZBufferBitDepth & DDBD_16 && p_device.m_HWDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE) { return TRUE; diff --git a/LEGO1/mxdirectx/mxdirect3d.cpp b/LEGO1/mxdirectx/mxdirect3d.cpp index b153ff3e..c35a3e2d 100644 --- a/LEGO1/mxdirectx/mxdirect3d.cpp +++ b/LEGO1/mxdirectx/mxdirect3d.cpp @@ -302,7 +302,7 @@ BOOL MxDirect3D::SetDevice(MxDeviceEnumerate& p_deviceEnumerate, MxDriver* p_dri if (&device == p_device) { memcpy(&d->m_guid, device.m_guid, sizeof(d->m_guid)); - if (device.m_HWDesc.dcmColorModel) { + if (device.m_HWDesc.dcmColorModel != D3DCOLOR_NONE) { d->m_flags |= MxAssignedDevice::c_hardwareMode; d->m_desc = device.m_HWDesc; } diff --git a/LEGO1/mxdirectx/mxdirectdraw.cpp b/LEGO1/mxdirectx/mxdirectdraw.cpp index 8ef07e3a..d39d0e22 100644 --- a/LEGO1/mxdirectx/mxdirectdraw.cpp +++ b/LEGO1/mxdirectx/mxdirectdraw.cpp @@ -776,7 +776,7 @@ BOOL MxDirectDraw::RestoreSurfaces() // FUNCTION: LEGO1 0x1009e5e0 // FUNCTION: BETA10 0x10122087 -BOOL MxDirectDraw::CreateZBuffer(DWORD memorytype, DWORD depth) +BOOL MxDirectDraw::CreateZBuffer(DDSCapsFlags memorytype, DWORD depth) { HRESULT result; // eax LPDIRECTDRAWSURFACE lpZBuffer; // [esp+8h] [ebp-70h] BYREF diff --git a/LEGO1/mxdirectx/mxdirectdraw.h b/LEGO1/mxdirectx/mxdirectdraw.h index 285eec5f..822ec375 100644 --- a/LEGO1/mxdirectx/mxdirectdraw.h +++ b/LEGO1/mxdirectx/mxdirectdraw.h @@ -77,7 +77,7 @@ class MxDirectDraw { BOOL DDCreateSurfaces(); HRESULT CreateDDSurface(LPDDSURFACEDESC a2, LPDIRECTDRAWSURFACE* a3, IUnknown* a4); BOOL GetDDSurfaceDesc(LPDDSURFACEDESC lpDDSurfDesc, LPDIRECTDRAWSURFACE lpDDSurf); - BOOL CreateZBuffer(DWORD memorytype, DWORD depth); + BOOL CreateZBuffer(DDSCapsFlags memorytype, DWORD depth); BOOL CreateTextSurfaces(); BOOL TextToTextSurface(const char* text, IDirectDrawSurface* pSurface, SIZE& textSizeOnSurface); diff --git a/LEGO1/tgl/d3drm/mesh.cpp b/LEGO1/tgl/d3drm/mesh.cpp index 2c6ef1f6..45cd6336 100644 --- a/LEGO1/tgl/d3drm/mesh.cpp +++ b/LEGO1/tgl/d3drm/mesh.cpp @@ -47,7 +47,7 @@ Result MeshImpl::SetTextureMappingMode(TextureMappingMode mode) return ResultVal(m_data->groupMesh->SetGroupMapping(m_data->groupIndex, D3DRMMAP_PERSPCORRECT)); } else { - return ResultVal(m_data->groupMesh->SetGroupMapping(m_data->groupIndex, 0)); + return ResultVal(m_data->groupMesh->SetGroupMapping(m_data->groupIndex, D3DRMMAP_NONE)); } } diff --git a/LEGO1/tgl/d3drm/meshbuilder.cpp b/LEGO1/tgl/d3drm/meshbuilder.cpp index be7119f3..887c6f2a 100644 --- a/LEGO1/tgl/d3drm/meshbuilder.cpp +++ b/LEGO1/tgl/d3drm/meshbuilder.cpp @@ -51,7 +51,7 @@ inline Result MeshSetTextureMappingMode(MeshImpl::MeshData* pMesh, TextureMappin return ResultVal(pMesh->groupMesh->SetGroupMapping(pMesh->groupIndex, D3DRMMAP_PERSPCORRECT)); } else { - return ResultVal(pMesh->groupMesh->SetGroupMapping(pMesh->groupIndex, 0)); + return ResultVal(pMesh->groupMesh->SetGroupMapping(pMesh->groupIndex, D3DRMMAP_NONE)); } } diff --git a/miniwin/miniwin/include/bitflags.h b/miniwin/miniwin/include/bitflags.h new file mode 100644 index 00000000..4b497a1d --- /dev/null +++ b/miniwin/miniwin/include/bitflags.h @@ -0,0 +1,48 @@ +#include + +// Enable bitwise ops only for enum classes with the ENABLE_BITMASK_OPERATORS trait +template +struct EnableBitMaskOperators { + static const bool enable = false; +}; + +#define ENABLE_BITMASK_OPERATORS(x) \ + template <> \ + struct EnableBitMaskOperators { \ + static const bool enable = true; \ + }; + +template +typename std::enable_if::enable, Enum>::type operator|(Enum lhs, Enum rhs) +{ + using underlying = typename std::underlying_type::type; + return static_cast(static_cast(lhs) | static_cast(rhs)); +} + +template +typename std::enable_if::enable, Enum&>::type operator|=(Enum& lhs, Enum rhs) +{ + lhs = lhs | rhs; + return lhs; +} + +template +typename std::enable_if::enable, Enum>::type operator&(Enum lhs, Enum rhs) +{ + using underlying = typename std::underlying_type::type; + return static_cast(static_cast(lhs) & static_cast(rhs)); +} + +template +typename std::enable_if::enable, Enum>::type operator~(Enum e) +{ + using underlying = typename std::underlying_type::type; + return static_cast(~static_cast(e)); +} + +template +typename std::enable_if::enable, Enum&>::type operator&=(Enum& lhs, Enum rhs) +{ + lhs = lhs & rhs; + return lhs; +} diff --git a/miniwin/miniwin/include/miniwin.h b/miniwin/miniwin/include/miniwin.h index af60ab90..0b750dbd 100644 --- a/miniwin/miniwin/include/miniwin.h +++ b/miniwin/miniwin/include/miniwin.h @@ -8,9 +8,8 @@ #define MAKE_HRESULT(sev, fac, code) \ ((HRESULT) (((uint32_t) (sev) << 31) | ((uint32_t) (fac) << 16) | ((uint32_t) (code)))) -// This is not the right way to make a GUID -#define DEFINE_GUID(GuidName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - const GUID GuidName = {l, w1, w2, b1 + b2 + b3 + b4 + b5 + b6 + b7 + b8} +#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}} // Remove WinAPI stuff #define CALLBACK @@ -61,7 +60,7 @@ // --- Typedefs --- typedef uint8_t BYTE, byte; typedef int32_t LONG; -typedef uint32_t ULONG, DWORD; +typedef uint32_t ULONG, DWORD, HRESULT; typedef DWORD* LPDWORD; typedef int BOOL, WINBOOL, INT; typedef unsigned int UINT; @@ -74,7 +73,7 @@ typedef void* HANDLE; typedef HANDLE HMENU, HICON, HFONT; typedef struct HINSTANCE__* HINSTANCE; typedef HANDLE HWND, HMODULE, HDC, HPALETTE, HFILE, HCURSOR; -typedef LONG HRESULT, LSTATUS, HKEY, REGSAM; +typedef LONG LSTATUS, HKEY, REGSAM; // --- Structs --- struct tagPOINT { @@ -136,10 +135,10 @@ struct PALETTEENTRY { typedef PALETTEENTRY* LPPALETTEENTRY; struct GUID { - int m_data1; - int m_data2; - int m_data3; - int m_data4; + uint32_t m_data1; + uint16_t m_data2; + uint16_t m_data3; + uint8_t m_data4[8]; }; typedef GUID* LPGUID; diff --git a/miniwin/miniwin/include/miniwin_d3d.h b/miniwin/miniwin/include/miniwin_d3d.h index 16d5a368..d31a0be7 100644 --- a/miniwin/miniwin/include/miniwin_d3d.h +++ b/miniwin/miniwin/include/miniwin_d3d.h @@ -3,19 +3,35 @@ #include "miniwin_ddraw.h" // --- Defines and Macros --- -#define D3DPAL_RESERVED 0x00000000 -#define D3DPAL_READONLY 0x00000001 -#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001 +#define D3DPAL_RESERVED 0x80 +#define D3DPAL_READONLY 0x40 + +#define DDBD_8 0x00000800 +#define DDBD_16 0x00000400 +#define DDBD_24 0x00000200 +#define DDBD_32 0x00000100 + +#define D3DDD_DEVICEZBUFFERBITDEPTH 0x00000100 // dwDeviceZBufferBitDepth is valid + +#define D3DPSHADECAPS_ALPHAFLATBLEND 0x00001000 // Supports D3DRMRENDERMODE_BLENDEDTRANSPARENCY + +#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001 // Supports perspective correction texturing + +#define D3DPTFILTERCAPS_LINEAR 0x00000002 // Supports bilinear filtering + +#define D3DCOLOR_NONE D3DCOLORMODEL::NONE +#define D3DCOLOR_RGB D3DCOLORMODEL::RGB +#define D3DCOLOR_MONO D3DCOLORMODEL::MONO // --- Enums --- -enum D3DCOLORMODEL { - D3DCOLOR_NONE, - D3DCOLOR_RGB, - D3DCOLOR_MONO +enum class D3DCOLORMODEL { + NONE = 0, + RGB = 1, + MONO = 2 }; // --- GUIDs --- -DEFINE_GUID(IID_IDirect3D2, 0x6aae1ec1, 0x662a, 0x11cf, 0x9a, 0x39, 0x00, 0xaa, 0x00, 0x6e, 0xf5, 0x5a); +DEFINE_GUID(IID_IDirect3D2, 0x6aae1ec1, 0x662a, 0x11d0, 0x88, 0x9d, 0x00, 0xaa, 0x00, 0xbb, 0xb7, 0x6a); // --- Structs --- struct D3DVECTOR { @@ -23,14 +39,14 @@ struct D3DVECTOR { }; struct D3DDEVICEDESC { - DWORD dwFlags; - DWORD dwDeviceZBufferBitDepth; - D3DCOLORMODEL dcmColorModel; - DWORD dwDeviceRenderBitDepth; + DWORD dwFlags; // D3DDD_* + DWORD dwDeviceZBufferBitDepth; // DDBD_* + D3DCOLORMODEL dcmColorModel; // D3DCOLOR_* Bit flag, but Isle think it's an enum + DWORD dwDeviceRenderBitDepth; // DDBD_* struct { - DWORD dwShadeCaps; - DWORD dwTextureCaps; - DWORD dwTextureFilterCaps; + DWORD dwShadeCaps; // D3DPSHADECAPS_* + DWORD dwTextureCaps; // D3DPTEXTURECAPS_* + DWORD dwTextureFilterCaps; // D3DPTFILTERCAPS_* } dpcTriCaps; }; typedef D3DDEVICEDESC* LPD3DDEVICEDESC; diff --git a/miniwin/miniwin/include/miniwin_d3drm.h b/miniwin/miniwin/include/miniwin_d3drm.h index 2ac59ea6..c42bab0b 100644 --- a/miniwin/miniwin/include/miniwin_d3drm.h +++ b/miniwin/miniwin/include/miniwin_d3drm.h @@ -8,86 +8,98 @@ #define D3DRM_OK DD_OK #define MAXSHORT ((short) 0x7fff) #define SUCCEEDED(hr) ((hr) >= D3DRM_OK) -#define D3DPTFILTERCAPS_LINEAR 0x00000001 -#define D3DPSHADECAPS_ALPHAFLATBLEND 0x00000100 // --- Typedefs --- -typedef DWORD D3DRMMAPPING, *LPD3DRMMAPPING; typedef float D3DVAL; typedef void* LPD3DRM_APPDATA; typedef unsigned long D3DRMGROUPINDEX; -typedef DWORD D3DRMRENDERQUALITY, *LPD3DRMRENDERQUALITY; typedef DWORD D3DCOLOR, *LPD3DCOLOR; typedef float D3DVALUE, *LPD3DVALUE; // --- Enums --- -enum D3DRMCOMBINETYPE { - D3DRMCOMBINE_REPLACE, - D3DRMCOMBINE_BEFORE, - D3DRMCOMBINE_AFTER +#define D3DRMCOMBINE_REPLACE D3DRMCOMBINETYPE::REPLACE +enum class D3DRMCOMBINETYPE { + REPLACE }; typedef D3DRMCOMBINETYPE* LPD3DRMCOMBINETYPE; -enum D3DRMPALETTEFLAGS { - D3DRMPALETTE_READONLY +#define D3DRMPALETTE_READONLY D3DRMPALETTEFLAGS::READONLY +enum class D3DRMPALETTEFLAGS { + READONLY = 1 }; typedef D3DRMPALETTEFLAGS* LPD3DRMPALETTEFLAGS; -enum D3DRMTEXTUREQUALITY { - D3DRMTEXTURE_NEAREST, - D3DRMTEXTURE_LINEAR, - D3DRMTEXTURE_MIPNEAREST, - D3DRMTEXTURE_MIPLINEAR, - D3DRMTEXTURE_LINEARMIPNEAREST, - D3DRMTEXTURE_LINEARMIPLINEAR +#define D3DRMTEXTURE_LINEAR D3DRMTEXTUREQUALITY::LINEAR +enum class D3DRMTEXTUREQUALITY { + LINEAR = 1 }; typedef D3DRMTEXTUREQUALITY* LPD3DRMTEXTUREQUALITY; -enum D3DRMRENDERMODE { - D3DRMRENDERMODE_BLENDEDTRANSPARENCY +#define D3DRMRENDERMODE_BLENDEDTRANSPARENCY D3DRMRENDERMODE::BLENDEDTRANSPARENCY +enum class D3DRMRENDERMODE { + BLENDEDTRANSPARENCY = 1 }; -enum D3DRMMappingFlag { - D3DRMMAP_WRAPU = 1, - D3DRMMAP_WRAPV = 2, - D3DRMMAP_PERSPCORRECT = 4 +#define D3DRMMAP_NONE D3DRMMAPPING::NONE +#define D3DRMMAP_PERSPCORRECT D3DRMMAPPING::PERSPCORRECT +enum class D3DRMMAPPING { + NONE = 0, + PERSPCORRECT = 4 }; +typedef D3DRMMAPPING* LPD3DRMMAPPING; -enum D3DRMLIGHTTYPE { - D3DRMLIGHT_AMBIENT, - D3DRMLIGHT_POINT, - D3DRMLIGHT_SPOT, - D3DRMLIGHT_DIRECTIONAL, - D3DRMLIGHT_PARALLELPOINT +#define D3DRMLIGHT_AMBIENT D3DRMLIGHTTYPE::AMBIENT +#define D3DRMLIGHT_POINT D3DRMLIGHTTYPE::POINT +#define D3DRMLIGHT_SPOT D3DRMLIGHTTYPE::SPOT +#define D3DRMLIGHT_DIRECTIONAL D3DRMLIGHTTYPE::DIRECTIONAL +#define D3DRMLIGHT_PARALLELPOINT D3DRMLIGHTTYPE::PARALLELPOINT +enum class D3DRMLIGHTTYPE { + AMBIENT, + POINT, + SPOT, + DIRECTIONAL, + PARALLELPOINT }; typedef D3DRMLIGHTTYPE* LPD3DRMLIGHTTYPE; -enum D3DRMMATERIALMODE { - D3DRMMATERIAL_FROMPARENT, - D3DRMMATERIAL_FROMFRAME, - D3DRMMATERIAL_FROMMESH +#define D3DRMMATERIAL_FROMMESH D3DRMMATERIALMODE::FROMMESH +#define D3DRMMATERIAL_FROMPARENT D3DRMMATERIALMODE::FROMPARENT +#define D3DRMMATERIAL_FROMFRAME D3DRMMATERIALMODE::FROMFRAME +enum class D3DRMMATERIALMODE { + FROMMESH, + FROMPARENT, + FROMFRAME }; -enum D3DRMRenderMode { - D3DRMRENDER_WIREFRAME = 0, - D3DRMRENDER_UNLITFLAT = 1, - D3DRMRENDER_FLAT = 2, - D3DRMRENDER_GOURAUD = 4, - D3DRMRENDER_PHONG = 8 -}; +#define D3DRMRENDER_WIREFRAME D3DRMRENDERQUALITY::WIREFRAME +#define D3DRMRENDER_UNLITFLAT D3DRMRENDERQUALITY::UNLITFLAT +#define D3DRMRENDER_FLAT D3DRMRENDERQUALITY::FLAT +#define D3DRMRENDER_GOURAUD D3DRMRENDERQUALITY::GOURAUD +#define D3DRMRENDER_PHONG D3DRMRENDERQUALITY::PHONG -enum D3DRMPROJECTIONTYPE { - D3DRMPROJECT_PERSPECTIVE, - D3DRMPROJECT_ORTHOGRAPHIC +enum class D3DRMRENDERQUALITY { + WIREFRAME = 64, + UNLITFLAT = 128, + FLAT = 136, + GOURAUD = 137, + PHONG = 138 +}; +typedef D3DRMRENDERQUALITY* LPD3DRMRENDERQUALITY; + +#define D3DRMPROJECT_PERSPECTIVE D3DRMPROJECTIONTYPE::PERSPECTIVE +#define D3DRMPROJECT_ORTHOGRAPHIC D3DRMPROJECTIONTYPE::ORTHOGRAPHIC +enum class D3DRMPROJECTIONTYPE { + PERSPECTIVE, + ORTHOGRAPHIC }; typedef D3DRMPROJECTIONTYPE* LPD3DRMPROJECTIONTYPE; // --- GUIDs --- -DEFINE_GUID(IID_IDirect3DRM2, 0x4516ec41, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMWinDevice, 0x0eb16e60, 0xcbf4, 0x11cf, 0xa5, 0x3c, 0x00, 0x20, 0xaf, 0x70, 0x7e, 0xfd); -DEFINE_GUID(IID_IDirect3DRMMesh, 0x4516ec78, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMMeshBuilder, 0x4516ec7b, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); -DEFINE_GUID(IID_IDirect3DRMTexture2, 0x120f30c0, 0x1629, 0x11d1, 0x94, 0x26, 0x00, 0x60, 0x97, 0x0c, 0xf4, 0x0d); +DEFINE_GUID(IID_IDirect3DRM2, 0x4516ecc8, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); +DEFINE_GUID(IID_IDirect3DRMWinDevice, 0xc5016cc0, 0xd273, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMMesh, 0xa3a80d01, 0x6e12, 0x11cf, 0xac, 0x4a, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMMeshBuilder, 0xa3a80d02, 0x6e12, 0x11cf, 0xac, 0x4a, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1); +DEFINE_GUID(IID_IDirect3DRMTexture2, 0x120f30c0, 0x1629, 0x11d0, 0x94, 0x1c, 0x00, 0x80, 0xc8, 0x0c, 0xfa, 0x7b); // --- Structs --- typedef struct D3DRMVECTOR4D { @@ -95,7 +107,8 @@ typedef struct D3DRMVECTOR4D { } D3DRMVECTOR4D; typedef struct D3DRMPALETTEENTRY { - unsigned char red, green, blue, flags; + unsigned char red, green, blue; + D3DRMPALETTEFLAGS flags; } D3DRMPALETTEENTRY; typedef struct D3DRMIMAGE { @@ -152,7 +165,8 @@ typedef IDirect3DRMTexture* LPDIRECT3DRMTEXTURE; struct IDirect3DRMTexture2 : public IDirect3DRMTexture {}; typedef IDirect3DRMTexture2* LPDIRECT3DRMTEXTURE2; -typedef struct IDirect3DRMMaterial *LPDIRECT3DRMMATERIAL, **LPLPDIRECT3DRMMATERIAL; +struct IDirect3DRMMaterial : virtual public IUnknown {}; +typedef IDirect3DRMMaterial *LPDIRECT3DRMMATERIAL, **LPLPDIRECT3DRMMATERIAL; struct IDirect3DRMMesh : virtual public IUnknown { virtual HRESULT Clone(int flags, GUID iid, void** object) = 0; @@ -176,12 +190,12 @@ struct IDirect3DRMMesh : virtual public IUnknown { virtual HRESULT SetGroupColorRGB(int groupIndex, float r, float g, float b) = 0; virtual HRESULT SetGroupTexture(int groupIndex, const IDirect3DRMTexture* texture) = 0; virtual HRESULT SetGroupMaterial(int groupIndex, IDirect3DRMMaterial* material) = 0; - virtual HRESULT SetGroupMapping(int groupIndex, int mapping) = 0; + virtual HRESULT SetGroupMapping(D3DRMGROUPINDEX groupIndex, D3DRMMAPPING mapping) = 0; virtual HRESULT SetGroupQuality(int groupIndex, D3DRMRENDERQUALITY quality) = 0; virtual HRESULT SetVertices(int groupIndex, int offset, int count, D3DRMVERTEX* vertices) = 0; virtual HRESULT GetGroupTexture(int groupIndex, LPDIRECT3DRMTEXTURE* texture) = 0; - virtual HRESULT GetGroupMapping(int groupIndex) = 0; - virtual HRESULT GetGroupQuality(int groupIndex) = 0; + virtual D3DRMMAPPING GetGroupMapping(int groupIndex) = 0; + virtual D3DRMRENDERQUALITY GetGroupQuality(int groupIndex) = 0; virtual HRESULT GetGroupColor(D3DRMGROUPINDEX index) = 0; virtual HRESULT GetVertices(int groupIndex, int startIndex, int count, D3DRMVERTEX* vertices) = 0; }; @@ -209,7 +223,7 @@ struct IDirect3DRMFrame : virtual public IUnknown { virtual HRESULT SetSceneBackgroundRGB(float r, float g, float b) = 0; virtual HRESULT AddLight(IDirect3DRMLight* light) = 0; virtual HRESULT GetLights(IDirect3DRMLightArray** lightArray) = 0; - virtual HRESULT AddTransform(int combine, D3DRMMATRIX4D matrix) = 0; + virtual HRESULT AddTransform(D3DRMCOMBINETYPE combine, D3DRMMATRIX4D matrix) = 0; virtual HRESULT GetPosition(int index, D3DVECTOR* position) = 0; virtual HRESULT AddVisual(IDirect3DRMVisual* visual) = 0; virtual HRESULT DeleteVisual(IDirect3DRMVisual* visual) = 0; @@ -293,14 +307,14 @@ struct IDirect3DRMDevice2 : virtual public IUnknown { virtual HRESULT GetBufferCount() = 0; virtual HRESULT SetShades(unsigned long shadeCount) = 0; virtual HRESULT GetShades() = 0; - virtual HRESULT SetQuality(int quality) = 0; - virtual HRESULT GetQuality() = 0; + virtual HRESULT SetQuality(D3DRMRENDERQUALITY quality) = 0; + virtual D3DRMRENDERQUALITY GetQuality() = 0; virtual HRESULT SetDither(int dither) = 0; virtual HRESULT GetDither() = 0; virtual HRESULT SetTextureQuality(D3DRMTEXTUREQUALITY quality) = 0; virtual D3DRMTEXTUREQUALITY GetTextureQuality() = 0; - virtual HRESULT SetRenderMode(int mode) = 0; - virtual HRESULT GetRenderMode() = 0; + virtual HRESULT SetRenderMode(D3DRMRENDERMODE mode) = 0; + virtual D3DRMRENDERMODE GetRenderMode() = 0; virtual HRESULT Update() = 0; virtual HRESULT GetViewports(IDirect3DRMViewportArray** ppViewportArray) = 0; }; diff --git a/miniwin/miniwin/include/miniwin_ddraw.h b/miniwin/miniwin/include/miniwin_ddraw.h index 7613c8d0..f8d0e580 100644 --- a/miniwin/miniwin/include/miniwin_ddraw.h +++ b/miniwin/miniwin/include/miniwin_ddraw.h @@ -1,146 +1,106 @@ #pragma once +#include "bitflags.h" #include "miniwin.h" #define _FACDD 0x876 -#define DDCKEY_SRCBLT 0x00000001 +#define DDCKEY_SRCBLT 0x00000008 #define DDENUMRET_OK 1 -#define DDFLIP_WAIT 0x00000004 -#define DISCL_BACKGROUND 0x00000002 +#define DDFLIP_WAIT 0x00000001 +#define DISCL_BACKGROUND 0x00000008 #define PC_NOCOLLAPSE 0x04 #define DDCAPS2_CERTIFIED 0x00000001 // DirectDraw Surface Description flags -#define DDSD_CAPS 0x00000001 -#define DDSD_HEIGHT 0x00000002 -#define DDSD_WIDTH 0x00000004 -#define DDSD_BACKBUFFERCOUNT 0x00000010 -#define DDSD_ZBUFFERBITDEPTH 0x00000040 -#define DDSD_PIXELFORMAT 0x00001000 +#define DDSD_CAPS DDSurfaceDescFlags::CAPS +#define DDSD_HEIGHT DDSurfaceDescFlags::HEIGHT +#define DDSD_WIDTH DDSurfaceDescFlags::WIDTH +#define DDSD_BACKBUFFERCOUNT DDSurfaceDescFlags::BACKBUFFERCOUNT +#define DDSD_ZBUFFERBITDEPTH DDSurfaceDescFlags::ZBUFFERBITDEPTH +#define DDSD_PIXELFORMAT DDSurfaceDescFlags::PIXELFORMAT -#define DDCAPS_OVERLAYCANTCLIP 0x00001000L -#define DDCAPS_OVERLAY 0x20000000L +#define DDSCAPS_BACKBUFFER DDSCapsFlags::BACKBUFFER +#define DDSCAPS_COMPLEX DDSCapsFlags::COMPLEX +#define DDSCAPS_FLIP DDSCapsFlags::FLIP +#define DDSCAPS_OFFSCREENPLAIN DDSCapsFlags::OFFSCREENPLAIN +#define DDSCAPS_PRIMARYSURFACE DDSCapsFlags::PRIMARYSURFACE +#define DDSCAPS_SYSTEMMEMORY DDSCapsFlags::SYSTEMMEMORY +#define DDSCAPS_TEXTURE DDSCapsFlags::TEXTURE +#define DDSCAPS_3DDEVICE DDSCapsFlags::D3DDEVICE +#define DDSCAPS_VIDEOMEMORY DDSCapsFlags::VIDEOMEMORY +#define DDSCAPS_ZBUFFER DDSCapsFlags::ZBUFFER -#define DDCAPS2_NONLOCALVIDMEM 0x00000004 +#define DDPCAPS_8BIT DDPixelCaps::_8BIT +#define DDPCAPS_INITIALIZE DDPixelCaps::INITIALIZE +#define DDPCAPS_ALLOW256 DDPixelCaps::ALLOW256 -#define DDSCAPS_PRIMARYSURFACE 0x00000001 -#define DDSCAPS_3DDEVICE 0x00000002 -#define DDSCAPS_BACKBUFFER 0x00000004 -#define DDSCAPS_VIDEOMEMORY 0x00000008 -#define DDSCAPS_SYSTEMMEMORY 0x00000010 -#define DDSCAPS_OFFSCREENPLAIN 0x00000020 -#define DDSCAPS_FLIP 0x00000040 -#define DDSCAPS_COMPLEX 0x00000080 -#define DDSCAPS_ZBUFFER 0x00000100 +#define DDBLT_KEYSRC 0x00008000 +#define DDBLT_ROP 0x00020000 -#define DDPCAPS_8BIT 0x00000001 -#define DDPCAPS_INITIALIZE 0x00000002 -#define DDPCAPS_ALLOW256 0x00000004 - -#define DDBLT_KEYSRC 0x00000002 -#define DDBLT_ROP 0x00000010 - -#define D3DDD_DEVICEZBUFFERBITDEPTH 0x00000010 -#define DDPF_PALETTEINDEXED8 0x00000020 -#define DDPF_RGB 0x00000040 +#define DDPF_PALETTEINDEXED8 0x00000020 // The texture uses an 8 bit palette +#define DDPF_RGB 0x00000040 // dwRGBBitCount, dwRBitMask, dwGBitMask, and dwBBitMask is valid #define DDBLTFAST_SRCCOLORKEY 0x00000001 #define DDBLTFAST_WAIT 0x00000010 -#define DDLOCK_WAIT 0x00000001L -#define DDLOCK_SURFACEMEMORYPTR 0x00000002L +#define DDLOCK_WAIT 0x00000001 +#define DDLOCK_SURFACEMEMORYPTR 0x00000000 -#define DDBD_8 0x00000001 -#define DDBD_16 0x00000002 -#define DDBD_24 0x00000004 -#define DDBD_32 0x00000005 - -#define DDSCL_NORMAL 0x00000000 +#define DDSCL_NORMAL 0x00000008 #define DDSCL_FULLSCREEN 0x00000001 -#define DDSCL_EXCLUSIVE 0x00000002 -#define DDSCL_ALLOWREBOOT 0x00000080 +#define DDSCL_ALLOWREBOOT 0x00000002 +#define DDSCL_EXCLUSIVE 0x00000010 #define MAKE_DDHRESULT(code) MAKE_HRESULT(1, _FACDD, code) #define DD_OK S_OK -#define DDERR_SURFACELOST MAKE_DDHRESULT(450) -#define DDERR_WASSTILLDRAWING MAKE_DDHRESULT(540) -#define DDERR_SURFACEBUSY MAKE_DDHRESULT(430) #define DDERR_ALREADYINITIALIZED MAKE_DDHRESULT(5) -#define DDERR_BLTFASTCANTCLIP MAKE_DDHRESULT(574) #define DDERR_CANNOTATTACHSURFACE MAKE_DDHRESULT(10) #define DDERR_CANNOTDETACHSURFACE MAKE_DDHRESULT(20) -#define DDERR_CANTCREATEDC MAKE_DDHRESULT(585) -#define DDERR_CANTDUPLICATE MAKE_DDHRESULT(583) -#define DDERR_CLIPPERISUSINGHWND MAKE_DDHRESULT(567) -#define DDERR_COLORKEYNOTSET MAKE_DDHRESULT(400) #define DDERR_CURRENTLYNOTAVAIL MAKE_DDHRESULT(40) -#define DDERR_DIRECTDRAWALREADYCREATED MAKE_DDHRESULT(562) #define DDERR_EXCEPTION MAKE_DDHRESULT(55) -#define DDERR_EXCLUSIVEMODEALREADYSET MAKE_DDHRESULT(581) -#define DDERR_GENERIC MAKE_DDHRESULT(1) +#define DDERR_GENERIC 0x80004005 #define DDERR_HEIGHTALIGN MAKE_DDHRESULT(90) -#define DDERR_HWNDALREADYSET MAKE_DDHRESULT(571) -#define DDERR_HWNDSUBCLASSED MAKE_DDHRESULT(570) -#define DDERR_IMPLICITLYCREATED MAKE_DDHRESULT(588) #define DDERR_INCOMPATIBLEPRIMARY MAKE_DDHRESULT(95) #define DDERR_INVALIDCAPS MAKE_DDHRESULT(100) #define DDERR_INVALIDCLIPLIST MAKE_DDHRESULT(110) -#define DDERR_INVALIDDIRECTDRAWGUID MAKE_DDHRESULT(561) #define DDERR_INVALIDMODE MAKE_DDHRESULT(120) #define DDERR_INVALIDOBJECT MAKE_DDHRESULT(130) -#define DDERR_INVALIDPARAMS MAKE_DDHRESULT(140) +#define DDERR_INVALIDPARAMS 0x80070057 #define DDERR_INVALIDPIXELFORMAT MAKE_DDHRESULT(145) -#define DDERR_INVALIDPOSITION MAKE_DDHRESULT(579) #define DDERR_INVALIDRECT MAKE_DDHRESULT(150) #define DDERR_LOCKEDSURFACES MAKE_DDHRESULT(160) #define DDERR_NO3D MAKE_DDHRESULT(170) #define DDERR_NOALPHAHW MAKE_DDHRESULT(180) -#define DDERR_NOBLTHW MAKE_DDHRESULT(575) #define DDERR_NOCLIPLIST MAKE_DDHRESULT(205) -#define DDERR_NOCLIPPERATTACHED MAKE_DDHRESULT(568) #define DDERR_NOCOLORCONVHW MAKE_DDHRESULT(210) -#define DDERR_NOCOLORKEYHW MAKE_DDHRESULT(220) -#define DDERR_NOCOLORKEY MAKE_DDHRESULT(215) #define DDERR_NOCOOPERATIVELEVELSET MAKE_DDHRESULT(212) -#define DDERR_NODC MAKE_DDHRESULT(586) -#define DDERR_NODDROPSHW MAKE_DDHRESULT(576) -#define DDERR_NODIRECTDRAWHW MAKE_DDHRESULT(563) -#define DDERR_NOEMULATION MAKE_DDHRESULT(565) +#define DDERR_NOCOLORKEY MAKE_DDHRESULT(215) +#define DDERR_NOCOLORKEYHW MAKE_DDHRESULT(220) #define DDERR_NOEXCLUSIVEMODE MAKE_DDHRESULT(225) #define DDERR_NOFLIPHW MAKE_DDHRESULT(230) #define DDERR_NOGDI MAKE_DDHRESULT(240) -#define DDERR_NOHWND MAKE_DDHRESULT(569) #define DDERR_NOMIRRORHW MAKE_DDHRESULT(250) -#define DDERR_NOOVERLAYDEST MAKE_DDHRESULT(578) +#define DDERR_NOTFOUND MAKE_DDHRESULT(255) #define DDERR_NOOVERLAYHW MAKE_DDHRESULT(260) -#define DDERR_NOPALETTEATTACHED MAKE_DDHRESULT(572) -#define DDERR_NOPALETTEHW MAKE_DDHRESULT(573) #define DDERR_NORASTEROPHW MAKE_DDHRESULT(280) #define DDERR_NOROTATIONHW MAKE_DDHRESULT(290) #define DDERR_NOSTRETCHHW MAKE_DDHRESULT(310) -#define DDERR_NOT4BITCOLORINDEX MAKE_DDHRESULT(317) #define DDERR_NOT4BITCOLOR MAKE_DDHRESULT(316) +#define DDERR_NOT4BITCOLORINDEX MAKE_DDHRESULT(317) #define DDERR_NOT8BITCOLOR MAKE_DDHRESULT(320) -#define DDERR_NOTAOVERLAYSURFACE MAKE_DDHRESULT(580) #define DDERR_NOTEXTUREHW MAKE_DDHRESULT(330) -#define DDERR_NOTFLIPPABLE MAKE_DDHRESULT(582) -#define DDERR_NOTFOUND MAKE_DDHRESULT(255) -#define DDERR_NOTLOCKED MAKE_DDHRESULT(584) -#define DDERR_NOTPALETTIZED MAKE_DDHRESULT(589) #define DDERR_NOVSYNCHW MAKE_DDHRESULT(335) #define DDERR_NOZBUFFERHW MAKE_DDHRESULT(340) #define DDERR_NOZOVERLAYHW MAKE_DDHRESULT(350) #define DDERR_OUTOFCAPS MAKE_DDHRESULT(360) -#define DDERR_OUTOFMEMORY MAKE_DDHRESULT(370) +#define DDERR_OUTOFMEMORY 0x8007000E #define DDERR_OUTOFVIDEOMEMORY MAKE_DDHRESULT(380) #define DDERR_OVERLAYCANTCLIP MAKE_DDHRESULT(382) #define DDERR_OVERLAYCOLORKEYONLYONEACTIVE MAKE_DDHRESULT(384) -#define DDERR_OVERLAYNOTVISIBLE MAKE_DDHRESULT(577) #define DDERR_PALETTEBUSY MAKE_DDHRESULT(387) -#define DDERR_PRIMARYSURFACEALREADYEXISTS MAKE_DDHRESULT(564) -#define DDERR_REGIONTOOSMALL MAKE_DDHRESULT(566) +#define DDERR_COLORKEYNOTSET MAKE_DDHRESULT(400) #define DDERR_SURFACEALREADYATTACHED MAKE_DDHRESULT(410) #define DDERR_SURFACEALREADYDEPENDENT MAKE_DDHRESULT(420) #define DDERR_SURFACEBUSY MAKE_DDHRESULT(430) @@ -150,29 +110,87 @@ #define DDERR_TOOBIGHEIGHT MAKE_DDHRESULT(470) #define DDERR_TOOBIGSIZE MAKE_DDHRESULT(480) #define DDERR_TOOBIGWIDTH MAKE_DDHRESULT(490) -#define DDERR_UNSUPPORTED MAKE_DDHRESULT(500) +#define DDERR_UNSUPPORTED 0x80004001 #define DDERR_UNSUPPORTEDFORMAT MAKE_DDHRESULT(510) #define DDERR_UNSUPPORTEDMASK MAKE_DDHRESULT(520) #define DDERR_VERTICALBLANKINPROGRESS MAKE_DDHRESULT(537) #define DDERR_WASSTILLDRAWING MAKE_DDHRESULT(540) -#define DDERR_WRONGMODE MAKE_DDHRESULT(587) #define DDERR_XALIGN MAKE_DDHRESULT(560) +#define DDERR_INVALIDDIRECTDRAWGUID MAKE_DDHRESULT(561) +#define DDERR_DIRECTDRAWALREADYCREATED MAKE_DDHRESULT(562) +#define DDERR_NODIRECTDRAWHW MAKE_DDHRESULT(563) +#define DDERR_PRIMARYSURFACEALREADYEXISTS MAKE_DDHRESULT(564) +#define DDERR_NOEMULATION MAKE_DDHRESULT(565) +#define DDERR_REGIONTOOSMALL MAKE_DDHRESULT(566) +#define DDERR_CLIPPERISUSINGHWND MAKE_DDHRESULT(567) +#define DDERR_NOCLIPPERATTACHED MAKE_DDHRESULT(568) +#define DDERR_NOHWND MAKE_DDHRESULT(569) +#define DDERR_HWNDSUBCLASSED MAKE_DDHRESULT(570) +#define DDERR_HWNDALREADYSET MAKE_DDHRESULT(571) +#define DDERR_NOPALETTEATTACHED MAKE_DDHRESULT(572) +#define DDERR_NOPALETTEHW MAKE_DDHRESULT(573) +#define DDERR_BLTFASTCANTCLIP MAKE_DDHRESULT(574) +#define DDERR_NOBLTHW MAKE_DDHRESULT(575) +#define DDERR_NODDROPSHW MAKE_DDHRESULT(576) +#define DDERR_OVERLAYNOTVISIBLE MAKE_DDHRESULT(577) +#define DDERR_NOOVERLAYDEST MAKE_DDHRESULT(578) +#define DDERR_INVALIDPOSITION MAKE_DDHRESULT(579) +#define DDERR_NOTAOVERLAYSURFACE MAKE_DDHRESULT(580) +#define DDERR_EXCLUSIVEMODEALREADYSET MAKE_DDHRESULT(581) +#define DDERR_NOTFLIPPABLE MAKE_DDHRESULT(582) +#define DDERR_CANTDUPLICATE MAKE_DDHRESULT(583) +#define DDERR_NOTLOCKED MAKE_DDHRESULT(584) +#define DDERR_CANTCREATEDC MAKE_DDHRESULT(585) +#define DDERR_NODC MAKE_DDHRESULT(586) +#define DDERR_WRONGMODE MAKE_DDHRESULT(587) +#define DDERR_IMPLICITLYCREATED MAKE_DDHRESULT(588) +#define DDERR_NOTPALETTIZED MAKE_DDHRESULT(589) // --- GUIDs --- -DEFINE_GUID(IID_IDirectDraw2, 0x6c14db80, 0x9ecf, 0x11d0, 0xa3, 0x2a, 0x0, 0xa0, 0xc9, 0x0, 0x6, 0x1f); -DEFINE_GUID(IID_IDirectDrawSurface3, 0xDA044E0, 0x69B2, 0x11D0, 0xA1, 0xD5, 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xBB); +DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0, 0x2B43, 0x11CF, 0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56); +DEFINE_GUID(IID_IDirectDrawSurface3, 0xDA044E00, 0x69B2, 0x11D0, 0xA1, 0xD5, 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xBB); + +enum class DDSurfaceDescFlags : uint32_t { + CAPS = 0x00000001, // ddsCaps is valid + HEIGHT = 0x00000002, // dwHeight is valid + WIDTH = 0x00000004, // dwWidth is valid + BACKBUFFERCOUNT = 0x00000020, // dwBackBufferCount is valid + ZBUFFERBITDEPTH = 0x00000040, // dwZBufferBitDepth is valid + PIXELFORMAT = 0x00001000, // ddpfPixelFormat is valid +}; +ENABLE_BITMASK_OPERATORS(DDSurfaceDescFlags) + +enum class DDSCapsFlags : uint32_t { + BACKBUFFER = 0x00000004, + COMPLEX = 0x00000008, + FLIP = 0x00000010, + OFFSCREENPLAIN = 0x00000040, + PRIMARYSURFACE = 0x00000200, + SYSTEMMEMORY = 0x00000800, + TEXTURE = 0x00001000, + D3DDEVICE = 0x00002000, + VIDEOMEMORY = 0x00004000, + ZBUFFER = 0x00020000, +}; +ENABLE_BITMASK_OPERATORS(DDSCapsFlags) + +enum class DDPixelCaps : uint32_t { + _8BIT = 0x00000004, + INITIALIZE = 0x00000008, + ALLOW256 = 0x00000040, +}; +ENABLE_BITMASK_OPERATORS(DDPixelCaps) // --- Structs --- struct DDCAPS { DWORD dwSize; - DWORD dwCaps; - DWORD dwCaps2; + DWORD dwCaps2; // DDCAPS2_* DWORD dwSVBRops[8]; }; typedef DDCAPS* LPDDCAPS; struct DDSCAPS { - DWORD dwCaps; + DDSCapsFlags dwCaps; // DDSCAPS_* }; typedef struct DDSCAPS* LPDDSCAPS; @@ -183,13 +201,12 @@ struct DDBLTFX { }; struct DDPIXELFORMAT { - DWORD dwSize; - DWORD dwFlags; - DWORD dwRGBBitCount; - DWORD dwRBitMask; - DWORD dwYBitMask; - DWORD dwGBitMask; - DWORD dwBBitMask; + DWORD dwSize; // sizeof(DDPIXELFORMAT) + DWORD dwFlags; // DDPF_RGB + DWORD dwRGBBitCount; // Bit count, Lego Island only handles 8 or 16 + DWORD dwRBitMask; // Red bit mask (0xF800) + DWORD dwGBitMask; // Green bit mask (0x07E0) + DWORD dwBBitMask; // Blue bit mask (0x001F) }; typedef struct DDPIXELFORMAT* LPDDPIXELFORMAT; @@ -200,8 +217,8 @@ struct DDCOLORKEY { typedef DDCOLORKEY* LPDDCOLORKEY; struct DDSURFACEDESC { - DWORD dwSize; - DWORD dwFlags; + DWORD dwSize; // sizeof(DDSURFACEDESC) + DDSurfaceDescFlags dwFlags; // DDSD_* DWORD dwHeight; DWORD dwWidth; LONG lPitch; @@ -272,7 +289,7 @@ typedef HRESULT (*LPDDENUMMODESCALLBACK)(LPDDSURFACEDESC, LPVOID); struct IDirectDraw : virtual public IUnknown { virtual HRESULT CreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER* lplpDDClipper, IUnknown* pUnkOuter) = 0; virtual HRESULT CreatePalette( - DWORD dwFlags, + DDPixelCaps dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter diff --git a/miniwin/miniwin/src/miniwin_d3drm.cpp b/miniwin/miniwin/src/miniwin_d3drm.cpp index 9719c52f..e1680260 100644 --- a/miniwin/miniwin/src/miniwin_d3drm.cpp +++ b/miniwin/miniwin/src/miniwin_d3drm.cpp @@ -10,14 +10,14 @@ struct Direct3DRMDevice2Impl : public IDirect3DRMDevice2 { HRESULT GetBufferCount() override { return DD_OK; } HRESULT SetShades(unsigned long shadeCount) override { return DD_OK; } HRESULT GetShades() override { return DD_OK; } - HRESULT SetQuality(int quality) override { return DD_OK; } - HRESULT GetQuality() override { return DD_OK; } + HRESULT SetQuality(D3DRMRENDERQUALITY quality) override { return DD_OK; } + D3DRMRENDERQUALITY GetQuality() override { return D3DRMRENDERQUALITY::GOURAUD; } HRESULT SetDither(int dither) override { return DD_OK; } HRESULT GetDither() override { return DD_OK; } HRESULT SetTextureQuality(D3DRMTEXTUREQUALITY quality) override { return DD_OK; } - D3DRMTEXTUREQUALITY GetTextureQuality() override { return D3DRMTEXTURE_NEAREST; } - HRESULT SetRenderMode(int mode) override { return DD_OK; } - HRESULT GetRenderMode() override { return DD_OK; } + D3DRMTEXTUREQUALITY GetTextureQuality() override { return D3DRMTEXTUREQUALITY::LINEAR; } + HRESULT SetRenderMode(D3DRMRENDERMODE mode) override { return DD_OK; } + D3DRMRENDERMODE GetRenderMode() override { return D3DRMRENDERMODE::BLENDEDTRANSPARENCY; } HRESULT Update() override { return DD_OK; } HRESULT GetViewports(IDirect3DRMViewportArray** ppViewportArray) override { return DD_OK; } }; @@ -42,7 +42,7 @@ struct Direct3DRMFrameImpl : public IDirect3DRMFrame2 { return DD_OK; } HRESULT GetLights(IDirect3DRMLightArray** lightArray) override { return DD_OK; } - HRESULT AddTransform(int combine, D3DRMMATRIX4D matrix) override { return DD_OK; } + HRESULT AddTransform(D3DRMCOMBINETYPE combine, D3DRMMATRIX4D matrix) override { return DD_OK; } HRESULT GetPosition(int index, D3DVECTOR* position) override { return DD_OK; } HRESULT AddVisual(IDirect3DRMVisual* visual) override { @@ -104,7 +104,7 @@ struct Direct3DRMViewportImpl : public IDirect3DRMViewport { HRESULT SetCamera(IDirect3DRMFrame* camera) override { return DD_OK; } HRESULT GetCamera(IDirect3DRMFrame** camera) override { return DD_OK; } HRESULT SetProjection(D3DRMPROJECTIONTYPE type) override { return DD_OK; } - D3DRMPROJECTIONTYPE GetProjection() override { return D3DRMPROJECT_PERSPECTIVE; } + D3DRMPROJECTIONTYPE GetProjection() override { return D3DRMPROJECTIONTYPE::PERSPECTIVE; } HRESULT SetFront(D3DVALUE z) override { return DD_OK; } D3DVALUE GetFront() override { return 0; } HRESULT SetBack(D3DVALUE z) override { return DD_OK; } diff --git a/miniwin/miniwin/src/miniwin_ddraw.cpp b/miniwin/miniwin/src/miniwin_ddraw.cpp index 13e8005c..9b12fa6b 100644 --- a/miniwin/miniwin/src/miniwin_ddraw.cpp +++ b/miniwin/miniwin/src/miniwin_ddraw.cpp @@ -93,7 +93,7 @@ struct DirectDrawImpl : public IDirectDraw2, public IDirect3D2 { return DD_OK; } HRESULT CreatePalette( - DWORD dwFlags, + DDPixelCaps dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter @@ -145,17 +145,17 @@ HRESULT DirectDrawImpl::EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx) return DDERR_INVALIDPARAMS; } - GUID deviceGuid = {0xa4665c, 0x2673, 0x11ce, 0x8034a0}; + GUID deviceGuid = {0xA1B2C3D4, 0x1122, 0x3344, {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11}}; char* deviceName = (char*) "MiniWin 3D Device"; char* deviceDesc = (char*) "Stubbed 3D device"; D3DDEVICEDESC halDesc = {}; - halDesc.dcmColorModel = D3DCOLOR_RGB; + halDesc.dcmColorModel = D3DCOLORMODEL::RGB; halDesc.dwDeviceZBufferBitDepth = DDBD_16; halDesc.dpcTriCaps.dwTextureCaps = D3DPTEXTURECAPS_PERSPECTIVE; D3DDEVICEDESC helDesc = {}; - halDesc.dcmColorModel = D3DCOLOR_RGB; + halDesc.dcmColorModel = D3DCOLORMODEL::RGB; halDesc.dwDeviceZBufferBitDepth = DDBD_16; halDesc.dpcTriCaps.dwTextureCaps = D3DPTEXTURECAPS_PERSPECTIVE; diff --git a/util/compat.h b/util/compat.h index db768dda..9b0fd541 100644 --- a/util/compat.h +++ b/util/compat.h @@ -7,6 +7,13 @@ #define COMPAT_MODE #endif +#ifndef MINIWIN +#define D3DCOLOR_NONE 0 +#define D3DRMMAP_NONE 0 +#define D3DRMRENDERMODE DWORD +#define DDSCapsFlags DWORD +#endif + // Disable "identifier was truncated to '255' characters" warning. // Impossible to avoid this if using STL map or set. // This removes most (but not all) occurrences of the warning.