-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.asm
1750 lines (1517 loc) · 40.1 KB
/
project.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.model small
.data
fire_reached db 0
origin_x_fire dw 0
origin_y_fire dw 0
mario_colliding_with_fire db 0
row_number db ?
column_number db ?
x_coord_reactangle dw ?
y_coord_reactangle dw ?
length_of_reactangle dw ?
height_of_reactangle dw ?
origin_x_character dw ?
origin_y_character dw ?
origin_x_enemy1 dw 0
origin_y_enemy1 dw 0
origin_x_enemy2 dw 0
origin_y_enemy2 dw 0
origin_x_monster dw 0
origin_y_monster dw 0
color_monster db 0
height_triangle dw 0
x_coord_triangle dw 0
y_coord_triangle dw 0
color_triangle db 3
counter_triangle dw 1
draw_counter db 0
add_or_sub db 0
draw_counter2 db 0
add_or_sub2 db 0
draw_counter3 db 0
add_or_sub3 db 0
draw_counter4 db 0
color_reactangle db ?
color_for_whole_screen db ?
binary_check db 1
remainder db ?
enter_key_to_continue db "Press ENTER key to continue the game.","$"
ending db "Game ended!!! Thanks for playing!",'$'
game_name DB "S U P E R M A R I O",'$'
lets_play DB "Press ENTER key to play game",'$'
arr db "please enter your name: ",'$'
user_name db 100 DUP(?)
game_level db 1
game_score db 0
display_score db "Score = ","$"
display_level db "Level = ","$"
display_level_completed db "Level completed","$"
display_all_levels_completed db "Congratulations!!! You have passed all the levels.","$"
display_exit_string db "Press Enter key to Exit.","$"
display_lives db "Lives = ","$"
does_it_collide db 0
collision_occuring_ONE db 0
lives db 3
lost_a_live db ". You have lost a life!","$"
you_lost_all_lives db "You have Lost all your lifes.","$"
print_stars db "* * * *","$"
.stack 100h
.code
jmp start
delay proc ;the procedure to delay the program
push ax
push bx
push cx
push dx
mov cx,1000
mydelay:
mov bx,300 ;; increase this number if you want to add more delay, and decrease this number if you want to reduce delay.
mydelay1:
dec bx
jnz mydelay1
loop mydelay
pop dx
pop cx
pop bx
pop ax
ret
delay endp
clear_entire_graphics proc
mov color_reactangle,0
mov height_of_reactangle,480
mov length_of_reactangle,640
mov x_coord_reactangle,0
mov y_coord_reactangle,0
call draw_reactangle
ret
clear_entire_graphics endp
draw_reactangle proc
push x_coord_reactangle;backing of coordinates
push y_coord_reactangle
mov cx,0
mov dx,0
mov al, color_reactangle
mov bh, 0
mov cx,height_of_reactangle
next_row:
push x_coord_reactangle
push cx
mov cx,length_of_reactangle
draw_lines:
push cx
mov ah, 0ch
mov cx, x_coord_reactangle
mov dx, y_coord_reactangle
int 10h
inc x_coord_reactangle
pop cx
loop draw_lines
inc y_coord_reactangle
pop cx
pop x_coord_reactangle
loop next_row
pop y_coord_reactangle
pop x_coord_reactangle
ret
draw_reactangle endp
draw_triangle proc
push x_coord_triangle
push y_coord_triangle
mov cx,0
mov dx,0
mov bh, 0
mov al, color_triangle
mov cx,height_triangle
outer2:
push cx
push x_coord_triangle
mov cx,0
mov cx,counter_triangle
inner2:
push cx
mov cx,0
mov ah, 0ch
mov cx, x_coord_triangle
mov dx, y_coord_triangle
inc x_coord_triangle
int 10h
pop cx
loop inner2
pop x_coord_triangle ;restorig the starting point
sub x_coord_triangle,1
add counter_triangle,2 ;for making it triangle
inc y_coord_triangle ;for next line
pop cx
loop outer2
mov bx,1
mov counter_triangle,bx ;initializing to 1
pop y_coord_triangle
pop x_coord_triangle
ret
draw_triangle endp
set_cursor_at_row_and_column proc
mov ah,02 ;set cursor to write super mario
mov bh,0
mov dh,row_number
mov dl,column_number
int 10h
ret
set_cursor_at_row_and_column endp
set_color_on_whole_screen proc
mov ah,06
mov al,0
mov ch,0
mov dh,24
mov cl,0
mov dl,80
mov bh,color_for_whole_screen
int 10h
ret
set_color_on_whole_screen endp
Draw_mario proc
mov bx,0
mov ax,0
mov dx,0
mov bx,origin_x_character ;40 staring axis
mov ax,origin_y_character ;420
cmp color_reactangle,0
je make_mario_black
;;stomach
mov color_reactangle,6
mov height_of_reactangle,20
mov length_of_reactangle,19
mov x_coord_reactangle,bx
mov y_coord_reactangle,ax
call draw_reactangle
;;;;;;;;;;;;;;;leg1
mov color_reactangle,7
mov height_of_reactangle,10
mov length_of_reactangle,3
add x_coord_reactangle,3
add y_coord_reactangle,20
call draw_reactangle
;;;;;;;;;;;;;;;leg2
add x_coord_reactangle,10
call draw_reactangle
;;;;;;;;;;;;;;;Neck
mov color_reactangle,8
mov height_of_reactangle,5
mov length_of_reactangle,4
sub x_coord_reactangle,6
sub y_coord_reactangle,25
call draw_reactangle
;;;;;;;;;;;;;;;Head
mov color_reactangle,6
mov height_of_reactangle,12
mov length_of_reactangle,12
sub x_coord_reactangle,4
sub y_coord_reactangle,11
call draw_reactangle
;;;;;;;;;;;;;;;;right Arm
mov color_reactangle,15
mov height_of_reactangle,4
mov length_of_reactangle,6
add x_coord_reactangle,16
add y_coord_reactangle,19
call draw_reactangle
;;;;;;;;;;;;;;;;left Arm
sub x_coord_reactangle,25
call draw_reactangle
jmp skip_mario_make_black
make_mario_black:
;;stomach
mov height_of_reactangle,20
mov length_of_reactangle,19
mov x_coord_reactangle,bx
mov y_coord_reactangle,ax
call draw_reactangle
;;;;;;;;;;;;;;;leg1
mov height_of_reactangle,10
mov length_of_reactangle,3
add x_coord_reactangle,3
add y_coord_reactangle,20
call draw_reactangle
;;;;;;;;;;;;;;;leg2
add x_coord_reactangle,10
call draw_reactangle
;;;;;;;;;;;;;;;Neck
mov height_of_reactangle,5
mov length_of_reactangle,4
sub x_coord_reactangle,6
sub y_coord_reactangle,25
call draw_reactangle
;;;;;;;;;;;;;;;Head
mov height_of_reactangle,12
mov length_of_reactangle,12
sub x_coord_reactangle,4
sub y_coord_reactangle,11
call draw_reactangle
;;;;;;;;;;;;;;;;right Arm
mov height_of_reactangle,4
mov length_of_reactangle,10
add x_coord_reactangle,16
add y_coord_reactangle,19
call draw_reactangle
;;;;;;;;;;;;;;;;left Arm
sub x_coord_reactangle,29
call draw_reactangle
skip_mario_make_black:
ret
Draw_mario endp
Draw_enemy proc
mov ax,0
mov bx,0
mov ax,origin_x_enemy1
mov bx,origin_y_enemy1
;;;head
mov x_coord_triangle,ax ;170
mov y_coord_triangle,bx ;400
mov height_triangle,10
;mov color_triangle,3
call draw_triangle
;;;foot one
mov ax,origin_x_enemy1
mov bx,origin_y_enemy1
add bx,10
sub ax,4
mov height_of_reactangle,10
mov length_of_reactangle,3
mov x_coord_reactangle,ax
mov y_coord_reactangle,bx
call draw_reactangle
;;;foot two
mov ax,origin_x_enemy1
mov bx,origin_y_enemy1
add bx,10
add ax,2
mov height_of_reactangle,10
mov length_of_reactangle,3
mov x_coord_reactangle,ax
mov y_coord_reactangle,bx
call draw_reactangle
ret
Draw_enemy endp
Draw_enemy2 proc
mov ax,0
mov bx,0
mov ax,origin_x_enemy2
mov bx,origin_y_enemy2
;;;head
mov x_coord_triangle,ax ;340
mov y_coord_triangle,bx ;400
mov height_triangle,10
;mov color_triangle,3
call draw_triangle
;;;foot one
mov ax,origin_x_enemy2
mov bx,origin_y_enemy2
add bx,10
sub ax,4
mov height_of_reactangle,10
mov length_of_reactangle,3
mov x_coord_reactangle,ax
mov y_coord_reactangle,bx
call draw_reactangle
;;;foot two
mov ax,origin_x_enemy2
mov bx,origin_y_enemy2
add bx,10
add ax,2
mov height_of_reactangle,10
mov length_of_reactangle,3
mov x_coord_reactangle,ax
mov y_coord_reactangle,bx
call draw_reactangle
ret
Draw_enemy2 endp
Draw_monster proc
mov ax,0
mov bx,0
cmp bl,color_monster
jne skip_make_color
jmp make_monster_black
skip_make_color:
mov color_triangle,4
mov ax,origin_x_monster ;right trianlge
mov bx,origin_y_monster
mov x_coord_triangle,ax ;340
mov y_coord_triangle,bx ;180
mov height_triangle,10
call draw_triangle
sub x_coord_triangle,24 ;;left trianlge
call draw_triangle
mov height_of_reactangle,3 ;left trianlge eye
mov length_of_reactangle,3
mov ax,0
mov ax,x_coord_triangle
mov bx,0
mov bx,y_coord_triangle
dec ax
add bx,3
mov x_coord_reactangle,ax ;316
mov y_coord_reactangle,bx ;183
mov color_reactangle,5
call draw_reactangle
add x_coord_reactangle,23 ;right trianlge eye
call draw_reactangle
mov height_of_reactangle,20 ;stomach
mov length_of_reactangle,50
sub x_coord_reactangle,35
add y_coord_reactangle,7
mov color_reactangle,6
call draw_reactangle
mov height_of_reactangle,4 ;left hand
mov length_of_reactangle,10
sub x_coord_reactangle,10
add y_coord_reactangle,3
mov color_reactangle,7
call draw_reactangle
add x_coord_reactangle,60 ;right hand
call draw_reactangle
jmp endpp
make_monster_black:
mov color_reactangle,0
mov color_triangle,0
mov ax,origin_x_monster ;right trianlge
mov bx,origin_y_monster
mov x_coord_triangle,ax ;340
mov y_coord_triangle,bx ;180
mov height_triangle,10
call draw_triangle
sub x_coord_triangle,24 ;;left trianlge
call draw_triangle
mov height_of_reactangle,3 ;left trianlge eye
mov length_of_reactangle,3
mov ax,0
mov ax,x_coord_triangle
mov bx,0
mov bx,y_coord_triangle
dec ax
add bx,3
mov x_coord_reactangle,ax ;316
mov y_coord_reactangle,bx ;183
call draw_reactangle
add x_coord_reactangle,23 ;right trianlge eye
call draw_reactangle
mov height_of_reactangle,20 ;stomach
mov length_of_reactangle,50
sub x_coord_reactangle,35
add y_coord_reactangle,7
call draw_reactangle
mov height_of_reactangle,4 ;left hand
mov length_of_reactangle,10
sub x_coord_reactangle,10
add y_coord_reactangle,3
call draw_reactangle
add x_coord_reactangle,60 ;right hand
call draw_reactangle
endpp:
ret
Draw_monster endp
zig_zaq_enemy_1 proc
push cx
push bx
mov ax,0
mov bx,0
inc draw_counter
mov bl,10
cmp bl,draw_counter
jne skip_draw_enemy_again
mov color_triangle,0
mov color_reactangle,0
call Draw_enemy
mov ax,140
cmp origin_x_enemy1,ax ;if equal then it will add in x
je make_add_or_sub_zero
mov ax,280
cmp origin_x_enemy1,ax
jg make_add_or_sub_ONE
jmp skip_make_ONE
make_add_or_sub_ONE:
mov bl,1
mov add_or_sub,bl
jmp skip_make_ONE
make_add_or_sub_ZERO:
mov bl,0
mov add_or_sub,bl
skip_make_ONE:
mov bx,0
cmp add_or_sub,bl ;if 0 then add in enemy x if 1 sub from enemy x
je add_in_enemy_x
sub_in_enemy_x:
sub origin_x_enemy1,5
jmp skip_add
add_in_enemy_x:
add origin_x_enemy1,5
skip_add:
mov color_triangle,10 ;drawing enemy
mov color_reactangle,10
call Draw_enemy
mov bl,0
mov draw_counter,bl ;restoring draw_counter to zero
skip_draw_enemy_again:
pop bx
pop cx
ret
zig_zaq_enemy_1 endp
zig_zaq_enemy_2 proc
push cx
push bx
mov ax,0
mov bx,0
inc draw_counter2
mov bl,10
cmp bl,draw_counter2
jne skip_draw_enemy_again2
mov color_triangle,0
mov color_reactangle,0
call Draw_enemy2
mov ax,330
cmp origin_x_enemy2,ax ;if equal then it will add in x
je make_add_or_sub_zero2
mov ax,480
cmp origin_x_enemy2,ax
jg make_add_or_sub_ONE2
jmp skip_make_ONE2
make_add_or_sub_ONE2:
mov bl,1
mov add_or_sub2,bl
jmp skip_make_ONE2
make_add_or_sub_ZERO2:
mov bl,0
mov add_or_sub2,bl
skip_make_ONE2:
mov bx,0
cmp add_or_sub2,bl ;if 0 then add in enemy x if 1 sub from enemy x
je add_in_enemy_x2
sub_in_enemy_x2:
sub origin_x_enemy2,5
jmp skip_add2
add_in_enemy_x2:
add origin_x_enemy2,5
skip_add2:
mov color_triangle,10 ;drawing enemy
mov color_reactangle,10
call Draw_enemy2
mov bl,0
mov draw_counter2,bl ;restoring draw_counter to zero
skip_draw_enemy_again2:
pop bx
pop cx
ret
zig_zaq_enemy_2 endp
zig_zaq_monster proc
push cx
push bx
mov ax,0
mov bx,0
inc draw_counter3
mov bl,4
cmp bl,draw_counter3
jne skip_draw_monster_again
mov color_monster,0
call Draw_monster
mov ax,50
cmp origin_x_monster,ax ;if equal then it will add in x
je make_add_or_sub_zero3
mov ax,580
cmp origin_x_monster,ax
jg make_add_or_sub_ONE3
jmp skip_make_ONE3
make_add_or_sub_ONE3:
mov bl,1
mov add_or_sub3,bl
jmp skip_make_ONE3
make_add_or_sub_ZERO3:
mov bl,0
mov add_or_sub3,bl
skip_make_ONE3:
mov bx,0
cmp add_or_sub3,bl ;if 0 then add in monster x if 1 sub from monster x
je add_in_monster_x
sub_in_monster_x:
sub origin_x_monster,5
jmp skip_add3
add_in_monster_x:
add origin_x_monster,5
skip_add3:
mov color_monster,3 ;drawing monster
call Draw_monster
mov bl,0
mov draw_counter3,bl ;restoring draw_counter to zero
skip_draw_monster_again:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;fire implementation
inc draw_counter4 ;for slowing down fire object
mov bl,5
cmp bl,draw_counter4
jne skip_fire_conditions
mov draw_counter4,0
mov color_reactangle,0
call draw_fire_object
cmp fire_reached,1 ; 1 when fire object is in air
je increment_in_fire_object_till_it_reached_ground
fire_start: ;0 when monster didnt fire so start firing
mov fire_reached,1
mov bx,0
mov bx,origin_x_monster
mov cx,0
mov cx,origin_y_monster
add cx,20
mov origin_x_fire,bx ;setting axis of monster to fire object
mov origin_y_fire,cx
jmp skip_fire_conditions
increment_in_fire_object_till_it_reached_ground:
add origin_y_fire,5
cmp origin_y_fire,430 ;floor y axis
je fire_object_reached_floor
mov ax,85 ;checking first hurdle top from left starting point
cmp origin_x_fire,ax
jg check_is_it_less_than_end_of_first_hurdle_top
jmp draw_still
check_is_it_less_than_end_of_first_hurdle_top:
mov ax,135
cmp origin_x_fire,ax
jl check_heigth_of_hurdle_1
jmp skip_hurdle_1_check
check_heigth_of_hurdle_1:
mov ax,380 ;heigth of first hurdle
cmp origin_y_fire,ax
je fire_object_reached_floor
jmp draw_still
skip_hurdle_1_check:
mov ax,0
mov ax,275
cmp origin_x_fire,ax
jg check_right_side_hurdle_2_top
jmp skip_hurdle_2_check
check_right_side_hurdle_2_top:
mov ax,0
mov ax,325 ;right end of hurdle 2 top
cmp origin_x_fire,ax
jl check_heigth_of_hurdle_2
jmp skip_hurdle_2_check
check_heigth_of_hurdle_2:
mov ax,0
mov ax,360
cmp origin_y_fire,ax
je fire_object_reached_floor
jmp draw_still
skip_hurdle_2_check:
mov ax,0
mov ax,480
cmp origin_x_fire,ax
jg check_hurdle_3_right_top
jmp draw_still
check_hurdle_3_right_top:
mov ax,0
mov ax,530
cmp origin_x_fire,ax
jl check_heigth_of_hurdle_3
jmp draw_still
check_heigth_of_hurdle_3:
mov ax,0
mov ax,390
cmp origin_y_fire,ax
je fire_object_reached_floor
draw_still:
mov color_reactangle,5
call draw_fire_object
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
detection_of_mario_with_fire_object:
mov ax,0
mov ax,origin_x_fire ;comparing x axis
cmp origin_x_character,ax
je check_y_axis_colliding
jmp skip_fire_conditions
check_y_axis_colliding:
mov ax,0
mov ax,origin_y_fire
cmp ax,origin_y_character
je collision_occuring_with_fire
mov ax,0
mov ax,origin_x_fire ;comparing x axis
add ax,5
cmp origin_x_character,ax
je check_y_axis_colliding2
jmp skip_fire_conditions
check_y_axis_colliding2:
mov ax,0
mov ax,origin_y_fire
sub ax,5
cmp ax,origin_y_character
je collision_occuring_with_fire
jmp skip_fire_collision_initializing
collision_occuring_with_fire:
mov mario_colliding_with_fire,1 ;1 means collided
skip_fire_collision_initializing:
jmp skip_fire_conditions
fire_object_reached_floor:
mov fire_reached,0
skip_fire_conditions:
pop bx
pop cx
ret
zig_zaq_monster endp
draw_fire_object proc
mov height_of_reactangle,5
mov length_of_reactangle,5
mov ax,0
mov bx,0
mov ax,origin_x_fire
mov bx,origin_y_fire
mov x_coord_reactangle,ax
mov y_coord_reactangle,bx
call draw_reactangle
ret
draw_fire_object endp
Darw_obstacles_and_flag proc
mov ah, 00h ;video mode
mov al, 12h
int 10h
mov color_reactangle,3
;;;;;;;;;;;;;;;;;;;;;;;hurdle 1 ;;;;;;;;;;;;;;;;;;Drawing objects
mov color_reactangle,4
mov height_of_reactangle,30
mov length_of_reactangle,20
mov x_coord_reactangle,110
mov y_coord_reactangle,420
call draw_reactangle
;;;;;;;;;;;;;;;;;;;;;;;hurdle top of 1
mov color_reactangle,8
mov height_of_reactangle,10
mov length_of_reactangle,40
mov x_coord_reactangle,100
mov y_coord_reactangle,410
call draw_reactangle
;;;;;;;;;;;;;;;;;;;;;;;;hurdle 2
mov color_reactangle,4
mov height_of_reactangle,50
mov length_of_reactangle,20
mov x_coord_reactangle,300
mov y_coord_reactangle,400
call draw_reactangle
;;;;;;;;;;;;;;;;;;;;;;;hurdle top of 2
mov color_reactangle,8
mov height_of_reactangle,10
mov length_of_reactangle,40
mov x_coord_reactangle,290
mov y_coord_reactangle,390
call draw_reactangle
;;;;;;;;;;;;;;;;;;;;;;;;hurdle 3
mov color_reactangle,4
mov height_of_reactangle,25
mov length_of_reactangle,20
mov x_coord_reactangle,500
mov y_coord_reactangle,430
call draw_reactangle
;;;;;;;;;;;;;;;;;;;;;;;hurdle top of 3
mov color_reactangle,8
mov height_of_reactangle,10
mov length_of_reactangle,40
mov x_coord_reactangle,490
mov y_coord_reactangle,420
call draw_reactangle
;;;;;;;;;;;;;;;;;;;;;;;;bottom layer of game
mov color_reactangle,9
mov height_of_reactangle,35
mov length_of_reactangle,640
mov x_coord_reactangle,0
mov y_coord_reactangle,450
call draw_reactangle
mov bl,3
cmp game_level,bl
je skip_flag
;;;;;;;;;;;;;;;;;;;;;;;;;making flag
;;pole
mov color_reactangle,7
mov height_of_reactangle,300
mov length_of_reactangle,10
mov x_coord_reactangle,630
mov y_coord_reactangle,200
call draw_reactangle
;;flag
mov color_reactangle,1
mov height_of_reactangle,80
mov length_of_reactangle,80
mov x_coord_reactangle,550
mov y_coord_reactangle,200
call draw_reactangle
jmp skip_ki
;;;;;;;;;;;;;;;;;;;;;;;;;drawing kindom
skip_flag:
mov x_coord_triangle,633
mov y_coord_triangle,413
mov height_triangle,7
mov color_triangle,9
call draw_triangle
mov x_coord_triangle,617 ;top triangles;2
call draw_triangle
mov x_coord_triangle,601 ;1
call draw_triangle
mov color_reactangle,7
mov height_of_reactangle,10 ;walls
mov length_of_reactangle,10
mov x_coord_reactangle,597
mov y_coord_reactangle,420
call draw_reactangle
mov x_coord_reactangle,613
call draw_reactangle
mov x_coord_reactangle,629
call draw_reactangle
mov color_reactangle,8
mov height_of_reactangle,20 ;base
mov length_of_reactangle,47
mov x_coord_reactangle,594
mov y_coord_reactangle,430
call draw_reactangle
skip_ki:
ret
Darw_obstacles_and_flag endp
check_obstacles_detection proc
mov ax,0
mov ax,85 ;starting point of hurdle 1
cmp ax,origin_x_character ;checking mario for touching first obstacle from left side
jne check_first_obstacle_from_right_side
sub ax,5
jmp checked_conditions
check_first_obstacle_from_right_side:
mov ax,0
mov ax,135 ;ending point of hurdle 1
cmp ax,origin_x_character ;checking mario for touching first obstacle from right side
jne check_second_obstacle_from_left_side
add ax,5
jmp checked_conditions
check_second_obstacle_from_left_side:
mov ax,0
mov ax,280 ;starting point of hurdle 2
cmp ax,origin_x_character ;checking mario for touching second obstacle from left side
jne check_second_obstacle_from_right_side
sub ax,5
jmp checked_conditions
check_second_obstacle_from_right_side:
mov ax,0
mov ax,325 ;ending point of hurdle 2
cmp ax,origin_x_character ;checking mario for touching second obstacle from right side
jne check_third_obstacle_from_left_side
add ax,5
jmp checked_conditions
check_third_obstacle_from_left_side:
mov ax,0
mov ax,470 ;starting point of hurdle 3
cmp ax,origin_x_character ;checking mario for touching third obstacle from left side
jne check_third_obstacle_from_right_side
sub ax,5
jmp checked_conditions
check_third_obstacle_from_right_side:
mov ax,0
mov ax,535 ;ending point of hurdle 3
cmp ax,origin_x_character ;checking mario for touching third obstacle from right side
jne end_obstacles_conditions
add ax,5
jmp checked_conditions
checked_conditions:
mov origin_x_character,ax
end_obstacles_conditions:
ret
check_obstacles_detection endp
make_it_multiple_of_5 proc
mov ax,0
mov bx,0
mov ax,origin_x_character
mov bl,5
div bl
mov remainder,ah
mov bl,5
sub bl,remainder
cmp bl,5
je skip_extra_add
add origin_x_character,bx
skip_extra_add:
ret
make_it_multiple_of_5 endp
mov_mario_to_ground_function proc
mov_mario_to_ground:
mov color_reactangle,0
call Draw_mario
mov bx,0
mov bx,420
cmp origin_y_character,bx
je skip_addtion
add origin_y_character,5
mov color_reactangle,3
call Draw_mario
jmp mov_mario_to_ground
skip_addtion:
ret
mov_mario_to_ground_function endp
check_detection_with_obstacles_when_jump_is_taken_or_falling_down proc ;conditions when mario touch with borders of obstacles while jumping
mov does_it_collide,0
call make_it_multiple_of_5
mov ax,0
mov ax,420 ; is mario off the floor (condition)
cmp origin_y_character,ax
je skip_value_move
mov ax,0
mov ax,380 ;height of first hurdle
cmp origin_y_character,ax ;checking when collide from left side of hurdle 1
jg check_x_axis_for_hurdle1
jmp skip_condition_of_collision_hurdle1
check_x_axis_for_hurdle1:
mov ax,0
mov ax,75
cmp origin_x_character,ax ;checking for x axis of hurdle 1
je collision_occuring
skip_condition_of_collision_hurdle1:
mov ax,0
mov ax,360
cmp origin_y_character,ax ;checking when collide from left side of hurdle 2
jg check_x_axis_for_hurdle2
jmp skip_condition_of_collision_hurdle2
check_x_axis_for_hurdle2:
mov ax,0
mov ax,265
cmp origin_x_character,ax
je collision_occuring
skip_condition_of_collision_hurdle2:
mov ax,0
mov ax,390
cmp origin_x_character,ax
jg check_x_axis_for_hurdle3
jmp skip_value_move
check_x_axis_for_hurdle3:
mov ax,0
mov ax,475
je collision_occuring
jmp skip_value_move
collision_occuring:
mov does_it_collide,1 ;1 for collision
skip_value_move:
ret
check_detection_with_obstacles_when_jump_is_taken_or_falling_down endp
detection_with_enemies proc
checking_x_axis_of_mario_and_enemy1:
mov ax,0
mov ax,origin_x_enemy1
cmp ax,origin_x_character ;checking x axis of both characters
je check_difference_of_y_axix_of_mario_and_enemy1
jmp now_check_collision_with_enemy2
check_difference_of_y_axix_of_mario_and_enemy1:
mov bx,0
mov bx,origin_y_character
add bx,10
cmp bx,430 ;y axis for enemies (both same)
je collision_occuring_with_enemy
jmp now_check_collision_with_enemy2
collision_occuring_with_enemy:
mov collision_occuring_ONE,1 ;1 for collision make level end
jmp end_check_collion_with_enemies