replace placeholder to working emulate_system variable set
This commit is contained in:
parent
10b7d06be8
commit
c27da955ab
|
@ -497,8 +497,8 @@ bool IsRdtscInstruction(xbaddr addr)
|
|||
// First the fastest check - does addr contain exact patch from PatchRdtsc?
|
||||
// Second check - is addr on the rdtsc patch list?
|
||||
return (*(uint16_t*)addr == OPCODE_PATCH_RDTSC)
|
||||
// Note : It's not needed to check for g_SkipRdtscPatching,
|
||||
// as when that's set, the g_RdtscPatches vector will be empty
|
||||
// Note : It's not needed to check for g_SkipRdtscPatching,
|
||||
// as when that's set, the g_RdtscPatches vector will be empty
|
||||
// anyway, failing this lookup :
|
||||
&& (std::find(g_RdtscPatches.begin(), g_RdtscPatches.end(), addr) != g_RdtscPatches.end());
|
||||
}
|
||||
|
@ -1130,10 +1130,16 @@ void CxbxKrnlEmulate(unsigned int reserved_systems, blocks_reserved_t blocks_res
|
|||
#endif
|
||||
|
||||
#ifndef CXBXR_EMU
|
||||
// Only for GUI executable with emulation code.
|
||||
blocks_reserved_t blocks_reserved_gui = { 0 };
|
||||
// Reserve console system's memory ranges before start initialize.
|
||||
if (!ReserveAddressRanges(emulate_system, blocks_reserved_gui)) {
|
||||
CxbxKrnlCleanup("Failed to reserve required memory ranges!", GetLastError());
|
||||
}
|
||||
// Initialize the memory manager
|
||||
blocks_reserved_t SystemDevBlocksReserved = { 0 };
|
||||
g_VMManager.Initialize(0, BootFlags, SystemDevBlocksReserved);
|
||||
g_VMManager.Initialize(emulate_system, BootFlags, blocks_reserved_gui);
|
||||
#else
|
||||
// Release unnecessary memory ranges to allow console/host to use those memory ranges.
|
||||
FreeAddressRanges(emulate_system, reserved_systems, blocks_reserved);
|
||||
// Initialize the memory manager
|
||||
g_VMManager.Initialize(emulate_system, BootFlags, blocks_reserved);
|
||||
|
@ -1169,15 +1175,15 @@ void CxbxKrnlEmulate(unsigned int reserved_systems, blocks_reserved_t blocks_res
|
|||
// HACK: Attempt to patch out XBE header reads
|
||||
// This works by searching for the XBEH signature and replacing it with what appears in host address space instead
|
||||
// Test case: Half Life 2
|
||||
// Iterate through each CODE section
|
||||
for (uint32_t sectionIndex = 0; sectionIndex < CxbxKrnl_Xbe->m_Header.dwSections; sectionIndex++) {
|
||||
if (!CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwFlags.bExecutable) {
|
||||
continue;
|
||||
}
|
||||
|
||||
EmuLogInit(LOG_LEVEL::INFO, "Searching for XBEH in section %s", CxbxKrnl_Xbe->m_szSectionName[sectionIndex]);
|
||||
xbaddr startAddr = CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwVirtualAddr;
|
||||
xbaddr endAddr = startAddr + CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwSizeofRaw;
|
||||
// Iterate through each CODE section
|
||||
for (uint32_t sectionIndex = 0; sectionIndex < CxbxKrnl_Xbe->m_Header.dwSections; sectionIndex++) {
|
||||
if (!CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwFlags.bExecutable) {
|
||||
continue;
|
||||
}
|
||||
|
||||
EmuLogInit(LOG_LEVEL::INFO, "Searching for XBEH in section %s", CxbxKrnl_Xbe->m_szSectionName[sectionIndex]);
|
||||
xbaddr startAddr = CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwVirtualAddr;
|
||||
xbaddr endAddr = startAddr + CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwSizeofRaw;
|
||||
for (xbaddr addr = startAddr; addr < endAddr; addr++) {
|
||||
if (*(uint32_t*)addr == 0x48454258) {
|
||||
EmuLogInit(LOG_LEVEL::INFO, "Patching XBEH at 0x%08X", addr);
|
||||
|
|
|
@ -77,20 +77,12 @@ bool VirtualMemoryArea::CanBeMergedWith(const VirtualMemoryArea& next) const
|
|||
void VMManager::Initialize(unsigned int SystemType, int BootFlags, blocks_reserved_t blocks_reserved)
|
||||
{
|
||||
if ((BootFlags & BOOT_QUICK_REBOOT) == 0) {
|
||||
#ifndef CXBXR_EMU
|
||||
SystemType = g_bIsRetail ? SYSTEM_XBOX : g_bIsChihiro ? SYSTEM_CHIHIRO : SYSTEM_DEVKIT; // TODO: Temporary placeholder until loader is functional.
|
||||
#endif
|
||||
g_EmuShared->SetMmLayout(&SystemType);
|
||||
}
|
||||
else {
|
||||
g_EmuShared->GetMmLayout(&SystemType);
|
||||
}
|
||||
|
||||
#ifndef CXBXR_EMU
|
||||
if (!ReserveAddressRanges(SystemType, blocks_reserved)) {
|
||||
CxbxKrnlCleanup("Failed to reserve required memory ranges!", GetLastError());
|
||||
}
|
||||
#endif
|
||||
m_MmLayoutChihiro = (SystemType == SYSTEM_CHIHIRO);
|
||||
m_MmLayoutDebug = (SystemType == SYSTEM_DEVKIT);
|
||||
m_MmLayoutRetail = (SystemType == SYSTEM_XBOX);
|
||||
|
|
Loading…
Reference in New Issue