1 // Emacs style mode select -*- C++ -*-
2 //---------------------------------------------------------------------------
3 //
4 // $Id: swdisp.c,v 1.2.2.1 2003/06/08 18:16:38 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 // swdispc - Display all players and objects
23 //
24 //---------------------------------------------------------------------------
25
26 #include "video.h"
27
28 #include "sw.h"
29 #include "swdisp.h"
30 #include "swgrpha.h"
31 #include "swmain.h"
32 #include "swsound.h"
33 #include "swsymbol.h"
34 #include "swutil.h"
35
plnsound(OBJECTS * obp)36 static void plnsound(OBJECTS *obp)
37 {
38 register OBJECTS *ob = obp;
39
40 if (ob->ob_firing)
41 sound(S_SHOT, 0, ob);
42 else
43 switch (ob->ob_state) {
44 case FALLING:
45 if (ob->ob_dy >= 0)
46 sound(S_HIT, 0, ob);
47 else
48 sound(S_FALLING, ob->ob_y, ob);
49 break;
50
51 case FLYING:
52 sound(S_PLANE, -ob->ob_speed, ob);
53 break;
54
55 case STALLED:
56 case WOUNDED:
57 case WOUNDSTALL:
58 sound(S_HIT, 0, ob);
59 break;
60
61 default:
62 break;
63 }
64
65 }
66
67
68
dispbomb(OBJECTS * obp)69 void dispbomb(OBJECTS * obp)
70 {
71 register OBJECTS *ob = obp;
72
73 if (ob->ob_dy <= 0)
74 sound(S_BOMB, -ob->ob_y, ob);
75 }
76
77
78
79
80
dispmiss(OBJECTS * obp)81 void dispmiss(OBJECTS * obp)
82 {
83 }
84
85
86
87
88
dispburst(OBJECTS * obp)89 void dispburst(OBJECTS * obp)
90 {
91 }
92
93
94
95
96
dispexpl(OBJECTS * obp)97 void dispexpl(OBJECTS * obp)
98 {
99 register OBJECTS *ob = obp;
100
101 if (ob->ob_orient)
102 sound(S_EXPLOSION, ob->ob_hitcount, ob);
103 }
104
105
106
107
108
dispcomp(OBJECTS * ob)109 void dispcomp(OBJECTS * ob)
110 {
111 plnsound(ob);
112 }
113
114
115
116
dispmult(OBJECTS * ob)117 void dispmult(OBJECTS * ob)
118 {
119 plnsound(ob);
120 }
121
122
123
124
disptarg(OBJECTS * ob)125 void disptarg(OBJECTS * ob)
126 {
127 if (ob->ob_firing)
128 sound(S_SHOT, 0, ob);
129 }
130
131
132
133
dispflck(OBJECTS * ob)134 void dispflck(OBJECTS * ob)
135 {
136 }
137
138
139
140
dispbird(OBJECTS * ob)141 void dispbird(OBJECTS * ob)
142 {
143 }
144
145
146
dispwobj(OBJECTS * obp)147 void dispwobj(OBJECTS * obp)
148 {
149 register OBJECTS *ob;
150 register OLDWDISP *ow;
151 // int ox, oy;
152 int oldplot;
153
154 ob = obp;
155 ow = &wdisp[ob->ob_index];
156
157 if (ow->ow_xorplot)
158 Vid_PlotPixel(ow->ow_x, ow->ow_y, ow->ow_xorplot - 1);
159
160 if (ob->ob_state >= FINISHED)
161 ow->ow_xorplot = 0;
162 else {
163 ow->ow_x = SCR_CENTR
164 + (ob->ob_x + ob->ob_newsym->w / 2) / WRLD_RSX;
165 ow->ow_y = (ob->ob_y - ob->ob_newsym->h / 2) / WRLD_RSY;
166
167 // sdh 27/03/02: use new functions
168
169 oldplot = Vid_GetPixel(ow->ow_x, ow->ow_y);
170 Vid_PlotPixel(ow->ow_x, ow->ow_y, ob->ob_owner->ob_clr);
171
172 if (oldplot == 0 || (oldplot & 0x0003) == 3) {
173 ow->ow_xorplot = oldplot + 1;
174 return;
175 }
176 Vid_PlotPixel(ow->ow_x, ow->ow_y, oldplot);
177 ow->ow_xorplot = 0;
178 }
179 }
180
181 #define SEED_START 74917777
182
183 static unsigned long seed = SEED_START;
184
randsd()185 static unsigned long randsd()
186 {
187 seed *= countmove;
188 seed += 7491;
189
190 if (!seed)
191 seed = SEED_START;
192
193 return 0;
194 }
195
196
dispwindshot()197 static void dispwindshot()
198 {
199 OBJECTS ob;
200
201 // sdh 28/10/2001: option to disable hud splats
202
203 if (!conf_hudsplats)
204 return;
205
206 ob.ob_type = DUMMYTYPE;
207 //ob.ob_symhgt = ob.ob_symwdt = 16;
208 ob.ob_clr = 0;
209 ob.ob_newsym = symbol_shotwin;
210
211 do {
212 randsd();
213 swputsym((unsigned) (seed % (SCR_WDTH - 16)),
214 (unsigned) (seed % (SCR_HGHT - 50)) + 50, &ob);
215 } while (--shothole);
216 }
217
218
219
dispsplatbird()220 static void dispsplatbird()
221 {
222 OBJECTS ob;
223
224 // sdh 28/10/2001: option to disable hud splats
225
226 if (!conf_hudsplats)
227 return;
228
229 ob.ob_type = DUMMYTYPE;
230 //ob.ob_symhgt = ob.ob_symwdt = 32;
231 ob.ob_clr = 2;
232 ob.ob_newsym = symbol_birdsplat;
233
234 do {
235 randsd();
236 swputsym((unsigned) (seed % (SCR_WDTH - 32)),
237 (unsigned) (seed % (SCR_HGHT - 60)) + 60, &ob);
238 } while (--splatbird);
239 }
240
241
242
243
dispoxsplat()244 static void dispoxsplat()
245 {
246 register OBJECTS *ob;
247 register int i;
248
249 // sdh 28/10/2001: option to disable hud splats
250
251 if (!conf_hudsplats)
252 return;
253
254 colorscreen(2);
255
256 swsetblk(0, SCR_SEGM,
257 ((SCR_HGHT - SCR_MNSH - 2) >> 1) * SCR_LINW, 0xAA);
258 swsetblk(SCR_ROFF, SCR_SEGM,
259 ((SCR_HGHT - SCR_MNSH - 3) >> 1) * SCR_LINW, 0xAA);
260 splatox = 0;
261 oxsplatted = 1;
262
263 ob = nobjects;
264 for (i = 0; i < MAX_OBJS; ++i, ob++)
265 ob->ob_drwflg = ob->ob_delflg = 0;
266
267 dispinit = TRUE;
268 }
269
dispplyr(OBJECTS * ob)270 void dispplyr(OBJECTS * ob)
271 {
272 if (shothole)
273 dispwindshot();
274 if (splatbird)
275 dispsplatbird();
276 if (splatox)
277 dispoxsplat();
278
279 plnsound(ob);
280 }
281
282
283 //---------------------------------------------------------------------------
284 //
285 // $Log: swdisp.c,v $
286 // Revision 1.2.2.1 2003/06/08 18:16:38 fraggle
287 // Fix networking and some compile bugs
288 //
289 // Revision 1.2 2003/04/05 22:44:04 fraggle
290 // Remove some useless functions from headers, make them static if they
291 // are not used by other files
292 //
293 // Revision 1.1.1.1 2003/02/14 19:03:10 fraggle
294 // Initial Sourceforge CVS import
295 //
296 //
297 // sdh 14/2/2003: change license header to GPL
298 // sdh 27/06/2002: move to new sopsym_t for symbols,
299 // remove symwdt and symhgt
300 // sdh 28/10/2001: option to disable hud splats
301 // sdh 21/10/2001: rearranged file headers, added cvs tags
302 // sdh 21/10/2001: reformatted with indent, adjusted some code by hand
303 // to make more readable
304 // sdh 19/10/2001: removed extern definitions: these are now in headers
305 // shuffled some functions around to shut up compiler
306 // sdh 18/10/2001: converted all functions to ANSI-style arguments
307 //
308 // 87-04-05 Missile and starburst support
309 // 87-03-13 Splatted bird symbol.
310 // 87-03-12 Wounded airplanes.
311 // 87-03-09 Microsoft compiler.
312 // 84-06-12 PCjr Speed-up
313 // 84-02-21 Development
314 //
315 //---------------------------------------------------------------------------
316
317