diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index d55b973936389c9dfbb20092d47817cdefb2011c..6f3bc6f8443fe30072553a437e2c7e29a4d2a45d 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -18,26 +18,24 @@ int __cdecl main(int argc, char **argv) { std::string program_dir = File::GetCurrentDir(); - LogManager::Init(); + LogManager::Init(); EmuWindow_GLFW* emu_window = new EmuWindow_GLFW; - System::Init(emu_window); + System::Init(emu_window); std::string boot_filename = "homebrew.elf"; std::string error_str; - + bool res = Loader::LoadFile(boot_filename, &error_str); if (!res) { ERROR_LOG(BOOT, "Failed to load ROM: %s", error_str.c_str()); } - for (;;) { - Core::SingleStep(); - } + Core::RunLoop(); delete emu_window; - return 0; + return 0; } diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 31958ac281f3ad531d30de0c68ec181a44b88116..cf9e1bffce9dc85a83a330b847f885925f8487ce 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -6,6 +6,8 @@ #include "core/core.h" #include "core/loader.h" +#include "core/hw/hw.h" + #include "video_core/video_core.h" #include "version.h" @@ -40,6 +42,7 @@ void EmuThread::run() emit CPUStepped(); } } + HW::Update(); } Core::Stop(); diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index 602c91e302997b32a8958fc5823e3fb174890e82..5c382ebbdd7303e90a53278015792eabfb539a58 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h @@ -17,12 +17,20 @@ public: ~ARM_Interface() { } + /** + * Runs the CPU for the given number of instructions + * @param num_instructions Number of instructions to run + */ + void Run(int num_instructions) { + ExecuteInstructions(num_instructions); + m_num_instructions += num_instructions; + } + /// Step CPU by one instruction void Step() { - ExecuteInstruction(); - m_num_instructions++; + Run(1); } - + /** * Set the Program Counter to an address * @param addr Address to set PC to @@ -74,8 +82,11 @@ public: protected: - /// Execture next instruction - virtual void ExecuteInstruction() = 0; + /** + * Executes the given number of instructions + * @param num_instructions Number of instructions to executes + */ + virtual void ExecuteInstructions(int num_instructions) = 0; private: diff --git a/src/core/arm/interpreter/arm_interpreter.cpp b/src/core/arm/interpreter/arm_interpreter.cpp index 4e1387fdb63cd4d4727d8fe00ecb19dc7749db76..c21ff0464983a8110d52b3c9208e3514b162e135 100644 --- a/src/core/arm/interpreter/arm_interpreter.cpp +++ b/src/core/arm/interpreter/arm_interpreter.cpp @@ -93,16 +93,11 @@ u64 ARM_Interpreter::GetTicks() const { return ARMul_Time(m_state); } -/// Execture next instruction -void ARM_Interpreter::ExecuteInstruction() { - m_state->step++; - m_state->cycle++; - m_state->EndCondition = 0; - m_state->stop_simulator = 0; - m_state->NextInstr = RESUME; - m_state->last_pc = m_state->Reg[15]; - m_state->Reg[15] = ARMul_DoInstr(m_state); - m_state->Cpsr = ((m_state->Cpsr & 0x0fffffdf) | (m_state->NFlag << 31) | (m_state->ZFlag << 30) | - (m_state->CFlag << 29) | (m_state->VFlag << 28) | (m_state->TFlag << 5)); - m_state->NextInstr |= PRIMEPIPE; // Flush pipe +/** + * Executes the given number of instructions + * @param num_instructions Number of instructions to executes + */ +void ARM_Interpreter::ExecuteInstructions(int num_instructions) { + m_state->NumInstrsToExecute = num_instructions; + ARMul_Emulate32(m_state); } diff --git a/src/core/arm/interpreter/arm_interpreter.h b/src/core/arm/interpreter/arm_interpreter.h index 78b188bee4fba70669b7a0826b0a6c9542dc5c71..474ba3e450615e1b29c50655e901b1f59e342652 100644 --- a/src/core/arm/interpreter/arm_interpreter.h +++ b/src/core/arm/interpreter/arm_interpreter.h @@ -62,8 +62,11 @@ public: protected: - /// Execture next instruction - void ExecuteInstruction(); + /** + * Executes the given number of instructions + * @param num_instructions Number of instructions to executes + */ + void ExecuteInstructions(int num_instructions); private: diff --git a/src/core/arm/interpreter/armdefs.h b/src/core/arm/interpreter/armdefs.h index 821825ae61953798fc2ac76bf735ed1f3b3e8065..5b2abc7f743e67af201572a52244e7e14ae9c5cf 100644 --- a/src/core/arm/interpreter/armdefs.h +++ b/src/core/arm/interpreter/armdefs.h @@ -288,6 +288,7 @@ struct ARMul_State ARMword loaded_addr, decoded_addr; /* saved pipeline state addr*/ unsigned int NumScycles, NumNcycles, NumIcycles, NumCcycles, NumFcycles; /* emulated cycles used */ unsigned long long NumInstrs; /* the number of instructions executed */ + unsigned NumInstrsToExecute; unsigned NextInstr; unsigned VectorCatch; /* caught exception mask */ unsigned CallDebug; /* set to call the debugger */ diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp index 87141653fca3d2a699b13d6f70b7e2d1b3585ac3..32e315f4b85767b3dac9e1942d92760dce6d2f44 100644 --- a/src/core/arm/interpreter/armemu.cpp +++ b/src/core/arm/interpreter/armemu.cpp @@ -4734,7 +4734,7 @@ TEST_EMULATE: else if (state->Emulate != RUN) break; } - while (!state->stop_simulator); + while (state->NumInstrsToExecute--); state->decoded = decoded; state->loaded = loaded; diff --git a/src/core/core.cpp b/src/core/core.cpp index 859a62c78fad00537d09739c11e54a7e75c3e8d3..61c237b2c322800c4d2cb3e3b8c8fac0dc2cbf90 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -4,8 +4,9 @@ #include "common/common_types.h" #include "common/log.h" -#include "core/core.h" +#include "common/symbols.h" +#include "core/core.h" #include "core/mem_map.h" #include "core/hw/hw.h" #include "core/arm/disassembler/arm_disasm.h" @@ -19,13 +20,15 @@ ARM_Interface* g_sys_core = NULL; ///< ARM11 system (OS) core /// Run the core CPU loop void RunLoop() { - // TODO(ShizZy): ImplementMe + for (;;){ + g_app_core->Run(10000); + HW::Update(); + } } /// Step the CPU one instruction void SingleStep() { g_app_core->Step(); - HW::Update(); } /// Halt the core