-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.asm
More file actions
7228 lines (6223 loc) · 224 KB
/
Main.asm
File metadata and controls
7228 lines (6223 loc) · 224 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
;================================================= MACROS ======================================================= ;
;; ------------------------------------------------ GUI MACROS --------------------------------------------------;;
PrintChar MACRO chara
PUSHA
;draw X in the cursor position
mov ah,0ah
mov al,chara
mov bh,0h
mov bl,0fh
mov cx,1
int 10H
POPA
ENDM PrintChar
PrintChar_black MACRO chara
;draw X in the cursor position
;;blabla
mov ah,0ah
mov al,chara
mov bh,0h
mov bl,0h
mov cx,1
int 10H
ENDM PrintChar_black
Set MACRO Yposition, Xposition
PUSHA
mov cx,0
; set cursor position
mov ah,2h
mov bh,0h
mov dh,Yposition
mov dl,Xposition
int 10h
POPA
ENDM Set
draw_obj MACRO colr
;draw X in the cursor position
mov ah,0ah
mov al,'o'
mov bh,0h
mov bl,colr
mov cx,1
int 10H
ENDM draw_obj
draw_point MACRO chr,clr
mov ah,0ah
mov al,chr
mov bh,0h
mov bl,clr
mov cx,1
int 10H
ENDM
;; ---------------------------------------------- Commands MACROS ---------------------------------------------;;
DstOpReg MACRO p1_Reg, p2_Reg
LOCAL p1_DstValReg, p2_DstValReg
CMP p1_CpuEnabled, 1
JZ p1_DstValReg
CMP p2_CpuEnabled, 1
JZ p2_DstValReg
JMP RETURN_DstSrc
p1_DstValReg:
LEA DI, p1_Reg
JMP RETURN_DstSrc
p2_DstValReg:
LEA DI, p2_Reg
JMP RETURN_DstSrc
ENDM
SrcOpReg MACRO p1_Reg, p2_Reg
LOCAL p1_SrcValReg, p2_SrcValReg
CMP p1_CpuEnabled, 1
JZ p1_SrcValReg
CMP p2_CpuEnabled, 1
JZ p2_SrcValReg
JMP RETURN_GetSrcOp
p1_SrcValReg:
mov AX, p1_Reg
JMP RETURN_GetSrcOp
p2_SrcValReg:
MOV AX, p2_Reg
JMP RETURN_GetSrcOp
ENDM
SrcOpReg_8bit MACRO p1_Reg, p2_Reg
LOCAL p1_SrcValReg, p2_SrcValReg
CMP p1_CpuEnabled, 1
JZ p1_SrcValReg
CMP p2_CpuEnabled, 1
JZ p2_SrcValReg
JMP RETURN_GetSrcOp_8Bit
p1_SrcValReg:
mov AL, BYTE PTR p1_Reg
JMP RETURN_GetSrcOp_8Bit
p2_SrcValReg:
mov AL, BYTE PTR p2_Reg
JMP RETURN_GetSrcOp_8Bit
ENDM
DstOpAddReg MACRO p1_Reg, p2_Reg
LOCAL p1_DstValAddReg, p2_DstValAddReg, p1_ValidAddress, p2_ValidAddress
CMP p1_CpuEnabled, 1
JZ p1_DstValAddReg
CMP p2_CpuEnabled, 1
JZ p2_DstValAddReg
JMP RETURN_DstSrc
p1_DstValAddReg:
MOV DX, p1_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p1_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_DstSrc
p1_ValidAddress:
MOV BX, p1_Reg
LEA DI, ourValMem[BX]
JMP RETURN_DstSrc
p2_DstValAddReg:
MOV DX, p2_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p2_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_DstSrc
p2_ValidAddress:
MOV BX, p2_Reg
LEA DI, ValMem[BX]
JMP RETURN_DstSrc
ENDM
SrcOpAddReg MACRO p1_Reg, p2_Reg
LOCAL p1_SrcOpAddReg, p2_SrcOpAddReg, p1_ValidAddress, p2_ValidAddress
CMP p1_CpuEnabled, 1
JZ p1_SrcOpAddReg
CMP p2_CpuEnabled, 1
JZ p2_SrcOpAddReg
JMP RETURN_GetSrcOp
p1_SrcOpAddReg:
MOV DX, p1_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p1_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_GetSrcOp
p1_ValidAddress:
MOV SI, p1_Reg
MOV AX, WORD PTR ourValMem[SI]
JMP RETURN_GetSrcOp
p2_SrcOpAddReg:
MOV DX, p2_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p2_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_GetSrcOp
p2_ValidAddress:
MOV SI, p2_Reg
MOV AX, WORD PTR ValMem[SI]
JMP RETURN_GetSrcOp
ENDM
SrcOpAddReg_8bit MACRO p1_Reg, p2_Reg
LOCAL p1_SrcOpAddReg, p2_SrcOpAddReg, p1_ValidAddress, p2_ValidAddress
CMP p1_CpuEnabled, 1
JZ p1_SrcOpAddReg
CMP p2_CpuEnabled, 1
JZ p2_SrcOpAddReg
JMP RETURN_GetSrcOp_8Bit
p1_SrcOpAddReg:
MOV DX, p1_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p1_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_GetSrcOp_8Bit
p1_ValidAddress:
MOV SI, p1_Reg
MOV AL, ourValMem[SI]
JMP RETURN_GetSrcOp_8Bit
p2_SrcOpAddReg:
MOV DX, p2_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p2_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_GetSrcOp_8Bit
p2_ValidAddress:
MOV SI, p2_Reg
MOV AL, ValMem[SI]
JMP RETURN_GetSrcOp_8Bit
ENDM
CheckForbidCharMacro MACRO comm
Local ValidCommand
mov di, comm
Call CheckForbidChar
CMP bl, 1
jnz ValidCommand
MOV isInvalidCommand, 1
ValidCommand:
ENDM
SendMem MACRO Mem
LOCAL SendMem
MOV CX,16
LEA SI, Mem
SendMem:
CALL SendData
inc si
DEC CX
JNZ SendMem
ENDM
RecMem MACRO Mem
LOCAL RecMem
MOV CX, 16
LEA DI, Mem
RecMem:
CALL RecieveByte
MOV [DI], BL
inc DI
DEC CX
JNZ RecMem
ENDM
SendRegister MACRO ValReg
LOCAL SendReg
MOV CX,2
LEA SI, ValReg
SendReg:
CALL SendData
inc si
DEC CX
JNZ SendReg
ENDM
RecieveRegister MACRO ValReg
LOCAL recReg
MOV CX, 2
LEA DI, ValReg
RecReg:
CALL RecieveByte
MOV [DI], BL
inc di
DEC CX
JNZ RecReg
ENDM
;================================================================================================================
.MODEL HUGE
;----------------
.386
.STACK 64
;================================================================================================================
.DATA
;---------------------------------------LEFT PROCESSOR----------------------------------------------:
; positions of X axis of the AX register in right processor
p1_AX_X1 EQU 44
p1_AX_X3 EQU 46
p1_AX_Y EQU 4 ; the Y axis of the AX register of the left processor
; positions of X axis of the BX register in right processor
p1_BX_X1 EQU 44
p1_BX_X3 EQU 46
p1_BX_Y EQU 6 ; the Y axis of the AX register of the left processor
; position of X axis of the DX register in right processor
p1_CX_X1 EQU 44
p1_CX_X3 EQU 46
p1_CX_Y EQU 8 ; the Y axis of the AX register of the left processor
; positions of X axis of the DX register in right processor
p1_DX_X1 EQU 44
p1_DX_X3 EQU 46
p1_DX_Y EQU 10 ; the Y axis of the AX register of the left processor
; positions of X axis of SP register in right processor
p1_SP_X1 equ 49
p1_SP_X3 EQU 51
p1_SP_Y equ 4 ; the Y position of SP register in the left processor
; positions of X axis of BP register in right processor
p1_BP_X1 equ 49
p1_BP_X3 EQU 51
p1_BP_Y equ 6 ; the Y position of BP register in the left processor
; positions of X axis of SI register in right processor
p1_SI_X1 equ 49
p1_SI_X3 EQU 51
p1_SI_Y equ 8 ; the Y position of SI register in the left processor
; positions of X axis of DI register in right processor
p1_DI_X1 equ 49
p1_DI_X3 EQU 51
p1_DI_Y equ 10 ; the Y position of SI register in the left processor
;---------------------------------------RIGHT PROCESSOR----------------------------------------------:
; positions of X axis of the AX register in right processor
p2_AX_X1 EQU 107
p2_AX_X3 EQU 109
p2_AX_Y EQU 4 ; the Y axis of the AX register of the left processor
; positions of X axis of the BX register in right processor
p2_BX_X1 EQU 107
p2_BX_X3 EQU 109
p2_BX_Y EQU 6 ; the Y axis of the AX register of the left processor
; positions of X axis of the DX register in right processor
p2_CX_X1 EQU 107
p2_CX_X3 EQU 109
p2_CX_Y EQU 8 ; the Y axis of the AX register of the left processor
; positions of X axis of the DX register in right processor
p2_DX_X1 EQU 107
p2_DX_X3 EQU 109
p2_DX_Y EQU 10 ; the Y axis of the AX register of the left processor
; positions of X axis of SP register in right processor
p2_SP_X1 equ 113
p2_SP_X3 EQU 115
p2_SP_Y equ 4 ; the Y position of SP register in the left processor
; positions of X axis of BP register in right processor
p2_BP_X1 equ 113
p2_BP_X3 EQU 115
p2_BP_Y equ 6 ; the Y position of BP register in the left processor
; positions of X axis of SI register in right processor
p2_SI_X1 equ 113
p2_SI_X3 EQU 115
p2_SI_Y equ 8 ; the Y position of SI register in the left processor
; positions of X axis of DI register in right processor
p2_DI_X1 equ 113
p2_DI_X3 EQU 115
p2_DI_Y equ 10 ; the Y position of SI register in the left processor
;-----------------------------------------------------LEFT MEMORY-----------------------------------------------------
; X positions of values of left memory
left_mem_X0 equ 97
left_mem_X1 equ 98
left_mem_X2 equ 97
left_mem_X3 equ 98
left_mem_X4 equ 97
left_mem_X5 equ 98
left_mem_X6 equ 97
left_mem_X7 equ 98
left_mem_X8 equ 97
left_mem_X9 equ 98
left_mem_X10 equ 97
left_mem_X11 equ 98
left_mem_X12 equ 97
left_mem_X13 equ 98
left_mem_X14 equ 97
left_mem_X15 equ 98
left_mem_X16 equ 97
left_mem_X17 equ 98
left_mem_X18 equ 97
left_mem_X19 equ 98
left_mem_X20 equ 97
left_mem_X21 equ 98
left_mem_X22 equ 97
left_mem_X23 equ 98
left_mem_X24 equ 97
left_mem_X25 equ 98
left_mem_X26 equ 97
left_mem_X27 equ 98
left_mem_X28 equ 97
left_mem_X29 equ 98
left_mem_X30 equ 97
left_mem_X31 equ 98
; Y positions of values in left memory
left_mem_Y0 equ 2
left_mem_Y1 equ 2
left_mem_Y2 equ 3
left_mem_Y3 equ 3
left_mem_Y4 equ 4
left_mem_Y5 equ 4
left_mem_Y6 equ 5
left_mem_Y7 equ 5
left_mem_Y8 equ 6
left_mem_Y9 equ 6
left_mem_Y10 equ 7
left_mem_Y11 equ 7
left_mem_Y12 equ 8
left_mem_Y13 equ 8
left_mem_Y14 equ 9
left_mem_Y15 equ 9
left_mem_Y16 equ 11
left_mem_Y17 equ 11
left_mem_Y18 equ 12
left_mem_Y19 equ 12
left_mem_Y20 equ 13
left_mem_Y21 equ 13
left_mem_Y22 equ 14
left_mem_Y23 equ 14
left_mem_Y24 equ 15
left_mem_Y25 equ 15
left_mem_Y26 equ 16
left_mem_Y27 equ 16
left_mem_Y28 equ 17
left_mem_Y29 equ 17
left_mem_Y30 equ 18
left_mem_Y31 equ 18
;-----------------------------------------------------RIGHT MEMORY-----------------------------------------------------
; X positions of values of left memory
right_mem_X0 equ 101
right_mem_X1 equ 102
right_mem_X2 equ 101
right_mem_X3 equ 102
right_mem_X4 equ 101
right_mem_X5 equ 102
right_mem_X6 equ 101
right_mem_X7 equ 102
right_mem_X8 equ 101
right_mem_X9 equ 102
right_mem_X10 equ 101
right_mem_X11 equ 102
right_mem_X12 equ 101
right_mem_X13 equ 102
right_mem_X14 equ 101
right_mem_X15 equ 102
right_mem_X16 equ 101
right_mem_X17 equ 102
right_mem_X18 equ 101
right_mem_X19 equ 102
right_mem_X20 equ 101
right_mem_X21 equ 102
right_mem_X22 equ 101
right_mem_X23 equ 102
right_mem_X24 equ 101
right_mem_X25 equ 102
right_mem_X26 equ 101
right_mem_X27 equ 102
right_mem_X28 equ 101
right_mem_X29 equ 102
right_mem_X30 equ 101
right_mem_X31 equ 102
; Y positions of values in left memory
right_mem_Y0 equ 2
right_mem_Y1 equ 2
right_mem_Y2 equ 3
right_mem_Y3 equ 3
right_mem_Y4 equ 4
right_mem_Y5 equ 4
right_mem_Y6 equ 5
right_mem_Y7 equ 5
right_mem_Y8 equ 6
right_mem_Y9 equ 6
right_mem_Y10 equ 7
right_mem_Y11 equ 7
right_mem_Y12 equ 8
right_mem_Y13 equ 8
right_mem_Y14 equ 9
right_mem_Y15 equ 9
right_mem_Y16 equ 11
right_mem_Y17 equ 11
right_mem_Y18 equ 12
right_mem_Y19 equ 12
right_mem_Y20 equ 13
right_mem_Y21 equ 13
right_mem_Y22 equ 14
right_mem_Y23 equ 14
right_mem_Y24 equ 15
right_mem_Y25 equ 15
right_mem_Y26 equ 16
right_mem_Y27 equ 16
right_mem_Y28 equ 17
right_mem_Y29 equ 17
right_mem_Y30 equ 18
right_mem_Y31 equ 18
; ----------------------------------------------- Keys Scan Codes ------------------------------------------- ;
UpArrowScanCode EQU 72
DownArrowScanCode EQU 80
RightScanCode EQU 77
LeftScanCode EQU 75
EnterScanCode EQU 28
SpaceScanCode EQU 57
EscScanCode EQU 1
F1ScanCode EQU 59
F2ScanCode EQU 60
; ------------------------------------------------ Test Messages -------------------------------------------- ;
mesSelCom db 10,'You have selected Command #', '$'
mesSelOp1Type db 10,'You have selected Operand 1 of Type #', '$'
mesSelReg db 10, 'You have selected Reg #', '$'
mesSelMem db 10, 'You have selected Mem #', '$'
mesEntVal db 10, 'You Entered value: ', '$'
mesOponentData db 10, '--------- Oponent Data ----------', 10, '$'
mesMyData db 10 , '------------ My Data ------------', 10, '$'
mesBackScreen db 10, 'Press any key to return to the game.', 10, '$'
mesMem db 10, 'Values Opponent in memory as Ascii: ', 10, '$'
mesStack db 10, 'Values in stack as Ascii: ', 10, '$'
mesStackPointer db 10, 'Value of stack pointer: ', 10 , '$'
mesTest db 10, ' TESTTTTTTT ', 10 , '$'
mesRegAX db 10, 'Value of AX: ', '$'
mesRegBX db 9, 'Value of BX: ', '$'
mesRegCX db 10, 'Value of CX: ', '$'
mesRegDX db 9, 'Value of DX: ', '$'
mesRegSI db 10, 'Value of SI: ', '$'
mesRegDI db 9, 'Value of DI: ', '$'
mesRegBP db 10, 'Value of BP: ', '$'
mesRegSP db 9, 'Value of SP: ', '$'
mesRegCF db 10, 'Value of CF: ', '$'
mesPoints db 9, 'Score: ', '$'
mesForbidChar db 10, 'Forbid Char: ', '$'
error db 13,10,"Error Input",'$'
; --------------------------------------------- Interface Variables ----------------------------------------- ;
MESG3 DB "Please, Enter Your Name: $"
MESG4 DB "Press Any Key to Start the Game...$"
MESG6 DB "Initial Points : $"
MESG7 DB "Level 1 OR 2 : $"
MESG8 DB "What is the forbidden Character? $"
CHOICE2 DB "Start Chatting$"
CHOICE1 DB "Start The Journey$"
CHOICE3 DB "Exit if you are afraid$"
BORDER1 DB 10,13," ------------------------------------------------------------------------------"
DB 10,13,"** # WELCOME TO MP Project Game # **"
DB 10,13," ------------------------------------------------------------------------------$"
BORDER2 DB 10,13," ------------------------------------------------------------------------------"
DB 10,13,"** # BE READY AND SMART # **"
DB " ------------------------------------------------------------------------------$"
BORDER3 DB 10,13,"------------------------------------------------------------------------------"
DB 10,13,"** # Notification Bar # **"
DB " ------------------------------------------------------------------------------$"
ChatInviteMsg DB 10, 'You have recieved a chat invitation, to accept it press F1 key!$'
GameInviteMsg DB 10, 'You have recieved a game invitation, to accept it press F2 key!$'
NAMEP1 DB 16 DUP('$')
NAMEP1LEN DW 0
NAMEP2 DB 16 DUP('$')
NAMEP2LEN DW 0
NAMELENGTH DW 0
InitialPoints DB 0
InitialPointsP1 DB 0
InitialPointsP2 DB 0
CHOSEN DB 1 ; CHOSEN CHOICE IN THE MAIN SCREEN
; ----------------------------------------------- GUI Variables --------------------------------------------- ;
; Define the variables
SerialData DB ?
X2position db 9
XpositionShooter1 db 8
XpositionShooter2 db 32
inputKey db ?
XbulletShooter1 db 8
YbulletShooter1 db 18
XbulletShooter2 db 32
YbulletShooter2 db 18
X_Arr db 2,2,24,24
red_pt db '1'
blue_pt db '1'
yellow_pt db '1'
ball_colr db 0ch
X db 0
Y db 1
x_axis db ?
y_axis db ?
text db 'string$'
InstructionMsg db 10, 'Use Up/Down Arrows to navigate between commands. ', '$'
ExecutionFailed db 10, 'Invalid Command. Press Enter to continue. ', '$'
ExecutedSuccesfully db 10, 'Command Executed Sucessfully. Press Enter to continue. ', '$'
PlayerTwoWaitRound db 10, 'Waiting for player two... Press Enter to skip ', '$'
ChangeForbidMsg db 10, 'Press the new forbidden char: ', '$'
LineStuckIndexMsg db 10, 'Enter the number of the stuck data line (0-15): ', '$'
LineStuckValMsg db 10, 'Enter the value to be stuck at (0/1): ', '$'
NoAvailablePointsMsg db 10, 'No Available points.', '$'
ClearCommandSpace db 15 dup(' '), '$'
Player1WinsMsg db 10, 'You Won! Congrats$', 10
Player2WinsMsg db 10, 'You lost!$', 10
; ---------------------------------------------- Cursor Locations ------------------------------------------- ;
MenmonicCursorLoc EQU 1500H
Op1CursorLoc EQU 1506H
CommaCursorLoc EQU 150BH
Op2CursorLoc EQU 150CH
PUPCursorLoc EQU 1500H
ForbidPUPCursor EQU 1516H
; --------------------------------------------- Commands Variables -------------------------------------------;
; ------------------------------- Menu Commands Variables --------------------------- ;
; ---------- Menu Strings -------- ;
CommStringSize EQU 6
SubPwrUpSize EQU 13
NOPcom db 'NOP ','$'
CLCcom db 'CLC ','$'
MOVcom db 'MOV ','$'
ADDcom db 'ADD ','$'
ADCcom db 'ADC ','$'
ANDcom db 'AND ','$'
PUSHcom db 'PUSH ','$'
POPcom db 'POP ','$'
INCcom db 'INC ','$'
DECcom db 'DEC ','$'
MULcom db 'MUL ','$'
DIVcom db 'DIV ','$'
IMULcom db 'IMUL ','$'
IDIVcom db 'IDIV ','$'
RORcom db 'ROR ','$'
ROLcom db 'ROL ','$'
RCRcom db 'RCR ','$'
RCLcom db 'RCL ','$'
SHLcom db 'SHL ','$'
SHRcom db 'SHR ','$'
Reg db 'REG ','$'
AddReg db '[REG]', '$'
Memory db 'MEM ','$'
Value db 'VAL ','$'
RegIndex EQU 0
AddRegIndex EQU 1
MemIndex EQU 2
ValIndex EQU 3
RegAX db 'AX ','$' ;0
RegAL db 'AL ','$' ;1
RegAH db 'AH ','$' ;2
RegBX db 'BX ','$' ;3
RegBL db 'BL ','$' ;4
RegBH db 'BH ','$' ;5
RegCX db 'CX ','$' ;6
RegCL db 'CL ','$' ;7
RegCH db 'CH ','$' ;8
RegDX db 'DX ','$' ;9
RegDL db 'DL ','$' ;10
RegDH db 'DH ','$' ;11
RegSX db 'SX ','$' ;12
RegSL db 'SL ','$' ;13
RegSH db 'SH ','$' ;14
RegBP db 'BP ','$' ;15
RegSP db 'SP ','$' ;16
RegSI db 'SI ','$' ;17
RegDI db 'DI ','$' ;18
AddRegAX db '[AX] ','$' ;0
AddRegAL db '[AL] ','$' ;1
AddRegAH db '[AH] ','$' ;2
AddRegBX db '[BX] ','$' ;3
AddRegBL db '[BL] ','$' ;4
AddRegBH db '[BH] ','$' ;5
AddRegCX db '[CX] ','$' ;6
AddRegCL db '[CL] ','$' ;7
AddRegCH db '[CH] ','$' ;8
AddRegDX db '[DX] ','$' ;9
AddRegDL db '[DL] ','$' ;10
AddRegDH db '[DH] ','$' ;11
AddRegSX db '[SX] ','$' ;12
AddRegSL db '[SL] ','$' ;13
AddRegSH db '[SH] ','$' ;14
AddRegBP db '[BP] ','$' ;15
AddRegSP db '[SP] ','$'
AddRegSI db '[SI] ','$'
AddRegDI db '[DI] ','$'
Mem0 db '[0] ','$'
Mem1 db '[1] ','$'
Mem2 db '[2] ','$'
Mem3 db '[3] ','$'
Mem4 db '[4] ','$'
Mem5 db '[5] ','$'
Mem6 db '[6] ','$'
Mem7 db '[7] ','$'
Mem8 db '[8] ','$'
Mem9 db '[9] ','$'
Mem10 db '[A] ','$'
Mem11 db '[B] ','$'
Mem12 db '[C] ','$'
Mem13 db '[D] ','$'
Mem14 db '[E] ','$'
Mem15 db '[F] ','$'
NOPUP db 'NoPo ','$'
PUP1 db 'PUp1 ','$'
PUP2 db 'PUp2 ','$'
PUP3 db 'PUp3 ','$'
PUP4 db 'PUp4 ','$'
PUP5 db 'PUp5 ','$'
DataIndex0 db 'Data Line 0 ','$'
DataIndex1 db 'Data Line 1 ','$'
DataIndex2 db 'Data Line 2 ','$'
DataIndex3 db 'Data Line 3 ','$'
DataIndex4 db 'Data Line 4 ','$'
DataIndex5 db 'Data Line 5 ','$'
DataIndex6 db 'Data Line 6 ','$'
DataIndex7 db 'Data Line 7 ','$'
DataIndex8 db 'Data Line 8 ','$'
DataIndex9 db 'Data Line 9 ','$'
DataIndex10 db 'Data Line 10','$'
DataIndex11 db 'Data Line 11','$'
DataIndex12 db 'Data Line 12','$'
DataIndex13 db 'Data Line 13','$'
DataIndex14 db 'Data Line 14','$'
DataIndex15 db 'Data Line 15','$'
StuckVal0 db 'Stuck Val: 0', '$'
StuckVal1 db 'Stuck Val: 1', '$'
; ----- Selection Variables ------ ;
selectedPUPType db -1, '$'
selectedComm db -1, '$'
selectedOp1Type db -1, '$'
selectedOp1Reg db -1, '$'
selectedOp1AddReg db -1, '$'
selectedOp1Mem db -1, '$'
selectedOp1Size db 8, '$'
Op1Val dw 0
Op1Valid db 1 ; 0 if Invalid
selectedOp2Type db -1, '$'
selectedOp2Reg db -1, '$'
selectedOp2AddReg db -1, '$'
selectedOp2Mem db -1, '$'
selectedOp2Size db 8, '$'
Op2Val dw 0
Op2Valid db 1 ; 0 if Invalid
; --- Operand Value Variables -----;
ClearSpace db ' ', '$'
num db 30,?,30 DUP(?)
StrSize db ?
num2 db 30,?,30 DUP(?)
StrSize2 db ?
a EQU 1000H
B EQU 100H
C EQU 10H
cc equ 10
; ------------------------------------- Game Variables ------------------------------ ;
; ----------- Opponent Data ----------;
ValRegAX dw 'AX'
ValRegBX dw 'BX'
ValRegCX dw 'CX'
ValRegDX dw 'DX'
ValRegBP dw 'BP'
ValRegSP dw 0
ValRegSI dw 'SI'
ValRegDI dw 5677H
ValMem db 16 dup('M'), '$'
ValStack dw 8 dup('S'), '$'
ValCF db 1
; ------------ Player Data -----------;
ourValRegAX dw 'AX'
ourValRegBX dw 'BX'
ourValRegCX dw 'CX'
ourValRegDX dw 'DX'
ourValRegBP dw 'BP'
ourValRegSP dw 0
ourValRegSI dw 'SI'
ourValRegDI dw 'DI'
ourValMem db 16 dup('M'), '$'
ourValStack dw 8 dup('S'), '$'
ourValCF db 0
; --------- Score and others --------;
Player1_Points DB 8
Player2_Points DB 0
Player1_ForbidChar DB 0
Player2_ForbidChar DB 'Z'
LEVEL DB 0
isInvalidCommand db 0 ; 1 if Invalid
p1_CpuEnabled db 0 ; 1 if command will run on it
p2_CpuEnabled db 1 ; ..
; ------- Power Up Variables --------;
isPwrUp3Used db 0 ;Chance to use forbiden power up
isPwrUp5Used db 0
ourPwrUpDataLineIndex db 1
ourPwrUpStuckVal db 1
ourPwrUpStuckEnabled db 0
opponentPwrUpDataLineIndex db 0
opponentPwrUpStuckVal db 0
opponentPwrUpStuckEnabled db 0
; ---------- Connection Variables ----- ;
GameInvite db 0
ChatInvite db 0
AcceptGame db 0
AcceptChat db 0
HOST DB 0
;------------------------------------------------ Chat Variables -------------------------------------------- ;
invrecieve db ?
invsend db ?
firs_half dw 0400h
Xsend db ?
Yrecieve db ?
sec_half dw 0f00h
border db "--------------------------------------------------------------------------------"
db "***** BOTH PLAYERS ARE ONLINE *****"
db "--------------------------------------------------------------------------------$"
Line db "--------------------------------------------------------------------------------$"
;----------------------------------------- Serial Communication VARIABLES ----------------------------------- ;
Char_Send DB ?
Char_Recieve DB ?
Exit_Chat DB 0
;===============================================================================================================
.CODE
MAIN PROC FAR
MOV AX,@DATA ; LOAD THE DATA VARIABLES
MOV DS,AX
MOV ES,AX
; JMP TestSkip
MAIN_MENU:
;---------------------------------------------------------------------------------------------------------------------------------------
MOV AH,0 ; CHOOSING VIDEO MODE "TEXT MODE"
MOV AL,3 ; 80 X 25 CHARS
INT 10H
;----------------------------------------------Taking PLAYERS' NAMES--------------------------------------------------------------------
Call configuration ; This procedure is used for initializing the UART (baud rate: The baud rate is the rate
; at which information is transferred in a communication channel, parity, data bits, stop bits,…)
MOV DL, 1 ; INITIALIZING THE COORDIANATES OF THE CURSOR
MOV DH, 1
CALL MOVECURSOR
MOV DX,OFFSET BORDER1
CALL PRINTMESSAGE ; DRAW THE BORDERS OF THE SCREEN
MOV DL, 0 ; INITIALIZING THE COORDIANATES OF THE CURSOR
MOV DH, 22
CALL MOVECURSOR
MOV DX,OFFSET BORDER2
CALL PRINTMESSAGE ; DRAW THE BORDERS OF THE SCREEN
MOV BP, OFFSET NAMEP1 ; SAVE THE NAME OF THE FIRST PLAYER IN NAMEP1
CALL FIRSTSCREEN ; CALL THE FIRST SCREEN OF THE PROJECT
MOV DX, NAMELENGTH
MOV NAMEP1LEN, DX
MOV NAMELENGTH,0
MOV DH , InitialPoints
MOV InitialPointsP1, DH
CALL CLEARSCREEN
MOV DL, 1
MOV DH, 1
CALL MOVECURSOR
MOV DX,OFFSET BORDER1
CALL PRINTMESSAGE
;MOV DL, 0
;MOV DH, 22
;CALL MOVECURSOR
;MOV DX,OFFSET BORDER2
;CALL PRINTMESSAGE
;MOV BP, OFFSET NAMEP2 ; SAVE THE NAEM OF THE SECOND PLAYER IN NAEMP2
;CALL FIRSTSCREEN
;MOV DX, NAMELENGTH
;MOV NAMEP2LEN, DX
;MOV NAMELENGTH,0
;MOV BH , InitialPoints
;MOV InitialPointsP2, BH
;CALL CLEARSCREEN
;---------------------------------------------------------------------------------------------------------------------------------------
BACK_TO_MAIN_SCREEN:
CALL RecieveInvitations
CALL PrintInvitation
MOV Exit_Chat , 0
MOV firs_half , 0400h
MOV sec_half , 0f00h
CALL MAINSCREEN ; CALLING THE MAIN SCREEN MENU
MOV AH,1 ; GET KEY PRESSED WITHOUT WAITING
INT 16H
JZ BACK_TO_MAIN_SCREEN ; JUMP TO MAIN SCREEN IF THERE IS NO KEY PRESSED
MOV AH,0 ; CONSUME THE ENTERED KEY FROM THE KEYBOARD BUFFER
INT 16H
CMP AX,1C0DH ; CHECK IF THE ENTERED KEY IS THE ENTER KEY
JE NEXTSCREEN ; JUMP IF THE ENTERED KEY IS PRESSED
CALL CHECKCHOICE ; CALL CHECKCHOICE TO NAVIGATE THE CHOICES
CALL CheckInvitationsAcception
CMP AcceptChat, 1
JZ GuestChat
CMP AcceptGame, 1
JZ GuestGame
JMP BACK_TO_MAIN_SCREEN
NEXTSCREEN:
;; IF THERE IS AN INVITATION AND USER WANT TO BECOME HOST
CMP GameInvite, 1
JE BACK_TO_MAIN_SCREEN
CMP ChatInvite, 1
JE BACK_TO_MAIN_SCREEN
CMP CHOSEN,1
JNE CHECK_CHAT
GAME_AGAIN:
MOV HOST, 1
CALL SendGameInvite
CALL WaitGameAcception
MOV CX, 100
WasteTime:
DEC CX
JNZ WasteTime
GuestGame:
CALL ExchangeInfo
MOV BH , InitialPointsP1
MOV BL , InitialPointsP2
CMP BL, BH
JB TAKE_PLAYER2POINTS
sub bh,16
MOV Player1_Points, BH
MOV Player2_Points, BH
jmp NotThisPointsDone
TAKE_PLAYER2POINTS:
sub bl,16
MOV Player1_Points, BL
MOV Player2_Points, BL
NotThisPointsDone:
CALL GAME
CHECK_CHAT: CMP CHOSEN,2
JNE EXITP_ROGRAM
MOV HOST, 1
Call SendChatInvite
CALL WaitChatAcception
GuestChat:
CALL ExchangeInfo
CALL CHATMODE
JMP BACK_TO_MAIN_SCREEN
EXITP_ROGRAM: MOV AH,0 ; NORMAL TERMINATION OF THE GAME
MOV AL,12H
INT 10H
MOV BL,2
MOV AH,4CH
INT 21H
MAIN ENDP
;-----------------------------------------------------------MOVE CURSOR FUNCTION-------------------------------------------------------------
MOVECURSOR PROC NEAR
; DL HOLDS THE X COORDINATE AND DH HOLDS THE Y COORDINATE
MOV AH,2
MOV AL,0
MOV BX,0
INT 10H
RET
MOVECURSOR ENDP
;----------------------------------------------------------PRINT MESSAGE FUNCTION------------------------------------------------------------
PRINTMESSAGE PROC NEAR
; DX HOLDS THE OFFSET OF THE MESSAGE
MOV AH,9
MOV AL,0
INT 21H
RET
PRINTMESSAGE ENDP
PrintInvitation PROC FAR