-
Notifications
You must be signed in to change notification settings - Fork 97
/
MODREST.C
314 lines (267 loc) · 6.12 KB
/
MODREST.C
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
//
// Enter modem savegame info
//
#include <string.h>
#include <process.h>
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <mem.h>
#include <stdlib.h>
#include <fcntl.h>
#include <io.h>
#include "main.h"
#include "default.h"
enum {MODS_0,MODS_1,MODS_2,MODS_3,MODS_4,MODS_5,
MODS_DEATHNO,MODS_DEATHYES,
MODS_COM1,MODS_COM2,MODS_COM3,MODS_COM4,
MODS_CONN1,MODS_CONN2,MODS_CONN3,
MODS_MAX};
item_t modsaveitems[]=
{
{MODS_0, 29,4,24, -1,-1},
{MODS_1, 29,5,24, -1,-1},
{MODS_2, 29,6,24, -1,-1},
{MODS_3, 29,7,24, -1,-1},
{MODS_4, 29,8,24, -1,-1},
{MODS_5, 29,9,24, -1,-1},
{MODS_DEATHNO, 29,11,24, -1,-1},
{MODS_DEATHYES,29,12,24, -1,-1},
{MODS_COM1, 29,14,4, -1,MODS_COM3},
{MODS_COM2, 29,15,4, -1,MODS_COM4,0,MODS_CONN1},
{MODS_COM3, 46,14,4, MODS_COM1,-1,MODS_DEATHYES},
{MODS_COM4, 46,15,4, MODS_COM2,-1},
{MODS_CONN1, 29,17,20, -1,-1,MODS_COM2},
{MODS_CONN2, 29,18,20, -1,-1},
{MODS_CONN3, 29,19,7, -1,-1}
};
menu_t modsavemenu=
{
&modsaveitems[0],
MODS_0,
MODS_MAX,
0x7f
};
// SAVEGAME radio group
radio_t modslots[]=
{
{26,4,0},
{26,5,1},
{26,6,2},
{26,7,3},
{26,8,4},
{26,9,5}
};
radiogroup_t modslotsg= { &modslots[0],6,&saveslot,15,1 };
// DEATHMATCH radio group
radio_t modsdeath[]=
{
{26,11,0},
{26,12,1}
};
radiogroup_t modsdeathg= { &modsdeath[0],2,&minfo.deathMatch,15,1 };
// COMPORT radio group
radio_t modscom[]=
{
{26,14,1},
{26,15,2},
{43,14,3},
{43,15,4}
};
radiogroup_t modscomg= { &modscom[0],4,&minfo.comport,15,1 };
// CONNECT TYPE radio group
radio_t modsconn[]=
{
{26,17,0},
{26,18,1},
{26,19,2}
};
radiogroup_t modsconng= { &modsconn[0],3,&minfo.comtype,15,1 };
int RestoreModem(void)
{
short field;
short key;
int rval = 0;
char *args[MAXARGS];
int argcount;
char string[MAXARGS*2][16];
int i;
int numplayers[6];
int handle;
char name[32];
char p1,p2,p3,p4;
item_t phonenum = {2,37,19,13,-1,-1};
char tempstring[16];
minfo = modeminfo; // save copy of netinfo
SaveScreen();
DrawPup(&modsave);
saveslot = -1;
memset(savenames,0,6*24);
//
// Read in savegame strings
//
textbackground(1);
textcolor(15);
for (i = 0;i < 6;i++)
{
sprintf(name,SAVENAME,i);
handle = open (name, O_BINARY | O_RDONLY);
if (handle == -1)
continue;
read(handle,savenames[i],24);
lseek(handle,27+16,SEEK_SET);
read(handle,&p1,1);
read(handle,&p2,1);
read(handle,&p3,1);
read(handle,&p4,1);
numplayers[i] = p1+p2+p3+p4;
close(handle);
Clear(&modsaveitems[i]);
Pos(&modsaveitems[i]);
cprintf("%s",savenames[i]);
}
//
// Set defaults
//
minfo.comtype = 1;
DrawRadios(&modsconng);
minfo.comport = comport;
DrawRadios(&modscomg);
minfo.deathMatch = 0;
DrawRadios(&modsdeathg);
strcpy(minfo.phonenum,"");
gotoxy(1,25);
while(1)
{
SetupMenu(&modsavemenu);
field = GetMenuInput();
key = menukey;
switch ( key )
{
case KEY_ESC:
rval = -1;
goto func_exit;
exitandsave:
case KEY_F10:
if (saveslot < 0)
{
ErrorWindow(&netserr);
break;
}
modeminfo = minfo;
M_SaveDefaults();
RestoreScreen();
argcount = 1;
args[0] = "sersetup.exe ";
if (cdrom)
args[argcount++] = "-cdrom";
args[argcount++] = "-nodes";
sprintf(string[argcount],"%d",numplayers[saveslot]);
args[argcount] = string[argcount];
argcount++;
if (modeminfo.deathMatch)
args[argcount++] = "-deathmatch";
sprintf(string[argcount],"-com%d",modeminfo.comport);
args[argcount] = string[argcount];
argcount++;
switch(modeminfo.comtype)
{
case 0: // no parameter if already connected!
break;
case 1:
args[argcount++] = "-answer";
break;
case 2:
args[argcount++] = "-dial";
sprintf(string[argcount],"%s",minfo.phonenum);
args[argcount] = string[argcount];
argcount++;
break;
}
args[argcount++] = "-loadgame";
sprintf(string[argcount],"%d",saveslot);
args[argcount] = string[argcount];
argcount++;
for (i = 1;i < myargc; i++)
args[argcount++] = myargv[i];
args[argcount] = NULL;
textbackground(0);
textcolor(7);
clrscr();
execv("sersetup.exe",args);
//
// ERROR EXECing!
//
printf("Problem EXECing SERSETUP for netplay. Need to be in same directory!");
exit(0);
case KEY_F2:
if (ChooseOpponentInList())
{
strcpy(minfo.phonenum,chosenPhoneNum);
textcolor(15);
textbackground(0);
Clear(&phonenum);
Pos(&phonenum);
cprintf("%s",minfo.phonenum);
minfo.comtype = 2;
DrawRadios(&modsconng);
gotoxy(1,25);
}
break;
case KEY_ENTER:
switch ( field )
{
case MODS_COM1:
case MODS_COM2:
case MODS_COM3:
case MODS_COM4:
minfo.comport = field - MODS_COM1 + 1;
DrawRadios(&modscomg);
break;
case MODS_CONN1:
case MODS_CONN2:
minfo.comtype = field - MODS_CONN1;
DrawRadios(&modsconng);
break;
case MODS_CONN3:
minfo.comtype = 2;
DrawRadios(&modsconng);
key = EditLine(&phonenum,tempstring,12);
if (key == KEY_ENTER)
strcpy(minfo.phonenum,tempstring);
gotoxy(1,25);
break;
case MODS_0:
case MODS_1:
case MODS_2:
case MODS_3:
case MODS_4:
case MODS_5:
if (!savenames[field - MODS_0][0])
{
sound(1000);
delay(12);
nosound();
break;
}
saveslot = field - MODS_0;
DrawRadios(&modslotsg);
break;
//
// Deathmatch
//
case MODS_DEATHNO:
case MODS_DEATHYES:
minfo.deathMatch = field - MODS_DEATHNO;
DrawRadios(&modsdeathg);
break;
default:
break;
}
break;
}
}
func_exit:
RestoreScreen();
return ( rval );
}