-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatusBar.s
More file actions
276 lines (208 loc) · 3.75 KB
/
statusBar.s
File metadata and controls
276 lines (208 loc) · 3.75 KB
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
// draw the status bar at the top of the screen
.encoding "screencode_mixed"
player_status_display:
.text "LEVEL "
player_status_level:
.text "0000 "
//.text "F3:SKIP "
player_status_seconds:
.text "0000"
.text ":"
player_status_second_tenths:
.text "00 "
player_dots:
.text " DOTS "
player_status_dots:
.text "0000 "
player_tries:
.text "TRIES "
player_status_tries:
.text "0001"
.text "@"
status_initial_level:
.text "0000"
status_initial_time:
.text "0000:00"
player_last_time:
.text "0000:00@"
player_best_time:
.text "9999:99@"
player_last_is_best:
.byte $0
StatusResetTime: {
phy
ldy #6
!:
lda player_status_seconds,y
sta player_last_time,y
lda status_initial_time,y
sta player_status_seconds,y
dey
bpl !-
// check if a best time
lda #<player_last_time
sta address_low
lda #>player_last_time
sta address_high
lda #<player_best_time
sta address_low_2
lda #>player_best_time
sta address_high_2
jsr CompareTimes
sta player_last_is_best
cmp #1
bne reset_time_done
// its a best time, copy last time into best time
ldy #6
!:
lda player_last_time,y
sta player_best_time,y
dey
bpl !-
reset_time_done:
ply
rts
}
StatusIncreaseTime: {
phy
lda #<player_status_second_tenths
sta status_address_low
lda #>player_status_second_tenths
sta status_address_high
jsr StatusIncrease2DigitNumber
bcc !+
lda #<player_status_seconds
sta status_address_low
lda #>player_status_seconds
sta status_address_high
jsr StatusIncreaseNumber
!:
ply
rts
}
// time1 in address_low
// time2 in address_high
CompareTimes: {
phy
ldy #0
!:
lda (address_low),y
cmp (address_low_2),y
// lda player_last_time,y
// cmp player_best_time,y
beq next_digit
bmi time2_bigger
bpl time1_bigger
next_digit:
iny
cpy #07
bne !-
time1_bigger:
lda #0
ply
rts
time2_bigger:
lda #1
ply
rts
}
status_increment:
.byte 0,0
status_2_digit_increment:
.byte 0,1
status_tenth_increment:
.byte 0,2
StatusResetLevel: {
phy
ldy #3
!:
lda status_initial_level,y
sta player_status_level,y
dey
bpl !-
ply
rts
}
StatusIncreaseLevel: {
lda #<player_status_level
sta status_address_low
lda #>player_status_level
sta status_address_high
jsr StatusIncreaseNumber
rts
}
StatusIncreaseDots: {
lda #<player_status_dots
sta status_address_low
lda #>player_status_dots
sta status_address_high
jsr StatusIncreaseNumber
rts
}
StatusIncreaseTries: {
lda #<player_status_tries
sta status_address_low
lda #>player_status_tries
sta status_address_high
jsr StatusIncreaseNumber
rts
}
StatusIncrease2DigitNumber: {
// save y
phy
// 4 digits, loop over digits starting with last digit first
ldy #1
clc
increase_number_loop:
lda (status_address_low),y
adc status_tenth_increment,y
// check if gone over 9 ($39 is screencode for 9 in mixed screencode mode)
cmp #$3a
bcc store_number
// gone over 9, so subtract 10
// carry should be set
sbc #10
store_number:
// lda #136 //TILE_9
sta (status_address_low),y
dey
bpl increase_number_loop
// restore y
ply
rts
}
StatusIncreaseNumber: {
// save y
phy
// 4 digits, loop over digits starting with last digit first
ldy #3
clc
increase_number_loop:
lda (status_address_low),y
adc status_increment,y
// check if gone over 9 ($39 is screencode for 9 in mixed screencode mode)
cmp #$3a
bcc store_number
// gone over 9, so subtract 10
// carry should be set
sbc #10
store_number:
// lda #136 //TILE_9
sta (status_address_low),y
dey
bpl increase_number_loop
// restore y
ply
rts
}
DrawStatus: {
lda #0
sta row
sta col
lda #<player_status_display
sta text_address_low
lda #>player_status_display
sta text_address_high
jsr DrawText
rts
}