summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/citra/citra.cpp12
-rw-r--r--src/citra_qt/bootmanager.cpp3
-rw-r--r--src/core/arm/arm_interface.h21
-rw-r--r--src/core/arm/interpreter/arm_interpreter.cpp19
-rw-r--r--src/core/arm/interpreter/arm_interpreter.h7
-rw-r--r--src/core/arm/interpreter/armdefs.h1
-rw-r--r--src/core/arm/interpreter/armemu.cpp2
-rw-r--r--src/core/core.cpp9
8 files changed, 44 insertions, 30 deletions
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp
index d55b97393..6f3bc6f84 100644
--- a/src/citra/citra.cpp
+++ b/src/citra/citra.cpp
@@ -18,26 +18,24 @@
18int __cdecl main(int argc, char **argv) { 18int __cdecl main(int argc, char **argv) {
19 std::string program_dir = File::GetCurrentDir(); 19 std::string program_dir = File::GetCurrentDir();
20 20
21 LogManager::Init(); 21 LogManager::Init();
22 22
23 EmuWindow_GLFW* emu_window = new EmuWindow_GLFW; 23 EmuWindow_GLFW* emu_window = new EmuWindow_GLFW;
24 24
25 System::Init(emu_window); 25 System::Init(emu_window);
26 26
27 std::string boot_filename = "homebrew.elf"; 27 std::string boot_filename = "homebrew.elf";
28 std::string error_str; 28 std::string error_str;
29 29
30 bool res = Loader::LoadFile(boot_filename, &error_str); 30 bool res = Loader::LoadFile(boot_filename, &error_str);
31 31
32 if (!res) { 32 if (!res) {
33 ERROR_LOG(BOOT, "Failed to load ROM: %s", error_str.c_str()); 33 ERROR_LOG(BOOT, "Failed to load ROM: %s", error_str.c_str());
34 } 34 }
35 35
36 for (;;) { 36 Core::RunLoop();
37 Core::SingleStep();
38 }
39 37
40 delete emu_window; 38 delete emu_window;
41 39
42 return 0; 40 return 0;
43} 41}
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index 31958ac28..cf9e1bffc 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -6,6 +6,8 @@
6 6
7#include "core/core.h" 7#include "core/core.h"
8#include "core/loader.h" 8#include "core/loader.h"
9#include "core/hw/hw.h"
10
9#include "video_core/video_core.h" 11#include "video_core/video_core.h"
10 12
11#include "version.h" 13#include "version.h"
@@ -40,6 +42,7 @@ void EmuThread::run()
40 emit CPUStepped(); 42 emit CPUStepped();
41 } 43 }
42 } 44 }
45 HW::Update();
43 } 46 }
44 47
45 Core::Stop(); 48 Core::Stop();
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h
index 602c91e30..5c382ebbd 100644
--- a/src/core/arm/arm_interface.h
+++ b/src/core/arm/arm_interface.h
@@ -17,12 +17,20 @@ public:
17 ~ARM_Interface() { 17 ~ARM_Interface() {
18 } 18 }
19 19
20 /**
21 * Runs the CPU for the given number of instructions
22 * @param num_instructions Number of instructions to run
23 */
24 void Run(int num_instructions) {
25 ExecuteInstructions(num_instructions);
26 m_num_instructions += num_instructions;
27 }
28
20 /// Step CPU by one instruction 29 /// Step CPU by one instruction
21 void Step() { 30 void Step() {
22 ExecuteInstruction(); 31 Run(1);
23 m_num_instructions++;
24 } 32 }
25 33
26 /** 34 /**
27 * Set the Program Counter to an address 35 * Set the Program Counter to an address
28 * @param addr Address to set PC to 36 * @param addr Address to set PC to
@@ -74,8 +82,11 @@ public:
74 82
75protected: 83protected:
76 84
77 /// Execture next instruction 85 /**
78 virtual void ExecuteInstruction() = 0; 86 * Executes the given number of instructions
87 * @param num_instructions Number of instructions to executes
88 */
89 virtual void ExecuteInstructions(int num_instructions) = 0;
79 90
80private: 91private:
81 92
diff --git a/src/core/arm/interpreter/arm_interpreter.cpp b/src/core/arm/interpreter/arm_interpreter.cpp
index 4e1387fdb..c21ff0464 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 {
93 return ARMul_Time(m_state); 93 return ARMul_Time(m_state);
94} 94}
95 95
96/// Execture next instruction 96/**
97void ARM_Interpreter::ExecuteInstruction() { 97 * Executes the given number of instructions
98 m_state->step++; 98 * @param num_instructions Number of instructions to executes
99 m_state->cycle++; 99 */
100 m_state->EndCondition = 0; 100void ARM_Interpreter::ExecuteInstructions(int num_instructions) {
101 m_state->stop_simulator = 0; 101 m_state->NumInstrsToExecute = num_instructions;
102 m_state->NextInstr = RESUME; 102 ARMul_Emulate32(m_state);
103 m_state->last_pc = m_state->Reg[15];
104 m_state->Reg[15] = ARMul_DoInstr(m_state);
105 m_state->Cpsr = ((m_state->Cpsr & 0x0fffffdf) | (m_state->NFlag << 31) | (m_state->ZFlag << 30) |
106 (m_state->CFlag << 29) | (m_state->VFlag << 28) | (m_state->TFlag << 5));
107 m_state->NextInstr |= PRIMEPIPE; // Flush pipe
108} 103}
diff --git a/src/core/arm/interpreter/arm_interpreter.h b/src/core/arm/interpreter/arm_interpreter.h
index 78b188bee..474ba3e45 100644
--- a/src/core/arm/interpreter/arm_interpreter.h
+++ b/src/core/arm/interpreter/arm_interpreter.h
@@ -62,8 +62,11 @@ public:
62 62
63protected: 63protected:
64 64
65 /// Execture next instruction 65 /**
66 void ExecuteInstruction(); 66 * Executes the given number of instructions
67 * @param num_instructions Number of instructions to executes
68 */
69 void ExecuteInstructions(int num_instructions);
67 70
68private: 71private:
69 72
diff --git a/src/core/arm/interpreter/armdefs.h b/src/core/arm/interpreter/armdefs.h
index 821825ae6..5b2abc7f7 100644
--- a/src/core/arm/interpreter/armdefs.h
+++ b/src/core/arm/interpreter/armdefs.h
@@ -288,6 +288,7 @@ struct ARMul_State
288 ARMword loaded_addr, decoded_addr; /* saved pipeline state addr*/ 288 ARMword loaded_addr, decoded_addr; /* saved pipeline state addr*/
289 unsigned int NumScycles, NumNcycles, NumIcycles, NumCcycles, NumFcycles; /* emulated cycles used */ 289 unsigned int NumScycles, NumNcycles, NumIcycles, NumCcycles, NumFcycles; /* emulated cycles used */
290 unsigned long long NumInstrs; /* the number of instructions executed */ 290 unsigned long long NumInstrs; /* the number of instructions executed */
291 unsigned NumInstrsToExecute;
291 unsigned NextInstr; 292 unsigned NextInstr;
292 unsigned VectorCatch; /* caught exception mask */ 293 unsigned VectorCatch; /* caught exception mask */
293 unsigned CallDebug; /* set to call the debugger */ 294 unsigned CallDebug; /* set to call the debugger */
diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp
index 87141653f..32e315f4b 100644
--- a/src/core/arm/interpreter/armemu.cpp
+++ b/src/core/arm/interpreter/armemu.cpp
@@ -4734,7 +4734,7 @@ TEST_EMULATE:
4734 else if (state->Emulate != RUN) 4734 else if (state->Emulate != RUN)
4735 break; 4735 break;
4736 } 4736 }
4737 while (!state->stop_simulator); 4737 while (state->NumInstrsToExecute--);
4738 4738
4739 state->decoded = decoded; 4739 state->decoded = decoded;
4740 state->loaded = loaded; 4740 state->loaded = loaded;
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 859a62c78..61c237b2c 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -4,8 +4,9 @@
4 4
5#include "common/common_types.h" 5#include "common/common_types.h"
6#include "common/log.h" 6#include "common/log.h"
7#include "core/core.h" 7#include "common/symbols.h"
8 8
9#include "core/core.h"
9#include "core/mem_map.h" 10#include "core/mem_map.h"
10#include "core/hw/hw.h" 11#include "core/hw/hw.h"
11#include "core/arm/disassembler/arm_disasm.h" 12#include "core/arm/disassembler/arm_disasm.h"
@@ -19,13 +20,15 @@ ARM_Interface* g_sys_core = NULL; ///< ARM11 system (OS) core
19 20
20/// Run the core CPU loop 21/// Run the core CPU loop
21void RunLoop() { 22void RunLoop() {
22 // TODO(ShizZy): ImplementMe 23 for (;;){
24 g_app_core->Run(10000);
25 HW::Update();
26 }
23} 27}
24 28
25/// Step the CPU one instruction 29/// Step the CPU one instruction
26void SingleStep() { 30void SingleStep() {
27 g_app_core->Step(); 31 g_app_core->Step();
28 HW::Update();
29} 32}
30 33
31/// Halt the core 34/// Halt the core