-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.asm
More file actions
4065 lines (2814 loc) · 65.2 KB
/
game.asm
File metadata and controls
4065 lines (2814 loc) · 65.2 KB
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: Yue Li, 1004746091, liyue42, yuee.li@mail.utoronto.ca
#
# Bitmap Display Configuration:
# - Unit width in pixels: 4 (update this as needed)
# - Unit height in pixels: 4 (update this as needed)
# - Display width in pixels: 256 (update this as needed)
# - Display height in pixels: 256 (update this as needed)
# - Base Address for Display: 0x10008000 ($gp)
#
# Which milestones have been reached in this submission?
# - Milestone 4
#
#
# Which approved features have been implemented for milestone 4?
#
# 1. Moving objects (2 marks)
# [enemies patrol left and right across on the platform they are on; pickups hovering gently up and down]
# 2. Moving platforms (2 marks)
# [Two moving platforms;]
# 3. Double jump (1 mark):
# allow the player to jump when in mid-air, but only once!
#
####
#
# Link to video demonstration for final submission:
# - https://youtu.be/kw-EAm9JxDY?si=jgWh2k4E4X0Sn_TY
#
# Are you OK with us sharing the video with people outside course staff?
# - yes, and please share this project github link as well!
#
# Any additional information that the TA needs to know:
# - (sometimes the "you won" page and gameover page takes longer to load, please try again)
# - (Display score in game over page was added later which was not included in the demo, please notice that it now displays the score earned in game over page)
#
#####################################################################
.eqv BASE_ADDRESS 0x10008000
.eqv EnemieInitialAddress 16108
# Max address (X = 59, Y = 62) 63 - 1 - 3 = 59; 63 - 1 = 62; Width = 64 => 16108
.eqv EnemieMaxPossibleBaseAddress 16108
# Min Address (X = 4, Y = 62) 15888
.eqv EnemieMinPossibleBaseAddress 15888
#
.eqv MainCharacterInitialAddress 15912
.eqv MainCharacterMaxXonGround 16116
.eqv MainCharacterMinXonGround 15880
#
.eqv MainCharacterMaxY
# .eqv PickUpsInitialAddresses
# Each 4-byte value has the following structure: 0x00RRGGBB, where 00 are just zeros, RR is
# an 8-bit colour value for the red component, GG are the 8-bits for the green components, and BB are
# the 8-bits for the blue component. For example, 0x00000000 is black,0x00ff0000 is bright red,
# 0x0000ff00 is green, and 0x00ffff00 is yellow
.eqv Orange 0x00ff7e00
.eqv BoundaryPink 0x00ffa3b1
.eqv PlatformGreen 0x00a8e61d
.eqv Black 0x00000000
.eqv Yellow 0x00fff200
.eqv CRLightBlue 0x0099d9ea
.eqv CRLightGreen 0x00d3f9bc
.eqv CRDarkGreen 0x0022b14c
.eqv EMGrey 0x00546d8e
.eqv EMRed 0x00ed1c24
.eqv EMdarkblue 0x002f3699
.eqv Sleeptime 40
.eqv NumEnemies 1
.eqv NumPickUps 3
.eqv JumpHeight 12 # units
.eqv MaxTimeJumped 2 # time before Collide with platform
.eqv FallingRate 1
.eqv JumpRate 12
.eqv platformMovingRate 1 #unitFrameBuffer
.eqv EnemieMovingRate 1
.eqv MainCharacterMovingRate 3
.eqv PickUpHoverRate 1
.eqv HeightofMainCharacter 9
.eqv RowUnit 64
.eqv LBM 16128 # (62*64+0)*4 = 16128
.eqv RBM 16124 #(62*64+63)*4 = 16124
.eqv GBM 16380 # (63*64+63)*4 = 16380
#####
.data
NumCollected: .word 0
NumFilled: .word 0
NumJumped: .word 0
EnemieState: .word 0
# Initial == 0
# Patrol Right == 1
# Collision with wall == 2
# Patrol left == 3
PickUpState1: .word 0
# ==
# == 1 ----> Erase ---> ScoreState + 1
PickUpState2: .word 0
PickUpState3: .word 0
ScoreState: .word 0
# Score == 0
# Score == 1 PaintScore1
# Score == 2 PaintScore2
# Score == 3 PaintScore3 --> GameState --> you win
######################
# Main Character 4 Signals:
Collison_with_Ground_Signal: .word 0
# A[0] Collison_with_Ground_Signal
# on_the_ground == 0 -> suspend respond_to_s;(no respond_to_s all the time?)
# in the air, could double jump == 1
# has double jumped == 2 -> suspend respond_to_w
Collision_with_Wall_Signal: .word 0
# A[1] Collision_with_Wall_Signal
# no wall == 0
# left_wall == 1 --> suspend respond_to_a
# right_Wall == 2 ---> suspend respond_to_d
Collision_with_Enemie_Signal: .word 0
# A[2] Collision_with_Enemie_Signal
# No == 0
#Yes == 1 ---> Red EFFECT --> GameOVer
Collision_with_PickUp_Signal: .word 0
# A[3] Collision_with_PickUp_Signal
# No == 0
# Yes == 1 ----> YellowEffect ----> NumCollected + 1
MainCharacterState: .word 0
# Initial/steady state == 0
# Jumping State == 1 --> detect up
# Falling State == 2 ----> detect down
GameState: .word 1
# initial == 1; win == 2; lose == 3;
# [0-63, 0-63]
# Address =
MainCRCoordinateXY: .word 0:2
PickUp1CoordinateXY: .word 22 50
# [23, 50]
PickUp2CoordinateXY: .word 35 50
# [36, 50]
PickUp3CoordinateXY: .word 54 38
# [55, 38]
EnemieInitialCoordinate: .word 31 62
EnemieCurrentCoordinate: .word 31 62
EnemieLeftMostCoordinate: .word 17 62
EnemieRightMostCoordinate: .word 46 62
# Range (Same as FLOATING PLATFORM)???
# base / central address
# [18, 63] ----[47, 63]
MainCharacterCurrentCoordinate: .word 4 62
MainCharacterInitialCoordinate: .word 4 62
MovingPlatformState: .word 1
# initial state == 0 == initial position
# Patrol right == 2
# Patrol left == 1
MovingPlatformState2: .word 1
# PatrolUp == 1
# PatrolDown == 2
MovingPlatformInitialCoordinateA: .word 48 39
# [48, 40]----[61, 40]
# Length == 14
MovingPlatformInitialCoordinateB: .word 61 39
MovingPlatformEndCoordinateA: .word 43 39
# [43, 40]------[56,40]
# Length == 14
MovingPlatformEndCoordinateB: .word 56 39
# MovingPlatformInitial [48, 40] ---- [61, 40] length = 14
# MovingPlatformEndRange [ 44, 40] ------[56, 40] length = 14
MovingPlatform2InitialCoordinateA: .word 48 29
# 27
MovingPlatform2InitialCoordinateB: .word 61 29
# 27
MovingPlatform2EndCoordinateA: .word 48 15
# 13
MovingPlatform2EndCoordinateB: .word 61 15
# 13
MovingPlatformCurrentCoordinateA: .word 48 39
MovingPlatformCurrentCoordinateB: .word 61 39
MovingPlatform2CurrentCoordinateA: .word 48 27
MovingPlatform2CurrentCoordinateB: .word 61 27
FloatingPlatformXCoordinate: .word 14 51
# [15,52] ----[49, 52] Length == 35
FloatingPlatformENDCoordinate: .word 48 51
FloatingPlatformLength: .word 35
MainCharacterCurrentAddress: .word 7 62
# IF Main Character's X coordinate less than or equal to 3, detect collision_with_left_wall
LeftWallBoundaryCoordinate: .word 2
# IF Main Character's X coordinate is greater than or equal to 62, collision_with_right_wall detected
RightWallBoundaryCoordinate: .word 61
ScoreBoxCoordinate: .word
# [2, 2] [7,2] [12,2] [17,2]
# [2, 7] [7,7] [12,7] [17,7]
ScoreBoxCoordinate1: .word 1 1
ScoreBoxCoordinate2: .word 16 1
ScoreBoxCoordinate3: .word 1 6
ScoreBoxCoordinate4: .word 16 6
ScoreBoxCoordinate5: .word 6 1
ScoreBoxCoordinate6: .word 6 6
ScoreBoxCoordinate7: .word 11 1
ScoreBoxCoordinate8: .word 11 6
FillScoreBox1Coordinate: .word 2 2
# [2,2] [5 2] ALL MINUS 1 !!!!!!!!!!!
# [2,5] [5,5]
FillScoreBox2Coordinate: .word 7 2
# [7,2] [10,2]
# [7,5] [10,5]
FillScoreBox3Coordinate: .word 12 2
# [12,2] [15,2]
# [12,5] [15,5]
DrawGameOverCoordinate: .word 14 22
DrawYouWinCoordinate: .word 10 23
###########################################################################################################
.text
.globl main
###################################################################################### MAIN STARTS HERE
main:
jal ClearScreenSetup
# GAME INITIAL SET UP
DrawInitialScreen:
# Start With DrawBoundaries Block
# WHICH draws in the order of UpperLeftGround -----> then Branch to Draw MiddlePlatform Block
# then branch to Draw Moving Platfrom Initial
# THEN BRANCH TO InitialDrawScoreBox
# Then Branch To Initial Draw PickUps
# Then Branch To initial Draw Enemie
# Then Branch to initial Draw Character
# Initial Drawing Finished
# NEXT, SET UP THE INITIAL STATES
################################ BLOCK #1 --------> DrawBoundaries
DrawBoundaries:
# This Block of Code uses all temporary registers t0 - t7 to paint the four boundaries for now
# IT ENDS THE WHOLE PROGRAM after running FOR NOW
# Draw the Upper Boundary to Pink
li $t0, BASE_ADDRESS
li $t1, BoundaryPink
# Draw the ground boundary (platform to green later [after drawing upper,left,right boundaries])
li $t7, PlatformGreen
# let t2 be the current address
move $t2, $t0
# endpoint for upper boundary painting
addi $t3, $t2, 256
# endpoint for left boundary painting 256 * 64 = 16384
addi $t4, $t0, LBM
# endpoint for right boundary painting
addi $t5, $t0, RBM
# endpoint for Ground Boundary painting
addi $t6, $t0, GBM
PaintUpperBoundary:
beq $t2, $t3, PaintLeftBoundary
sw $t1, 0($t2) # paint the first (top-left) unit pink
addi $t2, $t2, 4
j PaintUpperBoundary
PaintLeftBoundary:
# $t2 = $t0 + 256 at this time
beq $t2, $t4, PaintRightBoundaryInitial
sw $t1, 0($t2) # paint row 1 column 0 to pink
addi $t2, $t2, 256
j PaintLeftBoundary
PaintRightBoundaryInitial:
# $t2 = $t0 + LBM at this time
add $t2, $t0, 252
PaintRightBoundary:
sw $t1, 0($t2)
beq $t2, $t5, PaintGroundInitial
addi $t2, $t2, 256
j PaintRightBoundary
PaintGroundInitial:
# start from current t2 + 4
addi $t2, $t2, 4
PaintGround:
sw $t7, 0($t2)
beq $t2, $t6, DrawMiddlePlatform
addi $t2, $t2, 4
j PaintGround
################ BLOCK #1 <----------------------------
################################### BLOCK # 2------------------------------>
DrawMiddlePlatform:
# Set Up platform Length and Coordinates
la $t1, FloatingPlatformXCoordinate
# Load X coordinate
lw $t2, 0($t1)
# Load Y coordinate
lw $t3, 4($t1)
# Calculate Address
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
# StartAddress in $t4
# Get endpoint
la $t5, FloatingPlatformENDCoordinate
# Load X coordinate
lw $t6, 0($t5)
# Load Y coordinate
lw $t7, 4($t5)
# Calculate Address
move $a0, $t6
move $a1, $t7
jal CalculateAddress
move $t0, $v0
# Start Drawing
li $t7, PlatformGreen
DrawMidPlat:
bgt $t4, $t0, DrawMovingPlatformInitial
sw $t7, 0($t4)
addi $t4, $t4, 4
j DrawMidPlat
################################### BLOCK #2 <-----------------------------
################################ BLOCK # 3 ------------------------->
DrawMovingPlatformInitial:
# Set up Platform length and Moving Ranges
la $t1, MovingPlatformInitialCoordinateA
# Load X coordinate
lw $t2, 0($t1)
# Load Y coordinate
lw $t3, 4($t1)
# Calculate Address
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
# Get endpoint
la $t5, MovingPlatformInitialCoordinateB
# Load X coordinate
lw $t6, 0($t5)
# Load Y coordinate
lw $t7, 4($t5)
# Calculate Address
move $a0, $t6
move $a1, $t7
jal CalculateAddress
move $t0, $v0
StartDrawingFlot:
li $t7, PlatformGreen
DrawFlotPlatI:
bgt $t4, $t0, DrawMovingPlatform2Initial
sw $t7, 0($t4)
addi $t4, $t4, 4
j DrawFlotPlatI
# Change from branch to initial draw pickup to DRAWSCOREBOX, THEN BRANCH TO INITIAL DRAW PICKUP FROM THERE.
################################# INITIAL DRAW OF MOVING PLATFORM <----------------
################################# INITIAL DRAW OF MOVING PLATFORM 2 ------------->
DrawMovingPlatform2Initial:
# Set up Platform length and Moving Ranges
la $t1, MovingPlatform2InitialCoordinateA
# Load X coordinate
lw $t2, 0($t1)
# Load Y coordinate
lw $t3, 4($t1)
# Calculate Address
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
# Get endpoint
la $t5, MovingPlatform2InitialCoordinateB
# Load X coordinate
lw $t6, 0($t5)
# Load Y coordinate
lw $t7, 4($t5)
# Calculate Address
move $a0, $t6
move $a1, $t7
jal CalculateAddress
move $t0, $v0
StartDrawingFlot2:
li $t7, PlatformGreen
DrawFlotPlatII:
bgt $t4, $t0, InitialDrawScoreBox
sw $t7, 0($t4)
addi $t4, $t4, 4
j DrawFlotPlatII
################################# INITIAL DRAW OF MOVING PLATFORM 2 <----------------
######################### Initial DRAW THE SCORE BOX ----------------->
# BRANCH HERE FROM INITIAL MOVING PLATFORM, AND BRANCH TO INITIALDRAWPICKUP AFTER DONE IT
InitialDrawScoreBox:
la $t1, ScoreBoxCoordinate1
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
# get the starting address and saved in $t4
la $t1, ScoreBoxCoordinate2
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t5, $v0
# Get the endpoint and paint -->
li $t0, Orange
StartPaintIB1:
bgt $t4, $t5, PaintIB2
sw $t0, 0($t4)
addi $t4, $t4, 4
j StartPaintIB1
PaintIB2:
la $t1, ScoreBoxCoordinate3
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
# get the starting address and saved in $t4
la $t1, ScoreBoxCoordinate4
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t5, $v0
# Get the endpoint and paint -->
li $t0, Orange
StartPaintIB2:
bgt $t4, $t5, PaintIBV1
sw $t0, 0($t4)
addi $t4, $t4, 4
j StartPaintIB2
# start paint vertical lines FOUR(4) in total
PaintIBV1:
la $t1, ScoreBoxCoordinate1
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
# get the starting address and saved in $t4
la $t1, ScoreBoxCoordinate3
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t5, $v0
# Get the endpoint and paint -->
li $t0, Orange
StartPaintIBV1:
bgt $t4, $t5, PaintIBV2
sw $t0, 0($t4)
addi $t4, $t4, 256
j StartPaintIBV1
PaintIBV2:
la $t1, ScoreBoxCoordinate5
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
# get the starting address and saved in $t4
la $t1, ScoreBoxCoordinate6
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t5, $v0
# Get the endpoint and paint -->
li $t0, Orange
StartPaintIBV2:
bgt $t4, $t5, PaintIBV3
sw $t0, 0($t4)
addi $t4, $t4, 256
j StartPaintIBV2
PaintIBV3:
la $t1, ScoreBoxCoordinate7
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
# get the starting address and saved in $t4
la $t1, ScoreBoxCoordinate8
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t5, $v0
# Get the endpoint and paint -->
li $t0, Orange
StartPaintIBV3:
bgt $t4, $t5, PaintIBV4
sw $t0, 0($t4)
addi $t4, $t4, 256
j StartPaintIBV3
PaintIBV4:
la $t1, ScoreBoxCoordinate2
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
# get the starting address and saved in $t4
la $t1, ScoreBoxCoordinate4
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t5, $v0
# Get the endpoint and paint -->
li $t0, Orange
StartPaintIBV4:
bgt $t4, $t5, InitialDrawPickup
sw $t0, 0($t4)
addi $t4, $t4, 256
j StartPaintIBV4
# BRANCH TO InitialDrawPickup AFTER
############################# Initial SCORE BOX DRAWING <---------
######################## Initial Draw PickUps --------------->
InitialDrawPickup:
la $t1, PickUp1CoordinateXY
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
li $t5, Yellow
sw $t5, 0($t4)
sw $t5, -260($t4)
sw $t5, -252($t4)
sw $t5, -512($t4)
sw $t5, -764($t4)
sw $t5, -772($t4)
la $t1, PickUp2CoordinateXY
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
li $t5, Yellow
sw $t5, 0($t4)
sw $t5, -260($t4)
sw $t5, -252($t4)
sw $t5, -512($t4)
sw $t5, -764($t4)
sw $t5, -772($t4)
la $t1, PickUp3CoordinateXY
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t4, $v0
li $t5, Yellow
sw $t5, 0($t4)
sw $t5, -260($t4)
sw $t5, -252($t4)
sw $t5, -512($t4)
sw $t5, -764($t4)
sw $t5, -772($t4)
j InitialDrawEnemie
################################### Initial Draw Pick Ups <------------
##################### Initial Draw Enemie ---------------->
InitialDrawEnemie:
la $t0, EnemieInitialCoordinate
lw $t1, 0($t0)
lw $t2, 4($t0)
move $a0, $t1
move $a1, $t2
jal CalculateAddress
move $t1, $v0
# Get Colors
li $t7, EMGrey
li $t6, EMRed
li $t5, EMdarkblue
# Draw Bottom layer (1)
sw $t7, 0($t1)
sw $t7, 8($t1)
sw $t7, 12($t1)
sw $t7, -8($t1)
sw $t7, -12($t1)
sw $t5, 4($t1)
sw $t5, -4($t1)
# Draw Layer (2)
sw $t6, -252($t1)
sw $t6, -260($t1)
sw $t7, -248($t1)
sw $t7, -264($t1)
# lw $t7, 0($t1) Black no need to draw
# Draw Layer (3)
sw $t7, -516($t1)
sw $t7, -508($t1)
#lw $t7, 0($t1) Black no need to draw
# Draw Layer (4)
sw $t7, -768($t1)
j InitialDrawCharacter
# Branch to Initial Draw Character After it done
############################### Initial Draw Enemie <------------
################### Initial Draw Main Character ---------------->
InitialDrawCharacter:
la $t1, MainCharacterInitialCoordinate
lw $t2, 0($t1)
lw $t3, 4($t1)
move $a0, $t2
move $a1, $t3
jal CalculateAddress
move $t2, $v0
# t2 as the base address
li $t5, CRLightBlue
li $t6, CRLightGreen
# Draw Middle Line
sw $t5, 0($t2)
sw $t5, -256($t2)
sw $t5, -512($t2)
sw $t5, -768($t2)
sw $t6, -1024($t2)
sw $t6, -1280($t2)
sw $t6, -1536($t2)
sw $t5, -1792($t2)
sw $t5, -2048($t2)
sw $t5, 4($t2)
sw $t5, -772($t2)
sw $t6, -1276($t2)
sw $t5, -1540($t2)
sw $t5, -1796($t2)
sw $t5, -4($t2)
sw $t5, -764($t2)
sw $t6, -1284($t2)
sw $t5, -1532($t2)
sw $t5, -1788($t2)
# Finish Drawing
j InitializeState
########################### Initial Draw Main Character <----------
############
# for each iteration:
#• Check for keyboard input.
#• Figure out if the player character is standing on a platform.
#• Update player location, enemies, platforms, power ups, etc.
#• Check for various collisions (e.g., between playerand enemies).
#• Update other game state and end of game.
#• Erase objects from the old position on the screen.
#• Redraw objects in the new position on the screen.
# sleep for a short time and loop again...
############
InitializeState:
# Set up Game State
# Initial State should == 1
la $t1, GameState
li $t2, 1
sw $t2, 0($t1)
# 2. Set up MovingPlatformState
la $t1, MovingPlatformState
li $t2, 1 # patrol left == 1, right == 2
sw $t2, 0($t1)
# 3. Set up EnemieState
la $t1, EnemieState
li $t2, 2 # patrol left == 1, right == 2
sw $t2, 0($t1)
# 4. Set up all the signals
la $t1, Collison_with_Ground_Signal
sw $zero, 0($t1)
la $t1, Collision_with_Wall_Signal
li $t2, 1
sw $t2, 0($t1)
la $t1, Collision_with_Enemie_Signal
sw $zero, 0($t1)
la $t1, Collision_with_PickUp_Signal
sw $zero, 0($t1)
### Check if the signals match!!!
# Set PickUps States
la $t1, PickUpState1
sw $zero, 0($t1)
la $t1, PickUpState2
sw $zero, 0($t1)
la $t1, PickUpState3
sw $zero, 0($t1)
# Set Score State
la $t1, ScoreState
sw $zero, 0($t1)
# Set Main Character State
la $t1, MainCharacterState
sw $zero, 0($t1)
# Set initial Num Collected
la $t1, NumCollected
sw $zero, 0($t1)
# Set initial Num Filled
la $t1, NumFilled
sw $zero, 0($t1)
# Reset pickup1 initial coordinates
la $t1, PickUp1CoordinateXY
li $t2, 22
sw $t2, 0($t1)
li $t2, 50
sw $t2, 4($t1)
# Reset pickup2 initial coordinates
la $t1, PickUp2CoordinateXY
li $t2, 35
sw $t2, 0($t1)
li $t2, 50
sw $t2, 4($t1)
# Reset pickup3 initial coordinates
la $t1, PickUp3CoordinateXY
li $t2, 54
sw $t2, 0($t1)