diff --git a/Source/Render/DX7/DeviceOwnerDX7.cpp b/Source/Render/DX7/DeviceOwnerDX7.cpp index 2e84abb..3efd7be 100644 --- a/Source/Render/DX7/DeviceOwnerDX7.cpp +++ b/Source/Render/DX7/DeviceOwnerDX7.cpp @@ -1,4 +1,6 @@ #include "Render/DX7/DeviceOwnerDX7.h" +#include "Client/Application/ApplicationWindow.h" +#include "Render/DX7/DirectDrawEnumeration.h" #include @@ -22,17 +24,17 @@ namespace { // OFFSET: 0x0054AA50 // FUNCTION: fn_01900 - RECT ClientRectangle(HWND window, const RECT& monitor) { + RECT ClientRectangle(HWND window) { RECT result; GetClientRect(window, &result); POINT point{result.left, result.top}; ClientToScreen(window, &point); - result.left = point.x - monitor.left; - result.top = point.y - monitor.top; + result.left = point.x - g_monitorRectangleDX7.left; + result.top = point.y - g_monitorRectangleDX7.top; point = {result.right, result.bottom}; ClientToScreen(window, &point); - result.right = point.x - monitor.left; - result.bottom = point.y - monitor.top; + result.right = point.x - g_monitorRectangleDX7.left; + result.bottom = point.y - g_monitorRectangleDX7.top; return result; } @@ -89,7 +91,7 @@ DeviceOwnerDX7::DeviceOwnerDX7() // OFFSET: 0x005498A0 // FUNCTION: fn_01894 -HRESULT DeviceOwnerDX7::CreateSurfaces(const DDSURFACEDESC2* mode, DWORD flags, const RECT& monitor) { +HRESULT DeviceOwnerDX7::CreateSurfaces(const DDSURFACEDESC2* mode, DWORD flags) { const bool buffered = (flags & 2) != 0; DDSURFACEDESC2 description = SurfaceDescription(DDSD_CAPS, 0); HRESULT status; @@ -131,7 +133,7 @@ HRESULT DeviceOwnerDX7::CreateSurfaces(const DDSURFACEDESC2* mode, DWORD flags, GetClientRect(this->window, &this->source); this->width = this->source.right; this->height = this->source.bottom; - this->destination = ClientRectangle(this->window, monitor); + this->destination = ClientRectangle(this->window); description.ddsCaps.dwCaps = buffered ? DDSCAPS_PRIMARYSURFACE : DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE; status = this->draw->CreateSurface(&description, &this->primary, nullptr); @@ -201,7 +203,7 @@ HRESULT DeviceOwnerDX7::CreateSurfaces(const DDSURFACEDESC2* mode, DWORD flags, // OFFSET: 0x0054A000 // FUNCTION: fn_01895 -HRESULT DeviceOwnerDX7::CreateDevice(GUID* drawIdentity, const GUID* renderIdentity, const DDSURFACEDESC2* mode, DWORD flags, const RECT& monitor) { +HRESULT DeviceOwnerDX7::CreateDevice(GUID* drawIdentity, const GUID* renderIdentity, const DDSURFACEDESC2* mode, DWORD flags) { this->depthMemory = std::memcmp(renderIdentity, &IID_IDirect3DHALDevice, sizeof(GUID)) == 0 || std::memcmp(renderIdentity, &IID_IDirect3DTnLHalDevice, sizeof(GUID)) == 0 ? DDSCAPS_VIDEOMEMORY @@ -224,7 +226,7 @@ HRESULT DeviceOwnerDX7::CreateDevice(GUID* drawIdentity, const GUID* renderIdent return DeviceError(2); } - const HRESULT status = this->CreateSurfaces(mode, flags, monitor); + const HRESULT status = this->CreateSurfaces(mode, flags); if (FAILED(status)) { return status; @@ -335,9 +337,7 @@ HRESULT DeviceOwnerDX7::Close() { // OFFSET: 0x0054AAD0 // FUNCTION: fn_01901 -HRESULT DeviceOwnerDX7::Initialize( - HWND value, GUID* drawIdentity, const GUID* renderIdentity, const DDSURFACEDESC2* mode, DWORD flags, HWND applicationWindow, const RECT& monitor -) { +HRESULT DeviceOwnerDX7::Initialize(HWND value, GUID* drawIdentity, const GUID* renderIdentity, const DDSURFACEDESC2* mode, DWORD flags) { this->window = value; if (!value || !renderIdentity || (!mode && (flags & 1))) { @@ -347,11 +347,11 @@ HRESULT DeviceOwnerDX7::Initialize( this->fullscreen = flags & 1; if (this->fullscreen) { - SetWindowLongA(applicationWindow, GWL_STYLE, static_cast(WS_POPUP)); - ShowWindow(applicationWindow, SW_MAXIMIZE); + SetWindowLongA(hWnd, GWL_STYLE, static_cast(WS_POPUP)); + ShowWindow(hWnd, SW_MAXIMIZE); } - const HRESULT status = this->CreateDevice(drawIdentity, renderIdentity, mode, flags, monitor); + const HRESULT status = this->CreateDevice(drawIdentity, renderIdentity, mode, flags); if (FAILED(status)) { this->Close(); @@ -450,7 +450,7 @@ bool DeviceOwnerDX7::RestoreLostSurfaces() { // OFFSET: 0x0054AF20 // FUNCTION: fn_01904 -HRESULT DeviceOwnerDX7::Present(bool wait, const RECT& monitor) { +HRESULT DeviceOwnerDX7::Present(bool wait) { if (!this->primary) { return DeviceError(14); } @@ -460,7 +460,7 @@ HRESULT DeviceOwnerDX7::Present(bool wait, const RECT& monitor) { } if (wait && (!this->fullscreen || this->presentationOption)) { - this->destination = ClientRectangle(this->window, monitor); + this->destination = ClientRectangle(this->window); this->draw->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, nullptr); return this->primary->Blt(&this->destination, this->backBuffer, &this->source, DDBLT_WAIT, nullptr); } diff --git a/Source/Render/DX7/DeviceOwnerDX7.h b/Source/Render/DX7/DeviceOwnerDX7.h index 7788ebb..42ba410 100644 --- a/Source/Render/DX7/DeviceOwnerDX7.h +++ b/Source/Render/DX7/DeviceOwnerDX7.h @@ -20,14 +20,13 @@ class CRenderSystemBase; class DeviceOwnerDX7 { public: DeviceOwnerDX7(); - HRESULT - Initialize(HWND window, GUID* drawIdentity, const GUID* renderIdentity, const DDSURFACEDESC2* mode, DWORD flags, HWND applicationWindow, const RECT& monitor); - HRESULT CreateDevice(GUID* drawIdentity, const GUID* renderIdentity, const DDSURFACEDESC2* mode, DWORD flags, const RECT& monitor); - HRESULT CreateSurfaces(const DDSURFACEDESC2* mode, DWORD flags, const RECT& monitor); + HRESULT Initialize(HWND window, GUID* drawIdentity, const GUID* renderIdentity, const DDSURFACEDESC2* mode, DWORD flags); + HRESULT CreateDevice(GUID* drawIdentity, const GUID* renderIdentity, const DDSURFACEDESC2* mode, DWORD flags); + HRESULT CreateSurfaces(const DDSURFACEDESC2* mode, DWORD flags); HRESULT Close(); HRESULT Clear(DWORD color); HRESULT ClearDepth(); - HRESULT Present(bool wait, const RECT& monitor); + HRESULT Present(bool wait); bool RestoreLostSurfaces(); void MarkSurfacesLost(); void AdjustTextureDimensions(std::uint32_t& width, std::uint32_t& height) const; diff --git a/Source/Render/DX7/RenderSystemDX7.cpp b/Source/Render/DX7/RenderSystemDX7.cpp index 56e326c..0f820c1 100644 --- a/Source/Render/DX7/RenderSystemDX7.cpp +++ b/Source/Render/DX7/RenderSystemDX7.cpp @@ -1,5 +1,6 @@ #include "Render/DX7/RenderSystemDX7.h" #include "Render/DX7/DeviceOwnerDX7.h" +#include "Render/DX7/DirectDrawEnumeration.h" #include "Render/DX7/SurfaceDX7.h" #include "Render/DX7/TextureDX7.h" @@ -24,6 +25,12 @@ CRenderSystemDX7::~CRenderSystemDX7() { delete this->m_defaultTexture; } +// OFFSET: 0x0056B5D0 +// FUNCTION: fn_02316 +void ClearDirectDrawModes() { + DirectDrawEnumeration::ClearModes(); +} + // OFFSET: 0x0056B5F0 // FUNCTION: fn_02318 CSurface* CRenderSystemDX7::CreateSurface(std::uint32_t width, std::uint32_t height) { @@ -114,3 +121,8 @@ std::uint32_t CRenderSystemDX7::Width() { bool CRenderSystemDX7::IsWindowed() { return this->m_device->fullscreen != 0; } + +// OFFSET: 0x0056C4C0 +HRESULT CRenderSystemDX7::Present(bool option) { + return this->m_device->Present(option); +} diff --git a/Source/Render/DX7/RenderSystemDX7.h b/Source/Render/DX7/RenderSystemDX7.h index ec6af18..f8c8d37 100644 --- a/Source/Render/DX7/RenderSystemDX7.h +++ b/Source/Render/DX7/RenderSystemDX7.h @@ -43,6 +43,8 @@ private: /* 000C */ std::shared_ptr m_backBuffer; }; +void ClearDirectDrawModes(); + #if defined(_WIN32) && !defined(_WIN64) static_assert(sizeof(CRenderSystemDX7) == 20); #endif diff --git a/Source/Render/DX7/RendererPresentationDX7.cpp b/Source/Render/DX7/RendererPresentationDX7.cpp index 8518a5f..23a8f0f 100644 --- a/Source/Render/DX7/RendererPresentationDX7.cpp +++ b/Source/Render/DX7/RendererPresentationDX7.cpp @@ -11,7 +11,7 @@ // OFFSET: 0x0055B000 // FUNCTION: fn_02087 -void RendererPresentationDX7::Present(DeviceOwnerDX7& owner, bool wait, const RECT& monitor) { +void RendererPresentationDX7::Present(DeviceOwnerDX7& owner, bool wait) { ++this->frame; const unsigned elapsed = GetTickCount() - this->lastTick; @@ -31,7 +31,7 @@ void RendererPresentationDX7::Present(DeviceOwnerDX7& owner, bool wait, const RE this->backBuffer.Unlock(owner); } - if (owner.Present(wait, monitor) == DDERR_SURFACELOST) { + if (owner.Present(wait) == DDERR_SURFACELOST) { owner.MarkSurfacesLost(); } } diff --git a/Source/Render/DX7/RendererPresentationDX7.h b/Source/Render/DX7/RendererPresentationDX7.h index 7e914f5..0717641 100644 --- a/Source/Render/DX7/RendererPresentationDX7.h +++ b/Source/Render/DX7/RendererPresentationDX7.h @@ -16,7 +16,7 @@ struct RendererPresentationDX7 { unsigned& rate; RendererBackBuffer& backBuffer; - void Present(DeviceOwnerDX7& owner, bool wait, const RECT& monitor); + void Present(DeviceOwnerDX7& owner, bool wait); float FPS() const; void DrawFPS(CRenderSystemBase* system, int width, int height); };