-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMineField.asm
2080 lines (1666 loc) · 44.3 KB
/
MineField.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
.386
.STACK 64
.DATA
;main menu messages must be at the beginning!!!!!
;1st screen output messages ;13,10,;13 carriage etrurn ,10 line feed
User_mes1 DB "Please enter your Name: ",'$'
Press_mes2 DB "Press Enter key to continue",'$'
userName1 DB 15,?, 15 dup('$')
User_mes2 DB "Please enter 2nd player Name: ",'$'
userName2 DB 15,?, 15 dup('$')
;2nd screen output messages
mes1 DB "Choose one of the following: ",'$'
mes2 DB "*To start MineField game press F2",'$'
mes3 DB "*To end the program press ESC",10,13,'$'
SCORE_MSG DB ':Score:'
; Score, Number of digits, Score as a string
SCORE_P1 DW 0, ?, ?
SCORE_P2 DW 0, ?, ?
MAX_SCORE EQU 100
STATUS_PURPLE DB 'Choose a Box (Y / G / B)'
STATUS_PURPLE_LEN EQU 24
WIN_MSG1 DB 'PLAYER 1 WINS'
WIN_MSG2 DB 'PLAYER 2 WINS'
GAME_LEVEL DB 1
LVL_MSG DB 'Choose Level:'
LVL1_MSG DB '* Press F1 for Level 1'
LVL2_MSG DB '* Press F2 for Level 2'
ERROR_MSG DB 'ERROR: you entered a wrong key, please Re-enter F1 or F2:'
GAME_DESCRIPTION DB ' Here are some instructions for you:',10,13,10,13 ;,?
DB ' 1. The Left player move it using (w, s, a, d)',10,13
DB ' while the right one move it by the ordinary arrows.',10,13,10,13
DB ' 2. The coins are always good for you.',10,13,10,13
DB ' 3. Take care about boxes:',10,13,10,13,' - Red box:',9,' Make your score 0 (Be careful).',10,13
DB ' - Green box:',9,'Decrease your enemy score by 20.',10,13,' - Yellow box:',9,'increment your score by 15.' ,10,13
DB ' - Blue box:',9,'Remove the red boxes (bombs) from the grid.',10,13,' - Purple box:',9,'Let you choose one of the previous feature.',10,13
DB ' - White box:',9,'Put a bomb (Red box) near your enemy.',10,13,' - Aqua box:',9,'Remove all objects (boxes and coins) around the other player',10,13,10,13
DB ' 4. You won when your score reaches 100.',10,13,10,13,10,13
DB ' Press Any Key To Continue...$'
; Meo.bmp data
IMG_WID EQU 32
IMG_HEIGHT EQU 32
MEO DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19
DB 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 21, 22, 21, 21, 22, 22, 21, 21, 22, 21, 19, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 22, 22, 25, 27, 28, 89, 89, 89, 89, 28, 27, 25, 22, 22, 19, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 20, 22, 22, 26, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 26, 22, 22, 20, 0, 0, 0, 0, 0, 0, 20, 243, 243, 0, 0, 16, 21, 25
DB 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 25, 21, 16, 0, 0, 243, 243, 20, 245, 245, 20, 20, 20, 21, 24, 89, 89, 89, 28, 22, 27, 27, 27, 27
DB 27, 27, 27, 27, 22, 28, 89, 89, 89, 24, 21, 20, 20, 20, 245, 245, 0, 19, 20, 24, 26, 23, 26, 89, 89, 26, 21, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 21, 26, 89
DB 89, 26, 23, 26, 24, 20, 19, 0, 0, 0, 224, 20, 22, 28, 89, 89, 89, 26, 22, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 22, 26, 89, 89, 89, 28, 22, 20, 224, 0, 0
DB 0, 0, 0, 19, 21, 22, 89, 89, 90, 90, 27, 90, 30, 30, 30, 30, 30, 30, 30, 30, 90, 27, 90, 90, 89, 89, 22, 21, 19, 0, 0, 0, 0, 0, 0, 20, 21, 27, 90, 90
DB 23, 138, 138, 24, 29, 30, 30, 30, 30, 30, 30, 29, 24, 138, 138, 23, 90, 90, 27, 21, 20, 0, 0, 0, 0, 16, 20, 22, 28, 26, 26, 27, 20, 137, 137, 20, 90, 90, 90, 90
DB 90, 90, 90, 90, 20, 137, 137, 20, 27, 26, 26, 28, 22, 20, 16, 0, 243, 20, 20, 21, 21, 24, 28, 26, 19, 19, 22, 21, 27, 90, 90, 90, 90, 90, 90, 28, 19, 19, 20, 22
DB 25, 28, 24, 21, 21, 20, 20, 243, 245, 20, 19, 21, 24, 90, 90, 90, 20, 19, 20, 21, 90, 90, 90, 90, 90, 90, 90, 90, 21, 19, 19, 21, 28, 90, 90, 24, 21, 19, 20, 245
DB 0, 0, 0, 19, 22, 90, 90, 90, 90, 25, 25, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 26, 24, 28, 90, 90, 90, 22, 19, 0, 0, 0, 0, 0, 19, 19, 21, 29, 90, 90
DB 90, 90, 90, 90, 90, 25, 138, 138, 138, 138, 25, 90, 90, 90, 90, 90, 90, 90, 29, 21, 19, 19, 0, 0, 0, 0, 19, 20, 20, 23, 90, 90, 90, 90, 90, 90, 24, 139, 42, 43
DB 43, 42, 139, 24, 90, 90, 90, 90, 90, 90, 23, 20, 20, 19, 0, 0, 0, 16, 19, 20, 24, 24, 25, 90, 90, 90, 90, 90, 236, 6, 42, 138, 138, 42, 6, 235, 90, 90, 90, 90
DB 90, 25, 24, 24, 20, 19, 21, 0, 0, 19, 20, 20, 26, 87, 22, 28, 30, 90, 90, 27, 140, 43, 43, 42, 42, 43, 43, 140, 27, 90, 90, 30, 28, 22, 87, 26, 20, 20, 19, 0
DB 0, 19, 20, 20, 26, 87, 62, 21, 27, 28, 30, 27, 140, 42, 42, 42, 42, 42, 42, 140, 27, 30, 28, 27, 21, 62, 87, 26, 20, 20, 19, 0, 0, 19, 20, 20, 156, 62, 25, 20
DB 20, 21, 28, 25, 6, 6, 42, 139, 139, 42, 6, 140, 25, 28, 21, 20, 20, 25, 62, 156, 20, 20, 19, 0, 0, 19, 227, 20, 20, 20, 19, 19, 19, 20, 28, 21, 140, 43, 43, 43
DB 43, 43, 43, 140, 21, 28, 20, 19, 19, 19, 20, 20, 20, 227, 19, 0, 0, 0, 19, 20, 245, 19, 19, 19, 19, 20, 26, 20, 140, 6, 42, 137, 137, 42, 6, 140, 20, 26, 20, 19
DB 19, 19, 19, 245, 20, 19, 0, 0, 0, 0, 19, 20, 19, 19, 19, 19, 21, 20, 22, 19, 140, 43, 43, 43, 43, 43, 43, 140, 19, 22, 20, 21, 19, 19, 19, 19, 20, 19, 0, 0
DB 0, 0, 224, 19, 19, 19, 19, 0, 0, 20, 20, 19, 140, 6, 42, 139, 139, 42, 6, 139, 19, 20, 20, 0, 0, 19, 19, 19, 19, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 20, 20, 19, 20, 43, 43, 6, 6, 43, 43, 20, 19, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 245, 224, 0, 20, 140, 43, 14
DB 14, 43, 140, 20, 0, 224, 245, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 20, 236, 139, 139, 236, 20, 224, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 19, 19, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
; Pika.bmp data
IMG_WID2 EQU 32
IMG_HEIGHT2 EQU 32
PIKA DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
DB 16, 16, 16, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 245, 244, 244, 244, 20, 21, 166, 164
DB 164, 165, 167, 20, 20, 20, 21, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 244, 244, 20, 164, 66, 14, 14, 14, 14, 14, 14, 14, 67, 66, 24, 21, 21
DB 21, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 245, 244, 20, 25, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 67, 26, 21, 21, 21, 16, 16, 16, 16, 16
DB 16, 16, 16, 16, 245, 245, 244, 26, 14, 14, 14, 14, 14, 14, 14, 24, 24, 67, 14, 14, 14, 14, 14, 14, 27, 21, 21, 21, 16, 16, 16, 16, 16, 16, 16, 244, 245, 20, 20, 244
DB 25, 14, 14, 14, 14, 67, 21, 21, 21, 21, 67, 14, 14, 14, 14, 26, 21, 160, 21, 21, 21, 16, 16, 16, 16, 16, 16, 245, 20, 4, 4, 135, 20, 14, 14, 14, 14, 26, 20, 4
DB 12, 21, 25, 14, 14, 14, 67, 21, 160, 4, 4, 21, 21, 16, 16, 16, 16, 16, 243, 245, 136, 4, 4, 4, 244, 66, 14, 14, 14, 164, 135, 4, 4, 160, 164, 14, 14, 14, 66, 21
DB 12, 4, 4, 160, 21, 21, 16, 16, 16, 16, 245, 245, 136, 4, 4, 4, 244, 14, 14, 14, 26, 21, 20, 135, 137, 21, 167, 26, 67, 14, 67, 21, 4, 4, 4, 4, 21, 21, 16, 16
DB 16, 16, 245, 245, 20, 160, 160, 20, 164, 14, 14, 164, 20, 164, 165, 20, 20, 164, 164, 21, 25, 14, 14, 164, 21, 22, 22, 21, 21, 21, 16, 16, 16, 16, 245, 245, 165, 20, 20, 164
DB 14, 14, 14, 67, 67, 14, 14, 25, 25, 14, 14, 67, 67, 14, 14, 67, 24, 22, 21, 23, 21, 21, 16, 16, 16, 16, 21, 244, 164, 14, 14, 14, 14, 14, 14, 14, 14, 14, 66, 20
DB 20, 66, 14, 14, 14, 14, 14, 14, 68, 68, 68, 24, 21, 21, 16, 16, 16, 16, 16, 244, 20, 14, 14, 14, 67, 164, 24, 67, 14, 14, 14, 66, 66, 14, 14, 14, 67, 25, 25, 67
DB 68, 68, 67, 21, 21, 16, 16, 16, 16, 16, 16, 245, 244, 66, 14, 14, 165, 20, 20, 165, 14, 14, 14, 14, 14, 14, 14, 14, 164, 21, 21, 164, 68, 68, 66, 21, 21, 16, 16, 16
DB 16, 16, 16, 104, 244, 26, 14, 14, 20, 20, 26, 21, 14, 14, 14, 14, 14, 14, 14, 14, 22, 26, 21, 21, 68, 68, 27, 21, 104, 16, 16, 16, 16, 16, 16, 16, 244, 25, 14, 14
DB 164, 20, 26, 25, 14, 14, 14, 14, 14, 14, 14, 14, 25, 26, 21, 25, 68, 68, 25, 21, 16, 16, 16, 16, 16, 16, 16, 16, 244, 164, 14, 14, 14, 66, 66, 14, 14, 14, 14, 14
DB 14, 14, 14, 14, 14, 66, 66, 68, 68, 68, 24, 21, 16, 16, 16, 16, 16, 16, 16, 16, 244, 20, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 68, 68, 68
DB 68, 67, 21, 21, 16, 16, 16, 16, 16, 16, 16, 16, 20, 20, 27, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 68, 68, 68, 68, 68, 66, 21, 21, 16, 16, 16, 16
DB 16, 16, 16, 20, 244, 20, 164, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 68, 68, 68, 68, 68, 23, 21, 21, 21, 16, 16, 16, 16, 16, 20, 20, 21, 164, 20, 67
DB 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 68, 68, 68, 68, 68, 67, 21, 25, 22, 21, 174, 16, 16, 16, 104, 244, 20, 67, 14, 25, 67, 14, 14, 14, 14, 14, 14, 14, 14
DB 14, 14, 14, 68, 68, 68, 68, 68, 67, 25, 68, 67, 21, 175, 104, 16, 16, 244, 20, 20, 14, 14, 14, 14, 25, 27, 14, 14, 14, 14, 14, 14, 14, 14, 14, 68, 68, 67, 27, 25
DB 68, 68, 68, 67, 175, 174, 174, 16, 16, 244, 20, 20, 26, 14, 14, 14, 164, 20, 21, 25, 66, 14, 14, 14, 14, 14, 67, 67, 25, 22, 21, 24, 68, 68, 68, 66, 174, 174, 174, 16
DB 245, 20, 20, 20, 164, 14, 14, 14, 67, 21, 20, 20, 20, 21, 164, 164, 164, 164, 21, 21, 21, 21, 22, 67, 68, 68, 68, 24, 174, 174, 174, 175, 20, 20, 20, 20, 20, 14, 14, 67
DB 165, 20, 20, 16, 20, 20, 21, 21, 21, 21, 21, 21, 16, 21, 21, 23, 67, 68, 67, 22, 174, 174, 174, 174, 244, 20, 20, 20, 20, 26, 26, 21, 20, 20, 16, 16, 16, 16, 16, 16
DB 16, 16, 16, 16, 16, 16, 21, 21, 22, 27, 26, 174, 174, 174, 174, 174, 20, 20, 20, 20, 20, 20, 20, 20, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 152
DB 21, 175, 174, 174, 174, 174, 174, 22, 20, 20, 20, 20, 20, 20, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 175, 175, 174, 174, 174, 22, 22
DB 244, 20, 20, 20, 220, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 147, 175, 174, 174, 174, 16, 16, 16, 16, 16, 16, 16, 16
DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
;dollar.bmp data
IMG_WID3 EQU 16
IMG_HEIGHT3 EQU 16
DOLLAR DB 0, 0, 0, 0, 66, 66, 66, 66, 66, 66, 66, 66, 0, 0, 0, 0, 0, 0, 44, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 44
DB 0, 0, 0, 44, 66, 66, 66, 66, 14, 14, 14, 14, 66, 66, 66, 66, 44, 0, 0, 66, 66, 66, 14, 14, 14, 14, 14, 14, 14, 14, 66
DB 66, 66, 0, 66, 66, 66, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 66, 66, 66, 66, 66, 66, 14, 14, 14, 14, 66, 66, 14, 14
DB 14, 14, 66, 66, 66, 66, 66, 14, 14, 14, 14, 66, 14, 14, 66, 14, 14, 14, 14, 66, 66, 66, 66, 14, 14, 14, 14, 14, 14
DB 14, 14, 14, 14, 14, 14, 66, 66, 66, 66, 14, 14, 14, 14, 14, 14, 66, 14, 14, 14, 14, 14, 66, 66, 66, 66, 14, 14, 14
DB 14, 14, 14, 14, 66, 14, 14, 14, 14, 66, 66, 66, 66, 66, 14, 14, 14, 14, 66, 66, 14, 14, 14, 14, 66, 66, 66, 66, 66
DB 66, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 66, 66, 66, 0, 66, 66, 66, 14, 14, 14, 14, 14, 14, 14, 14, 66, 66, 66, 0
DB 0, 44, 66, 66, 66, 66, 14, 14, 14, 14, 66, 66, 66, 66, 44, 0, 0, 0, 44, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 44
DB 0, 0, 0, 0, 0, 0, 66, 66, 66, 66, 66, 66, 66, 66, 0, 0, 0, 0
MAX_GRID_WID EQU 640
MAX_GRID_HEIGHT EQU 344
BLACKBOX DB 1024 DUP(0)
BOX_PXS EQU 470
BLUE_BOX DB 470 DUP(9) ; Clears all red boxes from the whole grid
GREEN_BOX DB 470 DUP(10) ; Decreases other player's score by 20
AQUA_BOX DB 470 DUP(11) ; Removes every object around the other player
RED_BOX DB 470 DUP(12) ; Resets player's score
PURPLE_BOX DB 470 DUP(13) ; Lets the player choose a feature to proceed
YELLOW_BOX DB 470 DUP(14) ; Increases player's score by 15
WHITE_BOX DB 470 DUP(15) ; Adds a red box near the other player
TEMP_WID_16 EQU 16
TEMP_HEIGHT_16 EQU 16
TEMP_IMG_16 DB 256 DUP(?)
TEMP_WID_32 EQU 32
TEMP_HEIGHT_32 EQU 32
TEMP_IMG_32 DB 1024 DUP(?)
TEMP_BOX DB 470 DUP(?)
TEMP_X DW ?
TEMP_Y DW ?
; First Player's image, initial position and speed
PLAYER_IMG EQU MEO ; The name is defined above
X_POS DW 616 ; X and Y posistion of the player's right bottom corner
Y_POS DW 37
STEPX DW 80 ; Step in horizontal direction
STEPY DW 43 ; Step in vertical direction
; Second Player's image, initial position and speed
PLAYER_IMG2 EQU PIKA
X_POS2 DW 56
Y_POS2 DW 338
STEPX2 DW 80
STEPY2 DW 43
X_RAND_BOX DW ?
Y_RAND_BOX DW ?
X_RAND_COIN DW ?
Y_RAND_COIN DW ?
.CODE
; Key scancode
;
; Up Arrow 48
; Left Arrow 4B
; Right Arrow 4D
; Down Arrow 50
; w 11
; a 1E
; s 1F
; d 20
; r 13
; y 15
; g 22
; b 30
; F1 3B
; F2 3C
; Space 39
clearscreen PROC
MOV ah,0
MOV al,3
INT 10H
RET
clearscreen ENDP
PrintMessages PROC
;CALL clearscreen
;Printing Middle Messages
MOV ah,2 ;set cursor at middle of the screen
MOV DX,0A16h ;0C is low so i put 0A ;DL=x=16h,dh=y=0Ah
INT 10h
MOV ah,9
MOV DX,OFFSET mes1 ;print mes1
INT 21h
MOV ah,2 ;set cursor at middle of the sMahmsmscreen
MOV DX,0C16h ;increment row by 2 ;DL=x=16h,dh=y=0Ch
INT 10h
MOV ah,9
MOV DX,OFFSET mes2 ;print mes2
INT 21h
MOV ah,2 ;set cursor at middle of the screen
MOV DX,0E16h ;increment row by 2 ;DL=x=16h,dh=y=0Eh
INT 10h
MOV ah,9
MOV DX,OFFSET mes3 ;print mes3
INT 21h
; ;Printing Bottom Messages
; MOV ah,2 ;x=coloumn y=row
; MOV DX,1801h ;set cursor at bottom left of the screen ;DL=x=01h,dh=y=18h
; INT 10h
; MOV ah,9
; MOV DX,OFFSET mes4 ;print mes4
; INT 21h
; MOV ah,9
; MOV DX,OFFSET userName2+2 ;print username ;+2 because first 2 characters are garbage
; INT 21h
; MOV ah,2
; MOV DX,1901h ;set cursor at bottom left of the screen but alittle below 1st one ;DL=x=01h,dh=y=19h
; INT 10h
; MOV ah,9
; MOV DX,OFFSET mes5 ;print mes5
; INT 21h
; MOV ah,9
; MOV DX,OFFSET userName2+2 ;print username ;+2 because first 2 characters are garbage
; INT 21h
RET
PrintMessages ENDP
AskForUserName PROC
;CALL clearscreen
MOV ah,2
MOV DX,0C16h ;Set/Move Cursor to Middle postion
INT 10h
MOV ah,9
MOV DX,OFFSET User_mes1 ;print message
INT 21h
ReEnterName:
MOV ah,2
MOV DX,0D16h ;Set/Move Cursor to Middle postion (incremented row by 1)
INT 10h
MOV ah,0Ah ;Read user name from keyboard
MOV DX,OFFSET userName1
INT 21h
LEA bx,userName1 ;or MOV bx,OFFSET userName
;Validation of First Letter
MOV al,[bx]+2 ;because first byte is F->15
CMP al,'A' ;41h ;if Ascii less than A then its a special character
JB ReEnterName
;or JC
CMP al,'z' ;7Ah
JA ReEnterName ;if Ascii greater than z then its a special character
;or JNC
MOV cl, 96 ;move the character just before "a" to cl
sub cl, al ;do cl=cl-al ===> al contains the first letter of user name,,store the difference in cl,,say N"78" was first letter
CMP cl, 6 ;if difference in cl is smaller than 6, then invalid
JB ReEnterName ;special characters from 91d to 96d
;or JC
;-------------------------------------------------------------other user name
MOV ah,2
MOV DX,0E16h ;Set/Move Cursor to Middle postion
INT 10h
MOV ah,9
MOV DX,OFFSET User_mes2 ;print message
INT 21h
ReEnterName2:
MOV ah,2
MOV DX,0F16h ;Set/Move Cursor to Middle postion (incremented row by 1)
INT 10h
MOV ah,0Ah ;Read user name 2 from keyboard
MOV DX,OFFSET userName2
INT 21h
LEA bx,userName2 ;or MOV bx,OFFSET userName
;Validation of First Letter
MOV al,[bx]+2 ;because first byte is F->15
CMP al,'A';41h ;if Ascii less than A then its a special character
JB ReEnterName2
CMP al,'z' ;7Ah
JA ReEnterName2 ;if Ascii greater than z then its a special character
MOV cl, 96 ;move the character just before "a" to cl
sub cl, al ;do cl=cl-al ===> al contains the first letter of user name,,store the difference in cl,,say N"78" was first letter
CMP cl, 6 ;if difference in cl is smaller than 6, then invalid
JB ReEnterName2 ;special characters from 91d to 96d
;-------------------------------------------------------
MOV ah,2
MOV DX,1016h ;Set/Move Cursor to Middle postion (increment row by 1)
INT 10h
MOV ah,9
MOV DX,OFFSET Press_mes2 ;print other message
INT 21h
;Check for a keystroke
EnterLoop:
MOV ah,0
INT 16h ;get key pressed
CMP al, 13d ;Check the key was Enter
JNE EnterLoop ;enter key 0Dh
RET
AskForUserName ENDP
; Draws 8 X 8 Grid with 640 X 350 px of screen dimensions (VIDEO MODE AX = 0010H OR AX = 4F02H, BX = 0100)
DRAW_GRID PROC
MOV AH, 0CH ; Draw Pixel Command
MOV AL, 0fh ; grid's Pixel of light aqua color
MOV CX, 0 ;Starting ith position
MOV DX, 0 ;Starting jth position
INT 10H
FirstLineoftheSquare:
INT 10H
INC CX
CMP CX, 639
JNZ FirstLineoftheSquare
SecondLineoftheSquare:
INT 10H
INC DX
CMP DX, 343
JNZ SecondLineoftheSquare
ThirdLineoftheSquare:
INT 10H
dec CX
CMP CX, 0
JNZ ThirdLineoftheSquare
FourthLineoftheSquare:
INT 10H
dec DX
CMP DX, 0
JNZ FourthLineoftheSquare
MOV CX, 80
MOV DX, 0
;MOV bx, 344
vlone:
INT 10h
INC DX
CMP DX, 344
JNZ vlone
MOV CX, 160
MOV DX, 0
;MOV bx, 344
vltwo:
INT 10h
INC DX
CMP DX, 344
JNZ vltwo
MOV CX, 240
MOV DX, 0
;MOV bx, 344
vlthree:
INT 10h
INC DX
CMP DX, 344
JNZ vlthree
MOV CX, 320
MOV DX, 0
vlfour:
INT 10h
INC DX
CMP DX, 344
JNZ vlfour
MOV CX, 400
MOV DX, 0
;MOV bx, 344
vlfive:
INT 10h
INC DX
CMP DX, 344
JNZ vlfive
MOV CX, 480
MOV DX, 0
;MOV bx, 344
vlsix:
INT 10h
INC DX
CMP DX, 344
JNZ vlsix
MOV CX, 560
MOV DX, 0
;MOV bx, 344
vlseven:
INT 10h
INC DX
CMP DX, 344
JNZ vlseven
MOV CX, 640
MOV DX, 0
;MOV bx, 344
vleight:
INT 10h
INC DX
CMP DX, 344
JNZ vleight
MOV CX, 0
MOV DX, 43
hlone:
INT 10H
INC CX
CMP CX, 639
JNZ hlone
MOV CX, 0
MOV DX, 86
;MOV BX, 320
hltwo:
INT 10H
INC CX
CMP CX, 639
JNZ hltwo
MOV CX, 0
MOV DX, 129
;MOV BX, 320
hlthree:
INT 10H
INC CX
CMP CX, 639
JNZ hlthree
MOV CX, 0
MOV DX, 172
;MOV BX, 320
hlfour:
INT 10H
INC CX
CMP CX, 639
JNZ hlfour
MOV CX, 0
MOV DX, 215
;MOV BX, 320
hlfive:
INT 10H
INC CX
CMP CX, 639
JNZ hlfive
MOV CX, 0
MOV DX, 258
;MOV BX, 320
hlsix:
INT 10H
INC CX
CMP CX, 639
JNZ hlsix
MOV CX, 0
MOV DX, 301
;MOV BX, 320
hlseven:
INT 10H
INC CX
CMP CX, 639
JNZ hlseven
MOV CX, 0
MOV DX, 344
;MOV BX, 320
hleight:
INT 10H
INC CX
CMP CX, 639
JNZ hleight
RET
DRAW_GRID ENDP
; This macro does not accept X = 0 or Y = 0 as parameters
; It is recommended that X >= IMG_WID and Y >= IMG_HEIGHT
; X and Y are 16-bit values, so don't use 8-bit general registers
DRAW_IMAGE MACRO PLAYER_IMG, X, Y, WID, HEIGHT
LOCAL START, DRAW
MOV CX, X
MOV SI, X
SUB SI, WID
MOV DX, Y
MOV DI, Y
SUB DI, HEIGHT
LEA BX, PLAYER_IMG
JMP START
DRAW:
MOV AH, 0CH ;set the configuration to writing a pixel
MOV AL, [BX] ; color of the current coordinates
;MOV BH, 00H ;set the page number
INT 10H
START:
INC BX
DEC CX
CMP CX, SI
JNE DRAW
MOV CX, X
DEC DX
CMP DX, DI
JNE DRAW
ENDM DRAW_IMAGE
; This macro changes each pixel of the player to black
CLEAR_PLAYER MACRO X, Y
LOCAL START, CLEAR
MOV CX, X
MOV SI, X
SUB SI, IMG_WID
MOV DX, Y
MOV DI, Y
SUB DI, IMG_HEIGHT
JMP START
CLEAR:
MOV AX, 0C00H ; BLACK
INT 10H
START:
DEC CX
CMP CX, SI
JNE CLEAR
MOV CX, X
DEC DX
CMP DX, DI
JNE CLEAR
ENDM CLEAR_PLAYER
DRAW_RECT MACRO X, Y, LEN, WID
LOCAL DRAW_WID, DRAW_LEN
MOV CX, X ; X-Pos
MOV DX, Y ; Y-Pos
MOV AX, 0C0EH ; AH: Draw Pixel | AL: Color
; Draw the right and left sides
MOV BX, WID
ADD BX, DX
DRAW_WID:
INT 10H
ADD CX, LEN
INT 10H
SUB CX, LEN
INC DX
CMP DX, BX
JNE DRAW_WID
; Draw the top and bottom sides
MOV BX, LEN
ADD BX, CX
DRAW_LEN:
INT 10H
SUB DX, WID
INT 10H
ADD DX, WID
INC CX
CMP CX, BX
JNE DRAW_LEN
INT 10H
ENDM DRAW_RECT
DRAW_CUBOID MACRO X, Y, LEN, WID, HEIGHT
LOCAL DRAW_WID, DRAW_LEN, DRAW_HEIGHT, RIGHT, TOP
MOV CX, X ; X-Pos
MOV DX, Y ; Y-Pos
MOV AH, 0CH ; AH: Draw Pixel | AL: Color
MOV AL, 0EH
DRAW_RECT X, Y, LEN, HEIGHT
MOV BX, DX
MOV SI, WID
SHR SI, 1
SUB BX, SI
DRAW_WID:
INT 10H
SUB DX, HEIGHT
INT 10H
SUB CX, LEN
INT 10H
ADD CX, LEN
ADD DX, HEIGHT
INC CX
DEC DX
CMP DX, BX
JNE DRAW_WID
MOV BX, DX
SUB BX, HEIGHT
RIGHT:
INT 10H
DEC DX
CMP DX, BX
JNE RIGHT
MOV BX, CX
SUB BX, LEN
TOP:
INT 10H
DEC CX
CMP CX, BX
JNZ TOP
INT 10H
ENDM DRAW_CUBOID
DRAW_FILLED_RECT MACRO X, Y, LEN, WID, COLOR
LOCAL DRAW_WID, DRAW_LEN, FILL
MOV CX, X ; X-Pos
MOV DX, Y ; Y-Pos
MOV AH, 0CH ; AH: Draw Pixel | AL: Color
MOV AL, COLOR
; Draw the right and left sides
MOV BX, WID
ADD BX, DX
DRAW_WID:
INT 10H
MOV DI, CX
ADD DI, LEN
FILL:
INC CX
INT 10H
CMP CX, DI
JNE FILL
SUB CX, LEN
INC DX
CMP DX, BX
JNE DRAW_WID
ENDM DRAW_FILLED_RECT
DRAW_FILLED_CUBOID MACRO X, Y, LEN, WID, HEIGHT, COLOR
LOCAL DRAW, FILL_HEIGHT, FILL_LEN
MOV CX, X ; X-Pos
MOV DX, Y ; Y-Pos
MOV AH, 0CH ; AH: Draw Pixel
MOV AL, COLOR
; To draw the front side
;MOV BL, COLOR
;ADD BL, 8
DRAW_FILLED_RECT X, Y, LEN, HEIGHT, COLOR
ADD CX, LEN ; Reset X-Pos and Y-Pos to the bottom right corner
DEC DX
; To calculate the stop pos of the cuboid edges
MOV BX, DX
MOV SI, WID
SHR SI, 1
SUB BX, SI
MOV AL, COLOR ; Color of Top and Left sides
DRAW:
; To fill the right side of the cuboid
INT 10H
MOV DI, DX
SUB DI, HEIGHT
FILL_HEIGHT:
DEC DX
INT 10H
CMP DX, DI
JNE FILL_HEIGHT
; To fill the top side of the cuboid
MOV DI, CX
SUB DI, LEN
FILL_LEN:
DEC CX
INT 10H
CMP CX, DI
JNE FILL_LEN
ADD CX, LEN
ADD DX, HEIGHT
INC CX
DEC DX
CMP DX, BX
JNE DRAW
ENDM DRAW_FILLED_CUBOID
; initial X = 30
; initial Y = 15
DRAW_BOX MACRO X, Y, colour
DRAW_FILLED_CUBOID X, Y, 16, 12, 16, colour
ENDM DRAW_BOX
; initial X = 47
; initial Y = 30
DRAW_COIN MACRO X, Y
DRAW_IMAGE DOLLAR, X, Y, IMG_WID3, IMG_HEIGHT3
ENDM DRAW_COIN
DRAW_PLAYER MACRO PLAYER_IMG, X, Y
DRAW_IMAGE PLAYER_IMG, X, Y, IMG_WID, IMG_HEIGHT
ENDM DRAW_PLAYER
CHANGE_TO_VIDEO PROC
; Change to video mode 640 X 400 X 256
MOV AX, 4F02H
MOV BX, 0100H
INT 10h
; MOV AH,0Bh
RET
CHANGE_TO_VIDEO ENDP
; Don't pass registers
STORE_IMG_16 MACRO X, Y
LOCAL STORE, START
MOV CX, X
MOV SI, X
SUB SI, 16
MOV DX, Y
MOV DI, Y
SUB DI, 16
LEA BX, TEMP_IMG_16
;MOV [BX], 0
;MOV [BX+255], 0
JMP START
STORE:
MOV AH, 0DH
INT 10H
MOV [BX], AL
START:
INC BX
DEC CX
CMP CX, SI
JNE STORE
MOV CX, X
DEC DX
CMP DX, DI
JNE STORE
ENDM STORE_IMG_16
STORE_IMG_32 MACRO X, Y
LOCAL STORE, START
MOV CX, X
MOV SI, X
SUB SI, 32
MOV DX, Y
MOV DI, Y
SUB DI, 32
LEA BX, TEMP_IMG_32
JMP START
STORE:
MOV AH, 0DH
INT 10H
MOV [BX], AL
START:
INC BX
DEC CX
CMP CX, SI
JNE STORE
MOV CX, X
DEC DX
CMP DX, DI
JNE STORE
ENDM STORE_IMG_32
STORE_BOX MACRO X, Y
LOCAL READ_HEIGHT, FILL, DRAW, FILL_LEN, FILL_HEIGHT
MOV CX, X ; X-Pos
MOV DX, Y ; Y-Pos
MOV AH, 0DH ; AH: Read Pixel
; STORE RECT
; READ the right and left sides
MOV BX, 16 ; HEIGHT
ADD BX, DX
LEA SI, TEMP_BOX
READ_HEIGHT:
INT 10H
MOV [SI], AL
INC SI
MOV DI, CX
ADD DI, 16 ;LENGTH
FILL:
INC CX
INT 10H
MOV [SI], AL
INC SI
CMP CX, DI
JNE FILL
SUB CX, 16 ;LENGTH
INC DX
CMP DX, BX
JNE READ_HEIGHT
PUSH SI
;===================================
ADD CX, 16 ;LENGTH ; Reset X-Pos and Y-Pos to the bottom right corner
DEC DX
; To calculate the stop pos of the cuboid edges
MOV BX, DX
MOV SI, 12 ;WIDTH
SHR SI, 1
SUB BX, SI
POP SI
DRAW:
; To fill the right side of the cuboid
INT 10H
MOV [SI], AL
INC SI
MOV DI, DX
SUB DI, 16 ; HEIGHT
FILL_HEIGHT:
DEC DX
INT 10H
MOV [SI], AL
INC SI
CMP DX, DI
JNE FILL_HEIGHT
; To fill the top side of the cuboid
MOV DI, CX
SUB DI, 16 ;LENGTH
FILL_LEN:
DEC CX
INT 10H
MOV [SI], AL
INC SI
CMP CX, DI
JNE FILL_LEN
ADD CX, 16 ; LENGTH
ADD DX, 16 ; HEIGHT
INC CX
DEC DX
CMP DX, BX
JNE DRAW
ENDM STORE_BOX
; Use JE or JNE after comparing, if needed
COMPARE_OBJS MACRO OBJ1, OBJ2, NUM_OF_PX
LEA SI, OBJ1
LEA DI, OBJ2
MOV CX, NUM_OF_PX
REPE CMPSB
ENDM COMPARE_OBJS
STORE_IMG_RELATIVE PROC
MOV CX, X_POS
SUB CX, 9
MOV DX, Y_POS
SUB DX, 7
MOV TEMP_X, CX
MOV TEMP_Y, DX
STORE_IMG_16 TEMP_X, TEMP_Y
RET
STORE_IMG_RELATIVE ENDP
RANDGEN PROC
; A procedure which produce a random value in DX
MOV AH, 00h ; interrupts to get system time
INT 1AH ; CX:DX now hold number of clock ticks since midnight
MOV ax, DX
XOR DX, DX
MOV CX, 10
DIV CX ; here DX contains the remainder of the division - from 0 to 9
;add DL, '0' ; to ascii from '0' to '9'
;MOV ah, 2h ; call interrupt to display a value in DL
;INT 21h
RET
RANDGEN ENDP
DRAW_RAND_BOX MACRO Colour
Local ReGenRand1, ReGenRand2 , TERMINATE
ReGenRand1:
call RandGen
MOV AX, 80
sub DL, 2
Mul DL
Sub AX, 50
CMP AX, 640
JNC ReGenRand1
MOV X_RAND_Box, AX
ReGenRand2:
call RandGen
MOV AX, 43
add DL, 3
Mul DL
sub AX, 28
CMP AX, 350
JNC ReGenRand2
MOV Y_RAND_Box, AX
STORE_BOX X_RAND_BOX, Y_RAND_Box
COMPARE_OBJS TEMP_BOX, BLACKBOX, BOX_PXS
JNE TERMINATE
DRAW_BOX X_RAND_Box, Y_RAND_Box , Colour
TERMINATE:
ENDM DRAW_RAND_BOX
DRAW_RAND_COIN PROC
ReGenRandCoin1:
call RandGen
MOV AX, 80
INC DL
Mul DL
Add AX, 47
CMP AX, 640