1 // Emacs style mode select -*- C++ -*-
2 //---------------------------------------------------------------------------
3 //
4 // $Id: swtitle.c,v 1.3 2003/06/04 15:43:39 fraggle Exp $
5 //
6 // Copyright(C) 1984-2000 David L. Clark
7 // Copyright(C) 2001-2003 Simon Howard
8 //
9 // This program is free software; you can redistribute it and/or modify it
10 // under the terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 2 of the License, or (at your
12 // option) any later version. This program is distributed in the hope that
13 // it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 // the GNU General Public License for more details. You should have
16 // received a copy of the GNU General Public License along with this
17 // program; if not, write to the Free Software Foundation, Inc., 59 Temple
18 // Place - Suite 330, Boston, MA 02111-1307, USA.
19 //
20 //---------------------------------------------------------------------------
21 //
22 //        swtitle  -      SW perform animation on the title screen
23 //
24 //---------------------------------------------------------------------------
25 
26 #include <ctype.h>
27 
28 #include "video.h"
29 
30 #include "sw.h"
31 #include "swasynio.h"
32 #include "swconf.h"
33 #include "swend.h"
34 #include "swground.h"
35 #include "swgrpha.h"
36 #include "swmain.h"
37 #include "swmisc.h"
38 #include "swsound.h"
39 #include "swsymbol.h"
40 #include "swtitle.h"
41 
42 #define X_OFFSET ((SCR_WDTH/2)-160)
43 
44 // sdh -- use network edition title screen
45 
46 #define NET_TITLE
47 
swtitln()48 void swtitln()
49 {
50 	int i, h;
51 
52 	tickmode = 1;
53 
54 	sound(S_TITLE, 0, NULL);
55 
56 	// sdh 26/03/2002: remove swinitgrph call
57 
58 	// clear the screen
59 
60 	setvdisp();
61 
62 	clrdispv();
63 
64 /*---------------- Original BMB Version---------------*/
65 #ifndef NET_TITLE
66 
67 	swcolour(3);
68 	swposcur(13+X_OFFSET/8, 6);
69 	swputs("S O P W I T H");
70 
71 	swcolour(1);
72 	swposcur(12+X_OFFSET/8, 8);
73 	swputs("(Version " VERSION ")");
74 
75 	swcolour(3);
76 	swposcur(5+X_OFFSET/8, 11);
77 	swputs("(c) Copyright 1984, 1985, 1987");
78 
79 	swcolour(1);
80 	swposcur(6+X_OFFSET/8, 12);
81 	swputs("BMB ");
82 	swcolour(3);
83 	swputs("Compuscience Canada Ltd.");
84 #else
85 /*------------------ Original BMB Version---------------*/
86 
87 /*---------------- New Network Version ---------------*/
88 
89 	swcolour(2);
90 	swposcur(18+X_OFFSET/8, 2);
91 	swputs("SDL");
92 
93 	swcolour(3);
94 	swposcur(13+X_OFFSET/8, 4);
95 	swputs("S O P W I T H");
96 
97 	swposcur(13+X_OFFSET/8, 6);
98 	swputs("Version " VERSION);
99 
100 	swcolour(3);
101 	swposcur(1+X_OFFSET/8, 10);
102 	swputs("(c) Copyright 1984, 1985, 1987");
103 
104 	swcolour(1);
105 	swposcur(5+X_OFFSET/8, 11);
106 	swputs("BMB ");
107 	swcolour(3);
108 	swputs("Compuscience Canada Ltd.");
109 
110 	swcolour(3);
111 	swposcur(1+X_OFFSET/8, 12);
112 	swputs("(c) Copyright 1984-2000 David L. Clark");
113 
114 	swcolour(3);
115 	swposcur(1+X_OFFSET/8, 13);
116 	swputs("(c) Copyright 2001-2003 Simon Howard");
117 
118 /*---------------- New Network Version-----------------*/
119 
120 	displx = 700-X_OFFSET;
121 	dispinit = TRUE;
122 	swground();
123 
124 	// sdh 28/06/2002: cleared this up a lot, no more
125 	// creating objects etc
126 
127 	Vid_DispSymbol(260+X_OFFSET, 180, symbol_plane[0][0], 1);
128 	Vid_DispSymbol(50+X_OFFSET, 180, symbol_plane_win[3], 1);
129 	Vid_DispSymbol(100+X_OFFSET, ground[800] + 16, symbol_ox[0], 1);
130 	Vid_DispSymbol(234+X_OFFSET, ground[934] + 16, symbol_targets[3], 2);
131 	Vid_DispSymbol(20+X_OFFSET, 160, symbol_plane_hit[0], 1);
132 
133 	for (i = 9, h=150; i; --i, h += 5)
134 		Vid_PlotPixel(30+X_OFFSET, h, 3);
135 
136 #endif				/* #ifndef NET_TITLE */
137 }
138 
swtitlf()139 void swtitlf()
140 {
141 
142 	if (titleflg)
143 		return;
144 
145 	sound(0, 0, NULL);
146 	swsound();
147 	tickmode = 0;
148 }
149 
150 
151 //
152 // menus
153 //
154 // sdh 19/10/2001: moved all the menus into swtitle.c,
155 // I think they belong here anyway
156 // rename to swmenus.c?
157 //
158 
ctlbreak()159 BOOL ctlbreak()
160 {
161 	return Vid_GetCtrlBreak();
162 }
163 
164 // clear bottom of screen
165 
clrprmpt()166 void clrprmpt()
167 {
168 	// sdh: generic clear
169 
170 	int x, y;
171 
172 	for (y = 0; y <= 43; ++y)
173 		for (x = 0; x < SCR_WDTH; ++x) {
174 			Vid_PlotPixel(x, y, 0);
175 		}
176 
177 	swposcur(0, 20);
178 }
179 
gethost()180 static BOOL gethost()
181 {
182 	clrprmpt();
183 
184 	swputs("Enter Remote Hostname/IP:\n");
185 	swgets(asynhost, sizeof(asynhost) - 3);
186 
187 	return 1;
188 }
189 
190 // network menu
191 
getnet()192 static BOOL getnet()
193 {
194 	for (;;) {
195 		clrprmpt();
196 		swputs("Key: L - listen for connection\n");
197 		swputs("     C - connect to remote host\n");
198 		swputs("     T - connect to TCP loop\n");
199 
200 		Vid_Update();
201 
202 		swsndupdate();
203 
204 		if (ctlbreak())
205 			swend(NULL, NO);
206 
207 		switch (toupper(swgetc() & 0xff)) {
208 		case 'L':
209 			asynmode = ASYN_LISTEN;
210 			return 1;
211 		case 'C':
212 			asynmode = ASYN_CONNECT;
213 			gethost();
214 			return 1;
215 		case 'T':
216 			asynmode = ASYN_TCPLOOP;
217 			gethost();
218 			return 1;
219 		case 27:
220 			return 0;
221 		}
222 	}
223 }
224 
225 // controller menu (unused)
226 #if 0
227 static void getkey()
228 {
229 	register char key;
230 
231 	/*----------------97/12/27--------------
232         clrprmpt();
233         swputs( "Key: 1 - Joystick with IBM Keyboard\r\n" );
234         swputs( "     2 - Joystick with non-IBM Keyboard\r\n" );
235         swputs( "     3 - IBM Keyboard only\r\n" );
236         swputs( "     4 - Non-IBM keyboard only\r\n" );
237         for (;;) {
238                 if ( ctlbreak() )
239                         swend( NULL, NO );
240                 if ( ( ( key = swgetc() & 0x00FF ) < '1' )
241                         || ( key > '4' ) )
242                         continue;
243                 joystick = ( key <= '2' );
244                 ibmkeybd = ( key == '1' ) || ( key == '3' );
245                 return;
246         }
247         ------------------97/12/27--------------*/
248 	clrprmpt();
249 	swputs("Key: K - Keyboard Only\r\n");
250 	swputs("     J - Joystick and Keyboard\r\n");
251 
252 	Vid_Update();
253 
254 	for (;;) {
255 		swsndupdate();
256 		if (ctlbreak())
257 			swend(NULL, NO);
258 		if (((key = toupper(swgetc() & 0x00FF)) != 'K')
259 		    && (key != 'J'))
260 			continue;
261 		joystick = key == 'J';
262 		ibmkeybd = 1;
263 		return;
264 	}
265 }
266 #endif
267 
268 // game menu for multiplayer (unused)
269 
getgame()270 int getgame()
271 {
272 	register int game;
273 
274 	clrprmpt();
275 	swputs("         Key a game number");
276 
277 	for (;;) {
278 		if (ctlbreak())
279 			swend(NULL, NO);
280 		if (((game = (swgetc() & 0x00FF) - '0') >= 0)
281 		    && (game <= MAX_GAME))
282 			return (game);
283 	}
284 }
285 
286 // sdh: get single player skill level
287 
getskill()288 static BOOL getskill()
289 {
290 	for (;;) {
291 		clrprmpt();
292 		swputs("Key: N - novice player\r\n");
293 		swputs("     E - expert player\r\n");
294 
295 		Vid_Update();
296 
297 		swsndupdate();
298 		if (ctlbreak())
299 			swend(NULL, NO);
300 		switch (toupper(swgetc() & 0xff)) {
301 		case 'N':
302 			playmode = PLAYMODE_NOVICE;
303 			return 1;
304 		case 'E':
305 			playmode = PLAYMODE_SINGLE;
306 			return 1;
307 		case 27:
308 			return 0;
309 		}
310 	}
311 }
312 
getgamemode()313 void getgamemode()
314 {
315 	for (;;) {
316 		char c;
317 
318 		swtitln();
319 
320 		clrprmpt();
321 
322 		swputs("Key: S - single player\r\n");
323 		swputs("     C - single player against computer\r\n");
324 #ifdef TCPIP
325 		swputs("     N - network game\r\n");
326 #endif
327 		swputs("     O - game options\r\n");
328                 swputs("     Press CTRL-C to exit");
329 		Vid_Update();
330 
331 		if (ctlbreak())
332 			swend(NULL, NO);
333 
334 		c = toupper(swgetc() & 0xff);
335 
336 		switch (c) {
337 		case 'S':
338 			if (getskill())
339 				return;
340 			break;
341 		case 'O':
342 			setconfig();
343 			break;
344 		case 'C':
345 			playmode = PLAYMODE_COMPUTER;
346 			return;
347 #ifdef TCPIP
348 		case 'N':
349 			if (getnet()) {
350 				playmode = PLAYMODE_ASYNCH;
351 				return;
352 			}
353 			break;
354 #endif
355 		}
356 	}
357 }
358 
359 
360 //---------------------------------------------------------------------------
361 //
362 // $Log: swtitle.c,v $
363 // Revision 1.3  2003/06/04 15:43:39  fraggle
364 // Fix year range in copyright
365 //
366 // Revision 1.2  2003/04/05 22:55:11  fraggle
367 // Remove the FOREVER macro and some unused stuff from std.h
368 //
369 // Revision 1.1.1.1  2003/02/14 19:03:22  fraggle
370 // Initial Sourceforge CVS import
371 //
372 //
373 // sdh 14/2/2003: change license header to GPL
374 // sdh 27/06/2002: move to new sopsym_t for symbols,
375 //                 remove references to symwdt, symhgt
376 // sdh 28/04/2002: Centering of title screen on non-320 pixel wide screens
377 // sdh 26/03/2002: change CGA_ to Vid_
378 // sdh 16/11/2001: TCPIP #define to disable TCP/IP support
379 // sdh 29/10/2001: moved options menu into swconf.c
380 // sdh 29/10/2001: harrykeys
381 // sdh 28/10/2001: rearranged title/menu stuff a bit
382 //                 added options menu
383 // sdh 21/10/2001: rearranged headers, added cvs tags
384 // sdh 19/10/2001: moved all the menus here
385 // sdh 19/10/2001: removed extern definitions, these are now in headers
386 // sdh 18/10/2001: converted all functions to ANSI-style arguments
387 // sdh ??/10/2001: added #define to control whether we use the classic
388 //                 title screen or the "network edition" one
389 //
390 // 2000-10-29      Copyright update.
391 // 99-01-24        1999 copyright.
392 // 96-12-27        New network version.
393 // 87-04-01        Version 7.F15
394 // 87-03-11        Title reformatting.
395 // 87-03-10        Microsoft compiler.
396 // 84-02-02        Development
397 //
398 //---------------------------------------------------------------------------
399 
400