-
Notifications
You must be signed in to change notification settings - Fork 0
/
bonus.asm
81 lines (74 loc) · 1.19 KB
/
bonus.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
;Airaki! - FSE 2014
;Released under the GPL V3, see LICENSE.TXT
calc_bonus:
;See if TIMEEN is < 330 seconds
xor a
ld (SCOREBONUS),a
ld (SCOREBONUS+1),a
ld (SCOREBONUS+2),a
ld a,(TIMEEN_SEC) ;LSB
ld l,a
ld a,(TIMEEN_SEC+1) ;MSB
ld h,a
cp 2
ret nc ;>= $200
or a
jr z,+
ld a,l
cp $4A
ret nc ;>= $x4A
+:
;Do 330-TIMEEN
ld a,$4A
sub l
ld l,a
ld a,$1
sbc h
ld h,a
;16bit *8
sla l
rl h
sla l
rl h
sla l
rl h
;Hex to BCD
ld bc,16*256
ld de,0
-:
add hl,hl
ld a,e
adc a
daa
ld e,a
ld a,d
adc a
daa
ld d,a
ld a,c
adc a
daa
ld c,a
dec b
jr nz,-
ld a,e
ld (SCOREBONUS),a
ld a,d
ld (SCOREBONUS+1),a
xor a
ld (SCOREBONUS+2),a
;Add to score
ld a,(SCOREEN) ;LSB
add e
daa
ld (SCOREEN),a
ld a,(SCOREEN+1)
adc d
daa
ld (SCOREEN+1),a
ld a,(SCOREEN+2) ;MSB
ld d,0
adc d
daa
ld (SCOREEN+2),a
ret