Debian Codegraph @

Descent3/procedurals.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/procedurals.cpp $
21 * $Revision: 34 $
22 * $Date: 7/28/99 3:46p $
23 * $Author: Kevin $
24 *
25 * Procedurals
26 *
27 * $Log: /DescentIII/main/procedurals.cpp $
28 *
29 * 34 7/28/99 3:46p Kevin
30 * Mac!
31 *
32 * 33 5/10/99 10:23p Ardussi
33 * changes to compile on Mac
34 *
35 * 32 4/22/99 8:29p Kevin
36 * made psrand.h come after stdlib.h
37 *
38 * 31 4/21/99 11:05a Kevin
39 * new ps_rand and ps_srand to replace rand & srand
40 *
41 * $NoKeywords: $
42 */
43
44 #include <algorithm>
45
46 #include "procedurals.h"cxx . . $ `<file>/Descent3/procedurals.h`/
47 #include "bitmap.h"cxx . . $ `<file>/lib/bitmap.h`/
48 #include "gr.h"cxx . . $ `<file>/2dlib/gr.h`/
49 #include "gametexture.h"cxx . . $ `<file>/Descent3/gametexture.h`/
50 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
51 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
52 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
53 #include "config.h"cxx . . $ `<file>/Descent3/config.h`/
54 #include <stdlib.h>
55 #include <math.h>
56 #include <memory.h>
57 #include "psrand.h"cxx . . $ `<file>/misc/psrand.h`/
58
59
60 #define BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`! 254
61 #define PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! 128
62 #define TABSIZEcxx . . $ `Descent3/procedurals.cpp:62:9`! 256
63 #define TABMASKcxx . . $ `Descent3/procedurals.cpp:63:9`! (TABSIZEcxx . . $ `Descent3/procedurals.cpp:62:9`! - 1)
64 #define PERMcxx . . $ `Descent3/procedurals.cpp:64:9`!(x) perm[(x) & TABMASKcxx . . $ `Descent3/procedurals.cpp:63:9`!]
65 #define INDEXcxx . . $ `Descent3/procedurals.cpp:65:9`!(ix, iy) PERMcxx . . $ `Descent3/procedurals.cpp:64:9`!((ix) + PERMcxx . . $ `Descent3/procedurals.cpp:64:9`!((iy)))
66 #define RANDNBRcxx . . $ `Descent3/procedurals.cpp:66:9`! ((prand()) / (float)D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`!)
67 #define LERPcxx . . $ `Descent3/procedurals.cpp:67:9`!(t, x0, x1) ((x0) + (t) * ((x1) - (x0)))
68 #define SMOOTHSTEPcxx . . $ `Descent3/procedurals.cpp:68:9`!(x) ((x))
69 uint8_tcxx . . $ uint8_t# permcxx . . $ perm.[TABSIZEcxx . . $ `Descent3/procedurals.cpp:62:9`!];
70 static float Noise_tablecxx . . $ Noise_table.[TABSIZEcxx . . $ `Descent3/procedurals.cpp:62:9`! * 3];
71 dynamic_proc_elementcxx . . $ dynamic_proc_element# DynamicProcElementscxx . . $ DynamicProcElements.[MAX_PROC_ELEMENTScxx . . $ `Descent3/procedurals.h:26:9`!];
72 uint16_tcxx . . $ uint16_t# DefaultProcPalettecxx . . $ DefaultProcPalette.[256];
73 int Num_proc_elementscxx . . $ Num_proc_elements. = 0;
74 static int16_t Proc_free_listcxx . . $ Proc_free_list.[MAX_PROC_ELEMENTScxx . . $ `Descent3/procedurals.h:26:9`!];
75 uint16_tcxx . . $ uint16_t# ProcFadeTablecxx . . $ ProcFadeTable.[32768];
76 #define NUM_WATER_SHADEScxx . . $ `Descent3/procedurals.cpp:76:9`! 64
77 uint16_tcxx . . $ uint16_t# WaterProcTableHicxx . . $ WaterProcTableHi.[NUM_WATER_SHADEScxx . . $ `Descent3/procedurals.cpp:76:9`!][256];
78 uint8_tcxx . . $ uint8_t# WaterProcTableLocxx . . $ WaterProcTableLo.[NUM_WATER_SHADEScxx . . $ `Descent3/procedurals.cpp:76:9`!][256];
79 const char *ProcNamescxx . . $ ProcNames.[] = {"None", "Line Lightning", "Sphere lightning", "Straight", "Rising Embers", "Random Embers",
80 "Spinners", "Roamers", "Fountain", "Cone", "Fall Right", "Fall Left",
81 "END"};
82 const char *WaterProcNamescxx . . $ WaterProcNames.[] = {"None", "Height blob", "Sine Blob", "Random Raindrops", "Random Blobdrops", "END"};
83 static uint8_tcxx . . $ uint8_t# *ProcDestDatacxx . . $ ProcDestData.;
84 int pholdrandcxx . . $ pholdrand. = 1;
85 static inline int prandcxx . . $ prand(b126dc7c1de90089).() { return (((pholdrandcxx . . $ pholdrand. = pholdrandcxx . . $ pholdrand. * 214013L + 2531011L) >> 16) & 0x7fff); }
86 // Given an array of r,g,b values, generates a 16bit palette table for those colors
87 void GeneratePaletteForProceduralcxx . . $ GeneratePaletteForProcedural(192b6fdb665876e4).(uint8_tcxx . . $ uint8_t# *r, uint8_tcxx . . $ uint8_t# *g, uint8_tcxx . . $ uint8_t# *b, uint16_tcxx . . $ uint16_t# *pal) {
88 int i;
89 float fr, fg, fb;
90 for (i = 0; i < 256; i++) {
91 int ir = r[i];
92 int ig = g[i];
93 int ib = b[i];
94 fr = (float)ir / 255.0;
95 fg = (float)ig / 255.0;
96 fb = (float)ib / 255.0;
97 ir = (fr * 31.0);
98 ig = (fg * 31.0);
99 ib = (fb * 31.0);
100 pal[i] = OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`! | (ir << 10) | (ig << 5) | (ib);
101 }
102 }
103 // Inits the noise table for procedurals
104 void InitNoisecxx . . $ InitNoise(49f6e7a06ebc5aa8).() {
105 float *table = Noise_tablecxx . . $ Noise_table.;
106 float z, r, theta;
107 int i;
108 for (i = 0; i < TABSIZEcxx . . $ `Descent3/procedurals.cpp:62:9`!; i++) {
109 permcxx . . $ perm.[i] = prandcxx . . $ prand(b126dc7c1de90089).() % TABMASKcxx . . $ `Descent3/procedurals.cpp:63:9`!;
110 z = 1.0f - 2.0f * RANDNBRcxx . . $ `Descent3/procedurals.cpp:66:9`!;
111
112 /* r is radius of x,y circle */
113 r = sqrtf(1 - z * z);
114 /* theta is angle in (x,y) */
115 theta = 2.0f * 3.14f * RANDNBRcxx . . $ `Descent3/procedurals.cpp:66:9`!;
116 *table++ = r * cosf(theta);
117 *table++ = r * sinf(theta);
118 *table++ = z;
119 }
120 }
121 // Gets a lattice point for our noise
122 float GradLatticecxx . . $ GradLattice(d287910fd745093b).(int ix, int iy, float fx, float fy) {
123 float *g = &Noise_tablecxx . . $ Noise_table.[INDEXcxx . . $ `Descent3/procedurals.cpp:65:9`!(ix, iy) * 2];
124 return g[0] * fx + g[1] * fy;
125 }
126 float GradNoisecxx . . $ GradNoise(d59a45cd3bfd2eda).(float x, float y) {
127 int ix, iy;
128 float fx0, fx1, fy0, fy1;
129 float wx, wy;
130 float vx0, vx1, vy0, vy1;
131 ix = (int)floorcxx . . $ floor(fbcf3211dfe1bfd1).(x);
132 fx0 = x - ix;
133 fx1 = fx0 - 1;
134 wx = SMOOTHSTEPcxx . . $ `Descent3/procedurals.cpp:68:9`!(fx0);
135 iy = (int)floorcxx . . $ floor(fbcf3211dfe1bfd1).(y);
136 fy0 = y - iy;
137 fy1 = fy0 - 1;
138 wy = SMOOTHSTEPcxx . . $ `Descent3/procedurals.cpp:68:9`!(fy0);
139 vx0 = GradLatticecxx . . $ GradLattice(d287910fd745093b).(ix, iy, fx0, fy0);
140 vx1 = GradLatticecxx . . $ GradLattice(d287910fd745093b).(ix + 1, iy, fx1, fy0);
141 vy0 = LERPcxx . . $ `Descent3/procedurals.cpp:67:9`!(wx, vx0, vx1);
142 vx0 = GradLatticecxx . . $ GradLattice(d287910fd745093b).(ix, iy + 1, fx0, fy1);
143 vx1 = GradLatticecxx . . $ GradLattice(d287910fd745093b).(ix + 1, iy + 1, fx1, fy1);
144 vy1 = LERPcxx . . $ `Descent3/procedurals.cpp:67:9`!(wx, vx0, vx1);
145
146 return LERPcxx . . $ `Descent3/procedurals.cpp:67:9`!(wy, vy0, vy1);
147 }
148 extern uint8_tcxx . . $ uint8_t# EasterEggcxx . . $ EasterEgg.;
149 int Easter_egg_handlecxx . . $ Easter_egg_handle. = -1;
150 // Goes through our array and clears the slots out
151 void InitProceduralscxx . . $ InitProcedurals(49f6e7a06ebc5aa8).() {
152 int t;
153 int i;
154
155 // Load easter egg bitmap
156 Easter_egg_handlecxx . . $ Easter_egg_handle. = bm_AllocLoadFileBitmapcxx . . $ bm_AllocLoadFileBitmap(1163be050dbfff7).("FreakyEye.ogf", 0);
157 if (Easter_egg_handlecxx . . $ Easter_egg_handle. == -1) {
158 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Failed to load easter egg!\n");
159 }
160 for (i = 0; i < MAX_PROC_ELEMENTScxx . . $ `Descent3/procedurals.h:26:9`!; i++) {
161 DynamicProcElementscxx . . $ DynamicProcElements.[i].typecxx . . $ dynamic_proc_element#type. = PROC_NONEcxx . . $ `Descent3/procedurals.h:29:9`!;
162 Proc_free_listcxx . . $ Proc_free_list.[i] = i;
163 }
164
165 Num_proc_elementscxx . . $ Num_proc_elements. = 0;
166
167 // Init our fade table
168 for (i = 0; i < 32768; i++) {
169 int r = (i >> 10) & 0x1f;
170 int g = (i >> 5) & 0x1f;
171 int b = (i) & 0x1f;
172 r = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(0, r - 1);
173 g = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(0, g - 1);
174 b = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(0, b - 1);
175 ProcFadeTablecxx . . $ ProcFadeTable.[i] = OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`! | (r << 10) | (g << 5) | b;
176 }
177 // Init our palette
178 for (i = 0; i < 128; i++) {
179 float fr = (float)i / 127.0;
180 int ib = fr * 31.0;
181 int ig = fr * 16.0;
182 DefaultProcPalettecxx . . $ DefaultProcPalette.[i] = OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`! | (ig << 5) | (ib);
183 }
184 // Do lower part of table
185 for (i = 0; i < (NUM_WATER_SHADEScxx . . $ `Descent3/procedurals.cpp:76:9`!); i++) {
186 float norm = ((float)i / (float)(NUM_WATER_SHADEScxx . . $ `Descent3/procedurals.cpp:76:9`! - 1));
187 float lo_norm = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).((norm / .5) * 1.0, 1.0);
188 float hi_norm = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(((norm - .5) / .5) * 1.0, 0.0);
189
190 for (int rcount = 0; rcount < 32; rcount++) {
191 for (int gcount = 0; gcount < 4; gcount++) {
192 int r = rcount;
193
194 int index = (rcount * 4) + gcount;
195
196 float fr = r;
197
198 r = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(fr * lo_norm + (31.0 * hi_norm), 31.0);
199
200 WaterProcTableHicxx . . $ WaterProcTableHi.[i][index] = OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`! | (r << 10);
201 }
202 }
203 for (int bcount = 0; bcount < 32; bcount++) {
204 for (int gcount = 0; gcount < 8; gcount++) {
205 int b = bcount;
206 int index = gcount * 32 + bcount;
207
208 float fb = b;
209 b = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(fb * lo_norm + (31.0 * hi_norm), 31.0);
210
211 WaterProcTableLocxx . . $ WaterProcTableLo.[i][index] = b;
212 }
213 }
214
215 int gcount;
216 for (gcount = 0; gcount < 8; gcount++) {
217 float fg = gcount;
218 int g = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).((fg * lo_norm) + (7.0 * hi_norm), 7.0);
219 for (t = 0; t < 32; t++) {
220 int index = gcount * 32 + t;
221 WaterProcTableLocxx . . $ WaterProcTableLo.[i][gcount * 32 + t] |= (g << 5);
222 }
223 }
224 for (gcount = 0; gcount < 4; gcount++) {
225 float fg = gcount * 8;
226 int g = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).((fg * lo_norm) + (24.0 * hi_norm), 24.0);
227
228 for (t = 0; t < 32; t++) {
229 int index = t * 4 + gcount;
230
231 WaterProcTableHicxx . . $ WaterProcTableHi.[i][t * 4 + gcount] |= (g << 5);
232 }
233 }
234 }
235 /*for (i=0;i<NUM_WATER_SHADES;i++)
236 {
237 int r=(WaterProcTableHi[i][127]>>10) & 0x1f;
238 int g=((WaterProcTableHi[i][127]>>5) & 0x1f);
239 g+=((WaterProcTableLo[i][255]>>5) & 0x1f);
240 int b=(WaterProcTableLo[i][255]) & 0x1f;
241 mprintf(0,"index=%d r=%d g=%d b=%d\n",i,r,g,b);
242 }*/
243 // Init our default palette
244 for (i = 0; i < 128; i++) {
245 float norm = (float)i / 127.0;
246 int ir = (norm * 31.0);
247 int ig = 16 + (norm * 15.0);
248 DefaultProcPalettecxx . . $ DefaultProcPalette.[i + 128] = OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`! | (ir << 10) | (ig << 5) | (0x1f);
249 }
250 InitNoisecxx . . $ InitNoise(49f6e7a06ebc5aa8).();
251 }
252 // Returns the next free procelement
253 int ProcElementAllocatecxx . . $ ProcElementAllocate(b126dc7c1de90089).() {
254 if (Num_proc_elementscxx . . $ Num_proc_elements. == MAX_PROC_ELEMENTScxx . . $ `Descent3/procedurals.h:26:9`!) {
255 // mprintf(0,"Couldn't allocate proc element!\n");
256 return -1;
257 }
258
259 int n = Proc_free_listcxx . . $ Proc_free_list.[Num_proc_elementscxx . . $ Num_proc_elements.++];
260 ASSERTcxx . . $ `misc/pserror.h:246:9`!(DynamicProcElements[n].type == PROC_NONEcxx . . $ `Descent3/procedurals.h:29:9`!); // Get Jason
261
262 DynamicProcElementscxx . . $ DynamicProcElements.[n].nextcxx . . $ dynamic_proc_element#next. = -1;
263 DynamicProcElementscxx . . $ DynamicProcElements.[n].prevcxx . . $ dynamic_proc_element#prev. = -1;
264
265 return n;
266 }
267 // Frees up a procelement for use
268 int ProcElementFreecxx . . $ ProcElementFree(7864480464b09eea).(int index) {
269 ASSERTcxx . . $ `misc/pserror.h:246:9`!(index >= 0 && index <= MAX_PROC_ELEMENTScxx . . $ `Descent3/procedurals.h:26:9`!);
270 Proc_free_listcxx . . $ Proc_free_list.[--Num_proc_elementscxx . . $ Num_proc_elements.] = index;
271 DynamicProcElementscxx . . $ DynamicProcElements.[index].typecxx . . $ dynamic_proc_element#type. = PROC_NONEcxx . . $ `Descent3/procedurals.h:29:9`!;
272 return 1;
273 }
274 // Draws a line into the passed in bitmap
275 void DrawProceduralLinecxx . . $ DrawProceduralLine(ed3aaa55cdbc9b8b).(int x1, int y1, int x2, int y2, uint8_tcxx . . $ uint8_t# color) {
276 int DY, DX;
277 int i, x, y, yinc = 1, xinc = 1, error_term;
278
279 uint8_tcxx . . $ uint8_t# *surface_ptr = ProcDestDatacxx . . $ ProcDestData.;
280
281 int xmask = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1;
282 int ymask = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1;
283
284 // Check to see if our x coords are reversed
285 if (x1 > x2) {
286 stdcxx . . $ std/::swapcxx . . $ std/swap(c75b8fd57d7c2e06).(x1, x2);
287 stdcxx . . $ std/::swapcxx . . $ std/swap(c75b8fd57d7c2e06).(y1, y2);
288 }
289 DX = x2 - x1;
290 DY = y2 - y1;
291 if (DX < 0) {
292 xinc = -1;
293 DX = -DX;
294 }
295 if (DY < 0) {
296 yinc = -1;
297 DY = -DY;
298 }
299 if (DX >= DY) // X is greater than y
300 {
301 error_term = 0;
302 x = x1 & xmask;
303 y = y1 & ymask;
304 surface_ptr += y * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
305 for (i = 0; i < DX; i++) {
306
307 *(surface_ptr + x) = color;
308 x += xinc;
309 x &= xmask;
310 error_term += DY;
311 if (error_term >= DX) {
312 y += yinc;
313 y &= ymask;
314 surface_ptr = ProcDestDatacxx . . $ ProcDestData. + (y * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!);
315 error_term -= DX;
316 }
317 }
318 } else {
319 error_term = 0;
320 x = x1 & xmask;
321 y = y1 & ymask;
322 surface_ptr += y * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
323
324 for (i = 0; i < DY; i++) {
325 *(surface_ptr + x) = color;
326 y += yinc;
327 y &= ymask;
328 error_term += DX;
329 surface_ptr = ProcDestDatacxx . . $ ProcDestData. + (y * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!);
330 if (error_term >= DY) {
331 x += xinc;
332 x &= xmask;
333 error_term -= DY;
334 }
335 }
336 }
337 }
338 // Fades an entire bitmap one step closer to black
339 void FadeProcTexturecxx . . $ FadeProcTexture(d4f767463ce0a6b3).(int tex_handle) {
340 int total = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
341 uint8_tcxx . . $ uint8_t# *src_data = ProcDestDatacxx . . $ ProcDestData.;
342 int fadeval;
343 fadeval = 255 - GameTexturescxx . . $ GameTextures.[tex_handle].proceduralcxx . . $ texture#procedural.->heatcxx . . $ proc_struct#heat.;
344 fadeval >>= 3;
345 fadeval++;
346
347 for (int i = 0; i < total; i++, src_data++) {
348 int pix = *src_data;
349 if (pix) {
350 if (pix - fadeval <= 0)
351 *src_data = 0;
352 else
353 *src_data = pix - fadeval;
354 }
355 }
356 }
357 // Heats an entire bitmap
358 void HeatProcTexturecxx . . $ HeatProcTexture(d4f767463ce0a6b3).(int tex_handle) {
359 int total = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
360 uint8_tcxx . . $ uint8_t# *src_data = ProcDestDatacxx . . $ ProcDestData.;
361 uint8_tcxx . . $ uint8_t# val;
362 uint8_tcxx . . $ uint8_t# heat = GameTexturescxx . . $ GameTextures.[tex_handle].proceduralcxx . . $ texture#procedural.->heatcxx . . $ proc_struct#heat.;
363 val = 255 - heat;
364
365 for (int i = 0; i < total; i++, src_data++) {
366 int pix = *src_data;
367 if (pix < heat && pix >= val)
368 (*src_data)++;
369 }
370 }
371 // Fades and entire bitmap one step closer to black
372 void BlendProcTexturecxx . . $ BlendProcTexture(d4f767463ce0a6b3).(int tex_handle) {
373 int total = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
374 uint8_tcxx . . $ uint8_t# *src_data = (uint8_tcxx . . $ uint8_t# *)GameTexturescxx . . $ GameTextures.[tex_handle].proceduralcxx . . $ texture#procedural.->proc1cxx . . $ proc_struct#proc1.;
375 uint8_tcxx . . $ uint8_t# *dest_data = (uint8_tcxx . . $ uint8_t# *)GameTexturescxx . . $ GameTextures.[tex_handle].proceduralcxx . . $ texture#procedural.->proc2cxx . . $ proc_struct#proc2.;
376 uint8_tcxx . . $ uint8_t# *start_data = src_data;
377 for (int i = 0; i < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!; i++) {
378 uint8_tcxx . . $ uint8_t# *downrow;
379 uint8_tcxx . . $ uint8_t# *start_row = src_data;
380 // Get row underneath
381 if (i != PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
382 downrow = src_data + PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
383 else
384 downrow = start_data;
385 for (int t = 0; t < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!; t++, src_data++, dest_data++, downrow++) {
386 // Get center
387 total = *src_data;
388 // Get right
389 if (t != PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
390 total += *(src_data + 1);
391 else
392 total += *(start_row);
393 // Get left
394 if (t)
395 total += *(src_data - 1);
396 else
397 total += *(start_row + PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
398
399 // Get below
400 total += *(downrow);
401 total >>= 2;
402 *dest_data = total;
403 }
404 }
405 }
406 // Draws lightning into a bitmap
407 void AddProcLightningcxx . . $ AddProcLightning(c7d96eab35da25ae).(int x1, int y1, int x2, int y2, uint8_tcxx . . $ uint8_t# color, static_proc_elementcxx . . $ static_proc_element# *proc) {
408 float dx = x2 - x1;
409 float dy = y2 - y1;
410
411 float mag = sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).((dx * dx) + (dy * dy));
412 if (mag < 1)
413 return;
414 int num_segments = mag / 8;
415 dx /= mag;
416 dy /= mag;
417 float cur_x = x1;
418 float cur_y = y1;
419 float rot_x = dy;
420 float rot_y = dx;
421 float from_x = cur_x;
422 float from_y = cur_y;
423 for (int i = 0; i < num_segments; i++, cur_x += (dx * 8), cur_y += (dy * 8)) {
424 float to_x = cur_x + (dx * 8);
425 float to_y = cur_y + (dy * 8);
426 if (i != num_segments - 1) {
427 to_x += (rot_x) * ((1 + proc->speedcxx . . $ static_proc_element#speed.) * (((prandcxx . . $ prand(b126dc7c1de90089).() % 200) - 100.0) / 18.0));
428 to_y += (rot_y) * ((1 + proc->speedcxx . . $ static_proc_element#speed.) * (((prandcxx . . $ prand(b126dc7c1de90089).() % 200) - 100.0) / 18.0));
429 }
430
431 DrawProceduralLinecxx . . $ DrawProceduralLine(ed3aaa55cdbc9b8b).(from_x, from_y, to_x, to_y, color);
432
433 from_x = to_x;
434 from_y = to_y;
435 }
436 }
437 // link the procedural into the list for its texture
438 void ProcElementLinkcxx . . $ ProcElementLink(3e454b8ccf442868).(int index, int texnum) {
439 dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc = &DynamicProcElementscxx . . $ DynamicProcElements.[index];
440 proc->nextcxx . . $ dynamic_proc_element#next. = GameTexturescxx . . $ GameTextures.[texnum].proceduralcxx . . $ texture#procedural.->dynamic_proc_elementscxx . . $ proc_struct#dynamic_proc_elements.;
441 GameTexturescxx . . $ GameTextures.[texnum].proceduralcxx . . $ texture#procedural.->dynamic_proc_elementscxx . . $ proc_struct#dynamic_proc_elements. = index;
442 ASSERTcxx . . $ `misc/pserror.h:246:9`!(proc->next != index);
443
444 proc->prevcxx . . $ dynamic_proc_element#prev. = -1;
445 if (proc->nextcxx . . $ dynamic_proc_element#next. != -1)
446 DynamicProcElementscxx . . $ DynamicProcElements.[proc->nextcxx . . $ dynamic_proc_element#next.].prevcxx . . $ dynamic_proc_element#prev. = index;
447 }
448 // Unlinks a proc_element from a texture
449 void ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(int index, int texnum) {
450 dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc = &DynamicProcElementscxx . . $ DynamicProcElements.[index];
451
452 ASSERTcxx . . $ `misc/pserror.h:246:9`!(index != -1);
453 if (proc->prevcxx . . $ dynamic_proc_element#prev. == -1)
454 GameTexturescxx . . $ GameTextures.[texnum].proceduralcxx . . $ texture#procedural.->dynamic_proc_elementscxx . . $ proc_struct#dynamic_proc_elements. = proc->nextcxx . . $ dynamic_proc_element#next.;
455 else
456 DynamicProcElementscxx . . $ DynamicProcElements.[proc->prevcxx . . $ dynamic_proc_element#prev.].nextcxx . . $ dynamic_proc_element#next. = proc->nextcxx . . $ dynamic_proc_element#next.;
457 if (proc->nextcxx . . $ dynamic_proc_element#next. != -1)
458 DynamicProcElementscxx . . $ DynamicProcElements.[proc->nextcxx . . $ dynamic_proc_element#next.].prevcxx . . $ dynamic_proc_element#prev. = proc->prevcxx . . $ dynamic_proc_element#prev.;
459 ProcElementFreecxx . . $ ProcElementFree(7864480464b09eea).(index);
460 }
461 // Clears all the procedurals elements attached to this texture
462 void ClearAllProceduralsFromTexturecxx . . $ ClearAllProceduralsFromTexture(d4f767463ce0a6b3).(int texnum) {
463 int proc_num = GameTexturescxx . . $ GameTextures.[texnum].proceduralcxx . . $ texture#procedural.->dynamic_proc_elementscxx . . $ proc_struct#dynamic_proc_elements.;
464
465 while (proc_num != -1) {
466 int temp = DynamicProcElementscxx . . $ DynamicProcElements.[proc_num].nextcxx . . $ dynamic_proc_element#next.;
467 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc_num, texnum);
468 proc_num = temp;
469 }
470 GameTexturescxx . . $ GameTextures.[texnum].proceduralcxx . . $ texture#procedural.->num_static_elementscxx . . $ proc_struct#num_static_elements. = 0;
471 }
472 // Adds one point to a bitmap
473 void AddProcPointcxx . . $ AddProcPoint(a4317ac70dc71690).(int x, int y, uint8_tcxx . . $ uint8_t# color) {
474 x &= (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
475 y &= (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
476
477 int index = y * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + x;
478 ProcDestDatacxx . . $ ProcDestData.[index] = color;
479 }
480 // Adds one point to a bitmap
481 static inline void PlaceProcPointcxx . . $ PlaceProcPoint(a4317ac70dc71690).(int x, int y, uint8_tcxx . . $ uint8_t# color) {
482 x &= (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
483 y &= (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
484 ProcDestDatacxx . . $ ProcDestData.[y * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + x] = color;
485 }
486 // Adds a sphere lightning bolt
487 void AddProcSphereLightningcxx . . $ AddProcSphereLightning(35100e16194d3d84).(int handle, static_proc_elementcxx . . $ static_proc_element# *proc) {
488 int procnum = proc - GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->static_proc_elementscxx . . $ proc_struct#static_proc_elements.;
489
490 if (Detail_settingscxx . . $ Detail_settings..Procedurals_enabledcxx . . $ tDetailSettings#Procedurals_enabled.) {
491 if (proc->frequencycxx . . $ static_proc_element#frequency. != 0 && ((FrameCountcxx . . $ FrameCount.) % proc->frequencycxx . . $ static_proc_element#frequency.) != 0)
492 return;
493 }
494 float norm = ((float)proc->sizecxx . . $ static_proc_element#size. / 255.0);
495 int len = norm * (float)PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
496 len /= 2;
497 int dir = prandcxx . . $ prand(b126dc7c1de90089).() * 2;
498 int dest_x = proc->x1cxx . . $ static_proc_element#x1. + (FixCoscxx . . $ FixCos(9a38df040a81ca35).(dir) * (float)len);
499 int dest_y = proc->y1cxx . . $ static_proc_element#y1. + (FixSincxx . . $ FixSin(9a38df040a81ca35).(dir) * (float)len);
500 AddProcLightningcxx . . $ AddProcLightning(c7d96eab35da25ae).(proc->x1cxx . . $ static_proc_element#x1., proc->y1cxx . . $ static_proc_element#y1., dest_x, dest_y, BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`!, proc);
501 }
502 void AddProcRisingEmbercxx . . $ AddProcRisingEmber(35100e16194d3d84).(int handle, static_proc_elementcxx . . $ static_proc_element# *proc) {
503 if (proc->frequencycxx . . $ static_proc_element#frequency. == 0 || (FrameCountcxx . . $ FrameCount. % proc->frequencycxx . . $ static_proc_element#frequency.) == 0) {
504 // Add a new fizzle
505 int num = prandcxx . . $ prand(b126dc7c1de90089).() % 7;
506 for (int i = 0; i < num; i++) {
507 int index = ProcElementAllocatecxx . . $ ProcElementAllocate(b126dc7c1de90089).();
508 if (index > -1) {
509 ProcElementLinkcxx . . $ ProcElementLink(3e454b8ccf442868).(index, handle);
510 DynamicProcElementscxx . . $ DynamicProcElements.[index].typecxx . . $ dynamic_proc_element#type. = proc->typecxx . . $ static_proc_element#type.;
511
512 DynamicProcElementscxx . . $ DynamicProcElements.[index].x1cxx . . $ dynamic_proc_element#x1. = IntToFixcxx . . $ `fix/fix.h:105:9`!((int)proc->x1);
513 DynamicProcElementscxx . . $ DynamicProcElements.[index].y1cxx . . $ dynamic_proc_element#y1. = IntToFixcxx . . $ `fix/fix.h:105:9`!((int)proc->y1);
514 DynamicProcElementscxx . . $ DynamicProcElements.[index].colorcxx . . $ dynamic_proc_element#color. = BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`!;
515 DynamicProcElementscxx . . $ DynamicProcElements.[index].speedcxx . . $ dynamic_proc_element#speed. = proc->speedcxx . . $ static_proc_element#speed.;
516 DynamicProcElementscxx . . $ DynamicProcElements.[index].frames_leftcxx . . $ dynamic_proc_element#frames_left. = (prandcxx . . $ prand(b126dc7c1de90089).() % 10) + 15;
517 }
518 }
519 }
520 }
521 void DoDynamicRisingEmbercxx . . $ DoDynamicRisingEmber(f88332d939b43e7d).(int handle, dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc) {
522 PlaceProcPointcxx . . $ PlaceProcPoint(a4317ac70dc71690).(FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->x1), FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->y1), proc->colorcxx . . $ dynamic_proc_element#color.);
523 proc->frames_leftcxx . . $ dynamic_proc_element#frames_left.--;
524 if (proc->frames_leftcxx . . $ dynamic_proc_element#frames_left. < 1)
525 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
526 else {
527 proc->colorcxx . . $ dynamic_proc_element#color.--;
528 if (proc->colorcxx . . $ dynamic_proc_element#color. == 0)
529 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
530 else {
531 int speed_adjust = 1 + ((proc->speedcxx . . $ dynamic_proc_element#speed. / 255.0) * 2.0);
532 proc->dxcxx . . $ dynamic_proc_element#dx. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(((prand() % 3) - 1) * speed_adjust);
533 proc->dycxx . . $ dynamic_proc_element#dy. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(((prand() % 3) - 2) * speed_adjust);
534 proc->x1cxx . . $ dynamic_proc_element#x1. += proc->dxcxx . . $ dynamic_proc_element#dx.;
535 proc->y1cxx . . $ dynamic_proc_element#y1. += proc->dycxx . . $ dynamic_proc_element#dy.;
536 }
537 }
538 }
539 void AddProcSpinnerscxx . . $ AddProcSpinners(35100e16194d3d84).(int handle, static_proc_elementcxx . . $ static_proc_element# *proc) {
540 if (proc->frequencycxx . . $ static_proc_element#frequency. == 0 || (FrameCountcxx . . $ FrameCount. % proc->frequencycxx . . $ static_proc_element#frequency.) == 0) {
541
542 int proc_num = (proc - GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->static_proc_elementscxx . . $ proc_struct#static_proc_elements.) * 60;
543 int speed_adjust = 1 + ((proc->speedcxx . . $ static_proc_element#speed. / 255.0) * 5.0);
544 int cur_angle = (((FrameCountcxx . . $ FrameCount. + proc_num) * speed_adjust) % 64) * 1024;
545
546 int index = ProcElementAllocatecxx . . $ ProcElementAllocate(b126dc7c1de90089).();
547 if (index > -1) {
548 ProcElementLinkcxx . . $ ProcElementLink(3e454b8ccf442868).(index, handle);
549 DynamicProcElementscxx . . $ DynamicProcElements.[index].typecxx . . $ dynamic_proc_element#type. = proc->typecxx . . $ static_proc_element#type.;
550
551 DynamicProcElementscxx . . $ DynamicProcElements.[index].dxcxx . . $ dynamic_proc_element#dx. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(FixCos(cur_angle));
552 DynamicProcElementscxx . . $ DynamicProcElements.[index].dycxx . . $ dynamic_proc_element#dy. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(FixSin(cur_angle));
553 DynamicProcElementscxx . . $ DynamicProcElements.[index].x1cxx . . $ dynamic_proc_element#x1. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(proc->x1 + (DynamicProcElements[index].dx * FloatToFixcxx . . $ `fix/fix.h:104:9`!(proc->size)));
554 DynamicProcElementscxx . . $ DynamicProcElements.[index].y1cxx . . $ dynamic_proc_element#y1. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(proc->y1 + (DynamicProcElements[index].dy * FloatToFixcxx . . $ `fix/fix.h:104:9`!(proc->size)));
555 DynamicProcElementscxx . . $ DynamicProcElements.[index].colorcxx . . $ dynamic_proc_element#color. = BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`!;
556 DynamicProcElementscxx . . $ DynamicProcElements.[index].speedcxx . . $ dynamic_proc_element#speed. = proc->speedcxx . . $ static_proc_element#speed.;
557 DynamicProcElementscxx . . $ DynamicProcElements.[index].frames_leftcxx . . $ dynamic_proc_element#frames_left. = (prandcxx . . $ prand(b126dc7c1de90089).() % 10) + 15;
558 }
559 }
560 }
561 void DoDynamicSpinnerscxx . . $ DoDynamicSpinners(f88332d939b43e7d).(int handle, dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc) {
562 PlaceProcPointcxx . . $ PlaceProcPoint(a4317ac70dc71690).(FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->x1), FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->y1), proc->colorcxx . . $ dynamic_proc_element#color.);
563 proc->frames_leftcxx . . $ dynamic_proc_element#frames_left.--;
564 if (proc->frames_leftcxx . . $ dynamic_proc_element#frames_left. < 1)
565 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
566 else {
567 proc->colorcxx . . $ dynamic_proc_element#color.--;
568 if (proc->colorcxx . . $ dynamic_proc_element#color. == 0)
569 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
570 else {
571 proc->x1cxx . . $ dynamic_proc_element#x1. += proc->dxcxx . . $ dynamic_proc_element#dx.;
572 proc->y1cxx . . $ dynamic_proc_element#y1. += proc->dycxx . . $ dynamic_proc_element#dy.;
573 }
574 }
575 }
576 void AddProcRandomEmbercxx . . $ AddProcRandomEmber(35100e16194d3d84).(int handle, static_proc_elementcxx . . $ static_proc_element# *proc) {
577 if (proc->frequencycxx . . $ static_proc_element#frequency. == 0 || (FrameCountcxx . . $ FrameCount. % proc->frequencycxx . . $ static_proc_element#frequency.) == 0) {
578 // Add a new fizzle
579 int num = (prandcxx . . $ prand(b126dc7c1de90089).() % 4) + 1;
580 for (int i = 0; i < num; i++) {
581 int index = ProcElementAllocatecxx . . $ ProcElementAllocate(b126dc7c1de90089).();
582 if (index > -1) {
583 ProcElementLinkcxx . . $ ProcElementLink(3e454b8ccf442868).(index, handle);
584 DynamicProcElementscxx . . $ DynamicProcElements.[index].typecxx . . $ dynamic_proc_element#type. = proc->typecxx . . $ static_proc_element#type.;
585
586 DynamicProcElementscxx . . $ DynamicProcElements.[index].x1cxx . . $ dynamic_proc_element#x1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->x1);
587 DynamicProcElementscxx . . $ DynamicProcElements.[index].y1cxx . . $ dynamic_proc_element#y1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->y1);
588 DynamicProcElementscxx . . $ DynamicProcElements.[index].colorcxx . . $ dynamic_proc_element#color. = BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`!;
589 DynamicProcElementscxx . . $ DynamicProcElements.[index].speedcxx . . $ dynamic_proc_element#speed. = proc->speedcxx . . $ static_proc_element#speed.;
590 DynamicProcElementscxx . . $ DynamicProcElements.[index].frames_leftcxx . . $ dynamic_proc_element#frames_left. = (prandcxx . . $ prand(b126dc7c1de90089).() % 10) + 15;
591 }
592 }
593 }
594 }
595 void DoDynamicRandomEmbercxx . . $ DoDynamicRandomEmber(f88332d939b43e7d).(int handle, dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc) {
596 PlaceProcPointcxx . . $ PlaceProcPoint(a4317ac70dc71690).(FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->x1), FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->y1), proc->colorcxx . . $ dynamic_proc_element#color.);
597 proc->frames_leftcxx . . $ dynamic_proc_element#frames_left.--;
598 if (proc->frames_leftcxx . . $ dynamic_proc_element#frames_left. < 1)
599 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
600 else {
601 proc->colorcxx . . $ dynamic_proc_element#color.--;
602 if (proc->colorcxx . . $ dynamic_proc_element#color. == 0)
603 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
604 else {
605 int speed_adjust = 1 + ((proc->speedcxx . . $ dynamic_proc_element#speed. / 255.0) * 2.0);
606 proc->dxcxx . . $ dynamic_proc_element#dx. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(((prand() % 3) - 1) * speed_adjust);
607 proc->dycxx . . $ dynamic_proc_element#dy. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(((prand() % 3) - 1) * speed_adjust);
608 proc->x1cxx . . $ dynamic_proc_element#x1. += proc->dxcxx . . $ dynamic_proc_element#dx.;
609 proc->y1cxx . . $ dynamic_proc_element#y1. += proc->dycxx . . $ dynamic_proc_element#dy.;
610 }
611 }
612 }
613 void AddProcRoamerscxx . . $ AddProcRoamers(35100e16194d3d84).(int handle, static_proc_elementcxx . . $ static_proc_element# *proc) {
614 proc->x1cxx . . $ static_proc_element#x1. += (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 5) - 2;
615 proc->y1cxx . . $ static_proc_element#y1. += (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 5) - 2;
616 if (proc->frequencycxx . . $ static_proc_element#frequency. == 0 || (FrameCountcxx . . $ FrameCount. % proc->frequencycxx . . $ static_proc_element#frequency.) == 0) {
617 // Add a new fizzle
618 int num = (prandcxx . . $ prand(b126dc7c1de90089).() % 4) + 1;
619 for (int i = 0; i < num; i++) {
620 int index = ProcElementAllocatecxx . . $ ProcElementAllocate(b126dc7c1de90089).();
621 if (index > -1) {
622 ProcElementLinkcxx . . $ ProcElementLink(3e454b8ccf442868).(index, handle);
623 DynamicProcElementscxx . . $ DynamicProcElements.[index].typecxx . . $ dynamic_proc_element#type. = proc->typecxx . . $ static_proc_element#type.;
624
625 DynamicProcElementscxx . . $ DynamicProcElements.[index].x1cxx . . $ dynamic_proc_element#x1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->x1);
626 DynamicProcElementscxx . . $ DynamicProcElements.[index].y1cxx . . $ dynamic_proc_element#y1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->y1);
627 DynamicProcElementscxx . . $ DynamicProcElements.[index].colorcxx . . $ dynamic_proc_element#color. = BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`!;
628 DynamicProcElementscxx . . $ DynamicProcElements.[index].speedcxx . . $ dynamic_proc_element#speed. = proc->speedcxx . . $ static_proc_element#speed.;
629 DynamicProcElementscxx . . $ DynamicProcElements.[index].frames_leftcxx . . $ dynamic_proc_element#frames_left. = (prandcxx . . $ prand(b126dc7c1de90089).() % 10) + 15;
630 }
631 }
632 }
633 }
634 void DoDynamicRoamerscxx . . $ DoDynamicRoamers(f88332d939b43e7d).(int handle, dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc) {
635 PlaceProcPointcxx . . $ PlaceProcPoint(a4317ac70dc71690).(FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->x1), FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->y1), proc->colorcxx . . $ dynamic_proc_element#color.);
636 proc->frames_leftcxx . . $ dynamic_proc_element#frames_left.--;
637 if (proc->frames_leftcxx . . $ dynamic_proc_element#frames_left. < 1)
638 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
639 else {
640 proc->colorcxx . . $ dynamic_proc_element#color.--;
641 if (proc->colorcxx . . $ dynamic_proc_element#color. == 0)
642 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
643 else {
644 int speed_adjust = 1 + ((proc->speedcxx . . $ dynamic_proc_element#speed. / 255.0) * 2.0);
645 proc->dxcxx . . $ dynamic_proc_element#dx. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(((prand() % 3) - 1) * speed_adjust);
646 proc->dycxx . . $ dynamic_proc_element#dy. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(((prand() % 3) - 1) * speed_adjust);
647 proc->x1cxx . . $ dynamic_proc_element#x1. += proc->dxcxx . . $ dynamic_proc_element#dx.;
648 proc->y1cxx . . $ dynamic_proc_element#y1. += proc->dycxx . . $ dynamic_proc_element#dy.;
649 }
650 }
651 }
652 void AddProcFountaincxx . . $ AddProcFountain(35100e16194d3d84).(int handle, static_proc_elementcxx . . $ static_proc_element# *proc) {
653 if (proc->frequencycxx . . $ static_proc_element#frequency. == 0 || (FrameCountcxx . . $ FrameCount. % proc->frequencycxx . . $ static_proc_element#frequency.) == 0) {
654 // Add a new fizzle
655 int num = (prandcxx . . $ prand(b126dc7c1de90089).() % 4) + 1;
656 for (int i = 0; i < num; i++) {
657 int index = ProcElementAllocatecxx . . $ ProcElementAllocate(b126dc7c1de90089).();
658 if (index > -1) {
659 ProcElementLinkcxx . . $ ProcElementLink(3e454b8ccf442868).(index, handle);
660 DynamicProcElementscxx . . $ DynamicProcElements.[index].typecxx . . $ dynamic_proc_element#type. = proc->typecxx . . $ static_proc_element#type.;
661
662 DynamicProcElementscxx . . $ DynamicProcElements.[index].x1cxx . . $ dynamic_proc_element#x1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->x1);
663 DynamicProcElementscxx . . $ DynamicProcElements.[index].y1cxx . . $ dynamic_proc_element#y1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->y1);
664 DynamicProcElementscxx . . $ DynamicProcElements.[index].colorcxx . . $ dynamic_proc_element#color. = BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`!;
665 DynamicProcElementscxx . . $ DynamicProcElements.[index].speedcxx . . $ dynamic_proc_element#speed. = proc->speedcxx . . $ static_proc_element#speed.;
666 DynamicProcElementscxx . . $ DynamicProcElements.[index].dxcxx . . $ dynamic_proc_element#dx. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(((prand() % 100) - 50) / 200.0);
667 if ((prandcxx . . $ prand(b126dc7c1de90089).() % 10) == 0) {
668 DynamicProcElementscxx . . $ DynamicProcElements.[index].dycxx . . $ dynamic_proc_element#dy. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(-((prand() % 100) / 300.0));
669 DynamicProcElementscxx . . $ DynamicProcElements.[index].frames_leftcxx . . $ dynamic_proc_element#frames_left. = (prandcxx . . $ prand(b126dc7c1de90089).() % 6) + 3;
670 } else {
671 DynamicProcElementscxx . . $ DynamicProcElements.[index].dycxx . . $ dynamic_proc_element#dy. = FloatToFixcxx . . $ `fix/fix.h:104:9`!((prand() % 100) / 50.0);
672 DynamicProcElementscxx . . $ DynamicProcElements.[index].frames_leftcxx . . $ dynamic_proc_element#frames_left. = (prandcxx . . $ prand(b126dc7c1de90089).() % 10) + 15;
673 }
674 }
675 }
676 }
677 }
678 void DoDynamicFountaincxx . . $ DoDynamicFountain(f88332d939b43e7d).(int handle, dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc) {
679 PlaceProcPointcxx . . $ PlaceProcPoint(a4317ac70dc71690).(FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->x1), FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->y1), proc->colorcxx . . $ dynamic_proc_element#color.);
680 proc->frames_leftcxx . . $ dynamic_proc_element#frames_left.--;
681 if (proc->frames_leftcxx . . $ dynamic_proc_element#frames_left. < 1)
682 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
683 else {
684 proc->colorcxx . . $ dynamic_proc_element#color.--;
685 if (proc->colorcxx . . $ dynamic_proc_element#color. == 0)
686 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
687 else {
688 proc->x1cxx . . $ dynamic_proc_element#x1. += proc->dxcxx . . $ dynamic_proc_element#dx.;
689 proc->y1cxx . . $ dynamic_proc_element#y1. += proc->dycxx . . $ dynamic_proc_element#dy.;
690 }
691 }
692 }
693 void AddProcConecxx . . $ AddProcCone(35100e16194d3d84).(int handle, static_proc_elementcxx . . $ static_proc_element# *proc) {
694 if (proc->frequencycxx . . $ static_proc_element#frequency. == 0 || (FrameCountcxx . . $ FrameCount. % proc->frequencycxx . . $ static_proc_element#frequency.) == 0) {
695 // Add a new fizzle
696 int num = (prandcxx . . $ prand(b126dc7c1de90089).() % 4) + 1;
697 for (int i = 0; i < num; i++) {
698 int index = ProcElementAllocatecxx . . $ ProcElementAllocate(b126dc7c1de90089).();
699 if (index > -1) {
700 ProcElementLinkcxx . . $ ProcElementLink(3e454b8ccf442868).(index, handle);
701 DynamicProcElementscxx . . $ DynamicProcElements.[index].typecxx . . $ dynamic_proc_element#type. = proc->typecxx . . $ static_proc_element#type.;
702
703 DynamicProcElementscxx . . $ DynamicProcElements.[index].x1cxx . . $ dynamic_proc_element#x1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->x1);
704 DynamicProcElementscxx . . $ DynamicProcElements.[index].y1cxx . . $ dynamic_proc_element#y1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->y1);
705
706 DynamicProcElementscxx . . $ DynamicProcElements.[index].colorcxx . . $ dynamic_proc_element#color. = BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`!;
707 DynamicProcElementscxx . . $ DynamicProcElements.[index].speedcxx . . $ dynamic_proc_element#speed. = proc->speedcxx . . $ static_proc_element#speed.;
708 DynamicProcElementscxx . . $ DynamicProcElements.[index].dxcxx . . $ dynamic_proc_element#dx. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(((prand() % 100) - 50) / 80.0);
709 if ((prandcxx . . $ prand(b126dc7c1de90089).() % 10) == 0) {
710 DynamicProcElementscxx . . $ DynamicProcElements.[index].dycxx . . $ dynamic_proc_element#dy. = FloatToFixcxx . . $ `fix/fix.h:104:9`!(-((prand() % 100) / 300.0));
711 DynamicProcElementscxx . . $ DynamicProcElements.[index].frames_leftcxx . . $ dynamic_proc_element#frames_left. = (prandcxx . . $ prand(b126dc7c1de90089).() % 6) + 3;
712 } else {
713 DynamicProcElementscxx . . $ DynamicProcElements.[index].dycxx . . $ dynamic_proc_element#dy. = IntToFixcxx . . $ `fix/fix.h:105:9`!(1);
714 DynamicProcElementscxx . . $ DynamicProcElements.[index].frames_leftcxx . . $ dynamic_proc_element#frames_left. = (prandcxx . . $ prand(b126dc7c1de90089).() % 10) + 15;
715 }
716 }
717 }
718 }
719 }
720 void DoDynamicConecxx . . $ DoDynamicCone(f88332d939b43e7d).(int handle, dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc) {
721 PlaceProcPointcxx . . $ PlaceProcPoint(a4317ac70dc71690).(FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->x1), FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->y1), proc->colorcxx . . $ dynamic_proc_element#color.);
722 proc->frames_leftcxx . . $ dynamic_proc_element#frames_left.--;
723 if (proc->frames_leftcxx . . $ dynamic_proc_element#frames_left. < 1)
724 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
725 else {
726 proc->colorcxx . . $ dynamic_proc_element#color.--;
727 if (proc->colorcxx . . $ dynamic_proc_element#color. == 0)
728 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
729 else {
730 proc->x1cxx . . $ dynamic_proc_element#x1. += proc->dxcxx . . $ dynamic_proc_element#dx.;
731 proc->y1cxx . . $ dynamic_proc_element#y1. += proc->dycxx . . $ dynamic_proc_element#dy.;
732 }
733 }
734 }
735 void AddProcFallRightcxx . . $ AddProcFallRight(35100e16194d3d84).(int handle, static_proc_elementcxx . . $ static_proc_element# *proc) {
736 if (proc->frequencycxx . . $ static_proc_element#frequency. == 0 || (FrameCountcxx . . $ FrameCount. % proc->frequencycxx . . $ static_proc_element#frequency.) == 0) {
737 // Add a new fizzle
738 int num = (prandcxx . . $ prand(b126dc7c1de90089).() % 2) + 1;
739 for (int i = 0; i < num; i++) {
740 int index = ProcElementAllocatecxx . . $ ProcElementAllocate(b126dc7c1de90089).();
741 if (index > -1) {
742 ProcElementLinkcxx . . $ ProcElementLink(3e454b8ccf442868).(index, handle);
743 DynamicProcElementscxx . . $ DynamicProcElements.[index].typecxx . . $ dynamic_proc_element#type. = proc->typecxx . . $ static_proc_element#type.;
744
745 DynamicProcElementscxx . . $ DynamicProcElements.[index].x1cxx . . $ dynamic_proc_element#x1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->x1 + ((ps_rand() % 5) - 2));
746 DynamicProcElementscxx . . $ DynamicProcElements.[index].y1cxx . . $ dynamic_proc_element#y1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->y1 + ((ps_rand() % 5) - 2));
747 DynamicProcElementscxx . . $ DynamicProcElements.[index].colorcxx . . $ dynamic_proc_element#color. = BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`!;
748 DynamicProcElementscxx . . $ DynamicProcElements.[index].dxcxx . . $ dynamic_proc_element#dx. = IntToFixcxx . . $ `fix/fix.h:105:9`!(1);
749 DynamicProcElementscxx . . $ DynamicProcElements.[index].dycxx . . $ dynamic_proc_element#dy. = FloatToFixcxx . . $ `fix/fix.h:104:9`!((-(prand() % 100)) / 300.0);
750 DynamicProcElementscxx . . $ DynamicProcElements.[index].frames_leftcxx . . $ dynamic_proc_element#frames_left. = (prandcxx . . $ prand(b126dc7c1de90089).() % 15) + 25;
751 }
752 }
753 }
754 }
755 void DoDynamicFallRightcxx . . $ DoDynamicFallRight(f88332d939b43e7d).(int handle, dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc) {
756 PlaceProcPointcxx . . $ PlaceProcPoint(a4317ac70dc71690).(FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->x1), FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->y1), proc->colorcxx . . $ dynamic_proc_element#color.);
757 proc->frames_leftcxx . . $ dynamic_proc_element#frames_left.--;
758 if (proc->frames_leftcxx . . $ dynamic_proc_element#frames_left. < 1)
759 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
760 else {
761 proc->colorcxx . . $ dynamic_proc_element#color.--;
762 if (proc->colorcxx . . $ dynamic_proc_element#color. == 0)
763 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
764 else {
765 if (FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->dx) > 0)
766 proc->dxcxx . . $ dynamic_proc_element#dx. -= FloatToFixcxx . . $ `fix/fix.h:104:9`!(((ps_rand() % 100) / 2000.0));
767 if (FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->dy) < 2)
768 proc->dycxx . . $ dynamic_proc_element#dy. += FloatToFixcxx . . $ `fix/fix.h:104:9`!(((ps_rand() % 100) / 1000.0));
769 proc->x1cxx . . $ dynamic_proc_element#x1. += proc->dxcxx . . $ dynamic_proc_element#dx.;
770 proc->y1cxx . . $ dynamic_proc_element#y1. += proc->dycxx . . $ dynamic_proc_element#dy.;
771 }
772 }
773 }
774 void AddProcFallLeftcxx . . $ AddProcFallLeft(35100e16194d3d84).(int handle, static_proc_elementcxx . . $ static_proc_element# *proc) {
775 if (proc->frequencycxx . . $ static_proc_element#frequency. == 0 || (FrameCountcxx . . $ FrameCount. % proc->frequencycxx . . $ static_proc_element#frequency.) == 0) {
776 // Add a new fizzle
777 int num = (prandcxx . . $ prand(b126dc7c1de90089).() % 2) + 1;
778 for (int i = 0; i < num; i++) {
779 int index = ProcElementAllocatecxx . . $ ProcElementAllocate(b126dc7c1de90089).();
780 if (index > -1) {
781 ProcElementLinkcxx . . $ ProcElementLink(3e454b8ccf442868).(index, handle);
782 DynamicProcElementscxx . . $ DynamicProcElements.[index].typecxx . . $ dynamic_proc_element#type. = proc->typecxx . . $ static_proc_element#type.;
783
784 DynamicProcElementscxx . . $ DynamicProcElements.[index].x1cxx . . $ dynamic_proc_element#x1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->x1 + ((ps_rand() % 5) - 2));
785 DynamicProcElementscxx . . $ DynamicProcElements.[index].y1cxx . . $ dynamic_proc_element#y1. = IntToFixcxx . . $ `fix/fix.h:105:9`!(proc->y1 + ((ps_rand() % 5) - 2));
786 DynamicProcElementscxx . . $ DynamicProcElements.[index].colorcxx . . $ dynamic_proc_element#color. = BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`!;
787 DynamicProcElementscxx . . $ DynamicProcElements.[index].dxcxx . . $ dynamic_proc_element#dx. = IntToFixcxx . . $ `fix/fix.h:105:9`!(-1);
788 DynamicProcElementscxx . . $ DynamicProcElements.[index].dycxx . . $ dynamic_proc_element#dy. = FloatToFixcxx . . $ `fix/fix.h:104:9`!((-(prand() % 100)) / 300.0);
789 DynamicProcElementscxx . . $ DynamicProcElements.[index].frames_leftcxx . . $ dynamic_proc_element#frames_left. = (prandcxx . . $ prand(b126dc7c1de90089).() % 15) + 25;
790 }
791 }
792 }
793 }
794 void DoDynamicFallLeftcxx . . $ DoDynamicFallLeft(f88332d939b43e7d).(int handle, dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc) {
795 PlaceProcPointcxx . . $ PlaceProcPoint(a4317ac70dc71690).(FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->x1), FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->y1), proc->colorcxx . . $ dynamic_proc_element#color.);
796 proc->frames_leftcxx . . $ dynamic_proc_element#frames_left.--;
797 if (proc->frames_leftcxx . . $ dynamic_proc_element#frames_left. < 1)
798 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
799 else {
800 proc->colorcxx . . $ dynamic_proc_element#color.--;
801 if (proc->colorcxx . . $ dynamic_proc_element#color. == 0)
802 ProcElementUnlinkcxx . . $ ProcElementUnlink(3e454b8ccf442868).(proc - DynamicProcElementscxx . . $ DynamicProcElements., handle);
803 else {
804 if (FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->dx) < 0)
805 proc->dxcxx . . $ dynamic_proc_element#dx. += FloatToFixcxx . . $ `fix/fix.h:104:9`!(((ps_rand() % 100) / 2000.0));
806 if (FixToIntcxx . . $ `fix/fix.h:108:9`!(proc->dy) < 2)
807 proc->dycxx . . $ dynamic_proc_element#dy. += FloatToFixcxx . . $ `fix/fix.h:104:9`!(((ps_rand() % 100) / 1000.0));
808 proc->x1cxx . . $ dynamic_proc_element#x1. += proc->dxcxx . . $ dynamic_proc_element#dx.;
809 proc->y1cxx . . $ dynamic_proc_element#y1. += proc->dycxx . . $ dynamic_proc_element#dy.;
810 }
811 }
812 }
813 void CalcWater2cxx . . $ CalcWater2(3e454b8ccf442868).(int handle, int density) {
814 int newh;
815 int count = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + 1;
816 proc_structcxx . . $ proc_struct# *procedural = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.;
817
818 int16_t *newptr = (int16_t *)procedural->proc2cxx . . $ proc_struct#proc2.;
819 int16_t *oldptr = (int16_t *)procedural->proc1cxx . . $ proc_struct#proc1.;
820
821 int x, y;
822
823 // Do main block
824 for (y = 1; y < (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1); y++, count += 2) {
825 for (x = 1; x < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1; x++, count++) {
826 newh = ((oldptr[count + PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!] + oldptr[count - PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!] + oldptr[count + 1] + oldptr[count - 1] +
827 oldptr[count - PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1] + oldptr[count - PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + 1] + oldptr[count + PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1] +
828 oldptr[count + PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + 1]) >>
829 2) -
830 newptr[count];
831 newptr[count] = newh - (newh >> density);
832 }
833 }
834 int up, down, left, right;
835 count = 0;
836 for (y = 0; y < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!; y++) {
837 if (y == 0)
838 up = -((PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!);
839 else
840 up = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
841 if (y == PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
842 down = -((PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!);
843 else
844 down = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
845 for (x = 0; x < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!; x++, count++) {
846 if ((y != 0 && y != PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) && x != 0 && x != PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) {
847 if (x == 1) {
848 x = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 2;
849 count += (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 3);
850 }
851 continue;
852 }
853 if (x == 0)
854 left = -(PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
855 else
856 left = 1;
857
858 if (x == PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
859 right = -(PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
860 else
861 right = 1;
862 newh = oldptr[count + down];
863 newh += oldptr[count - up];
864 newh += oldptr[count + right];
865 newh += oldptr[count - left];
866 newh += oldptr[count - up - left];
867 newh += oldptr[count - up + right];
868 newh += oldptr[count + down - left];
869 newh += oldptr[count + down + right];
870 newh >>= 2;
871 newh -= newptr[count];
872 newptr[count] = newh - (newh >> density);
873 }
874 }
875 }
876 void CalcWatercxx . . $ CalcWater(3e454b8ccf442868).(int handle, int density) {
877 int newh;
878 int count = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + 1;
879 proc_structcxx . . $ proc_struct# *procedural = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.;
880
881 int16_t *newptr = (int16_t *)procedural->proc2cxx . . $ proc_struct#proc2.;
882 int16_t *oldptr = (int16_t *)procedural->proc1cxx . . $ proc_struct#proc1.;
883
884 int x, y;
885
886 // Do main block
887 for (y = 1; y < (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1); y++, count += 2) {
888 for (x = 1; x < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1; x++, count++) {
889 newh = ((oldptr[count + PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!] + oldptr[count - PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!] + oldptr[count + 1] + oldptr[count - 1]) >> 1) -
890 newptr[count];
891 newptr[count] = newh - (newh >> density);
892 }
893 }
894 int up, down, left, right;
895 count = 0;
896 for (y = 0; y < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!; y++) {
897 if (y == 0)
898 up = -((PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!);
899 else
900 up = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
901 if (y == PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
902 down = -((PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!);
903 else
904 down = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
905 for (x = 0; x < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!; x++, count++) {
906 if ((y != 0 && y != PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) && x != 0 && x != PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) {
907 if (x == 1) {
908 x = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 2;
909 count += (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 3);
910 }
911 continue;
912 }
913 if (x == 0)
914 left = -(PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
915 else
916 left = 1;
917
918 if (x == PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
919 right = -(PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
920 else
921 right = 1;
922 newh = oldptr[count + down];
923 newh += oldptr[count - up];
924 newh += oldptr[count + right];
925 newh += oldptr[count - left];
926 newh >>= 1;
927 newh -= newptr[count];
928 newptr[count] = newh - (newh >> density);
929 }
930 }
931 }
932 void DrawWaterNoLightcxx . . $ DrawWaterNoLight(d4f767463ce0a6b3).(int handle) {
933 int dx, dy;
934 int x, y;
935 int offset = 0;
936 proc_structcxx . . $ proc_struct# *procedural = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.;
937 int dest_bitmap = procedural->procedural_bitmapcxx . . $ proc_struct#procedural_bitmap.;
938 uint16_tcxx . . $ uint16_t# *dest_data = (uint16_tcxx . . $ uint16_t# *)bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(dest_bitmap, 0);
939 uint16_tcxx . . $ uint16_t# *src_data = (uint16_tcxx . . $ uint16_t# *)bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(GameTexturescxx . . $ GameTextures.[handle].bm_handlecxx . . $ texture#bm_handle., 0);
940 int16_t *ptr = (int16_t *)procedural->proc1cxx . . $ proc_struct#proc1.;
941 for (y = 0; y < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!; y++) {
942 for (x = 0; x < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!; x++, offset++) {
943 if (x == PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
944 dx = ptr[offset] - ptr[offset - (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)];
945 else
946 dx = ptr[offset] - ptr[offset + 1];
947 if (y == PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
948 dy = ptr[offset] - ptr[offset - ((PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!)];
949 else
950 dy = ptr[offset] - ptr[offset + PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!];
951 if (dy < 0)
952 dy = 0;
953 if (dx < 0)
954 dx = 0;
955
956 int yoffset = (y + (dy >> 3)) % PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
957 int xoffset = (x + (dx >> 3)) % PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
958 dest_data[offset] = src_data[yoffset * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + xoffset];
959 }
960 }
961 }
962 void DrawWaterWithLightcxx . . $ DrawWaterWithLight(3e454b8ccf442868).(int handle, int lightval) {
963 int dx, dy;
964 int x, y;
965 uint16_tcxx . . $ uint16_t# c;
966 int offset = 0;
967 proc_structcxx . . $ proc_struct# *procedural = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.;
968 int dest_bitmap = procedural->procedural_bitmapcxx . . $ proc_struct#procedural_bitmap.;
969 uint16_tcxx . . $ uint16_t# *dest_data = (uint16_tcxx . . $ uint16_t# *)bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(dest_bitmap, 0);
970 uint16_tcxx . . $ uint16_t# *src_data = (uint16_tcxx . . $ uint16_t# *)bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(GameTexturescxx . . $ GameTextures.[handle].bm_handlecxx . . $ texture#bm_handle., 0);
971 int16_t *ptr = (int16_t *)procedural->proc1cxx . . $ proc_struct#proc1.;
972 for (y = 0; y < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!; y++) {
973 int ychange, ychange2;
974 if (y == PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) {
975 ychange = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
976 ychange2 = ((PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!);
977 } else if (y == 0) {
978 ychange = -((PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1) * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!);
979 ychange2 = -PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
980 } else {
981 ychange = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
982 ychange2 = -PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
983 }
984
985 for (x = 0; x < PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!; x++, offset++) {
986 if (x == PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
987 dx = ptr[offset - 1] - ptr[offset - (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)];
988 else if (x == 0)
989 dx = ptr[offset + (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)] - ptr[offset + 1];
990 else
991 dx = ptr[offset - 1] - ptr[offset + 1];
992 dy = ptr[offset - ychange] - ptr[offset - ychange2];
993
994 int yoffset = (y + (dy >> 3));
995 int xoffset = (x + (dx >> 3));
996 yoffset &= (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
997 xoffset &= (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1);
998 ASSERTcxx . . $ `misc/pserror.h:246:9`!(yoffset >= 0);
999 ASSERTcxx . . $ `misc/pserror.h:246:9`!(xoffset >= 0);
1000 c = src_data[yoffset * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + xoffset];
1001 int l = (NUM_WATER_SHADEScxx . . $ `Descent3/procedurals.cpp:76:9`! / 2) - (dx >> lightval);
1002 if (l > (NUM_WATER_SHADEScxx . . $ `Descent3/procedurals.cpp:76:9`! - 1))
1003 l = NUM_WATER_SHADEScxx . . $ `Descent3/procedurals.cpp:76:9`! - 1;
1004 if (l < 0)
1005 l = 0;
1006 c &= ~OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`!;
1007
1008 c = WaterProcTableHicxx . . $ WaterProcTableHi.[l][c >> 8] + WaterProcTableLocxx . . $ WaterProcTableLo.[l][c & 0xFF];
1009
1010 dest_data[offset] = c;
1011 }
1012 }
1013 }
1014 void AddProcHeightBlobcxx . . $ AddProcHeightBlob(d8111ef3cdd9166c).(static_proc_elementcxx . . $ static_proc_element# *proc, int handle) {
1015 int rquad;
1016 int cx, cy, cyq;
1017 int left, top, right, bottom;
1018 int16_t *dest_data = (int16_t *)GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc1cxx . . $ proc_struct#proc1.;
1019 int x = proc->x1cxx . . $ static_proc_element#x1.;
1020 int y = proc->y1cxx . . $ static_proc_element#y1.;
1021 int procnum = proc - GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->static_proc_elementscxx . . $ proc_struct#static_proc_elements.;
1022 if (proc->frequencycxx . . $ static_proc_element#frequency. && ((FrameCountcxx . . $ FrameCount. + procnum) % proc->frequencycxx . . $ static_proc_element#frequency.))
1023 return;
1024 int radius = proc->sizecxx . . $ static_proc_element#size.;
1025 int height = proc->speedcxx . . $ static_proc_element#speed.;
1026 rquad = radius * radius;
1027
1028 left = -radius;
1029 right = radius;
1030 top = -radius;
1031 bottom = radius;
1032 // Perform edge clipping...
1033 if (x - radius < 1)
1034 left -= (x - radius - 1);
1035 if (y - radius < 1)
1036 top -= (y - radius - 1);
1037 if (x + radius > PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
1038 right -= (x + radius - PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + 1);
1039 if (y + radius > PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
1040 bottom -= (y + radius - PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + 1);
1041 for (cy = top; cy < bottom; cy++) {
1042 cyq = cy * cy;
1043 for (cx = left; cx < right; cx++) {
1044 if (cx * cx + cyq < rquad)
1045 dest_data[PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! * (cy + y) + (cx + x)] += height;
1046 }
1047 }
1048 }
1049 void AddProcRaindropscxx . . $ AddProcRaindrops(d8111ef3cdd9166c).(static_proc_elementcxx . . $ static_proc_element# *proc, int handle) {
1050 int procnum = proc - GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->static_proc_elementscxx . . $ proc_struct#static_proc_elements.;
1051 if (proc->frequencycxx . . $ static_proc_element#frequency. && ((FrameCountcxx . . $ FrameCount. + procnum) % proc->frequencycxx . . $ static_proc_element#frequency.))
1052 return;
1053 uint8_tcxx . . $ uint8_t# proc_frequency = proc->frequencycxx . . $ static_proc_element#frequency.;
1054 uint8_tcxx . . $ uint8_t# proc_size = proc->sizecxx . . $ static_proc_element#size.;
1055 uint8_tcxx . . $ uint8_t# proc_speed = proc->speedcxx . . $ static_proc_element#speed.;
1056 uint8_tcxx . . $ uint8_t# x1 = proc->x1cxx . . $ static_proc_element#x1.;
1057 uint8_tcxx . . $ uint8_t# y1 = proc->y1cxx . . $ static_proc_element#y1.;
1058 proc->frequencycxx . . $ static_proc_element#frequency. = 0;
1059 proc->sizecxx . . $ static_proc_element#size. = (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 3) + 1;
1060 proc->speedcxx . . $ static_proc_element#speed. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(0, proc_speed + ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 10) - 5));
1061 proc->x1cxx . . $ static_proc_element#x1. = x1 + (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % (proc_size * 2)) - (proc_size);
1062 proc->y1cxx . . $ static_proc_element#y1. = y1 + (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % (proc_size * 2)) - (proc_size);
1063 AddProcHeightBlobcxx . . $ AddProcHeightBlob(d8111ef3cdd9166c).(proc, handle);
1064 proc->x1cxx . . $ static_proc_element#x1. = x1;
1065 proc->y1cxx . . $ static_proc_element#y1. = y1;
1066 proc->sizecxx . . $ static_proc_element#size. = proc_size;
1067 proc->speedcxx . . $ static_proc_element#speed. = proc_speed;
1068 proc->frequencycxx . . $ static_proc_element#frequency. = proc_frequency;
1069 }
1070 void AddProcBlobdropscxx . . $ AddProcBlobdrops(d8111ef3cdd9166c).(static_proc_elementcxx . . $ static_proc_element# *proc, int handle) {
1071 int procnum = proc - GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->static_proc_elementscxx . . $ proc_struct#static_proc_elements.;
1072 if (proc->frequencycxx . . $ static_proc_element#frequency. && ((FrameCountcxx . . $ FrameCount. + procnum) % proc->frequencycxx . . $ static_proc_element#frequency.))
1073 return;
1074 uint8_tcxx . . $ uint8_t# proc_frequency = proc->frequencycxx . . $ static_proc_element#frequency.;
1075 uint8_tcxx . . $ uint8_t# proc_size = proc->sizecxx . . $ static_proc_element#size.;
1076 uint8_tcxx . . $ uint8_t# proc_speed = proc->speedcxx . . $ static_proc_element#speed.;
1077 uint8_tcxx . . $ uint8_t# x1 = proc->x1cxx . . $ static_proc_element#x1.;
1078 uint8_tcxx . . $ uint8_t# y1 = proc->y1cxx . . $ static_proc_element#y1.;
1079 proc->frequencycxx . . $ static_proc_element#frequency. = 0;
1080 proc->sizecxx . . $ static_proc_element#size. = (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 6) + 4;
1081 proc->speedcxx . . $ static_proc_element#speed. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(0, proc_speed + ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 50) - 25));
1082 proc->x1cxx . . $ static_proc_element#x1. = x1 + (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % (proc_size * 2)) - (proc_size);
1083 proc->y1cxx . . $ static_proc_element#y1. = y1 + (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % (proc_size * 2)) - (proc_size);
1084 AddProcHeightBlobcxx . . $ AddProcHeightBlob(d8111ef3cdd9166c).(proc, handle);
1085 proc->x1cxx . . $ static_proc_element#x1. = x1;
1086 proc->y1cxx . . $ static_proc_element#y1. = y1;
1087 proc->sizecxx . . $ static_proc_element#size. = proc_size;
1088 proc->speedcxx . . $ static_proc_element#speed. = proc_speed;
1089 proc->frequencycxx . . $ static_proc_element#frequency. = proc_frequency;
1090 }
1091 void AddProcSineBlobcxx . . $ AddProcSineBlob(d8111ef3cdd9166c).(static_proc_elementcxx . . $ static_proc_element# *proc, int handle) {
1092 int procnum = proc - GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->static_proc_elementscxx . . $ proc_struct#static_proc_elements.;
1093 if (proc->frequencycxx . . $ static_proc_element#frequency. && ((FrameCountcxx . . $ FrameCount. + procnum) % proc->frequencycxx . . $ static_proc_element#frequency.))
1094 return;
1095 int x = proc->x1cxx . . $ static_proc_element#x1.;
1096 int y = proc->y1cxx . . $ static_proc_element#y1.;
1097 int cx, cy;
1098 int left, top, right, bottom;
1099 int square, dist;
1100 int radius = proc->sizecxx . . $ static_proc_element#size.;
1101 int radsquare = radius * radius;
1102 float length = (1024.0 / (float)radius) * (1024.0 / (float)radius);
1103 int16_t *dest_data = (int16_t *)GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc1cxx . . $ proc_struct#proc1.;
1104 int height = proc->speedcxx . . $ static_proc_element#speed.;
1105 radsquare = (radius * radius);
1106 left = -radius;
1107 right = radius;
1108 top = -radius;
1109 bottom = radius;
1110 // Perform edge clipping...
1111 if (x - radius < 1)
1112 left -= (x - radius - 1);
1113 if (y - radius < 1)
1114 top -= (y - radius - 1);
1115 if (x + radius > PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
1116 right -= (x + radius - PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + 1);
1117 if (y + radius > PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! - 1)
1118 bottom -= (y + radius - PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! + 1);
1119 for (cy = top; cy < bottom; cy++) {
1120 for (cx = left; cx < right; cx++) {
1121 square = cy * cy + cx * cx;
1122 if (square < radsquare) {
1123 dist = sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(square * length);
1124 int addval = (FixCoscxx . . $ FixCos(9a38df040a81ca35).(dist % 65536) * (float)height);
1125 addval /= 8;
1126 dest_data[PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! * (cy + y) + cx + x] += addval;
1127 }
1128 }
1129 }
1130 }
1131 void AllocateMemoryForWaterProceduralcxx . . $ AllocateMemoryForWaterProcedural(d4f767463ce0a6b3).(int handle) {
1132 proc_structcxx . . $ proc_struct# *procedural = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.;
1133 int w = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
1134 int h = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
1135 if (procedural->proc1cxx . . $ proc_struct#proc1.)
1136 mem_freecxx . . $ `mem/mem.h:80:9`!(procedural->proc1);
1137 if (procedural->proc2cxx . . $ proc_struct#proc2.)
1138 mem_freecxx . . $ `mem/mem.h:80:9`!(procedural->proc2);
1139 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc1cxx . . $ proc_struct#proc1. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(w * h * 2);
1140 ASSERTcxx . . $ `misc/pserror.h:246:9`!(GameTextures[handle].procedural->proc1);
1141 memset(GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc1cxx . . $ proc_struct#proc1., 0, w * h * 2);
1142
1143 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc2cxx . . $ proc_struct#proc2. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(w * h * 2);
1144 ASSERTcxx . . $ `misc/pserror.h:246:9`!(GameTextures[handle].procedural->proc2);
1145 memset(GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc2cxx . . $ proc_struct#proc2., 0, w * h * 2);
1146 procedural->memory_typecxx . . $ proc_struct#memory_type. = PROC_MEMORY_TYPE_WATERcxx . . $ `Descent3/gametexture.h:248:9`!;
1147 }
1148 // Does a water effect for this texture
1149 void EvaluateWaterProceduralcxx . . $ EvaluateWaterProcedural(d4f767463ce0a6b3).(int handle) {
1150 proc_structcxx . . $ proc_struct# *procedural = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.;
1151 if (procedural->memory_typecxx . . $ proc_struct#memory_type. != PROC_MEMORY_TYPE_WATERcxx . . $ `Descent3/gametexture.h:248:9`!)
1152 AllocateMemoryForWaterProceduralcxx . . $ AllocateMemoryForWaterProcedural(d4f767463ce0a6b3).(handle);
1153
1154 int dest_bitmap = procedural->procedural_bitmapcxx . . $ proc_struct#procedural_bitmap.;
1155 for (int i = 0; i < procedural->num_static_elementscxx . . $ proc_struct#num_static_elements.; i++) {
1156 static_proc_elementcxx . . $ static_proc_element# *proc = &procedural->static_proc_elementscxx . . $ proc_struct#static_proc_elements.[i];
1157 switch (proc->typecxx . . $ static_proc_element#type.) {
1158 case PROC_WATER_HEIGHT_BLOBcxx . . $ `Descent3/procedurals.h:43:9`!:
1159 AddProcHeightBlobcxx . . $ AddProcHeightBlob(d8111ef3cdd9166c).(proc, handle);
1160 break;
1161 case PROC_WATER_SINE_BLOBcxx . . $ `Descent3/procedurals.h:44:9`!:
1162 AddProcSineBlobcxx . . $ AddProcSineBlob(d8111ef3cdd9166c).(proc, handle);
1163 break;
1164 case PROC_WATER_RAINDROPScxx . . $ `Descent3/procedurals.h:45:9`!:
1165 AddProcRaindropscxx . . $ AddProcRaindrops(d8111ef3cdd9166c).(proc, handle);
1166 break;
1167 case PROC_WATER_BLOBDROPScxx . . $ `Descent3/procedurals.h:46:9`!:
1168 AddProcBlobdropscxx . . $ AddProcBlobdrops(d8111ef3cdd9166c).(proc, handle);
1169 break;
1170 default:
1171 break;
1172 }
1173 }
1174 if (EasterEggcxx . . $ EasterEgg.) {
1175 if (Easter_egg_handlecxx . . $ Easter_egg_handle. != -1) {
1176 uint16_tcxx . . $ uint16_t# *src_data = bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(Easter_egg_handlecxx . . $ Easter_egg_handle., 0);
1177 int16_t *dest_data = (int16_t *)GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc1cxx . . $ proc_struct#proc1.;
1178 int sw = bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(Easter_egg_handlecxx . . $ Easter_egg_handle., 0);
1179 int sh = bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(Easter_egg_handlecxx . . $ Easter_egg_handle., 0);
1180 int x1 = (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! / 2) - (sw / 2);
1181 int y1 = (PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! / 2) - (sh / 2);
1182 // Make sure size is valid
1183 if (sw <= PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! && sh <= PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!) {
1184 int i, t;
1185 for (i = 0; i < sh; i++) {
1186 for (t = 0; t < sw; t++) {
1187 if (src_data[i * sw + t] & OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`!)
1188 dest_data[((y1 + i) * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!) + t + x1] += 200;
1189 }
1190 }
1191 }
1192 }
1193 EasterEggcxx . . $ EasterEgg. = 0;
1194 }
1195 // Calculate the water on the current texture
1196 if (!procedural->lightcxx . . $ proc_struct#light.)
1197 DrawWaterNoLightcxx . . $ DrawWaterNoLight(d4f767463ce0a6b3).(handle);
1198 else
1199 DrawWaterWithLightcxx . . $ DrawWaterWithLight(3e454b8ccf442868).(handle, procedural->lightcxx . . $ proc_struct#light. - 1);
1200 int thickness = procedural->thicknesscxx . . $ proc_struct#thickness.;
1201 if (procedural->osc_timecxx . . $ proc_struct#osc_time. > 0) {
1202 int start = procedural->osc_valuecxx . . $ proc_struct#osc_value.;
1203 int end = procedural->thicknesscxx . . $ proc_struct#thickness.;
1204 if (start > end) {
1205 int t = start;
1206 start = end;
1207 end = t;
1208 }
1209 int diff = end - start;
1210 if (diff > 0) {
1211 float gametime = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!();
1212 float frametime = procedural->osc_timecxx . . $ proc_struct#osc_time. / (diff);
1213 float cur_frametime = gametime / frametime;
1214 int int_frame = cur_frametime;
1215
1216 int_frame %= ((diff) * 2);
1217 if (int_frame >= diff)
1218 int_frame = (diff - 1) - (int_frame % diff);
1219 else
1220 int_frame %= diff;
1221
1222 thickness = start + int_frame;
1223 }
1224 }
1225 CalcWatercxx . . $ CalcWater(3e454b8ccf442868).(handle, thickness);
1226 // Swap for next time
1227 int16_t *temp = (int16_t *)procedural->proc1cxx . . $ proc_struct#proc1.;
1228 procedural->proc1cxx . . $ proc_struct#proc1. = procedural->proc2cxx . . $ proc_struct#proc2.;
1229 procedural->proc2cxx . . $ proc_struct#proc2. = temp;
1230 }
1231 void AllocateMemoryForFireProceduralcxx . . $ AllocateMemoryForFireProcedural(d4f767463ce0a6b3).(int handle) {
1232 proc_structcxx . . $ proc_struct# *procedural = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.;
1233 int w = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
1234 int h = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
1235 if (procedural->proc1cxx . . $ proc_struct#proc1.)
1236 mem_freecxx . . $ `mem/mem.h:80:9`!(procedural->proc1);
1237 if (procedural->proc2cxx . . $ proc_struct#proc2.)
1238 mem_freecxx . . $ `mem/mem.h:80:9`!(procedural->proc2);
1239 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc1cxx . . $ proc_struct#proc1. = (uint8_tcxx . . $ uint8_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(w * h * 1);
1240 ASSERTcxx . . $ `misc/pserror.h:246:9`!(GameTextures[handle].procedural->proc1);
1241 memset(GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc1cxx . . $ proc_struct#proc1., 0, w * h * 1);
1242
1243 GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc2cxx . . $ proc_struct#proc2. = (uint8_tcxx . . $ uint8_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(w * h * 1);
1244 ASSERTcxx . . $ `misc/pserror.h:246:9`!(GameTextures[handle].procedural->proc2);
1245 memset(GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.->proc2cxx . . $ proc_struct#proc2., 0, w * h * 1);
1246 procedural->memory_typecxx . . $ proc_struct#memory_type. = PROC_MEMORY_TYPE_FIREcxx . . $ `Descent3/gametexture.h:247:9`!;
1247 }
1248 void EvaluateFireProceduralcxx . . $ EvaluateFireProcedural(d4f767463ce0a6b3).(int handle) {
1249 proc_structcxx . . $ proc_struct# *procedural = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.;
1250
1251 int dest_bitmap = procedural->procedural_bitmapcxx . . $ proc_struct#procedural_bitmap.;
1252 if (procedural->memory_typecxx . . $ proc_struct#memory_type. != PROC_MEMORY_TYPE_FIREcxx . . $ `Descent3/gametexture.h:247:9`!) {
1253 AllocateMemoryForFireProceduralcxx . . $ AllocateMemoryForFireProcedural(d4f767463ce0a6b3).(handle);
1254 }
1255 ProcDestDatacxx . . $ ProcDestData. = (uint8_tcxx . . $ uint8_t# *)procedural->proc1cxx . . $ proc_struct#proc1.;
1256 // fade and the current texture
1257 FadeProcTexturecxx . . $ FadeProcTexture(d4f767463ce0a6b3).(handle);
1258 // HeatProcTexture (handle);
1259 // Do the static procedurals first
1260 int i;
1261 for (i = 0; i < procedural->num_static_elementscxx . . $ proc_struct#num_static_elements.; i++) {
1262 static_proc_elementcxx . . $ static_proc_element# *proc = &procedural->static_proc_elementscxx . . $ proc_struct#static_proc_elements.[i];
1263 switch (proc->typecxx . . $ static_proc_element#type.) {
1264 case PROC_LINE_LIGHTNINGcxx . . $ `Descent3/procedurals.h:30:9`!:
1265 AddProcLightningcxx . . $ AddProcLightning(c7d96eab35da25ae).(proc->x1cxx . . $ static_proc_element#x1., proc->y1cxx . . $ static_proc_element#y1., proc->x2cxx . . $ static_proc_element#x2., proc->y2cxx . . $ static_proc_element#y2., BRIGHT_COLORcxx . . $ `Descent3/procedurals.cpp:60:9`!, proc);
1266 break;
1267 case PROC_SPHERE_LIGHTNINGcxx . . $ `Descent3/procedurals.h:31:9`!:
1268 AddProcSphereLightningcxx . . $ AddProcSphereLightning(35100e16194d3d84).(handle, proc);
1269 break;
1270 case PROC_RISING_EMBERcxx . . $ `Descent3/procedurals.h:33:9`!:
1271 AddProcRisingEmbercxx . . $ AddProcRisingEmber(35100e16194d3d84).(handle, proc);
1272 break;
1273 case PROC_RANDOM_EMBERScxx . . $ `Descent3/procedurals.h:34:9`!:
1274 AddProcRandomEmbercxx . . $ AddProcRandomEmber(35100e16194d3d84).(handle, proc);
1275 break;
1276 case PROC_SPINNERScxx . . $ `Descent3/procedurals.h:35:9`!:
1277 AddProcSpinnerscxx . . $ AddProcSpinners(35100e16194d3d84).(handle, proc);
1278 break;
1279 case PROC_ROAMERScxx . . $ `Descent3/procedurals.h:36:9`!:
1280 AddProcRoamerscxx . . $ AddProcRoamers(35100e16194d3d84).(handle, proc);
1281 break;
1282 case PROC_FOUNTAINcxx . . $ `Descent3/procedurals.h:37:9`!:
1283 AddProcFountaincxx . . $ AddProcFountain(35100e16194d3d84).(handle, proc);
1284 break;
1285 case PROC_CONEcxx . . $ `Descent3/procedurals.h:38:9`!:
1286 AddProcConecxx . . $ AddProcCone(35100e16194d3d84).(handle, proc);
1287 break;
1288 case PROC_FALL_RIGHTcxx . . $ `Descent3/procedurals.h:39:9`!:
1289 AddProcFallRightcxx . . $ AddProcFallRight(35100e16194d3d84).(handle, proc);
1290 break;
1291 case PROC_FALL_LEFTcxx . . $ `Descent3/procedurals.h:40:9`!:
1292 AddProcFallLeftcxx . . $ AddProcFallLeft(35100e16194d3d84).(handle, proc);
1293 break;
1294 default:
1295 break;
1296 }
1297 }
1298 int proc_num = procedural->dynamic_proc_elementscxx . . $ proc_struct#dynamic_proc_elements.;
1299 while (proc_num != -1) {
1300 dynamic_proc_elementcxx . . $ dynamic_proc_element# *proc = &DynamicProcElementscxx . . $ DynamicProcElements.[proc_num];
1301
1302 switch (proc->typecxx . . $ dynamic_proc_element#type.) {
1303 case PROC_RISING_EMBERcxx . . $ `Descent3/procedurals.h:33:9`!:
1304 DoDynamicRisingEmbercxx . . $ DoDynamicRisingEmber(f88332d939b43e7d).(handle, proc);
1305 break;
1306 case PROC_RANDOM_EMBERScxx . . $ `Descent3/procedurals.h:34:9`!:
1307 DoDynamicRandomEmbercxx . . $ DoDynamicRandomEmber(f88332d939b43e7d).(handle, proc);
1308 break;
1309 case PROC_SPINNERScxx . . $ `Descent3/procedurals.h:35:9`!:
1310 DoDynamicSpinnerscxx . . $ DoDynamicSpinners(f88332d939b43e7d).(handle, proc);
1311 break;
1312 case PROC_ROAMERScxx . . $ `Descent3/procedurals.h:36:9`!:
1313 DoDynamicRoamerscxx . . $ DoDynamicRoamers(f88332d939b43e7d).(handle, proc);
1314 break;
1315 case PROC_FOUNTAINcxx . . $ `Descent3/procedurals.h:37:9`!:
1316 DoDynamicFountaincxx . . $ DoDynamicFountain(f88332d939b43e7d).(handle, proc);
1317 break;
1318 case PROC_CONEcxx . . $ `Descent3/procedurals.h:38:9`!:
1319 DoDynamicConecxx . . $ DoDynamicCone(f88332d939b43e7d).(handle, proc);
1320 break;
1321 case PROC_FALL_RIGHTcxx . . $ `Descent3/procedurals.h:39:9`!:
1322 DoDynamicFallRightcxx . . $ DoDynamicFallRight(f88332d939b43e7d).(handle, proc);
1323 break;
1324 case PROC_FALL_LEFTcxx . . $ `Descent3/procedurals.h:40:9`!:
1325 DoDynamicFallLeftcxx . . $ DoDynamicFallLeft(f88332d939b43e7d).(handle, proc);
1326 break;
1327 default:
1328 break;
1329 }
1330 proc_num = DynamicProcElementscxx . . $ DynamicProcElements.[proc_num].nextcxx . . $ dynamic_proc_element#next.;
1331 }
1332
1333 // blend the current texture
1334 BlendProcTexturecxx . . $ BlendProcTexture(d4f767463ce0a6b3).(handle);
1335 ProcDestDatacxx . . $ ProcDestData. = (uint8_tcxx . . $ uint8_t# *)procedural->proc2cxx . . $ proc_struct#proc2.;
1336 int total = PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`! * PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!;
1337 uint16_tcxx . . $ uint16_t# *data = bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(dest_bitmap, 0);
1338 uint16_tcxx . . $ uint16_t# *pal = procedural->palettecxx . . $ proc_struct#palette.;
1339 for (i = 0; i < total; i++, data++, ProcDestDatacxx . . $ ProcDestData.++) {
1340 *data = pal[*ProcDestDatacxx . . $ ProcDestData.];
1341 }
1342 // Swap for next time
1343 uint8_tcxx . . $ uint8_t# *temp = (uint8_tcxx . . $ uint8_t# *)procedural->proc1cxx . . $ proc_struct#proc1.;
1344 procedural->proc1cxx . . $ proc_struct#proc1. = procedural->proc2cxx . . $ proc_struct#proc2.;
1345 procedural->proc2cxx . . $ proc_struct#proc2. = temp;
1346 }
1347 // Does a procedural for this texture
1348 void EvaluateProceduralcxx . . $ EvaluateProcedural(d4f767463ce0a6b3).(int handle) {
1349 proc_structcxx . . $ proc_struct# *procedural = GameTexturescxx . . $ GameTextures.[handle].proceduralcxx . . $ texture#procedural.;
1350
1351 int dest_bitmap = procedural->procedural_bitmapcxx . . $ proc_struct#procedural_bitmap.;
1352 if (bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(dest_bitmap, 0) != PROC_SIZEcxx . . $ `Descent3/procedurals.cpp:61:9`!) {
1353 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Couldn't evaluate procedural because its not %d x %d!\n", PROC_SIZE, PROC_SIZE);
1354 return;
1355 }
1356 if (GameTexturescxx . . $ GameTextures.[handle].flagscxx . . $ texture#flags. & TF_WATER_PROCEDURALcxx . . $ `Descent3/gametexture.h:226:9`!)
1357 EvaluateWaterProceduralcxx . . $ EvaluateWaterProcedural(d4f767463ce0a6b3).(handle);
1358 else
1359 EvaluateFireProceduralcxx . . $ EvaluateFireProcedural(d4f767463ce0a6b3).(handle);
1360 }