Temporary check HLE cache file for LLE flags used.

This commit is contained in:
RadWolfie 2018-06-12 13:09:38 -05:00
parent 4760872a03
commit 6dacd65a40
2 changed files with 80 additions and 80 deletions

View File

@ -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;

View File

@ -383,6 +383,8 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
}
EmuUpdateLLEStatus(XbLibScan);
int gFlagsLLE;
g_EmuShared->GetFlagsLLE(&gFlagsLLE);
printf("\n");
printf("*******************************************************************************\n");
@ -422,84 +424,81 @@ 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 cacheFlagsLLE = GetPrivateProfileInt("Info", "FlagsLLE", 0, filename.c_str());
if (cacheFlagsLLE != gFlagsLLE) {
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 +571,10 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
WritePrivateProfileString("Info", "HLECacheHash", HLECacheHashString.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());