summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2014-04-05 15:23:59 -0400
committerGravatar bunnei2014-04-05 15:23:59 -0400
commited15feebf1cc60356e374e3492e6086066a7d09e (patch)
treef5f647e2a5b0d86aa0687ce48d40797cc076483e /src
parentUpdated common_types.h to use Gekko's version w/ Rect and some useful unions (diff)
downloadyuzu-ed15feebf1cc60356e374e3492e6086066a7d09e.tar.gz
yuzu-ed15feebf1cc60356e374e3492e6086066a7d09e.tar.xz
yuzu-ed15feebf1cc60356e374e3492e6086066a7d09e.zip
changed hw_lcd to use ARM core correct tick counter instead of [what was actually] just an instruction count. this seems to fix timing issues with the 3DS_Homebrew_Pong3Dv2 demo.
Diffstat (limited to 'src')
-rw-r--r--src/core/src/arm/arm_interface.h43
-rw-r--r--src/core/src/arm/interpreter/arm_interpreter.h7
-rw-r--r--src/core/src/hw/hw_lcd.cpp6
3 files changed, 48 insertions, 8 deletions
diff --git a/src/core/src/arm/arm_interface.h b/src/core/src/arm/arm_interface.h
index 80518a779..daf35b51d 100644
--- a/src/core/src/arm/arm_interface.h
+++ b/src/core/src/arm/arm_interface.h
@@ -24,32 +24,65 @@
24 24
25#pragma once 25#pragma once
26 26
27#include "common.h"
27#include "common_types.h" 28#include "common_types.h"
28 29
29/// Generic ARM11 CPU interface 30/// Generic ARM11 CPU interface
30class ARM_Interface { 31class ARM_Interface {
31public: 32public:
32 ARM_Interface() { 33 ARM_Interface() {
34 num_instructions_ = 0;
33 } 35 }
34 36
35 ~ARM_Interface() { 37 ~ARM_Interface() {
36 } 38 }
37 39
40 /// Step CPU by one instruction
38 void Step() { 41 void Step() {
39 ExecuteInstruction(); 42 ExecuteInstruction();
40 ticks_++; 43 num_instructions_++;
41 } 44 }
42 45
43 virtual void SetPC(u32 pc) = 0; 46 /**
47 * Set the Program Counter to an address
48 * @param addr Address to set PC to
49 */
50 virtual void SetPC(u32 addr) = 0;
51
52 /*
53 * Get the current Program Counter
54 * @return Returns current PC
55 */
44 virtual u32 PC() = 0; 56 virtual u32 PC() = 0;
57
58 /**
59 * Get an ARM register
60 * @param index Register index (0-15)
61 * @return Returns the value in the register
62 */
45 virtual u32 Reg(int index) = 0; 63 virtual u32 Reg(int index) = 0;
64
65 /**
66 * Get the current CPSR register
67 * @return Returns the value of the CPSR register
68 */
46 virtual u32 CPSR() = 0; 69 virtual u32 CPSR() = 0;
47 70
48 u64 ticks() { return ticks_; } 71 /**
72 * Returns the number of clock ticks since the last rese
73 * @return Returns number of clock ticks
74 */
75 virtual u64 GetTicks() = 0;
76
77 /// Getter for num_instructions_
78 u64 num_instructions() { return num_instructions_; }
49 79
50private: 80private:
51 81
82 /// Execture next instruction
52 virtual void ExecuteInstruction() = 0; 83 virtual void ExecuteInstruction() = 0;
53 84
54 u64 ticks_; 85 u64 num_instructions_; ///< Number of instructions executed
86
87 DISALLOW_COPY_AND_ASSIGN(ARM_Interface);
55}; 88};
diff --git a/src/core/src/arm/interpreter/arm_interpreter.h b/src/core/src/arm/interpreter/arm_interpreter.h
index 89f871fa9..074149f1b 100644
--- a/src/core/src/arm/interpreter/arm_interpreter.h
+++ b/src/core/src/arm/interpreter/arm_interpreter.h
@@ -24,6 +24,7 @@
24 24
25#pragma once 25#pragma once
26 26
27#include "common.h"
27#include "common_types.h" 28#include "common_types.h"
28#include "arm/arm_interface.h" 29#include "arm/arm_interface.h"
29 30
@@ -45,6 +46,12 @@ public:
45 46
46 u32 CPSR(); 47 u32 CPSR();
47 48
49 u64 GetTicks() {
50 return ARMul_Time(state);
51 }
52
48private: 53private:
49 ARMul_State* state; 54 ARMul_State* state;
55
56 DISALLOW_COPY_AND_ASSIGN(ARM_Interpreter);
50}; 57};
diff --git a/src/core/src/hw/hw_lcd.cpp b/src/core/src/hw/hw_lcd.cpp
index 19e3b4ab4..7e3728346 100644
--- a/src/core/src/hw/hw_lcd.cpp
+++ b/src/core/src/hw/hw_lcd.cpp
@@ -28,7 +28,7 @@
28 28
29namespace LCD { 29namespace LCD {
30 30
31static const u32 kFrameTicks = 268123480 / 30; // 268MHz / 30 frames per second 31static const u32 kFrameTicks = 268123480 / 60; ///< 268MHz / 60 frames per second
32 32
33u64 g_last_ticks = 0; ///< Last CPU ticks 33u64 g_last_ticks = 0; ///< Last CPU ticks
34 34
@@ -42,7 +42,7 @@ inline void Write(u32 addr, const T data) {
42 42
43/// Update hardware 43/// Update hardware
44void Update() { 44void Update() {
45 u64 current_ticks = Core::g_app_core->ticks(); 45 u64 current_ticks = Core::g_app_core->GetTicks();
46 46
47 if ((current_ticks - g_last_ticks) >= kFrameTicks) { 47 if ((current_ticks - g_last_ticks) >= kFrameTicks) {
48 g_last_ticks = current_ticks; 48 g_last_ticks = current_ticks;
@@ -52,7 +52,7 @@ void Update() {
52 52
53/// Initialize hardware 53/// Initialize hardware
54void Init() { 54void Init() {
55 g_last_ticks = Core::g_app_core->ticks(); 55 g_last_ticks = Core::g_app_core->GetTicks();
56 56
57 NOTICE_LOG(LCD, "LCD initialized OK"); 57 NOTICE_LOG(LCD, "LCD initialized OK");
58} 58}