-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.asm
More file actions
1821 lines (1637 loc) · 51.8 KB
/
Game.asm
File metadata and controls
1821 lines (1637 loc) · 51.8 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
.model small
.stack
.data
; Game Start X
startPosition = 4
;Flag position
flagPosition = 315
; Mario Coordinates
marioStart_X = 10
marioStart_Y = 158
marioHeight = 18
marioWidth = 14
; Enemy1 Coordinate
enemyStart_Y = 158
enemyHeight = 18
enemyWidth = 18
; kingdom positions
kingdomTop_X = 290
kingdomTop_Y = 128
kingdomBottom_X = 286
kingdomBottom_Y = 148
; Jumps variable
jumpHeight WORD 0
jumpFall WORD 0
jumpPower WORD ?
jumpPowerHalf WORD ?
jumpTime BYTE ?
; Constant Coordinate for the hurdles
hurdle1_X = 45
hurdle1_Y = 152
hurdle2_X = 155
hurdle2_Y = 146
hurdle3_X = 240
hurdle3_Y = 157
; hurdle lengths
hurdleTopLength = 26
hurdleBottomLength = 22
; Flag Coordinate
flag_X = 315
Flag_Y = 120
; kingdomfixed Coordinates
kingdomTopHeight = 24
kingdomTopWidth = 25
kingdomBottomHeight = 28
kingdomBottomWidth = 32
; Monster fixed Coordinates
monsterHeight = 35
monsterWidth = 34
monsterStart_X = 10
monster_Y = 13
monsterLeftMax = 40
monsterRightMax = 265
; Bomb fixed values
bombStart_Y = 29
bombHeight = 9
bombWidth = 8
; Arrow Keys Constants
arrowLeftKey = 4Bh
arrowRightKey = 4Dh
arrowUpKey = 48h
; This Macro set the cursor on that row and column
setCursor macro row, col
push ax
push bx
push dx
mov dh, row
mov dl, col
mov ah, 02h
mov bh, 0
int 10h
pop dx
pop bx
pop ax
endm
; This Macro writes a character to the screen
writeCharacter macro char
push ax
push bx
push cx
mov al, char
mov ah, 0Ah
mov bh, 0
mov bl, 15
mov cx, 1
int 10h
pop cx
pop bx
pop ax
endm
; Basic Shapes of the Oject Arrays
; For Drawing the hurdle
hurdleTop BYTE 2, 2, 2, 6, 2, 2, 2, 6, 2, 2, 2, 6, 2, 2, 2,6, 2, 2, 2, 6, 2, 2, 2, 6, 2, 2,2
hurdleBottom BYTE 2, 2, 2, 15, 2, 2, 15, 2, 2, 15, 2, 2, 15, 2, 2, 15, 2, 2, 15, 2, 2, 2
; colors for the Mario
mario BYTE 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54
BYTE 54, 54, 54, 54, 40, 40, 40, 40, 40, 54, 54, 54, 54, 54
BYTE 54, 54, 54, 40, 40, 40, 40, 40, 40, 40, 40, 40, 54, 54
BYTE 54, 54, 54, 22, 22, 22, 42, 42, 22, 42, 54, 54, 54, 54
BYTE 54, 54, 22, 42, 22, 42, 42, 42, 22, 42, 42, 42, 54, 54
BYTE 54, 54, 22, 42, 22, 22, 42, 42, 42, 22, 42, 42, 42, 54
BYTE 54, 54, 22, 22, 42, 42, 42, 42, 22, 22, 22, 22, 54, 54
BYTE 54, 54, 54, 54, 42, 42, 42, 42, 42, 42, 42, 54, 54, 54
BYTE 54, 54, 54, 22, 22, 40, 22, 22, 40, 54, 54, 54, 54, 54
BYTE 54, 54, 22, 22, 22, 40, 22, 22, 40, 22, 22, 22, 54, 54
BYTE 54, 22, 22, 22, 22, 40, 40, 40, 40, 22, 22, 22, 22, 54
BYTE 54, 42, 42, 22, 40, 42, 40, 40, 42, 40, 22, 42, 42, 54
BYTE 54, 42, 42, 42, 40, 40, 40, 40, 40, 40, 42, 42, 42, 54
BYTE 54, 42, 42, 40, 40, 40, 40, 40, 40, 40, 40, 42, 42, 54
BYTE 54, 54, 54, 40, 40, 40, 54, 54, 40, 40, 40, 54, 54, 54
BYTE 54, 54, 22, 22, 22, 54, 54, 54, 54, 22, 22, 22, 54, 54
BYTE 54, 22, 22, 22, 22, 54, 54, 54, 54, 22, 22, 22, 22, 54
BYTE 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54
; Color 2-D Array for the Enemy
enemy BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
BYTE 54,54,54,54,54,54,54, 6, 6, 6, 6,54,54,54,54,54,54,54
BYTE 54,54,54,54,54,54, 6, 6, 6, 6, 6, 6,54,54,54,54,54,54
BYTE 54,54,54,54,54, 6, 6, 6, 6, 6, 6, 6, 6,54,54,54,54,54
BYTE 54,54,54,54, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,54,54,54,54
BYTE 54,54,54, 6, 0, 0, 6, 6, 6, 6, 6, 6, 0, 0, 6,54,54,54
BYTE 54,54, 6, 6, 6,85, 0, 6, 6, 6, 6, 0,85, 6, 6, 6,54,54
BYTE 54,54, 6, 6, 6,85, 0, 0, 0, 0, 0, 0,85, 6, 6, 6,54,54
BYTE 54, 6, 6, 6, 6,85, 0,85, 6, 6,85, 0,85, 6, 6, 6, 6,54
BYTE 54, 6, 6, 6, 6,85,85,85, 6, 6,85,85,85, 6, 6, 6, 6,54
BYTE 54, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,54
BYTE 54,54, 6, 6, 6, 6,85,85,85,85,85,85, 6, 6, 6, 6,54,54
BYTE 54,54,54,54,54,85,85,85,85,85,85,85,85,54,54,54,54,54
BYTE 54,54,54, 0, 0,85,85,85,85,85,85,85,85,54,54,54,54,54
BYTE 54,54, 0, 0, 0, 0, 0,85,85,85,85,85, 0, 0,54,54,54,54
BYTE 54,54, 0, 0, 0, 0, 0, 0,85,85,85, 0, 0, 0,54,54,54,54
BYTE 54,54,54, 0, 0, 0, 0, 0,85,85, 0, 0, 0,54,54,54,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
; Colors 2-D Array for the KingdomTop
kingdomTop BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
BYTE 54,54,54,54,54,41,54,54,54,54,54,54,54,54,54,54,54,54,54,41,54,54,54,54,54
BYTE 54,54,54,54,41,41,41,54,54,54,54,54,54,54,54,54,54,54,41,41,41,54,54,54,54
BYTE 54,54,54,41,41,41,41,41,54,54,54,54,54,54,54,54,54,41,41,41,41,41,54,54,54
BYTE 54,54,41,41,41,41,41,41,41,54,54,54,54,54,54,54,41,41,41,41,41,41,41,54,54
BYTE 54,41,41,41,41,41,41,41,41,41,54,54,54,54,54,41,41,41,41,41,41,41,41,41,54
BYTE 41,41,41,41,41,41,41,41,41,41,41,54,54,54,41,41,41,41,41,41,41,41,41,41,41
BYTE 41,41,41,41,41,41,41,41,41,41,41,54,54,54,41,41,41,41,41,41,41,41,41,41,41
BYTE 41,41,41,41,41,41,41,41,41,41,41,54,54,54,41,41,41,41,41,41,41,41,41,41,41
BYTE 41,41,41,41,41,41,41,41,41,41,41,54,54,54,41,41,41,41,41,41,41,41,41,41,41
BYTE 41,41,41,41,41,41,41,41,41,41,41,54,54,54,41,41,41,41,41,41,41,41,41,41,41
BYTE 41,41,41,41,14,14,14,41,41,41,41,54,54,54,41,41,41,41,14,14,14,41,41,41,41
BYTE 41,41,41,41,14,14,14,41,41,41,41,54,54,54,41,41,41,41,14,14,14,41,41,41,41
BYTE 41,41,41,41,14,14,14,41,41,41,41,54,54,54,41,41,41,41,14,14,14,41,41,41,41
BYTE 41,41,41,41,14,14,14,41,41,41,41,54,54,54,41,41,41,41,14,14,14,41,41,41,41
BYTE 41,41,41,41,14,14,14,41,41,41,41,54,54,54,41,41,41,41,14,14,14,41,41,41,41
BYTE 41,41,41,41,14,14,14,41,41,41,41,54,54,54,41,41,41,41,14,14,14,41,41,41,41
BYTE 41,41,41,41,14,14,14,41,41,41,41,54,54,54,41,41,41,41,14,14,14,41,41,41,41
BYTE 41,41,41,41,14,14,14,41,41,41,41,54,54,54,41,41,41,41,14,14,14,41,41,41,41
BYTE 41,41,41,41,14,14,14,41,41,41,41,54,54,54,41,41,41,41,14,14,14,41,41,41,41
BYTE 41,41,41,41,41,41,41,41,41,41,41,54,54,54,41,41,41,41,41,41,41,41,41,41,41
BYTE 41,41,41,41,41,41,41,41,41,41,41,54,54,54,41,41,41,41,41,41,41,41,41,41,41
BYTE 41,41,41,41,41,41,41,41,41,41,41,54,54,54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54,54,54,54,54,54,54,54, 2, 2,85,85,85,14,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
BYTE 54,54,54,54,54,54,54,54, 2, 2, 2,85,85,14,14,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
BYTE 54,54,54,54,54,54,85,85, 2, 2, 2, 2,14,14, 2,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
BYTE 54,54,14,54,54, 2,85,85, 2, 2, 2, 2, 2, 2, 2,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
BYTE 54,14,54,14, 2, 2,85,85, 2, 2, 2, 2, 2, 2, 2,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
BYTE 54,14,14,14,85,85,85, 2, 2, 2,14, 2, 2, 2, 2, 2,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
BYTE 54,14,14,14,14,85, 2, 2, 2,14,14,14, 2, 2, 2, 2,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
BYTE 54,85,14,14,14, 2, 2,14,14,85, 2,14, 2, 2, 2, 2,85,85, 2, 2, 2,85,54,54,54,54,54,54,54,54,54,54,54,54
BYTE 54,54,85,54,14,14,14,14, 2, 2, 2,14, 2, 2, 2, 2,85,85, 2, 2,85,85,14, 2,54,54,54,54,54,54,54,54,54,54
BYTE 54,54,85,54,85,85, 2,85, 2, 2,85,14, 2, 2, 2, 2,85,85, 2,85,85,85,14,14, 2,85,85,85,54,54,54,54,54,54
BYTE 54,54,54,54,54,85,54,54,54, 2,14,14, 2, 2, 2,85,85,85, 2, 2,85,14,14, 2, 2,85,85,14,54,54,54,54,54,54
BYTE 54,54,54,54,54,54,54,54,54,85,14,14, 2, 2,85,85,85, 2, 2, 2, 2, 2, 2, 2, 2, 2,14,14, 2,85,54,54,54,54
BYTE 54,54,54,54,54,54,54,54,54,14,14, 2, 2,85,85,85, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,85,54,54,54,54
BYTE 54,54,54,54,54,54,54,85,14,14,14, 2, 2,85,85,85, 2, 2, 2, 2, 2, 2,85,85,85, 2, 2, 2, 2, 2,54,54,54,54
BYTE 54,54,54,54,54,54,54,54,14,14,54,54, 2, 2,85,85,85,85,85,85, 2, 2,85,85,14, 2, 2, 2,85,85,85,54,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54, 2, 2,14,14,14,85,85, 2, 2,14,14, 2, 2, 2,85,85,14,54,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,14,14,14,54,54,85,54,14,14,14,85,85, 2, 2, 2, 2, 2, 2, 2,14,14,54,54,54
BYTE 54,54,54,54,54,54,54,54,54,14,14,85,54,14,14,14,54,85,14,14, 2,85, 2, 2, 2, 2, 2, 2, 2, 2, 2,85,54,54
BYTE 54,54,54,54,54,54,54,54,54,14,14,54,54,14,14,14,14,54,54, 2, 2,85, 2, 2, 2,85,85,85, 2, 2, 2,14,85,54
BYTE 54,54,54,54,54,54,54,54,54,14,85,54,14,14,14,14,14,14,85, 2, 2,85,85, 2, 2,85,85,14, 2, 2, 2,54,54,54
BYTE 54,54,54,54,54,54,54,54,54,14,54,54,14,14,14,14,14, 2, 2, 2, 2,85,85, 2, 2, 2,14,14, 2, 2,85,85,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,85,54,14,14,14,14,14, 2, 2, 2, 2,85,85, 2, 2, 2, 2, 2, 2, 2,85,85,85,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,85,14,14,14,54, 2, 2, 2, 2, 2,85, 2, 2, 2, 2,85,85, 2,14,14,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54, 2, 2, 2, 2, 2,85,85, 2, 2, 2,14, 2, 2,14, 2,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54, 2, 2, 2, 2, 2, 2,85,85, 2, 2, 2, 2, 2, 2, 2,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54, 2, 2, 2, 2, 2, 2,85,85,85, 2, 2, 2, 2, 2,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54, 2, 2, 2, 2, 2, 2,85,85,85,85, 2, 2, 2,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,14, 2, 2, 2, 2, 2, 2, 2,85,85,85,85,85,85,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,85,85,14,14, 2, 2,14,14,14,14,14,85,85,85,85,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,85,85,85,14,14,14,14,14,14,14,14,14,14,14,85,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,85,85,14,14,85,85,14,14,14,14,14,54,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,85,85,85,14,85,85,85,14,14,14,14,14,14,54,54
BYTE 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54
; Bomb 2-D Array for Drawing
bomb BYTE 54,54,54,54,54,54,54,54
BYTE 54,54,54,15,15,15,54,54
BYTE 54,54,15,15,15,15,15,54
BYTE 54,15,15,15,15,15,15,15
BYTE 54,15,15,15,15,15,15,15
BYTE 54,15,15,15,15,15,15,15
BYTE 54,54,15,15,15,15,15,54
BYTE 54,54,54,15,15,15,54,54
BYTE 54,54,54,54,54,54,54,54
; This structure is used to specify position of all the Object in 2D Screen
screenPosition struct
x WORD ?
y WORD ?
screenPosition ends
; Coordinate of Objects
marioPosition screenPosition <>
monsterPosition screenPosition <>
enemyPosition screenPosition 2 DUP(<>)
bombPosition screenPosition 2 DUP(<>)
hurdles screenPosition 3 DUP(<>)
; Coordinate for Enemy
enemyDirection BYTE 2 DUP(0)
enemyStatus BYTE 2 DUP(0)
monsterDirection BYTE 0
bombTime1 BYTE 20, 55
bombTime2 BYTE 20, 55
; Welcome Strings
welcomeString1 BYTE "Super Mario Game!"
welcomeString2 BYTE "Enter Username"
welcomeString3 BYTE "Press Enter To Play"
scoreString BYTE "Score: "
livesString BYTE "Lives: "
levelString BYTE "Level: "
winString BYTE "You Won!"
loseString BYTE "You Lost!"
; Varying Values
score WORD 0
level WORD 1
lives WORD 3
.code
;-----------------------------------------
; This Is the Main Program, that will handle functioning
; of all the game. This function calls Respective level
; When the respecive level condition is meet.
;-----------------------------------------
main proc
mov ax, @data
mov ds, ax
mov ah, 0
mov al, 13h
int 10h
call WelComeScreen
call resetHurdlesPosition
call drawFixedObjects
; Level1 Checks
Level_1:
call firstLevel
call flagCollision
cmp ah, 1
je transitionLevel2
sub lives, 1
cmp lives, 0
je end_game
jmp Level_1
; level2 check
transitionLevel2:
mov level,2
call drawFixedObjects
add score,10
Level_2:
call secondLevel
call flagCollision
cmp ah, 1
je transitionLevel3
sub lives, 1
cmp lives, 0
je end_game
jmp Level_2
; Level3 check
transitionLevel3:
mov level,3
call drawFixedObjects
add score,10
Level_3:
call thirdLevel
call flagCollision
cmp ah, 1
je end_game
sub lives, 1
cmp lives, 0
jne Level_3
; End Screen of the Game
end_game:
add score,10
call drawEndScreen
; Exit the Game
exit:
mov ah, 4Ch
int 21h
main endp
;-----------------------------------------
; This Section Contain Procedure for Drawing and All
; the logic of the Game. The main function call the
; the respective level. Also, All the statics object
; have been drawn before the call to respective level.
;-----------------------------------------
;-----------------------------------------
; This function handle the logic for displaying
; the Welcome Screen and Taking name as Input.
; This function also Display Strings at start.
; Don't let User to Enter Game Till he press Enter
;-----------------------------------------
WelComeScreen proc uses ax bx cx
; Display of String1
mov bx, offset welcomeString1
mov ah, 8
mov al, 10
mov cx, lengthof welcomeString1
call displayString
; Display of String2
mov bx, offset welcomeString2
mov ah, 10
mov al, 10
mov cx, lengthof welcomeString2
call displayString
; Display of String3
mov bx, offset welcomeString3
mov ah, 14
mov al, 10
mov cx, lengthof welcomeString3
call displayString
; Taking Input and check for Enter
mov bl, 10
EnterCheck:
mov ah, 01
int 16h
jz EnterCheck
push ax
setCursor 12, bl
mov ah,01h
int 21h
pop ax
cmp ah, 0Eh
jne EnterCh
dec bl
setCursor 12, bl
mov dl,' '
mov ah,02h
int 21h
jmp EnterCheck
EnterCh:
inc bl
cmp ah, 1Ch
jne EnterCheck
ReturnMain:
ret
WelComeScreen endp
;-----------------------------------------
; This function Reset Position of the Hurdles after Each level
; Since the Postion struct have Memory of word.We have assigned
; Position of each hurdle According to it.
;-----------------------------------------
resetHurdlesPosition proc
mov Hurdles[0].x, hurdle1_X
mov Hurdles[0].y, hurdle1_Y
mov Hurdles[4].x, hurdle2_X
mov Hurdles[4].y, hurdle2_Y
mov Hurdles[8].x, hurdle3_X
mov Hurdles[8].y, hurdle3_Y
ret
resetHurdlesPosition endp
;-----------------------------------------
; This function draws all Fixed objects on
; the screen such as the hurdles and the
; flags, Ground, Sky, and Interface of Game
;-----------------------------------------
drawFixedObjects proc uses cx dx
call drawSky
call drawGround
cmp level,3
je Next
call drawFlag
Next:
mov ax, 19
mov cx, hurdles[0].y
mov dx, hurdles[0].x
call drawHurdle
mov ax, 25
mov cx, hurdles[4].y
mov dx, hurdles[4].x
call drawHurdle
mov ax, 14
mov cx, hurdles[8].y
mov dx, hurdles[8].x
call drawHurdle
ret
drawFixedObjects endp
;-----------------------------------------
; Takes length of the Hurdle Array in AX
; Takes the Drawing row index in CX
; Takes the Drawing col index in DX
; This function draws a Hurdle at the given
; row & col index.
;-----------------------------------------
drawHurdle proc uses ax bx cx dx si
push ax
mov bx, offset hurdleTop
mov ax, dx
mov dx, cx
mov cx, 10
HurdleTOpLoop:
push cx
mov cx, lengthof hurdleTop
call drawArray1D
inc dx
pop cx
loop HurdleTOpLoop
mov bx, offset hurdleBottom
add ax, 2
pop cx
bottom_loop:
push cx
mov cx, lengthof hurdleBottom
call drawArray1D
inc dx
pop cx
loop bottom_loop
ret
drawHurdle endp
;-----------------------------------------
; Takes the offset of color array in BX
; Takes the Size of the color array in CX
; Takes the Row index in DX
; Takes the start of Coloumn index in AX
; This Draw a 1D Array of Colors onto the Screen.
;-----------------------------------------
drawArray1D proc uses ax bx cx dx si
mov si, 0
draw_loop:
push cx
mov cx, ax
mov al, [bx + si]
mov ah, 0Ch
int 10h
inc si
inc cx
mov ax, cx
pop cx
loop draw_loop
ret
drawArray1D endp
;-----------------------------------------
; Takes Colors Array offset in BX.
; Takes the starting row index in CX
; Takes the starting col index in DX
; Takes the rows & columns in STACK
; Display a 2D Array of colors on the Screen
;-----------------------------------------
drawArray2D proc uses ax bx cx dx si
mov bp, sp
mov ax, dx
mov dx, cx
mov cx, [bp + 14]
draw2DArrayloop:
push cx
mov cx, [bp + 12]
call drawArray1D
inc dx
add bx, cx
pop cx
loop draw2DArrayloop
ret 4
drawArray2D endp
;-----------------------------------------
; This function draws the sky blue background
; of the game,making it appear like a sky.
;-----------------------------------------
drawSky proc uses ax bx cx dx
mov ah, 06h
mov al, 0
mov cx, 0
mov dh, 25
mov dl, 40
mov bh, 54
int 10h
ret
drawSky endp
;-----------------------------------------
; This function draws the brown Color background
; of the game,making it appear like a sky.
;-----------------------------------------
drawGround proc uses ax bx cx dx
mov ah,06
mov al,0
mov ch,byte ptr 22
mov cl,byte ptr 0
mov bh,6
mov dh,25
mov dl,100
int 10h
ret
drawGround endp
;-----------------------------------------
; This function draws the flag at a Given location
;-----------------------------------------
drawFlag proc
call drawFlagBanner
call drawFlagPole
ret
drawFlag endp
;-----------------------------------------
; This function draws the banner of the flag
; according to the Given X,Y location
;-----------------------------------------
drawFlagBanner proc uses ax bx cx dx
mov ah, 06h
mov al, 0
mov ch, 7
mov cl, 34
mov dh, 9
mov dl, 38
mov bh, 1
int 10h
ret
drawFlagBanner endp
;-----------------------------------------
; This function draws the pole of the flag
; according to the Given X,Y location
;-----------------------------------------
drawFlagPole proc uses ax cx dx
mov dx, 56
mov cx, Flag_Y
PoleDrawLoop:
push cx
mov cx, flag_X
mov al, 15
mov ah, 0Ch
int 10h
inc dx
pop cx
loop PoleDrawLoop
ret
drawFlagPole endp
;-----------------------------------------
; This function take row and col index in AH:AL
; Takes the String offset in the BX Register.
; Takes length of the String in the cx Register
; Draws the String at the Given Row and Column
;-----------------------------------------
displayString proc uses ax bx cx dx si
mov si, 0
DrawLoop:
setCursor ah, al
writeCharacter [bx + si]
add al, 1
add si, 1
loop DrawLoop
ret
displayString endp
;-----------------------------------------
; Level Implementation Logic Starts Here
;-----------------------------------------
;-----------------------------------------
; This procedure Runs for First level.
; Implements Drawing and movement of Mario.
;-----------------------------------------
firstLevel proc uses ax cx dx
call SetMarioPosition
mov jumpPower, 1200
mov jumpPowerHalf, 600
mov jumpTime, 10
Level1Loop:
mov bx, offset livesString
mov ah, 0
mov al, 0
mov cx, lengthof livesString
call displayString
add al, 6
mov dx, lives
call displayNumber
mov bx, offset scoreString
mov ah, 0
mov al, 15
mov cx, lengthof scoreString
call displayString
add al, 6
mov dx, score
call displayNumber
mov bx, offset levelString
mov ah, 0
mov al, 33
mov cx, lengthof levelString
call displayString
add al, 6
mov dx, level
call displayNumber
call drawMario
call moveMario
cmp ah, 1
je ReturnMain
jmp Level1Loop
ReturnMain:
ret
firstLevel endp
;-----------------------------------------
; This function implements all the required functionality
; for level2. Which include drawing of Objectand proper
; movement of enemy and their collisions with mario.
;-----------------------------------------
secondLevel proc uses ax bx cx dx
call clearMovingObjects
call SetMarioPosition
call resetEnemies
mov jumpPower, 480
mov jumpPowerHalf, 240
mov jumpTime, 4
mov cx, 0
mov bl, 10
Level2Loop:
push cx
push bx
mov bx, offset livesString
mov ah, 0
mov al, 0
mov cx, lengthof livesString
call displayString
add al, 6
mov dx, lives
call displayNumber
mov bx, offset scoreString
mov ah, 0
mov al, 15
mov cx, lengthof scoreString
call displayString
add al, 6
mov dx, score
call displayNumber
mov bx, offset levelString
mov ah, 0
mov al, 33
mov cx, lengthof levelString
call displayString
add al, 6
mov dx, level
call displayNumber
pop bx
pop cx
inc cx
call drawEnemy
call drawMario
mov ax, cx
div bl
cmp ah, 0
jne MovementContinue
call moveEnemy
mov cx, 0
cmp ah, 1
je ReturntoMain
MovementContinue:
call moveMario
cmp ah, 1
je ReturntoMain
jmp Level2Loop
ReturntoMain:
ret
secondLevel endp
;-----------------------------------------
; This function implements all the required functionality
; for level3. Which include drawing & proper movement
; of the monster, Bombs and all other collisions.
;-----------------------------------------
thirdLevel proc uses ax bx cx dx
call clearMovingObjects
call SetMarioPosition
call resetEnemies
call resetMonster
call drawKingdom
mov jumpPower, 240
mov jumpPowerHalf, 120
mov jumpTime, 2
mov bombPosition[0].x, 40
mov bombPosition[0].y, bombStart_Y
mov bombPosition[4].x, 80
mov bombPosition[4].y, bombStart_Y
mov cx, 0
mov bl, 4
level3loop:
push cx
push bx
mov bx, offset livesString
mov ah, 0
mov al, 0
mov cx, lengthof livesString
call displayString
add al, 6
mov dx, lives
call displayNumber
mov bx, offset scoreString
mov ah, 0
mov al, 15
mov cx, lengthof scoreString
call displayString
add al, 6
mov dx, score
call displayNumber
mov bx, offset levelString
mov ah, 0
mov al, 33
mov cx, lengthof levelString
call displayString
add al, 6
mov dx, level
call displayNumber
pop bx
pop cx
inc cx
call drawEnemy
call drawMario
call drawAllBombs
call drawMonster
mov ax, cx
div bl
cmp ah, 0
jne MovementContinue
call moveMonster
call moveBombs
cmp ah, 1
je ReturnMain
call moveEnemy
cmp ah, 1
je ReturnMain
mov cx, 0
MovementContinue:
call moveMario
cmp ah, 1
je ReturnMain
jmp level3loop
ReturnMain:
ret
thirdLevel endp
;-----------------------------------------
; Logic for Drawing all the Moving Objects Start Here
;-----------------------------------------
;-----------------------------------------
; This function draws mario at the location specified
; Used DrawArray2D function to draw the mario.
;-----------------------------------------
drawMario proc uses bx cx dx
mov bx, offset mario
mov cx, marioHeight
push cx
mov cx, marioWidth
push cx
mov cx, marioPosition.y
mov dx, marioPosition.x
call drawArray2D
ret
drawMario endp
;-----------------------------------------
; This function uses a loop to draw both the enemy sprites
; on the screen according to their screenPosition variables
; and it uses the function drawArray2D
;-----------------------------------------
drawEnemy proc uses ax bx cx dx
mov cx, 2
mov si, 0
mov ax, 0
draw_loop:
push cx
mov bx, ax
cmp enemyStatus[bx], 1
jne MovementContinue
mov cx, enemyHeight
push cx
mov cx, enemyWidth
push cx
mov cx, enemyPosition[si].y
mov dx, enemyPosition[si].x
mov bx, offset enemy
call drawArray2D
MovementContinue:
add si, 4
add ax, 1
pop cx
loop draw_loop
ret
drawEnemy endp
;-----------------------------------------
; This function draws the monster at the
; location specified by its screenPosition
; variable using the function drawArray2D
;-----------------------------------------
drawMonster proc uses bx cx dx
mov bx, offset monster
mov cx, monsterHeight
push cx
mov cx, monsterWidth
push cx
mov cx, monsterPosition.y
mov dx, monsterPosition.x
call drawArray2D
ret
drawMonster endp
;-----------------------------------------
; This function draws the bombs on the screen according
; to the positions stored in the bombPosition array.
;-----------------------------------------
drawAllBombs proc uses cx dx
cmp bombTime2[0], 0
jne SecondBomb
; First bomb
mov cx, bombPosition[0].y
mov dx, bombPosition[0].x
call drawBomb
SecondBomb:
cmp bombTime2[1], 0
jne ReturnMain
mov cx, bombPosition[4].y
mov dx, bombPosition[4].x
call drawBomb
ReturnMain:
ret
drawAllBombs endp
;-----------------------------------------
; Takes the Drawing row index in CX
; Takes the Drawing col index in DX
; This function draws a bomb at the
; given row & col index (Indices from top Left)
;-----------------------------------------
drawBomb proc uses bx cx dx
mov bx, bombHeight
push bx
mov bx, bombWidth
push bx
mov bx, offset bomb
call drawArray2D
ret
drawBomb endp
;-----------------------------------------
; This function draws Kingdom at the location
; specified Using DrawArray2D function.
;-----------------------------------------
drawKingdom proc uses bx cx dx
mov bx, offset kingdomTop
mov cx, kingdomTopHeight
push cx
mov cx, kingdomTopWidth
push cx
mov cx, kingdomTop_Y
mov dx, kingdomTop_X
call drawArray2D
mov bx, offset kingdomBottom
mov cx, kingdomBottomHeight
push cx
mov cx, kingdomBottomWidth
push cx
mov cx, kingdomBottom_Y
mov dx, kingdomBottom_X
call drawArray2D
ret
drawKingdom endp
;-----------------------------------------
; Logic for Reseting the Moving Object Coordinates Start Here
;-----------------------------------------
;-----------------------------------------
; This function sets the X & Y position (screenPosition) of
; the mario according to the constants defined at the top.
;-----------------------------------------
SetMarioPosition proc
mov marioPosition.x, marioStart_X
mov marioPosition.y, marioStart_Y
ret
SetMarioPosition endp
;-----------------------------------------
;This function sets the X & Y position (screenPosition) of
; the Enemies according to the constants defined at the top.
;-----------------------------------------
resetEnemies proc
mov enemyPosition[0].x, hurdle1_X
add enemyPosition[0].x, hurdleTopLength
inc enemyPosition[0].x
mov enemyPosition[0].y, enemyStart_Y
mov enemyPosition[4].x, hurdle2_X
add enemyPosition[4].x, hurdleTopLength
inc enemyPosition[4].x
mov enemyPosition[4].y, enemyStart_Y
mov enemyStatus[0], 1
mov enemyStatus[1], 1