-
Notifications
You must be signed in to change notification settings - Fork 96
/
NETPLAY.BAK
350 lines (290 loc) · 5.44 KB
/
NETPLAY.BAK
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
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <string.h>
#include <bios.h>
#include "main.h"
//
// Choose which type of modem to use
//
modem_t modems[MAXMODEMS];
int numModems;
//
// Draw a bar of attributes
//
void AttriBar(int x,int y,int length, char attr)
{
int i;
char far *screen;
screen = MK_FP(0xb800, y*160 + x*2 + 1);
for (i = 0;i < length;i++)
{
*screen = attr;
screen += 2;
}
}
//
// Parse the MODOOM.STR file
//
int ParseMODOOM(void)
{
int i;
int ok;
FILE *fp;
int rv;
int found;
fp = fopen("MODEM.STR","rt");
if (fp == NULL)
{
gotoxy(2,25);
cprintf("There's no MODEM.STR file! Press a key. ");
gotoxy(1,25);
sound(2500);
delay(3);
nosound();
getch();
return 0;
}
i = 0;
ok = 1;
do
{
rv = fscanf(fp,"%[^\n]",&modems[i].name);
if (!rv || rv == EOF)
ok = 0;
rv = fscanf(fp,"\n");
if (rv == EOF)
ok = 0;
rv = fscanf(fp,"%[^\n]",&modems[i].init);
if (!rv || rv == EOF)
ok = 0;
rv = fscanf(fp,"\n");
if (rv == EOF)
ok = 0;
rv = fscanf(fp,"%[^\n]",&modems[i].hangup);
if (!rv || rv == EOF)
ok = 0;
rv = fscanf(fp,"\n");
if (rv == EOF)
ok = 0;
rv = fscanf(fp,"%[^\n]",&modems[i].baud);
if (!rv || rv == EOF)
ok = 0;
rv = fscanf(fp,"\n\n");
if (rv == EOF)
ok = 0;
i++;
} while(ok);
numModems = i;
fclose(fp);
//
// Quick little shell sort
//
do
{
int j;
found = 0;
for (i = 0; i < numModems-1; i++)
for (j = i+1; j < numModems; j++)
if (strcmp(modems[j].name,modems[i].name)<0)
{
modem_t temp;
temp = modems[j];
modems[j] = modems[i];
modems[i] = temp;
found = 1;
}
} while(found);
return 1;
}
//
// Blit the modem names to the screen
//
void BlitModemNames(int start)
{
int i;
int max;
int y;
int j;
int len;
max = start + 10;
if (max > numModems)
max = numModems;
y = 8;
textbackground(1);
textcolor(11);
for (i = start; i < max; i++)
{
gotoxy(27,y++);
cprintf("%s",modems[i].name);
len = 27 - strlen(modems[i].name);
for (j = 0; j < len; j++)
cprintf(" ");
}
gotoxy(1,25);
}
void ChooseModem(void)
{
int xit;
int blitY;
int hliteY;
int lastHliteY;
FILE *fp;
if (!ParseMODOOM())
return;
SaveScreen();
DrawPup(&modemchs);
textbackground(7);
textcolor(0);
#ifndef FRENCH
gotoxy(2,25);
cprintf("Choose the type of modem you are going to use.");
gotoxy(1,25);
#endif
xit = 0;
blitY = 0;
lastHliteY = hliteY = 0;
do
{
int key;
BlitModemNames(blitY);
textbackground(7);
textcolor(0);
gotoxy(70,25);
cprintf("%s ",modems[hliteY + blitY].baud);
gotoxy(1,25);
AttriBar(26,lastHliteY+7,27,0x1b);
lastHliteY = hliteY;
AttriBar(26,hliteY+7,27,0x7f);
key = _bios_keybrd(_NKEYBRD_READ)>>8;
switch(key)
{
case 0x1c: // ENTER
gotoxy(2,25);
cprintf("Writing %s to MODEM.CFG...",modems[blitY + hliteY].name);
gotoxy(1,25);
fp = fopen("MODEM.CFG","w+t");
if (fp == NULL)
{
gotoxy(2,25);
cprintf("Error writing to MODEM.CFG. Press a key.");
gotoxy(1,25);
getch();
break;
}
fprintf(fp,"%s\n%s\n%s\n%s\n\n",
modems[blitY + hliteY].init,
modems[blitY + hliteY].hangup,
modems[blitY + hliteY].baud,
modems[blitY + hliteY].name);
fclose(fp);
xit = 1;
break;
case SC_ESC: // ESC
xit = 1;
break;
case 0x48: // UP
if (hliteY > 5)
hliteY--;
else
if (hliteY > 0 && blitY > 0)
blitY--;
else
if (!blitY && hliteY)
hliteY--;
else
if (!hliteY && blitY)
blitY--;
break;
case 0x50: // DOWN
if (hliteY > 4 && blitY+10<numModems)
blitY++;
else
if (hliteY < 9 &&
((blitY+10 == numModems) ||
(hliteY < numModems - 1)))
hliteY++;
break;
case 0x49: // PGUP
blitY -= 9;
if (blitY < 0)
hliteY = blitY = 0;
break;
case 0x51: // PGDN
blitY += 9;
if (blitY+10 > numModems)
{
blitY = numModems - 10;
hliteY = 9;
}
if (numModems < 10)
{
blitY = 0;
hliteY = numModems - 1;
}
break;
}
} while(!xit);
RestoreScreen();
}
//
// Choose which type of netplay
//
enum {GT_IPX,GT_MODEM,GT_SERIAL,GT_CHOOSE,GT_MACROS,GT_MAX};
item_t netplayitems[]=
{
{GT_IPX, 26,9,27, -1,-1},
{GT_MODEM, 26,10,27, -1,-1},
{GT_SERIAL, 26,11,27, -1,-1},
{GT_CHOOSE, 26,13,27, -1,-1},
{GT_MACROS, 26,14,27, -1,-1}
};
menu_t netplaymenu=
{
&netplayitems[0],
GT_IPX,
GT_MAX,
0x7f
};
void ChooseNetplay(void)
{
short key;
short field;
SaveScreen();
DrawPup(&netplay);
while(1)
{
SetupMenu(&netplaymenu);
field = GetMenuInput();
key = menukey;
switch(key)
{
case KEY_ESC:
RestoreScreen();
return;
case KEY_ENTER:
if (field == GT_CHOOSE)
{
ChooseModem();
continue;
}
switch(field)
{
case GT_IPX:
// NetworkConfig();
break;
case GT_MODEM:
ModemConfig();
break;
case GT_SERIAL:
SerialConfig();
break;
case GT_MACROS:
MacroConfig();
break;
}
RestoreScreen();
return;
}
}
}