separate D3D8 build version away from general build version
Plus prepare DSOUND build version to be use.
This commit is contained in:
parent
6bc8294c79
commit
63663301f2
|
@ -44,6 +44,10 @@ static_assert(false, "Please implement support for cross-platform's user profile
|
||||||
|
|
||||||
std::string g_exec_filepath;
|
std::string g_exec_filepath;
|
||||||
|
|
||||||
|
// Individual library version
|
||||||
|
uint16_t g_LibVersion_D3D8 = 0;
|
||||||
|
uint16_t g_LibVersion_DSOUND = 0;
|
||||||
|
|
||||||
// NOTE: Update settings_version when add/edit/delete setting's structure.
|
// NOTE: Update settings_version when add/edit/delete setting's structure.
|
||||||
const unsigned int settings_version = 4;
|
const unsigned int settings_version = 4;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,10 @@
|
||||||
|
|
||||||
extern std::string g_exec_filepath;
|
extern std::string g_exec_filepath;
|
||||||
|
|
||||||
|
// Individual library version
|
||||||
|
extern uint16_t g_LibVersion_D3D8;
|
||||||
|
extern uint16_t g_LibVersion_DSOUND;
|
||||||
|
|
||||||
#define szSettings_alloc_error "ERROR: Unable to allocate Settings class."
|
#define szSettings_alloc_error "ERROR: Unable to allocate Settings class."
|
||||||
|
|
||||||
// Cxbx-Reloaded's data storage location.
|
// Cxbx-Reloaded's data storage location.
|
||||||
|
|
|
@ -126,9 +126,6 @@ XTL::D3DCAPS g_D3DCaps = {}; // Direct3D Caps
|
||||||
// wireframe toggle
|
// wireframe toggle
|
||||||
static int g_iWireframe = 0;
|
static int g_iWireframe = 0;
|
||||||
|
|
||||||
// build version
|
|
||||||
extern uint32_t g_BuildVersion;
|
|
||||||
|
|
||||||
typedef uint64_t resource_key_t;
|
typedef uint64_t resource_key_t;
|
||||||
|
|
||||||
extern void UpdateFPSCounter();
|
extern void UpdateFPSCounter();
|
||||||
|
@ -3655,7 +3652,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexShaderConstant)
|
||||||
// some shaders need to add 96 to use ranges 0 to 192. This fixes 3911 - 4361 games and XDK
|
// some shaders need to add 96 to use ranges 0 to 192. This fixes 3911 - 4361 games and XDK
|
||||||
// samples, but breaks Turok.
|
// samples, but breaks Turok.
|
||||||
// See D3DDevice_GetVertexShaderConstant
|
// See D3DDevice_GetVertexShaderConstant
|
||||||
if(g_BuildVersion <= 4361)
|
if(g_LibVersion_D3D8 <= 4361)
|
||||||
Register += 96;
|
Register += 96;
|
||||||
|
|
||||||
HRESULT hRet;
|
HRESULT hRet;
|
||||||
|
@ -8194,7 +8191,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_GetVertexShaderConstant)
|
||||||
// some shaders need to add 96 to use ranges 0 to 192. This fixes 3911 - 4361 games and XDK
|
// some shaders need to add 96 to use ranges 0 to 192. This fixes 3911 - 4361 games and XDK
|
||||||
// samples, but breaks Turok.
|
// samples, but breaks Turok.
|
||||||
// See D3DDevice_SetVertexShaderConstant
|
// See D3DDevice_SetVertexShaderConstant
|
||||||
if (g_BuildVersion <= 4361)
|
if (g_LibVersion_D3D8 <= 4361)
|
||||||
Register += 96;
|
Register += 96;
|
||||||
|
|
||||||
HRESULT hRet = g_pD3DDevice->GetVertexShaderConstantF
|
HRESULT hRet = g_pD3DDevice->GetVertexShaderConstantF
|
||||||
|
@ -9118,7 +9115,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetPixelShaderConstant_4)
|
||||||
|
|
||||||
// TODO: This hack is necessary for Vertex Shaders on XDKs prior to 4361, but if this
|
// TODO: This hack is necessary for Vertex Shaders on XDKs prior to 4361, but if this
|
||||||
// causes problems with pixel shaders, feel free to comment out the hack below.
|
// causes problems with pixel shaders, feel free to comment out the hack below.
|
||||||
if(g_BuildVersion <= 4361)
|
if(g_LibVersion_D3D8 <= 4361)
|
||||||
Register += 96;
|
Register += 96;
|
||||||
|
|
||||||
HRESULT hRet = g_pD3DDevice->SetPixelShaderConstantF
|
HRESULT hRet = g_pD3DDevice->SetPixelShaderConstantF
|
||||||
|
|
|
@ -34,9 +34,8 @@
|
||||||
DWORD *XTL::EmuD3DDeferredRenderState = nullptr;
|
DWORD *XTL::EmuD3DDeferredRenderState = nullptr;
|
||||||
DWORD *XTL::EmuD3DDeferredTextureState = nullptr;
|
DWORD *XTL::EmuD3DDeferredTextureState = nullptr;
|
||||||
|
|
||||||
extern uint32_t g_BuildVersion;
|
|
||||||
|
|
||||||
#include "core\hle\Intercept.hpp" // For g_SymbolAddresses
|
#include "core\hle\Intercept.hpp" // For g_SymbolAddresses
|
||||||
|
#include "common/Settings.hpp" // For g_LibVersion_D3D8
|
||||||
|
|
||||||
void VerifyAndFixEmuDeferredRenderStateOffset()
|
void VerifyAndFixEmuDeferredRenderStateOffset()
|
||||||
{
|
{
|
||||||
|
@ -61,7 +60,7 @@ void VerifyAndFixEmuDeferredRenderStateOffset()
|
||||||
// Calculate index of D3DRS_CULLMODE for this XDK. We start counting from the first deferred state (D3DRS_FOGENABLE)
|
// Calculate index of D3DRS_CULLMODE for this XDK. We start counting from the first deferred state (D3DRS_FOGENABLE)
|
||||||
DWORD CullModeIndex = 0;
|
DWORD CullModeIndex = 0;
|
||||||
for (int i = XTL::X_D3DRS_FOGENABLE; i < XTL::X_D3DRS_CULLMODE; i++) {
|
for (int i = XTL::X_D3DRS_FOGENABLE; i < XTL::X_D3DRS_CULLMODE; i++) {
|
||||||
if (XTL::DxbxRenderStateInfo[i].V <= g_BuildVersion) {
|
if (XTL::DxbxRenderStateInfo[i].V <= g_LibVersion_D3D8) {
|
||||||
CullModeIndex++;
|
CullModeIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +80,7 @@ void UpdateDeferredRenderStates()
|
||||||
// Loop through all deferred render states
|
// Loop through all deferred render states
|
||||||
for (unsigned int RenderState = XTL::X_D3DRS_FOGENABLE; RenderState <= XTL::X_D3DRS_PRESENTATIONINTERVAL; RenderState++) {
|
for (unsigned int RenderState = XTL::X_D3DRS_FOGENABLE; RenderState <= XTL::X_D3DRS_PRESENTATIONINTERVAL; RenderState++) {
|
||||||
// If the current state is not present within our desired XDK, skip it
|
// If the current state is not present within our desired XDK, skip it
|
||||||
if (XTL::DxbxRenderStateInfo[RenderState].V >= g_BuildVersion) {
|
if (XTL::DxbxRenderStateInfo[RenderState].V >= g_LibVersion_D3D8) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +173,7 @@ DWORD GetDeferredTextureStateFromIndex(DWORD State)
|
||||||
{
|
{
|
||||||
// On early XDKs, we need to shuffle the values around a little
|
// On early XDKs, we need to shuffle the values around a little
|
||||||
// TODO: Verify which XDK version this change occurred at
|
// TODO: Verify which XDK version this change occurred at
|
||||||
if (g_BuildVersion <= 3948) {
|
if (g_LibVersion_D3D8 <= 3948) {
|
||||||
// Values range 0-9 (D3DTSS_COLOROP to D3DTSS_TEXTURETRANSFORMFLAGS) become 12-21
|
// Values range 0-9 (D3DTSS_COLOROP to D3DTSS_TEXTURETRANSFORMFLAGS) become 12-21
|
||||||
if (State <= 9) {
|
if (State <= 9) {
|
||||||
return State + 12;
|
return State + 12;
|
||||||
|
@ -228,7 +227,7 @@ DWORD TranslateXDKSpecificD3DTOP(DWORD Value)
|
||||||
// TODO: Determine when exactly these values changed
|
// TODO: Determine when exactly these values changed
|
||||||
// So far, 4134 is the earliest version we've seen using these mappings
|
// So far, 4134 is the earliest version we've seen using these mappings
|
||||||
// But this may change
|
// But this may change
|
||||||
if (g_BuildVersion >= 4134) {
|
if (g_LibVersion_D3D8 >= 4134) {
|
||||||
// For these XDKs, the mapping has been confirmed to match our internal mapping
|
// For these XDKs, the mapping has been confirmed to match our internal mapping
|
||||||
return Value;
|
return Value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,6 @@ static const char* section_symbols = "Symbols";
|
||||||
std::map<std::string, xbaddr> g_SymbolAddresses;
|
std::map<std::string, xbaddr> g_SymbolAddresses;
|
||||||
bool g_SymbolCacheUsed = false;
|
bool g_SymbolCacheUsed = false;
|
||||||
|
|
||||||
// D3D build version
|
|
||||||
uint32_t g_BuildVersion = 0;
|
|
||||||
|
|
||||||
bool bLLE_APU = false; // Set this to true for experimental APU (sound) LLE
|
bool bLLE_APU = false; // Set this to true for experimental APU (sound) LLE
|
||||||
bool bLLE_GPU = false; // Set this to true for experimental GPU (graphics) LLE
|
bool bLLE_GPU = false; // Set this to true for experimental GPU (graphics) LLE
|
||||||
bool bLLE_USB = false; // Set this to true for experimental USB (input) LLE
|
bool bLLE_USB = false; // Set this to true for experimental USB (input) LLE
|
||||||
|
@ -348,16 +345,29 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
||||||
uint32_t dwLibraryVersions = pXbeHeader->dwLibraryVersions;
|
uint32_t dwLibraryVersions = pXbeHeader->dwLibraryVersions;
|
||||||
const char* SectionName = nullptr;
|
const char* SectionName = nullptr;
|
||||||
Xbe::SectionHeader* pSectionHeaders = (Xbe::SectionHeader*)pXbeHeader->dwSectionHeadersAddr;
|
Xbe::SectionHeader* pSectionHeaders = (Xbe::SectionHeader*)pXbeHeader->dwSectionHeadersAddr;
|
||||||
|
uint32_t XbLibFlag;
|
||||||
|
|
||||||
// Get the highest revision build and prefix library to scan.
|
// Get the highest revision build and prefix library to scan.
|
||||||
for (uint32_t v = 0; v < dwLibraryVersions; v++) {
|
for (uint32_t v = 0; v < dwLibraryVersions; v++) {
|
||||||
uint16_t BuildVersion = pLibraryVersion[v].wBuildVersion;
|
uint16_t BuildVersion, QFEVersion;
|
||||||
uint16_t QFEVersion = pLibraryVersion[v].wFlags.QFEVersion;
|
BuildVersion = pLibraryVersion[v].wBuildVersion;
|
||||||
|
QFEVersion = pLibraryVersion[v].wFlags.QFEVersion;
|
||||||
|
|
||||||
if (xdkVersion < BuildVersion) {
|
if (xdkVersion < BuildVersion) {
|
||||||
xdkVersion = BuildVersion;
|
xdkVersion = BuildVersion;
|
||||||
}
|
}
|
||||||
XbLibScan |= XbSymbolLibrayToFlag(std::string(pLibraryVersion[v].szName, pLibraryVersion[v].szName + 8).c_str());
|
XbLibFlag = XbSymbolLibrayToFlag(std::string(pLibraryVersion[v].szName, pLibraryVersion[v].szName + 8).c_str());
|
||||||
|
XbLibScan |= XbLibFlag;
|
||||||
|
|
||||||
|
// Keep certain library versions for plugin usage.
|
||||||
|
if ((XbLibFlag & (XbSymbolLib_D3D8 | XbSymbolLib_D3D8LTCG)) > 0) {
|
||||||
|
if (g_LibVersion_D3D8 < BuildVersion) {
|
||||||
|
g_LibVersion_D3D8 = BuildVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((XbLibFlag & XbSymbolLib_DSOUND) > 0) {
|
||||||
|
g_LibVersion_DSOUND = BuildVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since XDK 4039 title does not have library version for DSOUND, let's check section header if it exists or not.
|
// Since XDK 4039 title does not have library version for DSOUND, let's check section header if it exists or not.
|
||||||
|
@ -365,6 +375,11 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
||||||
SectionName = (const char*)pSectionHeaders[v].dwSectionNameAddr;
|
SectionName = (const char*)pSectionHeaders[v].dwSectionNameAddr;
|
||||||
if (strncmp(SectionName, Lib_DSOUND, 8) == 0) {
|
if (strncmp(SectionName, Lib_DSOUND, 8) == 0) {
|
||||||
XbLibScan |= XbSymbolLib_DSOUND;
|
XbLibScan |= XbSymbolLib_DSOUND;
|
||||||
|
|
||||||
|
// If DSOUND version is not set, we need to force set it.
|
||||||
|
if (g_LibVersion_DSOUND == 0) {
|
||||||
|
g_LibVersion_DSOUND = xdkVersion;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,7 +420,7 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
||||||
|
|
||||||
symbolCacheData.LoadFile(filename.c_str());
|
symbolCacheData.LoadFile(filename.c_str());
|
||||||
|
|
||||||
g_BuildVersion = symbolCacheData.GetLongValue(section_libs, sect_libs_keys.BuildVersion, /*Default=*/0);
|
xdkVersion = symbolCacheData.GetLongValue(section_libs, sect_libs_keys.BuildVersion, /*Default=*/0);
|
||||||
|
|
||||||
// Verify the version of the cache file against the Symbol Database version hash
|
// Verify the version of the cache file against the Symbol Database version hash
|
||||||
const uint32_t SymbolDatabaseVersionHash = symbolCacheData.GetLongValue(section_info, sect_info_keys.SymbolDatabaseVersionHash, /*Default=*/0);
|
const uint32_t SymbolDatabaseVersionHash = symbolCacheData.GetLongValue(section_info, sect_info_keys.SymbolDatabaseVersionHash, /*Default=*/0);
|
||||||
|
@ -474,17 +489,6 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
||||||
|
|
||||||
std::printf("Symbol: Detected Microsoft XDK application...\n");
|
std::printf("Symbol: Detected Microsoft XDK application...\n");
|
||||||
|
|
||||||
// TODO: Is this enough for alias? We need to verify it.
|
|
||||||
if ((XbLibScan & XbSymbolLib_D3D8) > 0 || (XbLibScan & XbSymbolLib_D3D8LTCG) > 0) {
|
|
||||||
g_BuildVersion = xdkVersion;
|
|
||||||
}
|
|
||||||
#if 0 // NOTE: This is a note for what we should do for above.
|
|
||||||
if (BuildVersion >= 5558 && BuildVersion <= 5659 && QFEVersion > 1) {
|
|
||||||
EmuLog(LOG_LEVEL::WARNING, "D3D8 version 1.0.%d.%d Title Detected: This game uses an alias version 1.0.5788", BuildVersion, QFEVersion);
|
|
||||||
BuildVersion = 5788;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0 // NOTE: This code is currently disabled due to not optimized and require more work to do.
|
#if 0 // NOTE: This code is currently disabled due to not optimized and require more work to do.
|
||||||
|
|
||||||
XbSymbolRegisterLibrary(XbLibScan);
|
XbSymbolRegisterLibrary(XbLibScan);
|
||||||
|
@ -537,7 +541,7 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
||||||
symbolCacheData.SetLongValue(section_libs, LibraryName.c_str(), pLibraryVersion[i].wBuildVersion, nullptr, /*UseHex =*/false);
|
symbolCacheData.SetLongValue(section_libs, LibraryName.c_str(), pLibraryVersion[i].wBuildVersion, nullptr, /*UseHex =*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
symbolCacheData.SetLongValue(section_libs, sect_libs_keys.BuildVersion, g_BuildVersion, nullptr, /*UseHex =*/false);
|
symbolCacheData.SetLongValue(section_libs, sect_libs_keys.BuildVersion, xdkVersion, nullptr, /*UseHex =*/false);
|
||||||
|
|
||||||
// Store detected symbol addresses
|
// Store detected symbol addresses
|
||||||
for(auto it = g_SymbolAddresses.begin(); it != g_SymbolAddresses.end(); ++it) {
|
for(auto it = g_SymbolAddresses.begin(); it != g_SymbolAddresses.end(); ++it) {
|
||||||
|
|
Loading…
Reference in New Issue