-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.asm
116 lines (104 loc) · 1.86 KB
/
time.asm
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
;Airaki! - FSE 2014
;Released under the GPL V3, see LICENSE.TXT
inc_time:
ld a,(TIME_FRAME)
inc a
ld (TIME_FRAME),a
cp 60
jr nz,++
xor a
ld (TIME_FRAME),a
call inc_timeen
ld a,(TIME_SEC) ;Inc units seconds
inc a
ld (TIME_SEC),a
and $F
cp $A
jr nz,+
ld a,(TIME_SEC)
and $F0
add $10 ;Inc tens seconds
ld (TIME_SEC),a
and $F0
cp $60
jr nz,+
xor a
ld (TIME_SEC),a
ld a,(TIME_MIN) ;Inc units minutes
inc a
ld (TIME_MIN),a
and $F
cp $A
jr nz,+
ld a,(TIME_MIN)
and $F0
add $10 ;Inc tens minutes
ld (TIME_MIN),a
+:
call disp_time
++:
ld a,(TIME_SEC)
cp $59
ret nz
ld a,(TIME_MIN) ;Game over after 99:99
cp $99
ret nz
jp pdeath
inc_timeen:
ld a,(TIMEEN_SEC) ;LSB
ld l,a
ld a,(TIMEEN_SEC+1) ;MSB
ld h,a
cp $FF
jr nz,+
ld a,l
cp $FF
ret z
+:
inc hl
ld a,l
ld (TIMEEN_SEC),a ;LSB
ld a,h
ld (TIMEEN_SEC+1),a ;MSB
ret
;HL = VRAM, DE = min/sec, B = ASCII index
disp_time:
ldh a,($FF)
push af
xor a
ldh ($FF),a
ld hl,$9C00+1
ld b,$D0
ld a,(TIME_MIN)
ld d,a
ld a,(TIME_SEC)
ld e,a
ld a,d
swap a
and $F
add b
call wait_write
ldi (hl),a
ld a,d
and $F
add b
call wait_write
ldi (hl),a
ld a,':'-48
add b
call wait_write
ldi (hl),a
ld a,e
swap a
and $F
add b
call wait_write
ldi (hl),a
ld a,e
and $F
add b
call wait_write
ldi (hl),a
pop af
ldh ($FF),a
ret