-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchip8.r3
685 lines (629 loc) · 20.5 KB
/
chip8.r3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
REBOL[
; -- Core Header attributes --
title: "Chip8 Emulator"
file: %chip8.r3
version: 0.0.11
date: 2013-11-14/21:03:26
author: "Joshua Shireman"
purpose: {To emulate the CHIP8 instruction set interpreter with display}
web: http://www.github.com/kealist
source-encoding: "Windows-1252"
; -- Licensing details --
copyright: "Copyright © 2013 Joshua Shireman"
license-type: "Apache License v2.0"
license: {Copyright © 2013 Joshua Shireman
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.}
;- / history
history: {
v0.0.1 - 2013-11-14
-Initial header entry. There are a few things needed to implement. This most recent version has implemented file loading for the games.
v0.0.2 - 2013-11-14
-Fixed a few OPCODE bugs related to poking binary values. Started implementation of controls, but unfunctional
v0.0.3 - 2013-11-14
-Implemented Cyphre's sytle to detect the key presses for the 16 keypad. Currently they just print, but they will be extended to set a variable when pressed or NONE when the key up event occurs
v0.0.4 - 2013-11-19
- Cleaned up some code repetition by creating two new functions set-vx and set-vy
v0.0.5 - 2013-11-19
-Cleaned up more repetition with new functions get-vx and get-vy
v0.0.6 - 2013-11-19
-Removed extraneous code and changed keyboard control code to be tested.
v0.0.7 - 2013-11-19
-Substituted vprint for print in preparation for using SLIM. Cleaned up some various comments and code. Added a KEYPRESSED? variable initialization
v0.0.8 - 2013-11-20
-Fixed collision detection by adding alpha channel to logic test
v0.0.9 - 2013-11-22
-Added code for several more opcodes. Made a change to allow for r3-gui.r3 file since load-gui doesn't work when netowrok issues happen.
v0.0.10 - 2013-11-22
-Updated keyboard control system and changed spaces to tabs
v0.0.11 - 2013-11-24
-Cleaned up debug and a couple v16 errors}
;- \ history
;- / documentation
documentation: {
This Chip8 emulator requires Saphirions Rebol 3 with GUI and the R3-GUI file.
Currently it requires a folder full of %games/}
;- \ documentation
]
keys: copy [
false false false false
false false false false
false false false false
false false false false
]
flip-key: func [
key [char!]
/local table
][
table: [
#"1" 1 #"2" 2 #"3" 3 #"4" 4
#"q" 5 #"w" 6 #"e" 7 #"r" 8
#"a" 9 #"s" 10 #"d" 11 #"f" 12
#"z" 13 #"x" 14 #"c" 15 #"v" 16
]
key: select table key
if not none? key [
either (pick keys key) = 'false [
poke keys key 'true
][
poke keys key 'false
]
]
]
vprint: :print
either exists? %r3-gui.r3 [do %r3-gui.r3][load-gui]
moved?: false
stylize [
;backup the original window style to be able call the original key actor
window-orig: window []
;override window style with our key actor
window: window [
actors: [
on-key: [
;execute our key controls prior to 'system' key handling
switch arg/type [
key [
;here you can handle key-down events
flip-key arg/key
]
key-up [
;here you can handle key-up events
flip-key arg/key
]
]
;for example filter out faces that shouldn't get the system key events (for example editable styles)
unless all [
;moved?
guie/focal-face
tag-face? guie/focal-face 'edit
][
;handle the system key handling
do-actor/style face 'on-key arg 'window-orig
]
]
]
]
]
load-files: func [dir /local data files] [
data: copy []
files: read dir
foreach file files [
append data to-string file
insert head file dir
append/only data read file
]
data
]
game-list: load-files %games/
chip8: make object! [
;;opcode must be 2 bytes
opcode: none
; 4k memory total
;;;0x000-0x1FF - Chip 8 interpreter (contains font set in emu)
;;;0x050-0x0A0 - Used for the built in 4x5 pixel font set (0-F)
;;;0x200-0xFFF - Program ROM and work RAM
program: none
memory: #{00}
;CPU Register, 15 8-bit registers, 16th is carry flag
v: #{00}
;index register I
i: none
; program counter PC
pc: none
;gfx: array gfx-size: (64 * 32)
gfx-scale: 10
bg-color: black
ink-color: white
gfx-img: make image! reduce [to-pair reduce [64 * gfx-scale 32 * gfx-scale] ink-color]
draw-flag: false
hertz: 20
;Timers count at 60 Hz. When set above zero they will count down to zero
;The system's buzzer sounds whenever the sound timer reaches zero.
delay-timer: 0
sound-timer: 0
get-timer-value: func [
timer-id [integer!]
/local u
][
either (u: second select guie/timers timer-id) [
either ((m: now/time - u/time) < 0:0:0) [0] [to-integer m]
][
0
]
]
stack: copy array 16
sp: none
key: copy array 16
fontset: #{F0909090F02060202070F010F080F0F010F010F09090F01010F080F010F0F080F090F0F010204040F090F090F0F090F010F0F090F09090E090E090E0F0808080F0E0909090E0F080F080F0F080F08080}
initialize: func [/local u] [
random/seed now/time/precise
repeat num 4095 [append memory #{00}]
repeat num 15 [append v #{00}]
pc: 513
opcode: #{0000}
i: 1
sp: 1
;;load fontset --> Should be in #{0050} to #{00A0} which translates to memory index 81 to 161
repeat num 80 [poke memory (num) to-integer (pick fontset num)]
print "Chip 8 Emulator Initialized..."
game-names: copy []
game-data: copy []
foreach [game data] game-list [
append game-names game
append game-data data
]
program: pick game-data 1
view m: layout [
drop-down game-names on-action [
set 'program pick game-data (get-face face)
]
button "Start" on-action [
;set 'gfx-img make image! reduce [to-pair reduce [64 * gfx-scale 32 * gfx-scale] ink-color]
set 'memory copy #{00}
set 'v copy #{00}
repeat num 4095 [append memory #{00}]
repeat num 15 [append v #{00}]
set 'pc 513
set 'opcode copy #{0000}
i: 1
sp: 1
set 'stack copy array 16
set 'key copy array 16
;;load fontset --> Should be in #{0050} to #{00A0} which translates to memory index 81 to 161
repeat num 80 [poke memory (num) to-integer (pick fontset num)]
;;load game to memory ->
repeat num (length? program) [
;vprint reduce ["Setting memory location " (num + 512) " to value of " (pick program num)]
poke memory (num + 512) to-integer (pick program num)
]
vprint "Chip 8 Emulator Running Program..."
code: [chip8/emulate-cycle]
set-timer/repeat code (0:0:1 / chip8/hertz)
]
button "Stop" on-action [
foreach [t code] guie/timers [
clear-timer t
]
]
screen: image ; options [min-size: 640x320 max-size: 640x320]
when [enter] on-action [
;initialize game object
set-face screen gfx-img
]
]
]
load-program: does [
repeat num (length? program) [
poke memory (num + 512) (pick program num)
]
]
get-x: func [
o-c [binary!]
] [
(1 + shift to-integer (o-c and #{0F00}) -8)
]
get-y: func [o-c] [
(1 + shift to-integer (o-c and #{00F0}) -4)
]
get-vx: func [
o-c [binary!]
][
pick v (get-x o-c)
]
get-vy: func [
o-c [binary!]
][
pick v (get-y o-c)
]
set-vx: func [
o-c [binary!]
value
][
poke v (get-x o-c) value
]
set-vy: func [
o-c [binary!]
value
][
poke v (get-y o-c) value
]
increment-pc: does [pc: pc + 2]
fetch-opcode: func [/local u] [
u: copy #{0000}
vprint [{>>PC:} pc]
poke u 1 to-integer (pick memory pc)
poke u 2 to-integer (pick memory pc + 1)
u
;return append copy (pick memory pc) copy (pick memory (pc + 1))
]
decode-opcode: func [
oc /local n m w x u x-coord y-coord height
] [
wait 0
switch/default (oc and #{F000}) [
#{0000} [
switch/default (oc and #{000F}) [
#{0000} [
;;clear the screen
vprint [{------------------------>Clearing the screen}]
gfx-img: make image! to-pair reduce [64 * gfx-scale 32 * gfx-scale] bg-color
set-face screen gfx-img
draw-face/now screen
increment-pc
]
#{000E} [
; returns from subroutine
sp: sp - 1
pc: pick stack sp
increment-pc
vprint [{------------------------>Returning from subroutine to pc =} pc]
]
] [
;0NNN; Run program at address NNN
pc: 1 + to-integer (oc and #{0FFF})
vprint [{------------------------>Running program at address} pc]
;prin "ERROR: Unknown 0x0XXX OPCODE:" print oc
;increment-pc
]
]
#{1000} [
;; Jumps to address NNN.
vprint [{------------------------>} oc {: Jumping to address} 1 + to-integer (oc and #{0FFF})]
pc: 1 + to-integer (oc and #{0FFF})
]
#{2000} [
;; Calls subroutine at NNN.
poke stack sp pc
sp: sp + 1
u: (oc and #{0FFF})
;pc: to-integer (oc and #{0FFF})
pc: 1 + to-integer (oc and #{0FFF})
vprint ["------------------------>Subroutine at memory index " pc " = " (pick memory pc) (pick memory (pc + 1))]
]
#{3000} [
;; Skips the next instruction if VX equals NN.
nn: to-integer (oc and #{00FF})
vprint [{------------------------>V[} (get-x oc) {] =} (get-vx oc) {will skip if equal to} nn {and is} ((get-vx oc) = nn)]
either ((get-vx oc) = nn) [
increment-pc
increment-pc
] [increment-pc]
]
#{4000} [
;; Skips the next instruction if VX doesn't equal NN.
nn: (oc and #{00FF})
vprint [{------------------------>V[} (get-x oc) {] =} (get-vx oc) {will skip if not equal to} nn {and is} ((get-vx oc) = nn)]
either ((get-vx oc) != nn) [
increment-pc
increment-pc
] [increment-pc]
]
#{5000} [
;; Skips the next instruction if VX equals VY.
vprint [{------------------------>v[x]:} (get-vx oc) {v[y]} (get-vy oc) {=} ((get-vx oc) = (get-vy oc))]
either ((get-vx oc) = (get-vy oc)) [
increment-pc
increment-pc
] [increment-pc]
]
#{6000} [
;; Sets VX to NN.
nn: to-integer (oc and #{00FF})
vprint [{------------------------>Set V[} (get-x oc) {] to } nn {-->} to-integer nn]
set-vx oc nn
increment-pc
]
#{7000} [
;; Adds NN to VX.
nn: to-integer (oc and #{00FF})
vprint [{------------------------>Adding} nn {to the value of v[} (get-x oc) {]=} get-vx oc {=>} (nn + to-integer (get-vx oc))]
set-vx oc nn + (get-vx oc) ;;(remainder (num: nn + (get-vx oc)) 256)
;either ((num / 256) > 1) [poke v 16 1] [poke v 16 0]
increment-pc
]
#{8000} [
switch/default (oc and #{000F}) [
#{0000} [
;8XY0;Sets VX to the value of VY.
vprint [{------------------------Set V[} (get-x oc) {] to } (get-vy oc)]
set-vx oc (get-vy oc)
increment-pc
]
#{0001} [
;8XY1;Sets VX to VX or VY.
vprint [{------------------------>Set V[} (get-x oc) {] to } ((get-vx oc) or (get-vy oc))]
set-vx oc ((get-vx oc) or (get-vy oc))
increment-pc
]
#{0002} [
;8XY2;Sets VX to VX and VY.
vprint [{------------------------>Set V[} (get-x oc) {] to } ((get-vx oc) and (get-vy oc))]
set-vx oc ((get-vx oc) and (get-vy oc))
increment-pc
]
#{0003} [
;8XY3;Sets VX to VX xor VY.
vprint [{------------------------>Set V[} (get-x oc) {] to } ((get-vx oc) xor (get-vy oc))]
set-vx oc ((get-vx oc) xor (get-vy oc))
increment-pc
]
#{0004} [
;; 8XY4 adds register V[x] and V[y], setting v[16] flag if overflowed
vprint [{------------------------>Set V[} (get-x oc) {] to } get-vx oc {+} get-vy oc]
either (y: get-vy oc) > (255 - x: get-vx oc) [
poke v 16 1
] [
poke v 16 0
]
set-vx oc (x + y)
increment-pc
]
#{0005} [
;8XY5;VY is subtracted from VX. VF is set to 0 when there's a borrow, and 1 when there isn't.
vprint [{------------------------>Set V[} (get-x oc) {] to } get-vx oc {-} get-vy oc]
either (y: get-vy oc) > (x: get-vx oc) [
poke v 16 0
] [
poke v 16 1
]
either (x - y) > 0 [
set-vx oc (x - y)
][
set-vx oc 0
]
increment-pc
]
#{0006} [
;8XY6;Shifts VX right by one. VF is set to the value of the least significant bit of VX before the shift.
vprint [{------------------------>Set V[} (get-x oc) {] from} (get-vx oc) {to (shifted right)} (shift (get-vx oc) -1)]
poke v 16 to-integer (to-binary (get-vx oc)) and #{0000000000000001}
set-vx oc (shift (get-vx oc) -1)
increment-pc
]
#{0007} [
;8XY6;Sets VX to VY minus VX. VF is set to 0 when there's a borrow, and 1 when there isn't.
vprint [{------------------------>Set V[} (get-x oc) {] to } get-vx oc {-} get-vy oc]
either (y: get-vy oc) < (x: get-vx oc) [
poke v 16 0
] [
poke v 16 1
]
either (y - x) > 0 [
set-vx oc (y - x)
][
set-vx oc 0
]
increment-pc
]
#{000E} [
;;Shifts VX left by one. VF is set to the value of the most significant bit of VX before the shift.
vprint [{------------------------>Set V[} (get-x oc) {] from} (get-vx oc) {to (shifted left)} (shift (get-vx oc) 1)]
poke v 16 (to-binary (get-vx oc)) and #{0000000000000080}
set-vx oc (shift (get-vx oc) 1)
increment-pc
]
] [prin "ERROR: Unknown 0x8XXX OPCODE:" print oc increment-pc]
]
#{9000} [
;; Skips the next instruction if VX doesn't equal VY.
nn: to-integer (oc and #{00FF})
vprint [{------------------------>V[ } (get-x oc) {] =} (get-vx oc) {will skip if not equal to} nn {and is} ((get-vx oc) = nn)]
either ((get-vx oc) != nn) [
increment-pc
increment-pc
] [increment-pc]
]
#{A000} [
;;Sets I to the address NNN.
vprint[{------------------------>Set I to} to-integer (oc and #{0FFF})]
i: to-integer (oc and #{0FFF})
increment-pc
]
#{B000} [
;;Jumps to the address NNN plus V0.
nnn: to-integer (oc and #{0FFF})
vprint [{------------------------>Jump to address} nnn + (pick v 1)]
pc: nnn + (pick v 1)
]
#{C000} [
;;Sets VX to a random number and NN.
nn: to-integer oc and #{00FF}
m: random 256
vprint[{------------------------>Setting v[} get-x oc {]:} m {and} nn {=} m and nn]
set-vx oc to-integer ((random 256) and nn)
increment-pc
]
#{D000} [
;;0xDXYN Draws a sprite at coordinate vx, vy that has a width of 8 pixels and a height of N pixels. Each row of 8 pixels is read as bit-coded starting from memory location I; I value doesnât change after the execution of this instruction. As described above, VF is set to 1 if any screen pixels are flipped from set to unset when the sprite is drawn, and to 0 if that doesnât happen.
;print ["0xDXYN:" opcode]
height: to-integer (oc and #{000F})
poke v 16 0
x-coord: (to-integer get-vx oc)
y-coord: (to-integer get-vy oc)
vprint [{------------------------>Draw sprite} i {at} x-coord {x} y-coord {of height} height]
repeat num height [
;print (i + num - 1)
r: (pick memory (i + num))
w: enbase/base (append copy #{} r) 2
vprint [{pattern is} w]
;;m corresponds to the number of bits in m
repeat m 8 [
if ((first w) = #"1") [
coord-pair: to-pair reduce [(gfx-scale * (x-coord + m - 1)) (gfx-scale * (y-coord + num - 1))]
;;Collision Detection
;;vprint [{Collision Detection:} (pick gfx-img coord-pair) bg-color "="(pick gfx-img coord-pair) = bg-color]
either ((pick gfx-img coord-pair) = 0.0.0.255) [
vprint {Collision detected}
;;Draw a GFX-SCALE x GFX-SCALE pixel
poke v 16 1
repeat num-y gfx-scale [
repeat num-x gfx-scale [
draw-pair: coord-pair + to-pair reduce [num-x - 1 num-y - 1]
;vprint [{Drew at} draw-pair {from} coord-pair]
poke gfx-img draw-pair ink-color
]
]
] [
;;Draw a GFX-SCALE x GFX-SCALE pixel
repeat num-y gfx-scale [
repeat num-x gfx-scale [
draw-pair: coord-pair + to-pair reduce [num-x - 1 num-y - 1]
;vprint [{Drew at} draw-pair {from} coord-pair]
poke gfx-img draw-pair bg-color
]
]
]
]
w: next w
]
]
increment-pc
update-gfx
draw-flag: true
]
#{E000} [
switch/default (oc and #{00FF}) [
#{009E} [
;;Skip next instruction if key with the value of Vx is pressed.
;;Checks the keyboard, and if the key corresponding to the value of Vx is currently in the down position, PC is increased by 2.
k: pick keys ((get-vx oc) + 1)
vprint [{------------------------>key stored is:} (get-vx oc) {. k =} k {. Skipped?} k]
either (k = 'true) [
increment-pc
increment-pc
][
increment-pc
]
]
#{00A1} [
;;Skip next instruction if key with the value of Vx is not pressed.
;;Checks the keyboard, and if the key corresponding to the value of Vx is currently in the up position, PC is increased by 2.
k: pick keys ((get-vx oc) + 1)
vprint [{------------------------>key stored is:} (get-vx oc) {. k =} k {. Skipped?} (not k)]
either (k = 'true) [
increment-pc
][
increment-pc
increment-pc
]
]
] [prin "ERROR: Unknown 0xEXXX OPCODE:" print oc increment-pc]
]
#{F000} [
switch/default (oc and #{00FF}) [
#{0007} [
;;Sets VX to the value of the delay timer.
vprint [{------------------------>Set V[} get-x oc {:} (get-timer-value delay-timer)]
set-vx oc (get-timer-value delay-timer)
increment-pc
]
#{000A} [
;;A key press is awaited, and then stored in VX.
vprint [{------------------------>Waiting for key press....}]
while [any k: keys] [wait 1]
while [(first k) = 'false] [k: next k]
set-vx oc (index? k)
increment-pc
]
#{0015} [
;;Sets the delay timer to VX.
vprint [{------------------------>Set delay-timer to} get-vx oc]
delay-timer: set-timer [vprint "Delay timer done"] get-vx oc
increment-pc
]
#{0018} [
;;Sets the sound timer to VX.
vprint [{------------------------>Play Sound (unimplemented)}]
sound-timer: set-timer [vprint BEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEP!] get-vx oc
increment-pc
]
#{001E} [
;;Adds VX to I.
m: i
i: i + get-vx oc
vprint [{------------------------>Set i:} i {=} m {+ v[x]=} get-vx oc]
increment-pc
]
#{0029} [
;;Sets I to the location of the sprite for the character in VX. Characters 0-F (in hexadecimal) are represented by a 4x5 font.
i: to-integer get-vx oc
vprint [{------------------------>Set i:} i {to the value of v[} (get-x oc) {] =} to-integer get-vx oc {which is the character} (pick memory to-integer (get-vx oc))]
increment-pc
]
#{0033} [
;; Stores BCD representation of VX at address I, I + 1 and I + 2
m: to-integer get-vx oc
poke memory (i) (x: remainder m 10)
poke memory (i + 1) (((y: remainder m 100) - x) / 10)
poke memory (i + 2) ((m - y) / 100)
vprint [{------------------------>Set BCD at memory[i]:} x {memory[i+1]:} y {memory [i+2]:} (m - y) / 100]
increment-pc
]
#{0055} [
;;Stores V0 to VX in memory starting at address I.
repeat num 16 [
vprint [{------------------------>Set memory[} (i + num) {] =} (pick v num)]
poke memory (i + num) (pick v num) ;; removed
]
increment-pc
]
#{0065} [
;;Fills V0 to VX with values from memory starting at address I.
repeat num 16 [
vprint [{------------------------>Set V[} num {] =} (pick memory (i + num))]
poke v num (pick memory (i + num))
]
increment-pc
]
] [prin "ERROR: Unknown 0xFXXX OPCODE:" print oc increment-pc]
]
] [prin "ERROR: Unknown OPCODE:" print oc increment-pc]
]
update-gfx: does [
draw-face/now screen; gfx-img
;wait 1
]
update-timers: does [
]
emulate-cycle: does [
opcode: fetch-opcode
vprint [{>Fetched opcode:} opcode]
decode-opcode opcode
update-timers
]
]
vprint "Chip 8 Emulator Starting..."
chip8/initialize
vprint "Clearing Timers"
foreach [t code] guie/timers [
clear-timer t
]
vprint "Chip 8 Emulator Halting..."
halt