diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index 2a630ce13..c73d6b292 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp @@ -28,14 +28,15 @@ Common::Profiling::TimingCategory profile_execute("DynCom::Execute"); Common::Profiling::TimingCategory profile_decode("DynCom::Decode"); enum { - COND = (1 << 0), - NON_BRANCH = (1 << 1), - DIRECT_BRANCH = (1 << 2), - INDIRECT_BRANCH = (1 << 3), - CALL = (1 << 4), - RET = (1 << 5), - END_OF_PAGE = (1 << 6), - THUMB = (1 << 7) + COND = (1 << 0), + NON_BRANCH = (1 << 1), + DIRECT_BRANCH = (1 << 2), + INDIRECT_BRANCH = (1 << 3), + CALL = (1 << 4), + RET = (1 << 5), + END_OF_PAGE = (1 << 6), + THUMB = (1 << 7), + BINARY_TRANSLATED = (1 << 8) }; #define RM BITS(sht_oper, 0, 3) @@ -3653,6 +3654,10 @@ static int InterpreterTranslate(ARMul_State* cpu, int& bb_start, u32 addr) { translated: phys_addr += inst_size; + if (BinaryTranslationLoader::CanRun(phys_addr, cpu->TFlag)) + { + inst_base->br = BINARY_TRANSLATED; + } if ((phys_addr & 0xfff) == 0) { inst_base->br = END_OF_PAGE; } diff --git a/src/core/binary_translation/BinaryTranslationLoader.cpp b/src/core/binary_translation/BinaryTranslationLoader.cpp index e90002984..4904aeb62 100644 --- a/src/core/binary_translation/BinaryTranslationLoader.cpp +++ b/src/core/binary_translation/BinaryTranslationLoader.cpp @@ -130,6 +130,8 @@ void BinaryTranslationLoader::Load(FileUtil::IOFile& file) g_verify = *verify_ptr; g_enabled = true; + + LOG_INFO(Loader, "Binary translation enabled"); } void BinaryTranslationLoader::SetCpuState(ARMul_State* state) @@ -155,6 +157,16 @@ bool BinaryTranslationLoader::CanRun(bool specific_address) return true; } +bool BinaryTranslationLoader::CanRun(u32 pc, bool tflag) +{ + if (!g_enabled) return false; + if (tflag) return false; + std::swap(g_state->Reg[15], pc); + auto result = g_can_run_function(); + std::swap(g_state->Reg[15], pc); + return result; +} + uint32_t BinaryTranslationLoader::Run(uint32_t instruction_count) { // No need to check the PC, Run does it anyway diff --git a/src/core/binary_translation/BinaryTranslationLoader.h b/src/core/binary_translation/BinaryTranslationLoader.h index 58b570095..523588a92 100644 --- a/src/core/binary_translation/BinaryTranslationLoader.h +++ b/src/core/binary_translation/BinaryTranslationLoader.h @@ -12,6 +12,8 @@ public: // Checks whether the cpu state can be run // If specific_address, checks the specific PC too static bool CanRun(bool specific_address); + // Checks whether the cpu state can run the specific address at the specific mode + static bool CanRun(u32 pc, bool tflag); // Runs the state provided at SetCpuState. // Returns instruction_count + number of instructions executed static uint32_t Run(uint32_t instruction_count);