-
Notifications
You must be signed in to change notification settings - Fork 0
/
score.s
126 lines (96 loc) · 1.81 KB
/
score.s
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
numericScore: defb $00, $00
numericHighScore: defb $00, $00
drawScore:
ld a,2
call 5633
ld de,stringScore
ld bc,eostr-stringScore
call 8252
updateScore:
ld hl, (numericScore)
inc hl
ld (numericScore), hl
ld a,2
call 5633
ld de,score
ld bc,eostr-score
call 8252
ld hl,score+7
ld b,1
call userScore
endScoreUpdate:
ret
userScore:
ld a,(hl)
add a,b
ld (hl),a
cp 58
ret c
sub 10
ld (hl),a
userScoreNextPlace:
dec hl
inc (hl)
ld a,(hl)
cp 58
ret c
sub 10
ld (hl),a
jp userScoreNextPlace
resetScore:
ld hl, score + 3
ld (hl), 48
inc hl
ld (hl), 48
inc hl
ld (hl), 48
inc hl
ld (hl), 48
inc hl
ld (hl), 48
inc hl
ld hl, $0000
ld (numericScore), hl
ret
setHighScore:
ld hl, (numericScore)
ex de, hl ; de = numericScore
ld hl, (numericHighScore) ; hl = numericHighScore
sbc hl, de ; numericHighScore - numericScore
; if c flag is set, then numericScore is new high score
jr nc, noNewHS
noUpperBit:
ld (numericHighScore), de
ld hl, score + 7
ld a, (hl)
ld hl, highScore + 7
ld (hl), a
ld hl, score + 6
ld a, (hl)
ld hl, highScore + 6
ld (hl), a
ld hl, score + 5
ld a, (hl)
ld hl, highScore + 5
ld (hl), a
ld hl, score + 4
ld a, (hl)
ld hl, highScore + 4
ld (hl), a
ld hl, score + 3
ld a, (hl)
ld hl, highScore + 3
ld (hl), a
ld a,2
call 5633
ld de,score
ld bc,eostr-score
call 8252
noNewHS:
ret
;Theres prob a more effecient way to do this
stringScore: defb 22,1,1,'scr:'
score: defb 22,1,5,'00000'
stringHighScr: defb 22,1,20,'hScr:'
highScore: defb 22,1,25,'00000'
eostr: equ $