mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Fixed GDI display issues in Titanic: Adventure Out of Time
This commit is contained in:
parent
f13d842c24
commit
2099c80095
@ -48,8 +48,9 @@ namespace D3dDdi
|
|||||||
|
|
||||||
HRESULT Device::createPrivateResource(D3DDDIARG_CREATERESOURCE2& data)
|
HRESULT Device::createPrivateResource(D3DDDIARG_CREATERESOURCE2& data)
|
||||||
{
|
{
|
||||||
const bool isPalettizedOffScreen = D3DDDIFMT_P8 == data.Format && !data.Flags.Texture;
|
const bool isPalettized = D3DDDIFMT_P8 == data.Format;
|
||||||
if (isPalettizedOffScreen)
|
const bool isTexture = data.Flags.Texture;
|
||||||
|
if (isPalettized)
|
||||||
{
|
{
|
||||||
data.Format = D3DDDIFMT_L8;
|
data.Format = D3DDDIFMT_L8;
|
||||||
data.Flags.Texture = 1;
|
data.Flags.Texture = 1;
|
||||||
@ -59,10 +60,10 @@ namespace D3dDdi
|
|||||||
? m_origVtable.pfnCreateResource2(m_device, &data)
|
? m_origVtable.pfnCreateResource2(m_device, &data)
|
||||||
: m_origVtable.pfnCreateResource(m_device, reinterpret_cast<D3DDDIARG_CREATERESOURCE*>(&data));
|
: m_origVtable.pfnCreateResource(m_device, reinterpret_cast<D3DDDIARG_CREATERESOURCE*>(&data));
|
||||||
|
|
||||||
if (isPalettizedOffScreen)
|
if (isPalettized)
|
||||||
{
|
{
|
||||||
data.Format = D3DDDIFMT_P8;
|
data.Format = D3DDDIFMT_P8;
|
||||||
data.Flags.Texture = 0;
|
data.Flags.Texture = isTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -114,6 +115,7 @@ namespace D3dDdi
|
|||||||
|
|
||||||
void Device::setGdiResourceHandle(HANDLE resource)
|
void Device::setGdiResourceHandle(HANDLE resource)
|
||||||
{
|
{
|
||||||
|
LOG_FUNC("Device::setGdiResourceHandle", resource);
|
||||||
ScopedCriticalSection lock;
|
ScopedCriticalSection lock;
|
||||||
if ((!resource && !g_gdiResource) ||
|
if ((!resource && !g_gdiResource) ||
|
||||||
(g_gdiResource && resource == *g_gdiResource))
|
(g_gdiResource && resource == *g_gdiResource))
|
||||||
|
@ -478,6 +478,11 @@ namespace D3dDdi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (D3DDDIFMT_P8 == m_fixedData.Format)
|
||||||
|
{
|
||||||
|
data.Color <<= 16;
|
||||||
|
}
|
||||||
|
|
||||||
prepareForBltDst(data.hResource, data.SubResourceIndex, data.DstRect);
|
prepareForBltDst(data.hResource, data.SubResourceIndex, data.DstRect);
|
||||||
return LOG_RESULT(m_device.getOrigVtable().pfnColorFill(m_device, &data));
|
return LOG_RESULT(m_device.getOrigVtable().pfnColorFill(m_device, &data));
|
||||||
}
|
}
|
||||||
@ -924,7 +929,7 @@ namespace D3dDdi
|
|||||||
return prepareForBltDst(data.hDstResource, data.DstSubResourceIndex, data.DstRect);
|
return prepareForBltDst(data.hDstResource, data.DstSubResourceIndex, data.DstRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
Resource& Resource::prepareForBltDst(HANDLE& resource, UINT& subResourceIndex, RECT& rect)
|
Resource& Resource::prepareForBltDst(HANDLE& resource, UINT subResourceIndex, RECT& rect)
|
||||||
{
|
{
|
||||||
if (m_lockResource)
|
if (m_lockResource)
|
||||||
{
|
{
|
||||||
@ -1241,6 +1246,8 @@ namespace D3dDdi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DDraw::PrimarySurface::updatePalette();
|
||||||
|
|
||||||
if (isFullscreen)
|
if (isFullscreen)
|
||||||
{
|
{
|
||||||
g_presentationRect = calculatePresentationRect();
|
g_presentationRect = calculatePresentationRect();
|
||||||
|
@ -40,7 +40,7 @@ namespace D3dDdi
|
|||||||
void onDestroyResource(HANDLE resource);
|
void onDestroyResource(HANDLE resource);
|
||||||
Resource& prepareForBltSrc(const D3DDDIARG_BLT& data);
|
Resource& prepareForBltSrc(const D3DDDIARG_BLT& data);
|
||||||
Resource& prepareForBltDst(D3DDDIARG_BLT& data);
|
Resource& prepareForBltDst(D3DDDIARG_BLT& data);
|
||||||
Resource& prepareForBltDst(HANDLE& resource, UINT& subResourceIndex, RECT& rect);
|
Resource& prepareForBltDst(HANDLE& resource, UINT subResourceIndex, RECT& rect);
|
||||||
void prepareForCpuRead(UINT subResourceIndex);
|
void prepareForCpuRead(UINT subResourceIndex);
|
||||||
void prepareForCpuWrite(UINT subResourceIndex);
|
void prepareForCpuWrite(UINT subResourceIndex);
|
||||||
Resource& prepareForGpuRead(UINT subResourceIndex);
|
Resource& prepareForGpuRead(UINT subResourceIndex);
|
||||||
|
@ -79,18 +79,21 @@ namespace
|
|||||||
HRESULT STDMETHODCALLTYPE SetCooperativeLevel(TDirectDraw* This, HWND hWnd, DWORD dwFlags)
|
HRESULT STDMETHODCALLTYPE SetCooperativeLevel(TDirectDraw* This, HWND hWnd, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
HRESULT result = getOrigVtable(This).SetCooperativeLevel(This, hWnd, dwFlags);
|
HRESULT result = getOrigVtable(This).SetCooperativeLevel(This, hWnd, dwFlags);
|
||||||
if (SUCCEEDED(result))
|
if (SUCCEEDED(result) && (dwFlags & (DDSCL_FULLSCREEN | DDSCL_NORMAL)))
|
||||||
{
|
{
|
||||||
auto tagSurface = DDraw::TagSurface::get(*CompatPtr<IDirectDraw>::from(This));
|
auto tagSurface = DDraw::TagSurface::get(*CompatPtr<IDirectDraw>::from(This));
|
||||||
if (tagSurface)
|
if (tagSurface)
|
||||||
{
|
{
|
||||||
if (dwFlags & DDSCL_FULLSCREEN)
|
const bool wasFullscreen = tagSurface->isFullscreen();
|
||||||
|
const bool isFullscreen = dwFlags & DDSCL_FULLSCREEN;
|
||||||
|
if (wasFullscreen != isFullscreen)
|
||||||
{
|
{
|
||||||
tagSurface->setFullscreenWindow(hWnd);
|
tagSurface->setFullscreenWindow(isFullscreen ? hWnd : nullptr);
|
||||||
}
|
if (DDraw::RealPrimarySurface::getSurface())
|
||||||
else if (dwFlags & DDSCL_NORMAL)
|
{
|
||||||
{
|
DDraw::RealPrimarySurface::release();
|
||||||
tagSurface->setFullscreenWindow(nullptr);
|
DDraw::RealPrimarySurface::create(CompatRef<TDirectDraw>(*This));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,12 +293,9 @@ namespace
|
|||||||
g_clipper.release();
|
g_clipper.release();
|
||||||
CALL_ORIG_PROC(DirectDrawCreateClipper)(0, &g_clipper.getRef(), nullptr);
|
CALL_ORIG_PROC(DirectDrawCreateClipper)(0, &g_clipper.getRef(), nullptr);
|
||||||
g_frontBuffer->SetClipper(g_frontBuffer, g_clipper);
|
g_frontBuffer->SetClipper(g_frontBuffer, g_clipper);
|
||||||
|
|
||||||
const bool isFlippable = 0 != (desc.ddsCaps.dwCaps & DDSCAPS_FLIP);
|
|
||||||
g_surfaceDesc = desc;
|
g_surfaceDesc = desc;
|
||||||
g_isFullscreen = isFlippable;
|
|
||||||
|
|
||||||
if (isFlippable)
|
if (0 != (desc.ddsCaps.dwCaps & DDSCAPS_FLIP))
|
||||||
{
|
{
|
||||||
g_frontBuffer->Flip(g_frontBuffer, getLastSurface(), DDFLIP_WAIT);
|
g_frontBuffer->Flip(g_frontBuffer, getLastSurface(), DDFLIP_WAIT);
|
||||||
D3dDdi::KernelModeThunks::waitForVsyncCounter(D3dDdi::KernelModeThunks::getVsyncCounter() + 1);
|
D3dDdi::KernelModeThunks::waitForVsyncCounter(D3dDdi::KernelModeThunks::getVsyncCounter() + 1);
|
||||||
@ -341,7 +338,7 @@ namespace
|
|||||||
Input::updateCursor();
|
Input::updateCursor();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!g_frontBuffer || !src || DDraw::RealPrimarySurface::isLost())
|
if (!g_frontBuffer || !src || DDraw::RealPrimarySurface::isLost() || FAILED(src->IsLost(src)))
|
||||||
{
|
{
|
||||||
Gdi::Window::present(nullptr);
|
Gdi::Window::present(nullptr);
|
||||||
return;
|
return;
|
||||||
@ -381,12 +378,16 @@ namespace
|
|||||||
bool isFullscreen = false;
|
bool isFullscreen = false;
|
||||||
if (SUCCEEDED(g_frontBuffer->IsLost(g_frontBuffer)))
|
if (SUCCEEDED(g_frontBuffer->IsLost(g_frontBuffer)))
|
||||||
{
|
{
|
||||||
HWND foregroundWindow = GetForegroundWindow();
|
auto primary(DDraw::PrimarySurface::getPrimary());
|
||||||
if (foregroundWindow)
|
if (primary && SUCCEEDED(primary->IsLost(primary)))
|
||||||
{
|
{
|
||||||
DWORD pid = 0;
|
HWND foregroundWindow = GetForegroundWindow();
|
||||||
GetWindowThreadProcessId(foregroundWindow, &pid);
|
if (foregroundWindow)
|
||||||
isFullscreen = GetCurrentProcessId() == pid && Gdi::Window::hasFullscreenWindow();
|
{
|
||||||
|
DWORD pid = 0;
|
||||||
|
GetWindowThreadProcessId(foregroundWindow, &pid);
|
||||||
|
isFullscreen = GetCurrentProcessId() == pid && Gdi::Window::hasFullscreenWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,11 +447,13 @@ namespace DDraw
|
|||||||
desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
|
desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
|
||||||
desc.dwBackBufferCount = 2;
|
desc.dwBackBufferCount = 2;
|
||||||
|
|
||||||
|
g_isFullscreen = true;
|
||||||
CompatPtr<typename Types<DirectDraw>::TCreatedSurface> surface;
|
CompatPtr<typename Types<DirectDraw>::TCreatedSurface> surface;
|
||||||
HRESULT result = dd->CreateSurface(&dd, &desc, &surface.getRef(), nullptr);
|
HRESULT result = dd->CreateSurface(&dd, &desc, &surface.getRef(), nullptr);
|
||||||
|
|
||||||
if (DDERR_NOEXCLUSIVEMODE == result)
|
if (DDERR_NOEXCLUSIVEMODE == result)
|
||||||
{
|
{
|
||||||
|
g_isFullscreen = false;
|
||||||
desc.dwFlags = DDSD_CAPS;
|
desc.dwFlags = DDSD_CAPS;
|
||||||
desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||||
desc.dwBackBufferCount = 0;
|
desc.dwBackBufferCount = 0;
|
||||||
|
@ -255,6 +255,10 @@ namespace DDraw
|
|||||||
{
|
{
|
||||||
if (!s_palette)
|
if (!s_palette)
|
||||||
{
|
{
|
||||||
|
if (DDraw::RealPrimarySurface::isFullscreen())
|
||||||
|
{
|
||||||
|
Gdi::Palette::setHardwarePalette(Gdi::Palette::getSystemPalette().data());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ namespace DDraw
|
|||||||
|
|
||||||
static bool doesFullscreenDirectDrawExist();
|
static bool doesFullscreenDirectDrawExist();
|
||||||
|
|
||||||
|
bool isFullscreen() const { return m_fullscreenWindow; }
|
||||||
void setFullscreenWindow(HWND hwnd);
|
void setFullscreenWindow(HWND hwnd);
|
||||||
LONG setWindowStyle(LONG style);
|
LONG setWindowStyle(LONG style);
|
||||||
LONG setWindowExStyle(LONG exStyle);
|
LONG setWindowExStyle(LONG exStyle);
|
||||||
|
@ -21,6 +21,7 @@ namespace Gdi
|
|||||||
{
|
{
|
||||||
HWND create(HWND owner)
|
HWND create(HWND owner)
|
||||||
{
|
{
|
||||||
|
LOG_FUNC("PresentationWindow::create", owner);
|
||||||
HWND presentationWindow = nullptr;
|
HWND presentationWindow = nullptr;
|
||||||
GuiThread::execute([&]()
|
GuiThread::execute([&]()
|
||||||
{
|
{
|
||||||
@ -40,7 +41,7 @@ namespace Gdi
|
|||||||
CALL_ORIG_FUNC(SetLayeredWindowAttributes)(presentationWindow, 0, 255, LWA_ALPHA);
|
CALL_ORIG_FUNC(SetLayeredWindowAttributes)(presentationWindow, 0, 255, LWA_ALPHA);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return presentationWindow;
|
return LOG_RESULT(presentationWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installHooks()
|
void installHooks()
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <Config/Config.h>
|
#include <Config/Config.h>
|
||||||
#include <Common/ScopedCriticalSection.h>
|
#include <Common/ScopedCriticalSection.h>
|
||||||
#include <D3dDdi/Device.h>
|
#include <D3dDdi/Device.h>
|
||||||
|
#include <D3dDdi/Resource.h>
|
||||||
#include <D3dDdi/ScopedCriticalSection.h>
|
#include <D3dDdi/ScopedCriticalSection.h>
|
||||||
#include <DDraw/DirectDraw.h>
|
#include <DDraw/DirectDraw.h>
|
||||||
#include <DDraw/RealPrimarySurface.h>
|
#include <DDraw/RealPrimarySurface.h>
|
||||||
@ -270,6 +271,8 @@ namespace Gdi
|
|||||||
|
|
||||||
prevDisplaySettingsUniqueness = Win32::DisplayMode::queryDisplaySettingsUniqueness();
|
prevDisplaySettingsUniqueness = Win32::DisplayMode::queryDisplaySettingsUniqueness();
|
||||||
prevIsFullscreen = g_isFullscreen;
|
prevIsFullscreen = g_isFullscreen;
|
||||||
|
|
||||||
|
auto gdiResource = D3dDdi::Device::getGdiResource();
|
||||||
D3dDdi::Device::setGdiResourceHandle(nullptr);
|
D3dDdi::Device::setGdiResourceHandle(nullptr);
|
||||||
|
|
||||||
if (g_isFullscreen)
|
if (g_isFullscreen)
|
||||||
@ -307,6 +310,11 @@ namespace Gdi
|
|||||||
{
|
{
|
||||||
SelectObject(dc.first, createDib(dc.second.useDefaultPalette));
|
SelectObject(dc.first, createDib(dc.second.useDefaultPalette));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gdiResource && DDraw::PrimarySurface::getPrimary())
|
||||||
|
{
|
||||||
|
D3dDdi::Device::setGdiResourceHandle(*gdiResource);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Gdi::Window::updateAll();
|
Gdi::Window::updateAll();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user