mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 05:40:01 -06:00
HLE/GeckoCode: Add new HLE hook exit trampoline
Dolphin emulates GeckoCodes by fiddling with the CPU state when a VI Interrupt occurs. The problem with this is that we don't know where the PC is so it's non-deterministic and not necessarily suitable for use with the codehandler. There are two options: Patch the game like Gecko OS either directly or using HLE::Patch, or use a trampoline so we can branch from any PC even if it would otherwise not be valid. The problem with Gecko OS patches is there are 10 of them and they have to be configured manually (i.e. Game INIs to would need to have a [Core]GeckoHookType property). HLE_Misc::GeckoReturnTrampoline enables the Code Handler to be entered from anywhere, the trampoline restores all the registers that had to be secretly saved to the stack.
This commit is contained in:
@ -35,19 +35,23 @@ public:
|
||||
|
||||
// Installation address for codehandler.bin in the Game's RAM
|
||||
constexpr u32 INSTALLER_BASE_ADDRESS = 0x80001800;
|
||||
constexpr u32 ENTRY_POINT = 0x800018A8;
|
||||
constexpr u32 INSTALLER_END_ADDRESS = 0x80003000;
|
||||
constexpr u32 ENTRY_POINT = INSTALLER_BASE_ADDRESS + 0xA8;
|
||||
// If the GCT is max-length then this is the second word of the End code (0xF0000000 0x00000000)
|
||||
// If the table is shorter than the max-length then this address is unused / contains trash.
|
||||
constexpr u32 HLE_TRAMPOLINE_ADDRESS = INSTALLER_END_ADDRESS - 4;
|
||||
|
||||
// This forms part of a communication protocol with HLE_Misc::HLEGeckoCodehandler.
|
||||
// This forms part of a communication protocol with HLE_Misc::GeckoCodeHandlerICacheFlush.
|
||||
// Basically, codehandleronly.s doesn't use ICBI like it's supposed to when patching the
|
||||
// game's code. This results in the JIT happily ignoring all code patches for blocks that
|
||||
// are already compiled. The hack for getting around that is that the first 5 frames after
|
||||
// the handler is installed (0xD01F1BAD -> +5 -> 0xD01F1BB2) cause full ICache resets.
|
||||
//
|
||||
// HLEGeckoCodehandler will increment this value 5 times then cease flushing the ICache to
|
||||
// GeckoCodeHandlerICacheFlush will increment this value 5 times then cease flushing the ICache to
|
||||
// preserve the emulation performance.
|
||||
constexpr u32 MAGIC_GAMEID = 0xD01F1BAD;
|
||||
|
||||
void SetActiveCodes(const std::vector<GeckoCode>& gcodes);
|
||||
void RunCodeHandler();
|
||||
void RunCodeHandler(u32 msr_reg);
|
||||
|
||||
} // namespace Gecko
|
||||
|
Reference in New Issue
Block a user