1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Fixed palette issues with GetDC on primary surface

This commit is contained in:
narzoul 2018-03-11 18:42:06 +01:00
parent 6c34bbb437
commit 335d093cb9
3 changed files with 34 additions and 0 deletions

View File

@ -80,6 +80,25 @@ namespace
return result;
}
NTSTATUS APIENTRY createDcFromMemory(D3DKMT_CREATEDCFROMMEMORY* pData)
{
Compat::LogEnter("D3DKMTCreateDCFromMemory", pData);
NTSTATUS result = 0;
if (pData && D3DDDIFMT_P8 == pData->Format && !pData->pColorTable &&
DDraw::PrimarySurface::s_palette)
{
pData->pColorTable = DDraw::PrimarySurface::s_paletteEntries;
result = CALL_ORIG_FUNC(D3DKMTCreateDCFromMemory)(pData);
pData->pColorTable = nullptr;
}
else
{
result = CALL_ORIG_FUNC(D3DKMTCreateDCFromMemory)(pData);
}
Compat::LogLeave("D3DKMTCreateDCFromMemory", pData) << result;
return result;
}
NTSTATUS APIENTRY destroyContext(const D3DKMT_DESTROYCONTEXT* pData)
{
Compat::LogEnter("D3DKMTDestroyContext", pData);
@ -250,6 +269,7 @@ namespace D3dDdi
{
HOOK_FUNCTION(gdi32, D3DKMTCreateContext, createContext);
HOOK_FUNCTION(gdi32, D3DKMTCreateDevice, createDevice);
HOOK_FUNCTION(gdi32, D3DKMTCreateDCFromMemory, createDcFromMemory);
HOOK_FUNCTION(gdi32, D3DKMTDestroyContext, destroyContext);
HOOK_FUNCTION(gdi32, D3DKMTDestroyDevice, destroyDevice);
HOOK_FUNCTION(gdi32, D3DKMTQueryAdapterInfo, queryAdapterInfo);

View File

@ -34,6 +34,19 @@ std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATECONTEXTVIRTUAL& da
<< Compat::hex(data.hContext);
}
std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATEDCFROMMEMORY& data)
{
return Compat::LogStruct(os)
<< data.pMemory
<< data.Width
<< data.Height
<< data.Pitch
<< data.hDeviceDc
<< data.pColorTable
<< Compat::out(data.hDc)
<< Compat::out(data.hBitmap);
}
std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATEDEVICE& data)
{
return Compat::LogStruct(os)

View File

@ -10,6 +10,7 @@
std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATECONTEXT& data);
std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATECONTEXTVIRTUAL& data);
std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATEDCFROMMEMORY& data);
std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATEDEVICE& data);
std::ostream& operator<<(std::ostream& os, const D3DKMT_DESTROYCONTEXT& data);
std::ostream& operator<<(std::ostream& os, const D3DKMT_DESTROYDEVICE& data);