Delay committing fullscreen until seeing window size change
[lsnes.git] / libgambatte-patches / svn364 / 0002-Expose-CPU-registers.patch
blob8d9173dc8169af2ac55f8cecc2e48e5158cb0ffd
1 From 0ba9fa35b68d63c4adcf0bd7e19eef52bdc3ecd4 Mon Sep 17 00:00:00 2001
2 From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
3 Date: Mon, 18 Nov 2013 01:53:58 +0200
4 Subject: [PATCH 2/3] Expose CPU registers
6 ---
7 libgambatte/include/gambatte.h | 22 +++++++++++++++++++
8 libgambatte/src/cpu.h | 12 +++++------
9 libgambatte/src/gambatte.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++
10 3 files changed, 76 insertions(+), 6 deletions(-)
12 diff --git a/libgambatte/include/gambatte.h b/libgambatte/include/gambatte.h
13 index 11a54a9..98bd129 100644
14 --- a/libgambatte/include/gambatte.h
15 +++ b/libgambatte/include/gambatte.h
16 @@ -203,6 +203,28 @@ public:
18 /** Get version. */
19 static std::string version();
21 + /** CPU registers. */
22 + enum cpu_register
23 + {
24 + REG_CYCLECOUNTER,
25 + REG_PC,
26 + REG_SP,
27 + REG_HF1,
28 + REG_HF2,
29 + REG_ZF,
30 + REG_CF,
31 + REG_A,
32 + REG_B,
33 + REG_C,
34 + REG_D,
35 + REG_E,
36 + REG_F,
37 + REG_H,
38 + REG_L
39 + };
40 + uint32_t get_cpureg(enum cpu_register reg);
41 + void set_cpureg(enum cpu_register reg, uint32_t val);
42 private:
43 void preload_common();
44 void postload_common(const unsigned flags);
45 diff --git a/libgambatte/src/cpu.h b/libgambatte/src/cpu.h
46 index fd4bd64..08bcf80 100644
47 --- a/libgambatte/src/cpu.h
48 +++ b/libgambatte/src/cpu.h
49 @@ -31,6 +31,12 @@ namespace gambatte {
50 class CPU {
51 Memory memory;
54 + bool skip;
56 + void process(unsigned cycles);
58 +public:
59 unsigned cycleCounter_;
61 unsigned short PC_;
62 @@ -39,12 +45,6 @@ class CPU {
63 unsigned HF1, HF2, ZF, CF;
65 unsigned char A_, B, C, D, E, /*F,*/ H, L;
67 - bool skip;
69 - void process(unsigned cycles);
71 -public:
73 CPU(time_t (**_getCurrentTime)());
74 // void halt();
75 diff --git a/libgambatte/src/gambatte.cpp b/libgambatte/src/gambatte.cpp
76 index 9c4fcdc..380ab42 100644
77 --- a/libgambatte/src/gambatte.cpp
78 +++ b/libgambatte/src/gambatte.cpp
79 @@ -290,4 +290,52 @@ std::string GB::version()
80 return "SVN364";
83 +uint32_t GB::get_cpureg(enum cpu_register reg)
85 + switch(reg) {
86 + case REG_CYCLECOUNTER: return p_->cpu.cycleCounter_;
87 + case REG_PC: return p_->cpu.PC_;
88 + case REG_SP: return p_->cpu.SP;
89 + case REG_HF1: return p_->cpu.HF1;
90 + case REG_HF2: return p_->cpu.HF2;
91 + case REG_ZF: return p_->cpu.ZF;
92 + case REG_CF: return p_->cpu.CF;
93 + case REG_A: return p_->cpu.A_;
94 + case REG_B: return p_->cpu.B;
95 + case REG_C: return p_->cpu.C;
96 + case REG_D: return p_->cpu.D;
97 + case REG_E: return p_->cpu.E;
98 + case REG_F:
99 + return ((p_->cpu.HF2 & 0x600 | (p_->cpu.CF & 0x100)) >> 4)
100 + | (p_->cpu.ZF & 0xFF ? 0 : 0x80);
101 + case REG_H: return p_->cpu.H;
102 + case REG_L: return p_->cpu.L;
103 + default: return 0;
107 +void GB::set_cpureg(enum cpu_register reg, uint32_t val)
109 + switch(reg) {
110 + case REG_PC: p_->cpu.PC_ = val; break;
111 + case REG_SP: p_->cpu.SP = val; break;
112 + case REG_HF1: p_->cpu.HF1 = val; break;
113 + case REG_HF2: p_->cpu.HF2 = val; break;
114 + case REG_ZF: p_->cpu.ZF = val; break;
115 + case REG_CF: p_->cpu.CF = val; break;
116 + case REG_A: p_->cpu.A_ = val; break;
117 + case REG_B: p_->cpu.B = val; break;
118 + case REG_C: p_->cpu.C = val; break;
119 + case REG_D: p_->cpu.D = val; break;
120 + case REG_E: p_->cpu.E = val; break;
121 + case REG_F:
122 + p_->cpu.HF2 = (val << 4) & 0x600;
123 + p_->cpu.CF = (val << 4) & 0x100;
124 + p_->cpu.ZF = val & 0x80;
125 + break;
126 + case REG_H: p_->cpu.H = val; break;
127 + case REG_L: p_->cpu.L = val; break;
128 + default: break;
133 1.8.5