-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.asm
636 lines (553 loc) · 16.9 KB
/
display.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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
# Credit: Jarrett Billingsley for most of this implementation
.include "convenience.asm"
.include "game.asm"
# Exposed functions
.globl handle_input
.globl input_get_keys
.globl display_update
.globl display_update_and_clear
.globl display_set_pixel
.globl display_get_pixel
.globl display_fill_rect
.globl display_fill_rect_fast
.globl display_draw_text
.globl display_draw_int
.globl display_blit_5x5_trans
.globl display_blit_5x5
.globl display_font_test
# Exposed variables
.globl left_pressed
.globl right_pressed
.globl up_pressed
.globl down_pressed
.globl action_pressed
# MMIO Registers
.eqv DISPLAY_CTRL 0xFFFF0000
.eqv DISPLAY_KEYS 0xFFFF0004
.eqv DISPLAY_BASE 0xFFFF0008
# Display stuff
.eqv DISPLAY_W 64
.eqv DISPLAY_H 64
.eqv DISPLAY_W_SHIFT 6
# LED Colors -1 = transparent
.eqv COLOR_BLACK 0
.eqv COLOR_RED 1
.eqv COLOR_ORANGE 2
.eqv COLOR_YELLOW 3
.eqv COLOR_GREEN 4
.eqv COLOR_BLUE 5
.eqv COLOR_MAGENTA 6
.eqv COLOR_WHITE 7
.eqv COLOR_NONE 0xFF
# Input key flags
.eqv KEY_NONE 0x00
.eqv KEY_UP 0x01
.eqv KEY_DOWN 0x02
.eqv KEY_LEFT 0x04
.eqv KEY_RIGHT 0x08
.eqv KEY_B 0x10
.data
# Key states - Each variable contains the state of each of the keys
left_pressed: .word 0
right_pressed: .word 0
up_pressed: .word 0
down_pressed: .word 0
action_pressed: .word 0
.data
# each character is a 5x5 pixel block, stored row-by-row.
# have a look at the comments on the right to see what each character is.
pat_bang: .byte 0 0 7 0 0 0 0 7 0 0 0 0 7 0 0 0 0 0 0 0 0 0 7 0 0 # !
pat_quote: .byte 0 7 0 7 0 0 7 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # "
pat_pound: .byte 0 7 0 7 0 7 7 7 7 7 0 7 0 7 0 7 7 7 7 7 0 7 0 7 0 # #
pat_dollar: .byte 0 7 7 7 0 7 0 7 0 0 0 7 7 7 0 0 0 7 0 7 0 7 7 7 0 # $
pat_percent:.byte 7 0 0 0 7 0 0 0 7 0 0 0 7 0 0 0 7 0 0 0 7 0 0 0 7 # %
pat_and: .byte 0 7 0 0 0 7 0 7 0 0 0 7 0 0 0 7 0 7 0 7 0 7 0 7 0 # &
pat_apos: .byte 0 0 7 0 0 0 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # '
pat_lpar: .byte 0 0 0 7 0 0 0 7 0 0 0 0 7 0 0 0 0 7 0 0 0 0 0 7 0 # (
pat_rpar: .byte 0 7 0 0 0 0 0 7 0 0 0 0 7 0 0 0 0 7 0 0 0 7 0 0 0 # )
pat_star: .byte 0 0 7 0 0 7 0 7 0 7 0 7 7 7 0 0 7 0 7 0 7 0 0 0 7 # *
pat_plus: .byte 0 0 0 0 0 0 0 7 0 0 0 7 7 7 0 0 0 7 0 0 0 0 0 0 0 # +
pat_comma: .byte 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 7 0 0 0 0 # ,
pat_dash: .byte 0 0 0 0 0 0 0 0 0 0 0 7 7 7 0 0 0 0 0 0 0 0 0 0 0 # -
pat_dot: .byte 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 # .
pat_fsl: .byte 0 0 0 0 7 0 0 0 7 0 0 0 7 0 0 0 7 0 0 0 7 0 0 0 0 # /
pat_colon: .byte 0 0 0 0 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8: .byte 0 7 7 7 0 7 0 0 0 7 0 7 7 7 0 7 0 0 0 7 0 7 7 7 0
pat_9: .byte 0 7 7 7 0 7 0 0 0 7 0 7 7 7 7 0 0 0 0 7 0 7 7 7 0
# start at ASCII 32 since anything below that is unprintable
# a 0 means NULL i.e. unprintable character
ASCII_patterns: .word
0 pat_bang pat_quote pat_pound pat_dollar pat_percent pat_and pat_apos
pat_lpar pat_rpar pat_star pat_plus pat_comma pat_dash pat_dot pat_fsl
# overlapping arrays!
Digit_patterns: .word
pat_0 pat_1 pat_2 pat_3 pat_4 pat_5 pat_6 pat_7
pat_8 pat_9 pat_colon pat_semi pat_lt pat_eq pat_gt pat_ques
pat_at pat_A pat_B pat_C pat_D pat_E pat_F pat_G
pat_H pat_I pat_J pat_K pat_L pat_M pat_N pat_O
pat_P pat_Q pat_R pat_S pat_T pat_U pat_V pat_W
pat_X pat_Y pat_Z pat_lsq pat_bsl pat_rsq pat_caret pat_under
pat_back pat_A pat_B pat_C pat_D pat_E pat_F pat_G
pat_H pat_I pat_J pat_K pat_L pat_M pat_N pat_O
pat_P pat_Q pat_R pat_S pat_T pat_U pat_V pat_W
pat_X pat_Y pat_Z pat_lbra pat_or pat_rbra pat_tilde 0
.text
# Input Handling Function
# -----------------------------------------------------
# handle_input()
# Sets the variable contents according with button states.
handle_input:
enter
# Get the key state memory
jal input_get_keys
move t1, v0
# Check for key states
and t2, t1, 0x1
sw t2, up_pressed
srl t1, t1, 1
and t2, t1, 0x1
sw t2, down_pressed
srl t1, t1, 1
and t2, t1, 0x1
sw t2, left_pressed
srl t1, t1, 1
and t2, t1, 0x1
sw t2, right_pressed
srl t1, t1, 1
and t2, t1, 0x1
sw t2, action_pressed
move v0, t2
leave
# --------------------------------------------------------------------------------------------------
# returns a bitwise OR of the above key constants, indicating which keys are being held down.
input_get_keys:
lw v0, DISPLAY_KEYS
jr ra
# --------------------------------------------------------------------------------------------------
# copies the color data from display RAM onto the screen.
display_update:
sw zero, DISPLAY_CTRL
jr ra
# --------------------------------------------------------------------------------------------------
# copies the color data from display RAM onto the screen, and then clears display RAM.
# does not clear the display, only the RAM so you can draw a new frame from scratch!
display_update_and_clear:
li t0, 1
sw t0, DISPLAY_CTRL
jr ra
# --------------------------------------------------------------------------------------------------
# void display_set_pixel(int x, int y, int color)
# sets the LED at (x,y) to color
# a0 is x,
# a1 is y,
# a2 is the color (use one of the constants above)
# returns: none
display_set_pixel:
sll t0, a1, DISPLAY_W_SHIFT
add t0, t0, a0
add t0, t0, DISPLAY_BASE
sb a2, (t0)
jr ra
# --------------------------------------------------------------------------------------------------
# void display_get_pixel(int x, int y)
# gets the LED value at (x,y)
# a0 is x,
# a1 is y,
# returns: none
display_get_pixel:
sll t0, a1, DISPLAY_W_SHIFT
add t0, t0, a0
add t0, t0, DISPLAY_BASE
sb a2, (t0)
jr ra
jr ra
# --------------------------------------------------------------------------------------------------
# fills a rectangle of pixels with a given color.
# there are FIVE arguments, and I was naughty and used 'v1' as a "fifth argument register."
# this is technically bad practice. sue me.
# arguments:
# a0 = top-left corner x
# a1 = top-left corner y
# a2 = width
# a3 = height
# v1 = color (use one of the constants above)
display_fill_rect:
# turn w/h into x2/y2
add a2, a2, a0
add a3, a3, a1
# turn y1/y2 into addresses
li t0, DISPLAY_BASE
sll a1, a1, DISPLAY_W_SHIFT
add a1, a1, t0
add a1, a1, a0
sll a3, a3, DISPLAY_W_SHIFT
add a3, a3, t0
move t0, a1
_fill_loop_y:
move t1, t0
move t2, a0
_fill_loop_x:
sb v1, (t1)
addi t1, t1, 1
addi t2, t2, 1
blt t2, a2, _fill_loop_x
addi t0, t0, DISPLAY_W
blt t0, a3, _fill_loop_y
jr ra
# --------------------------------------------------------------------------------------------------
# exactly the same as display_fill_rect, but works faster for rectangles whose width and X coord
# are a multiple of 4.
# IF X IS NOT A MULTIPLE OF 4, IT WILL CRASH.
# IF WIDTH IS NOT A MULTIPLE OF 4, IT WILL DO WEIRD THINGS.
# arguments:
# same as display_fill_rect.
display_fill_rect_fast:
# duplicate color across v1
and v1, v1, 0xFF
mul v1, v1, 0x01010101
# a2 = x2
add a2, a2, a0
# a3 = y2
add a3, a3, a1
# t0 = display base address
li t0, DISPLAY_BASE
# a1 = start address
sll a1, a1, DISPLAY_W_SHIFT
add a1, a1, t0
add a1, a1, a0
# a3 = end address
sll a3, a3, DISPLAY_W_SHIFT
add a3, a3, t0
# t0 = current row's start address
move t0, a1
_fast_fill_loop_y:
move t1, t0 # t1 = current address
move t2, a0 # t2 = current x
_fast_fill_loop_x:
sw v1, (t1)
addi t1, t1, 4
addi t2, t2, 4
blt t2, a2, _fast_fill_loop_x
addi t0, t0, DISPLAY_W
blt t0, a3, _fast_fill_loop_y
jr ra
# --------------------------------------------------------------------------------------------------
# draws a string of text (using the font data at the top of the file)
# a0 = top-left x
# a1 = top-left y
# a2 = pointer to string to print
display_draw_text:
sub sp, sp, 16
sw ra, 0(sp)
sw s0, 4(sp)
sw s1, 8(sp)
sw s2, 12(sp)
move s0, a0
move s1, a1
move s2, a2
_draw_text_loop:
lbu t0, (s2)
beqz t0, _draw_text_exit
ble t0, 32, _draw_text_next
bge t0, 127, _draw_text_next
sub t0, t0, 32
la t1, ASCII_patterns
sll t0, t0, 2
add t0, t0, t1
lw a2, (t0)
beqz a2, _draw_text_next
move a0, s0
move a1, s1
jal display_blit_5x5
_draw_text_next:
add s0, s0, 6
inc s2
b _draw_text_loop
_draw_text_exit:
lw ra, 0(sp)
lw s0, 4(sp)
lw s1, 8(sp)
lw s2, 12(sp)
add sp, sp, 16
jr ra
# --------------------------------------------------------------------------------------------------
# draws a textual representation of an int.
# a0 = top-left x,
# a1 = top-left y
# a2 = integer to display (can be negative)
display_draw_int:
sub sp, sp, 20
sw ra, 0(sp)
sw s0, 4(sp) # current x
sw s1, 8(sp) # y
sw s2, 12(sp) # remaining digits to draw
sw s3, 16(sp) # radix (1, 10, 100 etc)
move s0, a0
move s1, a1
move s2, a2
li s3, 1
bgez s2, _draw_int_determine_length
# if it's negative, make it positive and draw a minus sign
neg s2, s2
move a0, s0
move a1, s1
la a2, pat_dash
jal display_blit_5x5
add s0, s0, 6
# determine the number of digits needed by multiplying radix
# by 10 until the radix no longer divides into the number
_draw_int_determine_length:
move t0, s3
div t1, s2, t0
blt t1, 10, _draw_int_loop
mul s3, s3, 10
b _draw_int_determine_length
_draw_int_loop:
# extract and strip off top digit
div s2, s3
mfhi s2 # keep lower digits in s2
mflo a2 # print top digit
# get digit pattern address
la t0, Digit_patterns
sll a2, a2, 2
add a2, a2, t0
lw a2, (a2)
move a0, s0
move a1, s1
jal display_blit_5x5
# scoot over, decrease radix until it's 0
add s0, s0, 6
div s3, s3, 10
bnez s3, _draw_int_loop
_draw_int_exit:
lw ra, 0(sp)
lw s0, 4(sp)
lw s1, 8(sp)
lw s2, 12(sp)
lw s3, 16(sp)
add sp, sp, 20
jr ra
# --------------------------------------------------------------------------------------------------
# quickly draw a 5x5-pixel pattern to the display. it can have transparent
# pixels; those with COLOR_NONE will not change the display. This way you can
# have "holes" in your images.
# a0 = top-left x
# a1 = top-left y
# a2 = pointer to pattern (an array of 25 bytes stored row-by-row)
display_blit_5x5_trans:
sll a1, a1, DISPLAY_W_SHIFT
add a1, a1, DISPLAY_BASE
add a1, a1, a0
lb t0, 0(a2)
bltz t0, _blitA
sb t0, 0(a1)
_blitA: lb t0, 1(a2)
bltz t0, _blitB
sb t0, 1(a1)
_blitB: lb t0, 2(a2)
bltz t0, _blitC
sb t0, 2(a1)
_blitC: lb t0, 3(a2)
bltz t0, _blitD
sb t0, 3(a1)
_blitD: lb t0, 4(a2)
bltz t0, _blitE
sb t0, 4(a1)
_blitE: lb t0, 5(a2)
bltz t0, _blitF
sb t0, 64(a1)
_blitF: lb t0, 6(a2)
bltz t0, _blitG
sb t0, 65(a1)
_blitG: lb t0, 7(a2)
bltz t0, _blitH
sb t0, 66(a1)
_blitH: lb t0, 8(a2)
bltz t0, _blitI
sb t0, 67(a1)
_blitI: lb t0, 9(a2)
bltz t0, _blitJ
sb t0, 68(a1)
_blitJ: lb t0, 10(a2)
bltz t0, _blitK
sb t0, 128(a1)
_blitK: lb t0, 11(a2)
bltz t0, _blitL
sb t0, 129(a1)
_blitL: lb t0, 12(a2)
bltz t0, _blitM
sb t0, 130(a1)
_blitM: lb t0, 13(a2)
bltz t0, _blitN
sb t0, 131(a1)
_blitN: lb t0, 14(a2)
bltz t0, _blitO
sb t0, 132(a1)
_blitO: lb t0, 15(a2)
bltz t0, _blitP
sb t0, 192(a1)
_blitP: lb t0, 16(a2)
bltz t0, _blitQ
sb t0, 193(a1)
_blitQ: lb t0, 17(a2)
bltz t0, _blitR
sb t0, 194(a1)
_blitR: lb t0, 18(a2)
bltz t0, _blitS
sb t0, 195(a1)
_blitS: lb t0, 19(a2)
bltz t0, _blitT
sb t0, 196(a1)
_blitT: lb t0, 20(a2)
bltz t0, _blitU
sb t0, 256(a1)
_blitU: lb t0, 21(a2)
bltz t0, _blitV
sb t0, 257(a1)
_blitV: lb t0, 22(a2)
bltz t0, _blitW
sb t0, 258(a1)
_blitW: lb t0, 23(a2)
bltz t0, _blitX
sb t0, 259(a1)
_blitX: lb t0, 24(a2)
bltz t0, _blit_exit
sb t0, 260(a1)
_blit_exit:
jr ra
# --------------------------------------------------------------------------------------------------
# quickly draw a 5x5-pixel pattern to the display without transparency.
# if it has any COLOR_NONE pixels, the result is undefined.
# a0 = top-left x
# a1 = top-left y
# a2 = pointer to pattern (an array of 25 bytes stored row-by-row)
display_blit_5x5:
sll a1, a1, DISPLAY_W_SHIFT
add a1, a1, DISPLAY_BASE
add a1, a1, a0
lb t0, 0(a2)
sb t0, 0(a1)
lb t0, 1(a2)
sb t0, 1(a1)
lb t0, 2(a2)
sb t0, 2(a1)
lb t0, 3(a2)
sb t0, 3(a1)
lb t0, 4(a2)
sb t0, 4(a1)
lb t0, 5(a2)
sb t0, 64(a1)
lb t0, 6(a2)
sb t0, 65(a1)
lb t0, 7(a2)
sb t0, 66(a1)
lb t0, 8(a2)
sb t0, 67(a1)
lb t0, 9(a2)
sb t0, 68(a1)
lb t0, 10(a2)
sb t0, 128(a1)
lb t0, 11(a2)
sb t0, 129(a1)
lb t0, 12(a2)
sb t0, 130(a1)
lb t0, 13(a2)
sb t0, 131(a1)
lb t0, 14(a2)
sb t0, 132(a1)
lb t0, 15(a2)
sb t0, 192(a1)
lb t0, 16(a2)
sb t0, 193(a1)
lb t0, 17(a2)
sb t0, 194(a1)
lb t0, 18(a2)
sb t0, 195(a1)
lb t0, 19(a2)
sb t0, 196(a1)
lb t0, 20(a2)
sb t0, 256(a1)
lb t0, 21(a2)
sb t0, 257(a1)
lb t0, 22(a2)
sb t0, 258(a1)
lb t0, 23(a2)
sb t0, 259(a1)
lb t0, 24(a2)
sb t0, 260(a1)
jr ra
# --------------------------------------------------------------------------------------------------
# draws all printable characters on the display.
# good for having a look at the characters if you want to change them.
display_font_test:
push ra
push s0
la s0, ASCII_patterns
li s2, 2
_font_test_row:
li s1, 2
_font_test_col:
move a0, s1
move a1, s2
lw a2, (s0)
add s0, s0, 4
beqz a2, _font_test_skip
jal display_blit_5x5
_font_test_skip:
add s1, s1, 6
blt s1, 60, _font_test_col
add s2, s2, 6
blt s2, 60, _font_test_row
pop s0
pop ra
jr ra