-
Notifications
You must be signed in to change notification settings - Fork 0
/
fin.asm
874 lines (712 loc) · 15.2 KB
/
fin.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
#####################################################################
#
# CSC258H5S Fall 2020 Assembly Final Project
# University of Toronto, St. George
#
# Student: Ng Bob Shoaun, 1006568992
#
# Bitmap Display Configuration:
# - Unit width in pixels: 16
# - Unit height in pixels: 16
# - Display width in pixels: 512
# - Display height in pixels: 512
# - Base Address for Display: 0x10008000 ($gp)
#
# Which milestone is reached in this submission?
# - Milestone 5
#
# Which approved additional features have been implemented?
# 1. Scoreboard
# 2. Game over/retry
# 3. Different levels
# 4. Dynamic difficulty
# - platform spacing increases
# - capped at a certain point
# 5. More platform types
# - broken platform
# - cloud platform
# - moving platform
# 6. Boosting / power-ups
# - Spring
# - jetpack
# 7. Fancier graphics
# 8. Background music & sound effects
#
# Any additional information that the TA needs to know:
# - I forgot to mention in my demo that i have also added moving platforms.
#
#####################################################################
.data
gameMatrix: .word 0:1536
sleepDuration: .word 40
doodlerColor: .word 0xEEB1D5
doodlerSecondaryColor: .word 0xe58abf
backgroundColor: .word 0x43AA8B
platformColor: .word 0xF9C74F
springColor: .word 0x577590
brokenPlatformColor: .word 0xF3722C
cloudPlatformColor: .word 0xF0F0F0
jetpackColor: .word 0x191923
movingPlatformColor: .word 0x22577A
jumpMeterColor: .word 0xF94144
scoreMeterColor: .word 0x2708A0
gameOverTextColor: .word 0x000000
doodlerInitialPosition: .word 64
doodlerJumpDuration: .word 13 # jump duration in frames
springBoostDuration: .word 25 # spring boost duration in frames
jetpackBoostDuration: .word 70
.text
main:
lw $t0, doodlerInitialPosition # doodler current position
li $t1, 0 # doodler velocity
li $t2, 0 # jump timer
li $t3, 0 # game over flag, 1 means game over
li $t4, 768 # next spawn coord / spawn timer
li $t5, 0 # difficulty / platform spacing
li $t6, -128 # moving platforms move timer
li $t7, 0 # background music timer
jal playRetrySound
li $s0, 0
startLoop:
beq $s0, 32, gameLoop
jal scrollWorld
jal spawnObstacle
jal drawWorld
addi $s0, $s0, 1
j startLoop
gameLoop:
jal playBackgroundMusic
bge $t0, 1536, skipScroll
jal scrollWorld
jal spawnObstacle
addi $t0, $t0, 128 # also scroll player
skipScroll:
jal movePlatforms
beq $t3, 1, skipMoveDoodler
jal moveDoodler
skipMoveDoodler:
jal drawWorld
jal drawDoodler
jal drawJumpMeter
jal drawScoreMeter
ble $t0, 4096, contGameLoop # doodler reaches bottom of screen
jal gameOver
jal drawGameOverText
beq $t3, 1, contGameLoop
li $t3, 1 # set gameOver to true
jal playGameOverSound
contGameLoop:
jal sleep
j gameLoop
endGameLoop:
li $v0, 10 # terminate the program gracefully
syscall
gameOver:
lw $s0, 0xffff0000
beq $s0, 1, gameOverInput
jr $ra
gameOverInput:
lw $s1, 0xffff0004
beq $s1, 0x72, rPressed
beq $s1, 0x71, qPressed
jr $ra
rPressed:
j main
qPressed:
li $v0, 10 # terminate the program gracefully
syscall
drawGameOverText:
addi $sp, $sp, -12
sw $s0, ($sp)
sw $s1, 4($sp)
sw $s2, 8($sp)
lw $s0, gameOverTextColor
addi $s1, $gp, 1960
# o
sw $s0, 0($s1)
sw $s0, 4($s1)
sw $s0, 8($s1)
sw $s0, 128($s1)
sw $s0, 136($s1)
sw $s0, 256($s1)
sw $s0, 260($s1)
sw $s0, 264($s1)
addi $s1, $s1, 16
# o
sw $s0, 0($s1)
sw $s0, 4($s1)
sw $s0, 8($s1)
sw $s0, 128($s1)
sw $s0, 136($s1)
sw $s0, 256($s1)
sw $s0, 260($s1)
sw $s0, 264($s1)
addi $s1, $s1, 16
# f
sw $s0, -252($s1)
sw $s0, -248($s1)
sw $s0, -124($s1)
sw $s0, 0($s1)
sw $s0, 4($s1)
sw $s0, 8($s1)
sw $s0, 132($s1)
sw $s0, 260($s1)
addi $s1, $s1, 1380
# r
sw $s0, 0($s1)
sw $s0, 4($s1)
sw $s0, 128($s1)
sw $s0, 256($s1)
addi $s1, $s1, 16
# |
sw $s0, -128($s1)
sw $s0, 0($s1)
sw $s0, 128($s1)
sw $s0, 256($s1)
sw $s0, 384($s1)
addi $s1, $s1, 12
# q
sw $s0, 4($s1)
sw $s0, 8($s1)
sw $s0, 128($s1)
sw $s0, 136($s1)
sw $s0, 260($s1)
sw $s0, 264($s1)
sw $s0, 392($s1)
sw $s0, 520($s1)
sw $s0, 524($s1)
lw $s2, 8($sp)
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 12
jr $ra
playBackgroundMusic:
addi $sp, $sp, -8
sw $s0, ($sp)
sw $s1, 4($sp)
li $s1, 16
div $t7, $s1
mfhi $s0
bne $s0, 0, endPlayBgMusic
li $v0, 42
li $a0, 0
li $a1, 10
syscall
addi $a0, $a0, 60 # pitch
li $a1, 3000 # duration
li $a2, 0 # instrument
li $a3, 20 # volume
li $v0, 31
syscall
endPlayBgMusic:
addi $t7, $t7, 1
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 8
jr $ra
playGameOverSound:
li $a0, 80 # pitch
li $a1, 2000 # duration
li $a2, 127 # instrument
li $a3, 64 # volume
li $v0, 31
syscall
jr $ra
playRetrySound:
li $a0, 80 # pitch
li $a1, 1500 # duration
li $a2, 125 # instrument
li $a3, 64 # volume
li $v0, 31
syscall
jr $ra
playJumpSound:
li $a0, 100 # pitch
li $a1, 1000 # duration
li $a2, 121 # instrument
li $a3, 64 # volume
li $v0, 31
syscall
jr $ra
playSpringSound:
li $a0, 75 # pitch
li $a1, 1000 # duration
li $a2, 123 # instrument
li $a3, 64 # volume
li $v0, 31
syscall
jr $ra
playCloudSound:
li $a0, 75 # pitch
li $a1, 1000 # duration
li $a2, 126 # instrument
li $a3, 64 # volume
li $v0, 31
syscall
jr $ra
playJetpackSound:
li $a0, 50 # pitch
li $a1, 10000 # duration
li $a2, 123 # instrument
li $a3, 64 # volume
li $v0, 31
syscall
jr $ra
playBrokenSound:
li $a0, 60 # pitch
li $a1, 1000 # duration
li $a2, 121 # instrument
li $a3, 64 # volume
li $v0, 31
syscall
jr $ra
movePlatforms:
addi $sp, $sp, -4
sw $ra, ($sp)
blt $t6, 128, contMovePlatforms
li $t6, -128
contMovePlatforms:
blt $t6, 0, moveRight
jal movePlatsLeft
j endMovePlatforms
moveRight:
jal movePlatsRight
endMovePlatforms:
lw $ra, ($sp)
addi $sp, $sp, 4
jr $ra
movePlatsRight:
addi $sp, $sp, -12
sw $s0, ($sp)
sw $s1, 4($sp)
sw $s2, 8($sp)
addi $t6, $t6, 4
li $s0, 4864
loopMovePlatsRight:
beq $s0, 764, endMovePlatsRight
lw $s1, gameMatrix($s0)
bne $s1, 6, contMovePlatsRight
addi $s2, $s0, 4
sw $zero, gameMatrix($s0)
sw $s1, gameMatrix($s2)
contMovePlatsRight:
addi $s0, $s0, -4
j loopMovePlatsRight
endMovePlatsRight:
lw $s2, 8($sp)
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 12
jr $ra
movePlatsLeft:
addi $sp, $sp, -12
sw $s0, ($sp)
sw $s1, 4($sp)
sw $s2, 8($sp)
addi $t6, $t6, 4
li $s0, 768
loopMovePlatsLeft:
beq $s0, 4864, endMovePlatsLeft
lw $s1, gameMatrix($s0)
bne $s1, 6, contMovePlatsLeft
addi $s2, $s0, -4
sw $zero, gameMatrix($s0)
sw $s1, gameMatrix($s2)
contMovePlatsLeft:
addi $s0, $s0, 4
j loopMovePlatsLeft
endMovePlatsLeft:
lw $s2, 8($sp)
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 12
jr $ra
drawScoreMeter:
addi $sp, $sp, -12
sw $s0, ($sp)
sw $s1, 4($sp)
sw $s2, 8($sp)
lw $s2, scoreMeterColor
div $s0, $t5, 24
drawScoreMeterLoop:
beq $s0, 0, endDrawScoreMeter
mul $s1, $s0, -128
add $s1, $s1, $gp
add $s2, $s2, -5 # gradient
sw $s2, 3972($s1)
addi $s0, $s0, -1
j drawScoreMeterLoop
endDrawScoreMeter:
lw $s2, 8($sp)
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 12
jr $ra
drawJumpMeter:
addi $sp, $sp, -12
sw $s0, ($sp)
sw $s1, 4($sp)
sw $s2, 8($sp)
lw $s2, jumpMeterColor
div $s0, $t2, 3
drawJumpMeterLoop:
beq $s0, 0, endDrawJumpMeter
mul $s1, $s0, -128
add $s1, $s1, $gp
add $s2, $s2, 5 # gradient
sw $s2, 4088($s1)
addi $s0, $s0, -1
j drawJumpMeterLoop
endDrawJumpMeter:
lw $s2, 8($sp)
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 12
jr $ra
spawnJetpack:
addi $sp, $sp, -8
sw $s0, ($sp)
sw $s1, 4($sp)
li $s1, 5 # 5 represents jetpack
addi $s0, $t4, -128
sw $s1, gameMatrix($s0)
addi $s0, $s0, -128
sw $s1, gameMatrix($s0)
addi $s0, $s0, -128
sw $s1, gameMatrix($s0)
addi $s0, $s0, 132
sw $s1, gameMatrix($s0)
addi $s0, $s0, 132
sw $s1, gameMatrix($s0)
addi $s0, $s0, -128
sw $s1, gameMatrix($s0)
addi $s0, $s0, -128
sw $s1, gameMatrix($s0)
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 8
jr $ra
# a0 platform type
spawnPlatform:
addi $sp, $sp, -4
sw $s0, ($sp)
move $s0, $t4
sw $a0, gameMatrix($s0) # spawn platform
addi $s0, $s0, 4
sw $a0, gameMatrix($s0)
addi $s0, $s0, 4
sw $a0, gameMatrix($s0)
addi $s0, $s0, 4
sw $a0, gameMatrix($s0)
addi $s0, $s0, 4
sw $a0, gameMatrix($s0)
lw $s0, ($sp)
addi $sp, $sp, 4
jr $ra
# $a0 random position on platform
spawnSpring:
addi $sp, $sp, -8
sw $s0, ($sp)
sw $s1, 4($sp)
mul $s0, $a0, 4 # multiply random num by 4
add $s0, $s0, $t4 # get coords of platform
addi $s0, $s0, -128 # spawn above platform
li $s1, 2 # 2 represents spring
sw $s1, gameMatrix($s0)
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 8
jr $ra
# $a0 reference in game matrix coord
removePlatform:
addi $sp, $sp, -16
sw $s0, ($sp)
sw $s1, 4($sp)
sw $s2, 8($sp)
sw $s3, 12($sp)
lw $s0, gameMatrix($a0) # load reference pixel to know which platform it is
li $s1, -16 # iterate all possibilities of a 4 wide platform
removeLoop:
beq $s1, 20, finishRemove
add $s3, $a0, $s1 # current coord we are looking at
lw $s4, gameMatrix($s3) # load contents of current pixel
bne $s4, $s0, contRemoveLoop # check if same as reference
sw $zero, gameMatrix($s3)
contRemoveLoop:
addi $s1, $s1, 4
j removeLoop
finishRemove:
lw $s3, 12($sp)
lw $s2, 8($sp)
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 16
jr $ra
spawnObstacle:
addi $sp, $sp, -8
sw $ra, ($sp)
sw $s0, 4($sp)
bge $t4, 768, endSpawnObstacle
# RNG for type of obstacle
li $v0, 42
li $a0, 0
li $a1, 30
syscall
blt $a0, 13, spawnNext1
li $a0, 1 # 1 represents standard platform
jal spawnPlatform
j endSpawn
spawnNext1:
blt $a0, 9, spawnNext2
# spawn standard platform and broken platform below
li $a0, 1 # 1 represents standard platform
jal spawnPlatform
# RNG to spawn broken platform
li $v0, 42
li $a0, 0
li $a1, 64
syscall
move $s0, $a0
mul $s0, $s0, 4 # coord form
addi $s0, $s0, 256 # lower bound
add $t4, $t4, $s0 # set platform spawn pos
li $a0, 3 # 3 represents broken platform
jal spawnPlatform
mul $s0, $s0, -1
add $t4, $t4, $s0 # revert original t4
j endSpawn
spawnNext2:
blt $a0, 6, spawnNext3
li $a0, 4 # 4 represents cloud platform
jal spawnPlatform
j endSpawn
spawnNext3:
blt $a0, 5, spawnNext4
li $a0, 6 # 6 represents moving platform
jal spawnPlatform
j endSpawn
spawnNext4:
blt $a0, 4, spawnNext5
li $a0, 1
jal spawnPlatform
jal spawnJetpack
j endSpawn
spawnNext5:
li $a0, 1
jal spawnPlatform
jal spawnSpring
j endSpawn
endSpawn:
# RNG for next platform
li $v0, 42
li $a0, 0
li $a1, 192
syscall
mul $a0, $a0, 4 # coord form
add $a0, $a0, $t5 # apply difficulty as spacing
addi $t4, $a0, 768 # apply offset for buffer
bgt $t5, 712, endSpawnObstacle # difficulty cap
addi $t5, $t5, 4 # increase difficulty
endSpawnObstacle:
lw $s0, 4($sp)
lw $ra, ($sp)
addi $sp, $sp, 8
jr $ra
scrollWorld:
addi $sp, $sp, -20
sw $ra, ($sp)
sw $s0, 4($sp)
sw $s1, 8($sp)
sw $s2, 12($sp)
sw $s3, 16($sp)
addi $t4, $t4, -128 # update scroll timer
li $s0, 4864
scroll:
blt $s0, $zero, endScrollWorld
lw $s1, gameMatrix($s0)
addi $s2, $s0, 128 # scroll amount
sw $s1, gameMatrix($s2)
addi $s0, $s0, -4
j scroll
endScrollWorld:
lw $s3, 16($sp)
lw $s2, 12($sp)
lw $s1, 8($sp)
lw $s0, 4($sp)
lw $ra, ($sp)
addi $sp, $sp, 20
jr $ra
drawWorld:
addi $sp, $sp, -20
sw $ra, ($sp)
sw $s0, 4($sp)
sw $s1, 8($sp)
sw $s2, 12($sp)
sw $s3, 16($sp)
li $s0, 0
drawLoop:
beq $s0, 4096, endDrawWorld
addi $s2, $s0, 768 # matrix coords by applying offset
lw $s1, gameMatrix($s2) # get value at coords
add $s2, $s0, $gp # get address at coords
beq $s1, 0, dBackground
beq $s1, 1, dPlatform
beq $s1, 2, dSpring
beq $s1, 3, dBrokenPlatform
beq $s1, 4, dCloudPlatform
beq $s1, 5, dJetpack
beq $s1, 6, dMovingPlatform
j contDrawLoop
dBackground:
lw $s3, backgroundColor
div $s1, $s0, 40 # gradient
add $s3, $s3, $s1
j contDrawLoop
dPlatform:
lw $s3, platformColor
j contDrawLoop
dSpring:
lw $s3, springColor
j contDrawLoop
dBrokenPlatform:
lw $s3, brokenPlatformColor
j contDrawLoop
dCloudPlatform:
lw $s3, cloudPlatformColor
j contDrawLoop
dJetpack:
lw $s3, jetpackColor
j contDrawLoop
dMovingPlatform:
lw $s3, movingPlatformColor
j contDrawLoop
contDrawLoop:
sw $s3, ($s2)
addi $s0, $s0, 4
j drawLoop
endDrawWorld:
lw $s3, 16($sp)
lw $s2, 12($sp)
lw $s1, 8($sp)
lw $s0, 4($sp)
lw $ra, ($sp)
addi $sp, $sp, 20
jr $ra
moveDoodler:
addi $sp, $sp, -4
sw $ra, ($sp)
li $t1, 0 # reset velocity
jal checkKeyboardInput
bne $t2, $zero, jumping
addi $t1, $t1, 128 # apply gravity
jal checkDoodlerCollision
j endMoveDoodler
jumping:
addi $t1, $t1, -128
addi $t2, $t2, -1
endMoveDoodler:
add $t0, $t0, $t1 # move doodler based on velocity
lw $ra, ($sp)
addi $sp, $sp, 4
jr $ra
checkDoodlerCollision:
addi $sp, $sp, -20
sw $s0, ($sp)
sw $s1, 4($sp)
sw $s2, 8($sp)
sw $s3, 12($sp)
sw $ra, 16($sp)
addi $s0, $t0, 768 # current pos in game matrix coords
li $s3, 384 # check left, middle and right
checkCollisions:
beq $s3, 396, endCheckCollisions
add $s1, $s0, $s3
lw $s2, gameMatrix($s1)
beq $s2, 1, standardPlatformCollision
beq $s2, 2, springCollision
beq $s2, 3, brokenPlatformCollision
beq $s2, 4, cloudPlatformCollision
beq $s2, 5, jetpackCollision
beq $s2, 6, standardPlatformCollision
addi $s3, $s3, 4 # increase iterator
j checkCollisions
standardPlatformCollision:
addi $t1, $t1, -128 # cancel gravity
lw $t2, doodlerJumpDuration # start jump
jal playJumpSound
j endCheckCollisions
springCollision:
addi $t1, $t1, -128 # cancel gravity
lw $t2, springBoostDuration # start jump with higher duration
jal playSpringSound
j endCheckCollisions
brokenPlatformCollision:
# remove broken platform
move $a0, $s1
jal removePlatform
jal playBrokenSound
j endCheckCollisions
cloudPlatformCollision:
addi $t1, $t1, -128 # cancel gravity
lw $t2, doodlerJumpDuration # start jump
# remove cloud platform
move $a0, $s1
jal removePlatform
jal playCloudSound
j endCheckCollisions
jetpackCollision:
lw $t2, jetpackBoostDuration
jal playJetpackSound
j endCheckCollisions
endCheckCollisions:
lw $ra, 16($sp)
lw $s3, 12($sp)
lw $s2, 8($sp)
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 20
jr $ra
checkKeyboardInput:
addi $sp, $sp, -8
sw $s0, ($sp)
sw $s1, 4($sp)
lw $s0, 0xffff0000
beq $s0, 1, inputDetected
j endCKI
inputDetected:
lw $s1, 0xffff0004
beq $s1, 0x6A, jPressed
beq $s1, 0x6B, kPressed
j endCKI
jPressed:
addi $t1, $t1, -8
j endCKI
kPressed:
addi $t1, $t1, 8
endCKI:
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 8
jr $ra
drawDoodler:
addi $sp, $sp, -8
sw $s0, ($sp)
sw $s1, 4($sp)
lw $s1, doodlerColor
add $s0, $gp, $t0
sw $s1, 128($s0)
sw $s1, 136($s0)
sw $s1, 256($s0)
sw $s1, 264($s0)
lw $s1, doodlerSecondaryColor
sw $s1, 4($s0)
sw $s1, 132($s0)
lw $s1, 4($sp)
lw $s0, ($sp)
addi $sp, $sp, 8
jr $ra
sleep:
li $v0, 32
lw $a0, sleepDuration
syscall
jr $ra