-
Notifications
You must be signed in to change notification settings - Fork 3
/
graphics.asm
495 lines (442 loc) · 8.94 KB
/
graphics.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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
drawChrome:
pcall(clearBuffer)
; Castle top
xor a
ld l, 2
pcall(setPixel)
kld(hl, castleTopSprite)
ld b, 12
ld de, 0x0100
_: ld a, 8
push bc
ld b, 3
pcall(putSpriteOR)
pop bc
add a, d
ld d, a
djnz -_
kld(hl, hotkeyLeftSprite)
ld b, 8
ld de, 0x0038
pcall(putSpriteOR)
kld(hl, hotkeyRightSprite)
ld de, 0x5838
pcall(putSpriteOR)
ld hl, 0x000A
ld de, 0x5F0A
pcall(drawLine)
drawBattery:
pcall(getBatteryLevel)
ld a, b
or a
jr z, batteryCritical
rlca \ rlca \ and 3 \ inc a ; (getBatteryLevel+1/64)+1
ld b, a
xor a
cp b
jr z, ++_
ld a, 26
_: ld l, 60
pcall(setPixel)
inc l
pcall(setPixel)
inc a
djnz -_
batteryNormal:
kld(hl, batteryIndicatorSprite)
ld b, 4
ld de, 0x193B
pcall(putSpriteOR)
jr _
batteryCritical:
kld(hl, batteryCriticalIndicatorSprite)
ld b, 4
ld de, 0x193B
pcall(putSpriteOR)
_: ; Fallthrough to drawClock
; TODO: 24 hour time in /etc/locale.conf
drawClock:
; Get time
push ix
push de
push bc
push hl
; Clear away old time
ld bc, (6 << 8) + (96 - 64)
ld e, 69
ld l, 4
pcall(rectAND)
; Get and draw new time
pcall(getTime)
jr nz, .skipTime
ld de, (64 << 8) | 4
ld a, b
cp 12
jr c, _
sub a, 12
_: or a
jr nz, _
ld a, 12
_: kcall(drawDecAPadded)
ld a, ':'
pcall(drawChar)
ld a, c
kcall(drawDecAPadded)
ld a, ' '
pcall(drawChar)
ld a, b
cp 12
jr nc, _
ld a, 'A'
jr ++_
_: ld a, 'P'
_: pcall(drawChar)
ld a, 'M'
pcall(drawChar)
.skipTime:
pop hl
pop bc
pop de
pop ix
ret
; From core/settings
drawDecAPadded:
cp 10
jr nc, .noPadding
; do padding
push af
ld a, '0'
pcall(drawChar)
pop af
.noPadding:
pcall(drawDecA)
ret
drawHome:
kld(hl, hotkeyPlusSprite)
ld b, 5
ld de, 0x013A
pcall(putSpriteOR)
kld(hl, hotkeyArrowRightSprite)
ld de, 0x593A
pcall(putSpriteOR)
kld(hl, menuArrowSprite)
ld b, 3
ld de, 0x353B
pcall(putSpriteOR)
ld de, 0x093A
kld(hl, appsString)
pcall(drawStr)
ld de, 0x253A
kld(hl, menuString)
pcall(drawStr)
ld de, 0x3C3A
kld(hl, runningString)
pcall(drawStr)
ret
drawPinnedApps:
push de
ld a, d
push af
; Clear away old icons
ld e, 0 \ ld l, 11 \ ld c, 96 \ ld b, 45
pcall(rectAND)
ld e, 0 \ ld l, 3 \ ld c, 69 \ ld b, 7
pcall(rectAND)
ld hl, 0x0021
ld de, 0x5F21
pcall(drawLine)
; First row
ld de, 0x020E
ld bc, 0x0A00
kld(ix, pinned_apps)
.loop:
; Check to see if this item is selected
pop af \ push af
cp c \ kcall(z, drawSelectionRectangle) \ inc c
push bc
push de
; Load icon
ld l, (ix + 4)
ld h, (ix + 5)
ld bc, 0
pcall(cpHLBC)
jr z, .emptyPin
ld bc, 10
add hl, bc
ld bc, 6
add ix, bc
pop de
.drawIcon:
ld b, 16
pcall(putSprite16OR)
ld a, 19
add a, d \ ld d, a
cp 97
jr nz, _
; Wrap
ld de, 0x0225
_: pop bc
djnz .loop
pop af
pop de
ret
.emptyPin:
kld(hl, emptySlotIcon)
ld bc, 6
add ix, bc
pop de
jr .drawIcon
drawSelectionRectangle:
push de \ push hl \ push bc \ push af
; Find name string
ld l, (ix + 2)
ld h, (ix + 3)
xor a
cp l
jr nz, _
cp h
jr nz, _
kcall(drawEmptySlotName)
jr ++_
_: kcall(drawSelectedName)
_: ld a, e ; Get x
sub 2
ld l, a
ld a, d ; Get y
sub 2
ld e, a
ld bc, 0x1414
push de \ push hl \ push bc
pcall(rectOR)
pop bc \ pop hl \ pop de
inc e \ inc l \ dec b \ dec b \ dec c \ dec c
pcall(rectXOR)
pop af \ pop bc \ pop hl \ pop de
ret
drawSelectedName:
; Draw name string
push de
ld de, 0x0104
pcall(drawStr)
pop de
ret
drawEmptySlotName:
push de
kld(hl, naString)
ld de, 0x0104
pcall(drawStr)
pop de
ret
drawPowerMenu:
ld e, 27
ld l, 36
ld c, 67-24
ld b, 56-35
pcall(rectOR)
ld e, 28
ld l, 37
ld c, 66-25
ld b, 55-36
pcall(rectXOR)
ld de, 0x2339
ld hl, 0x233F
pcall(drawLine)
ld de, 0x3B39
ld hl, 0x3B3F
pcall(drawLine)
ld e, 36
ld l, 56
ld c, 23
ld b, 1
pcall(rectXOR)
kld(hl, sleepString)
ld de, 0x2126
pcall(drawStr)
kld(hl, shutdownString)
ld de, 0x212C
pcall(drawStr)
kld(hl, restartString)
ld de, 0x2132
pcall(drawStr)
kld(hl, menuArrowSprite)
ld de, 0x353B
ld b, 3
pcall(putSpriteXOR)
kld(hl, menuArrowSpriteFlip)
ld de, 0x353B
ld b, 3
pcall(putSpriteOR)
kld(hl, selectionIndicatorSprite)
ld de, 0x1D26
ld b, 5
pcall(putSpriteOR)
ret
drawAppsChrome:
pcall(clearBuffer)
; Castle top
xor a
ld l, 2
pcall(setPixel)
kld(hl, castleTopSprite)
ld b, 12
ld de, 0x0100
_: ld a, 8
push bc
ld b, 3
pcall(putSpriteOR)
pop bc
add a, d
ld d, a
djnz -_
kld(hl, hotkeyLeftSprite)
ld b, 8
ld de, 0x0038
pcall(putSpriteOR)
ld hl, 0x000A
ld de, 0x5F0A
pcall(drawLine)
ret
drawAppsHome:
kld(hl, hotkeyArrowLeftSprite)
ld b, 5
ld de, 0x003A
pcall(putSpriteOR)
ld de, 0x093A
kld(hl, backString)
pcall(drawStr)
ld de, 0x0104
kld(hl, applistString)
pcall(drawStr)
ret
castleTopSprite: ; 8x3
.db 0b11110000
.db 0b10010000
.db 0b10011111
hotkeyLeftSprite: ; 8x8
.db 0b01111100
.db 0b10000010
.db 0b00000001
.db 0b00000001
.db 0b00000001
.db 0b00000001
.db 0b00000001
.db 0b10000010
hotkeyRightSprite: ; 8x8
.db 0b00111110
.db 0b01000001
.db 0b10000000
.db 0b10000000
.db 0b10000000
.db 0b10000000
.db 0b10000000
.db 0b01000001
hotkeyPlusSprite: ; 8x5
.db 0b00100000
.db 0b00100000
.db 0b11111000
.db 0b00100000
.db 0b00100000
hotkeyArrowLeftSprite: ; 8x5
.db 0b0010000
.db 0b0100000
.db 0b1111100
.db 0b0100000
.db 0b0010000
hotkeyArrowRightSprite: ; 8x5
.db 0b0010000
.db 0b0001000
.db 0b1111100
.db 0b0001000
.db 0b0010000
hotkeyArrowUpSprite: ; 8x5
.db 0b0010000
.db 0b0111000
.db 0b1010100
.db 0b0010000
.db 0b0010000
menuArrowSprite: ; 8x3
.db 0b00100000
.db 0b01110000
.db 0b11111000
menuArrowSpriteFlip: ; 8x3
.db 0b11111000
.db 0b01110000
.db 0b00100000
batteryIndicatorSprite: ; 8x4
.db 0b11111100
.db 0b10000110
.db 0b10000110
.db 0b11111100
batteryCriticalIndicatorSprite: ; 8x4
.db 0b10101100
.db 0b10100110
.db 0b10000110
.db 0b10101100
selectionIndicatorSprite: ; 8x5
.db 0b10000000
.db 0b11000000
.db 0b11100000
.db 0b11000000
.db 0b10000000
defaultIconSprite: ; 16x16
.db 0b01111111, 0b11111110
.db 0b11111111, 0b11111111
.db 0b11111111, 0b11111111
.db 0b10000000, 0b00000001
.db 0b10111111, 0b10111101
.db 0b10100000, 0b10111101
.db 0b10100000, 0b10111101
.db 0b10111111, 0b10111101
.db 0b10000000, 0b00111101
.db 0b10111100, 0b00111101
.db 0b10000000, 0b00111101
.db 0b10111111, 0b00111101
.db 0b10000000, 0b00111101
.db 0b10111110, 0b00111101
.db 0b10000000, 0b00000001
.db 0b11111111, 0b11111111
emptySlotIcon: ; 16x16
.db 0b10101010, 0b10101011
.db 0b00000000, 0b00000001
.db 0b10101000, 0b00000000
.db 0b00010000, 0b00000001
.db 0b10101000, 0b00000000
.db 0b00000000, 0b00000001
.db 0b10000000, 0b00000000
.db 0b00000000, 0b00000001
.db 0b10000000, 0b00000000
.db 0b00000000, 0b00000001
.db 0b10000000, 0b00000000
.db 0b00000000, 0b00000001
.db 0b10000000, 0b00000000
.db 0b00000000, 0b00000001
.db 0b10000000, 0b00000000
.db 0b11010101, 0b01010101
appsString:
.db "Apps", 0
moreString:
.db "More", 0
runningString:
.db "Running", 0
menuString:
.db "Menu", 0
backString:
.db "Back", 0
optionsString:
.db "Options", 0
addToCastleString:
.db "Add to Castle", 0
removeFromCastleString:
.db "Remove from Castle", 0
sleepString:
.db "Sleep", 0
shutdownString:
.db "Shut Down", 0
restartString:
.db "Restart", 0
noProgramsInstalledString:
.db "No programs installed!", 0
naString:
.db "[n/a]", 0
applistString:
.db "All Applications", 0