1 // Emacs style mode select -*- C++ -*-
2 //---------------------------------------------------------------------------
3 //
4 // $Id: sw.h,v 1.4 2003/06/04 15:49:05 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 //        sw.h     -      SW  Manifest Definitions
23 //
24 //---------------------------------------------------------------------------
25 
26 // sdh: #ifndef to catch multiple includes
27 
28 #ifndef __SW_H__
29 #define __SW_H__
30 
31 #include "std.h"
32 #include <setjmp.h>
33 #include "swsymbol.h"
34 #include "config.h"
35 
36 /*  Constants  */
37 
38 #define MAX_X           3000            /*  Maximum X coordinate            */
39 #define MAX_Y           200             /*  Maximum Y coordinate            */
40 #define MIN_SPEED       4               /*  Minimum plane speed             */
41 #define MAX_SPEED       8               /*  Maximum plane speed             */
42 #define MAX_THROTTLE    4               /*  Maximum acceleration            */
43 
44 #define MAXCRCOUNT      10              /*  Number of turns as crashed      */
45 #define FALLCOUNT       10              /*  Moves between falling plane adj */
46 #define STALLCOUNT      6               /*  Moves between stalling plane adj*/
47 #define TARGHITCOUNT    10              /*  Target hit count before explod'n*/
48 
49 #ifdef PSION
50 
51 // fill the screen on the revo
52 
53 #define SCR_WDTH        480             /*  Screen Width                    */
54 
55 #else
56 
57 #define SCR_WDTH        320             /*  Screen Width                    */
58 
59 #endif
60 
61 #define SCR_HGHT        200             /*  Screen Height                   */
62 
63 #define SCR_CENTR       ((SCR_WDTH / 2) - 8) /*  Centre column of screen */
64 #define SCR_SEGM        0xB800          /*  Screen Video segment            */
65 #define SCR_ROFF        0x2000          /*  Screen odd rastor line offset   */
66 #define SCR_LINW        80              /*  Screen line width in bytes      */
67 #define SCR_MNSH        16              /*  Minumum line number to shift    */
68 #define SCR_MXSH        75              /*  Maximum line number to shift    */
69 #define SCR_LIMIT       180             /*  Screen shift limits             */
70 
71 // sdh 27/7/2002: make these independent of the screen width
72 
73 #define WRLD_RSX        (MAX_X / 320 * 2 + 1) /*  World display X and  */
74 #define WRLD_RSY        (MAX_Y / SCR_MNSH + 1)     /*  Y divisors           */
75 
76 #define MINFLCKX        370 			  /*  Bird flock travel    */
77 #define MAXFLCKX        (MAX_X - 370)             /*  limits */
78 
79 // sdh 26/10/2001: merged guages, removed unneccesary coordinates
80 
81 #define GUAGEX          (SCR_CENTR - 25)  /* X co-ordinate of first guage */
82 #define GHOSTX          (SCR_CENTR - 21)/*  Ghost face display x-coodinate  */
83 
84 // sdh 28/10/2001: made into a type
85 
86 typedef enum {
87 	PLAYMODE_UNSET = 0,
88 	PLAYMODE_SINGLE,
89 	PLAYMODE_COMPUTER,
90 	PLAYMODE_ASYNCH,
91 	PLAYMODE_NOVICE
92 } playmode_t;
93 
94 #define MAXROUNDS       200             /* Maximum number of rounds of shot */
95 #define MAXBOMBS        5               /* Maximum number of bombs available*/
96 #define MAXMISSILES     5               /* Maximum number of missiles       */
97 #define MAXBURSTS       5               /* Maximum nuber of starbursts      */
98 #define MAXFUEL         ( 3 * MAX_X )   /* Maximum Number of turns between  */
99                                         /*  refuellings                     */
100 #define MAXCRASH        5               /* Mximum number of crashes allowed */
101 
102 #define MAX_PLYR        4               /* Maximum number of players        */
103 #define MAX_TARG        20              /* Maximum number of targets        */
104 #define MAX_OBJS        100             /* Maximum number of objects        */
105 #define MAX_FLCK        4               /* Maximum number of flocks         */
106 #define MAX_BIRD        1               /* Maximum number of stray birds    */
107                                         /*    per flock                     */
108 #define MAX_GAME        7               /* Maximum number of games          */
109 #define MAX_OXEN        2               /* Maximum number of oxen           */
110 
111 #define ANGLES          16              /*  Number of angle increments      */
112 #define ORIENTS         2               /*  Number of plane orientations    */
113 #define SYM_WDTH        16              /*  Symbol width in pixels          */
114 #define SYM_HGHT        16              /*  Symbol height in pixels         */
115 
116 #define BULSPEED        10              /* Bullet speed    */
117 #define BULLIFE         10              /* Bullet life     */
118 #define BOMBLIFE        5               /* Moves between bomb course adj   */
119 #define MISSLIFE        50              /* Missile life                    */
120 #define BURSTLIFE       20              /* Starburst life                  */
121 #define EXPLLIFE        3               /* Moves between explosion "  "    */
122 #define SMOKELIFE       10              /* Smoke life                      */
123 #define BIRDLIFE        4               /* Moves between bird flaps        */
124 #define FLOCKLIFE       5               /* Moves between flop flaps        */
125 
126 typedef enum {               /*  Player states  */
127 	WAITING = 0,
128 	FLYING ,
129 	HIT,
130 	CRASHED,
131 	FALLING,
132 	STANDING,
133 	STALLED,
134 	REBUILDING,
135 	WOUNDED,
136 	WOUNDSTALL,
137 
138 	FINISHED = 91,
139 	GHOST,
140 	GHOSTCRASHED,
141 	GHOSTSTALLED,
142 } obstate_t;
143 
144 // sdh 21/10/2001: made this an enum
145 
146 enum {
147 	WINNER = 1,
148 	LOSER
149 };
150 
151 // sdh 21/10/2001: converted object types to an enum
152 
153 typedef enum {
154 	GROUND = 0,
155 	PLANE,
156 	BOMB,
157 	SHOT,
158 	TARGET,
159 	EXPLOSION,
160 	SMOKE,
161 	FLOCK,
162 	BIRD,
163 	OX,
164 	MISSILE,
165 	STARBURST,
166 	DUMMYTYPE = 99,
167 } obtype_t;
168 
169 #define NEAR            ( 150 * 150 )   /* Computer control distances        */
170 #define NEARAPPROACH    200
171 #define CLOSE           32
172 #define DEADON          ( 4 * 4 )
173 #define HOME            16
174 #define SAFERESET       32
175 
176 #define QUIT            -5000           /* Plane life value when quitting    */
177 
178 #define K_ACCEL         0x0001          /* Keyboard word masks               */
179 #define K_DEACC         0x0002
180 #define K_FLAPU         0x0004
181 #define K_FLAPD         0x0008
182 #define K_FLIP          0x0010
183 #define K_SHOT          0x0020
184 #define K_BOMB          0x0100
185 #define K_HOME          0x0200
186 #define K_SOUND         0x0400
187 #define K_BREAK         0x0800
188 #define K_MISSILE       0x1000
189 #define K_STARBURST     0x2000
190 
191 #define K_ASYNACK       0x40
192 
193 // made these into typedefs rather than ugly #define macros
194 
195                                         /*  Internal representation of ground */
196                                         /*  due to non-implementation of      */
197                                         /*  unsigned char on ATARI            */
198 typedef  unsigned int GRNDTYPE;
199 
200 struct tt {                     /*  Continuous tone table entry    */
201         unsigned  tt_tone;
202         unsigned  tt_chng;
203         struct tt *tt_next;
204         struct tt *tt_prev;
205 };
206 
207 typedef struct tt TONETAB;
208 
209 typedef struct obj {                            /*  Object list             */
210 	obstate_t      ob_state;
211         int            ob_x, ob_y;
212         int            ob_dx, ob_dy;
213         int            ob_angle;
214         int            ob_orient;
215         int            ob_speed;
216         int            ob_accel;
217         int            ob_flaps;
218         struct obj    *ob_firing;
219         int            ob_score;
220         int            ob_rounds;
221         int            ob_hitcount;
222         int            ob_updcount;
223         int            ob_life;
224         struct obj    *ob_owner;
225         //int            ob_symhgt;   // sdh 27/6/2002
226         //int            ob_symwdt;   // sdh 27/6/2002
227         int            ob_bombing;
228         int            ob_bombs;
229         int            ob_clr;
230         int            ob_lx, ob_ly;
231         int            ob_ldx, ob_ldy;
232         struct obj    *ob_next;
233         struct obj    *ob_prev;
234         int            ob_index;
235         int            ob_oldx;
236         int            ob_oldy;
237         int            ob_drwflg;
238         int            ob_delflg;
239         // char          *ob_oldsym;   // sdh 27/6/2002
240 	sopsym_t      *ob_oldsym;
241         void        ( *ob_drawf ) ();
242         BOOL        ( *ob_movef ) ();
243         struct obj    *ob_xnext;
244         struct obj    *ob_xprev;
245         int            ob_crashcnt;
246         // char          *ob_newsym;   // sdh 27/6/2002
247 	sopsym_t      *ob_newsym;
248         int            ob_bdelay;
249         int            ob_home;
250         int            ob_hx[3], ob_hy[3];
251         obtype_t       ob_type;
252         struct obj    *ob_dnext;
253         int            ob_athome;
254         struct tt     *ob_sound;
255         int            ob_missiles;
256         struct obj    *ob_mfiring;
257         int            ob_mdelay;
258         struct obj    *ob_target;
259         int            ob_bursts;
260         int            ob_bfiring;
261         int            ob_bsdelay;
262 }       OBJECTS;
263 
264 typedef struct {                                /*  Game structure          */
265         int      gm_x[MAX_PLYR*2];
266         int      gm_orient[MAX_PLYR*2];
267         unsigned ( *gm_randf ) ();
268         unsigned gm_rseed;
269         int      ( *gm_specf ) ();
270         int      gm_xtarg[MAX_TARG];
271         int      gm_ttarg[MAX_TARG];
272 }       GAMES;
273 
274 typedef struct {                        /*  Old display parameters for    */
275         int     ow_xorplot;             /*  each object                   */
276         int     ow_x, ow_y;
277 }       OLDWDISP;
278 
279 // sdh: made these into inline functions rather than ugly #define macros
280 
281 extern int sintab[];
282 
COS(int x)283 static inline int COS(int x) {
284 	return sintab[(x+(ANGLES/4)) % ANGLES];
285 }
286 
SIN(int x)287 static inline int SIN(int x) {
288 	return sintab[x % ANGLES];
289 }
290 
291 #endif
292 
293 //---------------------------------------------------------------------------
294 //
295 // $Log: sw.h,v $
296 // Revision 1.4  2003/06/04 15:49:05  fraggle
297 // Removed and unused #define
298 //
299 // Revision 1.3  2003/04/05 22:48:34  fraggle
300 // Remove archaic swmach.h and all IBMPC/ATARI #defines
301 //
302 // Revision 1.2  2003/04/05 22:31:29  fraggle
303 // Remove PLAYMODE_MULTIPLE and swnetio.c
304 //
305 // Revision 1.1.1.1  2003/02/14 19:03:29  fraggle
306 // Initial Sourceforge CVS import
307 //
308 //
309 // sdh 14/2/2003: change license header to GPL
310 // sdh 27/07/2002: made some constants independent of screen width
311 // sdh 27/06/2002: remove ob_symwdt and ob_symhgt. use new sopsym_t for
312 //                 sprites
313 // sdh 20/04/2002: change SCR_CENTR to be dependent on SCR_WDTH
314 //                 widescreen on revo(psion)
315 // sdh 16/11/2001: TCPIP #define to disable TCP/IP support
316 // sdh 21/10/2001: moved sound priorities into swsound.h
317 // sdh 21/10/2001: moved plane sprite constants into appropriate headers
318 // sdh 21/10/2001: created obstate_t and obtype_t enum types
319 // sdh 21/10/2001: rearranged headers, added cvs tags
320 //
321 // 87-04-08        Delay between starbursts
322 // 87-04-04        Missile and starburst support
323 // 87-03-31        Missiles
324 // 87-03-30        Novice Player
325 // 87-03-13        Splatted bird symbol
326 // 87-03-12        Crashed planes stay longer at home.
327 // 87-03-12        Wounded airplanes
328 // 87-03-09        Microsoft compiler
329 // 85-10-31        Atari
330 // 85-04-02        Asynch Mode
331 // 84-06-12        PCjr Speed-up
332 // 84-02-02        Development
333 //
334 //---------------------------------------------------------------------------
335 
336