-
Notifications
You must be signed in to change notification settings - Fork 2
/
badicecream10.s
1584 lines (1162 loc) · 29.8 KB
/
badicecream10.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
.include "MACROSv21.s"
.data
CHAR_POS: .half 32,16
OLD_CHAR_POS: .half 32,16
INIMIGO_POS: .half 144,176
OLD_INIMIGO_POS: .half 144,176
BLOCO_POS: .half 0,0
SCORE1: .half 0
STRING1: .string " PONTOS: FASE 1 "
STRING2: .string " PONTOS: FASE 2 "
STRING3: .string " PONTOS: FASE 3 "
STRING_VAZIA: .string " "
CRIAR_OU_QUEBRAR: .half 0
TEMPO_INICIAL: .word 0
TEMPO_ATUAL: .word 0
DIR_INIMIGO: .half 1 # anti horário = 1 horário = 0
NUM: .word 40
NOTAS: 67,250,67,250,64,250,64,250,65,250,64,250,62,250,62,250,67,250,67,250,64,250,64,250,65,250,69,250,67,250,67,250,69,250,72,250,71,250,69,250,67,250,72,250,67,250,65,250,64,250,65,250,64,250,62,250,67,210,77,39,79,250,60,250,65,250,64,250,64,250,67,250,67,250,72,250,72,250,60,250,60,250
CONTADOR_NOTAS: .word 0
.text
# a0 = endereço da imagem
# a1 = x
# a2 = y
# a3 = frame (0 ou 1)
MENU:
la a0,menu
li a1,0
li a2,0
li a3,0
call PRINT
li a3,0
call PRINT
li a3,1
ESPACO: li t1,0xFF200000
lw t0,0(t1)
andi t0,t0,0x0001
beq t0,zero,ESPACO
lw t2,4(t1)
li t0,32
beq t0,t2,SETUP
SETUP: la s7,mapacolisaof14
li s11, 1
la a0,mapfase12 # carrega o endereço do map em a0
li a1,0 # x = 0
li a2,0 # y = 0
li a3,0 # frame = 0
call PRINT # imprime o mapa
li a3,1
call PRINT
la a0,STRING1
li a1,0
li a2,5
li a3,0xFF00
li a4,1
li a7,104
ecall
la a0,STRING1
li a1,0
li a2,5
li a3,0xFF00
li a4,0
li a7,104
ecall
la a0,blueberry # carrega o endereço do map em a0
li a1,20 # x = 0
li a2,0 # y = 0
li a3,0 # frame = 0
call PRINT # imprime o mapa
li a3,1
call PRINT
SET_MUSICA:
la s5,NUM # define o endereço do número de notas
lw s6,0(s5) # le o numero de notas
la s5,NOTAS # define o endereço das notas
SET_TEMPO: li a7,30
ecall
la s1,TEMPO_INICIAL
sw a0,0(s1)
la a0,char16dir
GAME_LOOP:
call TEMPO
GAME_LOOP1:
call KEY2
GAME_LOOP2:
xori s0,s0,1
li t0,0xFF200604 # carrega em t0 a troca de frame
sw s0,0(t0) # mostra o sprite
la t0,OLD_CHAR_POS #carrega em t0 o endereço de oldcharpos
lw s10,0(t0)
# LIMPA O RASTRO #
la a0,tile_neve # carrega o endereço do tile em a0
lh a1,0(t0) # posição
lh a2,2(t0)
mv a3,s0 # carrega o frame atual
xori a3,a3,1 # inverte a3
call PRINT # imprime
j GAME_LOOP # continua o loop
KEY2: li t1,0xFF200000 #KDMMIO
lw t0,0(t1) # le bit de controle do teclado
andi t0,t0,0x0001 # mascara o bit menos significativo
beq t0,zero,FIM # se não tem tecla pressionada, vai pra FIM
lw t2,4(t1) # le o valor da tecla
li t0,'w'
beq t2,t0,CHAR_CIMA
li t0,'a'
beq t2,t0,CHAR_ESQ
li t0,'s'
beq t2,t0,CHAR_BAIXO
li t0,'d'
beq t2,t0,CHAR_DIR
li t0,32
beq t2,t0,BLOCO_GELO
TEMPO: li a7,30 # guarda o tempo atual
ecall
la s2,TEMPO_ATUAL # pega o endereço do tempo atual
sw a0,0(s2) # guarda o endereço em tempo atual
la s1,TEMPO_INICIAL # chama o endereço do tempo inicial
lw t3,0(s1)
lw t4,0(s2)
li t5,250
sub s3,t4,t3
blt s3,t5,GAME_LOOP1 # se a diferença for menor que 750, volta pro loop **********
sw t4,0(s1) # coloca o tempo atual em tempo inicial
j MUSICA
INIMIGO:
la t3,INIMIGO_POS
lh t3,0(t3)
li t4,256
beq t3,t4,CIMA_OU_ESQUERDA
la t3,INIMIGO_POS
lh t3,2(t3)
li t4,176
beq t3,t4,DIREITA_OU_ESQUERDA
la t3,INIMIGO_POS
lh t3,2(t3)
li t4,48
beq t3,t4,ESQUERDA_OU_BAIXO
la t3,INIMIGO_POS
lh t3,0(t3)
li t4,48
beq t3,t4,BAIXO_OU_DIREITA
CIMA_OU_ESQUERDA:
la t3,INIMIGO_POS
lh t3,2(t3)
li t4,48
la t1,DIR_INIMIGO
lw t2,0(t1)
li t5,0
beq t2,t5,BAIXO_OU_ESQUERDA
beq t3,t4,ESQUERDA
j CIMA
ESQUERDA_OU_BAIXO:
la t3,INIMIGO_POS
lh t3,0(t3)
li t4,48
la t1, DIR_INIMIGO
lw t2,0(t1)
li t5,0
beq t2,t5,DIREITA
beq t3,t4,BAIXO
j ESQUERDA
BAIXO_OU_DIREITA:
la t3,INIMIGO_POS
lh t3,2(t3)
la t1, DIR_INIMIGO
lw t2,0(t1)
li t5,0
beq t2,t5,CIMA
li t4,176
beq t3,t4,DIREITA
j BAIXO
BAIXO_OU_ESQUERDA:
la t3,INIMIGO_POS
lh t3,2(t3)
li t4,176
beq t3,t4,ESQUERDA
j BAIXO
DIREITA_OU_ESQUERDA:
la t3,INIMIGO_POS
lh t3,0(t3)
li t4,48
beq t3,t4,BAIXO_OU_DIREITA
la t1, DIR_INIMIGO
lw t2,0(t1)
li t5,0
beq t2,t5,ESQUERDA
j DIREITA
DIREITA:
la t2,INIMIGO_POS # carrega a posição do inimigo
la t1,CHAR_POS
lw t4,0(t1)
lw t5,0(t2)
beq t4,t5,GAME_OVER
mv a2,s7
lh t3,0(t2) # carrega a posição x do personagem
lh t4,2(t2) # carrega a posição y do personagem
li t5,16
div t3,t3,t5
div t4,t4,t5
addi t3,t3,1 # aumenta o y em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a2,a2,a1 # adiciona y ao endereço base
add a2,t3,a2 # adiciona x ao endereço base
lb s8,0(a2) # carrega o pixel
li a3,-64
beq s8,a3,VAI_PRA_ESQUERDA
li a3,0x00000000
beq s8,a3,VAI_PRA_ESQUERDA
lh t4,0(t2) # carrega o x
lh t4,0(t2) # carrega o x
addi t4,t4,16 # aumenta o x em 16
la t6,OLD_INIMIGO_POS # carrega a posição antiga
lw t3,0(t2) # pega a posição atual do inimigo e coloca em t3
sw t3,0(t6) # guarda a posição atual na posição antiga
sh t4,0(t2) # atualizando o x
la a0,inimigo_dir # carrega o sprite
li t3,2
beq t3,s11,SPRITE_2_DIR
j PRINT_INIMIGO
SPRITE_2_DIR:
la a0,inimigo2dir
j PRINT_INIMIGO
CIMA: la t2,INIMIGO_POS # carrega a posição do inimigo
lh t4,2(t2) # carrega o x
la t1,CHAR_POS
lw t4,0(t1)
lw t5,0(t2)
beq t4,t5,GAME_OVER
mv a2,s7
lh t3,0(t2) # carrega a posição x do personagem
lh t4,2(t2) # carrega a posição y do personagem
li t5,16
div t3,t3,t5
div t4,t4,t5
addi t4,t4,-1 # aumenta o y em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a2,a2,a1 # adiciona y ao endereço base
add a2,t3,a2 # adiciona x ao endereço base
lb s8,0(a2) # carrega o pixel
li a3,-64
beq s8,a3,VAI_PRA_BAIXO
li a3,0x00000000
beq s8,a3,VAI_PRA_BAIXO
lh t4,2(t2)
addi t4,t4,-16 # diminui o y em 16
la t6,OLD_INIMIGO_POS # carrega a posição antiga
lw t3,0(t2) # pega a posição atual do inimigo e coloca em t3
sw t3,0(t6) # guarda a posição atual na posição antiga
sh t4,2(t2) # arualizando o y
la a0,inimigo_cima # carrega o sprite
j PRINT_INIMIGO
ESQUERDA: la t2,INIMIGO_POS # carrega a posição do inimigo
la t1,CHAR_POS
lw t4,0(t1)
lw t5,0(t2)
beq t4,t5,GAME_OVER
mv a2,s7
lh t3,0(t2) # carrega a posição x do personagem
lh t4,2(t2) # carrega a posição y do personagem
li t5,16
div t3,t3,t5
div t4,t4,t5
addi t3,t3,-1 # aumenta o y em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a2,a2,a1 # adiciona y ao endereço base
add a2,t3,a2 # adiciona x ao endereço base
lb s8,0(a2) # carrega o pixel
li a3,-64
beq s8,a3,VAI_PRA_DIREITA
li a3,0x00000000
beq s8,a3,VAI_PRA_DIREITA
lh t4,0(t2) # carrega o x
addi t4,t4,-16 # diminui o x em 16
la t6,OLD_INIMIGO_POS # carrega a posição antiga
lw t3,0(t2) # pega a posição atual do inimigo e coloca em t3
sw t3,0(t6) # guarda a posição atual na posição antiga
sh t4,0(t2) # arualizando o x
la a0,inimigo_esq # carrega o sprite
li t3,2
beq t3,s11,SPRITE_2_ESQ
j PRINT_INIMIGO
SPRITE_2_ESQ:
la a0,inimigo2esq
j PRINT_INIMIGO
BAIXO: la t2,INIMIGO_POS # carrega a posição do inimigo
la t1,CHAR_POS
lw t4,0(t1)
lw t5,0(t2)
beq t4,t5,GAME_OVER
mv a2,s7
lh t3,0(t2) # carrega a posição x do personagem
lh t4,2(t2) # carrega a posição y do personagem
li t5,16
div t3,t3,t5
div t4,t4,t5
addi t4,t4,1 # aumenta o y em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a2,a2,a1 # adiciona y ao endereço base
add a2,t3,a2 # adiciona x ao endereço base
lb s8,0(a2) # carrega o pixel
li a3,-64
beq s8,a3,VAI_PRA_CIMA
li a3,0x00000000
beq s8,a3,VAI_PRA_CIMA
lh t4,2(t2) # carrega o y
addi t4,t4,16 # aumenta o y em 16
la t6,OLD_INIMIGO_POS # carrega a posição antiga
lw t3,0(t2) # pega a posição atual do inimigo e coloca em t3
sw t3,0(t6) # guarda a posição atual na posição antiga
sh t4,2(t2) # arualizando o y
la a0,inimigo_baixo # carrega o sprite
j PRINT_INIMIGO
VAI_PRA_CIMA:
la t1,DIR_INIMIGO
lw t2,0(t1)
xori t2,t2,1
sw t2,0(t1)
j CIMA
VAI_PRA_BAIXO:
la t1,DIR_INIMIGO
lw t2,0(t1)
xori t2,t2,1
sw t2,0(t1)
j BAIXO
VAI_PRA_DIREITA:
la t1,DIR_INIMIGO
lw t2,0(t1)
xori t2,t2,1
sw t2,0(t1)
j DIREITA
VAI_PRA_ESQUERDA:
la t1,DIR_INIMIGO
lw t2,0(t1)
xori t2,t2,1
sw t2,0(t1)
j ESQUERDA
PRINT_INIMIGO:
xori s0,s0,1
la t2,INIMIGO_POS #carrega em t0 o endereço de charpos
lh a1,0(t2) # carrega x do personagem em a1
lh a2,2(t2) # carrega y do personagem em a2
mv a3,s0 # carrega o valor do frame em a3
call PRINT # imprime o sprite
xori s0,s0,1 # troca de frame
la t2,INIMIGO_POS #carrega em t0 o endereço de charpos
lh a1,0(t2) # carrega x do personagem em a1
lh a2,2(t2) # carrega y do personagem em a2
mv a3,s0 # carrega o valor do frame em a3
call PRINT # imprime o sprite
li t0,0xFF200604 # carrega em t0 a troca de frame
sw s0,0(t0) # mostra o sprite
la t2,OLD_INIMIGO_POS #carrega em t0 o endereço de oldcharpos
# LIMPA O RASTRO #
xori s0,s0,1
la a0,tile_neve # carrega o endereço do tile em a0
lh a1,0(t2)
lh a2,2(t2)
mv a3,s0 # carrega o frame atual
call PRINT # imprime
xori s0,s0,1
la t2,OLD_INIMIGO_POS
la a0,tile_neve
lh a1,0(t2)
lh a2,2(t2)
mv a3,s0
call PRINT
j GAME_LOOP1 # continua o loop
MUSICA:
la t5,CONTADOR_NOTAS
lw t6,0(t5)
li a2,32 # define o instrumento
li a3,80 # define o volume
beq t6,s6,FIM_MUSICA_ # contador chegou no final? então vá para FIM_MUSICA
lw a0,0(s5) # le o valor da nota
lw a1,4(s5) # le a duracao da nota
li a7,31 # define a chamada de syscall
ecall # toca a nota
addi s5,s5,8 # incrementa para o endereço da próxima nota
addi t6,t6,1 # incrementa o contador de notas
sw t6,0(t5) # guarda o novo valor no contador_notas
li t5,2
beq t5,s11,INIMIGO_2
j INIMIGO # volta ao loop
FIM_MUSICA_:
la t1,CONTADOR_NOTAS
li t0,0
sw t0,0(t1)
la s5,NUM # define o endereço do número de notas
lw s6,0(s5) # le o numero de notas
la s5,NOTAS # define o endereço das notas
li t5,2
beq t5,s11,INIMIGO_2
j INIMIGO
PRINT_CHAR:
xori s0,s0,1
la t0,CHAR_POS #carrega em t0 o endereço de charpos
lh a1,0(t0) # carrega x do personagem em a1
lh a2,2(t0) # carrega y do personagem em a2
mv a3,s0 # carrega o valor do frame em a3
call PRINT # imprime o sprite
xori s0,s0,1 # troca de frame
la t0,CHAR_POS #carrega em t0 o endereço de charpos
lh a1,0(t0) # carrega x do personagem em a1
lh a2,2(t0) # carrega y do personagem em a2
mv a3,s0 # carrega o valor do frame em a3
call PRINT # imprime o sprite
FIM: j GAME_LOOP2
CHAR_ESQ: la t0,CHAR_POS # carrega em t0 o endereço do personagem
la t1,INIMIGO_POS
lw t3,0(t1)
lw t2,0(t0)
beq t3,t2,GAME_OVER
la t3,SCORE1
lh t2,0(t3)
li t4,800
beq t2,t4,FIM_FASE
# CHECA COLISÃO À ESQUERDA
mv a6,s7
lh t3,0(t0) # carrega a posição x do personagem
lh t4,2(t0) # carrega a posição y do personagem
li t5,16
div t3,t3,t5
div t4,t4,t5
addi t3,t3,-1 # descresce o x em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a6,a6,a1 # adiciona y ao endereço base
add a6,t3,a6 # adiciona x ao endereço base
lb s8,0(a6) # carrega o pixel
li a3,0x00000000 # tile preto
beq s8,a3,KEY2 # se for igual, recomeça
li a3,-64
beq s8,a3,KEY2
li a5,1
li a3,-57
bne s8,a3,CONT_ESQ # se não tiver a fruta, continua o movimento
jal PONTUACAO # muda a pontuação
li t3,0xFF # lê um tile branco
sb t3,0(a6) # o tile que antes tinha fruta, agora é um tile normal
CONT_ESQ:
la t1,OLD_CHAR_POS # carrega em t1 o endereço de oldcharpos
lw t2,0(t0)
sw t2,0(t1) # salva a posição atual do personagem em oldcharpos
la t0,CHAR_POS # carrega o x atual do personagem
lh t1,0(t0)
addi t1,t1,-16 # diminui 16 pixels
sh t1,0(t0) # salva
la a0,charesquerda
j PRINT_CHAR # manda printar o personagem
CHAR_DIR: la t0,CHAR_POS # carrega em t0 o endereço do personagem
la t1,INIMIGO_POS
lw t3,0(t1)
lw t2,0(t0)
beq t2,t3,GAME_OVER
la t3,SCORE1
lh t2,0(t3)
li t4,800
beq t2,t4,FIM_FASE
#CHECA COLISÃO À DIREITA
mv a6,s7
lh t3,0(t0) # carrega a posição x do personagem
lh t4,2(t0) # carrega a posição y do personagem
li t5,16
div t3,t3,t5
div t4,t4,t5
addi t3,t3,1 # aumenta o x em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a6,a6,a1 # adiciona y ao endereço base
add a6,t3,a6 # adiciona x ao endereço base
lb s8,0(a6) # carrega o pixel
li a3,0x00000000 # tile preto
beq s8,a3,KEY2 # se for igual, recomeça
li a3,-64
beq s8,a3,KEY2
li a5,2
li a3,-57 # tile fruta
bne s8,a3,CONT_DIR # se não tiver fruta, continua normal
jal PONTUACAO # se tem fruta, muda a pontuação
li t3,0xFF # tile branco
sb t3,0(a6) # troca o tile colorido (fruta) por branco
CONT_DIR: la t1,OLD_CHAR_POS # carrega em t1 oldcharpos
lw t2,0(t0)
sw t2,0(t1) # salva a posição atual em oldcharpos
la t0,CHAR_POS # carrega o endereço do personagem
lh t1,0(t0)
addi t1,t1,16 # aumenta 16 pixels
sh t1,0(t0) # salva
la a0,char16dir
j PRINT_CHAR # manda printar o personagem
CHAR_CIMA: la t0,CHAR_POS # carrega a posição do personagem
la t1,INIMIGO_POS
lw t3,0(t1)
lw t2,0(t0)
beq t3,t2,GAME_OVER
la t3,SCORE1
lh t2,0(t3)
li t4,800
beq t2,t4,FIM_FASE
# CHECA COLISÃO ACIMA
mv a6,s7
lh t3,0(t0) # carrega a posição x do personagem
lh t4,2(t0) # carrega a posição y do personagem
li t5,16
div t3,t3,t5
div t4,t4,t5
addi t4,t4,-1 # decresce o y em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a6,a6,a1 # adiciona y ao endereço base
add a6,t3,a6 # adiciona x ao endereço base
lb s8,0(a6) # carrega o pixel
li a3,0x00000000 # tile preto
beq s8,a3,KEY2 # se for igual, recomeça
li a3,-64
beq s8,a3,KEY2
li a5,3
li a3,-57 # tile fruta
bne s8,a3,CONT_CIMA # se não tem fruta, anda normal
jal PONTUACAO # se tem fruta, muda pontuação
li t3,0xFF # tile branco
sb t3,0(a6) # troca o tile de fruta por branco
CONT_CIMA: la t1,OLD_CHAR_POS # carrega a posição do oldcharpos
lw t2,0(t0)
sw t2,0(t1) # salva a posição do personagem em oldcharpos
la t0,CHAR_POS
lh t1,2(t0) # carrega a posição y do personagem
addi t1,t1,-16 # diminiu 16 pixels
sh t1,2(t0) # salva em charpos
la a0,charcima
j PRINT_CHAR # manda printar o personagem
CHAR_BAIXO: la t0,CHAR_POS # carrega a posição do personagem
la t1,INIMIGO_POS
lw t3,0(t1)
lw t2,0(t0)
beq t2,t3,GAME_OVER
la t3,SCORE1
lh t2,0(t3)
li t4,800
beq t2,t4,FIM_FASE
# CHECA COLISÃO EMBAIXO
mv a6,s7
lh t3,0(t0) # carrega a posição x do personagem
lh t4,2(t0) # carrega a posição y do personagem
li t5,16
div t3,t3,t5
div t4,t4,t5
addi t4,t4,1 # aumenta o y em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a6,a6,a1 # adiciona y ao endereço base
add a6,t3,a6 # adiciona x ao endereço base
lb s8,0(a6) # carrega o pixel
li a3,0x00000000 # tile preto
beq s8,a3,KEY2 # se for igual, recomeça
li a3,-64
beq s8,a3,KEY2
li a5,4
li a3,-57 # tile fruta
bne s8,a3,CONT_BAIXO # se o tile nao for fruta, anda normal
jal PONTUACAO # se o tile for fruta, muda a pontuação
li t3,0xFF # tile branco
sb t3,0(a6) # troca o tile de fruta pelo tile branco
CONT_BAIXO: la t1,OLD_CHAR_POS # carrega oldcharpos
lw t2,0(t0)
sw t2,0(t1) # salva a posição atual em oldcharpos
la t0,CHAR_POS # carrega charpos
lh t1,2(t0) # carrega a posição y do personagem
addi t1,t1,16 # aumenta 16 pixels
sh t1,2(t0) # salva en charpos
la a0,charbaixo
j PRINT_CHAR # manda printar o personagem
BLOCO_GELO:
la t0,CHAR_POS
lh t3,0(t0) # carrega a posição x do personagem
lh t4,2(t0) # carrega a posição y do personagem
li t5,16 # coloca nas dimensões do mapa de colisão
div t3,t3,t5
div t4,t4,t5
li s4,1
beq a5,s4,BLOCO_ESQ
li s4,2
beq a5,s4,BLOCO_DIR
li s4,3
beq a5,s4,BLOCO_CIMA
li s4,4
beq a5,s4,BLOCO_BAIXO
BLOCO_ESQ:
mv a6,s7
addi t3,t3,-1 # descresce o x em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a6,a6,a1 # adiciona y ao endereço base
add a6,t3,a6 # adiciona x ao endereço base
lb s8,0(a6) # carrega o pixel
li a3,0x00000000
beq a3,s8,KEY2
li a3,-1
beq s8,a3,CRIAR_BLOCO_ESQ
li a3,-64
beq s8,a3,QUEBRA_BLOCO_ESQ
BLOCO_DIR:
mv a6,s7
addi t3,t3,1 # aumenta o x em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a6,a6,a1 # adiciona y ao endereço base
add a6,t3,a6 # adiciona x ao endereço base
lb s8,0(a6) # carrega o pixel
li a3,0x00000000
beq a3,s8,KEY2
li a3,-1
beq s8,a3,CRIAR_BLOCO_DIR
li a3,-64
beq s8,a3,QUEBRA_BLOCO_DIR
BLOCO_CIMA:
mv a6,s7
addi t4,t4,-1 # diminui o y em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a6,a6,a1 # adiciona y ao endereço base
add a6,t3,a6 # adiciona x ao endereço base
lb s8,0(a6) # carrega o pixel
li a3,0x00000000
beq a3,s8,KEY2
li a3,-1
beq s8,a3,CRIAR_BLOCO_CIMA
li a3,-64
beq s8,a3,QUEBRA_BLOCO_CIMA
BLOCO_BAIXO:
mv a6,s7
addi t4,t4,1 # aumenta o y em 1
li t5,20
mul a1,t4,t5 # a1 = y * 20
add a6,a6,a1 # adiciona y ao endereço base
add a6,t3,a6 # adiciona x ao endereço base
lb s8,0(a6) # carrega o pixel
li a3,0x00000000
beq a3,s8,KEY2
li a3,-1
beq s8,a3,CRIAR_BLOCO_BAIXO
li a3,-64
beq s8,a3,QUEBRA_BLOCO_BAIXO
CRIAR_BLOCO_ESQ:
li a0,60
li a1,250
li a2,76
li a3,80
li a7,31
ecall
la a0,iceblock
la t3,CRIAR_OU_QUEBRAR
li t5,1
sh t5,0(t3)
li t3,-64 # troca a cor do tile do mapa de colisão por azul
sb t3,0(a6)
la t0,CHAR_POS
la t3,BLOCO_POS
lw s8,0(t0)
sw s8,0(t3)
lh t5,0(t3)
addi t5,t5,-16
sh t5,0(t3)
j PRINT_BLOCO
CRIAR_BLOCO_DIR:
li a0,60
li a1,250
li a2,76
li a3,80
li a7,31
ecall
la a0,iceblock
la t3,CRIAR_OU_QUEBRAR
li t5,1
sh t5,0(t3)
li t3,-64 # troca a cor do tile do mapa de colisão por azul
sb t3,0(a6)
la t0,CHAR_POS
la t3,BLOCO_POS
lw s8,0(t0)
sw s8,0(t3)
lh t5,0(t3)
addi t5,t5,16
sh t5,0(t3)
j PRINT_BLOCO
CRIAR_BLOCO_CIMA:
li a0,60
li a1,250
li a2,76
li a3,80
li a7,31
ecall
la a0,iceblock
li t3,-64 # troca a cor do tile do mapa de colisão por azul
sb t3,0(a6)
la t3,CRIAR_OU_QUEBRAR
li t5,1
sh t5,0(t3)
la t0,CHAR_POS
la t3,BLOCO_POS
lw s8,0(t0)
sw s8,0(t3)
lh t5,2(t3)
addi t5,t5,-16
sh t5,2(t3)