annotate planets.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1 /* $Id: planets.c,v 1.1.1.1 1997/12/06 05:41:30 darius Exp $ */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
3 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
4 * planets.c
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
5 *
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
6 * Kevin P. Smith 2/21/89
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
7 *
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
8 * This file contains the galaxy definition as well as some support for
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
9 * determining when parts of the galactic map need to be redrawn.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
10 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
11 #include "copyright2.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
12
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
13 #include <stdio.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
14 #include <math.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
15 #include "Wlib.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
16 #include "defs.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
17 #include "struct.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
18 #include "data.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
19 #include "proto.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
20
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
21 /* define to get profiling info, to better set DEPTH and DETAIL [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
22 /*#define PROFILE1 /* maxdepth printed */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
23 /*#define PROFILE2 /* every PLREDRAW setting printed (VERBOSE) */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
24
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
25 /* Note: DETAIL * MUST * be a factor of GWIDTH. */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
26 #define DETAIL 80 /* Size of redraw array */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
27 #define RADIUS 2 /* number of adjacent cells to register in */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
28 #define SIZE 2500
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
29 #define DEPTH 8
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
30 #ifdef PROFILE1
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
31 #define ADDPLANET(i,j,k) { \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
32 for(z=0;z<DEPTH;z++) { \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
33 if(redraws[i][j][z] == (char)-1) { \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
34 redraws[i][j][z] = k; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
35 break; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
36 } \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
37 } z++; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
38 if(z > maxdepth) maxdepth = z; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
39 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
40 #else /* not PROFILEing */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
41 #define ADDPLANET(i,j,k) { \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
42 for(z=0;z<DEPTH;z++) { \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
43 if(redraws[i][j][z] == (char)-1) { \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
44 redraws[i][j][z]=k; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
45 break; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
46 } \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
47 } \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
48 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
49 #endif /* PROFILE1 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
50
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
51 #define LEFT 1 /* position flags for corner guessing */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
52 #define RIGHT 2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
53 #define TOP 4
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
54 #define BOTTOM 8
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
55
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
56 struct _star {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
57 int s_x, s_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
58 int s_color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
59 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
60
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
61 static void redrawStarSector P((struct _star star_sector[16]));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
62
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
63 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
64 planets may be on top of each other or very close, so more than one planet
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
65 can exist in a given block. The 3rd dimension is for a list of planets.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
66 [BDyess]
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
67 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
68 char redraws[DETAIL][DETAIL][DEPTH];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
69 static int initialized = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
70
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
71 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
72 since planets may be moved, the redraw matrix must be updated. This
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
73 function is for updating just one planet. This should help the moving
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
74 planet efficiency problems quite a bit. [BDyess]
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
75 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
76 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
77 initOnePlanet(pl)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
78 struct planet *pl;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
79 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
80 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
81
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
82 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
83 rewritten to repair UNBELIEVABLE inefficiencies in the original [BDyess]
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
84 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
85 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
86 initPlanets()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
87 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
88 register int i, j, k, x, y, z, r, s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
89 struct planet *pl;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
90 #ifdef PROFILE1
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
91 int maxdepth = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
92 #endif /* PROFILE1 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
93
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
94 /* initialize lookup array */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
95 for (i = 0; i < DETAIL; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
96 for (j = 0; j < DETAIL; j++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
97 for (k = 0; k < DEPTH; k++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
98 redraws[i][j][k] = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
99 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
100 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
101 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
102
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
103 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
104 check all the planets. If part of the planet falls inside a box in
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
105 the lookup array, add it to the refresh list for that box. [BDyess]
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
106 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
107 for (k = 0, pl = planets; k < nplanets; k++, pl++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
108 x = pl->pl_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
109 y = pl->pl_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
110 i = x / SIZE - 3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
111 j = y / SIZE - 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
112 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
113 fill cells around the target cell with the planetnum like so: ****
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
114
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
115 **
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
116
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
117 x** ****
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
118
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
119 **
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
120
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
121 ** taller than wide because of text ****
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
122
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
123 [BDyess]
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
124 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
125 for (r = 0; r < 5; r++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
126 i++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
127 if (i <= 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
128 continue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
129 if (i >= DETAIL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
130 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
131 for (s = 0; s < 7; s++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
132 j += s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
133 if (j <= 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
134 continue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
135 if (j >= DETAIL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
136 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
137 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
138 j -= s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
139 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
140 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
141 #if 0 /* this works, and allows the radius around
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
142 the hot spot to be changed. It's disabled
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
143 because a less-flexible piece of code
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
144 (above) is a bit faster. Plus, it's hard
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
145 to generalize about that extra added
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
146 lines. [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
147 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
148 for (r = 1; r <= RADIUS; r++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
149 /* draw box sides in all four directions */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
150 /* bottom */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
151 i += r;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
152 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
153 for (s = 1; s <= r; s++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
154 j += s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
155 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
156 j -= 2 * s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
157 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
158 j += s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
159 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
160 /* top */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
161 i -= 2 * r;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
162 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
163 for (s = 1; s <= r; s++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
164 j += s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
165 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
166 j -= 2 * s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
167 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
168 j += s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
169 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
170 /* left */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
171 i += r;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
172 j += r;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
173 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
174 for (s = 1; s < r; s++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
175 i += s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
176 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
177 i -= 2 * s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
178 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
179 i += s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
180 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
181 /* right */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
182 j -= 2 * r;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
183 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
184 for (s = 1; s < r; s++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
185 i += s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
186 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
187 i -= 2 * s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
188 ADDPLANET(i, j, k)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
189 i += s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
190 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
191 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
192 #endif /* 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
193 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
194 initialized = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
195 #ifdef PROFILE1
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
196 printf("max depth = %d\n", maxdepth);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
197 #endif /* PROFILE1 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
198 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
199
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
200 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
201 checkRedraw(x, y)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
202 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
203 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
204 int j;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
205 char i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
206
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
207 if (!initialized || x < 0 || y < 0 || x >= blk_gwidth || y >= blk_gwidth)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
208 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
209 x /= SIZE;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
210 y /= SIZE;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
211 for (j = 0; j < DEPTH; j++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
212 i = redraws[x][y][j];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
213 if (i == (char) -1)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
214 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
215 planets[i].pl_flags |= PLREDRAW;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
216 #ifdef PROFILE2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
217 printf("setting PLREDRAW flag for %s\n", planets[i].pl_name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
218 #endif /* PROFILE2 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
219 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
220 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
221
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
222
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
223 /* NOTE: this has been rewritten -- see below */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
224
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
225 #define NUMSTARS 1600
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
226
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
227 static int starsX[NUMSTARS];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
228 static int starsY[NUMSTARS];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
229
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
230 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
231 _initStars()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
232 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
233 register int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
234
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
235 for (i = 0; i < NUMSTARS; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
236 starsX[i] = (i % 40) * 5000 + random() % 5000;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
237 starsY[i] = (i / 40) * 5000 + random() % 5000;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
238 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
239 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
240
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
241 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
242 _drawStars()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
243 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
244 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
245 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
246
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
247 for (i = 0; i < NUMSTARS; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
248 x = starsX[i] - me->p_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
249 y = starsY[i] - me->p_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
250 if (ABS(x) < 10000 && ABS(y) < 10000) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
251 x = x / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
252 y = y / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
253 W_DrawPoint(w, x, y, W_White);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
254 W_CacheClearArea(w, x, y, 1, 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
255 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
256 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
257 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
258
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
259 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
260 * This rewrite improves drawStars() by a factor of about 30 (according to
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
261 * gprof)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
262 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
263
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
264 /* blk_gwidth/(WINSIDE * SCALE) == 10 for blk_gwidth == 200000 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
265 static struct _star stars[10][10][16];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
266
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
267 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
268 initStars()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
269 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
270 register int i, j, k;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
271
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
272 for (i = 0; i < 10; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
273 for (j = 0; j < 10; j++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
274 for (k = 0; k < 16; k++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
275 stars[i][j][k].s_x = i * (WINSIDE * SCALE) + random() % (WINSIDE * SCALE);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
276 stars[i][j][k].s_y = j * (WINSIDE * SCALE) + random() % (WINSIDE * SCALE);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
277 stars[i][j][k].s_color = randcolor();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
278 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
279 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
280 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
281 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
282
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
283 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
284 randcolor()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
285 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
286 switch (random() % 10) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
287 case 0:return W_Yellow;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
288 case 1:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
289 return W_Red;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
290 case 2:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
291 return W_Green;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
292 case 3:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
293 return W_Cyan;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
294 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
295 return W_White;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
296 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
297 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
298
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
299 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
300 drawStars()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
301 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
302 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
303 note: cpp symbols in expressions (WINSIDE*SCALE) will be precalculated
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
304 by any C optimizer
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
305 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
306 int sectorx = me->p_x / (WINSIDE * SCALE), sectory = me->p_y / (WINSIDE * SCALE);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
307 int sector_offx = me->p_x - sectorx * (WINSIDE * SCALE), sector_offy = me->p_y - sectory * (WINSIDE * SCALE);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
308 int l = 0, r = 0, t = 0, b = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
309
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
310 if (sector_offx < 0) { /* goddamn rounding towards 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
311 sectorx--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
312 sector_offx += WINSIDE * SCALE;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
313 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
314 if (sector_offy < 0) { /* goddamn rounding towards 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
315 sectory--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
316 sector_offy += WINSIDE * SCALE;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
317 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
318 #define MAXSECTOR (blk_gwidth/(WINSIDE*SCALE))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
319
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
320 /* at worst we have to redraw 4 star sectors */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
321
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
322 /* draw the one we're in */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
323 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
324 check first to make sure it's valid. This is mainly important for if
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
325 it tries to redraw and we're already dead
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
326 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
327 if (sectorx < 0 || sectory < 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
328 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
329
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
330 l = sector_offx < (WINSIDE * SCALE) / 2 && sectorx > 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
331 r = sector_offx > (WINSIDE * SCALE) / 2 && sectorx + 1 < MAXSECTOR;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
332 t = sector_offy < (WINSIDE * SCALE) / 2 && sectory > 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
333 b = sector_offy > (WINSIDE * SCALE) / 2 && sectory + 1 < MAXSECTOR;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
334
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
335 if (t) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
336 if (l) /* redraw upper-left sector */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
337 redrawStarSector(stars[sectorx - 1][sectory - 1]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
338
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
339 /* redraw upper sector */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
340 redrawStarSector(stars[sectorx][sectory - 1]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
341
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
342 if (r) /* redraw upper-right sector */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
343 redrawStarSector(stars[sectorx + 1][sectory - 1]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
344 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
345 if (l) /* redraw left sector */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
346 redrawStarSector(stars[sectorx - 1][sectory]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
347
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
348 /* redraw center sector */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
349 redrawStarSector(stars[sectorx][sectory]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
350
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
351 if (r) /* redraw right sector */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
352 redrawStarSector(stars[sectorx + 1][sectory]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
353
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
354 if (b) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
355 if (l) /* redraw bottom-left sector */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
356 redrawStarSector(stars[sectorx - 1][sectory + 1]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
357
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
358 /* redraw bottom sector */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
359 redrawStarSector(stars[sectorx][sectory + 1]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
360
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
361 if (r) /* redraw bottom-right sector */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
362 redrawStarSector(stars[sectorx + 1][sectory + 1]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
363 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
364 W_FlushPointCaches(w);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
365 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
366
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
367 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
368 redrawStarSector(star_sector)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
369 struct _star star_sector[16];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
370 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
371 register i, dx, dy, dxx, dyy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
372 register struct _star *s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
373 static int warpflag = 0; /* assume starting out not in warp */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
374 static int streaksOn = 0, lastspeed = 0, lastsubspeed = 0, updates = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
375 static int streaklength = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
376
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
377 if (warpStreaks) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
378 if (warpflag != (me->p_flags & PFWARP)) { /* change in warp state */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
379 streaksOn = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
380 warpflag = (me->p_flags & PFWARP);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
381 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
382 if (streaksOn) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
383 if (warpflag && (me->p_speed < lastspeed ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
384 (me->p_speed == lastspeed && me->p_subspeed <= lastsubspeed))) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
385 /* finished accelerating */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
386 updates++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
387 if (updates > 5) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
388 lastspeed = me->p_speed;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
389 lastsubspeed = me->p_subspeed;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
390 updates = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
391 streaksOn = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
392 redrawStarSector(star_sector);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
393 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
394 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
395 } else if (streaklength == 1 || (!warpflag && ((me->p_speed > lastspeed) ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
396 (me->p_speed == lastspeed && me->p_subspeed >= lastsubspeed)))) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
397 /* finished decelerating */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
398 updates++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
399 if (updates > 5) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
400 lastspeed = me->p_speed;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
401 lastsubspeed = me->p_subspeed;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
402 updates = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
403 streaksOn = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
404 streaklength = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
405 redrawStarSector(star_sector);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
406 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
407 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
408 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
409 updates = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
410 lastspeed = me->p_speed;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
411 lastsubspeed = me->p_subspeed;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
412 /* draw the streaks */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
413 if (warpflag)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
414 streaklength += 3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
415 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
416 streaklength--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
417 dxx = (int) (Cos[me->p_dir] * streaklength);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
418 dyy = (int) (Sin[me->p_dir] * streaklength);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
419 for (i = 0, s = star_sector; i < 16; i++, s++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
420 dx = s->s_x - me->p_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
421 dy = s->s_y - me->p_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
422 if (ABS(dx) > (SCALE * WINSIDE / 2) || ABS(dy) > (SCALE * WINSIDE / 2))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
423 continue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
424
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
425 dx = dx / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
426 dy = dy / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
427 W_CacheLine(w, dx, dy, dx - dxx, dy - dyy, s->s_color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
428
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
429 clearline[0][clearlcount] = dx;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
430 clearline[1][clearlcount] = dy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
431 clearline[2][clearlcount] = dx - dxx;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
432 clearline[3][clearlcount] = dy - dyy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
433 clearlcount++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
434 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
435 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
436 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
437 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
438 for (i = 0, s = star_sector; i < 16; i++, s++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
439 dx = s->s_x - me->p_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
440 dy = s->s_y - me->p_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
441 if (ABS(dx) > (SCALE * WINSIDE / 2) || ABS(dy) > (SCALE * WINSIDE / 2))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
442 continue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
443
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
444 dx = dx / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
445 dy = dy / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
446 W_CachePoint(w, dx, dy, s->s_color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
447 #ifndef AMIGA
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
448 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
449 this is a minor kludge: as long as there are less then 128 stars
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
450 in a sector these cached requests will not actually be written to
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
451 the X server until the next redraw cycle begins.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
452 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
453 W_CacheClearArea(w, dx, dy, 1, 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
454 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
455 clearline[0][clearlcount] = dx;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
456 clearline[1][clearlcount] = dy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
457 clearline[2][clearlcount] = dx;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
458 clearline[3][clearlcount] = dy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
459 clearlcount++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
460 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
461 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
462 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
463
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
464 #if 0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
465 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
466 clearStars()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
467 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
468 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
469 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
470
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
471 for (i = 0; i < NUMSTARS; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
472 x = starsX[i] - me->p_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
473 y = starsY[i] - me->p_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
474 if (ABS(x) < 10000 && ABS(y) < 10000) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
475 x = x / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
476 y = y / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
477 W_CacheClearArea(w, x, y, 1, 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
478 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
479 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
480 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
481 #endif