This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
string.A51
156 lines (139 loc) · 2.57 KB
/
string.A51
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
#include <89c51rx2.inc>
#include "battleship.inc"
NAME STRING
EXTRN CODE (SEND_RS232)
EXTRN CODE (RECEIVE_COORD)
EXTRN CODE (RECEIVE_DIR)
PUBLIC SENDSTRMODE
PUBLIC SENDMODEINSRT
PUBLIC SENDSTRREADY
PUBLIC SEND_PRESENTPLYR
PUBLIC SEND_STRGAMEOVER
PUBLIC WAITING_DIR
PUBLIC WAITING_COORD
PUBLIC SEND_STRSHIPNR
PUBLIC SEND_PB2START
STRINGCODE SEGMENT CODE
RSEG STRINGCODE
SEND_PB2START:
MOV DPTR,#STRPRESS
SEND_STR:
CLR A
MOVC A,@A+DPTR
JZ ENDSTR
LCALL SEND_RS232
INC DPTR
JMP SEND_STR
ENDSTR:
RET
SENDSTRREADY:
ACALL SEND_PRESENTPLYR
MOV DPTR,#STRREADY
ACALL SEND_STR
MOV A,#10
LCALL SEND_RS232
RET
SENDSTRMODE:
MOV DPTR,#STRGAMEMODE
ACALL SEND_STR
MOV A,#10
LCALL SEND_RS232
RET
SENDMODEINSRT:
MOV DPTR,#STRAUTOINSRT
ACALL SEND_STR
MOV A,#10
LCALL SEND_RS232
RET
SEND_PRESENTPLYR:
MOV DPTR,#STRPLYR
ACALL SEND_STR
CJNE R1,#BOARD_1HIT,SENDPLAYER2
MOV A,#'1'
LCALL SEND_RS232
JMP RET_SENDPLYR
SENDPLAYER2:
MOV A,#'2'
LCALL SEND_RS232
RET_SENDPLYR:
RET
WAITING_COORD:
PUSH DPH
PUSH DPL
MOV DPTR,#STRCOORD
ACALL SEND_STR
LCALL RECEIVE_COORD ;espera para receção de coordenada valida
MOV A,#10 ;NL = New Line
LCALL SEND_RS232
POP DPL
POP DPH
RET
WAITING_DIR:
PUSH DPH
PUSH DPL
MOV DPTR,#STRDIR
ACALL SEND_STR
LCALL RECEIVE_DIR
MOV A,#10 ;NL = New Line
LCALL SEND_RS232
POP DPL
POP DPH
RET
SEND_STRSHIPNR:
PUSH DPH
PUSH DPL
MOV DPTR,#STRSHIP
ACALL SEND_STR
MOV A,SHIP_NUMBER
LCALL SEND_RS232
MOV A,#10 ;NL = New Line
LCALL SEND_RS232
POP DPL
POP DPH
RET
SEND_STRGAMEOVER:
MOV DPTR,#STRGAMEOVER
LCALL SEND_STR
LCALL SEND_PRESENTPLYR
MOV A,#10
LCALL SEND_RS232
MOV A,MINUTO
MOV B,#10
DIV AB
ADD A,#'0'
LCALL SEND_RS232
MOV A,B
ADD A,#'0'
LCALL SEND_RS232
MOV A,#':'
LCALL SEND_RS232
MOV A,SEGUNDO
MOV B,#10
DIV AB
ADD A,#'0'
LCALL SEND_RS232
MOV A,B
ADD A,#'0'
LCALL SEND_RS232
MOV A,#10
LCALL SEND_RS232
RET
STRGAMEMODE:
DB 'MODO DE JOGO:',10,'1- HUMANO VS HUMANO',10,'2- HUMANO VS 8051',0
STRAUTOINSRT:
DB 10,'INSERIR AUTO.?(Y ou N)',0
STRSHIP:
DB 'INSERT SHIP N.: ',0
STRDIR:
DB 'DIR(V OU H): ',0
STRCOORD:
DB 'COORD(LETRANUM): ',0
STRGAMEOVER:
DB ' **GAMEOVER**',10,' WINNER',10,0
STRPLYR:
DB ' PLAYER ',0
STRPRESS:
DB '*PRESS BUTTON 2 (P3.5) TO START*',10,0
STRREADY:
DB 10,'READY?',10,'(PRESS PB2)',10,0
END