-
Notifications
You must be signed in to change notification settings - Fork 0
/
doodlejump.s
1033 lines (967 loc) · 25.2 KB
/
doodlejump.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
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
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#####################################################################
#
# CSC258H5S Fall 2020 Assembly Final Project
# University of Toronto, St. George
#
# Student: Jiayi Zeng, Student Number: 1004711564
#
# Bitmap Display Configuration:
# - Unit width in pixels: 8
# - Unit height in pixels: 8
# - Display width in pixels: 256
# - Display height in pixels: 256
# - Base Address for Display: 0x10008000 ($gp)
#
# Which milestone is reached in this submission?
# - Milestone 5
#
# Which approved additional features have been implemented?
# (See the assignment handout for the list of additional features)
# 1. Fancier graphics
# 2. Dynamic on-screen notifications: print WOW when score reaches 5 and print Awesome wehen score reaches 10.
# 3. Shields
# ... (add more if necessary)
#
# Any additional information that the TA needs to know:
# - (write here, if any)
#
#####################################################################
.data
displayAddress: .word 0x10008000
red: .word 0xff9999
green: .word 0xE5FFCC
purple: .word 0xCCCCFF
score: .word 0 #initial score of player
shield: .word 5 #initial position of shield in unit
platformArray: .space 20 #initialize array of 5 integers to store position of platform
doodler: .word 496 #initial offset of position of doodler
.text
main:
addi $sp, $sp, -4
sw $ra, 0($sp) #store return address into stack
jal redrawscreen
jal platformLocation # calculate new platform location
goUp: lw $t1, purple
addi $sp, $sp, -4
sw $t1, 0($sp) #draw shield with purple
jal drawShield
addi $sp, $sp, 4 #pop argument
jal drawplatform #initialize 5 platform based on platformLocation
lw $t1, green
addi $sp, $sp, -4
sw $t1, 0($sp) #draw Score with green
jal drawScore
addi $sp, $sp, 4 #pop argument
lw $t2, doodler
ble $t2, 0, Terminate #if doodler exceeds top of the screen, terminate program
jal drawdoodler #initialize doodler depend on menmory position
li $v0, 42 #radomize a number
li $a0, 0
li $a1, 928 #randomized number will be in range 0-928
syscall # radomized number stored in $a0
addi $sp, $sp, -4
la $t3, shield
sw $a0, 0($t3)
lw $t1, green
addi $sp, $sp, -4
sw $t1, 0($sp) #draw shield with green
jal drawShield
addi $sp, $sp, 4 #pop argument
jal collision # check collision
lw $t1, 0($sp)
beq $t1, 1 , updateScore
dropagain: jal dropdoodler #doodler drop by one unit
lw $t1, green
addi $sp, $sp, -4
sw $t1, 0($sp) #draw Score with green
jal drawScore
addi $sp, $sp, 4 #pop argument
jal drawplatform #incase some platform loss its color
jal collision # check collision
lw $t1, 0($sp)
beq $t1, 1, updateScore
lw $t2, doodler
blt $t2, 1024, dropagain
Terminate: jal redrawscreen
jal drawG
jal drawA
jal drawM
jal drawE
jal drawO
jal drawV
jal drawE2
jal drawR
li $v0, 10 # terminate the program gracefully
syscall
updateScore: lw $t1, purple
addi $sp, $sp, -4
sw $t1, 0($sp) #draw Score with black
jal drawScore
addi $sp, $sp, 4 #pop color
la $t9, score
lw $t8, score
addi $t8, $t8, 1
sw $t8, 0($t9)# score plus one
beq $t8, 5, drawwow
beq $t8, 10, drawawesome
backtoscore: j goUp
drawwow: addi $sp, $sp, -4
sw $ra, 0($sp) #store return address into stack
addi $sp, $sp, -4
li $s1, 774
sw $s1, 0($sp)
addi $sp, $sp, -4
lw $s2, green
sw $s2, 0($sp)
jal drawWOW
li $v0, 32 # wait for 1 second
li $a0, 500
syscall
lw $s2, purple
sw $s2, 0($sp)
jal drawWOW
addi $sp, $sp, 4
addi $sp, $sp, 4
lw $ra, 0($sp)
addi $sp, $sp, 4
j backtoscore
drawawesome: addi $sp, $sp, -4
sw $ra, 0($sp) #store return address into stack
addi $sp, $sp, -4
li $s1, 358
sw $s1, 0($sp)
addi $sp, $sp, -4
lw $s2, green
sw $s2, 0($sp)
jal drawAwesome
li $v0, 32 # wait for 1 second
li $a0, 500
syscall
lw $s2, purple
sw $s2, 0($sp)
jal drawAwesome
addi $sp, $sp, 4
addi $sp, $sp, 4
lw $ra, 0($sp)
addi $sp, $sp, 4
j backtoscore
redrawscreen: lw $t3, purple #store black color
li $t4, 1024 #max loop for screen
li $t1, 0 #offset
loop6: sll $t2, $t1, 2 #offset times 4
lw $t0, displayAddress #store base address
add $t0, $t0, $t2 #calculate position
sw $t3, 0($t0) #paint current block by black
addi $t1, $t1, 1
bne $t1, $t4, loop6
jr $ra
platformLocation: li $t1, 5 #loop 5 times
li $t2, 0 #offset
la $t6, platformArray #load array address
loop: li $v0, 42 #radomize a number
li $a0, 0
li $a1, 1024 #randomized number will be in range 0-1024
syscall # radomized number stored in $a0
sll $t5, $t2, 2
add $t6, $t6, $t5 #locate to array where we want to store number in
sw $a0, 0($t6) #store number into array
addi $t2, $t2, 1 #offset add 1
bne $t2, $t1, loop #check if we have 5 numbers already
jr $ra #jump back to caller
drawplatform: li $t5, 4 #t5 stores 4
li $t4, 5 #loop number, loop 5 times
li $t7, 0 #offset for platform array address
la $t6, platformArray #load platformArray address
loop2: sll $t8, $t7, 2 #offset $t7 times 4
add $t6, $t6, $t8 #locate to array where we want to store number in
lw $t3, 0($t6) #load position from array
mul $t3, $t3, $t5 #multiply position number with 4
lw $t1, red #store red color
lw $t0, displayAddress #store base address
add $t0, $t0, $t3 #calculate position
sw $t1, 0($t0) # paint the platform by red
sw $t1, 4($t0)
sw $t1, 8($t0)
sw $t1, 12($t0)
sw $t1, 16($t0)
sw $t1, 20($t0) #the platform has length of 6 unit
addi, $t7, $t7, 1 # increase $t7 by 1
bne, $t7, $t4, loop2 #if not complete 5 loops, continue looping
END: jr $ra#jump back to main
drawdoodler: lw $t3, purple #store black color
lw $t2, green #store green color
lw $t1, red #store red color
lw $t0, displayAddress #store base address
li $t6, 4 # store 4
li $t5, 10 #move up 10 units
loop3: lw $t4, doodler
mul $t4, $t4, $t6 #multiply $t4 with 4
lw $t0, displayAddress #store base address
add $t0, $t0, $t4 #calculate position
sw $t2, 0($t0) # paint the doodler by red
sw $t2, 124($t0)
sw $t2, 128($t0)
sw $t2, 132($t0)
sw $t2, 252($t0)
sw $t2, 256($t0)
sw $t3, 260($t0)
sw $t2, 264($t0)
sw $t2, 268($t0)
sw $t2, 380($t0)
sw $t2, 384($t0)
sw $t2, 388($t0)
sw $t1, 508($t0)
sw $t1, 512($t0)
sw $t1, 516($t0)
#addi $sp, $sp, -4
#sw $ra, 0($sp) #store return address into stack
#jal Scollision
#lw $s1, 0($sp)
#addi $sp, $sp, 4
#bne $s1, 1, nocoli
#sw $t1, 380($t0)
#sw $t1, 384($t0)
#sw $t1, 388($t0)
#lw $ra, 0($sp)
#addi $sp, $sp, 4
nocoli: li $v0, 32 # wait for 1 second
li $a0, 20
syscall
sw $t3, 0($t0) # repaint the screen by black
sw $t3, 124($t0)
sw $t3, 128($t0)
sw $t3, 132($t0)
sw $t3, 252($t0)
sw $t3, 256($t0)
sw $t3, 260($t0)
sw $t3, 264($t0)
sw $t3, 268($t0)
sw $t3, 380($t0)
sw $t3, 384($t0)
sw $t3, 388($t0)
sw $t3, 508($t0)
sw $t3, 512($t0)
sw $t3, 516($t0)
addi $sp, $sp, -4
sw $ra, 0($sp) #store return address into stack
addi $sp, $sp, -4
sw $t0, 0($sp) #store $t0 into stack
addi $sp, $sp, -4
sw $t1, 0($sp) #store $t1 into stack
addi $sp, $sp, -4
sw $t2, 0($sp) #store $t2 into stack
addi $sp, $sp, -4
sw $t3, 0($sp) #store $t3 into stack
addi $sp, $sp, -4
sw $t4, 0($sp) #store $t4 into stack
addi $sp, $sp, -4
sw $t5, 0($sp) #store $t5 into stack
addi $sp, $sp, -4
sw $t6, 0($sp) #store $t6 into stack
jal drawplatform
lw $t6, 0($sp) #load $t6 from stack
addi $sp, $sp, 4
lw $t5, 0($sp) #load $t5 from stack
addi $sp, $sp, 4
lw $t4, 0($sp) #load $t4 from stack
addi $sp, $sp, 4
lw $t3, 0($sp) #load $t3 from stack
addi $sp, $sp, 4
lw $t2, 0($sp) #load $t2 from stack
addi $sp, $sp, 4
lw $t1, 0($sp) #load $t1 from stack
addi $sp, $sp, 4
lw $t0, 0($sp) #load $t0 from stack
addi $sp, $sp, 4
lw $ra, 0($sp) #load return address into stack
addi $sp, $sp, 4
lw $t7, 0xffff0004
beq $t7, 0x6a, respond_j # check if j was pressed
beq $t7, 0x6b, respond_k # check if k was pressed
draw_move: addi $t4, $t4, -128
sra $t4, $t4, 2 #divide $t4 by 4
la $s0, doodler
sw $t4, 0($s0)
addi $t5, $t5, -1
bnez $t5, loop3
jr $ra
respond_j: addi $t4, $t4, -4 # position move one block to left
j draw_move
respond_k: addi $t4, $t4, 4 # position move one block to right
j draw_move
dropdoodler: lw $t3, purple #store black color
lw $t2, green #store green color
lw $t1, red #store red color
li $t6, 4 # store 4
lw $t4, doodler
mul $t4, $t4, $t6 #multiply $t4 with 4
lw $t7, 0xffff0004
beq $t7, 0x6a, respond_j2 # check if j was pressed
beq $t7, 0x6b, respond_k2 # check if k was pressed
draw: addi $t4, $t4, 128
lw $t0, displayAddress #store base address
add $t0, $t0, $t4 #calculate position
sra $t4, $t4, 2 #divide $t4 by 4
la $s0, doodler
sw $t4, 0($s0)
sw $t2, 0($t0) # paint the doodler
sw $t2, 124($t0)
sw $t2, 128($t0)
sw $t2, 132($t0)
sw $t2, 252($t0)
sw $t2, 256($t0)
sw $t3, 260($t0)
sw $t2, 264($t0)
sw $t2, 268($t0)
sw $t2, 380($t0)
sw $t2, 384($t0)
sw $t2, 388($t0)
sw $t1, 508($t0)
sw $t1, 512($t0)
sw $t1, 516($t0)
li $v0, 32 # wait for 1 second
li $a0, 20
syscall
sw $t3, 0($t0) # repaint the screen by black
sw $t3, 124($t0)
sw $t3, 128($t0)
sw $t3, 132($t0)
sw $t3, 252($t0)
sw $t3, 256($t0)
sw $t3, 260($t0)
sw $t3, 264($t0)
sw $t3, 268($t0)
sw $t3, 380($t0)
sw $t3, 384($t0)
sw $t3, 388($t0)
sw $t3, 508($t0)
sw $t3, 512($t0)
sw $t3, 516($t0)
jr $ra
respond_j2: addi $t4, $t4, -4 # position move one block to left
j draw
respond_k2: addi $t4, $t4, 4 # position move one block to right
j draw
collision: li $t5, 4 #t5 stores 4
li $t4, 5 #loop number, loop 5 times
li $t7, 0 #offset for platform array address
la $t6, platformArray #load platformArray address
loop4: sll $t8, $t7, 2 #offset $t7 times 4
add $t6, $t6, $t8 #locate to array with offset
lw $t3, 0($t6) #load position of platform from array
lw $t2, doodler #load doodler position
addi $t2, $t2, 161 #doodler right bottom position
bge $t2, $t3, next #check doodler right bottom greater than or equal to platform leftmost block
addi $t7, $t7, 1 # if not collide, offset plus one
bne $t7, $t4, loop4 # if not all platform checked, loop
li $t0, 0 # if all platform checked, no collision
addi $sp, $sp, -4
sw $t0, 0($sp) #store 1 for true 0 for false into stack
jr $ra #return 0
next: addi $t2, $t2, -2 #doodler left bottom
addi $t3, $t3, 6 #platform rightmost block
blt $t2, $t3, End # if collide, jump to end
addi $t7, $t7, 1
bne $t7, $t4, loop4
li $t0, 0
addi $sp, $sp, -4
sw $t0, 0($sp) #store 1 for true 0 for false into stack
jr $ra
End:
blt $t3, 864, platformdown #if collided block not in last 5 rows, move it down
addi $sp, $sp, -4
sw $ra, 0($sp)
jal drawplatform
lw $ra, 0($sp)
addi $sp, $sp, 4
li $t0, 1
addi $sp, $sp, -4
sw $t0, 0($sp) #store 1 for true 0 for false into stack
jr $ra
platformdown: addi $t3, $t3, 32 # move block down one row
li $s4, 5 #loop number, loop 5 times
li $s7, 0 #offset for platform array address
la $s6, platformArray #load platformArray address
loop5: sll $s1, $s7, 2 #offset $t7 times 4
add $s6, $s6, $s1 #locate to array where we want to store number in
lw $s3, 0($s6) #load position from array
lw $s2, purple #store block
sll $s5, $s3, 2 #position number times 4
lw $s0, displayAddress #load address
add $s0, $s0, $s5 #calculate new address
sw $s2, 0($s0)# paint old platform to black
sw $s2, 4($s0)
sw $s2, 8($s0)
sw $s2, 12($s0)
sw $s2, 16($s0)
sw $s2, 20($s0)
addi $s3, $s3, 32 #move one row down
bge $s3, 1024, renew
restore: sw $s3, 0($s6)
addi $s7, $s7, 1 #offset add 1
bne $s7, $s4, loop5 #check if we have 5 numbers already
j End
renew: li $v0, 42 #radomize a number
li $a0, 0
li $a1, 26 #randomized number will be in range 0-26
syscall # radomized number stored in $a0
addi $s3, $a0, 0
j restore
drawG: lw $t1, red
lw $t0, displayAddress
li $t3, 102 #offset of top left block
sll $t4, $t3, 2 # offset times 4
add $t0, $t0, $t4 #calculate top left block
sw $t1, 0($t0) #draw G with red
sw $t1, 4($t0)
sw $t1, 8($t0)
sw $t1, 12($t0)
sw $t1, 128($t0)
sw $t1, 256($t0)
sw $t1, 264($t0)
sw $t1, 268($t0)
sw $t1, 384($t0)
sw $t1, 396($t0)
sw $t1, 512($t0)
sw $t1, 516($t0)
sw $t1, 520($t0)
sw $t1, 524($t0)
jr $ra
drawA: lw $t1, red
lw $t0, displayAddress
li $t3, 108 #offset of top left block
sll $t4, $t3, 2 # offset times 4
add $t0, $t0, $t4 #calculate top left block
sw $t1, 0($t0) #draw G with red
sw $t1, 124($t0)
sw $t1, 132($t0)
sw $t1, 252($t0)
sw $t1, 256($t0)
sw $t1, 260($t0)
sw $t1, 380($t0)
sw $t1, 388($t0)
sw $t1, 508($t0)
sw $t1, 516($t0)
jr $ra
drawM: lw $t1, red
lw $t0, displayAddress
li $t3, 111 #offset of top left block
sll $t4, $t3, 2 # offset times 4
add $t0, $t0, $t4 #calculate top left block
sw $t1, 0($t0) #draw G with red
sw $t1, 16($t0)
sw $t1, 128($t0)
sw $t1, 132($t0)
sw $t1, 140($t0)
sw $t1, 144($t0)
sw $t1, 256($t0)
sw $t1, 264($t0)
sw $t1, 272($t0)
sw $t1, 384($t0)
sw $t1, 400($t0)
sw $t1, 512($t0)
sw $t1, 528($t0)
jr $ra
drawE: lw $t1, red
lw $t0, displayAddress
li $t3, 117 #offset of top left block
sll $t4, $t3, 2 # offset times 4
add $t0, $t0, $t4 #calculate top left block
sw $t1, 0($t0) #draw G with red
sw $t1, 4($t0)
sw $t1, 8($t0)
sw $t1, 128($t0)
sw $t1, 256($t0)
sw $t1, 260($t0)
sw $t1, 264($t0)
sw $t1, 384($t0)
sw $t1, 512($t0)
sw $t1, 516($t0)
sw $t1, 520($t0)
jr $ra
drawO: lw $t1, red
lw $t0, displayAddress
li $t3, 326 #offset of top left block
sll $t4, $t3, 2 # offset times 4
add $t0, $t0, $t4 #calculate top left block
sw $t1, 4($t0) #draw G with red
sw $t1, 8($t0)
sw $t1, 128($t0)
sw $t1, 140($t0)
sw $t1, 256($t0)
sw $t1, 268($t0)
sw $t1, 384($t0)
sw $t1, 396($t0)
sw $t1, 516($t0)
sw $t1, 520($t0)
jr $ra
drawV: lw $t1, red
lw $t0, displayAddress
li $t3, 331 #offset of top left block
sll $t4, $t3, 2 # offset times 4
add $t0, $t0, $t4 #calculate top left block
sw $t1, 0($t0) #draw G with red
sw $t1, 16($t0)
sw $t1, 128($t0)
sw $t1, 144($t0)
sw $t1, 256($t0)
sw $t1, 272($t0)
sw $t1, 388($t0)
sw $t1, 396($t0)
sw $t1, 520($t0)
jr $ra
drawE2: lw $t1, red
lw $t0, displayAddress
li $t3, 337 #offset of top left block
sll $t4, $t3, 2 # offset times 4
add $t0, $t0, $t4 #calculate top left block
sw $t1, 0($t0) #draw G with red
sw $t1, 4($t0)
sw $t1, 8($t0)
sw $t1, 128($t0)
sw $t1, 256($t0)
sw $t1, 260($t0)
sw $t1, 264($t0)
sw $t1, 384($t0)
sw $t1, 512($t0)
sw $t1, 516($t0)
sw $t1, 520($t0)
jr $ra
drawR: lw $t1, red
lw $t0, displayAddress
li $t3, 341 #offset of top left block
sll $t4, $t3, 2 # offset times 4
add $t0, $t0, $t4 #calculate top left block
sw $t1, 0($t0) #draw G with red
sw $t1, 4($t0)
sw $t1, 8($t0)
sw $t1, 128($t0)
sw $t1, 136($t0)
sw $t1, 256($t0)
sw $t1, 260($t0)
sw $t1, 264($t0)
sw $t1, 384($t0)
sw $t1, 388($t0)
sw $t1, 512($t0)
sw $t1, 520($t0)
jr $ra
drawWOW:
lw $t1, 0($sp)
lw $t0, displayAddress
lw $t3, 4($sp) #offset of top left block
sll $t4, $t3, 2 # offset times 4
add $t0, $t0, $t4 #calculate top left block
sw $t1, 0($t0) #draw G with red
sw $t1, 16($t0)
sw $t1, 128($t0)
sw $t1, 136($t0)
sw $t1, 144($t0)
sw $t1, 256($t0)
sw $t1, 264($t0)
sw $t1, 272($t0)
sw $t1, 388($t0)
sw $t1, 392($t0)
sw $t1, 396($t0)
sw $t1, 516($t0)
sw $t1, 524($t0)
add $t0, $t0, 24 #calculate top left block
sw $t1, 4($t0) #draw O with red
sw $t1, 8($t0)
sw $t1, 128($t0)
sw $t1, 140($t0)
sw $t1, 256($t0)
sw $t1, 268($t0)
sw $t1, 384($t0)
sw $t1, 396($t0)
sw $t1, 516($t0)
sw $t1, 520($t0)
add $t0, $t0, 24 #calculate top left block
sw $t1, 0($t0) #draw G with red
sw $t1, 16($t0)
sw $t1, 128($t0)
sw $t1, 136($t0)
sw $t1, 144($t0)
sw $t1, 256($t0)
sw $t1, 264($t0)
sw $t1, 272($t0)
sw $t1, 388($t0)
sw $t1, 392($t0)
sw $t1, 396($t0)
sw $t1, 516($t0)
sw $t1, 524($t0)
jr $ra
drawAwesome: lw $t1, 0($sp)
lw $t0, displayAddress
lw $t3, 4($sp) #offset of top left block
sll $t4, $t3, 2 # offset times 4
add $t0, $t0, $t4 #calculate top left block
sw $t1, 0($t0) #draw A
sw $t1, 124($t0)
sw $t1, 132($t0)
sw $t1, 252($t0)
sw $t1, 256($t0)
sw $t1, 260($t0)
sw $t1, 380($t0)
sw $t1, 388($t0)
sw $t1, 508($t0)
sw $t1, 516($t0)
add $t0, $t0, 16 #calculate top left block
sw $t1, 0($t0) #draw W
sw $t1, 16($t0)
sw $t1, 128($t0)
sw $t1, 136($t0)
sw $t1, 144($t0)
sw $t1, 256($t0)
sw $t1, 264($t0)
sw $t1, 272($t0)
sw $t1, 388($t0)
sw $t1, 392($t0)
sw $t1, 396($t0)
sw $t1, 516($t0)
sw $t1, 524($t0)
add $t0, $t0, 24 #calculate top left block
sw $t1, 0($t0) #draw E with red
sw $t1, 4($t0)
sw $t1, 8($t0)
sw $t1, 128($t0)
sw $t1, 256($t0)
sw $t1, 260($t0)
sw $t1, 264($t0)
sw $t1, 384($t0)
sw $t1, 512($t0)
sw $t1, 516($t0)
sw $t1, 520($t0)
add $t0, $t0, 744 #calculate top left block
sw $t1, 0($t0) #draw s
sw $t1, 4($t0)
sw $t1, 8($t0)
sw $t1, 128($t0)
sw $t1, 256($t0)
sw $t1, 260($t0)
sw $t1, 264($t0)
sw $t1, 392($t0)
sw $t1, 512($t0)
sw $t1, 516($t0)
sw $t1, 520($t0)
add $t0, $t0, 20 #calculate top left block
sw $t1, 4($t0) #draw O with red
sw $t1, 8($t0)
sw $t1, 128($t0)
sw $t1, 140($t0)
sw $t1, 256($t0)
sw $t1, 268($t0)
sw $t1, 384($t0)
sw $t1, 396($t0)
sw $t1, 516($t0)
sw $t1, 520($t0)
add $t0, $t0, 24 #calculate top left block
sw $t1, 0($t0) #draw M with red
sw $t1, 16($t0)
sw $t1, 128($t0)
sw $t1, 132($t0)
sw $t1, 140($t0)
sw $t1, 144($t0)
sw $t1, 256($t0)
sw $t1, 264($t0)
sw $t1, 272($t0)
sw $t1, 384($t0)
sw $t1, 400($t0)
sw $t1, 512($t0)
sw $t1, 528($t0)
add $t0, $t0, 28 #calculate top left block
sw $t1, 0($t0) #draw E with red
sw $t1, 4($t0)
sw $t1, 8($t0)
sw $t1, 128($t0)
sw $t1, 256($t0)
sw $t1, 260($t0)
sw $t1, 264($t0)
sw $t1, 384($t0)
sw $t1, 512($t0)
sw $t1, 516($t0)
sw $t1, 520($t0)
jr $ra
drawScore: lw $t6, 0($sp)# pop color from stack
addi $sp, $sp, 4 #pop
lw $t1, score
li $t2, 10 # store 10
div $t1, $t2 #divide score with 10
mflo $t3 #quotient, tenth digit
mfhi $t4 #remainder, oneth digit
li $t5, 132 #top left block of tenth digit
addi $sp, $sp, -4
sw $ra, 0($sp) #store return address into stack
addi $sp, $sp, -4
sw $t3, 0($sp) #store quotient into stack
addi $sp, $sp, -4
sw $t4, 0($sp) #store remainder into stack
addi $sp, $sp, -4
sw $t6, 0($sp) #store color into stack
addi $sp, $sp, -4
sw $t5, 0($sp) #store top left block for tenth digit into stack
beq $t3, 0, drawzero # if tenth digit is 0
beq $t3, 1, drawone # if tenth digit is 1
beq $t3, 2, drawtwo # if tenth digit is 2
beq $t3, 3, drawthree # if tenth digit is 3
beq $t3, 4, drawfour # if tenth digit is 4
beq $t3, 5, drawfive # if tenth digit is 5
beq $t3, 6, drawsix # if tenth digit is 6
beq $t3, 7, drawseven # if tenth digit is 7
beq $t3, 8, draweight # if tenth digit is 8
beq $t3, 9, drawnine # if tenth digit is 9
drawoneth: lw $t5, 0($sp)
addi $sp, $sp, 4 #pop numbers
lw $t6, 0($sp)
addi $sp, $sp, 4 #pop numbers
lw $t4, 0($sp)
addi $sp, $sp, 4 #pop numbers
lw $t3, 0($sp)
addi $sp, $sp, 4 #pop numbers
li $t5, 148 #top left block of oneth digit
addi $sp, $sp, -4
sw $t6, 0($sp) #store color into stack
addi $sp, $sp, -4
sw $t5, 0($sp) #store top left block for oneth digit into stack
beq $t4, 0, drawzero2 # if oneth digit is 0
beq $t4, 1, drawone2 # if oneth digit is 1
beq $t4, 2, drawtwo2 # if oneth digit is 2
beq $t4, 3, drawthree2 # if oneth digit is 3
beq $t4, 4, drawfour2 # if oneth digit is 4
beq $t4, 5, drawfive2 # if oneth digit is 5
beq $t4, 6, drawsix2 # if oneth digit is 6
beq $t4, 7, drawseven2 # if oneth digit is 7
beq $t4, 8, draweight2 # if oneth digit is 8
beq $t4, 9, drawnine2 # if oneth digit is 9
Finish: lw $t5, 0($sp)
addi $sp, $sp, 4 #pop numbers
lw $t6, 0($sp)
addi $sp, $sp, 4 #pop color
lw $ra, 0($sp)
addi $sp, $sp, 4 #pop $ra
jr $ra
drawzero: jal drawZero
j drawoneth
drawone: jal drawOne
j drawoneth
drawtwo: jal drawTwo
j drawoneth
drawthree: jal drawThree
j drawoneth
drawfour: jal drawFour
j drawoneth
drawfive: jal drawFive
j drawoneth
drawsix: jal drawSix
j drawoneth
drawseven: jal drawSeven
j drawoneth
draweight: jal drawEight
j drawoneth
drawnine: jal drawNine
j drawoneth
drawzero2: jal drawZero
j Finish
drawone2: jal drawOne
j Finish
drawtwo2: jal drawTwo
j Finish
drawthree2: jal drawThree
j Finish
drawfour2: jal drawFour
j Finish
drawfive2: jal drawFive
j Finish
drawsix2: jal drawSix
j Finish
drawseven2: jal drawSeven
j Finish
draweight2: jal drawEight
j Finish
drawnine2: jal drawNine
j Finish
drawZero: lw $t1, 0($sp) #load offset
lw $t0, displayAddress
lw $t2, 4($sp) #load color
add $t0, $t0, $t1 #locate left top block
sw $t2, 0($t0) # paint the number
sw $t2, 4($t0)
sw $t2, 8($t0)
sw $t2, 128($t0)
sw $t2, 136($t0)
sw $t2, 256($t0)
sw $t2, 264($t0)
sw $t2, 384($t0)
sw $t2, 392($t0)
sw $t2, 512($t0)
sw $t2, 516($t0)
sw $t2, 520($t0)
jr $ra
drawOne: lw $t1, 0($sp) #load offset
lw $t0, displayAddress
lw $t2, 4($sp) #load color
add $t0, $t0, $t1 #locate left top block
sw $t2, 0($t0) # paint the number
sw $t2, 4($t0)
sw $t2, 132($t0)
sw $t2, 260($t0)
sw $t2, 388($t0)
sw $t2, 512($t0)
sw $t2, 516($t0)
sw $t2, 520($t0)
jr $ra
drawTwo: lw $t1, 0($sp) #load offset
lw $t0, displayAddress
lw $t2, 4($sp) #load color
add $t0, $t0, $t1 #locate left top block
sw $t2, 0($t0) # paint the number
sw $t2, 4($t0)
sw $t2, 8($t0)
sw $t2, 136($t0)
sw $t2, 256($t0)
sw $t2, 260($t0)
sw $t2, 264($t0)
sw $t2, 384($t0)
sw $t2, 512($t0)
sw $t2, 516($t0)
sw $t2, 520($t0)
jr $ra
drawThree: lw $t1, 0($sp) #load offset
lw $t0, displayAddress
lw $t2, 4($sp) #load color
add $t0, $t0, $t1 #locate left top block
sw $t2, 0($t0) # paint the number
sw $t2, 4($t0)
sw $t2, 8($t0)
sw $t2, 136($t0)
sw $t2, 256($t0)
sw $t2, 260($t0)
sw $t2, 264($t0)
sw $t2, 392($t0)
sw $t2, 512($t0)
sw $t2, 516($t0)
sw $t2, 520($t0)
jr $ra
drawFour: lw $t1, 0($sp) #load offset
lw $t0, displayAddress
lw $t2, 4($sp) #load color
add $t0, $t0, $t1 #locate left top block
sw $t2, 0($t0) # paint the number
sw $t2, 8($t0)
sw $t2, 128($t0)
sw $t2, 136($t0)
sw $t2, 256($t0)
sw $t2, 260($t0)
sw $t2, 264($t0)
sw $t2, 392($t0)
sw $t2, 520($t0)
jr $ra
drawFive: lw $t1, 0($sp) #load offset
lw $t0, displayAddress
lw $t2, 4($sp) #load color
add $t0, $t0, $t1 #locate left top block
sw $t2, 0($t0) # paint the number
sw $t2, 4($t0)
sw $t2, 8($t0)
sw $t2, 128($t0)
sw $t2, 256($t0)
sw $t2, 260($t0)
sw $t2, 264($t0)
sw $t2, 392($t0)
sw $t2, 512($t0)
sw $t2, 516($t0)
sw $t2, 520($t0)
jr $ra
drawSix: lw $t1, 0($sp) #load offset
lw $t0, displayAddress
lw $t2, 4($sp) #load color
add $t0, $t0, $t1 #locate left top block
sw $t2, 0($t0) # paint the number
sw $t2, 4($t0)
sw $t2, 8($t0)
sw $t2, 128($t0)
sw $t2, 256($t0)
sw $t2, 260($t0)
sw $t2, 264($t0)
sw $t2, 384($t0)
sw $t2, 392($t0)
sw $t2, 512($t0)
sw $t2, 516($t0)
sw $t2, 520($t0)
jr $ra
drawSeven: lw $t1, 0($sp) #load offset
lw $t0, displayAddress
lw $t2, 4($sp) #load color
add $t0, $t0, $t1 #locate left top block
sw $t2, 0($t0) # paint the number
sw $t2, 4($t0)
sw $t2, 8($t0)
sw $t2, 136($t0)
sw $t2, 264($t0)
sw $t2, 392($t0)
sw $t2, 520($t0)
jr $ra
drawEight: lw $t1, 0($sp) #load offset
lw $t0, displayAddress
lw $t2, 4($sp) #load color
add $t0, $t0, $t1 #locate left top block
sw $t2, 0($t0) # paint the number
sw $t2, 4($t0)
sw $t2, 8($t0)
sw $t2, 128($t0)
sw $t2, 136($t0)
sw $t2, 256($t0)
sw $t2, 260($t0)
sw $t2, 264($t0)
sw $t2, 384($t0)
sw $t2, 392($t0)
sw $t2, 512($t0)
sw $t2, 516($t0)
sw $t2, 520($t0)
jr $ra
drawNine: lw $t1, 0($sp) #load offset
lw $t0, displayAddress
lw $t2, 4($sp) #load color
add $t0, $t0, $t1 #locate left top block
sw $t2, 0($t0) # paint the number
sw $t2, 4($t0)
sw $t2, 8($t0)
sw $t2, 128($t0)
sw $t2, 136($t0)
sw $t2, 256($t0)
sw $t2, 260($t0)
sw $t2, 264($t0)
sw $t2, 392($t0)
sw $t2, 520($t0)
jr $ra
drawShield: lw $t1, shield #load offset number
sll $t4, $t1, 2 # offset number times 4
lw $t0, displayAddress
lw $t2, 0($sp) #load color
add $t0, $t0, $t4 #locate left top block