-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.asm
169 lines (140 loc) · 2.49 KB
/
main.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
include Gameover.inc
EXTRN Game:far
EXTRN menu:far
EXTRN gameover:far
EXTRN selname:far
EXTRN chatproc:far
EXTRN p1lives:byte, p2lives:byte,p1name:byte
EXTRN waitproc:far
EXTRN getp2name:far
PUBLIC p1cd,p2cd,p1cl,p2cl,p2name
PUBLIC currentoption,option1,optionssize
PUBLIC status
public p2status
public lvlOption
public hostorguest
.model small
.stack
.data
recivecount db 16
sendcount db 16
status db -1 ;-4 host or guest|| -3 ==> ChangeLv2 || -2 ==> chat || -1 ==> SelectName || 0 ==> Menu || 1 ==> ChooseColor || 2 ==> Game || 3 ==> EndGame || 4 ==> GameOver
p2status db -1
p1cl db 0
p1cd db 0
p2cl db 0
p2cd db 0
hostorguest db 0
currentoption dw 0
option1 db 14,"START NEW GAME"
option2 db 9 ,"QUIT GAME"
optionssize dw 2
connectionoptions1 db 4,'HOST'
connectionoptions2 db 5,'guest'
connectionoptions dw 2
currentoptionconnection dw 0
lvlOption dw 2 ; 1 ==> lv1 , 2 ==> lv2
p2name db 16 dup('$') ;temporary for phase 1
.code
main proc far
MainLoop:
call selname
cmp status, 0
jne EndGame
call connection
MenuLB:
call menu
cmp status, -2
je ChatLB
cmp status, 2
je GameLB
cmp status,5
je GameLB
cmp status, 0
je MenuLB
jne EndGame
ChatLB:
call waitproc
cmp status, 0
je MenuLB
cmp status, -2
jne EndGame
call getp2name
call chatproc
cmp status, 0
je MenuLB
cmp status, 2
jne EndGame
GameLB:
call waitproc
cmp status, 0
je MenuLB
call xchgcolors
;cmp status, 2
;je EndGame
call Game
mov status, 4
call gameover
cmp currentoption, 1
je EndGame
mov status, 1
jmp MainLoop
EndGame:
mov ah, 4ch
int 21h
main endp
xchgcolors proc
repsend1:
mov dx, 3fdh
in al, dx
test al, 00100000b
jz repsend1
mov dx , 3F8H ; Transmit data register
mov al, p1cl
out dx , al
reprec1:
mov dx , 3FDH ; Line Status Register
in al , dx
test al , 1
jz reprec1
mov dx , 03F8H
in al , dx
mov p2cl, al
repsend2:
mov dx, 3fdh
in al, dx
test al, 00100000b
jz repsend2
mov dx , 3F8H ; Transmit data register
mov al, p1cd
out dx , al
reprec2:
mov dx , 3FDH ; Line Status Register
in al , dx
test al , 1
jz reprec2
mov dx , 03F8H
in al , dx
mov p2cd, al
ret
xchgcolors endp
connection proc
againhostorguest:
WriteGameoverUI currentoptionconnection,connectionoptions1,connectionoptions
mov ah,1
int 16h
jz notagainhostorguest1
mov dh, ah
mov ah,0h
int 16h
jmp againhostorguest
notagainhostorguest1:
cmp dh,01ch
jz notagainhostorguest2
jmp againhostorguest
notagainhostorguest2:
mov ax, currentoptionconnection
mov hostorguest,al
ret
connection endp
end main