Merge pull request #23 from StrikerX3/master
Fix for EnumAdapterMode issues
This commit is contained in:
commit
78ebfcccd8
|
@ -82,6 +82,10 @@ extern thread_local std::string _logPrefix;
|
|||
#define LOG_FUNC_ARG(arg) \
|
||||
msg << "\n " << std::setw(26) << std::left << std::setfill(' ') << #arg" : " << arg;
|
||||
|
||||
// LOG_FUNC_ARG_STR writes a pointer-based string argument, rendering nulls as <nullptr>
|
||||
#define LOG_FUNC_ARG_STR(arg) \
|
||||
msg << "\n " << std::setw(26) << std::left << std::setfill(' ') << #arg" : " << (arg == NULL ? "<nullptr>" : arg);
|
||||
|
||||
// LOG_FUNC_ARG_OUT prevents expansion of types, by only rendering as a pointer
|
||||
#define LOG_FUNC_ARG_OUT(arg) \
|
||||
msg << "\n " << std::setw(26) << std::left << std::setfill(' ') << #arg << " : 0x" << (void*)arg;
|
||||
|
@ -99,6 +103,7 @@ extern thread_local std::string _logPrefix;
|
|||
#else
|
||||
#define LOG_FUNC_BEGIN
|
||||
#define LOG_FUNC_ARG(arg)
|
||||
#define LOG_FUNC_ARG_STR(arg)
|
||||
#define LOG_FUNC_ARG_OUT(arg)
|
||||
#define LOG_FUNC_END
|
||||
#define LOG_FUNC_RESULT(r)
|
||||
|
|
|
@ -169,17 +169,29 @@ typedef struct
|
|||
{
|
||||
int W;
|
||||
int H;
|
||||
XTL::X_D3DFORMAT F;
|
||||
unsigned long PCMode;
|
||||
char N[6];
|
||||
} XboxResolution;
|
||||
|
||||
std::vector<XboxResolution> XboxResolutions = {
|
||||
{ 640, 480, 0, "NTSC"},
|
||||
{ 640, 576, 0, "PAL" },
|
||||
{ 720, 480, 0, "480p" },
|
||||
{ 720, 576, 0, "PAL2" },
|
||||
{ 1280, 720, 0, "720p" },
|
||||
{ 1920, 1080, 0, "1080i" }
|
||||
{ 640, 480, XTL::X_D3DFMT_LIN_X8R8G8B8, 0, "NTSC" },
|
||||
{ 640, 480, XTL::X_D3DFMT_LIN_X1R5G5B5, 0, "NTSC" },
|
||||
|
||||
{ 640, 576, XTL::X_D3DFMT_LIN_X8R8G8B8, 0, "PAL" },
|
||||
{ 640, 576, XTL::X_D3DFMT_LIN_X1R5G5B5, 0, "PAL" },
|
||||
|
||||
{ 720, 480, XTL::X_D3DFMT_LIN_X8R8G8B8, 0, "480p" },
|
||||
{ 720, 480, XTL::X_D3DFMT_LIN_X1R5G5B5, 0, "480p" },
|
||||
|
||||
{ 720, 576, XTL::X_D3DFMT_LIN_X8R8G8B8, 0, "PAL2" },
|
||||
{ 720, 576, XTL::X_D3DFMT_LIN_X1R5G5B5, 0, "PAL2" },
|
||||
|
||||
{ 1280, 720, XTL::X_D3DFMT_LIN_X8R8G8B8, 0, "720p" },
|
||||
{ 1280, 720, XTL::X_D3DFMT_LIN_X1R5G5B5, 0, "720p" },
|
||||
|
||||
{ 1920, 1080, XTL::X_D3DFMT_LIN_X8R8G8B8, 0, "1080i" },
|
||||
{ 1920, 1080, XTL::X_D3DFMT_LIN_X1R5G5B5, 0, "1080i" }
|
||||
};
|
||||
|
||||
bool IsValidXboxDisplayMode(XTL::D3DDISPLAYMODE PCDisplayMode, int PCModeNr)
|
||||
|
@ -1683,25 +1695,9 @@ UINT WINAPI XTL::EmuIDirect3D8_GetAdapterModeCount
|
|||
");\n",
|
||||
GetCurrentThreadId(), Adapter);
|
||||
|
||||
D3DDISPLAYMODE PCDisplayMode;
|
||||
// NOTE: completely ignoring the Adapter parameter
|
||||
|
||||
UINT ret = g_pD3D8->GetAdapterModeCount(g_XBVideo.GetDisplayAdapter());
|
||||
|
||||
for (uint32 v = 0;v<ret;v++)
|
||||
{
|
||||
HRESULT hRet = g_pD3D8->EnumAdapterModes(g_XBVideo.GetDisplayAdapter(), v, &PCDisplayMode);
|
||||
|
||||
if (hRet != D3D_OK)
|
||||
break;
|
||||
|
||||
// Dxbx addition: Only count valid Xbox resultions :
|
||||
if (!IsValidXboxDisplayMode(PCDisplayMode, v))
|
||||
ret--;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ret;
|
||||
return XboxResolutions.size();
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -1721,34 +1717,24 @@ HRESULT WINAPI XTL::EmuIDirect3D8_GetAdapterDisplayMode
|
|||
" pMode : 0x%.08X\n"
|
||||
");\n",
|
||||
GetCurrentThreadId(), Adapter, pMode);
|
||||
|
||||
// NOTE: completely ignoring the Adapter parameter
|
||||
|
||||
// NOTE: WARNING: We should cache the "Emulated" display mode and return
|
||||
// This value. We can initialize the cache with the default Xbox mode data.
|
||||
HRESULT hRet = g_pD3D8->GetAdapterDisplayMode
|
||||
(
|
||||
g_XBVideo.GetDisplayAdapter(),
|
||||
(D3DDISPLAYMODE*)pMode
|
||||
);
|
||||
HRESULT hRet;
|
||||
|
||||
// make adjustments to the parameters to make sense with windows direct3d
|
||||
{
|
||||
D3DDISPLAYMODE *pPCMode = (D3DDISPLAYMODE*)pMode;
|
||||
// TODO: Retrieve from current CreateDevice settings?
|
||||
pMode->Width = 640;
|
||||
pMode->Height = 480;
|
||||
pMode->RefreshRate = 60;
|
||||
pMode->Format = X_D3DFMT_LIN_X8R8G8B8;
|
||||
|
||||
// Convert Format (PC->Xbox)
|
||||
pMode->Format = EmuPC2XB_D3DFormat(pPCMode->Format);
|
||||
// TODO: Make this configurable in the future?
|
||||
// D3DPRESENTFLAG_FIELD | D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_LOCKABLE_BACKBUFFER
|
||||
pMode->Flags = 0x000000A1;
|
||||
|
||||
// TODO: Make this configurable in the future?
|
||||
// D3DPRESENTFLAG_FIELD | D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_LOCKABLE_BACKBUFFER
|
||||
pMode->Flags = 0x000000A1;
|
||||
hRet = D3D_OK;
|
||||
|
||||
// TODO: Retrieve from current CreateDevice settings?
|
||||
pMode->Width = 640;
|
||||
pMode->Height = 480;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return hRet;
|
||||
return hRet;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -1773,42 +1759,24 @@ HRESULT WINAPI XTL::EmuIDirect3D8_EnumAdapterModes
|
|||
|
||||
HRESULT hRet;
|
||||
|
||||
D3DDISPLAYMODE PCMode;
|
||||
|
||||
if (Mode < XboxResolutions.size())
|
||||
hRet = g_pD3D8->EnumAdapterModes(g_XBVideo.GetDisplayAdapter(), XboxResolutions[Mode].PCMode, (D3DDISPLAYMODE*)&PCMode);
|
||||
else
|
||||
// NOTE: completely ignoring the Adapter parameter
|
||||
if (Mode >= XboxResolutions.size())
|
||||
{
|
||||
hRet = D3DERR_INVALIDCALL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pMode->Width = XboxResolutions[Mode].W;
|
||||
pMode->Height = XboxResolutions[Mode].H;
|
||||
pMode->RefreshRate = 60;
|
||||
pMode->Format = XboxResolutions[Mode].F;
|
||||
// D3DPRESENTFLAG_FIELD | D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_LOCKABLE_BACKBUFFER
|
||||
pMode->Flags = 0x000000A1;
|
||||
|
||||
// make adjustments to parameters to make sense with windows direct3d
|
||||
if(hRet == D3D_OK)
|
||||
{
|
||||
//
|
||||
// NOTE: WARNING: PC D3DDISPLAYMODE is different than Xbox D3DDISPLAYMODE!
|
||||
//
|
||||
hRet = D3D_OK;
|
||||
}
|
||||
|
||||
// Convert Format (PC->Xbox)
|
||||
pMode->Width = PCMode.Width;
|
||||
pMode->Height = PCMode.Height;
|
||||
pMode->RefreshRate = PCMode.RefreshRate;
|
||||
|
||||
// TODO: Make this configurable in the future?
|
||||
// D3DPRESENTFLAG_FIELD | D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_LOCKABLE_BACKBUFFER
|
||||
pMode->Flags = 0x000000A1;
|
||||
|
||||
pMode->Format = EmuPC2XB_D3DFormat(PCMode.Format);
|
||||
}
|
||||
else
|
||||
{
|
||||
// hRet = S_OK;
|
||||
hRet = D3DERR_INVALIDCALL;
|
||||
// CxbxKrnlCleanup("EnumAdapterModes failed!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return hRet;
|
||||
return S_OK; // Hack
|
||||
return hRet;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
|
|
@ -267,7 +267,7 @@ NTSTATUS CxbxObjectAttributesToNT(xboxkrnl::POBJECT_ATTRIBUTES ObjectAttributes,
|
|||
DbgPrintf(" Org:\"%s\"\n", OriginalPath.c_str());
|
||||
if (_strnicmp(NativePath.c_str(), CxbxBasePath.c_str(), CxbxBasePath.length()) == 0)
|
||||
{
|
||||
DbgPrintf(" New:\"$CxbxPath\\EmuDisk\\%s%s\"\n", (NativePath.substr(CxbxBasePath.length(), std::string::npos)).c_str(), RelativePath.c_str());
|
||||
DbgPrintf(" New:\"$CxbxPath\\EmuDisk\\%s\\%s\"\n", (NativePath.substr(CxbxBasePath.length(), std::string::npos)).c_str(), RelativePath.c_str());
|
||||
}
|
||||
else
|
||||
DbgPrintf(" New:\"$XbePath\\%s\"\n", RelativePath.c_str());
|
||||
|
|
|
@ -815,7 +815,7 @@ DWORD WINAPI XTL::EmuXLaunchNewImage
|
|||
)
|
||||
{
|
||||
LOG_FUNC_BEGIN
|
||||
LOG_FUNC_ARG(lpTitlePath)
|
||||
LOG_FUNC_ARG_STR(lpTitlePath)
|
||||
LOG_FUNC_ARG(pLaunchData)
|
||||
LOG_FUNC_END;
|
||||
|
||||
|
|
Loading…
Reference in New Issue