-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdelay_timer_test.8o
74 lines (51 loc) · 1.56 KB
/
delay_timer_test.8o
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
# CHIP-8 Delay Timer Test
# Copyright 2015 Matthew Mikolay
# See github.com/mattmikolay/chip-8 or mattmik.com for more info.
# Note: Don't use v0, v1, or v2, as they are needed for printing digits
:alias x v3 # x coordinate of current digit
:alias y v4 # y coordinate of current digit
:alias current_key v5 # Key pressed by user
:alias duration v6 # Duration of time entered by user
: main
y := 0
loop
loop
print_time
current_key := key
# If user pressed 2 key, increment duration
if current_key == 0x02 then
duration += 0x01
# If user pressed 8 key, decrement duration
if current_key == 0x08 then
duration += 0xFF
# Continue accepting user input until the 5 key is pressed
if current_key != 0x05 then
again
# Begin a countdown from the time entered by the user
delay := duration
loop
duration := delay
print_time
if duration != 0x00 then
again
again
: print_time
clear
# Store BCD of current time in program memory
i := program_end
bcd duration
load v2
x := 0
# Print hundreds digit
i := hex v0
sprite x y 0x05
x += 5
# Print tens digit
i := hex v1
sprite x y 0x05
x += 5
# Print ones digit
i := hex v2
sprite x y 0x05
return
: program_end