rubyboy 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/CHANGELOG.md +15 -0
- data/README.md +5 -1
- data/exe/rubyboy +2 -1
- data/lib/rubyboy/apu.rb +118 -0
- data/lib/rubyboy/apu_channels/channel1.rb +154 -0
- data/lib/rubyboy/apu_channels/channel2.rb +116 -0
- data/lib/rubyboy/apu_channels/channel3.rb +117 -0
- data/lib/rubyboy/apu_channels/channel4.rb +148 -0
- data/lib/rubyboy/audio.rb +33 -0
- data/lib/rubyboy/bus.rb +65 -121
- data/lib/rubyboy/cartridge/factory.rb +1 -1
- data/lib/rubyboy/cartridge/mbc1.rb +52 -38
- data/lib/rubyboy/cpu.rb +701 -677
- data/lib/rubyboy/lcd.rb +30 -19
- data/lib/rubyboy/ppu.rb +16 -4
- data/lib/rubyboy/raylib/audio.rb +32 -0
- data/lib/rubyboy/raylib/lcd.rb +40 -0
- data/lib/rubyboy/raylib/raylib_loader.rb +36 -0
- data/lib/rubyboy/registers.rb +67 -61
- data/lib/rubyboy/sdl.rb +71 -0
- data/lib/rubyboy/version.rb +1 -1
- data/lib/rubyboy.rb +23 -41
- data/resource/logo/logo.png +0 -0
- data/resource/logo/logo.svg +1 -0
- metadata +23 -16
- data/lib/rubyboy/operand/direct16.rb +0 -13
- data/lib/rubyboy/operand/direct8.rb +0 -13
- data/lib/rubyboy/operand/hl_dec.rb +0 -11
- data/lib/rubyboy/operand/hl_inc.rb +0 -11
- data/lib/rubyboy/operand/immediate16.rb +0 -13
- data/lib/rubyboy/operand/immediate8.rb +0 -13
- data/lib/rubyboy/operand/indirect.rb +0 -13
- data/lib/rubyboy/operand/register16.rb +0 -13
- data/lib/rubyboy/operand/register8.rb +0 -13
- data/lib/rubyboy/operand.rb +0 -12
- data/lib/rubyboy/register.rb +0 -24
data/lib/rubyboy/cpu.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'registers'
|
4
|
-
require_relative 'operand'
|
5
4
|
|
6
5
|
module Rubyboy
|
7
6
|
class Cpu
|
@@ -51,509 +50,509 @@ module Rubyboy
|
|
51
50
|
|
52
51
|
case opcode
|
53
52
|
when 0x00 then 4 # NOP
|
54
|
-
when 0x01 then ld16(
|
55
|
-
when 0x02 then ld8(
|
56
|
-
when 0x03 then inc16(
|
57
|
-
when 0x04 then inc8(
|
58
|
-
when 0x05 then dec8(
|
59
|
-
when 0x06 then ld8(
|
60
|
-
when 0x07 then rlca
|
61
|
-
when 0x08 then ld16(
|
62
|
-
when 0x09 then add16(
|
63
|
-
when 0x0a then ld8(
|
64
|
-
when 0x0b then dec16(
|
65
|
-
when 0x0c then inc8(
|
66
|
-
when 0x0d then dec8(
|
67
|
-
when 0x0e then ld8(
|
68
|
-
when 0x0f then rrca
|
53
|
+
when 0x01 then ld16(:bc, :immediate16, cycles: 12)
|
54
|
+
when 0x02 then ld8(:indirect_bc, :a, cycles: 8)
|
55
|
+
when 0x03 then inc16(:bc, cycles: 8)
|
56
|
+
when 0x04 then inc8(:b, cycles: 4)
|
57
|
+
when 0x05 then dec8(:b, cycles: 4)
|
58
|
+
when 0x06 then ld8(:b, :immediate8, cycles: 8)
|
59
|
+
when 0x07 then rlca(cycles: 4)
|
60
|
+
when 0x08 then ld16(:direct16, :sp, cycles: 20)
|
61
|
+
when 0x09 then add16(:hl, :bc, cycles: 8)
|
62
|
+
when 0x0a then ld8(:a, :indirect_bc, cycles: 8)
|
63
|
+
when 0x0b then dec16(:bc, cycles: 8)
|
64
|
+
when 0x0c then inc8(:c, cycles: 4)
|
65
|
+
when 0x0d then dec8(:c, cycles: 4)
|
66
|
+
when 0x0e then ld8(:c, :immediate8, cycles: 8)
|
67
|
+
when 0x0f then rrca(cycles: 4)
|
69
68
|
when 0x10 then 4 # STOP
|
70
|
-
when 0x11 then ld16(
|
71
|
-
when 0x12 then ld8(
|
72
|
-
when 0x13 then inc16(
|
73
|
-
when 0x14 then inc8(
|
74
|
-
when 0x15 then dec8(
|
75
|
-
when 0x16 then ld8(
|
76
|
-
when 0x17 then rla
|
77
|
-
when 0x18 then jr
|
78
|
-
when 0x19 then add16(
|
79
|
-
when 0x1a then ld8(
|
80
|
-
when 0x1b then dec16(
|
81
|
-
when 0x1c then inc8(
|
82
|
-
when 0x1d then dec8(
|
83
|
-
when 0x1e then ld8(
|
84
|
-
when 0x1f then rra
|
85
|
-
when 0x20 then jr(condition: !
|
86
|
-
when 0x21 then ld16(
|
87
|
-
when 0x22 then ld8(
|
88
|
-
when 0x23 then inc16(
|
89
|
-
when 0x24 then inc8(
|
90
|
-
when 0x25 then dec8(
|
91
|
-
when 0x26 then ld8(
|
92
|
-
when 0x27 then daa
|
93
|
-
when 0x28 then jr(condition:
|
94
|
-
when 0x29 then add16(
|
95
|
-
when 0x2a then ld8(
|
96
|
-
when 0x2b then dec16(
|
97
|
-
when 0x2c then inc8(
|
98
|
-
when 0x2d then dec8(
|
99
|
-
when 0x2e then ld8(
|
100
|
-
when 0x2f then cpl
|
101
|
-
when 0x30 then jr(condition: !
|
102
|
-
when 0x31 then ld16(
|
103
|
-
when 0x32 then ld8(
|
104
|
-
when 0x33 then inc16(
|
105
|
-
when 0x34 then inc8(
|
106
|
-
when 0x35 then dec8(
|
107
|
-
when 0x36 then ld8(
|
108
|
-
when 0x37 then scf
|
109
|
-
when 0x38 then jr(condition:
|
110
|
-
when 0x39 then add16(
|
111
|
-
when 0x3a then ld8(
|
112
|
-
when 0x3b then dec16(
|
113
|
-
when 0x3c then inc8(
|
114
|
-
when 0x3d then dec8(
|
115
|
-
when 0x3e then ld8(
|
116
|
-
when 0x3f then ccf
|
117
|
-
when 0x40 then ld8(
|
118
|
-
when 0x41 then ld8(
|
119
|
-
when 0x42 then ld8(
|
120
|
-
when 0x43 then ld8(
|
121
|
-
when 0x44 then ld8(
|
122
|
-
when 0x45 then ld8(
|
123
|
-
when 0x46 then ld8(
|
124
|
-
when 0x47 then ld8(
|
125
|
-
when 0x48 then ld8(
|
126
|
-
when 0x49 then ld8(
|
127
|
-
when 0x4a then ld8(
|
128
|
-
when 0x4b then ld8(
|
129
|
-
when 0x4c then ld8(
|
130
|
-
when 0x4d then ld8(
|
131
|
-
when 0x4e then ld8(
|
132
|
-
when 0x4f then ld8(
|
133
|
-
when 0x50 then ld8(
|
134
|
-
when 0x51 then ld8(
|
135
|
-
when 0x52 then ld8(
|
136
|
-
when 0x53 then ld8(
|
137
|
-
when 0x54 then ld8(
|
138
|
-
when 0x55 then ld8(
|
139
|
-
when 0x56 then ld8(
|
140
|
-
when 0x57 then ld8(
|
141
|
-
when 0x58 then ld8(
|
142
|
-
when 0x59 then ld8(
|
143
|
-
when 0x5a then ld8(
|
144
|
-
when 0x5b then ld8(
|
145
|
-
when 0x5c then ld8(
|
146
|
-
when 0x5d then ld8(
|
147
|
-
when 0x5e then ld8(
|
148
|
-
when 0x5f then ld8(
|
149
|
-
when 0x60 then ld8(
|
150
|
-
when 0x61 then ld8(
|
151
|
-
when 0x62 then ld8(
|
152
|
-
when 0x63 then ld8(
|
153
|
-
when 0x64 then ld8(
|
154
|
-
when 0x65 then ld8(
|
155
|
-
when 0x66 then ld8(
|
156
|
-
when 0x67 then ld8(
|
157
|
-
when 0x68 then ld8(
|
158
|
-
when 0x69 then ld8(
|
159
|
-
when 0x6a then ld8(
|
160
|
-
when 0x6b then ld8(
|
161
|
-
when 0x6c then ld8(
|
162
|
-
when 0x6d then ld8(
|
163
|
-
when 0x6e then ld8(
|
164
|
-
when 0x6f then ld8(
|
165
|
-
when 0x70 then ld8(
|
166
|
-
when 0x71 then ld8(
|
167
|
-
when 0x72 then ld8(
|
168
|
-
when 0x73 then ld8(
|
169
|
-
when 0x74 then ld8(
|
170
|
-
when 0x75 then ld8(
|
171
|
-
when 0x76 then halt
|
172
|
-
when 0x77 then ld8(
|
173
|
-
when 0x78 then ld8(
|
174
|
-
when 0x79 then ld8(
|
175
|
-
when 0x7a then ld8(
|
176
|
-
when 0x7b then ld8(
|
177
|
-
when 0x7c then ld8(
|
178
|
-
when 0x7d then ld8(
|
179
|
-
when 0x7e then ld8(
|
180
|
-
when 0x7f then ld8(
|
181
|
-
when 0x80 then add8(
|
182
|
-
when 0x81 then add8(
|
183
|
-
when 0x82 then add8(
|
184
|
-
when 0x83 then add8(
|
185
|
-
when 0x84 then add8(
|
186
|
-
when 0x85 then add8(
|
187
|
-
when 0x86 then add8(
|
188
|
-
when 0x87 then add8(
|
189
|
-
when 0x88 then adc8(
|
190
|
-
when 0x89 then adc8(
|
191
|
-
when 0x8a then adc8(
|
192
|
-
when 0x8b then adc8(
|
193
|
-
when 0x8c then adc8(
|
194
|
-
when 0x8d then adc8(
|
195
|
-
when 0x8e then adc8(
|
196
|
-
when 0x8f then adc8(
|
197
|
-
when 0x90 then sub8(
|
198
|
-
when 0x91 then sub8(
|
199
|
-
when 0x92 then sub8(
|
200
|
-
when 0x93 then sub8(
|
201
|
-
when 0x94 then sub8(
|
202
|
-
when 0x95 then sub8(
|
203
|
-
when 0x96 then sub8(
|
204
|
-
when 0x97 then sub8(
|
205
|
-
when 0x98 then sbc8(
|
206
|
-
when 0x99 then sbc8(
|
207
|
-
when 0x9a then sbc8(
|
208
|
-
when 0x9b then sbc8(
|
209
|
-
when 0x9c then sbc8(
|
210
|
-
when 0x9d then sbc8(
|
211
|
-
when 0x9e then sbc8(
|
212
|
-
when 0x9f then sbc8(
|
213
|
-
when 0xa0 then and8(
|
214
|
-
when 0xa1 then and8(
|
215
|
-
when 0xa2 then and8(
|
216
|
-
when 0xa3 then and8(
|
217
|
-
when 0xa4 then and8(
|
218
|
-
when 0xa5 then and8(
|
219
|
-
when 0xa6 then and8(
|
220
|
-
when 0xa7 then and8(
|
221
|
-
when 0xa8 then xor8(
|
222
|
-
when 0xa9 then xor8(
|
223
|
-
when 0xaa then xor8(
|
224
|
-
when 0xab then xor8(
|
225
|
-
when 0xac then xor8(
|
226
|
-
when 0xad then xor8(
|
227
|
-
when 0xae then xor8(
|
228
|
-
when 0xaf then xor8(
|
229
|
-
when 0xb0 then or8(
|
230
|
-
when 0xb1 then or8(
|
231
|
-
when 0xb2 then or8(
|
232
|
-
when 0xb3 then or8(
|
233
|
-
when 0xb4 then or8(
|
234
|
-
when 0xb5 then or8(
|
235
|
-
when 0xb6 then or8(
|
236
|
-
when 0xb7 then or8(
|
237
|
-
when 0xb8 then cp8(
|
238
|
-
when 0xb9 then cp8(
|
239
|
-
when 0xba then cp8(
|
240
|
-
when 0xbb then cp8(
|
241
|
-
when 0xbc then cp8(
|
242
|
-
when 0xbd then cp8(
|
243
|
-
when 0xbe then cp8(
|
244
|
-
when 0xbf then cp8(
|
245
|
-
when 0xc0 then ret_if(!
|
246
|
-
when 0xc1 then pop16(:bc)
|
247
|
-
when 0xc2 then jp(
|
248
|
-
when 0xc3 then jp(
|
249
|
-
when 0xc4 then call16(
|
250
|
-
when 0xc5 then push16(:bc)
|
251
|
-
when 0xc6 then add8(
|
252
|
-
when 0xc7 then rst(0x00)
|
253
|
-
when 0xc8 then ret_if(
|
254
|
-
when 0xc9 then ret
|
255
|
-
when 0xca then jp(
|
256
|
-
when 0xcc then call16(
|
257
|
-
when 0xcd then call16(
|
258
|
-
when 0xce then adc8(
|
259
|
-
when 0xcf then rst(0x08)
|
260
|
-
when 0xd0 then ret_if(!
|
261
|
-
when 0xd1 then pop16(:de)
|
262
|
-
when 0xd2 then jp(
|
263
|
-
when 0xd4 then call16(
|
264
|
-
when 0xd5 then push16(:de)
|
265
|
-
when 0xd6 then sub8(
|
266
|
-
when 0xd7 then rst(0x10)
|
267
|
-
when 0xd8 then ret_if(
|
268
|
-
when 0xd9 then reti
|
269
|
-
when 0xda then jp(
|
270
|
-
when 0xdc then call16(
|
271
|
-
when 0xde then sbc8(
|
272
|
-
when 0xdf then rst(0x18)
|
273
|
-
when 0xe0 then ld8(
|
274
|
-
when 0xe1 then pop16(:hl)
|
275
|
-
when 0xe2 then ld8(
|
276
|
-
when 0xe5 then push16(:hl)
|
277
|
-
when 0xe6 then and8(
|
278
|
-
when 0xe7 then rst(0x20)
|
279
|
-
when 0xe8 then add_sp_r8
|
280
|
-
when 0xe9 then
|
281
|
-
when 0xea then ld8(
|
282
|
-
when 0xee then xor8(
|
283
|
-
when 0xef then rst(0x28)
|
284
|
-
when 0xf0 then ld8(
|
285
|
-
when 0xf1 then pop16(:af)
|
286
|
-
when 0xf2 then ld8(
|
287
|
-
when 0xf3 then di
|
288
|
-
when 0xf5 then push16(:af)
|
289
|
-
when 0xf6 then or8(
|
290
|
-
when 0xf7 then rst(0x30)
|
291
|
-
when 0xf8 then ld_hl_sp_r8
|
292
|
-
when 0xf9 then ld16(
|
293
|
-
when 0xfa then ld8(
|
294
|
-
when 0xfb then ei
|
295
|
-
when 0xfe then cp8(
|
296
|
-
when 0xff then rst(0x38)
|
69
|
+
when 0x11 then ld16(:de, :immediate16, cycles: 12)
|
70
|
+
when 0x12 then ld8(:indirect_de, :a, cycles: 8)
|
71
|
+
when 0x13 then inc16(:de, cycles: 8)
|
72
|
+
when 0x14 then inc8(:d, cycles: 4)
|
73
|
+
when 0x15 then dec8(:d, cycles: 4)
|
74
|
+
when 0x16 then ld8(:d, :immediate8, cycles: 8)
|
75
|
+
when 0x17 then rla(cycles: 4)
|
76
|
+
when 0x18 then jr(condition: true)
|
77
|
+
when 0x19 then add16(:hl, :de, cycles: 8)
|
78
|
+
when 0x1a then ld8(:a, :indirect_de, cycles: 8)
|
79
|
+
when 0x1b then dec16(:de, cycles: 8)
|
80
|
+
when 0x1c then inc8(:e, cycles: 4)
|
81
|
+
when 0x1d then dec8(:e, cycles: 4)
|
82
|
+
when 0x1e then ld8(:e, :immediate8, cycles: 8)
|
83
|
+
when 0x1f then rra(cycles: 4)
|
84
|
+
when 0x20 then jr(condition: !flag_z)
|
85
|
+
when 0x21 then ld16(:hl, :immediate16, cycles: 12)
|
86
|
+
when 0x22 then ld8(:hl_inc, :a, cycles: 8)
|
87
|
+
when 0x23 then inc16(:hl, cycles: 8)
|
88
|
+
when 0x24 then inc8(:h, cycles: 4)
|
89
|
+
when 0x25 then dec8(:h, cycles: 4)
|
90
|
+
when 0x26 then ld8(:h, :immediate8, cycles: 8)
|
91
|
+
when 0x27 then daa(cycles: 4)
|
92
|
+
when 0x28 then jr(condition: flag_z)
|
93
|
+
when 0x29 then add16(:hl, :hl, cycles: 8)
|
94
|
+
when 0x2a then ld8(:a, :hl_inc, cycles: 8)
|
95
|
+
when 0x2b then dec16(:hl, cycles: 8)
|
96
|
+
when 0x2c then inc8(:l, cycles: 4)
|
97
|
+
when 0x2d then dec8(:l, cycles: 4)
|
98
|
+
when 0x2e then ld8(:l, :immediate8, cycles: 8)
|
99
|
+
when 0x2f then cpl(cycles: 4)
|
100
|
+
when 0x30 then jr(condition: !flag_c)
|
101
|
+
when 0x31 then ld16(:sp, :immediate16, cycles: 12)
|
102
|
+
when 0x32 then ld8(:hl_dec, :a, cycles: 8)
|
103
|
+
when 0x33 then inc16(:sp, cycles: 8)
|
104
|
+
when 0x34 then inc8(:indirect_hl, cycles: 12)
|
105
|
+
when 0x35 then dec8(:indirect_hl, cycles: 12)
|
106
|
+
when 0x36 then ld8(:indirect_hl, :immediate8, cycles: 12)
|
107
|
+
when 0x37 then scf(cycles: 4)
|
108
|
+
when 0x38 then jr(condition: flag_c)
|
109
|
+
when 0x39 then add16(:hl, :sp, cycles: 8)
|
110
|
+
when 0x3a then ld8(:a, :hl_dec, cycles: 8)
|
111
|
+
when 0x3b then dec16(:sp, cycles: 8)
|
112
|
+
when 0x3c then inc8(:a, cycles: 4)
|
113
|
+
when 0x3d then dec8(:a, cycles: 4)
|
114
|
+
when 0x3e then ld8(:a, :immediate8, cycles: 8)
|
115
|
+
when 0x3f then ccf(cycles: 4)
|
116
|
+
when 0x40 then ld8(:b, :b, cycles: 4)
|
117
|
+
when 0x41 then ld8(:b, :c, cycles: 4)
|
118
|
+
when 0x42 then ld8(:b, :d, cycles: 4)
|
119
|
+
when 0x43 then ld8(:b, :e, cycles: 4)
|
120
|
+
when 0x44 then ld8(:b, :h, cycles: 4)
|
121
|
+
when 0x45 then ld8(:b, :l, cycles: 4)
|
122
|
+
when 0x46 then ld8(:b, :indirect_hl, cycles: 8)
|
123
|
+
when 0x47 then ld8(:b, :a, cycles: 4)
|
124
|
+
when 0x48 then ld8(:c, :b, cycles: 4)
|
125
|
+
when 0x49 then ld8(:c, :c, cycles: 4)
|
126
|
+
when 0x4a then ld8(:c, :d, cycles: 4)
|
127
|
+
when 0x4b then ld8(:c, :e, cycles: 4)
|
128
|
+
when 0x4c then ld8(:c, :h, cycles: 4)
|
129
|
+
when 0x4d then ld8(:c, :l, cycles: 4)
|
130
|
+
when 0x4e then ld8(:c, :indirect_hl, cycles: 8)
|
131
|
+
when 0x4f then ld8(:c, :a, cycles: 4)
|
132
|
+
when 0x50 then ld8(:d, :b, cycles: 4)
|
133
|
+
when 0x51 then ld8(:d, :c, cycles: 4)
|
134
|
+
when 0x52 then ld8(:d, :d, cycles: 4)
|
135
|
+
when 0x53 then ld8(:d, :e, cycles: 4)
|
136
|
+
when 0x54 then ld8(:d, :h, cycles: 4)
|
137
|
+
when 0x55 then ld8(:d, :l, cycles: 4)
|
138
|
+
when 0x56 then ld8(:d, :indirect_hl, cycles: 8)
|
139
|
+
when 0x57 then ld8(:d, :a, cycles: 4)
|
140
|
+
when 0x58 then ld8(:e, :b, cycles: 4)
|
141
|
+
when 0x59 then ld8(:e, :c, cycles: 4)
|
142
|
+
when 0x5a then ld8(:e, :d, cycles: 4)
|
143
|
+
when 0x5b then ld8(:e, :e, cycles: 4)
|
144
|
+
when 0x5c then ld8(:e, :h, cycles: 4)
|
145
|
+
when 0x5d then ld8(:e, :l, cycles: 4)
|
146
|
+
when 0x5e then ld8(:e, :indirect_hl, cycles: 8)
|
147
|
+
when 0x5f then ld8(:e, :a, cycles: 4)
|
148
|
+
when 0x60 then ld8(:h, :b, cycles: 4)
|
149
|
+
when 0x61 then ld8(:h, :c, cycles: 4)
|
150
|
+
when 0x62 then ld8(:h, :d, cycles: 4)
|
151
|
+
when 0x63 then ld8(:h, :e, cycles: 4)
|
152
|
+
when 0x64 then ld8(:h, :h, cycles: 4)
|
153
|
+
when 0x65 then ld8(:h, :l, cycles: 4)
|
154
|
+
when 0x66 then ld8(:h, :indirect_hl, cycles: 8)
|
155
|
+
when 0x67 then ld8(:h, :a, cycles: 4)
|
156
|
+
when 0x68 then ld8(:l, :b, cycles: 4)
|
157
|
+
when 0x69 then ld8(:l, :c, cycles: 4)
|
158
|
+
when 0x6a then ld8(:l, :d, cycles: 4)
|
159
|
+
when 0x6b then ld8(:l, :e, cycles: 4)
|
160
|
+
when 0x6c then ld8(:l, :h, cycles: 4)
|
161
|
+
when 0x6d then ld8(:l, :l, cycles: 4)
|
162
|
+
when 0x6e then ld8(:l, :indirect_hl, cycles: 8)
|
163
|
+
when 0x6f then ld8(:l, :a, cycles: 4)
|
164
|
+
when 0x70 then ld8(:indirect_hl, :b, cycles: 8)
|
165
|
+
when 0x71 then ld8(:indirect_hl, :c, cycles: 8)
|
166
|
+
when 0x72 then ld8(:indirect_hl, :d, cycles: 8)
|
167
|
+
when 0x73 then ld8(:indirect_hl, :e, cycles: 8)
|
168
|
+
when 0x74 then ld8(:indirect_hl, :h, cycles: 8)
|
169
|
+
when 0x75 then ld8(:indirect_hl, :l, cycles: 8)
|
170
|
+
when 0x76 then halt(cycles: 4)
|
171
|
+
when 0x77 then ld8(:indirect_hl, :a, cycles: 8)
|
172
|
+
when 0x78 then ld8(:a, :b, cycles: 4)
|
173
|
+
when 0x79 then ld8(:a, :c, cycles: 4)
|
174
|
+
when 0x7a then ld8(:a, :d, cycles: 4)
|
175
|
+
when 0x7b then ld8(:a, :e, cycles: 4)
|
176
|
+
when 0x7c then ld8(:a, :h, cycles: 4)
|
177
|
+
when 0x7d then ld8(:a, :l, cycles: 4)
|
178
|
+
when 0x7e then ld8(:a, :indirect_hl, cycles: 8)
|
179
|
+
when 0x7f then ld8(:a, :a, cycles: 4)
|
180
|
+
when 0x80 then add8(:b, cycles: 4)
|
181
|
+
when 0x81 then add8(:c, cycles: 4)
|
182
|
+
when 0x82 then add8(:d, cycles: 4)
|
183
|
+
when 0x83 then add8(:e, cycles: 4)
|
184
|
+
when 0x84 then add8(:h, cycles: 4)
|
185
|
+
when 0x85 then add8(:l, cycles: 4)
|
186
|
+
when 0x86 then add8(:indirect_hl, cycles: 8)
|
187
|
+
when 0x87 then add8(:a, cycles: 4)
|
188
|
+
when 0x88 then adc8(:b, cycles: 4)
|
189
|
+
when 0x89 then adc8(:c, cycles: 4)
|
190
|
+
when 0x8a then adc8(:d, cycles: 4)
|
191
|
+
when 0x8b then adc8(:e, cycles: 4)
|
192
|
+
when 0x8c then adc8(:h, cycles: 4)
|
193
|
+
when 0x8d then adc8(:l, cycles: 4)
|
194
|
+
when 0x8e then adc8(:indirect_hl, cycles: 8)
|
195
|
+
when 0x8f then adc8(:a, cycles: 4)
|
196
|
+
when 0x90 then sub8(:b, cycles: 4)
|
197
|
+
when 0x91 then sub8(:c, cycles: 4)
|
198
|
+
when 0x92 then sub8(:d, cycles: 4)
|
199
|
+
when 0x93 then sub8(:e, cycles: 4)
|
200
|
+
when 0x94 then sub8(:h, cycles: 4)
|
201
|
+
when 0x95 then sub8(:l, cycles: 4)
|
202
|
+
when 0x96 then sub8(:indirect_hl, cycles: 8)
|
203
|
+
when 0x97 then sub8(:a, cycles: 4)
|
204
|
+
when 0x98 then sbc8(:b, cycles: 4)
|
205
|
+
when 0x99 then sbc8(:c, cycles: 4)
|
206
|
+
when 0x9a then sbc8(:d, cycles: 4)
|
207
|
+
when 0x9b then sbc8(:e, cycles: 4)
|
208
|
+
when 0x9c then sbc8(:h, cycles: 4)
|
209
|
+
when 0x9d then sbc8(:l, cycles: 4)
|
210
|
+
when 0x9e then sbc8(:indirect_hl, cycles: 8)
|
211
|
+
when 0x9f then sbc8(:a, cycles: 4)
|
212
|
+
when 0xa0 then and8(:b, cycles: 4)
|
213
|
+
when 0xa1 then and8(:c, cycles: 4)
|
214
|
+
when 0xa2 then and8(:d, cycles: 4)
|
215
|
+
when 0xa3 then and8(:e, cycles: 4)
|
216
|
+
when 0xa4 then and8(:h, cycles: 4)
|
217
|
+
when 0xa5 then and8(:l, cycles: 4)
|
218
|
+
when 0xa6 then and8(:indirect_hl, cycles: 8)
|
219
|
+
when 0xa7 then and8(:a, cycles: 4)
|
220
|
+
when 0xa8 then xor8(:b, cycles: 4)
|
221
|
+
when 0xa9 then xor8(:c, cycles: 4)
|
222
|
+
when 0xaa then xor8(:d, cycles: 4)
|
223
|
+
when 0xab then xor8(:e, cycles: 4)
|
224
|
+
when 0xac then xor8(:h, cycles: 4)
|
225
|
+
when 0xad then xor8(:l, cycles: 4)
|
226
|
+
when 0xae then xor8(:indirect_hl, cycles: 8)
|
227
|
+
when 0xaf then xor8(:a, cycles: 4)
|
228
|
+
when 0xb0 then or8(:b, cycles: 4)
|
229
|
+
when 0xb1 then or8(:c, cycles: 4)
|
230
|
+
when 0xb2 then or8(:d, cycles: 4)
|
231
|
+
when 0xb3 then or8(:e, cycles: 4)
|
232
|
+
when 0xb4 then or8(:h, cycles: 4)
|
233
|
+
when 0xb5 then or8(:l, cycles: 4)
|
234
|
+
when 0xb6 then or8(:indirect_hl, cycles: 8)
|
235
|
+
when 0xb7 then or8(:a, cycles: 4)
|
236
|
+
when 0xb8 then cp8(:b, cycles: 4)
|
237
|
+
when 0xb9 then cp8(:c, cycles: 4)
|
238
|
+
when 0xba then cp8(:d, cycles: 4)
|
239
|
+
when 0xbb then cp8(:e, cycles: 4)
|
240
|
+
when 0xbc then cp8(:h, cycles: 4)
|
241
|
+
when 0xbd then cp8(:l, cycles: 4)
|
242
|
+
when 0xbe then cp8(:indirect_hl, cycles: 8)
|
243
|
+
when 0xbf then cp8(:a, cycles: 4)
|
244
|
+
when 0xc0 then ret_if(condition: !flag_z)
|
245
|
+
when 0xc1 then pop16(:bc, cycles: 12)
|
246
|
+
when 0xc2 then jp(:immediate16, condition: !flag_z)
|
247
|
+
when 0xc3 then jp(:immediate16, condition: true)
|
248
|
+
when 0xc4 then call16(:immediate16, condition: !flag_z)
|
249
|
+
when 0xc5 then push16(:bc, cycles: 16)
|
250
|
+
when 0xc6 then add8(:immediate8, cycles: 8)
|
251
|
+
when 0xc7 then rst(0x00, cycles: 16)
|
252
|
+
when 0xc8 then ret_if(condition: flag_z)
|
253
|
+
when 0xc9 then ret(cycles: 16)
|
254
|
+
when 0xca then jp(:immediate16, condition: flag_z)
|
255
|
+
when 0xcc then call16(:immediate16, condition: flag_z)
|
256
|
+
when 0xcd then call16(:immediate16, condition: true)
|
257
|
+
when 0xce then adc8(:immediate8, cycles: 8)
|
258
|
+
when 0xcf then rst(0x08, cycles: 16)
|
259
|
+
when 0xd0 then ret_if(condition: !flag_c)
|
260
|
+
when 0xd1 then pop16(:de, cycles: 12)
|
261
|
+
when 0xd2 then jp(:immediate16, condition: !flag_c)
|
262
|
+
when 0xd4 then call16(:immediate16, condition: !flag_c)
|
263
|
+
when 0xd5 then push16(:de, cycles: 16)
|
264
|
+
when 0xd6 then sub8(:immediate8, cycles: 8)
|
265
|
+
when 0xd7 then rst(0x10, cycles: 16)
|
266
|
+
when 0xd8 then ret_if(condition: flag_c)
|
267
|
+
when 0xd9 then reti(cycles: 16)
|
268
|
+
when 0xda then jp(:immediate16, condition: flag_c)
|
269
|
+
when 0xdc then call16(:immediate16, condition: flag_c)
|
270
|
+
when 0xde then sbc8(:immediate8, cycles: 8)
|
271
|
+
when 0xdf then rst(0x18, cycles: 16)
|
272
|
+
when 0xe0 then ld8(:ff00, :a, cycles: 12)
|
273
|
+
when 0xe1 then pop16(:hl, cycles: 12)
|
274
|
+
when 0xe2 then ld8(:ff00_c, :a, cycles: 8)
|
275
|
+
when 0xe5 then push16(:hl, cycles: 16)
|
276
|
+
when 0xe6 then and8(:immediate8, cycles: 8)
|
277
|
+
when 0xe7 then rst(0x20, cycles: 16)
|
278
|
+
when 0xe8 then add_sp_r8(cycles: 16)
|
279
|
+
when 0xe9 then jp_hl(cycles: 4)
|
280
|
+
when 0xea then ld8(:direct8, :a, cycles: 16)
|
281
|
+
when 0xee then xor8(:immediate8, cycles: 8)
|
282
|
+
when 0xef then rst(0x28, cycles: 16)
|
283
|
+
when 0xf0 then ld8(:a, :ff00, cycles: 12)
|
284
|
+
when 0xf1 then pop16(:af, cycles: 12)
|
285
|
+
when 0xf2 then ld8(:a, :ff00_c, cycles: 8)
|
286
|
+
when 0xf3 then di(cycles: 4)
|
287
|
+
when 0xf5 then push16(:af, cycles: 16)
|
288
|
+
when 0xf6 then or8(:immediate8, cycles: 8)
|
289
|
+
when 0xf7 then rst(0x30, cycles: 16)
|
290
|
+
when 0xf8 then ld_hl_sp_r8(cycles: 12)
|
291
|
+
when 0xf9 then ld16(:sp, :hl, cycles: 8)
|
292
|
+
when 0xfa then ld8(:a, :direct8, cycles: 16)
|
293
|
+
when 0xfb then ei(cycles: 4)
|
294
|
+
when 0xfe then cp8(:immediate8, cycles: 8)
|
295
|
+
when 0xff then rst(0x38, cycles: 16)
|
297
296
|
when 0xcb # CB prefix
|
298
297
|
opcode = read_byte_and_advance_pc
|
299
298
|
|
300
299
|
case opcode
|
301
|
-
when 0x00 then rlc8(
|
302
|
-
when 0x01 then rlc8(
|
303
|
-
when 0x02 then rlc8(
|
304
|
-
when 0x03 then rlc8(
|
305
|
-
when 0x04 then rlc8(
|
306
|
-
when 0x05 then rlc8(
|
307
|
-
when 0x06 then rlc8(
|
308
|
-
when 0x07 then rlc8(
|
309
|
-
when 0x08 then rrc8(
|
310
|
-
when 0x09 then rrc8(
|
311
|
-
when 0x0a then rrc8(
|
312
|
-
when 0x0b then rrc8(
|
313
|
-
when 0x0c then rrc8(
|
314
|
-
when 0x0d then rrc8(
|
315
|
-
when 0x0e then rrc8(
|
316
|
-
when 0x0f then rrc8(
|
317
|
-
when 0x10 then rl8(
|
318
|
-
when 0x11 then rl8(
|
319
|
-
when 0x12 then rl8(
|
320
|
-
when 0x13 then rl8(
|
321
|
-
when 0x14 then rl8(
|
322
|
-
when 0x15 then rl8(
|
323
|
-
when 0x16 then rl8(
|
324
|
-
when 0x17 then rl8(
|
325
|
-
when 0x18 then rr8(
|
326
|
-
when 0x19 then rr8(
|
327
|
-
when 0x1a then rr8(
|
328
|
-
when 0x1b then rr8(
|
329
|
-
when 0x1c then rr8(
|
330
|
-
when 0x1d then rr8(
|
331
|
-
when 0x1e then rr8(
|
332
|
-
when 0x1f then rr8(
|
333
|
-
when 0x20 then sla8(
|
334
|
-
when 0x21 then sla8(
|
335
|
-
when 0x22 then sla8(
|
336
|
-
when 0x23 then sla8(
|
337
|
-
when 0x24 then sla8(
|
338
|
-
when 0x25 then sla8(
|
339
|
-
when 0x26 then sla8(
|
340
|
-
when 0x27 then sla8(
|
341
|
-
when 0x28 then sra8(
|
342
|
-
when 0x29 then sra8(
|
343
|
-
when 0x2a then sra8(
|
344
|
-
when 0x2b then sra8(
|
345
|
-
when 0x2c then sra8(
|
346
|
-
when 0x2d then sra8(
|
347
|
-
when 0x2e then sra8(
|
348
|
-
when 0x2f then sra8(
|
349
|
-
when 0x30 then swap8(
|
350
|
-
when 0x31 then swap8(
|
351
|
-
when 0x32 then swap8(
|
352
|
-
when 0x33 then swap8(
|
353
|
-
when 0x34 then swap8(
|
354
|
-
when 0x35 then swap8(
|
355
|
-
when 0x36 then swap8(
|
356
|
-
when 0x37 then swap8(
|
357
|
-
when 0x38 then srl8(
|
358
|
-
when 0x39 then srl8(
|
359
|
-
when 0x3a then srl8(
|
360
|
-
when 0x3b then srl8(
|
361
|
-
when 0x3c then srl8(
|
362
|
-
when 0x3d then srl8(
|
363
|
-
when 0x3e then srl8(
|
364
|
-
when 0x3f then srl8(
|
365
|
-
when 0x40 then bit8(0,
|
366
|
-
when 0x41 then bit8(0,
|
367
|
-
when 0x42 then bit8(0,
|
368
|
-
when 0x43 then bit8(0,
|
369
|
-
when 0x44 then bit8(0,
|
370
|
-
when 0x45 then bit8(0,
|
371
|
-
when 0x46 then bit8(0,
|
372
|
-
when 0x47 then bit8(0,
|
373
|
-
when 0x48 then bit8(1,
|
374
|
-
when 0x49 then bit8(1,
|
375
|
-
when 0x4a then bit8(1,
|
376
|
-
when 0x4b then bit8(1,
|
377
|
-
when 0x4c then bit8(1,
|
378
|
-
when 0x4d then bit8(1,
|
379
|
-
when 0x4e then bit8(1,
|
380
|
-
when 0x4f then bit8(1,
|
381
|
-
when 0x50 then bit8(2,
|
382
|
-
when 0x51 then bit8(2,
|
383
|
-
when 0x52 then bit8(2,
|
384
|
-
when 0x53 then bit8(2,
|
385
|
-
when 0x54 then bit8(2,
|
386
|
-
when 0x55 then bit8(2,
|
387
|
-
when 0x56 then bit8(2,
|
388
|
-
when 0x57 then bit8(2,
|
389
|
-
when 0x58 then bit8(3,
|
390
|
-
when 0x59 then bit8(3,
|
391
|
-
when 0x5a then bit8(3,
|
392
|
-
when 0x5b then bit8(3,
|
393
|
-
when 0x5c then bit8(3,
|
394
|
-
when 0x5d then bit8(3,
|
395
|
-
when 0x5e then bit8(3,
|
396
|
-
when 0x5f then bit8(3,
|
397
|
-
when 0x60 then bit8(4,
|
398
|
-
when 0x61 then bit8(4,
|
399
|
-
when 0x62 then bit8(4,
|
400
|
-
when 0x63 then bit8(4,
|
401
|
-
when 0x64 then bit8(4,
|
402
|
-
when 0x65 then bit8(4,
|
403
|
-
when 0x66 then bit8(4,
|
404
|
-
when 0x67 then bit8(4,
|
405
|
-
when 0x68 then bit8(5,
|
406
|
-
when 0x69 then bit8(5,
|
407
|
-
when 0x6a then bit8(5,
|
408
|
-
when 0x6b then bit8(5,
|
409
|
-
when 0x6c then bit8(5,
|
410
|
-
when 0x6d then bit8(5,
|
411
|
-
when 0x6e then bit8(5,
|
412
|
-
when 0x6f then bit8(5,
|
413
|
-
when 0x70 then bit8(6,
|
414
|
-
when 0x71 then bit8(6,
|
415
|
-
when 0x72 then bit8(6,
|
416
|
-
when 0x73 then bit8(6,
|
417
|
-
when 0x74 then bit8(6,
|
418
|
-
when 0x75 then bit8(6,
|
419
|
-
when 0x76 then bit8(6,
|
420
|
-
when 0x77 then bit8(6,
|
421
|
-
when 0x78 then bit8(7,
|
422
|
-
when 0x79 then bit8(7,
|
423
|
-
when 0x7a then bit8(7,
|
424
|
-
when 0x7b then bit8(7,
|
425
|
-
when 0x7c then bit8(7,
|
426
|
-
when 0x7d then bit8(7,
|
427
|
-
when 0x7e then bit8(7,
|
428
|
-
when 0x7f then bit8(7,
|
429
|
-
when 0x80 then res8(0,
|
430
|
-
when 0x81 then res8(0,
|
431
|
-
when 0x82 then res8(0,
|
432
|
-
when 0x83 then res8(0,
|
433
|
-
when 0x84 then res8(0,
|
434
|
-
when 0x85 then res8(0,
|
435
|
-
when 0x86 then res8(0,
|
436
|
-
when 0x87 then res8(0,
|
437
|
-
when 0x88 then res8(1,
|
438
|
-
when 0x89 then res8(1,
|
439
|
-
when 0x8a then res8(1,
|
440
|
-
when 0x8b then res8(1,
|
441
|
-
when 0x8c then res8(1,
|
442
|
-
when 0x8d then res8(1,
|
443
|
-
when 0x8e then res8(1,
|
444
|
-
when 0x8f then res8(1,
|
445
|
-
when 0x90 then res8(2,
|
446
|
-
when 0x91 then res8(2,
|
447
|
-
when 0x92 then res8(2,
|
448
|
-
when 0x93 then res8(2,
|
449
|
-
when 0x94 then res8(2,
|
450
|
-
when 0x95 then res8(2,
|
451
|
-
when 0x96 then res8(2,
|
452
|
-
when 0x97 then res8(2,
|
453
|
-
when 0x98 then res8(3,
|
454
|
-
when 0x99 then res8(3,
|
455
|
-
when 0x9a then res8(3,
|
456
|
-
when 0x9b then res8(3,
|
457
|
-
when 0x9c then res8(3,
|
458
|
-
when 0x9d then res8(3,
|
459
|
-
when 0x9e then res8(3,
|
460
|
-
when 0x9f then res8(3,
|
461
|
-
when 0xa0 then res8(4,
|
462
|
-
when 0xa1 then res8(4,
|
463
|
-
when 0xa2 then res8(4,
|
464
|
-
when 0xa3 then res8(4,
|
465
|
-
when 0xa4 then res8(4,
|
466
|
-
when 0xa5 then res8(4,
|
467
|
-
when 0xa6 then res8(4,
|
468
|
-
when 0xa7 then res8(4,
|
469
|
-
when 0xa8 then res8(5,
|
470
|
-
when 0xa9 then res8(5,
|
471
|
-
when 0xaa then res8(5,
|
472
|
-
when 0xab then res8(5,
|
473
|
-
when 0xac then res8(5,
|
474
|
-
when 0xad then res8(5,
|
475
|
-
when 0xae then res8(5,
|
476
|
-
when 0xaf then res8(5,
|
477
|
-
when 0xb0 then res8(6,
|
478
|
-
when 0xb1 then res8(6,
|
479
|
-
when 0xb2 then res8(6,
|
480
|
-
when 0xb3 then res8(6,
|
481
|
-
when 0xb4 then res8(6,
|
482
|
-
when 0xb5 then res8(6,
|
483
|
-
when 0xb6 then res8(6,
|
484
|
-
when 0xb7 then res8(6,
|
485
|
-
when 0xb8 then res8(7,
|
486
|
-
when 0xb9 then res8(7,
|
487
|
-
when 0xba then res8(7,
|
488
|
-
when 0xbb then res8(7,
|
489
|
-
when 0xbc then res8(7,
|
490
|
-
when 0xbd then res8(7,
|
491
|
-
when 0xbe then res8(7,
|
492
|
-
when 0xbf then res8(7,
|
493
|
-
when 0xc0 then set8(0,
|
494
|
-
when 0xc1 then set8(0,
|
495
|
-
when 0xc2 then set8(0,
|
496
|
-
when 0xc3 then set8(0,
|
497
|
-
when 0xc4 then set8(0,
|
498
|
-
when 0xc5 then set8(0,
|
499
|
-
when 0xc6 then set8(0,
|
500
|
-
when 0xc7 then set8(0,
|
501
|
-
when 0xc8 then set8(1,
|
502
|
-
when 0xc9 then set8(1,
|
503
|
-
when 0xca then set8(1,
|
504
|
-
when 0xcb then set8(1,
|
505
|
-
when 0xcc then set8(1,
|
506
|
-
when 0xcd then set8(1,
|
507
|
-
when 0xce then set8(1,
|
508
|
-
when 0xcf then set8(1,
|
509
|
-
when 0xd0 then set8(2,
|
510
|
-
when 0xd1 then set8(2,
|
511
|
-
when 0xd2 then set8(2,
|
512
|
-
when 0xd3 then set8(2,
|
513
|
-
when 0xd4 then set8(2,
|
514
|
-
when 0xd5 then set8(2,
|
515
|
-
when 0xd6 then set8(2,
|
516
|
-
when 0xd7 then set8(2,
|
517
|
-
when 0xd8 then set8(3,
|
518
|
-
when 0xd9 then set8(3,
|
519
|
-
when 0xda then set8(3,
|
520
|
-
when 0xdb then set8(3,
|
521
|
-
when 0xdc then set8(3,
|
522
|
-
when 0xdd then set8(3,
|
523
|
-
when 0xde then set8(3,
|
524
|
-
when 0xdf then set8(3,
|
525
|
-
when 0xe0 then set8(4,
|
526
|
-
when 0xe1 then set8(4,
|
527
|
-
when 0xe2 then set8(4,
|
528
|
-
when 0xe3 then set8(4,
|
529
|
-
when 0xe4 then set8(4,
|
530
|
-
when 0xe5 then set8(4,
|
531
|
-
when 0xe6 then set8(4,
|
532
|
-
when 0xe7 then set8(4,
|
533
|
-
when 0xe8 then set8(5,
|
534
|
-
when 0xe9 then set8(5,
|
535
|
-
when 0xea then set8(5,
|
536
|
-
when 0xeb then set8(5,
|
537
|
-
when 0xec then set8(5,
|
538
|
-
when 0xed then set8(5,
|
539
|
-
when 0xee then set8(5,
|
540
|
-
when 0xef then set8(5,
|
541
|
-
when 0xf0 then set8(6,
|
542
|
-
when 0xf1 then set8(6,
|
543
|
-
when 0xf2 then set8(6,
|
544
|
-
when 0xf3 then set8(6,
|
545
|
-
when 0xf4 then set8(6,
|
546
|
-
when 0xf5 then set8(6,
|
547
|
-
when 0xf6 then set8(6,
|
548
|
-
when 0xf7 then set8(6,
|
549
|
-
when 0xf8 then set8(7,
|
550
|
-
when 0xf9 then set8(7,
|
551
|
-
when 0xfa then set8(7,
|
552
|
-
when 0xfb then set8(7,
|
553
|
-
when 0xfc then set8(7,
|
554
|
-
when 0xfd then set8(7,
|
555
|
-
when 0xfe then set8(7,
|
556
|
-
when 0xff then set8(7,
|
300
|
+
when 0x00 then rlc8(:b, cycles: 8)
|
301
|
+
when 0x01 then rlc8(:c, cycles: 8)
|
302
|
+
when 0x02 then rlc8(:d, cycles: 8)
|
303
|
+
when 0x03 then rlc8(:e, cycles: 8)
|
304
|
+
when 0x04 then rlc8(:h, cycles: 8)
|
305
|
+
when 0x05 then rlc8(:l, cycles: 8)
|
306
|
+
when 0x06 then rlc8(:indirect_hl, cycles: 16)
|
307
|
+
when 0x07 then rlc8(:a, cycles: 8)
|
308
|
+
when 0x08 then rrc8(:b, cycles: 8)
|
309
|
+
when 0x09 then rrc8(:c, cycles: 8)
|
310
|
+
when 0x0a then rrc8(:d, cycles: 8)
|
311
|
+
when 0x0b then rrc8(:e, cycles: 8)
|
312
|
+
when 0x0c then rrc8(:h, cycles: 8)
|
313
|
+
when 0x0d then rrc8(:l, cycles: 8)
|
314
|
+
when 0x0e then rrc8(:indirect_hl, cycles: 16)
|
315
|
+
when 0x0f then rrc8(:a, cycles: 8)
|
316
|
+
when 0x10 then rl8(:b, cycles: 8)
|
317
|
+
when 0x11 then rl8(:c, cycles: 8)
|
318
|
+
when 0x12 then rl8(:d, cycles: 8)
|
319
|
+
when 0x13 then rl8(:e, cycles: 8)
|
320
|
+
when 0x14 then rl8(:h, cycles: 8)
|
321
|
+
when 0x15 then rl8(:l, cycles: 8)
|
322
|
+
when 0x16 then rl8(:indirect_hl, cycles: 16)
|
323
|
+
when 0x17 then rl8(:a, cycles: 8)
|
324
|
+
when 0x18 then rr8(:b, cycles: 8)
|
325
|
+
when 0x19 then rr8(:c, cycles: 8)
|
326
|
+
when 0x1a then rr8(:d, cycles: 8)
|
327
|
+
when 0x1b then rr8(:e, cycles: 8)
|
328
|
+
when 0x1c then rr8(:h, cycles: 8)
|
329
|
+
when 0x1d then rr8(:l, cycles: 8)
|
330
|
+
when 0x1e then rr8(:indirect_hl, cycles: 16)
|
331
|
+
when 0x1f then rr8(:a, cycles: 8)
|
332
|
+
when 0x20 then sla8(:b, cycles: 8)
|
333
|
+
when 0x21 then sla8(:c, cycles: 8)
|
334
|
+
when 0x22 then sla8(:d, cycles: 8)
|
335
|
+
when 0x23 then sla8(:e, cycles: 8)
|
336
|
+
when 0x24 then sla8(:h, cycles: 8)
|
337
|
+
when 0x25 then sla8(:l, cycles: 8)
|
338
|
+
when 0x26 then sla8(:indirect_hl, cycles: 16)
|
339
|
+
when 0x27 then sla8(:a, cycles: 8)
|
340
|
+
when 0x28 then sra8(:b, cycles: 8)
|
341
|
+
when 0x29 then sra8(:c, cycles: 8)
|
342
|
+
when 0x2a then sra8(:d, cycles: 8)
|
343
|
+
when 0x2b then sra8(:e, cycles: 8)
|
344
|
+
when 0x2c then sra8(:h, cycles: 8)
|
345
|
+
when 0x2d then sra8(:l, cycles: 8)
|
346
|
+
when 0x2e then sra8(:indirect_hl, cycles: 16)
|
347
|
+
when 0x2f then sra8(:a, cycles: 8)
|
348
|
+
when 0x30 then swap8(:b, cycles: 8)
|
349
|
+
when 0x31 then swap8(:c, cycles: 8)
|
350
|
+
when 0x32 then swap8(:d, cycles: 8)
|
351
|
+
when 0x33 then swap8(:e, cycles: 8)
|
352
|
+
when 0x34 then swap8(:h, cycles: 8)
|
353
|
+
when 0x35 then swap8(:l, cycles: 8)
|
354
|
+
when 0x36 then swap8(:indirect_hl, cycles: 16)
|
355
|
+
when 0x37 then swap8(:a, cycles: 8)
|
356
|
+
when 0x38 then srl8(:b, cycles: 8)
|
357
|
+
when 0x39 then srl8(:c, cycles: 8)
|
358
|
+
when 0x3a then srl8(:d, cycles: 8)
|
359
|
+
when 0x3b then srl8(:e, cycles: 8)
|
360
|
+
when 0x3c then srl8(:h, cycles: 8)
|
361
|
+
when 0x3d then srl8(:l, cycles: 8)
|
362
|
+
when 0x3e then srl8(:indirect_hl, cycles: 16)
|
363
|
+
when 0x3f then srl8(:a, cycles: 8)
|
364
|
+
when 0x40 then bit8(0, :b, cycles: 8)
|
365
|
+
when 0x41 then bit8(0, :c, cycles: 8)
|
366
|
+
when 0x42 then bit8(0, :d, cycles: 8)
|
367
|
+
when 0x43 then bit8(0, :e, cycles: 8)
|
368
|
+
when 0x44 then bit8(0, :h, cycles: 8)
|
369
|
+
when 0x45 then bit8(0, :l, cycles: 8)
|
370
|
+
when 0x46 then bit8(0, :indirect_hl, cycles: 12)
|
371
|
+
when 0x47 then bit8(0, :a, cycles: 8)
|
372
|
+
when 0x48 then bit8(1, :b, cycles: 8)
|
373
|
+
when 0x49 then bit8(1, :c, cycles: 8)
|
374
|
+
when 0x4a then bit8(1, :d, cycles: 8)
|
375
|
+
when 0x4b then bit8(1, :e, cycles: 8)
|
376
|
+
when 0x4c then bit8(1, :h, cycles: 8)
|
377
|
+
when 0x4d then bit8(1, :l, cycles: 8)
|
378
|
+
when 0x4e then bit8(1, :indirect_hl, cycles: 12)
|
379
|
+
when 0x4f then bit8(1, :a, cycles: 8)
|
380
|
+
when 0x50 then bit8(2, :b, cycles: 8)
|
381
|
+
when 0x51 then bit8(2, :c, cycles: 8)
|
382
|
+
when 0x52 then bit8(2, :d, cycles: 8)
|
383
|
+
when 0x53 then bit8(2, :e, cycles: 8)
|
384
|
+
when 0x54 then bit8(2, :h, cycles: 8)
|
385
|
+
when 0x55 then bit8(2, :l, cycles: 8)
|
386
|
+
when 0x56 then bit8(2, :indirect_hl, cycles: 12)
|
387
|
+
when 0x57 then bit8(2, :a, cycles: 8)
|
388
|
+
when 0x58 then bit8(3, :b, cycles: 8)
|
389
|
+
when 0x59 then bit8(3, :c, cycles: 8)
|
390
|
+
when 0x5a then bit8(3, :d, cycles: 8)
|
391
|
+
when 0x5b then bit8(3, :e, cycles: 8)
|
392
|
+
when 0x5c then bit8(3, :h, cycles: 8)
|
393
|
+
when 0x5d then bit8(3, :l, cycles: 8)
|
394
|
+
when 0x5e then bit8(3, :indirect_hl, cycles: 12)
|
395
|
+
when 0x5f then bit8(3, :a, cycles: 8)
|
396
|
+
when 0x60 then bit8(4, :b, cycles: 8)
|
397
|
+
when 0x61 then bit8(4, :c, cycles: 8)
|
398
|
+
when 0x62 then bit8(4, :d, cycles: 8)
|
399
|
+
when 0x63 then bit8(4, :e, cycles: 8)
|
400
|
+
when 0x64 then bit8(4, :h, cycles: 8)
|
401
|
+
when 0x65 then bit8(4, :l, cycles: 8)
|
402
|
+
when 0x66 then bit8(4, :indirect_hl, cycles: 12)
|
403
|
+
when 0x67 then bit8(4, :a, cycles: 8)
|
404
|
+
when 0x68 then bit8(5, :b, cycles: 8)
|
405
|
+
when 0x69 then bit8(5, :c, cycles: 8)
|
406
|
+
when 0x6a then bit8(5, :d, cycles: 8)
|
407
|
+
when 0x6b then bit8(5, :e, cycles: 8)
|
408
|
+
when 0x6c then bit8(5, :h, cycles: 8)
|
409
|
+
when 0x6d then bit8(5, :l, cycles: 8)
|
410
|
+
when 0x6e then bit8(5, :indirect_hl, cycles: 12)
|
411
|
+
when 0x6f then bit8(5, :a, cycles: 8)
|
412
|
+
when 0x70 then bit8(6, :b, cycles: 8)
|
413
|
+
when 0x71 then bit8(6, :c, cycles: 8)
|
414
|
+
when 0x72 then bit8(6, :d, cycles: 8)
|
415
|
+
when 0x73 then bit8(6, :e, cycles: 8)
|
416
|
+
when 0x74 then bit8(6, :h, cycles: 8)
|
417
|
+
when 0x75 then bit8(6, :l, cycles: 8)
|
418
|
+
when 0x76 then bit8(6, :indirect_hl, cycles: 12)
|
419
|
+
when 0x77 then bit8(6, :a, cycles: 8)
|
420
|
+
when 0x78 then bit8(7, :b, cycles: 8)
|
421
|
+
when 0x79 then bit8(7, :c, cycles: 8)
|
422
|
+
when 0x7a then bit8(7, :d, cycles: 8)
|
423
|
+
when 0x7b then bit8(7, :e, cycles: 8)
|
424
|
+
when 0x7c then bit8(7, :h, cycles: 8)
|
425
|
+
when 0x7d then bit8(7, :l, cycles: 8)
|
426
|
+
when 0x7e then bit8(7, :indirect_hl, cycles: 12)
|
427
|
+
when 0x7f then bit8(7, :a, cycles: 8)
|
428
|
+
when 0x80 then res8(0, :b, cycles: 8)
|
429
|
+
when 0x81 then res8(0, :c, cycles: 8)
|
430
|
+
when 0x82 then res8(0, :d, cycles: 8)
|
431
|
+
when 0x83 then res8(0, :e, cycles: 8)
|
432
|
+
when 0x84 then res8(0, :h, cycles: 8)
|
433
|
+
when 0x85 then res8(0, :l, cycles: 8)
|
434
|
+
when 0x86 then res8(0, :indirect_hl, cycles: 16)
|
435
|
+
when 0x87 then res8(0, :a, cycles: 8)
|
436
|
+
when 0x88 then res8(1, :b, cycles: 8)
|
437
|
+
when 0x89 then res8(1, :c, cycles: 8)
|
438
|
+
when 0x8a then res8(1, :d, cycles: 8)
|
439
|
+
when 0x8b then res8(1, :e, cycles: 8)
|
440
|
+
when 0x8c then res8(1, :h, cycles: 8)
|
441
|
+
when 0x8d then res8(1, :l, cycles: 8)
|
442
|
+
when 0x8e then res8(1, :indirect_hl, cycles: 16)
|
443
|
+
when 0x8f then res8(1, :a, cycles: 8)
|
444
|
+
when 0x90 then res8(2, :b, cycles: 8)
|
445
|
+
when 0x91 then res8(2, :c, cycles: 8)
|
446
|
+
when 0x92 then res8(2, :d, cycles: 8)
|
447
|
+
when 0x93 then res8(2, :e, cycles: 8)
|
448
|
+
when 0x94 then res8(2, :h, cycles: 8)
|
449
|
+
when 0x95 then res8(2, :l, cycles: 8)
|
450
|
+
when 0x96 then res8(2, :indirect_hl, cycles: 16)
|
451
|
+
when 0x97 then res8(2, :a, cycles: 8)
|
452
|
+
when 0x98 then res8(3, :b, cycles: 8)
|
453
|
+
when 0x99 then res8(3, :c, cycles: 8)
|
454
|
+
when 0x9a then res8(3, :d, cycles: 8)
|
455
|
+
when 0x9b then res8(3, :e, cycles: 8)
|
456
|
+
when 0x9c then res8(3, :h, cycles: 8)
|
457
|
+
when 0x9d then res8(3, :l, cycles: 8)
|
458
|
+
when 0x9e then res8(3, :indirect_hl, cycles: 16)
|
459
|
+
when 0x9f then res8(3, :a, cycles: 8)
|
460
|
+
when 0xa0 then res8(4, :b, cycles: 8)
|
461
|
+
when 0xa1 then res8(4, :c, cycles: 8)
|
462
|
+
when 0xa2 then res8(4, :d, cycles: 8)
|
463
|
+
when 0xa3 then res8(4, :e, cycles: 8)
|
464
|
+
when 0xa4 then res8(4, :h, cycles: 8)
|
465
|
+
when 0xa5 then res8(4, :l, cycles: 8)
|
466
|
+
when 0xa6 then res8(4, :indirect_hl, cycles: 16)
|
467
|
+
when 0xa7 then res8(4, :a, cycles: 8)
|
468
|
+
when 0xa8 then res8(5, :b, cycles: 8)
|
469
|
+
when 0xa9 then res8(5, :c, cycles: 8)
|
470
|
+
when 0xaa then res8(5, :d, cycles: 8)
|
471
|
+
when 0xab then res8(5, :e, cycles: 8)
|
472
|
+
when 0xac then res8(5, :h, cycles: 8)
|
473
|
+
when 0xad then res8(5, :l, cycles: 8)
|
474
|
+
when 0xae then res8(5, :indirect_hl, cycles: 16)
|
475
|
+
when 0xaf then res8(5, :a, cycles: 8)
|
476
|
+
when 0xb0 then res8(6, :b, cycles: 8)
|
477
|
+
when 0xb1 then res8(6, :c, cycles: 8)
|
478
|
+
when 0xb2 then res8(6, :d, cycles: 8)
|
479
|
+
when 0xb3 then res8(6, :e, cycles: 8)
|
480
|
+
when 0xb4 then res8(6, :h, cycles: 8)
|
481
|
+
when 0xb5 then res8(6, :l, cycles: 8)
|
482
|
+
when 0xb6 then res8(6, :indirect_hl, cycles: 16)
|
483
|
+
when 0xb7 then res8(6, :a, cycles: 8)
|
484
|
+
when 0xb8 then res8(7, :b, cycles: 8)
|
485
|
+
when 0xb9 then res8(7, :c, cycles: 8)
|
486
|
+
when 0xba then res8(7, :d, cycles: 8)
|
487
|
+
when 0xbb then res8(7, :e, cycles: 8)
|
488
|
+
when 0xbc then res8(7, :h, cycles: 8)
|
489
|
+
when 0xbd then res8(7, :l, cycles: 8)
|
490
|
+
when 0xbe then res8(7, :indirect_hl, cycles: 16)
|
491
|
+
when 0xbf then res8(7, :a, cycles: 8)
|
492
|
+
when 0xc0 then set8(0, :b, cycles: 8)
|
493
|
+
when 0xc1 then set8(0, :c, cycles: 8)
|
494
|
+
when 0xc2 then set8(0, :d, cycles: 8)
|
495
|
+
when 0xc3 then set8(0, :e, cycles: 8)
|
496
|
+
when 0xc4 then set8(0, :h, cycles: 8)
|
497
|
+
when 0xc5 then set8(0, :l, cycles: 8)
|
498
|
+
when 0xc6 then set8(0, :indirect_hl, cycles: 16)
|
499
|
+
when 0xc7 then set8(0, :a, cycles: 8)
|
500
|
+
when 0xc8 then set8(1, :b, cycles: 8)
|
501
|
+
when 0xc9 then set8(1, :c, cycles: 8)
|
502
|
+
when 0xca then set8(1, :d, cycles: 8)
|
503
|
+
when 0xcb then set8(1, :e, cycles: 8)
|
504
|
+
when 0xcc then set8(1, :h, cycles: 8)
|
505
|
+
when 0xcd then set8(1, :l, cycles: 8)
|
506
|
+
when 0xce then set8(1, :indirect_hl, cycles: 16)
|
507
|
+
when 0xcf then set8(1, :a, cycles: 8)
|
508
|
+
when 0xd0 then set8(2, :b, cycles: 8)
|
509
|
+
when 0xd1 then set8(2, :c, cycles: 8)
|
510
|
+
when 0xd2 then set8(2, :d, cycles: 8)
|
511
|
+
when 0xd3 then set8(2, :e, cycles: 8)
|
512
|
+
when 0xd4 then set8(2, :h, cycles: 8)
|
513
|
+
when 0xd5 then set8(2, :l, cycles: 8)
|
514
|
+
when 0xd6 then set8(2, :indirect_hl, cycles: 16)
|
515
|
+
when 0xd7 then set8(2, :a, cycles: 8)
|
516
|
+
when 0xd8 then set8(3, :b, cycles: 8)
|
517
|
+
when 0xd9 then set8(3, :c, cycles: 8)
|
518
|
+
when 0xda then set8(3, :d, cycles: 8)
|
519
|
+
when 0xdb then set8(3, :e, cycles: 8)
|
520
|
+
when 0xdc then set8(3, :h, cycles: 8)
|
521
|
+
when 0xdd then set8(3, :l, cycles: 8)
|
522
|
+
when 0xde then set8(3, :indirect_hl, cycles: 16)
|
523
|
+
when 0xdf then set8(3, :a, cycles: 8)
|
524
|
+
when 0xe0 then set8(4, :b, cycles: 8)
|
525
|
+
when 0xe1 then set8(4, :c, cycles: 8)
|
526
|
+
when 0xe2 then set8(4, :d, cycles: 8)
|
527
|
+
when 0xe3 then set8(4, :e, cycles: 8)
|
528
|
+
when 0xe4 then set8(4, :h, cycles: 8)
|
529
|
+
when 0xe5 then set8(4, :l, cycles: 8)
|
530
|
+
when 0xe6 then set8(4, :indirect_hl, cycles: 16)
|
531
|
+
when 0xe7 then set8(4, :a, cycles: 8)
|
532
|
+
when 0xe8 then set8(5, :b, cycles: 8)
|
533
|
+
when 0xe9 then set8(5, :c, cycles: 8)
|
534
|
+
when 0xea then set8(5, :d, cycles: 8)
|
535
|
+
when 0xeb then set8(5, :e, cycles: 8)
|
536
|
+
when 0xec then set8(5, :h, cycles: 8)
|
537
|
+
when 0xed then set8(5, :l, cycles: 8)
|
538
|
+
when 0xee then set8(5, :indirect_hl, cycles: 16)
|
539
|
+
when 0xef then set8(5, :a, cycles: 8)
|
540
|
+
when 0xf0 then set8(6, :b, cycles: 8)
|
541
|
+
when 0xf1 then set8(6, :c, cycles: 8)
|
542
|
+
when 0xf2 then set8(6, :d, cycles: 8)
|
543
|
+
when 0xf3 then set8(6, :e, cycles: 8)
|
544
|
+
when 0xf4 then set8(6, :h, cycles: 8)
|
545
|
+
when 0xf5 then set8(6, :l, cycles: 8)
|
546
|
+
when 0xf6 then set8(6, :indirect_hl, cycles: 16)
|
547
|
+
when 0xf7 then set8(6, :a, cycles: 8)
|
548
|
+
when 0xf8 then set8(7, :b, cycles: 8)
|
549
|
+
when 0xf9 then set8(7, :c, cycles: 8)
|
550
|
+
when 0xfa then set8(7, :d, cycles: 8)
|
551
|
+
when 0xfb then set8(7, :e, cycles: 8)
|
552
|
+
when 0xfc then set8(7, :h, cycles: 8)
|
553
|
+
when 0xfd then set8(7, :l, cycles: 8)
|
554
|
+
when 0xfe then set8(7, :indirect_hl, cycles: 16)
|
555
|
+
when 0xff then set8(7, :a, cycles: 8)
|
557
556
|
else
|
558
557
|
raise "unknown opcode: 0xcb 0x#{'%02x' % opcode}"
|
559
558
|
end
|
@@ -593,27 +592,33 @@ module Rubyboy
|
|
593
592
|
end
|
594
593
|
|
595
594
|
def print_log(opcode)
|
596
|
-
puts "PC: 0x#{'%04x' % @pc}, Opcode: 0x#{'%02x' % opcode}, AF: 0x#{'%04x' % @registers.
|
595
|
+
puts "PC: 0x#{'%04x' % @pc}, Opcode: 0x#{'%02x' % opcode}, AF: 0x#{'%04x' % @registers.af}, BC: 0x#{'%04x' % @registers.bc}, HL: 0x#{'%04x' % @registers.hl}, SP: 0x#{'%04x' % @sp}"
|
597
596
|
end
|
598
597
|
|
599
|
-
def
|
600
|
-
|
601
|
-
{
|
602
|
-
z: f_value[7] == 1,
|
603
|
-
n: f_value[6] == 1,
|
604
|
-
h: f_value[5] == 1,
|
605
|
-
c: f_value[4] == 1
|
606
|
-
}
|
598
|
+
def flag_z
|
599
|
+
@registers.f[7] == 1
|
607
600
|
end
|
608
601
|
|
609
|
-
def
|
602
|
+
def flag_n
|
603
|
+
@registers.f[6] == 1
|
604
|
+
end
|
605
|
+
|
606
|
+
def flag_h
|
607
|
+
@registers.f[5] == 1
|
608
|
+
end
|
609
|
+
|
610
|
+
def flag_c
|
611
|
+
@registers.f[4] == 1
|
612
|
+
end
|
613
|
+
|
614
|
+
def update_flags(z: flag_z, n: flag_n, h: flag_h, c: flag_c)
|
610
615
|
f_value = 0x00
|
611
616
|
f_value |= 0x80 if z
|
612
617
|
f_value |= 0x40 if n
|
613
618
|
f_value |= 0x20 if h
|
614
619
|
f_value |= 0x10 if c
|
615
620
|
|
616
|
-
@registers.
|
621
|
+
@registers.f = f_value
|
617
622
|
end
|
618
623
|
|
619
624
|
def bool_to_integer(bool)
|
@@ -633,10 +638,10 @@ module Rubyboy
|
|
633
638
|
byte > 127 ? byte - 256 : byte
|
634
639
|
end
|
635
640
|
|
636
|
-
def rlca
|
637
|
-
a_value = @registers.
|
641
|
+
def rlca(cycles:)
|
642
|
+
a_value = @registers.a
|
638
643
|
a_value = ((a_value << 1) | (a_value >> 7)) & 0xff
|
639
|
-
@registers.
|
644
|
+
@registers.a = a_value
|
640
645
|
update_flags(
|
641
646
|
z: false,
|
642
647
|
n: false,
|
@@ -644,13 +649,13 @@ module Rubyboy
|
|
644
649
|
c: a_value[0] == 1
|
645
650
|
)
|
646
651
|
|
647
|
-
|
652
|
+
cycles
|
648
653
|
end
|
649
654
|
|
650
|
-
def rrca
|
651
|
-
a_value = @registers.
|
655
|
+
def rrca(cycles:)
|
656
|
+
a_value = @registers.a
|
652
657
|
a_value = ((a_value >> 1) | (a_value << 7)) & 0xff
|
653
|
-
@registers.
|
658
|
+
@registers.a = a_value
|
654
659
|
update_flags(
|
655
660
|
z: false,
|
656
661
|
n: false,
|
@@ -658,14 +663,14 @@ module Rubyboy
|
|
658
663
|
c: a_value[7] == 1
|
659
664
|
)
|
660
665
|
|
661
|
-
|
666
|
+
cycles
|
662
667
|
end
|
663
668
|
|
664
|
-
def rra
|
665
|
-
a_value = @registers.
|
669
|
+
def rra(cycles:)
|
670
|
+
a_value = @registers.a
|
666
671
|
cflag = a_value[0] == 1
|
667
|
-
a_value = ((a_value >> 1) | (bool_to_integer(
|
668
|
-
@registers.
|
672
|
+
a_value = ((a_value >> 1) | (bool_to_integer(flag_c) << 7)) & 0xff
|
673
|
+
@registers.a = a_value
|
669
674
|
update_flags(
|
670
675
|
z: false,
|
671
676
|
n: false,
|
@@ -673,14 +678,14 @@ module Rubyboy
|
|
673
678
|
c: cflag
|
674
679
|
)
|
675
680
|
|
676
|
-
|
681
|
+
cycles
|
677
682
|
end
|
678
683
|
|
679
|
-
def rla
|
680
|
-
a_value = @registers.
|
684
|
+
def rla(cycles:)
|
685
|
+
a_value = @registers.a
|
681
686
|
cflag = a_value[7] == 1
|
682
|
-
a_value = ((a_value << 1) | bool_to_integer(
|
683
|
-
@registers.
|
687
|
+
a_value = ((a_value << 1) | bool_to_integer(flag_c)) & 0xff
|
688
|
+
@registers.a = a_value
|
684
689
|
update_flags(
|
685
690
|
z: false,
|
686
691
|
n: false,
|
@@ -688,62 +693,62 @@ module Rubyboy
|
|
688
693
|
c: cflag
|
689
694
|
)
|
690
695
|
|
691
|
-
|
696
|
+
cycles
|
692
697
|
end
|
693
698
|
|
694
|
-
def daa
|
695
|
-
a_value = @registers.
|
696
|
-
if
|
697
|
-
a_value -= 0x06 if
|
698
|
-
a_value -= 0x60 if
|
699
|
+
def daa(cycles:)
|
700
|
+
a_value = @registers.a
|
701
|
+
if flag_n
|
702
|
+
a_value -= 0x06 if flag_h
|
703
|
+
a_value -= 0x60 if flag_c
|
699
704
|
else
|
700
|
-
if
|
705
|
+
if flag_c || a_value > 0x99
|
701
706
|
a_value += 0x60
|
702
707
|
update_flags(c: true)
|
703
708
|
end
|
704
|
-
a_value += 0x06 if
|
709
|
+
a_value += 0x06 if flag_h || (a_value & 0x0f) > 0x09
|
705
710
|
end
|
706
711
|
|
707
|
-
@registers.
|
712
|
+
@registers.a = a_value
|
708
713
|
update_flags(
|
709
|
-
z: @registers.
|
714
|
+
z: @registers.a == 0,
|
710
715
|
h: false
|
711
716
|
)
|
712
717
|
|
713
|
-
|
718
|
+
cycles
|
714
719
|
end
|
715
720
|
|
716
|
-
def cpl
|
717
|
-
@registers.
|
721
|
+
def cpl(cycles:)
|
722
|
+
@registers.a = ~@registers.a
|
718
723
|
update_flags(
|
719
724
|
n: true,
|
720
725
|
h: true
|
721
726
|
)
|
722
727
|
|
723
|
-
|
728
|
+
cycles
|
724
729
|
end
|
725
730
|
|
726
|
-
def scf
|
731
|
+
def scf(cycles:)
|
727
732
|
update_flags(
|
728
733
|
n: false,
|
729
734
|
h: false,
|
730
735
|
c: true
|
731
736
|
)
|
732
737
|
|
733
|
-
|
738
|
+
cycles
|
734
739
|
end
|
735
740
|
|
736
|
-
def ccf
|
741
|
+
def ccf(cycles:)
|
737
742
|
update_flags(
|
738
743
|
n: false,
|
739
744
|
h: false,
|
740
|
-
c: !
|
745
|
+
c: !flag_c
|
741
746
|
)
|
742
747
|
|
743
|
-
|
748
|
+
cycles
|
744
749
|
end
|
745
750
|
|
746
|
-
def inc8(x)
|
751
|
+
def inc8(x, cycles:)
|
747
752
|
value = (get_value(x) + 1) & 0xff
|
748
753
|
set_value(x, value)
|
749
754
|
update_flags(
|
@@ -752,16 +757,16 @@ module Rubyboy
|
|
752
757
|
h: (value & 0x0f) == 0
|
753
758
|
)
|
754
759
|
|
755
|
-
|
760
|
+
cycles
|
756
761
|
end
|
757
762
|
|
758
|
-
def inc16(x)
|
763
|
+
def inc16(x, cycles:)
|
759
764
|
set_value(x, get_value(x) + 1)
|
760
765
|
|
761
|
-
|
766
|
+
cycles
|
762
767
|
end
|
763
768
|
|
764
|
-
def dec8(x)
|
769
|
+
def dec8(x, cycles:)
|
765
770
|
value = (get_value(x) - 1) & 0xff
|
766
771
|
set_value(x, value)
|
767
772
|
update_flags(
|
@@ -770,35 +775,35 @@ module Rubyboy
|
|
770
775
|
h: (value & 0x0f) == 0x0f
|
771
776
|
)
|
772
777
|
|
773
|
-
|
778
|
+
cycles
|
774
779
|
end
|
775
780
|
|
776
|
-
def dec16(x)
|
781
|
+
def dec16(x, cycles:)
|
777
782
|
set_value(x, get_value(x) - 1)
|
778
783
|
|
779
|
-
|
784
|
+
cycles
|
780
785
|
end
|
781
786
|
|
782
|
-
def add8(x)
|
783
|
-
a_value = @registers.
|
787
|
+
def add8(x, cycles:)
|
788
|
+
a_value = @registers.a
|
784
789
|
x_value = get_value(x)
|
785
790
|
|
786
791
|
hflag = (a_value & 0x0f) + (x_value & 0x0f) > 0x0f
|
787
792
|
cflag = a_value + x_value > 0xff
|
788
793
|
|
789
794
|
a_value += x_value
|
790
|
-
@registers.
|
795
|
+
@registers.a = a_value
|
791
796
|
update_flags(
|
792
|
-
z: @registers.
|
797
|
+
z: @registers.a == 0,
|
793
798
|
n: false,
|
794
799
|
h: hflag,
|
795
800
|
c: cflag
|
796
801
|
)
|
797
802
|
|
798
|
-
|
803
|
+
cycles
|
799
804
|
end
|
800
805
|
|
801
|
-
def add16(x, y)
|
806
|
+
def add16(x, y, cycles:)
|
802
807
|
x_value = get_value(x)
|
803
808
|
y_value = get_value(y)
|
804
809
|
|
@@ -812,10 +817,10 @@ module Rubyboy
|
|
812
817
|
c: cflag
|
813
818
|
)
|
814
819
|
|
815
|
-
|
820
|
+
cycles
|
816
821
|
end
|
817
822
|
|
818
|
-
def add_sp_r8
|
823
|
+
def add_sp_r8(cycles:)
|
819
824
|
byte = to_signed_byte(read_byte_and_advance_pc)
|
820
825
|
|
821
826
|
hflag = (@sp & 0x0f) + (byte & 0x0f) > 0x0f
|
@@ -830,17 +835,17 @@ module Rubyboy
|
|
830
835
|
c: cflag
|
831
836
|
)
|
832
837
|
|
833
|
-
|
838
|
+
cycles
|
834
839
|
end
|
835
840
|
|
836
|
-
def sub8(x)
|
837
|
-
a_value = @registers.
|
841
|
+
def sub8(x, cycles:)
|
842
|
+
a_value = @registers.a
|
838
843
|
x_value = get_value(x)
|
839
844
|
|
840
845
|
hflag = (x_value & 0x0f) > (a_value & 0x0f)
|
841
846
|
cflag = x_value > a_value
|
842
847
|
a_value -= x_value
|
843
|
-
@registers.
|
848
|
+
@registers.a = a_value
|
844
849
|
update_flags(
|
845
850
|
z: a_value == 0,
|
846
851
|
n: true,
|
@@ -848,50 +853,50 @@ module Rubyboy
|
|
848
853
|
c: cflag
|
849
854
|
)
|
850
855
|
|
851
|
-
|
856
|
+
cycles
|
852
857
|
end
|
853
858
|
|
854
|
-
def adc8(x)
|
855
|
-
a_value = @registers.
|
859
|
+
def adc8(x, cycles:)
|
860
|
+
a_value = @registers.a
|
856
861
|
x_value = get_value(x)
|
857
|
-
c_value = bool_to_integer(
|
862
|
+
c_value = bool_to_integer(flag_c)
|
858
863
|
|
859
864
|
hflag = (a_value & 0x0f) + (x_value & 0x0f) + c_value > 0x0f
|
860
865
|
cflag = a_value + x_value + c_value > 0xff
|
861
866
|
a_value += x_value + c_value
|
862
|
-
@registers.
|
867
|
+
@registers.a = a_value
|
863
868
|
update_flags(
|
864
|
-
z: @registers.
|
869
|
+
z: @registers.a == 0,
|
865
870
|
n: false,
|
866
871
|
h: hflag,
|
867
872
|
c: cflag
|
868
873
|
)
|
869
874
|
|
870
|
-
|
875
|
+
cycles
|
871
876
|
end
|
872
877
|
|
873
|
-
def sbc8(x)
|
874
|
-
a_value = @registers.
|
878
|
+
def sbc8(x, cycles:)
|
879
|
+
a_value = @registers.a
|
875
880
|
x_value = get_value(x)
|
876
|
-
c_value = bool_to_integer(
|
881
|
+
c_value = bool_to_integer(flag_c)
|
877
882
|
|
878
883
|
hflag = (x_value & 0x0f) + c_value > (a_value & 0x0f)
|
879
884
|
cflag = x_value + c_value > a_value
|
880
885
|
a_value -= x_value + c_value
|
881
|
-
@registers.
|
886
|
+
@registers.a = a_value
|
882
887
|
update_flags(
|
883
|
-
z: @registers.
|
888
|
+
z: @registers.a == 0,
|
884
889
|
n: true,
|
885
890
|
h: hflag,
|
886
891
|
c: cflag
|
887
892
|
)
|
888
893
|
|
889
|
-
|
894
|
+
cycles
|
890
895
|
end
|
891
896
|
|
892
|
-
def and8(x)
|
893
|
-
a_value = @registers.
|
894
|
-
@registers.
|
897
|
+
def and8(x, cycles:)
|
898
|
+
a_value = @registers.a & get_value(x)
|
899
|
+
@registers.a = a_value
|
895
900
|
update_flags(
|
896
901
|
z: a_value == 0,
|
897
902
|
n: false,
|
@@ -899,12 +904,12 @@ module Rubyboy
|
|
899
904
|
c: false
|
900
905
|
)
|
901
906
|
|
902
|
-
|
907
|
+
cycles
|
903
908
|
end
|
904
909
|
|
905
|
-
def or8(x)
|
906
|
-
a_value = @registers.
|
907
|
-
@registers.
|
910
|
+
def or8(x, cycles:)
|
911
|
+
a_value = @registers.a | get_value(x)
|
912
|
+
@registers.a = a_value
|
908
913
|
update_flags(
|
909
914
|
z: a_value == 0,
|
910
915
|
n: false,
|
@@ -912,12 +917,12 @@ module Rubyboy
|
|
912
917
|
c: false
|
913
918
|
)
|
914
919
|
|
915
|
-
|
920
|
+
cycles
|
916
921
|
end
|
917
922
|
|
918
|
-
def xor8(x)
|
919
|
-
a_value = @registers.
|
920
|
-
@registers.
|
923
|
+
def xor8(x, cycles:)
|
924
|
+
a_value = @registers.a ^ get_value(x)
|
925
|
+
@registers.a = a_value
|
921
926
|
update_flags(
|
922
927
|
z: a_value == 0,
|
923
928
|
n: false,
|
@@ -925,58 +930,49 @@ module Rubyboy
|
|
925
930
|
c: false
|
926
931
|
)
|
927
932
|
|
928
|
-
|
933
|
+
cycles
|
929
934
|
end
|
930
935
|
|
931
|
-
def push16(register16)
|
932
|
-
value = @registers.read16(register16)
|
936
|
+
def push16(register16, cycles:)
|
933
937
|
@sp -= 2
|
934
|
-
write_word(@sp,
|
938
|
+
write_word(@sp, get_value(register16))
|
935
939
|
|
936
|
-
|
940
|
+
cycles
|
937
941
|
end
|
938
942
|
|
939
|
-
def pop16(register16)
|
940
|
-
|
943
|
+
def pop16(register16, cycles:)
|
944
|
+
set_value(register16, read_word(@sp))
|
941
945
|
@sp += 2
|
942
946
|
|
943
|
-
|
947
|
+
cycles
|
944
948
|
end
|
945
949
|
|
946
|
-
def halt
|
950
|
+
def halt(cycles:)
|
947
951
|
@halted = true
|
948
952
|
|
949
|
-
|
953
|
+
cycles
|
950
954
|
end
|
951
955
|
|
952
|
-
def ld8(x, y)
|
956
|
+
def ld8(x, y, cycles:)
|
953
957
|
value = get_value(y)
|
954
958
|
set_value(x, value)
|
955
959
|
|
956
|
-
|
957
|
-
return 12 if x[:type] == :indirect && y[:type] == :immediate8
|
958
|
-
return 12 if x[:type] == :ff00 || y[:type] == :ff00
|
959
|
-
return 16 if x[:type] == :direct8 || y[:type] == :direct8
|
960
|
-
|
961
|
-
8
|
960
|
+
cycles
|
962
961
|
end
|
963
962
|
|
964
|
-
def ld16(x, y)
|
963
|
+
def ld16(x, y, cycles:)
|
965
964
|
value = get_value(y)
|
966
965
|
set_value(x, value)
|
967
966
|
|
968
|
-
|
969
|
-
return 20 if y[:type] == :sp
|
970
|
-
|
971
|
-
12
|
967
|
+
cycles
|
972
968
|
end
|
973
969
|
|
974
|
-
def ld_hl_sp_r8
|
970
|
+
def ld_hl_sp_r8(cycles:)
|
975
971
|
byte = to_signed_byte(read_byte_and_advance_pc)
|
976
972
|
|
977
973
|
hflag = (@sp & 0x0f) + (byte & 0x0f) > 0x0f
|
978
974
|
cflag = (@sp & 0xff) + (byte & 0xff) > 0xff
|
979
|
-
@registers.
|
975
|
+
@registers.hl = @sp + byte
|
980
976
|
update_flags(
|
981
977
|
z: false,
|
982
978
|
n: false,
|
@@ -984,24 +980,24 @@ module Rubyboy
|
|
984
980
|
c: cflag
|
985
981
|
)
|
986
982
|
|
987
|
-
|
983
|
+
cycles
|
988
984
|
end
|
989
985
|
|
990
|
-
def ei
|
986
|
+
def ei(cycles:)
|
991
987
|
@ime_delay = true
|
992
988
|
|
993
|
-
|
989
|
+
cycles
|
994
990
|
end
|
995
991
|
|
996
|
-
def di
|
992
|
+
def di(cycles:)
|
997
993
|
@ime_delay = false
|
998
994
|
@ime = false
|
999
995
|
|
1000
|
-
|
996
|
+
cycles
|
1001
997
|
end
|
1002
998
|
|
1003
|
-
def cp8(x)
|
1004
|
-
a_value = @registers.
|
999
|
+
def cp8(x, cycles:)
|
1000
|
+
a_value = @registers.a
|
1005
1001
|
x_value = get_value(x)
|
1006
1002
|
|
1007
1003
|
hflag = (x_value & 0x0f) > (a_value & 0x0f)
|
@@ -1013,34 +1009,38 @@ module Rubyboy
|
|
1013
1009
|
c: cflag
|
1014
1010
|
)
|
1015
1011
|
|
1016
|
-
|
1012
|
+
cycles
|
1017
1013
|
end
|
1018
1014
|
|
1019
|
-
def rst(addr)
|
1015
|
+
def rst(addr, cycles:)
|
1020
1016
|
@sp -= 2
|
1021
1017
|
write_word(@sp, @pc)
|
1022
1018
|
@pc = addr
|
1023
1019
|
|
1024
|
-
|
1020
|
+
cycles
|
1025
1021
|
end
|
1026
1022
|
|
1027
|
-
def jr(condition:
|
1023
|
+
def jr(condition:)
|
1028
1024
|
value = to_signed_byte(read_byte_and_advance_pc)
|
1029
1025
|
@pc += value if condition
|
1030
1026
|
|
1031
1027
|
condition ? 12 : 8
|
1032
1028
|
end
|
1033
1029
|
|
1034
|
-
def jp(x, condition:
|
1030
|
+
def jp(x, condition:)
|
1035
1031
|
addr = get_value(x)
|
1036
1032
|
@pc = addr if condition
|
1037
1033
|
|
1038
|
-
return 4 if x[:type] == :register16
|
1039
|
-
|
1040
1034
|
condition ? 16 : 12
|
1041
1035
|
end
|
1042
1036
|
|
1043
|
-
def
|
1037
|
+
def jp_hl(cycles:)
|
1038
|
+
@pc = @registers.hl
|
1039
|
+
|
1040
|
+
cycles
|
1041
|
+
end
|
1042
|
+
|
1043
|
+
def call16(x, condition:)
|
1044
1044
|
addr = get_value(x)
|
1045
1045
|
if condition
|
1046
1046
|
@sp -= 2
|
@@ -1051,25 +1051,25 @@ module Rubyboy
|
|
1051
1051
|
condition ? 24 : 12
|
1052
1052
|
end
|
1053
1053
|
|
1054
|
-
def ret
|
1054
|
+
def ret(cycles:)
|
1055
1055
|
@pc = read_word(@sp)
|
1056
1056
|
@sp += 2
|
1057
1057
|
|
1058
|
-
|
1058
|
+
cycles
|
1059
1059
|
end
|
1060
1060
|
|
1061
|
-
def ret_if(condition)
|
1062
|
-
ret if condition
|
1061
|
+
def ret_if(condition:)
|
1062
|
+
ret(cycles: 16) if condition
|
1063
1063
|
|
1064
1064
|
condition ? 20 : 8
|
1065
1065
|
end
|
1066
1066
|
|
1067
|
-
def reti
|
1067
|
+
def reti(cycles:)
|
1068
1068
|
@ime = true
|
1069
|
-
ret
|
1069
|
+
ret(cycles:)
|
1070
1070
|
end
|
1071
1071
|
|
1072
|
-
def rlc8(x)
|
1072
|
+
def rlc8(x, cycles:)
|
1073
1073
|
value = get_value(x)
|
1074
1074
|
value = (value << 1) | (value >> 7)
|
1075
1075
|
set_value(x, value)
|
@@ -1080,10 +1080,10 @@ module Rubyboy
|
|
1080
1080
|
c: value[0] == 1
|
1081
1081
|
)
|
1082
1082
|
|
1083
|
-
|
1083
|
+
cycles
|
1084
1084
|
end
|
1085
1085
|
|
1086
|
-
def rrc8(x)
|
1086
|
+
def rrc8(x, cycles:)
|
1087
1087
|
value = get_value(x)
|
1088
1088
|
value = (value >> 1) | (value << 7)
|
1089
1089
|
set_value(x, value)
|
@@ -1094,13 +1094,13 @@ module Rubyboy
|
|
1094
1094
|
c: value[7] == 1
|
1095
1095
|
)
|
1096
1096
|
|
1097
|
-
|
1097
|
+
cycles
|
1098
1098
|
end
|
1099
1099
|
|
1100
|
-
def rl8(x)
|
1100
|
+
def rl8(x, cycles:)
|
1101
1101
|
value = get_value(x)
|
1102
1102
|
cflag = value[7] == 1
|
1103
|
-
value = ((value << 1) | bool_to_integer(
|
1103
|
+
value = ((value << 1) | bool_to_integer(flag_c)) & 0xff
|
1104
1104
|
set_value(x, value)
|
1105
1105
|
update_flags(
|
1106
1106
|
z: value == 0,
|
@@ -1109,13 +1109,13 @@ module Rubyboy
|
|
1109
1109
|
c: cflag
|
1110
1110
|
)
|
1111
1111
|
|
1112
|
-
|
1112
|
+
cycles
|
1113
1113
|
end
|
1114
1114
|
|
1115
|
-
def rr8(x)
|
1115
|
+
def rr8(x, cycles:)
|
1116
1116
|
value = get_value(x)
|
1117
1117
|
cflag = value[0] == 1
|
1118
|
-
value = (value >> 1) | (bool_to_integer(
|
1118
|
+
value = (value >> 1) | (bool_to_integer(flag_c) << 7)
|
1119
1119
|
set_value(x, value)
|
1120
1120
|
update_flags(
|
1121
1121
|
z: value == 0,
|
@@ -1124,10 +1124,10 @@ module Rubyboy
|
|
1124
1124
|
c: cflag
|
1125
1125
|
)
|
1126
1126
|
|
1127
|
-
|
1127
|
+
cycles
|
1128
1128
|
end
|
1129
1129
|
|
1130
|
-
def sla8(x)
|
1130
|
+
def sla8(x, cycles:)
|
1131
1131
|
value = get_value(x)
|
1132
1132
|
cflag = value[7] == 1
|
1133
1133
|
value <<= 1
|
@@ -1140,10 +1140,10 @@ module Rubyboy
|
|
1140
1140
|
c: cflag
|
1141
1141
|
)
|
1142
1142
|
|
1143
|
-
|
1143
|
+
cycles
|
1144
1144
|
end
|
1145
1145
|
|
1146
|
-
def sra8(x)
|
1146
|
+
def sra8(x, cycles:)
|
1147
1147
|
value = get_value(x)
|
1148
1148
|
cflag = value[0] == 1
|
1149
1149
|
value = (value >> 1) | (value[7] << 7)
|
@@ -1155,10 +1155,10 @@ module Rubyboy
|
|
1155
1155
|
c: cflag
|
1156
1156
|
)
|
1157
1157
|
|
1158
|
-
|
1158
|
+
cycles
|
1159
1159
|
end
|
1160
1160
|
|
1161
|
-
def swap8(x)
|
1161
|
+
def swap8(x, cycles:)
|
1162
1162
|
value = get_value(x)
|
1163
1163
|
value = ((value & 0x0f) << 4) | ((value & 0xf0) >> 4)
|
1164
1164
|
set_value(x, value)
|
@@ -1169,10 +1169,10 @@ module Rubyboy
|
|
1169
1169
|
c: false
|
1170
1170
|
)
|
1171
1171
|
|
1172
|
-
|
1172
|
+
cycles
|
1173
1173
|
end
|
1174
1174
|
|
1175
|
-
def srl8(x)
|
1175
|
+
def srl8(x, cycles:)
|
1176
1176
|
value = get_value(x)
|
1177
1177
|
cflag = value[0] == 1
|
1178
1178
|
value >>= 1
|
@@ -1184,10 +1184,10 @@ module Rubyboy
|
|
1184
1184
|
c: cflag
|
1185
1185
|
)
|
1186
1186
|
|
1187
|
-
|
1187
|
+
cycles
|
1188
1188
|
end
|
1189
1189
|
|
1190
|
-
def bit8(n, x)
|
1190
|
+
def bit8(n, x, cycles:)
|
1191
1191
|
value = get_value(x)
|
1192
1192
|
update_flags(
|
1193
1193
|
z: value[n] == 0,
|
@@ -1195,65 +1195,89 @@ module Rubyboy
|
|
1195
1195
|
h: true
|
1196
1196
|
)
|
1197
1197
|
|
1198
|
-
|
1198
|
+
cycles
|
1199
1199
|
end
|
1200
1200
|
|
1201
|
-
def res8(n, x)
|
1201
|
+
def res8(n, x, cycles:)
|
1202
1202
|
value = get_value(x)
|
1203
1203
|
value &= ((~(1 << n)) & 0xff)
|
1204
1204
|
set_value(x, value)
|
1205
1205
|
|
1206
|
-
|
1206
|
+
cycles
|
1207
1207
|
end
|
1208
1208
|
|
1209
|
-
def set8(n, x)
|
1209
|
+
def set8(n, x, cycles:)
|
1210
1210
|
value = get_value(x)
|
1211
1211
|
value |= (1 << n)
|
1212
1212
|
set_value(x, value)
|
1213
1213
|
|
1214
|
-
|
1214
|
+
cycles
|
1215
1215
|
end
|
1216
1216
|
|
1217
1217
|
def get_value(operand)
|
1218
|
-
case operand
|
1219
|
-
when :
|
1220
|
-
when :
|
1218
|
+
case operand
|
1219
|
+
when :a then @registers.a
|
1220
|
+
when :b then @registers.b
|
1221
|
+
when :c then @registers.c
|
1222
|
+
when :d then @registers.d
|
1223
|
+
when :e then @registers.e
|
1224
|
+
when :h then @registers.h
|
1225
|
+
when :l then @registers.l
|
1226
|
+
when :f then @registers.f
|
1227
|
+
when :af then @registers.af
|
1228
|
+
when :bc then @registers.bc
|
1229
|
+
when :de then @registers.de
|
1230
|
+
when :hl then @registers.hl
|
1221
1231
|
when :sp then @sp
|
1222
1232
|
when :immediate8 then read_byte_and_advance_pc
|
1223
1233
|
when :immediate16 then read_word_and_advance_pc
|
1224
1234
|
when :direct8 then read_byte(read_word_and_advance_pc)
|
1225
1235
|
when :direct16 then read_word(read_word_and_advance_pc)
|
1226
|
-
when :indirect then read_byte(@registers.read16(operand[:value]))
|
1227
1236
|
when :ff00 then read_byte(0xff00 + read_byte_and_advance_pc)
|
1228
|
-
when :ff00_c then read_byte(0xff00 + @registers.
|
1237
|
+
when :ff00_c then read_byte(0xff00 + @registers.c)
|
1229
1238
|
when :hl_inc
|
1230
|
-
value = read_byte(@registers.
|
1231
|
-
@registers.
|
1239
|
+
value = read_byte(@registers.hl)
|
1240
|
+
@registers.hl += 1
|
1232
1241
|
value
|
1233
1242
|
when :hl_dec
|
1234
|
-
value = read_byte(@registers.
|
1235
|
-
@registers.
|
1243
|
+
value = read_byte(@registers.hl)
|
1244
|
+
@registers.hl -= 1
|
1236
1245
|
value
|
1246
|
+
when :indirect_hl then read_byte(@registers.hl)
|
1247
|
+
when :indirect_bc then read_byte(@registers.bc)
|
1248
|
+
when :indirect_de then read_byte(@registers.de)
|
1237
1249
|
else raise "unknown operand: #{operand}"
|
1238
1250
|
end
|
1239
1251
|
end
|
1240
1252
|
|
1241
1253
|
def set_value(operand, value)
|
1242
|
-
case operand
|
1243
|
-
when :
|
1244
|
-
when :
|
1254
|
+
case operand
|
1255
|
+
when :a then @registers.a = value
|
1256
|
+
when :b then @registers.b = value
|
1257
|
+
when :c then @registers.c = value
|
1258
|
+
when :d then @registers.d = value
|
1259
|
+
when :e then @registers.e = value
|
1260
|
+
when :h then @registers.h = value
|
1261
|
+
when :l then @registers.l = value
|
1262
|
+
when :f then @registers.f = value
|
1263
|
+
when :af then @registers.af = value
|
1264
|
+
when :bc then @registers.bc = value
|
1265
|
+
when :de then @registers.de = value
|
1266
|
+
when :hl then @registers.hl = value
|
1245
1267
|
when :sp then @sp = value & 0xffff
|
1246
1268
|
when :direct8 then write_byte(read_word_and_advance_pc, value)
|
1247
1269
|
when :direct16 then write_word(read_word_and_advance_pc, value)
|
1248
|
-
when :indirect then write_byte(@registers.read16(operand[:value]), value)
|
1249
1270
|
when :ff00 then write_byte(0xff00 + read_byte_and_advance_pc, value)
|
1250
|
-
when :ff00_c then write_byte(0xff00 + @registers.
|
1271
|
+
when :ff00_c then write_byte(0xff00 + @registers.c, value)
|
1251
1272
|
when :hl_inc
|
1252
|
-
write_byte(@registers.
|
1253
|
-
@registers.
|
1273
|
+
write_byte(@registers.hl, value)
|
1274
|
+
@registers.hl += 1
|
1254
1275
|
when :hl_dec
|
1255
|
-
write_byte(@registers.
|
1256
|
-
@registers.
|
1276
|
+
write_byte(@registers.hl, value)
|
1277
|
+
@registers.hl -= 1
|
1278
|
+
when :indirect_hl then write_byte(@registers.hl, value)
|
1279
|
+
when :indirect_bc then write_byte(@registers.bc, value)
|
1280
|
+
when :indirect_de then write_byte(@registers.de, value)
|
1257
1281
|
when :immediate8, :immediate16 then raise 'immediate type is read only'
|
1258
1282
|
else raise "unknown operand: #{operand}"
|
1259
1283
|
end
|