-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoodlejump.s
2248 lines (2130 loc) · 64 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: Nathan DeGoey, 1006314329
#
# 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?
# (See the assignment handout for descriptions of the milestones)
# - Milestone 5 (choose the one the applies)
#
# Which approved additional features have been implemented?
# (See the assignment handout for the list of additional features)
# 1. Game Over
# 2. Player names
# 3. On Screen Notifications
# 4. Sound and Background Music
# 5. Scoreboard
# 6. Fancier Graphics (somewhat)
#
#
# Any additional information that the TA needs to know:
# - hope you enjoy my game!
#
#####################################################################
.data
displayAddress: .word 0x10008000
offsetDisplayAddress: .word 0x10008014
lowerAddress: .word 0x10008c04
offsetLowerAddress: .word 0x10008c18
offsetLowerAddress2: .word 0x10008c30
offsetLowerAddress3: .word 0x10008c48
bufferAddress: .word 0x10008000 #fix for the flashiness
bottomRightAddress: .word 0x10008ffc
bottomBarrier: .word 31 #the bottom barrier of the display
sky: .word 0xe6eff4
platform: .word 0x3f1736
doodler: .word 0xfa8072
title: .word 0x4ee018
letter: .word 0x0a1ba9
doodler_XPos: .word 14 #the X position of the base of the doodler (should be 14)
doodler_YPos: .word 28 #the Y position of the base of the doodler (should be 28)
startPlat_X: .word 13 #(should be 13)
startPlat_Y: .word 29 #start at the bottom of the display (should be 29)
platOne_X: .space 4 #reserve space in memory for the X value of platform one
platOne_Y: 23 #reserve space in memory for the Y value of platform one
platTwo_X: .space 4
platTwo_Y: 17
platThree_X: .space 4
platThree_Y: 11
platFour_X: .space 4
platFour_Y: 5
maxJump: .word 10 #set the max height to 10
jumpHeight: .word 0 #used to count where in the jump the doodler currently is
maxPlatShift: .word 8 #set the max shift of the platforms to 6
shiftHeight: .word 0 #used to count how much the platform as shifted so far
current_pop_up: .word 0 #used to store the number containing the current pop up, which will be updated when a new
#platform is landed on and checked everytime the screen is looped.
purple_colour: .word 0xb21bd0
red_colour: .word 0xdd254f
orange_colour: .word 0xff763b
pop_up_colour: .word 0xb21bd0 #default is purple
#values for the scoreboard
ones_digit: .word 0 #set the digit to a starting value of 0
tens_digit: .word 0 #set the digit to a starting value of 0
note: .word 77 #idea: an array of notes that the loop goes through during gameplay. The notes are
# a simple 8-bit type song. Values found in MIDI doc and Youtube video.
notes: .space 96
notes_ind: .word 0 #curr index in the notes array. starts at 0. Will get incremented in the loop
max_notes_ind: .word 96
curr_note: .word 0
#sound library
E_note: .word 76#64
F_note: .word 77#65
G_note: .word 79#67
A_note: .word 81#69
#player name. Start the letters off by painting A (value 1).
first_letter: .word 1
second_letter: .word 1
third_letter: .word 1
fourth_letter: .word 1
letter_count: .word 0 #the count of how many letters are currently counted
#these are saved here for the reset
orgdoodler_XPos: .word 14 #the X position of the base of the doodler (should be 14)
orgdoodler_YPos: .word 28 #the Y position of the base of the doodler (should be 28)
orgstartPlat_X: .word 13 #(should be 13)
orgstartPlat_Y: .word 29 #start at the bottom of the display (should be 29)
orgplatOne_X: .space 4 #reserve space in memory for the X value of platform one
orgplatOne_Y: 23 #reserve space in memory for the Y value of platform one
orgplatTwo_X: .space 4
orgplatTwo_Y: 17
orgplatThree_X: .space 4
orgplatThree_Y: 11
orgplatFour_X: .space 4
orgplatFour_Y: 5
.text
main:
jal PAINTWELCOME #paint the welcome screen when the system is booted up
j check_s_input #immediately check for keyboard input to start the game
main2:
j check_s_inputAgain #if game over, then wait for s input again to keep playing
Exit:
li $v0, 10 # terminate the program gracefully
syscall
PAINTWELCOME:
#paint the sky for the welcome screen
lw $t0, displayAddress # $t0 stores the base address for display. PERSONAL CONVENTION...THIS WILL ALWAYS BE TRUE
lw $t1, sky # $t1 stores the background colour code
lw $t4, bottomRightAddress # $t4 stores the last address for display
addi $sp, $sp, -4 #add space to the stack for storing $ra
sw $ra, 0($sp) #push the value of $ra onto the stack
jal SKY #jump to SKY and set a new $ra to return back here
#draw the starting platform
jal STORESTARTXY
jal DRAWPLATFORM
#draw the doodler
lw $t3, doodler # $t3 stores the sprite colour code
jal DRAWDOODLER
jal PAINTWELCOMETEXT
lw $ra, 0($sp) #Since $ra has been changed from the jump to all of the above functions, load the proper one back into $ra
addi $sp, $sp, 4 #return the stack pointer to the start of the stack
jr $ra #jump back to main
check_s_inputAgain:
lw $t8, 0xffff0000 #store the keyboard register in t8
beq $t8, 1, s_inputAgain #check if t8 is equal to 1. If it is, then branch to keyboard_input
j check_s_inputAgain
check_s_input:
lw $t8, 0xffff0000 #store the keyboard register in t8
beq $t8, 1, s_input #check if t8 is equal to 1. If it is, then branch to keyboard_input
j check_s_input
s_inputAgain:
lw $t7, 0xffff0004
beq $t7, 0x73, respond_to_sAgain #s
j check_s_input #put this in a loop so that it waits for the proper keys to be pressed
s_input:
lw $t7, 0xffff0004
beq $t7, 0x73, respond_to_s #s
j check_s_input #put this in a loop so that it waits for the proper keys to be pressed
respond_to_sAgain: #start the game
jal RESET #since this method happens when teh game is started again, reset everything and start again
j SETUP #this may be unnecessary
j LOOP
respond_to_s: #start the game
jal get_player_name
j SETUP #this may be unnecessary
j LOOP
keyboard_input:
lw $t7, 0xffff0004
beq $t7, 0x6a respond_to_j #j
beq $t7, 0x6b, respond_to_k #k
j LOOP #either j LOOP or jr $ra
respond_to_j:
lw $a1, doodler_XPos #load the current y-pos of the doodler into $a1
li $a0, 1
beq $a1, $a0, SKIP #do not allow the doodler to cross the screen
addi $a1, $a1, -1 #add 1 to the y-pos of the doodler into $a1
sw $a1, doodler_XPos #update doodler_YPos with the updated YPos
j LOOP #not sure if this should be jr $ra or j LOOP
respond_to_k:
lw $a1, doodler_XPos #load the current y-pos of the doodler into $a1
li $a0, 29
beq $a1, $a0, SKIP #do not allow the doodler to cross the screen
addi $a1, $a1, 1 #add 1 to the y-pos of the doodler into $a1
sw $a1, doodler_XPos #update doodler_YPos with the updated YPos
j LOOP #not sure if this should be jr $ra or j LOOP
SKIP:
j LOOP #jump back to the loop if this method is reached
get_player_name:
#a method that will check for keyboard input before starting the game to check for the player name
#the name can be maximum 4 letters, and after the fourth letter is chosen, the game automatically starts
#each letter will fill the specified index in memory for the player name.
lw $t8, 0xffff0000 #store the keyboard register in t8
beq $t8, 1, player_name_input #check if t8 is equal to 1. If it is, then branch to player_name_input
j get_player_name #put this in a loop until all four letters are spelt out
player_name_input:
lw $t7, 0xffff0004
lw $t9, letter_count #t9 holds the current letter count
#need a response to every lowercase letter of english alphabet
beq $t7, 0x61, store_a
beq $t7, 0x62, store_b
beq $t7, 0x63, store_c
beq $t7, 0x64, store_d
beq $t7, 0x65, store_e
beq $t7, 0x66, store_f
beq $t7, 0x67, store_g
beq $t7, 0x68, store_h
beq $t7, 0x69, store_i
beq $t7, 0x6a, store_j
beq $t7, 0x6b, store_k
beq $t7, 0x6c, store_l
beq $t7, 0x6d, store_m
beq $t7, 0x6e, store_n
beq $t7, 0x6f, store_o
beq $t7, 0x70, store_p
beq $t7, 0x71, store_q
beq $t7, 0x72, store_r
beq $t7, 0x73, store_s
beq $t7, 0x74, store_t
beq $t7, 0x75, store_u
beq $t7, 0x76, store_v
beq $t7, 0x77, store_w
beq $t7, 0x78, store_x
beq $t7, 0x79, store_y
beq $t7, 0x7a, store_z
store_a:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 1
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_b:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 2
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_c:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 3
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_d:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 4
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_e:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 5
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_f:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 6
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_g:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 7
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_h:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 8
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_i:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 9
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_j:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 10 #the 10th letter of the alphabet
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_k:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 11
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_l:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 12
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_m:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 13
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_n:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 14
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_o:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 15
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_p:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 16
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_q:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 17
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_r:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 18
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_s:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 19
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_t:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 20
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_u:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 21
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_v:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 22
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_w:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 23
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_x:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 24
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_y:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 25
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_z:
#Check what value t9 holds (the letter count)
addi $t6, $zero, 26
addi $t4, $zero, 0
beq $t9, $t4, store_letter_one #0 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_two #1 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_three #2 case
addi $t4, $t4, 1
beq $t9, $t4, store_letter_four #3 case
store_letter_one:
#t6 holds the current letter, so store that value in memory
sw $t6, first_letter
#update letter count
addi $t9, $t9, 1
sw $t9, letter_count
j get_player_name #jumps back to get player name to await the next letter
store_letter_two:
#t6 holds the current letter, so store that value in memory
sw $t6, second_letter
#update letter count
addi $t9, $t9, 1
sw $t9, letter_count
j get_player_name #jumps back to get player name to await the next letter
store_letter_three:
#t6 holds the current letter, so store that value in memory
sw $t6, third_letter
#update letter count
addi $t9, $t9, 1
sw $t9, letter_count
j get_player_name #jumps back to get player name to await the next letter
store_letter_four:
#t6 holds the current letter, so store that value in memory
sw $t6, fourth_letter
#got the fourth letter, jump back to the orginal return address
jr $ra
RESET:
#function used to reset vales in memory when the game is restarted.
#do not forget to reset the jumpHeight and ShiftHeight to zero for a new game
lw $a0, orgdoodler_XPos
sw $a0, doodler_XPos
lw $a0, orgdoodler_YPos
sw $a0, doodler_YPos
lw $a0, orgstartPlat_X
sw $a0, startPlat_X
lw $a0, orgstartPlat_Y
sw $a0, startPlat_Y
lw $a0, orgplatOne_X
sw $a0, platOne_X
lw $a0, orgplatOne_Y
sw $a0, platOne_Y
lw $a0, orgplatTwo_X
sw $a0, platTwo_X
lw $a0, orgplatTwo_Y
sw $a0, platTwo_Y
lw $a0, orgplatThree_X
sw $a0, platThree_X
lw $a0, orgplatThree_Y
sw $a0, platThree_Y
lw $a0, orgplatFour_X
sw $a0, platFour_X
lw $a0, orgplatFour_Y
sw $a0, platFour_Y
#reset jumpHeight and shiftHeight
addi $a0, $zero, 0
sw $a0, jumpHeight
sw $a0, shiftHeight
#reset scoreboard
sw $a0, ones_digit
sw $a0, tens_digit
#reset current_pop_up to 0 so that there is not a pop up right away
sw $a0, current_pop_up
jr $ra
SETUP:
#SOME COMMENTS, THERE IS NO NEED TO PAINT HERE
#set the necessary registers for the call to SKY
lw $t0, displayAddress # $t0 stores the base address for display. PERSONAL CONVENTION...THIS WILL ALWAYS BE TRUE
#lw $t1, sky # $t1 stores the background colour code
#lw $t4, bottomRightAddress # $t4 stores the last address for display
#jal SKY #jump to SKY and set $ra
#set the necessary registers for the call to DRAWPLATFORM
#lw $t2, platform # $t2 stores the platform colour code https://www.color-hex.com/color/621514
jal STOREXY #randomly generate an X and Y value and store them in the stack to be used in DRAWPLATFORM
addi $t9, $zero, 0 #the index $t9 is initialized to 0
#store the X in memory
sw $a0,platOne_X($t9) #a0 contains the X value (see STOREXY)
lw $a1, platOne_Y #set a1 to the predetermined Y value that is already stored in memory
#jal DRAWPLATFORM #jump to DRAWPLATFORM and set $ra
jal STOREXY
#store the X in memory
sw $a0,platTwo_X($t9)
lw $a1, platTwo_Y
#jal DRAWPLATFORM
jal STOREXY
#store the X in memory
sw $a0,platThree_X($t9)
lw $a1, platThree_Y
#jal DRAWPLATFORM
jal STOREXY
#store the X in memory
sw $a0,platFour_X($t9)
lw $a1, platFour_Y
#jal DRAWPLATFORM
#draw the starting platform
jal STORESTARTXY
#jal DRAWPLATFORM
#draw the doodler
#lw $t3, doodler # $t3 stores the sprite colour code
#jal DRAWDOODLER
#set up the notes array. Remember, the notes are just values between 0 and 127
#load the proper note into a0
#store the contents of a0 into the notes array at index t9 (starts at 0)
#increment t9 to go to the next index of the notes array
#repeat with a new note, until notes array is filled
lw $a0, E_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, E_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, E_note
sw $a0, notes($t9)
addi $t9, $t9, 4
###
lw $a0, F_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, F_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, F_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, F_note
sw $a0, notes($t9)
addi $t9, $t9, 4
###
lw $a0, G_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, G_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, G_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, G_note
sw $a0, notes($t9)
addi $t9, $t9, 4
###
lw $a0, A_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, A_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, A_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, A_note
sw $a0, notes($t9)
addi $t9, $t9, 4
###
lw $a0, G_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, G_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, G_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, G_note
sw $a0, notes($t9)
addi $t9, $t9, 4
###
lw $a0, F_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, F_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, F_note
sw $a0, notes($t9)
addi $t9, $t9, 4
lw $a0, F_note
sw $a0, notes($t9)
###
j LOOP #once setup is finished, jump to the main loop
reset_notes_ind:
#a function to reset the notes index
#t9 should have the notes index at this point
addi $t9, $zero, 0 #reset t9 to 0
sw $t9, notes_ind #use t9 to reset the notes_ind to 0
j LOOP #jump back to the main loop
LOOP:
#start with a sleep, cause it needs its rest
li $v0, 32
li $a0, 75
syscall
jal CHECKFAIL #check for failure right at the beginning so as not to waste a loop runtime
#FUNCTION FOR PLAYING SOUND, CUT IT OUT FOR NOW BECAUSE IT WAS ANNOYING
#playsound THIS ACTUALLY WORKS, NOW JUST FIGURE OUT A WAY TO SLOW THE SOUND DOWN WHILE MAINTAINING A PLAYABLE SPEED
#lw $t9, notes_ind
#lw $t8, max_notes_ind
#beq $t9, $t8, reset_notes_ind #reset the notes_ind and jump back to the loop
#if not equal, this means that the notes_ind is still a valid index in the notes array
#lw $t7, notes($t9)
#sw $t7, curr_note
#addi $t9, $t9, 4 #update notes ind
#sw $t9, notes_ind
#everything should be set up, so now load the sound into a0 and play the sound
#li $v0, 31
#lw $a0, curr_note
#li $a1, -1 #time in miliseconds (negative values mean 1 second)
#li $a2, 80 #strings 81 - synth
#li $a3, 50 #volume
#syscall #play the note
#check for keyboard input
lw $t8, 0xffff0000 #store the keyboard register in t8
beq $t8, 1, keyboard_input #check if t8 is equal to 1. If it is, then branch to keyboard_input
#update the location of all platforms and other objects
#redraw the screen
#set the necessary registers for the call to SKY
lw $t0, displayAddress # $t0 stores the base address for display. PERSONAL CONVENTION...THIS WILL ALWAYS BE TRUE
lw $t1, sky # $t1 stores the background colour code
lw $t4, bottomRightAddress # $t4 stores the last address for display
jal SKY #jump to SKY and set $ra
jal DRAWSCORETENS #draw the current score of the tens digit and return
lw $t0, offsetDisplayAddress
jal DRAWSCOREONES #draw the current score of the ones digit and return
lw $t0, displayAddress
#draw the current pop-up
jal DRAWPOPUP
#set the necessary registers for the call to DRAWPLATFORM
lw $t2, platform # $t2 stores the platform colour code https://www.color-hex.com/color/621514
lw $t4, platOne_X #load the value of platOne_X into $t4
lw $t5, platOne_Y #load the value of platOne_Y into $t5
addi $sp, $sp, -8 #create room in the stack for the X value
sw $t4, 4($sp) #store the X-value in the stack
sw $t5, 0($sp) #store the Y-value in the stack
jal DRAWPLATFORM #jump to DRAWPLATFORM and set $ra
lw $t4, platTwo_X #load the value of platOne_X into $t4
lw $t5, platTwo_Y #load the value of platOne_Y into $t5
addi $sp, $sp, -8 #create room in the stack for the X value
sw $t4, 4($sp) #store the X-value in the stack
sw $t5, 0($sp) #store the Y-value in the stack
jal DRAWPLATFORM
lw $t4, platThree_X #load the value of platOne_X into $t4
lw $t5, platThree_Y #load the value of platOne_Y into $t5
addi $sp, $sp, -8 #create room in the stack for the X value
sw $t4, 4($sp) #store the X-value in the stack
sw $t5, 0($sp) #store the Y-value in the stack
jal DRAWPLATFORM
lw $t4, platFour_X #load the value of platOne_X into $t4
lw $t5, platFour_Y #load the value of platOne_Y into $t5
addi $sp, $sp, -8 #create room in the stack for the X value
sw $t4, 4($sp) #store the X-value in the stack
sw $t5, 0($sp) #store the Y-value in the stack
jal DRAWPLATFORM
jal STORESTARTXY
jal DRAWPLATFORM
#update the position of the doodler
lw $t3, doodler # $t3 stores the sprite colour code
jal DRAWDOODLER #important to draw the doodler before everything
lw $a0, jumpHeight #set $a0 to jumpHeight
lw $a1, maxJump #set a1 to maxJump
#first, check if the jumpHeight is at its max
beq $a0, $a1, RESETJUMPHEIGHT #if these are equal, reset the jumpHeight and come back to the loop.
bgt $a0, $zero, UPDATEJUMP #note that if a0 is gt 0, that means we are in a jumping phase, so then update the jump
#note that the code will only come here if we are not in a "jump state". This means the doodler should be falling and checking for jumps
jal DOODLERFALL
jal DRAWDOODLER #this kinda gives it a "fast moving while falling vibe"
#check all of the jump conditions to see if the sprite is on a platform
jal CHECKJUMPSTART
#go back to step 1
j LOOP #jump back to the beginning of the loop to create it infinitely
UPDATEJUMP: #update the jump height and go back to the loop
lw $a0, jumpHeight
addi $a0, $a0, 1
sw $a0, jumpHeight
#update the doodlers y position by 1
lw $a1, doodler_YPos #load the current y-pos of the doodler into $a1
addi $a1, $a1, -1 #minus 1 to the y-pos of the doodler into $a1
sw $a1, doodler_YPos #update doodler_YPos with the updated YPos
#should check here that the shiftHeight does not equal maxPlatShift
lw $t4, maxPlatShift
lw $t5, shiftHeight
beq $t4, $t5, SKIP #if the shiftHieght equals the maxPlatShift, DO NOT UPDATE, JUST GO BACK TO THE LOOP
#if we made it here, we can update the shift height for this iteration
addi $t5, $t5, 1 #add one to the shift height here
sw $t5, shiftHeight #store the updated shiftHeight back in memory
j UPDATEPLATFORMS
j LOOP
UPDATEPLATFORMS:
#each platform is "lowered" on the screen in this format:
#load the current_Y value into a1
#increment a1 by to lower it by 1 unit
#store the updated value back into the Y value of the platform
lw $a2, bottomBarrier
#for each platform position Y position, check if it is greater than the bottomBarrier, and if it is, repaint it at the top with a new X-coor
#first, check if any of the platforms need to be redrawn, in wihc case, just redraw that platform in this iteration and do not update the rest
#this hsould fix the issue that they new platforms are "falling behind" in the program
lw $a1, platFour_Y
bgt $a1, $a2, DRAWNEWPLATFORMFOUR
lw $a1, platThree_Y
bgt $a1, $a2, DRAWNEWPLATFORMTHREE
lw $a1, platTwo_Y
bgt $a1, $a2, DRAWNEWPLATFORMTWO
lw $a1, platOne_Y
bgt $a1, $a2, DRAWNEWPLATFORMONE
lw $a1, startPlat_Y
bgt $a1, $a2, DRAWNEWPLATFORMSTART
#if we have gotten here, none of them needed to be redrawn in this iteration, so update the poritions of all of them
#note that this ideally only occurs mid-jump
#update the fourth platform
lw $a1, platFour_Y
addi $a1, $a1, 1
sw, $a1, platFour_Y
#update the third platform
lw $a1, platThree_Y
addi $a1, $a1, 1
sw, $a1, platThree_Y
#update the second platform
lw $a1, platTwo_Y
addi $a1, $a1, 1
sw, $a1, platTwo_Y
#update the first platform
lw $a1, platOne_Y
addi $a1, $a1, 1
sw, $a1, platOne_Y
#update the starting platform
lw $a1, startPlat_Y
addi $a1, $a1, 1
sw $a1, startPlat_Y
j LOOP #update the platforms then jump back to the loop
DRAWNEWPLATFORMFOUR:
#load a new X and Y value into stack so that the new platform is drawn correctly
#When this method is called, a1 refers to the platforms Y position.
addi $a1, $a1, -32 #subtract enough from the platform that it appears to be spawning from the top of the display
sw $a1, platFour_Y
jal GENERATERANDOMXVALUE
#now, a0 refers to the random x value
sw $a0, platFour_X # store the new random X in memory
j LOOP
DRAWNEWPLATFORMTHREE:
#load a new X and Y value into stack so that the new platform is drawn correctly
#When this method is called, a1 refers to the platforms Y position.
addi $a1, $a1, -32 #subtract enough from the platform that it appears to be spawning from the top of the display
sw $a1, platThree_Y
jal GENERATERANDOMXVALUE
#now, a0 refers to the random x value
sw $a0, platThree_X # store the new random X in memory
j LOOP
DRAWNEWPLATFORMTWO:
#load a new X and Y value into stack so that the new platform is drawn correctly
#When this method is called, a1 refers to the platforms Y position.
addi $a1, $a1, -32 #subtract enough from the platform that it appears to be spawning from the top of the display
sw $a1, platTwo_Y
jal GENERATERANDOMXVALUE
#now, a0 refers to the random x value
sw $a0, platTwo_X # store the new random X in memory
j LOOP
DRAWNEWPLATFORMONE:
#load a new X and Y value into stack so that the new platform is drawn correctly
#When this method is called, a1 refers to the platforms Y position.
addi $a1, $a1, -32 #subtract enough from the platform that it appears to be spawning from the top of the display
sw $a1, platOne_Y
jal GENERATERANDOMXVALUE
#now, a0 refers to the random x value
sw $a0, platOne_X # store the new random X in memory
j LOOP
DRAWNEWPLATFORMSTART:
#load a new X and Y value into stack so that the new platform is drawn correctly
#When this method is called, a1 refers to the platforms Y position.
addi $a1, $a1, -32 #subtract enough from the platform that it appears to be spawning from the top of the display
sw $a1, startPlat_Y
jal GENERATERANDOMXVALUE
#now, a0 refers to the random x value
sw $a0, startPlat_X # store the new random X in memory
j LOOP
GENERATERANDOMXVALUE:
li $v0, 42
li $a0, 1 #x-value
li $a1, 25 #the maximum number will be 29. This will set the random x-coor of the platform.
syscall
jr $ra
CHECKJUMPSTART: #Now that we are here, check if the Doodler's X_Pos is in the range of the starting platform
lw $a0, doodler_YPos #load the doodler's Y pos into a0
lw $a1, startPlat_Y #load the starting platforms Y pos into a1
bne $a0, $a1, CHECKJUMPONE #check if the doodler's Y pos is the same as the starting platform's Y pos. if not, check for the next platform
lw $a2, doodler_XPos
lw $a3, startPlat_X
beq $a2, $a3, DOODLERJUMP # checks if the X_pos of the doodler aligns with the range of the platform
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
j LOOP #we've concluded that the X values don't align, so jump to LOOP
CHECKJUMPONE: #Now that we are here, check if the Doodler's X_Pos is in the range of the starting platform
lw $a0, doodler_YPos #load the doodler's Y pos into a0
lw $a1, platOne_Y #load the platforms Y pos into a1
bne $a0, $a1, CHECKJUMPTWO #check if the doodler's Y pos is the same as the starting platform's Y pos. if not, check for the next platform
lw $a2, doodler_XPos
lw $a3, platOne_X
beq $a2, $a3, DOODLERJUMP # checks if the X_pos of the doodler aligns with the range of the platform
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
j LOOP #we've concluded that the X values don't align, so jump to LOOP
CHECKJUMPTWO: #Now that we are here, check if the Doodler's X_Pos is in the range of the starting platform
lw $a0, doodler_YPos #load the doodler's Y pos into a0
lw $a1, platTwo_Y #load the platforms Y pos into a1
bne $a0, $a1, CHECKJUMPTHREE #check if the doodler's Y pos is the same as the starting platform's Y pos. if not, check for the next platform
lw $a2, doodler_XPos
lw $a3, platTwo_X
beq $a2, $a3, DOODLERJUMP # checks if the X_pos of the doodler aligns with the range of the platform
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
j LOOP #we've concluded that the X values don't align, so jump to LOOP
CHECKJUMPTHREE: #Now that we are here, check if the Doodler's X_Pos is in the range of the starting platform
lw $a0, doodler_YPos #load the doodler's Y pos into a0
lw $a1, platThree_Y #load the platforms Y pos into a1
bne $a0, $a1, CHECKJUMPFOUR #check if the doodler's Y pos is the same as the starting platform's Y pos. if not, check for the next platform
lw $a2, doodler_XPos
lw $a3, platThree_X
beq $a2, $a3, DOODLERJUMP # checks if the X_pos of the doodler aligns with the range of the platform
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
add $a3, $a3, 1
beq $a2, $a3, DOODLERJUMP
j LOOP #we've concluded that the X values don't align, so jump to LOOP
CHECKJUMPFOUR: #Now that we are here, check if the Doodler's X_Pos is in the range of the starting platform
lw $a0, doodler_YPos #load the doodler's Y pos into a0
lw $a1, platFour_Y #load the platforms Y pos into a1
bne $a0, $a1, LOOP #check if the doodler's Y pos is the same as the starting platform's Y pos. if not, go back to LOOP