-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.asm
9157 lines (9013 loc) · 229 KB
/
game.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
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
#####################################################################
#
# CSCB58 Winter 2024 Assembly Final Project
# University of Toronto, Scarborough
#
# Student: Nikolos Zegas-Tepper, **** , ****, ****
#
# Bitmap Display Configuration:
# - Unit width in pixels: 4
# - Unit height in pixels: 4
# - Display width in pixels: 256
# - Display height in pixels: 256
# - Base Address for Display: 0x10008000 ($gp)
#
# Which milestoneshave been reached in this submission?
# (See the assignment handout for descriptions of the milestones)
# - Milestone 4
#
# Which approved features have been implemented for milestone 3?
# (See the assignment handout for the list of additional features)
# 1. Moving Objects (turtles)
# 2. Enemies Shoot Back
# 3. Animated Sprites
#
# Link to video demonstration for final submission:
# - (insert YouTube / MyMedia / other URL here). Make sure we can view it!
#
# Are you OK with us sharing the video with people outside course staff?
# - yes / no / yes, and please share this project github link as well!
#
# Any additional information that the TA needs to know:
# - (write here, if any)
#
#####################################################################
.eqv BASE_ADDRESS 0x10008000
.eqv PLAYER_SPEED 1
.eqv GRAVITY 1
.eqv TURTLE_SPEED 1
.eqv DRIP_SPEED 1
# colours
.eqv EMPTY_HEART 0x533a20
.eqv HEALTH_LOC 976
.eqv RED 0xff0000 # HEART + 1HP HAT + DRAGON FIRE
.eqv WHITE 0xffffff
.eqv BLACK 0x000000
.eqv GOLD 0xf1e504
.eqv GOLD2 0xf5ed61
.eqv GOLD3 0xdabc00
.eqv GOLD4 0xcdcc00
.eqv HAT_D1 0xd400ff #3hp
.eqv HAT_D2 0xeaff00 #2hp
.eqv EDGE 0x702e0e
.eqv BACK 0xbc5a2a
.eqv TURTLE1_GREEN 0x12b112
.eqv TURTLE_SPIKE 0xa29994
.eqv STALA 0x4e4444
.eqv ACID_GREEN 0x3eff09
.eqv TURTLE2_GREEN 0x50bc2a
.data
MAIN_POS: .word 6, 7 # characters position, operating on coord grid (x, y): x,y in [0, 63] (6,7)
MAIN_HEALTH: .word 3 # begin with 3 hp
TURTLE1_POS: .word 17, 21, 1 # start moving right (use 3rd variable 1=right -1=left) (17,21,1)
TURTLE2_POS: .word 50, 47, -1 # same as above
DRIP_POS: .word 16, 28 # track drips (SINCE ALL ARE IN A LINE, ONLY NEED 1 COORD) change to actual pos before implement
DRIP_TIMER: .word 0
.text
.globl main
#TODO:
# - GET IT ALL MOVING (PLAYER + ENEMIES)
# - HARD BOUNDARIES (edges)
# - COLLISION BETWEEN THEM AND PLAYER
# - DAMAGE
# - victory / loss screen?
#WANT menu (+1), shooting(?), moving enemies (+2), diff damage level colours (+2). ez 5.
#NEED score for win/lose? consider big rocks that reach the end? or coins?
main:
jal draw_stage
j loop
loop:
li $a0 1 #THIS AND BELOW DELETES
jal draw_player #PLAYER
jal draw_turtle1
jal draw_turtle2
jal draw_acid
li $a0, 0 #RESET HARD CHECK FOR THIS CLOCK CYCLE
jal grav
jal handle_input
jal move_enemies
jal handle_acid
jal draw_player
jal draw_turtle1
jal draw_turtle2
jal draw_acid
jal check_collision
jal check_win
sleep:
li $v0, 32 #MARS instruction for sleep
li $a0, 40 #sleep for 40ms
syscall
j loop #restart loop
check_win:
la $t0 MAIN_POS
lw $t1 4($t0) #get y position
bgt $t1 57 check_win2
jr $ra
check_win2:
lw $t1 0($t0)
bgt $t1 25 draw_win
jr $ra
check_collision:
la $t0 BASE_ADDRESS
la $t1, MAIN_POS #player in memory
lw $t2, 0($t1) #get x in t2
lw $t3, 4($t1)
#get exact pixel location
sll $t2, $t2, 2 # actual x = stored x * 4
sll $t3, $t3, 8 # actual y = stored y * (2^8)
add $t1, $t0, $t2 #base + x
add $t1, $t1, $t3 #base+x + y
lw $t4, 0($t1) #collision checks (ALL PIXELS)
beq $t4 TURTLE1_GREEN spike1_death
beq $t4 TURTLE2_GREEN spike2_death
beq $t4 ACID_GREEN acid_death
lw $t4, 4($t1)
beq $t4 TURTLE1_GREEN spike1_death
beq $t4 TURTLE2_GREEN spike2_death
beq $t4 ACID_GREEN acid_death
lw $t4, -4($t1)
beq $t4 TURTLE1_GREEN spike1_death
beq $t4 TURTLE2_GREEN spike2_death
beq $t4 ACID_GREEN acid_death
lw $t4, -256($t1)
beq $t4 TURTLE1_GREEN spike1_death
beq $t4 TURTLE2_GREEN spike2_death
beq $t4 ACID_GREEN acid_death
lw $t4, -512($t1)
beq $t4 TURTLE1_GREEN spike1_death
beq $t4 TURTLE2_GREEN spike2_death
beq $t4 ACID_GREEN acid_death
lw $t4, 256($t1)
beq $t4 TURTLE1_GREEN spike1_death
beq $t4 TURTLE2_GREEN spike2_death
beq $t4 ACID_GREEN acid_death
lw $t4, 252($t1)
beq $t4 TURTLE1_GREEN spike1_death
beq $t4 TURTLE2_GREEN spike2_death
beq $t4 ACID_GREEN acid_death
lw $t4, 260($t1)
beq $t4 TURTLE1_GREEN spike1_death
beq $t4 TURTLE2_GREEN spike2_death
beq $t4 ACID_GREEN acid_death
lw $t4, 516($t1)
beq $t4 TURTLE1_GREEN spike1_death
beq $t4 TURTLE2_GREEN spike2_death
beq $t4 ACID_GREEN acid_death
lw $t4, 508($t1)
beq $t4 TURTLE1_GREEN spike1_death
beq $t4 TURTLE2_GREEN spike2_death
beq $t4 ACID_GREEN acid_death
jr $ra
spike1_death:
la $t0, BASE_ADDRESS #framebuffer
la $t1, TURTLE1_POS #player in memory
lw $t2, 0($t1) #get x in t2
lw $t3, 4($t1) #get y in t3
#get exact pixel location
sll $t2, $t2, 2 # actual x = stored x * 4
sll $t3, $t3, 8 # actual y = stored y * (2^8)
add $t1, $t0, $t2 #base + x
add $t1, $t1, $t3 #base+x + y
li $t2, TURTLE_SPIKE
sw $t2, 12($t1)
sw $t2, 16($t1)
sw $t2, -512($t1)
sw $t2, -768($t1)
sw $t2, -1024($t1)
sw $t2, -504($t1)
sw $t2, -520($t1)
sw $t2, -756($t1)
sw $t2, -780($t1)
sw $t2, -12($t1)
sw $t2, -16($t1)
j lose_heart
spike2_death:
la $t0, BASE_ADDRESS #framebuffer
la $t1, TURTLE2_POS #player in memory
lw $t2, 0($t1) #get x in t2
lw $t3, 4($t1) #get y in t3
#get exact pixel location
sll $t2, $t2, 2 # actual x = stored x * 4
sll $t3, $t3, 8 # actual y = stored y * (2^8)
add $t1, $t0, $t2 #base + x
add $t1, $t1, $t3 #base+x + y
li $t2, TURTLE_SPIKE
sw $t2, 12($t1)
sw $t2, 16($t1)
sw $t2, -512($t1)
sw $t2, -768($t1)
sw $t2, -1024($t1)
sw $t2, -504($t1)
sw $t2, -520($t1)
sw $t2, -756($t1)
sw $t2, -780($t1)
sw $t2, -12($t1)
sw $t2, -16($t1)
j lose_heart
acid_death:
li $a0 2
jal draw_player
j lose_heart
lose_heart:
la $t0 MAIN_HEALTH
lw $t1 0($t0)
add $t1 $t1 -1
li $v0, 32 #MARS instruction for sleep
li $a0, 1000 #sleep for 1s
syscall
beq $t1 0 draw_lose
sw $t1, 0($t0)
# REMOVE A HEART
la $t0 BASE_ADDRESS
li $t2, HEALTH_LOC #health in memory
mul $t3, $t1, 16 #increment by amt of health*offset of each (16)
add $t1, $t0, $t3
add $t1, $t1, $t2
li $t2, EMPTY_HEART
sw $t2, 0($t1)
sw $t2, 256($t1)
sw $t2, 4($t1)
sw $t2, -252($t1)
sw $t2, -260($t1)
sw $t2, -4($t1)
li $a0, 1
li $a1, 1
jal draw_player
jal draw_turtle1
jal draw_turtle2
jal draw_acid
li $a0, 0
li $a1, 0
j start_state
handle_input:
li $t9, 0xffff0000
lw $t8, 0($t9)
bne $t8, 1, return
lw $t2, 4($t9) # this assumes $t9 is set to 0xfff0000 from before
beq $t2, 97, left #a was pressed
beq $t2, 100, right #d
beq $t2, 114, restart #r
beq $t2, 113, draw_lose #q
jr $ra #any other input is invalid
left:
la $t0 BASE_ADDRESS
la $t1, MAIN_POS #player in memory
lw $t2, 0($t1) #get x in t2
lw $t3, 4($t1) #get y in t3
#get exact pixel location
sll $t2, $t2, 2 # actual x = stored x * 4
sll $t3, $t3, 8 # actual y = stored y * (2^8)
add $t1, $t0, $t2 #base + x
add $t1, $t1, $t3 #base+x + y
add $t1, $t1, -8 #want just left of player
lw $t4, 0($t1) #CHECK ALL 5 PIXELS LEFT OF PLAYER
beq $t4, EDGE, return
lw $t4, 256($t1)
beq $t4, EDGE, return
lw $t4, 512($t1)
beq $t4, EDGE, return
lw $t4, -256($t1)
beq $t4, EDGE, return
lw $t4, -512($t1)
beq $t4, EDGE, return
la $t0, MAIN_POS #same for drip
lw $t1, 0($t0)
addi $t1, $t1, -PLAYER_SPEED
sw $t1, 0($t0)
jr $ra
right:
la $t0 BASE_ADDRESS
la $t1, MAIN_POS #player in memory
lw $t2, 0($t1) #get x in t2
lw $t3, 4($t1) #get y in t3
#get exact pixel location
sll $t2, $t2, 2 # actual x = stored x * 4
sll $t3, $t3, 8 # actual y = stored y * (2^8)
add $t1, $t0, $t2 #base + x
add $t1, $t1, $t3 #base+x + y
add $t1, $t1, 8 #want just right of player
lw $t4, 0($t1) #CHECK ALL 5 PIXELS RIGHT OF PLAYER
beq $t4, EDGE, return
lb $t4, 256($t1)
beq $t4, EDGE, return
lb $t4, 512($t1)
beq $t4, EDGE, return
lb $t4, -256($t1)
beq $t4, EDGE, return
lb $t4, -512($t1)
beq $t4, EDGE, return
la $t0, MAIN_POS #same for drip
lw $t1, 0($t0)
addi $t1, $t1, PLAYER_SPEED
sw $t1, 0($t0)
jr $ra
grav:
la $t0 BASE_ADDRESS
la $t1, MAIN_POS #player in memory
lw $t2, 0($t1) #get x in t2
lw $t3, 4($t1) #get y in t3
#get exact pixel location
sll $t2, $t2, 2 # actual x = stored x * 4
sll $t3, $t3, 8 # actual y = stored y * (2^8)
add $t1, $t0, $t2 #base + x
add $t1, $t1, $t3 #base+x + y
add $t1, $t1, 768 #want just below player
lw $t4, 0($t1)
beq $t4, EDGE, return
lw $t4, 4($t1)
beq $t4, EDGE, return
lw $t4, -4($t1)
beq $t4, EDGE, return
la $t0, MAIN_POS #same for drip
lw $t1, 4($t0)
addi $t1, $t1, GRAVITY
sw $t1, 4($t0)
jr $ra
restart:
la $t0, MAIN_HEALTH
li $t1, 3
sw $t1, 0($t0)
jal ready_hearts
j start_state
start_state:
la $t0, MAIN_POS
li $t1, 6
sw $t1, 0($t0)
li $t1, 7
sw $t1, 4($t0)
la $t0, TURTLE1_POS
li $t1, 17
sw $t1, 0($t0)
li $t1, 21
sw $t1, 4($t0)
li $t1, 1
sw $t1, 8($t0)
la $t0, TURTLE2_POS
li $t1, 50
sw $t1, 0($t0)
li $t1, 47
sw $t1, 4($t0)
li $t1, -1
sw $t1, 8($t0)
la $t0, DRIP_POS
li $t1, 16
sw $t1, 0($t0)
li $t1, 28
sw $t1, 4($t0)
la $t0, DRIP_TIMER
li $t1, 0
sw $t1, 0($t0)
beq $a0 1 main
j loop
move_enemies:
la $t1, TURTLE1_POS
lw $t2, 0($t1) #check x value
lw $t3, 8($t1)
add $t2, $t2, $t3 #add + x
sw $t2, 0($t1)
#check if need to change direction
beq $t2, 60, change_turtle1
beq $t2, 15, change_turtle2
j move_turtle2
change_turtle1:
li $t3 -1
sw $t3 8($t1)
j move_turtle2
change_turtle2:
li $t3 1
sw $t3 8($t1)
j move_turtle2
move_turtle2:
la $t1, TURTLE2_POS
lw $t2, 0($t1) #check x value
lw $t3, 8($t1)
add $t2, $t2, $t3 #add + x
sw $t2, 0($t1)
#check if need to change direction
beq $t2, 60, change_turtle3
beq $t2, 14, change_turtle4
jr $ra
change_turtle3:
li $t3 -1
sw $t3 8($t1)
jr $ra
change_turtle4:
li $t3 1
sw $t3 8($t1)
jr $ra
handle_acid:
la $t0, DRIP_TIMER #same for drip
lw $t1, 0($t0)
addi $t1, $t1, 40 #increment by 40
sw $t1, 0($t0)
bgt $t1 2000 move_acid #if been 1 second start drip
la $t0, DRIP_POS
lw $t1, 4($t0)
bgt $t1, 28, move_acid
jr $ra # go back no moving needed
move_acid:
la $t0, DRIP_POS
lw $t1, 4($t0)
add $t1, $t1 1 #move down 1
bgt $t1 35, reset_drip
sw $t1, 4($t0)
la $t0, DRIP_TIMER
li $t1, 0
sw $t1, 0($t0)
jr $ra
reset_drip:
li $t1, 28
sw $t1, 4($t0)
jr $ra
#player drawing
draw_player:
la $t0, BASE_ADDRESS #framebuffer
la $t1, MAIN_POS #player in memory
lw $t2, 0($t1) #get x in t2
lw $t3, 4($t1) #get y in t3
#get exact pixel location
sll $t2, $t2, 2 # actual x = stored x * 4
sll $t3, $t3, 8 # actual y = stored y * (2^8)
add $t1, $t0, $t2 #base + x
add $t1, $t1, $t3 #base+x + y
#determine health level
lw $t3, MAIN_HEALTH #get health
li $t2, BLACK
beq $a0, 1, load_clear #HARD CHECK FOR REMOVE PLAYER
beq $a0, 2, load_green #FOR ACID ANIMATION
beq $t3, 3, load_dmg1
beq $t3, 2, load_dmg2
beq $t3, 1, load_dmg3
beq $t3, 0, load_clear
#set colours based on dmg level
load_dmg1:
li $t3, HAT_D1
j render_player
load_dmg2:
li $t3, HAT_D2
j render_player
load_dmg3:
li $t3, RED
j render_player
load_clear: #dead
li $t2, BACK
li $t3, BACK
j render_player
load_green: #ACID ANIMATION
li $t2, ACID_GREEN
li $t3, TURTLE1_GREEN
j render_player
render_player:
sw $t2, 0($t1)
sw $t2, 256($t1)
sw $t2, 516($t1)
sw $t2, 508($t1)
sw $t2, -4($t1)
sw $t2, 4($t1)
sw $t2, -256($t1)
sw $t3, -512($t1)
jr $ra
#turtle drawing
draw_turtle1:
la $t0, BASE_ADDRESS #framebuffer
la $t1, TURTLE1_POS #player in memory
lw $t2, 0($t1) #get x in t2
lw $t3, 4($t1) #get y in t3
#get exact pixel location
sll $t2, $t2, 2 # actual x = stored x * 4
sll $t3, $t3, 8 # actual y = stored y * (2^8)
add $t1, $t0, $t2 #base + x
add $t1, $t1, $t3 #base+x + y
li $t2, TURTLE1_GREEN
li $t3, BLACK
beq $a0, 1, turtle_clear
j render_turtle
draw_turtle2:
la $t0, BASE_ADDRESS #framebuffer
la $t1, TURTLE2_POS #player in memory
lw $t2, 0($t1) #get x in t2
lw $t3, 4($t1) #get y in t3
#get exact pixel location
sll $t2, $t2, 2 # actual x = stored x * 4
sll $t3, $t3, 8 # actual y = stored y * (2^8)
add $t1, $t0, $t2 #base + x
add $t1, $t1, $t3 #base+x + y
li $t2, TURTLE2_GREEN
li $t3, BLACK
beq $a0, 1, turtle_clear
j render_turtle
turtle_clear:
li $t2, BACK
li $t3, BACK
j render_turtle
render_turtle:
sw $t2, 0($t1)
sw $t2, 4($t1)
sw $t2, 8($t1)
sw $t2, -4($t1)
sw $t2, -8($t1)
sw $t2, -256($t1)
sw $t2, -252($t1)
sw $t2, -260($t1)
sw $t3, 260($t1)
sw $t3, 252($t1)
beq $a1, 1, clear_spikes #SET $a1 to 1 if clear spikes
jr $ra
clear_spikes:
sw $t2, 12($t1)
sw $t2, 16($t1)
sw $t2, -512($t1)
sw $t2, -768($t1)
sw $t2, -1024($t1)
sw $t2, -504($t1)
sw $t2, -520($t1)
sw $t2, -756($t1)
sw $t2, -780($t1)
sw $t2, -12($t1)
sw $t2, -16($t1)
jr $ra
draw_acid:
la $t0, BASE_ADDRESS #framebuffer
la $t1, DRIP_POS #player in memory
lw $t2, 0($t1) #get x in t2
lw $t3, 4($t1) #get y in t3
sll $t2, $t2, 2 # actual x = stored x * 4
sll $t3, $t3, 8 # actual y = stored y * (2^8)
add $t1, $t0, $t2 #base + x
add $t1, $t1, $t3 #base+x + y
li $t2, ACID_GREEN
beq $a0, 1, acid_clear
j render_acid
acid_clear:
li $t2, BACK
render_acid:
sw $t2, 0($t1)
addi $t1 $t1 72
sw $t2, 0($t1)
addi $t1 $t1 52
sw $t2, 0($t1)
addi $t1 $t1 3212
sw $t2, 0($t1)
jr $ra
#### STAGE DRAWING (happens once)
draw_stage:
la $t0, BASE_ADDRESS #framebuffer
li $t1, 0 #iterator
li $t2, EDGE #colour
draw_outline1:
bgt $t1, 252, ready_back
add $t4, $t0, $t1
sw $t2, 0($t4)
addi $t1, $t1, 4
j draw_outline1
ready_back:
li $t2, BACK #colour
draw_back:
bgt $t1, 16124, ready_outline
add $t4, $t0, $t1 #get address of current pixel
sw $t2, 0($t4)
addi $t1, $t1, 4 #iterate
j draw_back
ready_outline:
li $t2, EDGE
draw_outline2:
bgt $t1, 16380, draw_outline3
add $t4, $t0, $t1
sw $t2, 0($t4)
addi $t1, $t1, 4
j draw_outline2
draw_outline3:
blt $t1, 256, ready_levels
add $t4, $t0, $t1
sw $t2, 0($t4)
add $t4, $t4, 252
sw $t2, 0($t4)
subi $t1, $t1, 256
j draw_outline3
ready_levels:
li $t1, 2560
draw_levels:
bgt $t1, 2816, ready_holes
add $t4, $t0, $t1 #r1
sw $t2, 0($t4)
add $t4, $t4, 256 #r1.5
sw $t2, 0($t4)
add $t4, $t4, 3072 #r2
sw $t2, 0($t4)
add $t4, $t4, 256 #r2.5
sw $t2, 0($t4)
add $t4, $t4, 3072 #r3
sw $t2, 0($t4)
add $t4, $t4, 256 #r3.5
sw $t2, 0($t4)
add $t4, $t4, 3072 #r4
sw $t2, 0($t4)
add $t4, $t4, 256 #r4.5
sw $t2, 0($t4)
addi $t1, $t1, 4
j draw_levels
ready_holes:
li $t2, BACK
li $t1, 2724
draw_holes:
bgt $t1, 2752, draw_stala
add $t4, $t0, $t1
sw $t2, 0($t4)
add $t4, $t4, 256
sw $t2, 0($t4)
add $t4, $t4, 2924
sw $t2, 0($t4)
add $t4, $t4, 256
sw $t2, 0($t4)
add $t4, $t4, 3256
sw $t2, 0($t4)
add $t4, $t4, 256
sw $t2, 0($t4)
add $t4, $t4, 2888
sw $t2, 0($t4)
add $t4, $t4, 256
sw $t2, 0($t4)
addi $t1, $t1, 4
j draw_holes
draw_stala: #grey spikes
li $t2 STALA
li $t1 6464
add $t1 $t0 $t1
sw $t2 0($t1)
sw $t2 256($t1)
sw $t2 512($t1)
sw $t2 -4($t1)
sw $t2 4($t1)
sw $t2 260($t1)
addi $t1 $t1 72
sw $t2 0($t1)
sw $t2 -4($t1)
sw $t2 4($t1)
sw $t2 252($t1)
sw $t2 256($t1)
sw $t2 260($t1)
sw $t2 512($t1)
addi $t1 $t1 52
sw $t2 0($t1)
sw $t2 -4($t1)
sw $t2 4($t1)
sw $t2 252($t1)
sw $t2 256($t1)
sw $t2 512($t1)
addi $t1 $t1 3212
sw $t2 0($t1)
sw $t2 -4($t1)
sw $t2 4($t1)
sw $t2 256($t1)
sw $t2 260($t1)
sw $t2 512($t1)
draw_gold: #TO BE COMPLETED!! just remember victory pixel is (40 , 60)
li $t0 BASE_ADDRESS
add $t1 $t0 14484
li $t2 GOLD
li $t3 GOLD2
li $t4 GOLD3
li $t5 GOLD4
sw $t3 0($t1)
sw $t3 4($t1)
sw $t2 8($t1)
add $t1 $t1 244
sw $t3 0($t1)
sw $t3 4($t1)
sw $t3 8($t1)
sw $t3 12($t1)
sw $t2 16($t1)
sw $t2 20($t1)
sw $t2 24($t1)
sw $t4 28($t1)
sw $t5 32($t1)
add $t1 $t1 248
sw $t3 0($t1)
sw $t3 4($t1)
sw $t3 8($t1)
sw $t3 12($t1)
sw $t3 16($t1)
sw $t2 20($t1)
sw $t2 24($t1)
sw $t2 28($t1)
sw $t2 32($t1)
sw $t2 36($t1)
sw $t4 40($t1)
sw $t5 44($t1)
add $t1 $t1 252
sw $t3 0($t1)
sw $t3 4($t1)
sw $t3 8($t1)
sw $t3 12($t1)
sw $t3 16($t1)
sw $t3 20($t1)
sw $t2 24($t1)
sw $t2 28($t1)
sw $t2 32($t1)
sw $t2 36($t1)
sw $t2 40($t1)
sw $t2 44($t1)
sw $t2 48($t1)
sw $t4 52($t1)
sw $t5 56($t1)
add $t1 $t1 252
sw $t3 0($t1)
sw $t3 4($t1)
sw $t3 8($t1)
sw $t3 12($t1)
sw $t3 16($t1)
sw $t3 20($t1)
sw $t2 24($t1)
sw $t2 28($t1)
sw $t2 32($t1)
sw $t2 36($t1)
sw $t2 40($t1)
sw $t2 44($t1)
sw $t2 48($t1)
sw $t2 52($t1)
sw $t2 56($t1)
sw $t4 60($t1)
sw $t5 64($t1)
add $t1 $t1 252
sw $t3 0($t1)
sw $t3 4($t1)
sw $t3 8($t1)
sw $t3 12($t1)
sw $t3 16($t1)
sw $t3 20($t1)
sw $t2 24($t1)
sw $t2 28($t1)
sw $t2 32($t1)
sw $t2 36($t1)
sw $t2 40($t1)
sw $t2 44($t1)
sw $t2 48($t1)
sw $t2 52($t1)
sw $t2 56($t1)
sw $t2 60($t1)
sw $t2 64($t1)
sw $t4 68($t1)
sw $t5 72($t1)
add $t1 $t1 252
sw $t2 0($t1)
sw $t2 4($t1)
sw $t2 8($t1)
sw $t2 12($t1)
sw $t2 16($t1)
sw $t2 20($t1)
sw $t2 24($t1)
sw $t2 28($t1)
sw $t2 32($t1)
sw $t2 36($t1)
sw $t2 40($t1)
sw $t2 44($t1)
sw $t2 48($t1)
sw $t2 52($t1)
sw $t2 56($t1)
sw $t2 60($t1)
sw $t2 64($t1)
sw $t2 68($t1)
sw $t2 72($t1)
sw $t4 76($t1)
sw $t5 80($t1)
ready_hearts:
li $t0 BASE_ADDRESS
li $t2 RED
li $t1 0
li $t3 HEALTH_LOC
draw_hearts:
bgt $t1 2 return
add $t4 $t0 $t3
sw $t2 0($t4)
sw $t2 -4($t4)
sw $t2 -260($t4)
sw $t2 -252($t4)
sw $t2 4($t4)
sw $t2 256($t4)
addi $t3 $t3 16
addi $t1 $t1 1
j draw_hearts
return:
jr $ra
exit:
li $v0, 10 # exit program
syscall
wait_restart:
li $v0, 32 #MARS instruction for sleep
li $a0, 40 #sleep for 40ms
syscall
li $t2, 0
li $t9, 0xffff0000
lw $t2, 4($t9) # this assumes $t9 is set to 0xfff0000 from before
beq $t2, 114, set_restart #r
beq $t2, 113, exit
j wait_restart
set_restart:
li $a0 1
j restart
draw_win:
la $t0, BASE_ADDRESS
li $t1, 0x702e0e
li $t2, 0xbc5a2a
li $t3, 0xf1e504
sw $t1, 0($t0)
sw $t1, 4($t0)
sw $t1, 8($t0)
sw $t1, 12($t0)
sw $t1, 16($t0)
sw $t1, 20($t0)
sw $t1, 24($t0)
sw $t1, 28($t0)
sw $t1, 32($t0)
sw $t1, 36($t0)
sw $t1, 40($t0)
sw $t1, 44($t0)
sw $t1, 48($t0)
sw $t1, 52($t0)
sw $t1, 56($t0)
sw $t1, 60($t0)
sw $t1, 64($t0)
sw $t1, 68($t0)
sw $t1, 72($t0)
sw $t1, 76($t0)
sw $t1, 80($t0)
sw $t1, 84($t0)
sw $t1, 88($t0)
sw $t1, 92($t0)
sw $t1, 96($t0)
sw $t1, 100($t0)
sw $t1, 104($t0)
sw $t1, 108($t0)
sw $t1, 112($t0)
sw $t1, 116($t0)
sw $t1, 120($t0)
sw $t1, 124($t0)
sw $t1, 128($t0)
sw $t1, 132($t0)
sw $t1, 136($t0)
sw $t1, 140($t0)
sw $t1, 144($t0)
sw $t1, 148($t0)
sw $t1, 152($t0)
sw $t1, 156($t0)
sw $t1, 160($t0)
sw $t1, 164($t0)
sw $t1, 168($t0)
sw $t1, 172($t0)
sw $t1, 176($t0)