1 /*
2 	swdispc  -	Display all players and objects
3 
4 	Copyright (C) 1984-2003 David L. Clark.
5 	This program is free software; you can redistribute it and/or modify it under
6 	the terms of the GNU General Public License as published by the Free Software
7 	Foundation; either version 2 of the License, or (at your option) any later
8 	version. This program is distributed in the hope that it will be useful,
9 	but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 	or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 	more details. You should have received a copy of the GNU General Public
12 	License along with this program; if not, write to the Free Software Foundation,
13 	Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
14 
15 			Author: Dave Clark
16 
17 	Modification History:
18 			84-02-21	Development
19 			84-06-12	PCjr Speed-up
20 			87-03-09	Microsoft compiler.
21 			87-03-12	Wounded airplanes.
22 			87-03-13	Splatted bird symbol.
23 			87-04-05	Missile and starburst support
24 			2003-01-27	GNU General Public License
25 */
26 #include	"sw.h"
27 
28 
29 
30 extern	OLDWDISP wdisp[];		/*  World display status	    */
31 extern	OBJECTS *nobjects;		/*  Objects list.		    */
32 extern	OBJECTS *objtop;		/*  Start of object list.	    */
33 extern	int	shothole;		/*  Number of shot holes to display */
34 extern	int	splatbird;		/*  Number of splatted birds	    */
35 extern	int	splatox;		/* Display splatted ox		    */
36 extern	int	oxsplatted;		/* An ox has been splatted	    */
37 extern	char	swshtsym[];		/*  Shot hole symbol		    */
38 extern	char	swsplsym[];		/*  Splatted bird symbol	    */
39 extern	int	countmove;		/*  Move number 		    */
40 
41 
42 
43 
44 
45 
46 
47 dispplyr( ob )
48 OBJECTS *ob;
49 {
50 	if ( shothole )
51 		dispwindshot();
52 	if ( splatbird )
53 		dispsplatbird();
54 	plnsound( ob );
55 }
56 
57 
58 
59 
60 
61 
62 dispbomb( obp )
63 OBJECTS *obp;
64 {
65 register OBJECTS *ob;
66 
67 	if ( ( ob = obp )->ob_dy <= 0 )
68 		sound( S_BOMB, -( ob->ob_y ), ob );
69 }
70 
71 
72 
73 
74 
75 dispmiss( obp )
76 OBJECTS *obp;
77 {
78 }
79 
80 
81 
82 
83 
84 dispburst( obp )
85 OBJECTS *obp;
86 {
87 }
88 
89 
90 
91 
92 
93 dispexpl( obp )
94 OBJECTS *obp;
95 {
96 register OBJECTS *ob;
97 
98 	if ( ( ob = obp )->ob_orient )
99 		sound( S_EXPLOSION, ob->ob_hitcount, ob );
100 }
101 
102 
103 
104 
105 
106 dispcomp( ob )
107 OBJECTS *ob;
108 {
109 	plnsound( ob );
110 }
111 
112 
113 
114 
115 dispmult( ob )
116 OBJECTS *ob;
117 {
118 	plnsound( ob );
119 }
120 
121 
122 
123 
124 disptarg( ob )
125 OBJECTS *ob;
126 {
127 	if ( ob->ob_firing )
128 		sound( S_SHOT, 0, ob );
129 }
130 
131 
132 
133 
134 dispflck( ob )
135 OBJECTS *ob;
136 {
137 }
138 
139 
140 
141 
142 dispbird( ob )
143 OBJECTS *ob;
144 {
145 }
146 
147 
148 
149 
150 
151 static	plnsound( obp )
152 OBJECTS *obp;
153 {
154 register OBJECTS *ob;
155 
156 	ob = obp;
157 	if ( ob->ob_firing )
158 		sound( S_SHOT, 0, ob );
159 	else
160 		switch ( ob->ob_state ) {
161 			case FALLING:
162 				if ( ob->ob_dy >= 0 )
163 					sound( S_HIT, 0, ob );
164 				else
165 					sound( S_FALLING, ob->ob_y, ob );
166 				break;
167 
168 			case FLYING:
169 				sound( S_PLANE, -( ob->ob_speed ), ob );
170 				break;
171 
172 			case STALLED:
173 			case WOUNDED:
174 			case WOUNDSTALL:
175 				sound( S_HIT, 0, ob );
176 				break;
177 
178 			default:
179 				break;
180 		}
181 
182 }
183 
184 
185 
186 
187 dispwobj( obp )
188 OBJECTS *obp;
189 {
190 register OBJECTS  *ob;
191 register OLDWDISP *ow;
192 int		  ox, oy, oldplot;
193 
194 	ob = obp;
195 	ow = &wdisp[ob->ob_index];
196 
197 	if ( ow->ow_xorplot )
198 		swpntsym( ow->ow_x, ow->ow_y, ow->ow_xorplot - 1 );
199 
200 	if ( ob->ob_state >= FINISHED )
201 		ow->ow_xorplot = 0;
202 	else {
203 		oldplot = swpntcol( ow->ow_x = SCR_CENTR
204 				    + ( ob->ob_x + ob->ob_symwdt / 2 )
205 				    / WRLD_RSX,
206 				    ow->ow_y
207 				    = ( ob->ob_y - ob->ob_symhgt / 2 )
208 				    / WRLD_RSY,
209 				    ob->ob_owner->ob_clr );
210 
211 		if ( ( oldplot == 0 ) || ( ( oldplot & 0x0003 ) == 3 ) ) {
212 			ow->ow_xorplot = oldplot + 1;
213 			return;
214 		}
215 		swpntsym( ow->ow_x, ow->ow_y, oldplot );
216 		ow->ow_xorplot = 0;
217 	}
218 }
219 
220 
221 static	unsigned long	 seed = 74917777;
222 
223 unsigned long	randsd()
224 {
225 	if ( !( seed = seed * countmove + 7491 ) )
226 		seed = 74917777;
227 }
228 
229 
230 
231 dispwindshot()
232 {
233 OBJECTS 		 ob;
234 
235 	ob.ob_type = DUMMYTYPE;
236 	ob.ob_symhgt = ob.ob_symwdt = 16;
237 	ob.ob_clr = 1;
238 	ob.ob_newsym = swshtsym;
239 	do {
240 		randsd();
241 		swputsym( (unsigned)( seed % ( SCR_WDTH - 16 ) ),
242 			  (unsigned)( seed % ( SCR_HGHT - 50 ) ) + 50,
243 			  &ob );
244 	} while ( --shothole );
245 }
246 
247 
248 
249 dispsplatbird()
250 {
251 OBJECTS 		 ob;
252 
253 	ob.ob_type = DUMMYTYPE;
254 	ob.ob_symhgt = ob.ob_symwdt = 32;
255 	ob.ob_clr = 2;
256 	ob.ob_newsym = swsplsym;
257 	do {
258 		randsd();
259 		swputsym( (unsigned)( seed % ( SCR_WDTH - 32 ) ),
260 			  (unsigned)( seed % ( SCR_HGHT - 60 ) ) + 60,
261 			  &ob );
262 	} while ( --splatbird );
263 }
264 
265 
266 
267 
268 dispoxsplat()
269 {
270 register OBJECTS *ob;
271 register int	 i;
272 
273 	swsetblk( 0,	    SCR_SEGM,
274 		  ( ( SCR_HGHT - SCR_MNSH - 2 ) >> 1 ) * SCR_LINW, 0xAA );
275 	swsetblk( SCR_ROFF, SCR_SEGM,
276 		  ( ( SCR_HGHT - SCR_MNSH - 3 ) >> 1 ) * SCR_LINW, 0xAA );
277 	splatox = 0;
278 	oxsplatted = 1;
279 
280 	ob = nobjects;
281 	for ( i = 0; i < MAX_OBJS; ++i, ob++ )
282 		ob->ob_drwflg = ob->ob_delflg = 0;
283 }
284 