GameBoy Emulator 1
Game Boy emulator core and tooling
Loading...
Searching...
No Matches
cb_op_0E.cpp
1#include "../../../../../include/ProcessingUnit.hpp"
2#include "../../../../../include/cb_opcodes.hpp"
3#include "../../../../../include/mmu.hpp"
4
5constexpr int machine_cycles = 4;
6#define totalMachineCycles(n) ((n) * machine_cycles)
7
8#define DUMMY(name) int name(ProcessingUnit&, MMU&) { return totalMachineCycles(1); }
9
10int op_set_4_b(ProcessingUnit& cpu, MMU& mmu) // 0xCBE0
11{
12 u8 value = cpu.reg(ProcessingUnit::Register::B);
13
14 u8 result = value | 0x10;
15 cpu.reg(ProcessingUnit::Register::B) = result;
16
17 return totalMachineCycles(2);
18}
19
20int op_set_4_c(ProcessingUnit& cpu, MMU& mmu) // 0xCBE1
21{
22 u8 value = cpu.reg(ProcessingUnit::Register::C);
23
24 u8 result = value | 0x10;
25 cpu.reg(ProcessingUnit::Register::C) = result;
26
27 return totalMachineCycles(2);
28}
29
30int op_set_4_d(ProcessingUnit& cpu, MMU& mmu) // 0xCBE2
31{
32 u8 value = cpu.reg(ProcessingUnit::Register::D);
33
34 u8 result = value | 0x10;
35 cpu.reg(ProcessingUnit::Register::D) = result;
36
37 return totalMachineCycles(2);
38}
39
40int op_set_4_e(ProcessingUnit& cpu, MMU& mmu) // 0xCBE3
41{
42 u8 value = cpu.reg(ProcessingUnit::Register::E);
43
44 u8 result = value | 0x10;
45 cpu.reg(ProcessingUnit::Register::E) = result;
46
47 return totalMachineCycles(2);
48}
49
50int op_set_4_h(ProcessingUnit& cpu, MMU& mmu) // 0xCBE4
51{
52 u8 value = cpu.reg(ProcessingUnit::Register::H);
53
54 u8 result = value | 0x10;
55 cpu.reg(ProcessingUnit::Register::H) = result;
56
57 return totalMachineCycles(2);
58}
59
60int op_set_4_l(ProcessingUnit& cpu, MMU& mmu) // 0xCBE5
61{
62 u8 value = cpu.reg(ProcessingUnit::Register::L);
63
64 u8 result = value | 0x10;
65 cpu.reg(ProcessingUnit::Register::L) = result;
66
67 return totalMachineCycles(2);
68}
69
70int op_set_4_hl(ProcessingUnit& cpu, MMU& mmu) // 0xCBE6
71{
72 u16 addr = cpu.get_hl();
73 u8 value = mmu.read(addr);
74
75 u8 result = value | 0x10;
76 mmu.write(addr, result);
77
78 return totalMachineCycles(4);
79}
80
81int op_set_4_a(ProcessingUnit& cpu, MMU& mmu) // 0xCBE7
82{
83 u8 value = cpu.reg(ProcessingUnit::Register::A);
84
85 u8 result = value | 0x10;
86 cpu.reg(ProcessingUnit::Register::A) = result;
87
88 return totalMachineCycles(2);
89}
90
91int op_set_5_b(ProcessingUnit& cpu, MMU& mmu) // 0xCBE8
92{
93 u8 value = cpu.reg(ProcessingUnit::Register::B);
94
95 u8 result = value | 0x20;
96 cpu.reg(ProcessingUnit::Register::B) = result;
97
98 return totalMachineCycles(2);
99}
100
101int op_set_5_c(ProcessingUnit& cpu, MMU& mmu) // 0xCBE9
102{
103 u8 value = cpu.reg(ProcessingUnit::Register::C);
104
105 u8 result = value | 0x20;
106 cpu.reg(ProcessingUnit::Register::C) = result;
107
108 return totalMachineCycles(2);
109}
110
111int op_set_5_d(ProcessingUnit& cpu, MMU& mmu) // 0xCBEA
112{
113 u8 value = cpu.reg(ProcessingUnit::Register::D);
114
115 u8 result = value | 0x20;
116 cpu.reg(ProcessingUnit::Register::D) = result;
117
118 return totalMachineCycles(2);
119}
120
121int op_set_5_e(ProcessingUnit& cpu, MMU& mmu) // 0xCBEB
122{
123 u8 value = cpu.reg(ProcessingUnit::Register::E);
124
125 u8 result = value | 0x20;
126 cpu.reg(ProcessingUnit::Register::E) = result;
127
128 return totalMachineCycles(2);
129}
130
131int op_set_5_h(ProcessingUnit& cpu, MMU& mmu) // 0xCBEC
132{
133 u8 value = cpu.reg(ProcessingUnit::Register::H);
134
135 u8 result = value | 0x20;
136 cpu.reg(ProcessingUnit::Register::H) = result;
137
138 return totalMachineCycles(2);
139}
140
141int op_set_5_l(ProcessingUnit& cpu, MMU& mmu) // 0xCBED
142{
143 u8 value = cpu.reg(ProcessingUnit::Register::L);
144
145 u8 result = value | 0x20;
146 cpu.reg(ProcessingUnit::Register::L) = result;
147
148 return totalMachineCycles(2);
149}
150
151int op_set_5_hl(ProcessingUnit& cpu, MMU& mmu) // 0xCBEE
152{
153 u16 addr = cpu.get_hl();
154 u8 value = mmu.read(addr);
155
156 u8 result = value | 0x20;
157 mmu.write(addr, result);
158
159 return totalMachineCycles(4);
160}
161
162int op_set_5_a(ProcessingUnit& cpu, MMU& mmu) // 0xCBEF
163{
164 u8 value = cpu.reg(ProcessingUnit::Register::A);
165
166 u8 result = value | 0x20;
167 cpu.reg(ProcessingUnit::Register::A) = result;
168
169 return totalMachineCycles(2);
170}
Definition mmu.hpp:12