Merge pull request #1281 from RadWolfie/check-hle-cache-file-for-lle-stat
Temporary check HLE cache file for LLE flags used.
This commit is contained in:
commit
c2b4162a9b
|
@ -1320,7 +1320,6 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
case ID_EMULATION_LLE_JIT:
|
||||
{
|
||||
m_FlagsLLE = m_FlagsLLE ^ LLE_JIT;
|
||||
ClearHLECache();
|
||||
RefreshMenus();
|
||||
}
|
||||
break;
|
||||
|
@ -1328,7 +1327,6 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
case ID_EMULATION_LLE_APU:
|
||||
{
|
||||
m_FlagsLLE = m_FlagsLLE ^ LLE_APU;
|
||||
ClearHLECache();
|
||||
RefreshMenus();
|
||||
}
|
||||
break;
|
||||
|
@ -1336,7 +1334,6 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
case ID_EMULATION_LLE_GPU:
|
||||
{
|
||||
m_FlagsLLE = m_FlagsLLE ^ LLE_GPU;
|
||||
ClearHLECache();
|
||||
RefreshMenus();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -350,6 +350,9 @@ void EmuUpdateLLEStatus(uint32_t XbLibScan)
|
|||
// NOTE: EmuHLEIntercept do not get to be in XbSymbolDatabase, do the intecept in Cxbx project only.
|
||||
void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
||||
{
|
||||
// NOTE: Increase this revision number any time we changed something inside Cxbx-Reloaded.
|
||||
int revisionCache = 4;
|
||||
|
||||
Xbe::LibraryVersion *pLibraryVersion = (Xbe::LibraryVersion*)pXbeHeader->dwLibraryVersionsAddr;
|
||||
|
||||
uint16 xdkVersion = 0;
|
||||
|
@ -383,6 +386,8 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
|||
}
|
||||
|
||||
EmuUpdateLLEStatus(XbLibScan);
|
||||
int gFlagsLLE;
|
||||
g_EmuShared->GetFlagsLLE(&gFlagsLLE);
|
||||
|
||||
printf("\n");
|
||||
printf("*******************************************************************************\n");
|
||||
|
@ -422,84 +427,86 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
|||
if (HLECacheHash == XbSymbolLibraryVersion()) {
|
||||
char buffer[SHRT_MAX] = { 0 };
|
||||
char* bufferPtr = buffer;
|
||||
|
||||
printf("Using HLE Cache\n");
|
||||
|
||||
GetPrivateProfileSection("Symbols", buffer, sizeof(buffer), filename.c_str());
|
||||
|
||||
// Parse the .INI file into the map of symbol addresses
|
||||
while (strlen(bufferPtr) > 0) {
|
||||
std::string ini_entry(bufferPtr);
|
||||
|
||||
auto separator = ini_entry.find('=');
|
||||
std::string key = ini_entry.substr(0, separator);
|
||||
std::string value = ini_entry.substr(separator + 1, std::string::npos);
|
||||
uint32_t addr = strtol(value.c_str(), 0, 16);
|
||||
|
||||
g_SymbolAddresses[key] = addr;
|
||||
bufferPtr += strlen(bufferPtr) + 1;
|
||||
}
|
||||
|
||||
// Iterate through the map of symbol addresses, calling GetEmuPatchAddr on all functions.
|
||||
for (auto it = g_SymbolAddresses.begin(); it != g_SymbolAddresses.end(); ++it) {
|
||||
std::string functionName = (*it).first;
|
||||
xbaddr location = (*it).second;
|
||||
|
||||
std::stringstream output;
|
||||
output << "HLECache: 0x" << std::setfill('0') << std::setw(8) << std::hex << location
|
||||
<< " -> " << functionName;
|
||||
void* pFunc = GetEmuPatchAddr(functionName);
|
||||
if (pFunc != nullptr)
|
||||
{
|
||||
// skip entries that weren't located at all
|
||||
if (location == NULL)
|
||||
{
|
||||
output << "\t(not patched)";
|
||||
}
|
||||
// Prevent patching illegal addresses
|
||||
else if (location < XBE_IMAGE_BASE)
|
||||
{
|
||||
output << "\t*ADDRESS TOO LOW!*";
|
||||
}
|
||||
else if (location > g_SystemMaxMemory)
|
||||
{
|
||||
output << "\t*ADDRESS TOO HIGH!*";
|
||||
}
|
||||
else
|
||||
{
|
||||
EmuInstallPatch(functionName, location, pFunc);
|
||||
output << "\t*PATCHED*";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (location != NULL)
|
||||
output << "\t(no patch)";
|
||||
}
|
||||
|
||||
output << "\n";
|
||||
printf(output.str().c_str());
|
||||
}
|
||||
|
||||
// Fix up Render state and Texture States
|
||||
if (g_SymbolAddresses.find("D3DDeferredRenderState") == g_SymbolAddresses.end()
|
||||
|| g_SymbolAddresses["D3DDeferredRenderState"] == 0) {
|
||||
EmuWarning("EmuD3DDeferredRenderState was not found!");
|
||||
}
|
||||
|
||||
if (g_SymbolAddresses.find("D3DDeferredTextureState") == g_SymbolAddresses.end()
|
||||
|| g_SymbolAddresses["D3DDeferredTextureState"] == 0) {
|
||||
EmuWarning("EmuD3DDeferredTextureState was not found!");
|
||||
}
|
||||
|
||||
if (g_SymbolAddresses.find("D3DDEVICE") == g_SymbolAddresses.end()
|
||||
|| g_SymbolAddresses["D3DDEVICE"] == 0) {
|
||||
EmuWarning("D3DDEVICE was not found!");
|
||||
}
|
||||
|
||||
EmuD3D_Init_DeferredStates();
|
||||
|
||||
g_HLECacheUsed = true;
|
||||
|
||||
const uint32 cacheRevision = GetPrivateProfileInt("Info", "revision", 0, filename.c_str());
|
||||
const uint32 cacheFlagsLLE = GetPrivateProfileInt("Info", "FlagsLLE", 0, filename.c_str());
|
||||
|
||||
if (cacheFlagsLLE != gFlagsLLE) {
|
||||
g_HLECacheUsed = false;
|
||||
}
|
||||
else if (cacheRevision != revisionCache) {
|
||||
g_HLECacheUsed = false;
|
||||
}
|
||||
|
||||
if (g_HLECacheUsed) {
|
||||
printf("Using HLE Cache\n");
|
||||
|
||||
GetPrivateProfileSection("Symbols", buffer, sizeof(buffer), filename.c_str());
|
||||
|
||||
// Parse the .INI file into the map of symbol addresses
|
||||
while (strlen(bufferPtr) > 0) {
|
||||
std::string ini_entry(bufferPtr);
|
||||
|
||||
auto separator = ini_entry.find('=');
|
||||
std::string key = ini_entry.substr(0, separator);
|
||||
std::string value = ini_entry.substr(separator + 1, std::string::npos);
|
||||
uint32_t addr = strtol(value.c_str(), 0, 16);
|
||||
|
||||
g_SymbolAddresses[key] = addr;
|
||||
bufferPtr += strlen(bufferPtr) + 1;
|
||||
}
|
||||
|
||||
// Iterate through the map of symbol addresses, calling GetEmuPatchAddr on all functions.
|
||||
for (auto it = g_SymbolAddresses.begin(); it != g_SymbolAddresses.end(); ++it) {
|
||||
std::string functionName = (*it).first;
|
||||
xbaddr location = (*it).second;
|
||||
|
||||
std::stringstream output;
|
||||
output << "HLECache: 0x" << std::setfill('0') << std::setw(8) << std::hex << location
|
||||
<< " -> " << functionName;
|
||||
void* pFunc = GetEmuPatchAddr(functionName);
|
||||
if (pFunc != nullptr) {
|
||||
// skip entries that weren't located at all
|
||||
if (location == NULL) {
|
||||
output << "\t(not patched)";
|
||||
}
|
||||
// Prevent patching illegal addresses
|
||||
else if (location < XBE_IMAGE_BASE) {
|
||||
output << "\t*ADDRESS TOO LOW!*";
|
||||
} else if (location > g_SystemMaxMemory) {
|
||||
output << "\t*ADDRESS TOO HIGH!*";
|
||||
} else {
|
||||
EmuInstallPatch(functionName, location, pFunc);
|
||||
output << "\t*PATCHED*";
|
||||
}
|
||||
} else {
|
||||
if (location != NULL)
|
||||
output << "\t(no patch)";
|
||||
}
|
||||
|
||||
output << "\n";
|
||||
printf(output.str().c_str());
|
||||
}
|
||||
|
||||
// Fix up Render state and Texture States
|
||||
if (g_SymbolAddresses.find("D3DDeferredRenderState") == g_SymbolAddresses.end()
|
||||
|| g_SymbolAddresses["D3DDeferredRenderState"] == 0) {
|
||||
EmuWarning("EmuD3DDeferredRenderState was not found!");
|
||||
}
|
||||
|
||||
if (g_SymbolAddresses.find("D3DDeferredTextureState") == g_SymbolAddresses.end()
|
||||
|| g_SymbolAddresses["D3DDeferredTextureState"] == 0) {
|
||||
EmuWarning("EmuD3DDeferredTextureState was not found!");
|
||||
}
|
||||
|
||||
if (g_SymbolAddresses.find("D3DDEVICE") == g_SymbolAddresses.end()
|
||||
|| g_SymbolAddresses["D3DDEVICE"] == 0) {
|
||||
EmuWarning("D3DDEVICE was not found!");
|
||||
}
|
||||
|
||||
EmuD3D_Init_DeferredStates();
|
||||
}
|
||||
}
|
||||
|
||||
// If g_SymbolAddresses didn't get filled, the HLE cache is invalid
|
||||
|
@ -572,6 +579,15 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
|||
WritePrivateProfileString("Info", "HLECacheHash", HLECacheHashString.c_str(), filename.c_str());
|
||||
}
|
||||
|
||||
|
||||
std::stringstream revision;
|
||||
revision << std::dec << revisionCache;
|
||||
WritePrivateProfileString("Info", "revision", revision.str().c_str(), filename.c_str());
|
||||
|
||||
std::stringstream flagsLLE;
|
||||
flagsLLE << std::dec << gFlagsLLE;
|
||||
WritePrivateProfileString("Info", "FlagsLLE", flagsLLE.str().c_str(), filename.c_str());
|
||||
|
||||
// Write the Certificate Details to the cache file
|
||||
WritePrivateProfileString("Certificate", "Name", tAsciiTitle, filename.c_str());
|
||||
|
||||
|
|
Loading…
Reference in New Issue