1 /*
2 BStone: A Source port of
3 Blake Stone: Aliens of Gold and Blake Stone: Planet Strike
4 
5 Copyright (c) 1992-2013 Apogee Entertainment, LLC
6 Copyright (c) 2013-2015 Boris I. Bendovsky (bibendovsky@hotmail.com)
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the
20 Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23 
24 
25 #ifndef BSTONE_3D_DEF_INCLUDED
26 #define BSTONE_3D_DEF_INCLUDED
27 
28 
29 #include <cmath>
30 
31 #include "id_heads.h"
32 #include "jm_io.h"
33 #include "jm_cio.h"
34 
35 
36 #define LOOK_FOR_DEAD_GUYS (0)
37 
38 #define LIMITED_AMMO
39 
40 
41 enum class ScanCode;
42 
43 
44 const int BS_SAVE_VERSION = 4;
45 
46 extern bool no_screens;
47 
48 #define GOLD_MORPH_LEVEL (19) // Level which Dr. GoldFire Morphs.
49 
50 #define VERSION_TEXT_COLOR (0x82)
51 #define VERSION_TEXT_BKCOLOR (0x80)
52 
53 #define NO_SHADING (-128)
54 #define LAMP_ON_SHADING (-12)
55 #define EXPLOSION_SHADING (-52)
56 
57 #define DISK_SPACE_NEEDED (1024L * 1024L)
58 
59 #define BORDER_HI_COLOR (0x85)
60 #define BORDER_MED_COLOR (0x82)
61 #define BORDER_LO_COLOR (0x80)
62 #define BORDER_TEXT_COLOR (0xAF)
63 
64 
65 // FONT DEFINES
66 //
67 #define COAL_FONT (STARTFONT + 4)
68 
69 
70 /*
71 =============================================================================
72 
73  MACROS
74 
75 =============================================================================
76 */
77 
78 
79 #define MAX_RADAR_ENERGY (14400)
80 #define RADAR_PAK_VALUE (60 * 15)
81 
82 #define MAXKEYS (1)
83 
84 #define MAPSPOT(x, y, plane) (*(mapsegs[plane] + farmapylookup[y] + x))
85 
86 #define ABS(x) (static_cast<int16_t>(x) > 0 ? (x) : -(x))
87 #define LABS(x) (static_cast<int32_t>(x) > 0 ? (x) : -(x))
88 
89 #define DISPLAY_MSG_STD_TIME (5 * 60) // Tics display len
90 #define DISPLAY_TIMED_MSG(msg, pri, type) DisplayInfoMsg((msg), (pri), DISPLAY_MSG_STD_TIME, (type))
91 #define DISPLAY_MSG(msg, pri, type) DisplayInfoMsg((msg), (pri), 0, (type))
92 
93 
94 // SMART_ACTORS is the "case" used for certain switch statements.
95 //
96 
97 #define SMART_ACTORS proguardobj : \
98 case rentacopobj : \
99 case gen_scientistobj
100 
101 
102 // Barrier Code Stuff
103 
104 #define MAX_BARRIER_SWITCHES (40) // max number level wall switches
105 
106 
107 #define SLIDE_TEMP(obj) (ui16_to_actor(obj->hitpoints))
108 
109 //
110 // M_BASE1 - represents 100 percent in 1st base
111 // M_BASE2 - represents 100 percent in 2nd base
112 // F_BASE2 - fractional portion of 2nd base
113 // SCALE - arbitrary scaling value (bigger number means more accurate)
114 //
115 // RETURNS: F_BASE1 - represents fractional portion of 1st base
116 //
117 // ex: RATIO(320,16,8,7)    returns  160
118 //
119 // Make sure values used won't overflow a WORD! In general, if largest number
120 // to be used (320 in ex: above) * (1<<SCALE) is greater than 65535, use
121 // LRATIO or a lower SCALE. Using a SCALE of 8 in the example above would
122 // overflow a WORD in some circumstances!
123 //
124 // LRATIO is to be used for larger SCALEs, thus, giving you massive accuracy!
125 //
126 #define LRATIO(M_BASE1, M_BASE2, F_BASE2, SCALE) (((int32_t)M_BASE1 * (((int32_t)F_BASE2 << SCALE) / M_BASE2)) >> SCALE)
127 
128 
129 #define MAX_INF_AREA_MSGS (6)
130 #define MAX_LOCATION_DESC_LEN (45)
131 
132 #define DOOR_RUBBLE_STATNUM (112) // Door Rubble sprite
133 
134 #define SpawnExplosion(a, b) SpawnCusExplosion((a), (b), SPR_EXPLOSION_1, 4, 5, explosionobj)
135 #define SpawnFlash(a, b) SpawnCusExplosion((a), (b), SPR_EXPLOSION_1, 4, 5, deadobj)
136 
137 
138 /*
139 =============================================================================
140 
141  GLOBAL CONSTANTS
142 
143 =============================================================================
144 */
145 
146 #define OV_ACTORS (0x0001)
147 #define OV_SHOWALL (0x0002)
148 #define OV_KEYS (0x0004)
149 #define OV_PUSHWALLS (0x0008)
150 
151 // BBi
152 #define OV_WHOLE_MAP (0x0010)
153 
154 
155 #define TT_TRAVELED (0x01)
156 #define TT_KEYS (0x02)
157 
158 
159 #define MAXACTORS (150) // max number of nazis, etc / map
160 #define MAXSTATS (400) // max number of lamps, bonus, etc
161 #define MAXDOORS (64) // max number of sliding doors
162 #define MAXCONCESSIONS (15) // max number of concession machines
163 #define MAXWALLTILES (64) // max number of wall tiles
164 #define MAXEAWALLS (12) // max electro-alien wall sockets
165 
166 
167 #define GS_NEEDCOORD (0)
168 #define GS_FIRSTTIME (1)
169 #define GS_COORDFOUND (2)
170 #define GS_NO_MORE (3)
171 
172 #define GOLDIE_MAX_SPAWNS (10) // Max Number of spawn points for Goldstern
173 #define MIN_GOLDIE_FIRST_WAIT (5 * 60) // Min wait time for FIRST goldstern (5 Secs)
174 #define MAX_GOLDIE_FIRST_WAIT (15 * 60) // Max wait time for FIRST goldstern (15 Secs)
175 #define MIN_GOLDIE_WAIT (30 * 60) // Min wait time for next goldstern (30 Secs)
176 #define MAX_GOLDIE_WAIT (4 * 60 * 60) // Max wait time for next goldstern (4 Mins)
177 
178 
179 
180 
181 //
182 // tile constants
183 //
184 
185 #define ICONARROWS (90)
186 #define PUSHABLETILE (98)
187 #define EXITTILE (99) // at end of castle
188 #define AREATILE (108) // first of NUMAREAS floor tiles
189 #define HIDDENAREATILE (162) // first of hidden floor tiles
190 #define NUMAREAS (45)
191 #define DOORTRIGGERTILE (158)
192 
193 #define SMART_OFF_TRIGGER (159)
194 #define SMART_ON_TRIGGER (160)
195 
196 #define TRANSPORTERTILE (21)
197 #define DIRECTTRANSPORTTILE (32) // Wall to use on direct level transporters
198 #define SODATILE (15)
199 #define FOODTILE (18)
200 #define AMBUSHTILE (106)
201 
202 #define RKEY_TILE (72)
203 #define YKEY_TILE (73)
204 #define BKEY_TILE (74)
205 #define BFG_TILE (75)
206 #define ION_TILE (76)
207 #define DETONATOR_TILE (77)
208 #define CLOAK_TILE (78)
209 #define LINC_TILE (79)
210 #define CLOAK_AMBUSH_TILE (80)
211 
212 #define EATILE (24)
213 #define ON_SWITCH (45) // ON Wall Switch -
214 #define OFF_SWITCH (57) // OFF Wall Switch -
215 #define WINTIGGERTILE (157) // Win Tile
216 
217 #define START_TEXTURES (125) // Start of Textures - (Also LAST_WALL_TILE NUM)
218 #define NUM_TILES (PMSpriteStart)
219 
220 
221 // ----------------
222 
223 #define EXTRAPOINTS (400000)
224 
225 #define MAX_EXTRA_LIVES (4)
226 
227 #define RUNSPEED (6000)
228 
229 #define SCREENBWIDE (::vga_ref_width)
230 
231 #define HEIGHTRATIO (0.41)
232 #define TOP_STRIP_HEIGHT (16) // Pix height of top strip.
233 
234 #define PLAYERSIZE (MINDIST) // player radius
235 #define MINACTORDIST (0x10000L) // minimum dist from player center
236 // to any actor center
237 
238 #define NUMLATCHPICS (100)
239 
240 
241 #define PI (3.141592657)
242 
243 #define GLOBAL1 (1L << 16)
244 #define TILEGLOBAL (GLOBAL1)
245 #define TILESHIFT (16L)
246 #define UNSIGNEDSHIFT (8)
247 
248 #define ANGLES (360) // must be divisable by 4
249 #define ANGLEQUAD (ANGLES / 4)
250 #define FINEANGLES (3600)
251 
252 #define MINDIST (0x5800L)
253 
254 #define MAPSIZE (64) // maps are 64*64 max
255 #define NORTH (0)
256 #define EAST (1)
257 #define SOUTH (2)
258 #define WEST (3)
259 
260 #define STATUSLINES (48)
261 
262 #define SCREENSIZE (SCREENBWIDE * ::vga_ref_height)
263 
264 #define STARTAMMO (8)
265 
266 // Token Definations
267 
268 #define MAX_TOKENS (25)
269 
270 
271 
272 // Ammo/Weapon Definations
273 
274 #define MAX_AMMO (100) // Max ammount of ammo for any weapon
275 #define AUTOCHARGE_WAIT (50) // Tics wait time for a full charge
276 
277 #define MAX_PLASMA_DETONATORS (100) // Max number of Plasma Detonators
278 #define PLASMA_DETONATORS_DELAY (60 * 4) // Number of tics before plasma detonator explodes
279 
280 
281 
282 // gamestate.flags flag values
283 
284 #define GS_HEARTB_SOUND (0x0001)
285 #define GS_DRAW_CEILING (0x0002)
286 #define GS_CLIP_WALLS (0x0004)
287 #define GS_DRAW_FLOOR (0x0008)
288 #define GS_VIRGIN_LEVEL (0x0010)
289 #define GS_CHECK_STATS_BONUS (0x0020)
290 #define GS_ATTACK_INFOAREA (0x0040)
291 #define GS_KILL_INF_WARN (0x0080)
292 #define GS_SHOW_OVERHEAD (0x0100)
293 #define GS_BAD_DIZ_FILE (0x0200)
294 #define GS_MUSIC_TEST (0x0400)
295 #define GS_LIGHTING (0x0800)
296 #define GS_TICS_FOR_SCORE (0x1000)
297 #define GS_NOWAIT (0x2000)
298 #define GS_STARTLEVEL (0x4000)
299 #define GS_QUICKRUN (0x8000)
300 
301 // object flag values - Oh Shit Longs!
302 
303 #define FL_SHOOTABLE (0x00000001)
304 #define FL_BONUS (0x00000002)
305 #define FL_NEVERMARK (0x00000004)
306 #define FL_VISABLE (0x00000008)
307 #define FL_ATTACKMODE (0x00000010)
308 #define FL_FIRSTATTACK (0x00000020)
309 #define FL_AMBUSH (0x00000040)
310 #define FL_NONMARK (0x00000080)
311 #define FL_SOLID (0x00000100)
312 #define FL_STATIONARY (0x00000200)
313 #define FL_FRIENDLY (0x00000400)
314 #define FL_DEADGUY (0x00000800)
315 #define FL_RUNAWAY (0x00001000)
316 #define FL_RUNTOSTATIC (0x00002000)
317 #define FL_OFFSET_STATES (0x00004000)
318 #define FL_INFORMANT (0x00008000)
319 #define FL_INTERROGATED (0x00010000)
320 #define FL_RANDOM_TURN (0x00020000)
321 #define FL_NO_SLIDE (0x00040000)
322 #define FL_MUST_ATTACK (0x00080000)
323 #define FL_ALERTED (0x00100000)
324 #define FL_FREEZE (0x00200000)
325 #define FL_HAS_AMMO (0x00400000)
326 #define FL_PROJ_TRANSPARENT (0x00800000)
327 #define FL_PROJ_CHECK_TRANSPARENT (0x01000000)
328 #define FL_HAS_TOKENS (0x02000000)
329 #define FL_LOCKED_STATE (0x04000000)
330 #define FL_BARRIER (0x08000000)
331 #define FL_SHOOTMODE (0x10000000)
332 #define FL_SLIDE_INIT (0x20000000)
333 #define FL_STORED_OBJPTR (0x40000000)
334 #define FL_FAKE_STATIC (0x80000000)
335 
336 #define FL_BARRIER_DAMAGE (FL_HAS_TOKENS)
337 
338 
339 // object flags2 values
340 
341 #define FL2_BFGSHOT_SOLID (0x0001)
342 #define FL2_BFG_SHOOTABLE (0x0002)
343 
344 #define FL2_NOTGUNSHOOTABLE (0x0004)
345 #define FL2_SCARED (0x0008)
346 #define FL2_DROP_RKEY (0x0010)
347 #define FL2_DROP_YKEY (0x0020)
348 #define FL2_DROP_BKEY (0x0040)
349 
350 #define FL2_DROP_BFG (0x0080)
351 #define FL2_DROP_ION (0x0100)
352 #define FL2_DROP_DETONATOR (0x0200)
353 #define FL2_CLOAKED (0x0400)
354 #define FL2_LINC (0x0800)
355 #define FL2_DAMAGE_CLOAK (0x1000)
356 
357 
358 // Run Reason Flags -- Why am I running..Duh..
359 
360 #define RR_AMMO (0x0001)
361 #define RR_HEALTH (0x0002)
362 #define RR_INTERROGATED (0x0004)
363 #define RR_CASUAL_PICKUP (0x0008)
364 #define RR_SCARED (0x0010)
365 
366 
367 //
368 // Concession Machine Types
369 #define CT_FOOD 0x1
370 #define CT_BEVS 0x2
371 
372 //
373 // Door Flags
374 //
375 #define DR_BLASTABLE (0x01)
376 
377 //
378 // Smart Trigger Possiblities
379 //
380 #define ST_TURN_OFF (0x00)
381 #define ST_TURN_ON (0x01)
382 #define ST_TOGGLE (0x02)
383 
384 
385 //
386 //
387 //
388 
389 #define CANT_SAVE_GAME_TXT " Can't save this game! \n" \
390     "    Hard Disk FULL!"
391 
392 enum ss_type {
393     ss_normal,
394     ss_quick,
395     ss_justcalc
396 }; // ss_type
397 
398 enum cds_io_type {
399     cds_dos_print,
400     cds_id_print,
401     cds_menu_print
402 }; // cds_io_type
403 
404 
405 enum sp_type {
406     sp_normal,
407     sp_loading,
408     sp_saving,
409     sp_changeview,
410     sp_teleporting
411 }; // sp_type
412 
413 //
414 // sprite constants
415 //
416 
417 extern int16_t SPR_DEMO;
418 
419 //
420 // Static sprites
421 //
422 extern int16_t SPR_STAT_0;
423 extern int16_t SPR_STAT_1;
424 extern int16_t SPR_STAT_2;
425 extern int16_t SPR_STAT_3;
426 extern int16_t SPR_STAT_4;
427 extern int16_t SPR_STAT_5;
428 extern int16_t SPR_STAT_6;
429 extern int16_t SPR_STAT_7;
430 extern int16_t SPR_STAT_8;
431 extern int16_t SPR_STAT_9;
432 extern int16_t SPR_STAT_10;
433 extern int16_t SPR_STAT_11;
434 extern int16_t SPR_STAT_12;
435 extern int16_t SPR_STAT_13;
436 extern int16_t SPR_STAT_14;
437 extern int16_t SPR_STAT_15;
438 extern int16_t SPR_STAT_16;
439 extern int16_t SPR_STAT_17;
440 extern int16_t SPR_STAT_18;
441 extern int16_t SPR_STAT_19;
442 extern int16_t SPR_STAT_20;
443 extern int16_t SPR_STAT_21;
444 extern int16_t SPR_STAT_22;
445 extern int16_t SPR_STAT_23;
446 extern int16_t SPR_STAT_24;
447 extern int16_t SPR_STAT_25;
448 extern int16_t SPR_STAT_26;
449 extern int16_t SPR_STAT_27;
450 extern int16_t SPR_STAT_28;
451 extern int16_t SPR_STAT_29;
452 extern int16_t SPR_STAT_30;
453 extern int16_t SPR_STAT_31;
454 extern int16_t SPR_STAT_32;
455 extern int16_t SPR_STAT_33;
456 extern int16_t SPR_STAT_34; // Green Key (AOG) / Anti-Plasma Cannon (PS)
457 extern int16_t SPR_STAT_35;
458 extern int16_t SPR_STAT_36; // Gold Key (AOG) / Yellow Package? (PS)
459 extern int16_t SPR_STAT_37;
460 extern int16_t SPR_STAT_38;
461 extern int16_t SPR_STAT_39;
462 extern int16_t SPR_STAT_40;
463 extern int16_t SPR_STAT_41;
464 extern int16_t SPR_STAT_42;
465 extern int16_t SPR_STAT_43;
466 extern int16_t SPR_STAT_44;
467 extern int16_t SPR_STAT_45;
468 extern int16_t SPR_STAT_46;
469 extern int16_t SPR_STAT_47;
470 extern int16_t SPR_STAT_48;
471 extern int16_t SPR_STAT_49;
472 extern int16_t SPR_STAT_50;
473 extern int16_t SPR_STAT_51;
474 extern int16_t SPR_STAT_52;
475 extern int16_t SPR_STAT_53;
476 extern int16_t SPR_STAT_54;
477 extern int16_t SPR_STAT_55;
478 extern int16_t SPR_STAT_56;
479 
480 extern int16_t SPR_CRATE_1;
481 extern int16_t SPR_CRATE_2;
482 extern int16_t SPR_CRATE_3;
483 
484 extern int16_t SPR_STAT_57;
485 extern int16_t SPR_STAT_58;
486 extern int16_t SPR_STAT_59;
487 extern int16_t SPR_STAT_60;
488 extern int16_t SPR_STAT_61;
489 extern int16_t SPR_STAT_62;
490 extern int16_t SPR_STAT_63;
491 extern int16_t SPR_STAT_64;
492 extern int16_t SPR_STAT_65;
493 extern int16_t SPR_STAT_66;
494 extern int16_t SPR_STAT_67;
495 extern int16_t SPR_STAT_68;
496 extern int16_t SPR_STAT_69;
497 extern int16_t SPR_STAT_70;
498 extern int16_t SPR_STAT_71;
499 extern int16_t SPR_STAT_72;
500 extern int16_t SPR_STAT_73;
501 extern int16_t SPR_STAT_74;
502 extern int16_t SPR_STAT_75;
503 extern int16_t SPR_STAT_76;
504 extern int16_t SPR_STAT_77;
505 extern int16_t SPR_STAT_78;
506 extern int16_t SPR_STAT_79;
507 
508 extern int16_t SPR_DOORBOMB;
509 extern int16_t SPR_ALT_DOORBOMB;
510 extern int16_t SPR_RUBBLE;
511 extern int16_t SPR_BONZI_TREE;
512 extern int16_t SPR_AUTOMAPPER;
513 extern int16_t SPR_POT_PLANT;
514 extern int16_t SPR_TUBE_PLANT;
515 extern int16_t SPR_HITECH_CHAIR;
516 
517 //
518 // Aesthetics
519 //
520 extern int16_t SPR_AIR_VENT;
521 extern int16_t SPR_BLOOD_DRIP1;
522 extern int16_t SPR_BLOOD_DRIP2;
523 extern int16_t SPR_BLOOD_DRIP3;
524 extern int16_t SPR_BLOOD_DRIP4;
525 extern int16_t SPR_WATER_DRIP1;
526 extern int16_t SPR_WATER_DRIP2;
527 extern int16_t SPR_WATER_DRIP3;
528 extern int16_t SPR_WATER_DRIP4;
529 
530 extern int16_t SPR_DECO_ARC_1;
531 extern int16_t SPR_DECO_ARC_2;
532 extern int16_t SPR_DECO_ARC_3;
533 
534 extern int16_t SPR_GRATE;
535 extern int16_t SPR_STEAM_1;
536 extern int16_t SPR_STEAM_2;
537 extern int16_t SPR_STEAM_3;
538 extern int16_t SPR_STEAM_4;
539 
540 extern int16_t SPR_STEAM_PIPE;
541 extern int16_t SPR_PIPE_STEAM_1;
542 extern int16_t SPR_PIPE_STEAM_2;
543 extern int16_t SPR_PIPE_STEAM_3;
544 extern int16_t SPR_PIPE_STEAM_4;
545 
546 //
547 // Dead Actors (from Blake Stone: AOG)
548 //
549 extern int16_t SPR_DEAD_RENT;
550 extern int16_t SPR_DEAD_PRO;
551 extern int16_t SPR_DEAD_SWAT;
552 
553 //
554 // Sector Patrol (AOG) / Rent-A-Cop (PS)
555 //
556 extern int16_t SPR_RENT_S_1;
557 extern int16_t SPR_RENT_S_2;
558 extern int16_t SPR_RENT_S_3;
559 extern int16_t SPR_RENT_S_4;
560 extern int16_t SPR_RENT_S_5;
561 extern int16_t SPR_RENT_S_6;
562 extern int16_t SPR_RENT_S_7;
563 extern int16_t SPR_RENT_S_8;
564 
565 extern int16_t SPR_RENT_W1_1;
566 extern int16_t SPR_RENT_W1_2;
567 extern int16_t SPR_RENT_W1_3;
568 extern int16_t SPR_RENT_W1_4;
569 extern int16_t SPR_RENT_W1_5;
570 extern int16_t SPR_RENT_W1_6;
571 extern int16_t SPR_RENT_W1_7;
572 extern int16_t SPR_RENT_W1_8;
573 
574 extern int16_t SPR_RENT_W2_1;
575 extern int16_t SPR_RENT_W2_2;
576 extern int16_t SPR_RENT_W2_3;
577 extern int16_t SPR_RENT_W2_4;
578 extern int16_t SPR_RENT_W2_5;
579 extern int16_t SPR_RENT_W2_6;
580 extern int16_t SPR_RENT_W2_7;
581 extern int16_t SPR_RENT_W2_8;
582 
583 extern int16_t SPR_RENT_W3_1;
584 extern int16_t SPR_RENT_W3_2;
585 extern int16_t SPR_RENT_W3_3;
586 extern int16_t SPR_RENT_W3_4;
587 extern int16_t SPR_RENT_W3_5;
588 extern int16_t SPR_RENT_W3_6;
589 extern int16_t SPR_RENT_W3_7;
590 extern int16_t SPR_RENT_W3_8;
591 
592 extern int16_t SPR_RENT_W4_1;
593 extern int16_t SPR_RENT_W4_2;
594 extern int16_t SPR_RENT_W4_3;
595 extern int16_t SPR_RENT_W4_4;
596 extern int16_t SPR_RENT_W4_5;
597 extern int16_t SPR_RENT_W4_6;
598 extern int16_t SPR_RENT_W4_7;
599 extern int16_t SPR_RENT_W4_8;
600 
601 extern int16_t SPR_RENT_DIE_1;
602 extern int16_t SPR_RENT_DIE_2;
603 extern int16_t SPR_RENT_DIE_3;
604 extern int16_t SPR_RENT_DIE_4;
605 extern int16_t SPR_RENT_PAIN_1;
606 extern int16_t SPR_RENT_DEAD;
607 
608 extern int16_t SPR_RENT_SHOOT1;
609 extern int16_t SPR_RENT_SHOOT2;
610 extern int16_t SPR_RENT_SHOOT3;
611 
612 //
613 // Star Sentinel (AOG) / Pro-Guard (PS)
614 //
615 extern int16_t SPR_PRO_S_1;
616 extern int16_t SPR_PRO_S_2;
617 extern int16_t SPR_PRO_S_3;
618 extern int16_t SPR_PRO_S_4;
619 extern int16_t SPR_PRO_S_5;
620 extern int16_t SPR_PRO_S_6;
621 extern int16_t SPR_PRO_S_7;
622 extern int16_t SPR_PRO_S_8;
623 
624 extern int16_t SPR_PRO_W1_1;
625 extern int16_t SPR_PRO_W1_2;
626 extern int16_t SPR_PRO_W1_3;
627 extern int16_t SPR_PRO_W1_4;
628 extern int16_t SPR_PRO_W1_5;
629 extern int16_t SPR_PRO_W1_6;
630 extern int16_t SPR_PRO_W1_7;
631 extern int16_t SPR_PRO_W1_8;
632 
633 extern int16_t SPR_PRO_W2_1;
634 extern int16_t SPR_PRO_W2_2;
635 extern int16_t SPR_PRO_W2_3;
636 extern int16_t SPR_PRO_W2_4;
637 extern int16_t SPR_PRO_W2_5;
638 extern int16_t SPR_PRO_W2_6;
639 extern int16_t SPR_PRO_W2_7;
640 extern int16_t SPR_PRO_W2_8;
641 
642 extern int16_t SPR_PRO_W3_1;
643 extern int16_t SPR_PRO_W3_2;
644 extern int16_t SPR_PRO_W3_3;
645 extern int16_t SPR_PRO_W3_4;
646 extern int16_t SPR_PRO_W3_5;
647 extern int16_t SPR_PRO_W3_6;
648 extern int16_t SPR_PRO_W3_7;
649 extern int16_t SPR_PRO_W3_8;
650 
651 extern int16_t SPR_PRO_W4_1;
652 extern int16_t SPR_PRO_W4_2;
653 extern int16_t SPR_PRO_W4_3;
654 extern int16_t SPR_PRO_W4_4;
655 extern int16_t SPR_PRO_W4_5;
656 extern int16_t SPR_PRO_W4_6;
657 extern int16_t SPR_PRO_W4_7;
658 extern int16_t SPR_PRO_W4_8;
659 
660 extern int16_t SPR_PRO_PAIN_1;
661 extern int16_t SPR_PRO_DIE_1;
662 extern int16_t SPR_PRO_DIE_2;
663 extern int16_t SPR_PRO_DIE_3;
664 extern int16_t SPR_PRO_PAIN_2;
665 extern int16_t SPR_PRO_DIE_4;
666 extern int16_t SPR_PRO_DEAD;
667 
668 extern int16_t SPR_PRO_SHOOT1;
669 extern int16_t SPR_PRO_SHOOT2;
670 extern int16_t SPR_PRO_SHOOT3;
671 
672 //
673 // Star Trooper (AOG) / SWAT (PS)
674 //
675 extern int16_t SPR_SWAT_S_1;
676 extern int16_t SPR_SWAT_S_2;
677 extern int16_t SPR_SWAT_S_3;
678 extern int16_t SPR_SWAT_S_4;
679 extern int16_t SPR_SWAT_S_5;
680 extern int16_t SPR_SWAT_S_6;
681 extern int16_t SPR_SWAT_S_7;
682 extern int16_t SPR_SWAT_S_8;
683 
684 extern int16_t SPR_SWAT_W1_1;
685 extern int16_t SPR_SWAT_W1_2;
686 extern int16_t SPR_SWAT_W1_3;
687 extern int16_t SPR_SWAT_W1_4;
688 extern int16_t SPR_SWAT_W1_5;
689 extern int16_t SPR_SWAT_W1_6;
690 extern int16_t SPR_SWAT_W1_7;
691 extern int16_t SPR_SWAT_W1_8;
692 
693 extern int16_t SPR_SWAT_W2_1;
694 extern int16_t SPR_SWAT_W2_2;
695 extern int16_t SPR_SWAT_W2_3;
696 extern int16_t SPR_SWAT_W2_4;
697 extern int16_t SPR_SWAT_W2_5;
698 extern int16_t SPR_SWAT_W2_6;
699 extern int16_t SPR_SWAT_W2_7;
700 extern int16_t SPR_SWAT_W2_8;
701 
702 extern int16_t SPR_SWAT_W3_1;
703 extern int16_t SPR_SWAT_W3_2;
704 extern int16_t SPR_SWAT_W3_3;
705 extern int16_t SPR_SWAT_W3_4;
706 extern int16_t SPR_SWAT_W3_5;
707 extern int16_t SPR_SWAT_W3_6;
708 extern int16_t SPR_SWAT_W3_7;
709 extern int16_t SPR_SWAT_W3_8;
710 
711 extern int16_t SPR_SWAT_W4_1;
712 extern int16_t SPR_SWAT_W4_2;
713 extern int16_t SPR_SWAT_W4_3;
714 extern int16_t SPR_SWAT_W4_4;
715 extern int16_t SPR_SWAT_W4_5;
716 extern int16_t SPR_SWAT_W4_6;
717 extern int16_t SPR_SWAT_W4_7;
718 extern int16_t SPR_SWAT_W4_8;
719 
720 extern int16_t SPR_SWAT_PAIN_1;
721 extern int16_t SPR_SWAT_DIE_1;
722 extern int16_t SPR_SWAT_DIE_2;
723 extern int16_t SPR_SWAT_DIE_3;
724 extern int16_t SPR_SWAT_PAIN_2;
725 extern int16_t SPR_SWAT_DIE_4;
726 extern int16_t SPR_SWAT_DEAD;
727 
728 extern int16_t SPR_SWAT_SHOOT1;
729 extern int16_t SPR_SWAT_SHOOT2;
730 extern int16_t SPR_SWAT_SHOOT3;
731 
732 extern int16_t SPR_SWAT_WOUNDED1;
733 extern int16_t SPR_SWAT_WOUNDED2;
734 extern int16_t SPR_SWAT_WOUNDED3;
735 extern int16_t SPR_SWAT_WOUNDED4;
736 
737 //
738 // General Scientist
739 //
740 extern int16_t SPR_OFC_S_1;
741 extern int16_t SPR_OFC_S_2;
742 extern int16_t SPR_OFC_S_3;
743 extern int16_t SPR_OFC_S_4;
744 extern int16_t SPR_OFC_S_5;
745 extern int16_t SPR_OFC_S_6;
746 extern int16_t SPR_OFC_S_7;
747 extern int16_t SPR_OFC_S_8;
748 
749 extern int16_t SPR_OFC_W1_1;
750 extern int16_t SPR_OFC_W1_2;
751 extern int16_t SPR_OFC_W1_3;
752 extern int16_t SPR_OFC_W1_4;
753 extern int16_t SPR_OFC_W1_5;
754 extern int16_t SPR_OFC_W1_6;
755 extern int16_t SPR_OFC_W1_7;
756 extern int16_t SPR_OFC_W1_8;
757 
758 extern int16_t SPR_OFC_W2_1;
759 extern int16_t SPR_OFC_W2_2;
760 extern int16_t SPR_OFC_W2_3;
761 extern int16_t SPR_OFC_W2_4;
762 extern int16_t SPR_OFC_W2_5;
763 extern int16_t SPR_OFC_W2_6;
764 extern int16_t SPR_OFC_W2_7;
765 extern int16_t SPR_OFC_W2_8;
766 
767 extern int16_t SPR_OFC_W3_1;
768 extern int16_t SPR_OFC_W3_2;
769 extern int16_t SPR_OFC_W3_3;
770 extern int16_t SPR_OFC_W3_4;
771 extern int16_t SPR_OFC_W3_5;
772 extern int16_t SPR_OFC_W3_6;
773 extern int16_t SPR_OFC_W3_7;
774 extern int16_t SPR_OFC_W3_8;
775 
776 extern int16_t SPR_OFC_W4_1;
777 extern int16_t SPR_OFC_W4_2;
778 extern int16_t SPR_OFC_W4_3;
779 extern int16_t SPR_OFC_W4_4;
780 extern int16_t SPR_OFC_W4_5;
781 extern int16_t SPR_OFC_W4_6;
782 extern int16_t SPR_OFC_W4_7;
783 extern int16_t SPR_OFC_W4_8;
784 
785 extern int16_t SPR_OFC_PAIN_1;
786 extern int16_t SPR_OFC_DIE_1;
787 extern int16_t SPR_OFC_DIE_2;
788 extern int16_t SPR_OFC_DIE_3;
789 extern int16_t SPR_OFC_PAIN_2;
790 extern int16_t SPR_OFC_DIE_4;
791 extern int16_t SPR_OFC_DEAD;
792 
793 extern int16_t SPR_OFC_SHOOT1;
794 extern int16_t SPR_OFC_SHOOT2;
795 extern int16_t SPR_OFC_SHOOT3;
796 
797 //
798 // Bad Boy Dr. Goldstern
799 //
800 extern int16_t SPR_GOLD_S_1;
801 extern int16_t SPR_GOLD_S_2;
802 extern int16_t SPR_GOLD_S_3;
803 extern int16_t SPR_GOLD_S_4;
804 extern int16_t SPR_GOLD_S_5;
805 extern int16_t SPR_GOLD_S_6;
806 extern int16_t SPR_GOLD_S_7;
807 extern int16_t SPR_GOLD_S_8;
808 
809 extern int16_t SPR_GOLD_W1_1;
810 extern int16_t SPR_GOLD_W1_2;
811 extern int16_t SPR_GOLD_W1_3;
812 extern int16_t SPR_GOLD_W1_4;
813 extern int16_t SPR_GOLD_W1_5;
814 extern int16_t SPR_GOLD_W1_6;
815 extern int16_t SPR_GOLD_W1_7;
816 extern int16_t SPR_GOLD_W1_8;
817 
818 extern int16_t SPR_GOLD_W2_1;
819 extern int16_t SPR_GOLD_W2_2;
820 extern int16_t SPR_GOLD_W2_3;
821 extern int16_t SPR_GOLD_W2_4;
822 extern int16_t SPR_GOLD_W2_5;
823 extern int16_t SPR_GOLD_W2_6;
824 extern int16_t SPR_GOLD_W2_7;
825 extern int16_t SPR_GOLD_W2_8;
826 
827 extern int16_t SPR_GOLD_W3_1;
828 extern int16_t SPR_GOLD_W3_2;
829 extern int16_t SPR_GOLD_W3_3;
830 extern int16_t SPR_GOLD_W3_4;
831 extern int16_t SPR_GOLD_W3_5;
832 extern int16_t SPR_GOLD_W3_6;
833 extern int16_t SPR_GOLD_W3_7;
834 extern int16_t SPR_GOLD_W3_8;
835 
836 extern int16_t SPR_GOLD_W4_1;
837 extern int16_t SPR_GOLD_W4_2;
838 extern int16_t SPR_GOLD_W4_3;
839 extern int16_t SPR_GOLD_W4_4;
840 extern int16_t SPR_GOLD_W4_5;
841 extern int16_t SPR_GOLD_W4_6;
842 extern int16_t SPR_GOLD_W4_7;
843 extern int16_t SPR_GOLD_W4_8;
844 
845 extern int16_t SPR_GOLD_PAIN_1;
846 
847 extern int16_t SPR_GOLD_WRIST_1;
848 extern int16_t SPR_GOLD_WRIST_2;
849 
850 extern int16_t SPR_GOLD_SHOOT1;
851 extern int16_t SPR_GOLD_SHOOT2;
852 extern int16_t SPR_GOLD_SHOOT3;
853 
854 extern int16_t SPR_GOLD_WARP1;
855 extern int16_t SPR_GOLD_WARP2;
856 extern int16_t SPR_GOLD_WARP3;
857 extern int16_t SPR_GOLD_WARP4;
858 extern int16_t SPR_GOLD_WARP5;
859 
860 extern int16_t SPR_GOLD_DEATH1;
861 extern int16_t SPR_GOLD_DEATH2;
862 extern int16_t SPR_GOLD_DEATH3;
863 extern int16_t SPR_GOLD_DEATH4;
864 extern int16_t SPR_GOLD_DEATH5;
865 extern int16_t SPR_MGOLD_OUCH;
866 
867 extern int16_t SPR_GOLD_MORPH1;
868 extern int16_t SPR_GOLD_MORPH2;
869 extern int16_t SPR_GOLD_MORPH3;
870 extern int16_t SPR_GOLD_MORPH4;
871 extern int16_t SPR_GOLD_MORPH5;
872 extern int16_t SPR_GOLD_MORPH6;
873 extern int16_t SPR_GOLD_MORPH7;
874 extern int16_t SPR_GOLD_MORPH8;
875 
876 extern int16_t SPR_MGOLD_WALK1;
877 extern int16_t SPR_MGOLD_WALK2;
878 extern int16_t SPR_MGOLD_WALK3;
879 extern int16_t SPR_MGOLD_WALK4;
880 extern int16_t SPR_MGOLD_ATTACK1;
881 extern int16_t SPR_MGOLD_ATTACK2;
882 extern int16_t SPR_MGOLD_ATTACK3;
883 extern int16_t SPR_MGOLD_ATTACK4;
884 
885 extern int16_t SPR_MGOLD_SHOT1;
886 extern int16_t SPR_MGOLD_SHOT2;
887 extern int16_t SPR_MGOLD_SHOT3;
888 extern int16_t SPR_MGOLD_SHOT_EXP1;
889 extern int16_t SPR_MGOLD_SHOT_EXP2;
890 extern int16_t SPR_MGOLD_SHOT_EXP3;
891 
892 //
893 // Volatile Material Transporter
894 //
895 extern int16_t SPR_GSCOUT_W1_1;
896 extern int16_t SPR_GSCOUT_W1_2;
897 extern int16_t SPR_GSCOUT_W1_3;
898 extern int16_t SPR_GSCOUT_W1_4;
899 extern int16_t SPR_GSCOUT_W1_5;
900 extern int16_t SPR_GSCOUT_W1_6;
901 extern int16_t SPR_GSCOUT_W1_7;
902 extern int16_t SPR_GSCOUT_W1_8;
903 
904 extern int16_t SPR_GSCOUT_W2_1;
905 extern int16_t SPR_GSCOUT_W2_2;
906 extern int16_t SPR_GSCOUT_W2_3;
907 extern int16_t SPR_GSCOUT_W2_4;
908 extern int16_t SPR_GSCOUT_W2_5;
909 extern int16_t SPR_GSCOUT_W2_6;
910 extern int16_t SPR_GSCOUT_W2_7;
911 extern int16_t SPR_GSCOUT_W2_8;
912 
913 extern int16_t SPR_GSCOUT_W3_1;
914 extern int16_t SPR_GSCOUT_W3_2;
915 extern int16_t SPR_GSCOUT_W3_3;
916 extern int16_t SPR_GSCOUT_W3_4;
917 extern int16_t SPR_GSCOUT_W3_5;
918 extern int16_t SPR_GSCOUT_W3_6;
919 extern int16_t SPR_GSCOUT_W3_7;
920 extern int16_t SPR_GSCOUT_W3_8;
921 
922 extern int16_t SPR_GSCOUT_W4_1;
923 extern int16_t SPR_GSCOUT_W4_2;
924 extern int16_t SPR_GSCOUT_W4_3;
925 extern int16_t SPR_GSCOUT_W4_4;
926 extern int16_t SPR_GSCOUT_W4_5;
927 extern int16_t SPR_GSCOUT_W4_6;
928 extern int16_t SPR_GSCOUT_W4_7;
929 extern int16_t SPR_GSCOUT_W4_8;
930 
931 extern int16_t SPR_GSCOUT_DIE1;
932 extern int16_t SPR_GSCOUT_DIE2;
933 extern int16_t SPR_GSCOUT_DIE3;
934 extern int16_t SPR_GSCOUT_DIE4;
935 extern int16_t SPR_GSCOUT_DIE5;
936 extern int16_t SPR_GSCOUT_DIE6;
937 extern int16_t SPR_GSCOUT_DIE7;
938 extern int16_t SPR_GSCOUT_DIE8;
939 
940 extern int16_t SPR_GSCOUT_DEAD;
941 
942 //
943 // Perscan Drone
944 //
945 extern int16_t SPR_FSCOUT_W1_1;
946 extern int16_t SPR_FSCOUT_W1_2;
947 extern int16_t SPR_FSCOUT_W1_3;
948 extern int16_t SPR_FSCOUT_W1_4;
949 extern int16_t SPR_FSCOUT_W1_5;
950 extern int16_t SPR_FSCOUT_W1_6;
951 extern int16_t SPR_FSCOUT_W1_7;
952 extern int16_t SPR_FSCOUT_W1_8;
953 
954 extern int16_t SPR_FSCOUT_W2_1;
955 extern int16_t SPR_FSCOUT_W2_2;
956 extern int16_t SPR_FSCOUT_W2_3;
957 extern int16_t SPR_FSCOUT_W2_4;
958 extern int16_t SPR_FSCOUT_W2_5;
959 extern int16_t SPR_FSCOUT_W2_6;
960 extern int16_t SPR_FSCOUT_W2_7;
961 extern int16_t SPR_FSCOUT_W2_8;
962 
963 extern int16_t SPR_FSCOUT_W3_1;
964 extern int16_t SPR_FSCOUT_W3_2;
965 extern int16_t SPR_FSCOUT_W3_3;
966 extern int16_t SPR_FSCOUT_W3_4;
967 extern int16_t SPR_FSCOUT_W3_5;
968 extern int16_t SPR_FSCOUT_W3_6;
969 extern int16_t SPR_FSCOUT_W3_7;
970 extern int16_t SPR_FSCOUT_W3_8;
971 
972 extern int16_t SPR_FSCOUT_W4_1;
973 extern int16_t SPR_FSCOUT_W4_2;
974 extern int16_t SPR_FSCOUT_W4_3;
975 extern int16_t SPR_FSCOUT_W4_4;
976 extern int16_t SPR_FSCOUT_W4_5;
977 extern int16_t SPR_FSCOUT_W4_6;
978 extern int16_t SPR_FSCOUT_W4_7;
979 extern int16_t SPR_FSCOUT_W4_8;
980 
981 extern int16_t SPR_FSCOUT_DIE1;
982 extern int16_t SPR_FSCOUT_DIE2;
983 extern int16_t SPR_FSCOUT_DIE3;
984 extern int16_t SPR_FSCOUT_DIE4;
985 extern int16_t SPR_FSCOUT_DIE5;
986 extern int16_t SPR_FSCOUT_DIE6;
987 extern int16_t SPR_FSCOUT_DIE7;
988 extern int16_t SPR_FSCOUT_DEAD;
989 
990 //
991 // General Explosion Anim
992 //
993 extern int16_t SPR_EXPLOSION_1;
994 extern int16_t SPR_EXPLOSION_2;
995 extern int16_t SPR_EXPLOSION_3;
996 extern int16_t SPR_EXPLOSION_4;
997 extern int16_t SPR_EXPLOSION_5;
998 
999 //
1000 // Projection Generator
1001 //
1002 extern int16_t SPR_VITAL_STAND;
1003 extern int16_t SPR_VITAL_DIE_1;
1004 extern int16_t SPR_VITAL_DIE_2;
1005 extern int16_t SPR_VITAL_DIE_3;
1006 extern int16_t SPR_VITAL_DIE_4;
1007 extern int16_t SPR_VITAL_DIE_5;
1008 extern int16_t SPR_VITAL_DIE_6;
1009 extern int16_t SPR_VITAL_DIE_7;
1010 extern int16_t SPR_VITAL_DIE_8;
1011 extern int16_t SPR_VITAL_DEAD_1;
1012 extern int16_t SPR_VITAL_DEAD_2;
1013 extern int16_t SPR_VITAL_DEAD_3;
1014 extern int16_t SPR_VITAL_OUCH;
1015 
1016 //
1017 // Security Cube
1018 //
1019 extern int16_t SPR_CUBE1;
1020 extern int16_t SPR_CUBE2;
1021 extern int16_t SPR_CUBE3;
1022 extern int16_t SPR_CUBE4;
1023 extern int16_t SPR_CUBE5;
1024 extern int16_t SPR_CUBE6;
1025 extern int16_t SPR_CUBE7;
1026 extern int16_t SPR_CUBE8;
1027 extern int16_t SPR_CUBE9;
1028 extern int16_t SPR_CUBE10;
1029 extern int16_t SPR_CUBE_EXP1;
1030 extern int16_t SPR_CUBE_EXP2;
1031 extern int16_t SPR_CUBE_EXP3;
1032 extern int16_t SPR_CUBE_EXP4;
1033 extern int16_t SPR_CUBE_EXP5;
1034 extern int16_t SPR_CUBE_EXP6;
1035 extern int16_t SPR_CUBE_EXP7;
1036 extern int16_t SPR_CUBE_EXP8;
1037 extern int16_t SPR_DEAD_CUBE;
1038 
1039 //
1040 // Red Security Lights
1041 //
1042 extern int16_t SPR_SECURITY_NORMAL;
1043 extern int16_t SPR_SECURITY_ALERT;
1044 
1045 //
1046 // P.O.D. Alien
1047 //
1048 extern int16_t SPR_POD_EGG;
1049 extern int16_t SPR_POD_HATCH1;
1050 extern int16_t SPR_POD_HATCH2;
1051 extern int16_t SPR_POD_HATCH3;
1052 extern int16_t SPR_POD_WALK1;
1053 extern int16_t SPR_POD_WALK2;
1054 extern int16_t SPR_POD_WALK3;
1055 extern int16_t SPR_POD_WALK4;
1056 extern int16_t SPR_POD_ATTACK1;
1057 extern int16_t SPR_POD_ATTACK2;
1058 extern int16_t SPR_POD_ATTACK3;
1059 extern int16_t SPR_POD_OUCH;
1060 extern int16_t SPR_POD_DIE1;
1061 extern int16_t SPR_POD_DIE2;
1062 extern int16_t SPR_POD_DIE3;
1063 extern int16_t SPR_POD_SPIT1;
1064 extern int16_t SPR_POD_SPIT2;
1065 extern int16_t SPR_POD_SPIT3;
1066 
1067 //
1068 // Electro-Alien
1069 //
1070 extern int16_t SPR_ELEC_APPEAR1;
1071 extern int16_t SPR_ELEC_APPEAR2;
1072 extern int16_t SPR_ELEC_APPEAR3;
1073 extern int16_t SPR_ELEC_WALK1;
1074 extern int16_t SPR_ELEC_WALK2;
1075 extern int16_t SPR_ELEC_WALK3;
1076 extern int16_t SPR_ELEC_WALK4;
1077 extern int16_t SPR_ELEC_OUCH;
1078 extern int16_t SPR_ELEC_SHOOT1;
1079 extern int16_t SPR_ELEC_SHOOT2;
1080 extern int16_t SPR_ELEC_SHOOT3;
1081 extern int16_t SPR_ELEC_DIE1;
1082 extern int16_t SPR_ELEC_DIE2;
1083 extern int16_t SPR_ELEC_DIE3;
1084 extern int16_t SPR_ELEC_SHOT1;
1085 extern int16_t SPR_ELEC_SHOT2;
1086 extern int16_t SPR_ELEC_SHOT_EXP1;
1087 extern int16_t SPR_ELEC_SHOT_EXP2;
1088 
1089 //
1090 // ElectroSphere
1091 //
1092 extern int16_t SPR_ELECTRO_SPHERE_ROAM1;
1093 extern int16_t SPR_ELECTRO_SPHERE_ROAM2;
1094 extern int16_t SPR_ELECTRO_SPHERE_ROAM3;
1095 extern int16_t SPR_ELECTRO_SPHERE_OUCH;
1096 extern int16_t SPR_ELECTRO_SPHERE_DIE1;
1097 extern int16_t SPR_ELECTRO_SPHERE_DIE2;
1098 extern int16_t SPR_ELECTRO_SPHERE_DIE3;
1099 extern int16_t SPR_ELECTRO_SPHERE_DIE4;
1100 
1101 //
1102 // Genetic Guard
1103 //
1104 extern int16_t SPR_GENETIC_W1;
1105 extern int16_t SPR_GENETIC_W2;
1106 extern int16_t SPR_GENETIC_W3;
1107 extern int16_t SPR_GENETIC_W4;
1108 extern int16_t SPR_GENETIC_SWING1;
1109 extern int16_t SPR_GENETIC_SWING2;
1110 extern int16_t SPR_GENETIC_SWING3;
1111 extern int16_t SPR_GENETIC_DEAD;
1112 extern int16_t SPR_GENETIC_DIE1;
1113 extern int16_t SPR_GENETIC_DIE2;
1114 extern int16_t SPR_GENETIC_DIE3;
1115 extern int16_t SPR_GENETIC_DIE4;
1116 extern int16_t SPR_GENETIC_OUCH;
1117 extern int16_t SPR_GENETIC_SHOOT1;
1118 extern int16_t SPR_GENETIC_SHOOT2;
1119 extern int16_t SPR_GENETIC_SHOOT3;
1120 
1121 //
1122 // Experimental Mech-Sentinel
1123 //
1124 extern int16_t SPR_MUTHUM1_W1;
1125 extern int16_t SPR_MUTHUM1_W2;
1126 extern int16_t SPR_MUTHUM1_W3;
1127 extern int16_t SPR_MUTHUM1_W4;
1128 extern int16_t SPR_MUTHUM1_SWING1;
1129 extern int16_t SPR_MUTHUM1_SWING2;
1130 extern int16_t SPR_MUTHUM1_SWING3;
1131 extern int16_t SPR_MUTHUM1_DEAD;
1132 extern int16_t SPR_MUTHUM1_DIE1;
1133 extern int16_t SPR_MUTHUM1_DIE2;
1134 extern int16_t SPR_MUTHUM1_DIE3;
1135 extern int16_t SPR_MUTHUM1_DIE4;
1136 extern int16_t SPR_MUTHUM1_OUCH;
1137 extern int16_t SPR_MUTHUM1_SPIT1;
1138 extern int16_t SPR_MUTHUM1_SPIT2;
1139 extern int16_t SPR_MUTHUM1_SPIT3;
1140 
1141 //
1142 // Muntant human type 2
1143 //
1144 extern int16_t SPR_MUTHUM2_W1;
1145 extern int16_t SPR_MUTHUM2_W2;
1146 extern int16_t SPR_MUTHUM2_W3;
1147 extern int16_t SPR_MUTHUM2_W4;
1148 extern int16_t SPR_MUTHUM2_SWING1;
1149 extern int16_t SPR_MUTHUM2_SWING2;
1150 extern int16_t SPR_MUTHUM2_SWING3;
1151 extern int16_t SPR_MUTHUM2_DEAD;
1152 extern int16_t SPR_MUTHUM2_DIE1;
1153 extern int16_t SPR_MUTHUM2_DIE2;
1154 extern int16_t SPR_MUTHUM2_DIE3;
1155 extern int16_t SPR_MUTHUM2_DIE4;
1156 extern int16_t SPR_MUTHUM2_OUCH;
1157 extern int16_t SPR_MUTHUM2_SPIT1;
1158 extern int16_t SPR_MUTHUM2_SPIT2;
1159 extern int16_t SPR_MUTHUM2_SPIT3;
1160 
1161 extern int16_t SPR_MUTHUM2_MORPH1;
1162 extern int16_t SPR_MUTHUM2_MORPH2;
1163 extern int16_t SPR_MUTHUM2_MORPH3;
1164 extern int16_t SPR_MUTHUM2_MORPH4;
1165 extern int16_t SPR_MUTHUM2_MORPH5;
1166 extern int16_t SPR_MUTHUM2_MORPH6;
1167 extern int16_t SPR_MUTHUM2_MORPH7;
1168 extern int16_t SPR_MUTHUM2_MORPH8;
1169 extern int16_t SPR_MUTHUM2_MORPH9;
1170 
1171 //
1172 // Large Cantained Alien
1173 //
1174 extern int16_t SPR_LCAN_ALIEN_READY;
1175 extern int16_t SPR_LCAN_ALIEN_B1;
1176 extern int16_t SPR_LCAN_ALIEN_B2;
1177 extern int16_t SPR_LCAN_ALIEN_B3;
1178 extern int16_t SPR_LCAN_ALIEN_EMPTY;
1179 
1180 extern int16_t SPR_LCAN_ALIEN_W1;
1181 extern int16_t SPR_LCAN_ALIEN_W2;
1182 extern int16_t SPR_LCAN_ALIEN_W3;
1183 extern int16_t SPR_LCAN_ALIEN_W4;
1184 extern int16_t SPR_LCAN_ALIEN_SWING1;
1185 extern int16_t SPR_LCAN_ALIEN_SWING2;
1186 extern int16_t SPR_LCAN_ALIEN_SWING3;
1187 extern int16_t SPR_LCAN_ALIEN_DEAD;
1188 extern int16_t SPR_LCAN_ALIEN_DIE1;
1189 extern int16_t SPR_LCAN_ALIEN_DIE2;
1190 extern int16_t SPR_LCAN_ALIEN_DIE3;
1191 extern int16_t SPR_LCAN_ALIEN_DIE4;
1192 extern int16_t SPR_LCAN_ALIEN_OUCH;
1193 extern int16_t SPR_LCAN_ALIEN_SPIT1;
1194 extern int16_t SPR_LCAN_ALIEN_SPIT2;
1195 extern int16_t SPR_LCAN_ALIEN_SPIT3;
1196 
1197 //
1198 // Small Canister Alien
1199 //
1200 extern int16_t SPR_SCAN_ALIEN_READY;
1201 extern int16_t SPR_SCAN_ALIEN_B1;
1202 extern int16_t SPR_SCAN_ALIEN_B2;
1203 extern int16_t SPR_SCAN_ALIEN_B3;
1204 extern int16_t SPR_SCAN_ALIEN_EMPTY;
1205 
1206 extern int16_t SPR_SCAN_ALIEN_W1;
1207 extern int16_t SPR_SCAN_ALIEN_W2;
1208 extern int16_t SPR_SCAN_ALIEN_W3;
1209 extern int16_t SPR_SCAN_ALIEN_W4;
1210 extern int16_t SPR_SCAN_ALIEN_SWING1;
1211 extern int16_t SPR_SCAN_ALIEN_SWING2;
1212 extern int16_t SPR_SCAN_ALIEN_SWING3;
1213 extern int16_t SPR_SCAN_ALIEN_DEAD;
1214 extern int16_t SPR_SCAN_ALIEN_DIE1;
1215 extern int16_t SPR_SCAN_ALIEN_DIE2;
1216 extern int16_t SPR_SCAN_ALIEN_DIE3;
1217 extern int16_t SPR_SCAN_ALIEN_DIE4;
1218 extern int16_t SPR_SCAN_ALIEN_OUCH;
1219 
1220 extern int16_t SPR_SCAN_ALIEN_SPIT1;
1221 extern int16_t SPR_SCAN_ALIEN_SPIT2;
1222 extern int16_t SPR_SCAN_ALIEN_SPIT3;
1223 
1224 //
1225 // Gurney Mutant
1226 //
1227 extern int16_t SPR_GURNEY_MUT_READY;
1228 extern int16_t SPR_GURNEY_MUT_B1;
1229 extern int16_t SPR_GURNEY_MUT_B2;
1230 extern int16_t SPR_GURNEY_MUT_B3;
1231 extern int16_t SPR_GURNEY_MUT_EMPTY;
1232 
1233 extern int16_t SPR_GURNEY_MUT_W1;
1234 extern int16_t SPR_GURNEY_MUT_W2;
1235 extern int16_t SPR_GURNEY_MUT_W3;
1236 extern int16_t SPR_GURNEY_MUT_W4;
1237 extern int16_t SPR_GURNEY_MUT_SWING1;
1238 extern int16_t SPR_GURNEY_MUT_SWING2;
1239 extern int16_t SPR_GURNEY_MUT_SWING3;
1240 extern int16_t SPR_GURNEY_MUT_DEAD;
1241 extern int16_t SPR_GURNEY_MUT_DIE1;
1242 extern int16_t SPR_GURNEY_MUT_DIE2;
1243 extern int16_t SPR_GURNEY_MUT_DIE3;
1244 extern int16_t SPR_GURNEY_MUT_DIE4;
1245 extern int16_t SPR_GURNEY_MUT_OUCH;
1246 
1247 //
1248 // Liquid Alien
1249 //
1250 extern int16_t SPR_LIQUID_M1;
1251 extern int16_t SPR_LIQUID_M2;
1252 extern int16_t SPR_LIQUID_M3;
1253 extern int16_t SPR_LIQUID_R1;
1254 extern int16_t SPR_LIQUID_R2;
1255 extern int16_t SPR_LIQUID_R3;
1256 extern int16_t SPR_LIQUID_R4;
1257 extern int16_t SPR_LIQUID_S1;
1258 extern int16_t SPR_LIQUID_S2;
1259 extern int16_t SPR_LIQUID_S3;
1260 extern int16_t SPR_LIQUID_OUCH;
1261 extern int16_t SPR_LIQUID_DIE_1;
1262 extern int16_t SPR_LIQUID_DIE_2;
1263 extern int16_t SPR_LIQUID_DIE_3;
1264 extern int16_t SPR_LIQUID_DIE_4;
1265 extern int16_t SPR_LIQUID_DEAD;
1266 extern int16_t SPR_LIQUID_SHOT_FLY_1;
1267 extern int16_t SPR_LIQUID_SHOT_FLY_2;
1268 extern int16_t SPR_LIQUID_SHOT_FLY_3;
1269 extern int16_t SPR_LIQUID_SHOT_BURST_1;
1270 extern int16_t SPR_LIQUID_SHOT_BURST_2;
1271 extern int16_t SPR_LIQUID_SHOT_BURST_3;
1272 
1273 //
1274 // Spit Shots
1275 //
1276 extern int16_t SPR_SPIT1_1;
1277 extern int16_t SPR_SPIT1_2;
1278 extern int16_t SPR_SPIT1_3;
1279 extern int16_t SPR_SPIT_EXP1_1;
1280 extern int16_t SPR_SPIT_EXP1_2;
1281 extern int16_t SPR_SPIT_EXP1_3;
1282 
1283 extern int16_t SPR_SPIT2_1;
1284 extern int16_t SPR_SPIT2_2;
1285 extern int16_t SPR_SPIT2_3;
1286 extern int16_t SPR_SPIT_EXP2_1;
1287 extern int16_t SPR_SPIT_EXP2_2;
1288 extern int16_t SPR_SPIT_EXP2_3;
1289 
1290 extern int16_t SPR_SPIT3_1;
1291 extern int16_t SPR_SPIT3_2;
1292 extern int16_t SPR_SPIT3_3;
1293 extern int16_t SPR_SPIT_EXP3_1;
1294 extern int16_t SPR_SPIT_EXP3_2;
1295 extern int16_t SPR_SPIT_EXP3_3;
1296 
1297 //
1298 // Hanging Turret
1299 //
1300 extern int16_t SPR_TERROT_1;
1301 extern int16_t SPR_TERROT_2;
1302 extern int16_t SPR_TERROT_3;
1303 extern int16_t SPR_TERROT_4;
1304 extern int16_t SPR_TERROT_5;
1305 extern int16_t SPR_TERROT_6;
1306 extern int16_t SPR_TERROT_7;
1307 extern int16_t SPR_TERROT_8;
1308 
1309 extern int16_t SPR_TERROT_FIRE_1;
1310 extern int16_t SPR_TERROT_FIRE_2;
1311 extern int16_t SPR_TERROT_DIE_1;
1312 extern int16_t SPR_TERROT_DIE_2;
1313 extern int16_t SPR_TERROT_DIE_3;
1314 extern int16_t SPR_TERROT_DIE_4;
1315 extern int16_t SPR_TERROT_DEAD;
1316 
1317 //
1318 // Player attack frames
1319 //
1320 extern int16_t SPR_KNIFEREADY;
1321 extern int16_t SPR_KNIFEATK1;
1322 extern int16_t SPR_KNIFEATK2;
1323 extern int16_t SPR_KNIFEATK3;
1324 extern int16_t SPR_KNIFEATK4;
1325 
1326 extern int16_t SPR_PISTOLREADY;
1327 extern int16_t SPR_PISTOLATK1;
1328 extern int16_t SPR_PISTOLATK2;
1329 extern int16_t SPR_PISTOLATK3;
1330 extern int16_t SPR_PISTOLATK4;
1331 
1332 extern int16_t SPR_MACHINEGUNREADY;
1333 extern int16_t SPR_MACHINEGUNATK1;
1334 extern int16_t SPR_MACHINEGUNATK2;
1335 extern int16_t SPR_MACHINEGUNATK3;
1336 extern int16_t SPR_MACHINEGUNATK4;
1337 
1338 extern int16_t SPR_CHAINREADY;
1339 extern int16_t SPR_CHAINATK1;
1340 extern int16_t SPR_CHAINATK2;
1341 extern int16_t SPR_CHAINATK3;
1342 extern int16_t SPR_CHAINATK4;
1343 
1344 extern int16_t SPR_GRENADEREADY;
1345 extern int16_t SPR_GRENADEATK1;
1346 extern int16_t SPR_GRENADEATK2;
1347 extern int16_t SPR_GRENADEATK3;
1348 extern int16_t SPR_GRENADEATK4;
1349 
1350 extern int16_t SPR_GRENADE_FLY1;
1351 extern int16_t SPR_GRENADE_FLY2;
1352 extern int16_t SPR_GRENADE_FLY3;
1353 extern int16_t SPR_GRENADE_FLY4;
1354 extern int16_t SPR_GRENADE_EXPLODE1;
1355 extern int16_t SPR_GRENADE_EXPLODE2;
1356 extern int16_t SPR_GRENADE_EXPLODE3;
1357 extern int16_t SPR_GRENADE_EXPLODE4;
1358 extern int16_t SPR_GRENADE_EXPLODE5;
1359 
1360 extern int16_t SPR_ELEC_ARC1;
1361 extern int16_t SPR_ELEC_ARC2;
1362 extern int16_t SPR_ELEC_ARC3;
1363 extern int16_t SPR_ELEC_ARC4;
1364 extern int16_t SPR_ELEC_POST1;
1365 extern int16_t SPR_ELEC_POST2;
1366 extern int16_t SPR_ELEC_POST3;
1367 extern int16_t SPR_ELEC_POST4;
1368 
1369 extern int16_t SPR_VPOST1;
1370 extern int16_t SPR_VPOST2;
1371 extern int16_t SPR_VPOST3;
1372 extern int16_t SPR_VPOST4;
1373 extern int16_t SPR_VPOST5;
1374 extern int16_t SPR_VPOST6;
1375 extern int16_t SPR_VPOST7;
1376 extern int16_t SPR_VPOST8;
1377 
1378 extern int16_t SPR_VSPIKE1;
1379 extern int16_t SPR_VSPIKE2;
1380 extern int16_t SPR_VSPIKE3;
1381 extern int16_t SPR_VSPIKE4;
1382 extern int16_t SPR_VSPIKE5;
1383 extern int16_t SPR_VSPIKE6;
1384 extern int16_t SPR_VSPIKE7;
1385 extern int16_t SPR_VSPIKE8;
1386 
1387 extern int16_t SPR_GREEN_OOZE1;
1388 extern int16_t SPR_GREEN_OOZE2;
1389 extern int16_t SPR_GREEN_OOZE3;
1390 extern int16_t SPR_BLACK_OOZE1;
1391 extern int16_t SPR_BLACK_OOZE2;
1392 extern int16_t SPR_BLACK_OOZE3;
1393 
1394 extern int16_t SPR_GREEN2_OOZE1;
1395 extern int16_t SPR_GREEN2_OOZE2;
1396 extern int16_t SPR_GREEN2_OOZE3;
1397 extern int16_t SPR_BLACK2_OOZE1;
1398 extern int16_t SPR_BLACK2_OOZE2;
1399 extern int16_t SPR_BLACK2_OOZE3;
1400 
1401 extern int16_t SPR_CANDY_BAR;
1402 extern int16_t SPR_CANDY_WRAPER;
1403 extern int16_t SPR_SANDWICH;
1404 extern int16_t SPR_SANDWICH_WRAPER;
1405 
1406 extern int16_t SPR_BLAKE_W1;
1407 extern int16_t SPR_BLAKE_W2;
1408 extern int16_t SPR_BLAKE_W3;
1409 extern int16_t SPR_BLAKE_W4;
1410 
1411 //
1412 // Boss 1 (Spider Mutant)
1413 //
1414 extern int16_t SPR_BOSS1_W1;
1415 extern int16_t SPR_BOSS1_W2;
1416 extern int16_t SPR_BOSS1_W3;
1417 extern int16_t SPR_BOSS1_W4;
1418 extern int16_t SPR_BOSS1_SWING1;
1419 extern int16_t SPR_BOSS1_SWING2;
1420 extern int16_t SPR_BOSS1_SWING3;
1421 extern int16_t SPR_BOSS1_DEAD;
1422 extern int16_t SPR_BOSS1_DIE1;
1423 extern int16_t SPR_BOSS1_DIE2;
1424 extern int16_t SPR_BOSS1_DIE3;
1425 extern int16_t SPR_BOSS1_DIE4;
1426 extern int16_t SPR_BOSS1_OUCH;
1427 extern int16_t SPR_BOSS1_PROJ1;
1428 extern int16_t SPR_BOSS1_PROJ2;
1429 extern int16_t SPR_BOSS1_PROJ3;
1430 extern int16_t SPR_BOSS1_EXP1;
1431 extern int16_t SPR_BOSS1_EXP2;
1432 extern int16_t SPR_BOSS1_EXP3;
1433 extern int16_t SPR_BOSS1_MORPH1;
1434 extern int16_t SPR_BOSS1_MORPH2;
1435 extern int16_t SPR_BOSS1_MORPH3;
1436 extern int16_t SPR_BOSS1_MORPH4;
1437 extern int16_t SPR_BOSS1_MORPH5;
1438 extern int16_t SPR_BOSS1_MORPH6;
1439 extern int16_t SPR_BOSS1_MORPH7;
1440 extern int16_t SPR_BOSS1_MORPH8;
1441 extern int16_t SPR_BOSS1_MORPH9;
1442 
1443 //
1444 // Boss 2 (Breather Beast)
1445 //
1446 extern int16_t SPR_BOSS2_W1;
1447 extern int16_t SPR_BOSS2_W2;
1448 extern int16_t SPR_BOSS2_W3;
1449 extern int16_t SPR_BOSS2_W4;
1450 extern int16_t SPR_BOSS2_SWING1;
1451 extern int16_t SPR_BOSS2_SWING2;
1452 extern int16_t SPR_BOSS2_SWING3;
1453 extern int16_t SPR_BOSS2_DEAD;
1454 extern int16_t SPR_BOSS2_DIE1;
1455 extern int16_t SPR_BOSS2_DIE2;
1456 extern int16_t SPR_BOSS2_DIE3;
1457 extern int16_t SPR_BOSS2_DIE4;
1458 extern int16_t SPR_BOSS2_OUCH;
1459 
1460 //
1461 // Boss 3 (Cyborg Warrior)
1462 //
1463 extern int16_t SPR_BOSS3_W1;
1464 extern int16_t SPR_BOSS3_W2;
1465 extern int16_t SPR_BOSS3_W3;
1466 extern int16_t SPR_BOSS3_W4;
1467 extern int16_t SPR_BOSS3_SWING1;
1468 extern int16_t SPR_BOSS3_SWING2;
1469 extern int16_t SPR_BOSS3_SWING3;
1470 extern int16_t SPR_BOSS3_DEAD;
1471 extern int16_t SPR_BOSS3_DIE1;
1472 extern int16_t SPR_BOSS3_DIE2;
1473 extern int16_t SPR_BOSS3_DIE3;
1474 extern int16_t SPR_BOSS3_DIE4;
1475 extern int16_t SPR_BOSS3_OUCH;
1476 
1477 //
1478 // Boss 4 (Reptilian Warrior)
1479 //
1480 extern int16_t SPR_BOSS4_W1;
1481 extern int16_t SPR_BOSS4_W2;
1482 extern int16_t SPR_BOSS4_W3;
1483 extern int16_t SPR_BOSS4_W4;
1484 extern int16_t SPR_BOSS4_SWING1;
1485 extern int16_t SPR_BOSS4_SWING2;
1486 extern int16_t SPR_BOSS4_SWING3;
1487 extern int16_t SPR_BOSS4_DEAD;
1488 extern int16_t SPR_BOSS4_DIE1;
1489 extern int16_t SPR_BOSS4_DIE2;
1490 extern int16_t SPR_BOSS4_DIE3;
1491 extern int16_t SPR_BOSS4_DIE4;
1492 extern int16_t SPR_BOSS4_OUCH;
1493 extern int16_t SPR_BOSS4_MORPH1;
1494 extern int16_t SPR_BOSS4_MORPH2;
1495 extern int16_t SPR_BOSS4_MORPH3;
1496 extern int16_t SPR_BOSS4_MORPH4;
1497 extern int16_t SPR_BOSS4_MORPH5;
1498 extern int16_t SPR_BOSS4_MORPH6;
1499 extern int16_t SPR_BOSS4_MORPH7;
1500 extern int16_t SPR_BOSS4_MORPH8;
1501 extern int16_t SPR_BOSS4_MORPH9;
1502 
1503 //
1504 // Boss 5 (Acid Dragon)
1505 //
1506 extern int16_t SPR_BOSS5_W1;
1507 extern int16_t SPR_BOSS5_W2;
1508 extern int16_t SPR_BOSS5_W3;
1509 extern int16_t SPR_BOSS5_W4;
1510 extern int16_t SPR_BOSS5_SWING1;
1511 extern int16_t SPR_BOSS5_SWING2;
1512 extern int16_t SPR_BOSS5_SWING3;
1513 extern int16_t SPR_BOSS5_DEAD;
1514 extern int16_t SPR_BOSS5_DIE1;
1515 extern int16_t SPR_BOSS5_DIE2;
1516 extern int16_t SPR_BOSS5_DIE3;
1517 extern int16_t SPR_BOSS5_DIE4;
1518 extern int16_t SPR_BOSS5_OUCH;
1519 extern int16_t SPR_BOSS5_PROJ1;
1520 extern int16_t SPR_BOSS5_PROJ2;
1521 extern int16_t SPR_BOSS5_PROJ3;
1522 extern int16_t SPR_BOSS5_EXP1;
1523 extern int16_t SPR_BOSS5_EXP2;
1524 extern int16_t SPR_BOSS5_EXP3;
1525 
1526 //
1527 // Boss 6 (Bio-Mech Guardian)
1528 //
1529 extern int16_t SPR_BOSS6_W1;
1530 extern int16_t SPR_BOSS6_W2;
1531 extern int16_t SPR_BOSS6_W3;
1532 extern int16_t SPR_BOSS6_W4;
1533 extern int16_t SPR_BOSS6_SWING1;
1534 extern int16_t SPR_BOSS6_SWING2;
1535 extern int16_t SPR_BOSS6_SWING3;
1536 extern int16_t SPR_BOSS6_DEAD;
1537 extern int16_t SPR_BOSS6_DIE1;
1538 extern int16_t SPR_BOSS6_DIE2;
1539 extern int16_t SPR_BOSS6_DIE3;
1540 extern int16_t SPR_BOSS6_DIE4;
1541 extern int16_t SPR_BOSS6_OUCH;
1542 
1543 
1544 //
1545 // Boss 7
1546 //
1547 extern int16_t SPR_BOSS7_W1;
1548 extern int16_t SPR_BOSS7_W2;
1549 extern int16_t SPR_BOSS7_W3;
1550 extern int16_t SPR_BOSS7_W4;
1551 extern int16_t SPR_BOSS7_SHOOT1;
1552 extern int16_t SPR_BOSS7_SHOOT2;
1553 extern int16_t SPR_BOSS7_SHOOT3;
1554 extern int16_t SPR_BOSS7_DEAD;
1555 extern int16_t SPR_BOSS7_DIE1;
1556 extern int16_t SPR_BOSS7_DIE2;
1557 extern int16_t SPR_BOSS7_DIE3;
1558 extern int16_t SPR_BOSS7_DIE4;
1559 extern int16_t SPR_BOSS7_OUCH;
1560 
1561 //
1562 // Boss 8
1563 //
1564 extern int16_t SPR_BOSS8_W1;
1565 extern int16_t SPR_BOSS8_W2;
1566 extern int16_t SPR_BOSS8_W3;
1567 extern int16_t SPR_BOSS8_W4;
1568 extern int16_t SPR_BOSS8_SHOOT1;
1569 extern int16_t SPR_BOSS8_SHOOT2;
1570 extern int16_t SPR_BOSS8_SHOOT3;
1571 extern int16_t SPR_BOSS8_DIE1;
1572 extern int16_t SPR_BOSS8_DIE2;
1573 extern int16_t SPR_BOSS8_DIE3;
1574 extern int16_t SPR_BOSS8_DIE4;
1575 extern int16_t SPR_BOSS8_DEAD;
1576 extern int16_t SPR_BOSS8_OUCH;
1577 
1578 //
1579 // Boss 9
1580 //
1581 extern int16_t SPR_BOSS9_W1;
1582 extern int16_t SPR_BOSS9_W2;
1583 extern int16_t SPR_BOSS9_W3;
1584 extern int16_t SPR_BOSS9_W4;
1585 extern int16_t SPR_BOSS9_SHOOT1;
1586 extern int16_t SPR_BOSS9_SHOOT2;
1587 extern int16_t SPR_BOSS9_SHOOT3;
1588 extern int16_t SPR_BOSS9_DIE1;
1589 extern int16_t SPR_BOSS9_DIE2;
1590 extern int16_t SPR_BOSS9_DIE3;
1591 extern int16_t SPR_BOSS9_DIE4;
1592 extern int16_t SPR_BOSS9_DEAD;
1593 extern int16_t SPR_BOSS9_OUCH;
1594 
1595 //
1596 // Boss 10
1597 //
1598 extern int16_t SPR_BOSS10_W1;
1599 extern int16_t SPR_BOSS10_W2;
1600 extern int16_t SPR_BOSS10_W3;
1601 extern int16_t SPR_BOSS10_W4;
1602 extern int16_t SPR_BOSS10_SHOOT1;
1603 extern int16_t SPR_BOSS10_SHOOT2;
1604 extern int16_t SPR_BOSS10_SHOOT3;
1605 extern int16_t SPR_BOSS10_DEAD;
1606 extern int16_t SPR_BOSS10_DIE1;
1607 extern int16_t SPR_BOSS10_DIE2;
1608 extern int16_t SPR_BOSS10_DIE3;
1609 extern int16_t SPR_BOSS10_DIE4;
1610 extern int16_t SPR_BOSS10_OUCH;
1611 
1612 extern int16_t SPR_BOSS10_SPIT1;
1613 extern int16_t SPR_BOSS10_SPIT2;
1614 extern int16_t SPR_BOSS10_SPIT3;
1615 extern int16_t SPR_BOSS10_SPIT_EXP1;
1616 extern int16_t SPR_BOSS10_SPIT_EXP2;
1617 extern int16_t SPR_BOSS10_SPIT_EXP3;
1618 
1619 //
1620 // Plasma detonator explosion
1621 //
1622 extern int16_t SPR_DETONATOR_EXP1;
1623 extern int16_t SPR_DETONATOR_EXP2;
1624 extern int16_t SPR_DETONATOR_EXP3;
1625 extern int16_t SPR_DETONATOR_EXP4;
1626 extern int16_t SPR_DETONATOR_EXP5;
1627 extern int16_t SPR_DETONATOR_EXP6;
1628 extern int16_t SPR_DETONATOR_EXP7;
1629 extern int16_t SPR_DETONATOR_EXP8;
1630 
1631 //
1632 // Clip Explosion
1633 //
1634 extern int16_t SPR_CLIP_EXP1;
1635 extern int16_t SPR_CLIP_EXP2;
1636 extern int16_t SPR_CLIP_EXP3;
1637 extern int16_t SPR_CLIP_EXP4;
1638 extern int16_t SPR_CLIP_EXP5;
1639 extern int16_t SPR_CLIP_EXP6;
1640 extern int16_t SPR_CLIP_EXP7;
1641 extern int16_t SPR_CLIP_EXP8;
1642 
1643 //
1644 // BFG Cannon Weapon
1645 //
1646 extern int16_t SPR_BFG_WEAPON1;
1647 extern int16_t SPR_BFG_WEAPON2;
1648 extern int16_t SPR_BFG_WEAPON3;
1649 extern int16_t SPR_BFG_WEAPON4;
1650 extern int16_t SPR_BFG_WEAPON5;
1651 
1652 //
1653 // BFG Cannon Weapon shots
1654 //
1655 extern int16_t SPR_BFG_WEAPON_SHOT1;
1656 extern int16_t SPR_BFG_WEAPON_SHOT2;
1657 extern int16_t SPR_BFG_WEAPON_SHOT3;
1658 
1659 //
1660 // BFG Shot explosion
1661 //
1662 extern int16_t SPR_BFG_EXP1;
1663 extern int16_t SPR_BFG_EXP2;
1664 extern int16_t SPR_BFG_EXP3;
1665 extern int16_t SPR_BFG_EXP4;
1666 extern int16_t SPR_BFG_EXP5;
1667 extern int16_t SPR_BFG_EXP6;
1668 extern int16_t SPR_BFG_EXP7;
1669 extern int16_t SPR_BFG_EXP8;
1670 
1671 
1672 //
1673 // Door Objects
1674 //
1675 enum doortype {
1676     // LOCKED DOORS
1677 
1678     L_METAL,
1679     L_METAL_SHADE,
1680 
1681     L_BIO,
1682     L_BIO_SHADE,
1683 
1684     L_ELEVATOR,
1685     L_ELEVATOR_SHADE,
1686 
1687     L_SPACE,
1688     L_SPACE_SHADE,
1689 
1690     L_PRISON,
1691     L_PRISON_SHADE,
1692 
1693     L_HIGH_SECURITY,
1694     L_HIGH_SECURITY_SHADE,
1695 
1696     L_ENTER_ONLY,
1697     L_ENTER_ONLY_SHADE,
1698 
1699     L_HIGH_TECH,
1700     L_HIGH_TECH_SHADE,
1701 
1702 
1703     // UNLOCKED DOORS
1704 
1705     UL_METAL,
1706     UL_METAL_SHADE,
1707 
1708     UL_BIO,
1709     UL_BIO_SHADE,
1710 
1711     UL_ELEVATOR,
1712     UL_ELEVATOR_SHADE,
1713 
1714     UL_SPACE,
1715     UL_SPACE_SHADE,
1716 
1717     UL_PRISON,
1718     UL_PRISON_SHADE,
1719 
1720     UL_HIGH_SECURITY,
1721     UL_HIGH_SECURITY_SHADE,
1722 
1723     UL_ENTER_ONLY,
1724     UL_ENTER_ONLY_SHADE,
1725 
1726     UL_HIGH_TECH,
1727     UL_HIGH_TECH_SHADE,
1728 
1729 
1730     // MISC DOORS
1731 
1732     NOEXIT,
1733     NOEXIT_SHADE,
1734 
1735     STEEL_JAM,
1736     STEEL_JAM_SHADE,
1737 
1738     SPACE_JAM,
1739     SPACE_JAM_SHADE,
1740 
1741     OFFICE_JAM,
1742     OFFICE_JAM_SHADE,
1743 
1744     BIO_JAM,
1745     BIO_JAM_SHADE,
1746 
1747     SPACE_JAM_2,
1748     SPACE_JAM_2_SHADE,
1749 
1750 
1751     // END OF DOOR LIST
1752     NUMDOORTYPES,
1753 }; // doortype
1754 
1755 
1756 //
1757 // Breifing types - Note these are ordered to an char array in Breifing().
1758 //
1759 enum breifing_type {
1760     BT_LOSE,
1761     BT_WIN,
1762     BT_INTRO
1763 }; // breifing_type
1764 
1765 
1766 //
1767 // Barrier State Transistions
1768 //
1769 enum barrier_state_type {
1770     bt_OFF,
1771     bt_ON,
1772     bt_DISABLING,
1773     bt_DISABLED,
1774     bt_OPENING, // For physical barriers
1775     bt_CLOSING, //            " " "
1776 }; // barrier_state_type
1777 
1778 
1779 /*
1780 =============================================================================
1781 
1782  GLOBAL TYPES
1783 
1784 =============================================================================
1785 */
1786 
1787 using fixed = int32_t;
1788 
1789 // Display priority is determined by the order of these bits!
1790 // And, this order must match the PinballBonus table in AGENT.C!
1791 //
1792 #define B_GALIEN_DESTROYED 0x0001
1793 #define B_SCORE_ROLLED 0x0002
1794 #define B_ONE_MILLION 0x0004
1795 #define B_EXTRA_MAN 0x0008
1796 #define B_ENEMY_DESTROYED 0x0010
1797 #define B_TOTAL_POINTS 0x0020
1798 #define B_INFORMANTS_ALIVE 0x0040
1799 
1800 #define BONUS_QUEUE gamestuff.level[gamestate.mapon].bonus_queue
1801 #define BONUS_SHOWN gamestuff.level[gamestate.mapon].bonus_shown
1802 
1803 #define PinballBonusShown(bonus) (BONUS_SHOWN & bonus)
1804 #define ActivatePinballBonus(bonus) if (!PinballBonusShown(bonus))BONUS_QUEUE |= bonus
1805 
1806 struct PinballBonusInfo {
1807     char* BonusText; // REBA text pointer
1808     int32_t Points; // Score for this bonus
1809     bool Recurring; // Appear multiple times in a single level?
1810     void (* func)(); // Code to execute when you get this bonus.
1811 }; // PinballBonusInfo
1812 
1813 struct atkinf_t {
1814     int8_t tics;
1815     int8_t attack;
1816     int8_t frame; // attack is 1 for gun, 2 for knife
1817 }; // atkinf_t
1818 
1819 
1820 // NOTE - This enum list is ORDERED!
1821 enum movie_t {
1822     mv_intro,
1823     mv_final,
1824     mv_final2, // AOG Episode 3/5
1825     mv_final3, // AOG Episode 6
1826     mv_NUM_MOVIES,
1827 }; // movie_t
1828 
1829 enum controldir_t {
1830     di_north,
1831     di_east,
1832     di_south,
1833     di_west
1834 }; // controldir_t
1835 
1836 // NOTE - This enum list is ORDERED!
1837 enum door_t {
1838     dr_bio,
1839     dr_normal,
1840     dr_prison,
1841     dr_elevator,
1842     dr_high_security,
1843     dr_office,
1844     dr_oneway_left,
1845     dr_oneway_up,
1846     dr_oneway_right,
1847     dr_oneway_down,
1848     dr_space
1849 }; // door_t
1850 
1851 enum keytype {
1852     kt_none = -1,
1853     kt_red,
1854     kt_yellow,
1855     kt_blue,
1856     kt_green,
1857     kt_gold,
1858     NUMKEYS,
1859 }; // keytype
1860 
1861 enum activetype {
1862     ac_badobject = -1,
1863     ac_no,
1864     ac_yes,
1865     ac_allways
1866 }; // activetype
1867 
1868 enum classtype {
1869     nothing,
1870     playerobj,
1871     inertobj,
1872     fixup_inertobj,
1873     deadobj,
1874 
1875 
1876     // BEGIN - Start of ordered list for ActorInfoMsg[] for attacking
1877     // actor REBA messages
1878 
1879     rentacopobj,
1880     hang_terrotobj,
1881     gen_scientistobj,
1882     podobj,
1883     electroobj,
1884     electrosphereobj,
1885     proguardobj,
1886     genetic_guardobj,
1887     mutant_human1obj,
1888     mutant_human2obj,
1889     lcan_wait_alienobj,
1890     lcan_alienobj,
1891     scan_wait_alienobj,
1892     scan_alienobj,
1893     gurney_waitobj,
1894     gurneyobj,
1895     liquidobj,
1896     swatobj,
1897     goldsternobj,
1898     gold_morphobj,
1899     volatiletransportobj,
1900     floatingbombobj,
1901     rotating_cubeobj,
1902 
1903     spider_mutantobj,
1904     breather_beastobj,
1905     cyborg_warriorobj,
1906     reptilian_warriorobj,
1907     acid_dragonobj,
1908     mech_guardianobj,
1909 
1910     final_boss1obj,
1911     final_boss2obj,
1912     final_boss3obj,
1913     final_boss4obj,
1914 
1915     blakeobj,
1916 
1917     crate1obj,
1918     crate2obj,
1919     crate3obj,
1920 
1921     green_oozeobj,
1922     black_oozeobj,
1923     green2_oozeobj,
1924     black2_oozeobj,
1925     podeggobj,
1926 
1927     morphing_spider_mutantobj,
1928     morphing_reptilian_warriorobj,
1929     morphing_mutanthuman2obj,
1930 
1931     SPACER1_OBJ,
1932     electroshotobj, // NON-HITPOINT objects...
1933     post_barrierobj,
1934     arc_barrierobj,
1935     vpost_barrierobj,
1936     vspike_barrierobj,
1937     goldmorphshotobj,
1938 
1939     security_lightobj,
1940     explosionobj,
1941     steamgrateobj,
1942     steampipeobj,
1943 
1944     liquidshotobj,
1945 
1946     lcanshotobj,
1947     podshotobj,
1948     scanshotobj,
1949     dogshotobj,
1950     mut_hum1shotobj,
1951 
1952     ventdripobj,
1953     playerspshotobj,
1954     flickerlightobj,
1955 
1956     plasma_detonatorobj,
1957     plasma_detonator_reserveobj,
1958 
1959     grenadeobj,
1960     bfg_shotobj,
1961     bfg_explosionobj,
1962     pd_explosionobj,
1963 
1964     spider_mutantshotobj,
1965     breather_beastshotobj,
1966     cyborg_warriorshotobj,
1967     reptilian_warriorshotobj,
1968     acid_dragonshotobj,
1969     mech_guardianshotobj,
1970     final_boss2shotobj,
1971     final_boss4shotobj,
1972 
1973     doorexplodeobj, // Door explosion_anim acto
1974     gr_explosionobj,
1975     gold_morphingobj
1976 
1977 }; // classtype
1978 
1979 // BBi
1980 inline classtype operator++(
1981     classtype& a,
1982     int)
1983 {
1984     auto result = a;
1985     a = static_cast<classtype>(a + 1);
1986     return result;
1987 }
1988 // BBi
1989 
1990 //
1991 // NOTE: When adding bonus objects - Make sure that they are added
1992 // at the bottom of the list or that BonusMsg[] is correctly
1993 // updated.
1994 //
1995 
1996 enum stat_t {
1997     dressing,
1998 
1999     bo_red_key,
2000     bo_yellow_key,
2001     bo_blue_key,
2002 
2003     bo_clip,
2004     bo_clip2,
2005     bo_pistol,
2006     bo_burst_rifle,
2007     bo_ion_cannon,
2008     bo_grenade,
2009     bo_bfg_cannon,
2010 
2011     // START of Bonus Health Ordered list
2012 
2013     bo_fullheal,
2014     bo_firstaid,
2015     bo_ham,
2016     bo_chicken,
2017     bo_sandwich,
2018     bo_candybar,
2019     bo_water,
2020     bo_water_puddle,
2021 
2022     // END of ordered ...
2023 
2024     bo_money_bag,
2025     bo_loot,
2026 
2027     bo_gold1,
2028     bo_gold2,
2029     bo_gold3,
2030 
2031     bo_gold,
2032     bo_bonus,
2033 
2034     bo_plainvent,
2035     bo_bloodvent,
2036     bo_watervent,
2037 
2038     bo_coin,
2039     bo_coin5,
2040 
2041     bo_plasma_detonator,
2042     bo_automapper1,
2043 
2044     bo_nothing,
2045 
2046     block,
2047 
2048     bo_green_key,
2049     bo_gold_key,
2050 }; // stat_t
2051 
2052 struct stattype {
2053     int16_t picnum;
2054     stat_t type;
2055 }; // stattype
2056 
2057 enum dirtype {
2058     east,
2059     northeast,
2060     north,
2061     northwest,
2062     west,
2063     southwest,
2064     south,
2065     southeast,
2066     nodir
2067 }; // dirtype
2068 
2069 // BBi
2070 inline dirtype operator+=(
2071     dirtype& a,
2072     int b)
2073 {
2074     a = static_cast<dirtype>(a + b);
2075     return a;
2076 }
2077 
2078 inline dirtype operator-=(
2079     dirtype& a,
2080     int b)
2081 {
2082     a = static_cast<dirtype>(a - b);
2083     return a;
2084 }
2085 
2086 inline dirtype operator|=(
2087     dirtype& a,
2088     int b)
2089 {
2090     a = static_cast<dirtype>(a | b);
2091     return a;
2092 }
2093 
2094 inline dirtype operator--(
2095     dirtype& a,
2096     int)
2097 {
2098     auto result = a;
2099     a -= 1;
2100     return result;
2101 }
2102 
2103 inline dirtype operator++(
2104     dirtype& a,
2105     int)
2106 {
2107     auto result = a;
2108     a += 1;
2109     return result;
2110 }
2111 
2112 enum enemy_t {
2113     en_rentacop, // Actors with hitpoints (normal actors)
2114     en_hang_terrot,
2115     en_gen_scientist,
2116     en_pod,
2117     en_electro_alien,
2118     en_electrosphere,
2119     en_proguard,
2120     en_genetic_guard,
2121     en_mutant_human1,
2122     en_mutant_human2,
2123     en_lcan_wait_alien,
2124     en_lcan_alien,
2125     en_scan_wait_alien,
2126     en_scan_alien,
2127     en_gurney_wait,
2128     en_gurney,
2129     en_liquid,
2130     en_swat,
2131     en_goldstern,
2132     en_gold_morph,
2133     en_volatiletransport,
2134     en_floatingbomb,
2135     en_rotating_cube,
2136 
2137     en_spider_mutant,
2138     en_breather_beast,
2139     en_cyborg_warrior,
2140     en_reptilian_warrior,
2141     en_acid_dragon,
2142     en_mech_guardian,
2143 
2144     en_final_boss1,
2145     en_final_boss2,
2146     en_final_boss3,
2147     en_final_boss4,
2148 
2149     en_blake,
2150 
2151     en_crate1,
2152     en_crate2,
2153     en_crate3,
2154 
2155     en_green_ooze,
2156     en_black_ooze,
2157     en_green2_ooze,
2158     en_black2_ooze,
2159     en_podegg,
2160 
2161     en_morphing_spider_mutant,
2162     en_morphing_reptilian_warrior,
2163     en_morphing_mutanthuman2,
2164 
2165     NUMHITENEMIES,
2166 
2167     en_electro_shot, // Actors WITHOUT hitpoints (abnormal actors?)
2168     en_post_barrier,
2169     en_arc_barrier,
2170     en_vpost_barrier,
2171     en_vspike_barrier,
2172     en_goldmorphshot,
2173 
2174     en_security_light,
2175     en_explosion,
2176     en_steamgrate,
2177     en_steampipe,
2178 
2179     en_liquidshot,
2180 
2181     en_lcanshot,
2182     en_podshot,
2183     en_scanshot,
2184     en_dogshot,
2185     en_mut_hum1shot,
2186 
2187     en_ventdrip,
2188     en_playerspshotobj,
2189     en_flickerlight,
2190 
2191     en_plasma_detonator,
2192     en_plasma_detonator_reserve,
2193 
2194     en_vertsphere, // Actor types only used for spawning.
2195     en_horzsphere,
2196     en_diagsphere,
2197     en_bloodvent,
2198     en_watervent,
2199     NUMENEMIES,
2200 }; // enemy_t
2201 
2202 
2203 #define SF_ROTATE (0x01)
2204 #define SF_PAINFRAME (0x02)
2205 
2206 
2207 struct objtype;
2208 
2209 
2210 struct statetype {
2211     int flags;
2212     int shapenum; // a shapenum of -1 means get from ob->temp1
2213     int tictime;
2214 
2215     void (* think)(
2216         objtype* actor);
2217 
2218     void (* action)(
2219         objtype* actor);
2220 
2221     statetype* next;
2222 }; // statetype
2223 
2224 
2225 // ---------------------
2226 //
2227 // trivial actor structure
2228 //
2229 // ---------------------
2230 
2231 struct statobj_t {
2232     uint8_t tilex;
2233     uint8_t tiley;
2234     uint8_t areanumber;
2235 
2236     uint8_t* visspot;
2237     int16_t shapenum; // if shapenum == -1 the obj has been removed
2238     uint16_t flags;
2239     uint8_t itemnumber;
2240     int8_t lighting;
2241 
2242     void serialize(
2243         bstone::BinaryWriter& writer,
2244         bstone::Crc32& checksum) const;
2245 
2246     void deserialize(
2247         bstone::BinaryReader& reader,
2248         bstone::Crc32& checksum);
2249 }; // statobj_t
2250 
2251 
2252 // ---------------------
2253 //
2254 // door actor structure
2255 //
2256 // ---------------------
2257 
2258 // BBi
2259 enum DoorAction {
2260     dr_open,
2261     dr_closed,
2262     dr_opening,
2263     dr_closing,
2264     dr_jammed,
2265 }; // DoorAction
2266 
2267 struct doorobj_t {
2268     uint8_t tilex;
2269     uint8_t tiley;
2270     bool vertical;
2271     int8_t flags;
2272     keytype lock;
2273     door_t type;
2274     DoorAction action;
2275     int16_t ticcount;
2276     uint8_t areanumber[2];
2277 
2278     void serialize(
2279         bstone::BinaryWriter& writer,
2280         bstone::Crc32& checksum) const;
2281 
2282     void deserialize(
2283         bstone::BinaryReader& reader,
2284         bstone::Crc32& checksum);
2285 }; // doorobj_t
2286 
2287 
2288 // --------------------
2289 //
2290 // thinking actor structure
2291 //
2292 // --------------------
2293 
2294 struct objtype {
2295     uint8_t tilex;
2296     uint8_t tiley;
2297     uint8_t areanumber;
2298 
2299     activetype active;
2300     int16_t ticcount;
2301     classtype obclass;
2302     statetype* state;
2303 
2304     uint32_t flags;
2305     uint16_t flags2; // Aux flags
2306 
2307     int32_t distance; // if negative, wait for that door to open
2308     dirtype dir;
2309     dirtype trydir; // "bit 7" == "direction to turn" flag
2310 
2311     fixed x;
2312     fixed y;
2313     uint8_t s_tilex;
2314     uint8_t s_tiley; // s_tilex==0, running for corner
2315 
2316     int16_t viewx;
2317     uint16_t viewheight;
2318     fixed transx;
2319     fixed transy; // in global coord
2320 
2321     // FIXME
2322     // In original code it also used to store a 16-bit pointer to object.
2323     // Since our code is at least 32-bit we are using an index of object.
2324     int16_t hitpoints;
2325 
2326     uint8_t ammo;
2327     int8_t lighting;
2328     uint16_t linc;
2329     int16_t angle;
2330     int32_t speed;
2331 
2332     int16_t temp1;
2333 
2334     // FIXME
2335     // In original code it also used to store a 16-bit pointer to object.
2336     // Since our code is at least 32-bit we are using an index of object.
2337     int16_t temp2;
2338 
2339     // FIXME
2340     // In original code it also used to store a 16-bit pointer to object.
2341     // Since our code is at least 32-bit we are using an index of object.
2342     uint16_t temp3; // holds 'last door used' by 'smart' actors
2343 
2344     objtype* next;
2345     objtype* prev;
2346 
2347 
2348     void serialize(
2349         bstone::BinaryWriter& writer,
2350         bstone::Crc32& checksum) const;
2351 
2352     void deserialize(
2353         bstone::BinaryReader& reader,
2354         bstone::Crc32& checksum);
2355 }; // objtype
2356 
2357 
2358 enum ButtonState {
2359     bt_nobutton = -1,
2360     bt_attack = 0,
2361     bt_strafe,
2362     bt_run,
2363     bt_use,
2364     bt_ready_autocharge,
2365     bt_ready_pistol,
2366     bt_ready_burst_rifle,
2367     bt_ready_ion_cannon,
2368     bt_ready_grenade,
2369     bt_ready_bfg_cannon,
2370     bt_ready_plasma_detonators,
2371 
2372     bt_SPACER,
2373 
2374     NUMBUTTONS,
2375 }; // ButtonState
2376 
2377 
2378 enum weapontype {
2379     wp_autocharge,
2380     wp_pistol,
2381     wp_burst_rifle,
2382     wp_ion_cannon,
2383     wp_grenade,
2384     wp_bfg_cannon,
2385 
2386     wp_SPACER,
2387 }; // weapontype
2388 
2389 extern int NUMWEAPONS;
2390 
2391 
2392 enum Difficulty {
2393     gd_baby,
2394     gd_easy,
2395     gd_medium,
2396     gd_hard,
2397 }; // Difficulty
2398 
2399 
2400 enum backgroundtype {
2401     ELEVATOR_BACK,
2402     TRANSPORTER_BACK
2403 }; // backgroundtype
2404 
2405 
2406 //
2407 // General Coord (tile) structure
2408 //
2409 struct tilecoord_t {
2410     uint8_t tilex;
2411     uint8_t tiley;
2412 
2413     void serialize(
2414         bstone::BinaryWriter& writer,
2415         bstone::Crc32& checksum) const;
2416 
2417     void deserialize(
2418         bstone::BinaryReader& reader,
2419         bstone::Crc32& checksum);
2420 }; // tilecoord_t
2421 
2422 
2423 // -----------------------------------
2424 //
2425 // barrier coord/table structure
2426 //
2427 // -----------------------------------
2428 struct barrier_type {
2429     uint8_t level;
2430     tilecoord_t coord;
2431     uint8_t on;
2432 
2433     void serialize(
2434         bstone::BinaryWriter& writer,
2435         bstone::Crc32& checksum) const;
2436 
2437     void deserialize(
2438         bstone::BinaryReader& reader,
2439         bstone::Crc32& checksum);
2440 }; // barrier_type;
2441 
2442 struct statsInfoType {
2443     int32_t total_points;
2444     int32_t accum_points;
2445     uint8_t total_enemy;
2446     uint8_t accum_enemy;
2447     uint8_t total_inf;
2448     uint8_t accum_inf;
2449     int16_t overall_floor;
2450 
2451     void serialize(
2452         bstone::BinaryWriter& writer,
2453         bstone::Crc32& checksum) const;
2454 
2455     void deserialize(
2456         bstone::BinaryReader& reader,
2457         bstone::Crc32& checksum);
2458 }; // statsInfoType
2459 
2460 struct levelinfo {
2461     uint16_t bonus_queue; // bonuses that need to be shown
2462     uint16_t bonus_shown; // bonuses that have been shown
2463     bool locked;
2464     statsInfoType stats;
2465     uint8_t ptilex;
2466     uint8_t ptiley;
2467     int16_t pangle;
2468 
2469     void serialize(
2470         bstone::BinaryWriter& writer,
2471         bstone::Crc32& checksum) const;
2472 
2473     void deserialize(
2474         bstone::BinaryReader& reader,
2475         bstone::Crc32& checksum);
2476 }; // levelinfo
2477 
2478 
2479 struct fargametype {
2480     using LevelInfos = std::vector<levelinfo>;
2481 
2482     LevelInfos old_levelinfo;
2483     LevelInfos level;
2484 
2485     fargametype();
2486 
2487     fargametype(
2488         const fargametype& that) = delete;
2489 
2490     fargametype& operator=(
2491         const fargametype& that) = delete;
2492 
2493     void initialize();
2494 
2495     void clear();
2496 
2497     void serialize(
2498         bstone::BinaryWriter& writer,
2499         bstone::Crc32& checksum) const;
2500 
2501     void deserialize(
2502         bstone::BinaryReader& reader,
2503         bstone::Crc32& checksum);
2504 }; // fargametype
2505 
2506 struct gametype {
2507     int16_t turn_around;
2508     int16_t turn_angle;
2509     uint16_t flags;
2510     int16_t lastmapon;
2511     int16_t difficulty;
2512     int16_t mapon;
2513     int32_t oldscore;
2514     int32_t tic_score;
2515     int32_t score;
2516     int32_t nextextra;
2517     int16_t score_roll_wait;
2518     int16_t lives;
2519     int16_t health;
2520     char health_str[4];
2521 
2522     int16_t rpower;
2523     int16_t old_rpower;
2524     int8_t rzoom;
2525     int8_t radar_leds;
2526     int8_t lastradar_leds;
2527 
2528     int8_t lastammo_leds;
2529     int8_t ammo_leds;
2530     int16_t ammo;
2531     int16_t old_ammo;
2532 
2533     int16_t plasma_detonators;
2534     int16_t old_plasma_detonators;
2535 
2536     int8_t useable_weapons;
2537     int8_t weapons;
2538     int8_t weapon;
2539     int8_t chosenweapon;
2540     int8_t old_weapons[4];
2541 
2542     int8_t weapon_wait;
2543     int16_t attackframe;
2544     int16_t attackcount;
2545     int16_t weaponframe;
2546     int16_t episode;
2547     uint32_t TimeCount;
2548     const char* msg; // InfoArea msg...
2549     int8_t numkeys[NUMKEYS];
2550     int8_t old_numkeys[NUMKEYS];
2551 
2552     // BBi
2553     barrier_type cross_barriers[MAX_BARRIER_SWITCHES];
2554     // BBi
2555 
2556     barrier_type barrier_table[MAX_BARRIER_SWITCHES];
2557     barrier_type old_barrier_table[MAX_BARRIER_SWITCHES];
2558     uint16_t tokens;
2559     uint16_t old_tokens;
2560     bool boss_key_dropped;
2561     bool old_boss_key_dropped;
2562     int16_t wintilex;
2563     int16_t wintiley;
2564 
2565 
2566     void serialize(
2567         bstone::BinaryWriter& writer,
2568         bstone::Crc32& checksum) const;
2569 
2570     void deserialize(
2571         bstone::BinaryReader& reader,
2572         bstone::Crc32& checksum);
2573 
2574     void initialize_cross_barriers();
2575     void initialize_local_barriers();
2576     void store_local_barriers();
2577     void restore_local_barriers();
2578 }; // gametype
2579 
2580 enum exit_t {
2581     ex_stillplaying,
2582     ex_completed,
2583     ex_transported,
2584     ex_died,
2585     ex_warped,
2586     ex_resetgame,
2587     ex_loadedgame,
2588     ex_victorious,
2589     ex_abort,
2590     ex_demodone,
2591     ex_secretlevel,
2592     ex_title
2593 }; // exit_t
2594 
2595 
2596 struct CycleInfo {
2597     uint8_t init_delay;
2598     uint8_t delay_count;
2599     uint8_t firstreg;
2600     uint8_t lastreg;
2601 }; // CycleInfo
2602 
2603 
2604 struct visobj_t {
2605     int16_t viewx;
2606     int16_t viewheight;
2607     int16_t shapenum;
2608     int8_t lighting;
2609     bool cloaked;
2610 }; // visobj_t
2611 
2612 
2613 enum animtype_t {
2614     at_NONE = 0,
2615     at_CYCLE,
2616     at_REBOUND,
2617     at_ONCE,
2618 }; // animtype_t
2619 
2620 enum animdir_t {
2621     ad_FWD = 0,
2622     ad_REV,
2623 }; // animdir_t
2624 
2625 
2626 struct ofs_anim_t {
2627     static const int animtype_offset = 0;
2628     static const int animtype_size = 2;
2629 
2630     static const int curframe_offset = animtype_offset + animtype_size;
2631     static const int curframe_size = 5;
2632 
2633     static const int maxframe_offset = curframe_offset + curframe_size;
2634     static const int maxframe_size = 5;
2635 
2636     static const int animdir_offset = maxframe_offset + maxframe_size;
2637     static const int animdir_size = 1;
2638 
2639 
2640     template<int TOffset, int TSize>
getofs_anim_t2641     static uint16_t get(
2642         const objtype* o)
2643     {
2644         return (o->temp3 >> TOffset) & ((1 << TSize) - 1);
2645     }
2646 
2647     template<int TOffset, int TSize>
setofs_anim_t2648     static void set(
2649         const uint16_t value,
2650         objtype* o)
2651     {
2652         o->temp3 &= ~(((1 << TSize) - 1) << TOffset);
2653         o->temp3 |= ((value & ((1 << TSize) - 1)) << TOffset);
2654     }
2655 
get_animtypeofs_anim_t2656     static uint16_t get_animtype(
2657         const objtype* o)
2658     {
2659         return get<animtype_offset, animtype_size>(o);
2660     }
2661 
set_animtypeofs_anim_t2662     static void set_animtype(
2663         const uint16_t value,
2664         objtype* o)
2665     {
2666         set<animtype_offset, animtype_size>(value, o);
2667     }
2668 
2669 
get_curframeofs_anim_t2670     static uint16_t get_curframe(
2671         const objtype* o)
2672     {
2673         return get<curframe_offset, curframe_size>(o);
2674     }
2675 
set_curframeofs_anim_t2676     static void set_curframe(
2677         const uint16_t value,
2678         objtype* o)
2679     {
2680         set<curframe_offset, curframe_size>(value, o);
2681     }
2682 
2683 
get_maxframeofs_anim_t2684     static uint16_t get_maxframe(
2685         const objtype* o)
2686     {
2687         return get<maxframe_offset, maxframe_size>(o);
2688     }
2689 
set_maxframeofs_anim_t2690     static void set_maxframe(
2691         const uint16_t value,
2692         objtype* o)
2693     {
2694         set<maxframe_offset, maxframe_size>(value, o);
2695     }
2696 
2697 
get_animdirofs_anim_t2698     static uint16_t get_animdir(
2699         const objtype* o)
2700     {
2701         return get<animdir_offset, animdir_size>(o);
2702     }
2703 
set_animdirofs_anim_t2704     static void set_animdir(
2705         const uint16_t value,
2706         objtype* o)
2707     {
2708         set<animdir_offset, animdir_size>(value, o);
2709     }
2710 }; // ofs_anim_t
2711 
2712 
2713 //
2714 // DisplayInfoMsg Priorities - Duplicate Values are Allowed.
2715 //
2716 // ("enum" list used simply for debuging use like Object Classes)
2717 //
2718 
2719 //
2720 // Msg_Priorities - Hell.. Lets just make them all the same...
2721 
2722 enum msg_priorities {
2723     MP_min_val = 0,
2724 
2725     MP_HEARTB_SND = 0x0200,
2726     MP_WALLSWITCH_OPERATE = 0x0200,
2727 
2728     MP_DOOR_OPERATE = 0x0200,
2729     MP_CONCESSION_OPERATE = 0x0200,
2730     MP_WEAPON_AVAIL = 0x0200,
2731 
2732     MP_ATTACK_INFO = 0x0200,
2733     MP_NO_MORE_AMMO = 0x0200,
2734     MP_WEAPON_MALFUNCTION = 0x0200,
2735 
2736     MP_INTERROGATE = 0x0200,
2737     MP_CONCESSION_HINT = 0x0200,
2738     MP_NO_MORE_TOKENS = 0x0200,
2739     MP_CONCESSION_OUT_ORDER = 0x0200,
2740 
2741     MP_BONUS = 0x0200,
2742 
2743     MP_TAKE_DAMAGE = 0x0200,
2744     MP_DETONATOR = 0x0200,
2745 
2746     MP_PINBALL_BONUS = 0x3000,
2747     MP_FLOOR_UNLOCKED = 0x3000,
2748 
2749     MP_POWERUP = 0x7000, // Power-Up/Game-Start Value
2750     MP_max_val = 0x7FFF, // DO NOT USE/EXCEED - MAX Val
2751 }; // msg_priorities
2752 
2753 enum infomsg_type {
2754     MT_NOTHING,
2755     MT_CLEAR,
2756     MT_ATTACK,
2757     MT_GENERAL,
2758     MT_OUT_OF_AMMO,
2759     MT_MALFUNCTION,
2760     MT_NO_MO_FOOD_TOKENS,
2761     MT_BONUS,
2762 }; // infomsg_type
2763 
2764 
2765 //
2766 // Menu Instruction Text types...
2767 //
2768 enum inst_type {
2769     IT_STANDARD,
2770     IT_HIGHSCORES,
2771     IT_ENTER_HIGHSCORE,
2772     IT_MOUSE_SEN,
2773 
2774     // BBi
2775     IT_SOUND_VOLUME,
2776     IT_CONTROLS,
2777     IT_CONTROLS_ASSIGNING_KEY,
2778 
2779     MAX_INSTRUCTIONS,
2780 }; // inst_type
2781 
2782 
2783 
2784 #define MAX_CACHE_MSGS (30)
2785 #define MAX_CACHE_MSG_LEN (190)
2786 
2787 // ------------------------- BASIC STRUCTURES -----------------------------
2788 
2789 // Basic 'message info' structure
2790 //
2791 struct mCacheInfo {
2792     uint8_t local_val; // where msg is in 'local' list
2793     uint8_t global_val; // where msg was in 'global' list
2794     char* mSeg; // pointer to message
2795 
2796     void serialize(
2797         bstone::BinaryWriter& writer,
2798         bstone::Crc32& checksum) const;
2799 
2800     void deserialize(
2801         bstone::BinaryReader& reader,
2802         bstone::Crc32& checksum);
2803 }; // mCacheInfo
2804 
2805 // Basic 'message list' structure
2806 //
2807 struct mCacheList {
2808     int16_t NumMsgs; // number of messages
2809     mCacheInfo mInfo[MAX_CACHE_MSGS]; // table of message 'info'
2810 }; // mCacheList
2811 
2812 // ----------------------- CONCESSION STRUCTURES --------------------------
2813 
2814 // Concession 'message info' structure
2815 //
2816 struct con_mCacheInfo {
2817     mCacheInfo mInfo;
2818     uint8_t type; // type of concession
2819     uint8_t operate_cnt; // # of times req'd to operate
2820 
2821     void serialize(
2822         bstone::BinaryWriter& writer,
2823         bstone::Crc32& checksum) const;
2824 
2825     void deserialize(
2826         bstone::BinaryReader& reader,
2827         bstone::Crc32& checksum);
2828 }; // con_mCacheInfo
2829 
2830 // Concession 'message list' structure
2831 //
2832 struct concession_t {
2833     int16_t NumMsgs; // also, num concessions
2834     con_mCacheInfo cmInfo[MAX_CACHE_MSGS];
2835 
2836     void serialize(
2837         bstone::BinaryWriter& writer,
2838         bstone::Crc32& checksum) const;
2839 
2840     void deserialize(
2841         bstone::BinaryReader& reader,
2842         bstone::Crc32& checksum);
2843 }; // concession_t
2844 
2845 // ------------------------ INFORMANT STRUCTURES --------------------------
2846 
2847 // Informant 'message info' structure
2848 //
2849 struct sci_mCacheInfo {
2850     mCacheInfo mInfo;
2851     uint8_t areanumber; // 'where' msg can be used
2852 }; // sci_mCacheInfo
2853 
2854 // Informant 'message list' structure
2855 //
2856 struct scientist_t {
2857     int16_t NumMsgs;
2858     sci_mCacheInfo smInfo[MAX_CACHE_MSGS];
2859 }; // scientist_t
2860 
2861 // ------------------------------------------------------------------------
2862 
2863 // Electro-Alien controller structer
2864 //
2865 struct eaWallInfo {
2866     int8_t tilex;
2867     int8_t tiley; // where this controller is in the map.
2868     int8_t aliens_out; // aliens spawned by this controller.
2869     int16_t delay; // delay before spawning another alien.
2870 
2871     void serialize(
2872         bstone::BinaryWriter& writer,
2873         bstone::Crc32& checksum) const;
2874 
2875     void deserialize(
2876         bstone::BinaryReader& reader,
2877         bstone::Crc32& checksum);
2878 }; // eaWallInfo
2879 
2880 
2881 // General Structure to hold goldstern specific stuff...
2882 //
2883 
2884 struct GoldsternInfo_t {
2885     uint8_t LastIndex; // Last Spawn Coord Index
2886     uint8_t SpawnCnt; // Num of Spawnpoints for Goldstern
2887     uint16_t flags; // What type of command/operation is needed...
2888     uint16_t WaitTime; // Wait time for Goldstern Spawn (current & Next)
2889     bool GoldSpawned; // Has Goldstern been spawned?
2890 
2891     void serialize(
2892         bstone::BinaryWriter& writer,
2893         bstone::Crc32& checksum) const;
2894 
2895     void deserialize(
2896         bstone::BinaryReader& reader,
2897         bstone::Crc32& checksum);
2898 }; // GoldsternInfo_t
2899 
2900 
2901 struct star_t {
2902     int32_t x;
2903     int32_t y;
2904     int32_t z;
2905     uint8_t color;
2906 }; // star_t
2907 
2908 
2909 /*
2910 =============================================================================
2911 
2912 3D_MAIN DEFINITIONS
2913 
2914 =============================================================================
2915 */
2916 
2917 extern int16_t TITLE_LOOP_MUSIC;
2918 
2919 #define CANT_PLAY_TXT "\n" \
2920     "ERROR: Insufficient disk space.\n" \
2921     "Try deleting some files from your hard disk.\n\n"
2922 
2923 
2924 extern std::string data_dir;
2925 
2926 extern const float radtoint; // = (float)FINEANGLES/2/PI;
2927 
2928 // FIXME Unused
2929 #if 0
2930 extern int16_t view_xl;
2931 extern int16_t view_xh;
2932 extern int16_t view_yl;
2933 extern int16_t view_yh;
2934 #endif
2935 
2936 extern int16_t starting_level;
2937 extern int16_t debug_value;
2938 extern int16_t starting_episode;
2939 extern int16_t starting_difficulty;
2940 
2941 extern bool MS_CheckParm(
2942     const std::string& value);
2943 
2944 extern int8_t lastmap_tilex;
2945 extern int8_t lastmap_tiley;
2946 extern uint16_t TopColor;
2947 extern uint16_t BottomColor;
2948 extern char str[80];
2949 extern char str2[20];
2950 extern bool nospr;
2951 extern bool IsA386;
2952 
2953 extern int focallength;
2954 extern int viewangles;
2955 extern int screenofs;
2956 extern int viewwidth;
2957 extern int viewheight;
2958 extern int centerx;
2959 extern int shootdelta;
2960 
2961 extern int16_t dirangle[9];
2962 
2963 extern bool startgame;
2964 extern bool loadedgame;
2965 extern int mouseadjustment;
2966 
2967 // BBi
2968 const int min_mouse_sensitivity = 0;
2969 const int max_mouse_sensitivity = 54;
2970 const int default_mouse_sensitivity = 5;
2971 // BBi
2972 
2973 //
2974 // math tables
2975 //
2976 extern std::vector<int> pixelangle;
2977 extern int finetangent[FINEANGLES / 4];
2978 extern int sintable[];
2979 extern int* costable;
2980 
2981 //
2982 // derived constants
2983 //
2984 extern int scale;
2985 extern int maxslope;
2986 extern int heightnumerator;
2987 extern int minheightdiv;
2988 extern int mindist;
2989 
2990 extern char configname[13];
2991 
2992 extern bool ShowQuickMsg;
2993 
2994 int DeleteChunk(
2995     bstone::MemoryStream& stream,
2996     const std::string& chunk_name);
2997 
2998 void LoadFonts();
2999 void ClearNClose();
3000 void CycleColors();
3001 void LoadAccessCodes();
3002 void AlignPlayerInElevator();
3003 void HelpScreens();
3004 void OrderingInfo();
3005 void TEDDeath();
3006 
3007 void CalcProjection(
3008     int32_t focal);
3009 
3010 void SetViewSize();
3011 void SetPlaneViewSize();
3012 
3013 void NewGame(
3014     int16_t difficulty,
3015     int16_t episode);
3016 
3017 void NewViewSize();
3018 
3019 uint16_t scan_atoi(
3020     const char* s);
3021 
3022 void AlignPlayerOnTransporter();
3023 
3024 uint16_t UseFunc(
3025     const char* first,
3026     const char* next);
3027 
3028 bool DoMovie(
3029     movie_t movie,
3030     void* palette);
3031 
3032 bool CheckDiskSpace(
3033     int32_t needed,
3034     const char* text,
3035     cds_io_type io_type);
3036 
3037 bool SaveTheGame(
3038     const std::string& file_name,
3039     const std::string& description);
3040 
3041 int32_t ChecksumFile(
3042     const std::string& file,
3043     int32_t checksum);
3044 
3045 void BadChecksum();
3046 
3047 void CheckValidity(
3048     char* file,
3049     int32_t valid_checksum);
3050 
3051 void UnauthorizedLevels();
3052 void ShowChecksums();
3053 
3054 void SetupWalls();
3055 void InitDigiMap();
3056 
3057 void CleanUpDoors_N_Actors();
3058 
3059 
3060 void InitDestPath();
3061 
3062 // On success current stream position is at chunk's data.
3063 int FindChunk(
3064     bstone::IStream* stream,
3065     const std::string& dst_chunk_name);
3066 
3067 int NextChunk(
3068     bstone::IStream* stream);
3069 
3070 /*
3071 =============================================================================
3072 
3073  3D_GAME DEFINITIONS
3074 
3075 =============================================================================
3076 */
3077 
3078 extern int16_t db_count;
3079 extern classtype debug_bonus[2][800];
3080 extern fargametype gamestuff;
3081 extern tilecoord_t GoldieList[GOLDIE_MAX_SPAWNS];
3082 extern GoldsternInfo_t GoldsternInfo;
3083 
3084 extern uint8_t VitalsRemain;
3085 extern uint8_t VitalsOnFloor;
3086 
3087 extern eaWallInfo eaList[];
3088 extern int8_t NumEAWalls;
3089 extern int8_t NumEASpawned;
3090 extern bool ingame;
3091 extern bool fizzlein;
3092 extern int latchpics[NUMLATCHPICS];
3093 extern gametype gamestate;
3094 extern int16_t doornum;
3095 
3096 void DrawPlayBorder();
3097 void ScanInfoPlane();
3098 void SetupGameLevel();
3099 void NormalScreen();
3100 void DrawPlayScreen(bool);
3101 void FizzleOut();
3102 void GameLoop();
3103 
3104 
3105 void Warped();
3106 
3107 void RotateView(
3108     int16_t DestAngle,
3109     uint8_t RotSpeed);
3110 
3111 void DrawWarpIn();
3112 
3113 void BMAmsg(
3114     const char* msg);
3115 
3116 void CacheBMAmsg(
3117     uint16_t MsgNum);
3118 
3119 void BevelBox(
3120     int16_t xl,
3121     int16_t yl,
3122     int16_t w,
3123     int16_t h,
3124     uint8_t hi,
3125     uint8_t med,
3126     uint8_t lo);
3127 
3128 void AddTotalPoints(
3129     uint16_t points);
3130 
3131 void AddTotalInformants(
3132     int8_t informants);
3133 
3134 void AddTotalEnemy(
3135     uint16_t enemies);
3136 
3137 void ShadowPrintLocationText(
3138     sp_type type);
3139 
3140 void LoseScreen();
3141 
3142 void LoadLocationText(
3143     int16_t textNum);
3144 
3145 /*
3146 =============================================================================
3147 
3148  3D_PLAY DEFINITIONS
3149 
3150 =============================================================================
3151 */
3152 
3153 extern int objcount;
3154 
3155 extern objtype* DeadGuys[];
3156 extern objtype dummyobj;
3157 extern uint8_t NumDeadGuys;
3158 
3159 extern exit_t playstate;
3160 
3161 extern int16_t bordertime;
3162 
3163 extern bool madenoise;
3164 extern bool usedummy;
3165 extern bool nevermark;
3166 extern uint8_t alerted;
3167 extern uint8_t alerted_areanum;
3168 
3169 extern objtype objlist[MAXACTORS];
3170 extern objtype* new_actor;
3171 extern objtype* player;
3172 extern objtype* lastobj;
3173 extern objtype* objfreelist;
3174 extern objtype* killerobj;
3175 extern statobj_t statobjlist[MAXSTATS];
3176 extern statobj_t* laststatobj;
3177 extern doorobj_t doorobjlist[MAXDOORS];
3178 extern doorobj_t* lastdoorobj;
3179 
3180 extern uint16_t farmapylookup[MAPSIZE];
3181 extern uint8_t* nearmapylookup[MAPSIZE];
3182 
3183 extern uint8_t tilemap[MAPSIZE][MAPSIZE]; // wall values only
3184 extern uint8_t spotvis[MAPSIZE][MAPSIZE];
3185 extern objtype* actorat[MAPSIZE][MAPSIZE];
3186 
3187 extern bool singlestep;
3188 extern bool godmode;
3189 extern bool noclip;
3190 extern bool DebugOk;
3191 extern int16_t InstantWin;
3192 extern int16_t InstantQuit;
3193 extern int16_t TestQuickSave;
3194 extern int16_t TestAutoMapper;
3195 extern uint16_t ExtraRadarFlags;
3196 
3197 //
3198 // control info
3199 //
3200 using ScanCodes = std::vector<ScanCode>;
3201 using Buttons = std::vector<int16_t>;
3202 
3203 
3204 extern bool mouseenabled;
3205 extern bool joystickenabled;
3206 extern bool joypadenabled;
3207 extern bool joystickprogressive;
3208 extern int16_t joystickport;
3209 extern ScanCodes dirscan;
3210 extern ScanCodes buttonscan;
3211 extern Buttons buttonmouse;
3212 extern Buttons buttonjoy;
3213 
3214 extern bool buttonheld[NUMBUTTONS];
3215 
3216 extern const int viewsize;
3217 
3218 //
3219 // curent user input
3220 //
3221 extern int controlx;
3222 extern int controly; // range from -100 to 100
3223 extern bool buttonstate[NUMBUTTONS];
3224 extern int strafe_value;
3225 
3226 extern char Computing[];
3227 
3228 
3229 void CenterWindow(
3230     uint16_t w,
3231     uint16_t h);
3232 
3233 void InitActorList();
3234 void GetNewActor();
3235 
3236 void RemoveObj(
3237     objtype* gone);
3238 
3239 void PollControls();
3240 void StopMusic();
3241 
3242 void StartMusic(
3243     bool startit);
3244 
3245 void PlayLoop();
3246 
3247 void ChangeSwapFiles(
3248     bool display);
3249 
3250 void OpenPageFile();
3251 void CheckMusicToggle();
3252 
3253 /*
3254 =============================================================================
3255 
3256  3D_DEBUG
3257 
3258 =============================================================================
3259 */
3260 
3261 int16_t DebugKeys();
3262 void CalcMemFree();
3263 
3264 
3265 /*
3266 =============================================================================
3267 
3268  3D_DRAW DEFINITIONS
3269 
3270 =============================================================================
3271 */
3272 
3273 extern uint8_t TravelTable[MAPSIZE][MAPSIZE];
3274 
3275 extern int16_t weaponchangetics;
3276 extern int16_t itemchangetics;
3277 extern int16_t bodychangetics;
3278 extern int16_t plaqueon;
3279 extern int16_t plaquetime;
3280 extern int16_t plaquetimefrac;
3281 extern int16_t getpic;
3282 
3283 extern statobj_t* firststarobj;
3284 
3285 extern int32_t space_xmove;
3286 extern int32_t space_ymove;
3287 
3288 extern int32_t lasttimecount;
3289 extern int32_t framecount;
3290 extern int32_t frameon;
3291 extern bool fizzlein;
3292 
3293 using SpanStart = std::vector<int>;
3294 using StepScale = std::vector<int>;
3295 using BaseDist = std::vector<int>;
3296 using PlaneYLookup = std::vector<int>;
3297 using MirrorOfs = std::vector<int>;
3298 using WallHeight = std::vector<int>;
3299 
3300 extern WallHeight wallheight;
3301 
3302 extern fixed focallength;
3303 extern fixed mindist;
3304 
3305 //
3306 // refresh variables
3307 //
3308 extern int viewx;
3309 extern int viewy; // the focal point
3310 extern int viewangle;
3311 extern int viewsin;
3312 extern int viewcos;
3313 
3314 extern const uint8_t* postsource;
3315 extern int postx;
3316 
3317 // BBi
3318 extern int posty;
3319 
3320 
3321 extern int16_t horizwall[];
3322 extern int16_t vertwall[];
3323 
3324 extern uint16_t pwallpos;
3325 
3326 extern bool cloaked_shape;
3327 
3328 fixed FixedByFrac(
3329     fixed a,
3330     fixed b);
3331 
3332 void TransformActor(
3333     objtype* ob);
3334 
3335 void BuildTables();
3336 
3337 void ClearScreen();
3338 
3339 int16_t CalcRotate(
3340     objtype* ob);
3341 
3342 void DrawScaleds();
3343 void CalcTics();
3344 void ThreeDRefresh();
3345 void FarScalePost();
3346 void DrawStars();
3347 
3348 bool TransformTile(
3349     int16_t tx,
3350     int16_t ty,
3351     int16_t* dispx,
3352     int16_t* dispheight);
3353 
3354 void WrapTransformActor(
3355     objtype* ob);
3356 
3357 void ComputeActorPosition(
3358     objtype* ob,
3359     int8_t adjust_x,
3360     int8_t adjust_y);
3361 
3362 void WrapDrawScaleds();
3363 
3364 bool WrapActorPosition(
3365     objtype* obj);
3366 
3367 void WrapStaticPosition(
3368     statobj_t* statptr,
3369     visobj_t* visptr);
3370 
3371 void ShowOverhead(
3372     int bx,
3373     int by,
3374     int radius,
3375     int zoom,
3376     int flags);
3377 
3378 void UpdateTravelTable();
3379 
3380 
3381 /*
3382 =============================================================================
3383 
3384  3D_DRAW2 DEFINITIONS
3385 
3386 =============================================================================
3387 */
3388 extern uint16_t CeilingTile;
3389 extern uint16_t FloorTile;
3390 extern void (* MapRowPtr)();
3391 
3392 void DrawPlanes();
3393 
3394 
3395 void MapRow();
3396 void C_MapRow();
3397 void F_MapRow();
3398 
3399 
3400 /*
3401 =============================================================================
3402 
3403  3D_STATE DEFINITIONS
3404 
3405 =============================================================================
3406 */
3407 
3408 extern uint16_t actor_points[];
3409 extern dirtype opposite[9];
3410 extern dirtype diagonal[9][9];
3411 
3412 
3413 void SeekPlayerOrStatic(
3414     objtype* ob,
3415     int16_t* deltax,
3416     int16_t* deltay);
3417 
3418 uint16_t CheckRunChase(
3419     objtype* ob);
3420 
3421 void GetCornerSeek(
3422     objtype* ob);
3423 
3424 bool LookForGoodies(
3425     objtype* ob,
3426     uint16_t RunReason);
3427 
3428 void InitHitRect(
3429     objtype* ob,
3430     uint16_t radius);
3431 
3432 void SpawnNewObj(
3433     uint16_t tilex,
3434     uint16_t tiley,
3435     statetype* state);
3436 
3437 void NewState(
3438     objtype* ob,
3439     statetype* state);
3440 
3441 bool TryWalk(
3442     objtype* ob,
3443     bool moveit);
3444 
3445 void SelectChaseDir(
3446     objtype* ob);
3447 
3448 void SelectDodgeDir(
3449     objtype* ob);
3450 
3451 void MoveObj(
3452     objtype* ob,
3453     int32_t move);
3454 
3455 void KillActor(
3456     objtype* ob);
3457 
3458 void DamageActor(
3459     objtype* ob,
3460     uint16_t damage,
3461     objtype* attacker);
3462 
3463 bool CheckLine(
3464     objtype* from_obj,
3465     objtype* to_obj);
3466 
3467 bool CheckSight(
3468     objtype* from_obj,
3469     objtype* to_obj);
3470 
3471 bool PosVisable(
3472     fixed from_x,
3473     fixed from_y,
3474     fixed to_x,
3475     fixed to_y,
3476     int16_t from_angle);
3477 
3478 bool PlayerIsBlocking(
3479     objtype* ob);
3480 
3481 void MakeAlertNoise(
3482     objtype* obj);
3483 
3484 objtype* CheckAndReserve();
3485 
3486 
3487 /*
3488 =============================================================================
3489 
3490  3D_SCALE DEFINITIONS
3491 
3492 =============================================================================
3493 */
3494 
3495 
3496 #define COMPSCALECODESTART (65 * 4) // offset to start of code in comp scaler
3497 
3498 struct t_compshape {
3499     uint16_t leftpix, rightpix;
3500     uint16_t dataofs[64];
3501 
3502     // table data after dataofs[rightpix-leftpix+1]
3503 }; // t_compshape
3504 
3505 extern int maxscale;
3506 extern int maxscaleshl2;
3507 extern bool scaledir_avail;
3508 
3509 extern int normalshade;
3510 extern int normalshade_div;
3511 extern int shade_max;
3512 
3513 
3514 void FreeScaleDirectory();
3515 
3516 void SetupScaling(
3517     int maxscaleheight);
3518 
3519 void ScaleShape(
3520     int xcenter,
3521     int shapenum,
3522     int height);
3523 
3524 // BBi
3525 void scale_player_weapon(
3526     const int sprite_id,
3527     const int height);
3528 
3529 
3530 /*
3531 =============================================================================
3532 
3533  3D_AGENT DEFINITIONS
3534 
3535 =============================================================================
3536 */
3537 
3538 extern scientist_t InfHintList;
3539 extern scientist_t NiceSciList;
3540 extern scientist_t MeanSciList;
3541 
3542 extern uint16_t static_points[];
3543 extern bool GAN_HiddenArea;
3544 extern char* InfAreaMsgs[];
3545 extern uint8_t NumAreaMsgs;
3546 extern uint8_t LastInfArea;
3547 extern int16_t FirstGenInfMsg;
3548 extern int16_t TotalGenInfMsgs;
3549 extern classtype LastInfoAttacker;
3550 
3551 extern int16_t LastInfoAttacker_Cloaked;
3552 
3553 extern char term_com_name[];
3554 extern char term_msg_name[];
3555 
3556 extern atkinf_t attackinfo[7][14];
3557 
3558 //
3559 // player state info
3560 //
3561 extern bool commandmode;
3562 extern int32_t thrustspeed;
3563 extern uint16_t plux;
3564 extern uint16_t pluy; // player coordinates scaled to unsigned
3565 extern bool PlayerInvisable;
3566 extern int8_t DrawInfoArea_COUNT;
3567 extern int8_t InitInfoArea_COUNT;
3568 
3569 extern uint16_t player_oldtilex;
3570 extern uint16_t player_oldtiley;
3571 
3572 // Terminal variables
3573 
3574 extern uint16_t RadarSw;
3575 
3576 // Location Bar message string...
3577 
3578 extern char LocationText[MAX_LOCATION_DESC_LEN];
3579 
3580 
3581 //
3582 // search / move info
3583 //
3584 extern uint16_t searchon; // held object number looking at
3585 extern int16_t searchtics; // when it reaches SEARCHTICS, get an obj
3586 extern objtype* searchobj; // current object being searched
3587 extern uint16_t foundflag; // only show NOTHING if nothing was found
3588 extern objtype* moveobj; // current object being draged
3589 
3590 extern int anglefrac;
3591 extern int16_t facecount;
3592 
3593 extern uint16_t LastMsgPri;
3594 extern int16_t MsgTicsRemain;
3595 
3596 void GivePoints(
3597     int32_t score,
3598     bool add_to_stats);
3599 
3600 void SpawnPlayer(
3601     int16_t tilex,
3602     int16_t tiley,
3603     int16_t dir);
3604 
3605 void DrawCash();
3606 void UpdateHealth();
3607 
3608 void DrawAmmoGuage();
3609 void DrawAmmoMsg();
3610 
3611 void DrawAmmo(
3612     bool ForceRefresh);
3613 
3614 bool DisplayInfoMsg(
3615     const char* Msg,
3616     msg_priorities Priority,
3617     int16_t DisplayTime,
3618     int16_t MessageType);
3619 
3620 bool DisplayInfoMsg(
3621     const std::string& Msg,
3622     msg_priorities Priority,
3623     int16_t DisplayTime,
3624     int16_t MessageType);
3625 
3626 void UpdateInfoAreaClock();
3627 void UpdateInfoArea();
3628 void DrawHealthMonitor();
3629 void CalcHealthDisplay();
3630 void UpdateScore();
3631 
3632 uint8_t ValidAreaTile(
3633     const uint16_t* ptr);
3634 
3635 int8_t GetAreaNumber(
3636     int tilex,
3637     int tiley);
3638 
3639 int16_t InputFloor();
3640 void RestoreInfoArea();
3641 void DrawHeartPic();
3642 void DrawInfoArea();
3643 void AnimatePage();
3644 
3645 void ActivateTerminal(bool);
3646 
3647 void TerminalPrint(
3648     char* msg,
3649     bool FastPrint);
3650 
3651 void FloorCheat(
3652     uint16_t RadarFlags);
3653 
3654 bool Interrogate(
3655     objtype* ob);
3656 
3657 void GiveKey(
3658     int16_t key);
3659 
3660 void TakeKey(
3661     int16_t key);
3662 
3663 void GiveToken(
3664     int16_t tokens);
3665 
3666 void TakePlasmaDetonator(
3667     int16_t count);
3668 
3669 void GivePlasmaDetonator(
3670     int16_t count);
3671 
3672 void CacheDrawPic(
3673     int x,
3674     int y,
3675     int pic);
3676 
3677 void LoadTerminalCommands();
3678 
3679 // BBi
3680 void store_cross_barrier(
3681     uint8_t level,
3682     uint8_t x,
3683     uint8_t y,
3684     bool state);
3685 
3686 void apply_cross_barriers();
3687 // BBi
3688 
3689 void ActivateWallSwitch(
3690     uint16_t iconnum,
3691     int16_t x,
3692     int16_t y);
3693 
3694 uint16_t UpdateBarrierTable(
3695     uint8_t level,
3696     uint8_t x,
3697     uint8_t y,
3698     bool OnOff);
3699 
3700 uint16_t ScanBarrierTable(
3701     uint8_t x,
3702     uint8_t y);
3703 
3704 void DisplaySwitchOperateMsg(
3705     int coords);
3706 
3707 void DisplayNoMoMsgs();
3708 
3709 void PrintStatPercent(
3710     int16_t nx,
3711     int16_t ny,
3712     int8_t percentage);
3713 
3714 int16_t ShowStats(
3715     int16_t bx,
3716     int16_t by,
3717     ss_type type,
3718     statsInfoType* stats);
3719 
3720 bool PerfectStats();
3721 bool CheckPerfectStats();
3722 
3723 bool OperateSmartSwitch(
3724     uint16_t tilex,
3725     uint16_t tiley,
3726     int8_t Operation,
3727     bool Force);
3728 
3729 /*
3730 =============================================================================
3731 
3732  3D_ACT1 DEFINITIONS
3733 
3734 =============================================================================
3735 */
3736 using StatInfos = std::vector<stattype>;
3737 
3738 
3739 extern int8_t xy_offset[8][2];
3740 extern StatInfos statinfo;
3741 extern concession_t ConHintList;
3742 
3743 extern doorobj_t doorobjlist[MAXDOORS];
3744 extern doorobj_t* lastdoorobj;
3745 extern int16_t doornum;
3746 
3747 extern uint16_t doorposition[MAXDOORS];
3748 extern uint16_t pwallstate;
3749 
3750 extern uint8_t areaconnect[NUMAREAS][NUMAREAS];
3751 
3752 extern bool areabyplayer[NUMAREAS];
3753 
3754 extern uint16_t pwallstate;
3755 extern uint16_t pwallpos; // amount a pushable wall has been moved (0-63)
3756 extern uint16_t pwallx;
3757 extern uint16_t pwally;
3758 extern int16_t pwalldir;
3759 extern int16_t pwalldist;
3760 
3761 
3762 statobj_t* ReserveStatic();
3763 
3764 void SpawnStatic(
3765     int16_t tilex,
3766     int16_t tiley,
3767     int16_t type);
3768 
3769 void SpawnDoor(
3770     int16_t tilex,
3771     int16_t tiley,
3772     bool vertical,
3773     keytype lock,
3774     door_t type);
3775 
3776 void OperateConcession(
3777     uint16_t concession);
3778 
3779 void SpawnConcession(
3780     int16_t tilex,
3781     int16_t tiley,
3782     uint16_t credits,
3783     uint16_t machinetype);
3784 
3785 uint16_t LoadConcessionHint(
3786     uint16_t MsgNum);
3787 
3788 void CacheInfoAreaMsg(
3789     uint16_t block,
3790     uint16_t MsgNum,
3791     char* hint_buffer,
3792     uint16_t MaxBufferLen);
3793 
3794 void CheckSpawnEA();
3795 
3796 int16_t TransformAreas(
3797     int8_t tilex,
3798     int8_t tiley,
3799     int8_t xform);
3800 
3801 
3802 void CheckSpawnGoldstern();
3803 void FindNewGoldieSpawnSite();
3804 
3805 void InitMsgCache(
3806     mCacheList* mList,
3807     uint16_t listSize,
3808     uint16_t infoSize);
3809 
3810 void FreeMsgCache(
3811     mCacheList* mList,
3812     uint16_t listSize);
3813 
3814 void CacheMsg(
3815     mCacheInfo* ci,
3816     uint16_t SegNum,
3817     uint16_t MsgNum);
3818 
3819 int16_t LoadMsg(
3820     char* hint_buffer,
3821     uint16_t SegNum,
3822     uint16_t MsgNum,
3823     uint16_t MaxMsgLen);
3824 
3825 void CacheConcessionMsg();
3826 
3827 bool ReuseMsg(
3828     mCacheInfo* ci,
3829     int16_t count,
3830     int16_t struct_size);
3831 
3832 void DropPlasmaDetonator();
3833 
3834 void BlockDoorOpen(
3835     int16_t door);
3836 
3837 void BlastNearDoors(
3838     int16_t tilex,
3839     int16_t tiley);
3840 
3841 void TryBlastDoor(
3842     int8_t door);
3843 
3844 statobj_t* FindStatic(
3845     uint16_t tilex,
3846     uint16_t tiley);
3847 
3848 statobj_t* UseReservedStatic(
3849     int16_t itemtype,
3850     int16_t tilex,
3851     int16_t tiley);
3852 
3853 void PlaceReservedItemNearTile(
3854     int16_t itemtype,
3855     int16_t tilex,
3856     int16_t tiley);
3857 
3858 void ExplodeStatics(
3859     int16_t tilex,
3860     int16_t tiley);
3861 
3862 
3863 /*
3864 =============================================================================
3865 
3866  3D_ACT2 DEFINITIONS
3867 
3868 =============================================================================
3869 */
3870 
3871 #define s_nakedbody s_static10
3872 
3873 
3874 #define BARRIER_STATE(obj) ((obj)->ammo)
3875 
3876 void MakeFakeStatic(
3877     objtype* ob);
3878 
3879 void UnmakeFakeStatic(
3880     objtype* ob);
3881 
3882 extern int8_t detonators_spawned;
3883 
3884 extern int16_t starthitpoints[][NUMHITENEMIES];
3885 
3886 extern uint16_t MorphClass[];
3887 
3888 extern statetype s_ofs_bounce;
3889 
3890 extern statetype s_ofs_esphere_death1;
3891 extern statetype s_ofs_ouch;
3892 
3893 extern statetype s_ofs_static;
3894 
3895 extern statetype s_rent_die1;
3896 extern statetype s_ofcdie1;
3897 extern statetype s_swatdie1;
3898 extern statetype s_prodie1;
3899 extern statetype s_proshoot1;
3900 
3901 
3902 extern statetype s_rent_chase1;
3903 extern statetype s_ofcchase1;
3904 extern statetype s_prochase1;
3905 extern statetype s_swatchase1;
3906 
3907 
3908 extern statetype s_rent_pain;
3909 extern statetype s_ofcpain;
3910 extern statetype s_propain;
3911 extern statetype s_swatpain;
3912 
3913 extern statetype s_hold;
3914 
3915 
3916 extern statetype s_swatwounded1;
3917 
3918 extern statetype s_deathcam;
3919 
3920 
3921 extern statetype s_terrot_wait;
3922 extern statetype s_terrot_seek1;
3923 
3924 
3925 extern statetype s_ofs_stand;
3926 extern statetype s_ofs_chase1;
3927 extern statetype s_ofs_pain;
3928 extern statetype s_ofs_die1;
3929 extern statetype s_ofs_pod_death1;
3930 extern statetype s_ofs_pod_ouch;
3931 extern statetype s_ofs_attack1;
3932 
3933 extern statetype s_electro_appear1;
3934 extern statetype s_electro_chase1;
3935 extern statetype s_electro_ouch;
3936 extern statetype s_electro_shoot1;
3937 extern statetype s_electro_die1;
3938 
3939 
3940 extern statetype s_liquid_wait;
3941 extern statetype s_liquid_move;
3942 extern statetype s_liquid_rise1;
3943 extern statetype s_liquid_shoot1;
3944 extern statetype s_liquid_ouch;
3945 extern statetype s_liquid_shot;
3946 extern statetype s_liquid_die1;
3947 extern statetype s_liquid_shot_exp1;
3948 
3949 
3950 
3951 extern statetype s_goldstand;
3952 extern statetype s_goldpath1;
3953 extern statetype s_goldpain;
3954 extern statetype s_goldshoot1;
3955 extern statetype s_goldchase1;
3956 extern statetype s_goldwarp_it; // Warp In w/button pressing
3957 extern statetype s_goldwarp_out1;
3958 extern statetype s_goldwarp_in1;
3959 
3960 extern statetype s_goldmorph1;
3961 extern statetype s_goldmorph2;
3962 extern statetype s_goldmorph3;
3963 extern statetype s_goldmorph4;
3964 extern statetype s_goldmorph5;
3965 extern statetype s_goldmorph6;
3966 extern statetype s_goldmorph7;
3967 extern statetype s_goldmorph8;
3968 
3969 extern statetype s_mgold_chase1;
3970 extern statetype s_mgold_chase2;
3971 extern statetype s_mgold_chase3;
3972 extern statetype s_mgold_chase4;
3973 
3974 extern statetype s_mgold_shoot1;
3975 extern statetype s_mgold_shoot2;
3976 extern statetype s_mgold_shoot3;
3977 extern statetype s_mgold_shoot4;
3978 
3979 extern statetype s_mgold_pain;
3980 
3981 extern statetype s_security_light;
3982 
3983 
3984 extern statetype s_scout_path1;
3985 extern statetype s_scout_path2;
3986 extern statetype s_scout_path3;
3987 extern statetype s_scout_path4;
3988 extern statetype s_scout_pain;
3989 extern statetype s_scout_run;
3990 extern statetype s_scout_run2;
3991 extern statetype s_scout_run3;
3992 extern statetype s_scout_run4;
3993 extern statetype s_scout_die1;
3994 extern statetype s_scout_stand;
3995 extern statetype s_scout_dead;
3996 
3997 extern statetype s_explosion1;
3998 
3999 extern statetype s_steamgrate;
4000 extern statetype s_vital;
4001 
4002 extern statetype s_vital_ouch;
4003 extern statetype s_vital_die;
4004 extern statetype s_vital_die1;
4005 extern statetype s_vital_die2;
4006 extern statetype s_vital_die3;
4007 extern statetype s_vital_die4;
4008 extern statetype s_vital_die5;
4009 extern statetype s_vital_die6;
4010 extern statetype s_vital_die7;
4011 extern statetype s_vital_die8;
4012 
4013 extern statetype s_ooze_chase;
4014 extern statetype s_vpost_barrier;
4015 extern statetype s_spike_barrier;
4016 
4017 void T_PainThink(
4018     objtype* obj);
4019 
4020 void T_ExplodeScout(
4021     objtype* obj);
4022 
4023 void T_Security(
4024     objtype* obj);
4025 
4026 void T_ChangeShape(
4027     objtype* obj);
4028 
4029 void T_MakeOffset(
4030     objtype* obj);
4031 
4032 void T_LiquidStand(
4033     objtype* obj);
4034 
4035 void PlaceTowardPlayer(
4036     objtype* obj);
4037 
4038 void T_Seek(
4039     objtype* ob);
4040 
4041 void SpawnProjectile(
4042     objtype* shooter,
4043     classtype class_type);
4044 
4045 void SpawnStand(
4046     enemy_t which,
4047     int16_t tilex,
4048     int16_t tiley,
4049     int16_t dir);
4050 
4051 void SpawnPatrol(
4052     enemy_t which,
4053     int16_t tilex,
4054     int16_t tiley,
4055     int16_t dir);
4056 
4057 void KillActor(
4058     objtype* ob);
4059 
4060 void US_ControlPanel(
4061     ScanCode scan_code);
4062 
4063 int16_t IntSqrt(
4064     int32_t va);
4065 
4066 uint16_t CalcDistance(
4067     uint16_t x1,
4068     uint16_t y1,
4069     uint16_t x2,
4070     uint16_t y2);
4071 
4072 void T_Hit(
4073     objtype* ob);
4074 
4075 void SpawnOffsetObj(
4076     enemy_t which,
4077     int16_t tilex,
4078     int16_t tiley);
4079 
4080 
4081 void InitSmartAnimStruct(
4082     objtype* obj,
4083     uint16_t ShapeNum,
4084     uint8_t StartOfs,
4085     uint8_t MaxOfs,
4086     animtype_t AnimType,
4087     animdir_t AnimDir);
4088 
4089 bool AnimateOfsObj(
4090     objtype* obj);
4091 
4092 void AdvanceAnimREV(
4093     objtype* obj);
4094 
4095 void AdvanceAnimFWD(
4096     objtype* obj);
4097 
4098 void SpawnCusExplosion(
4099     fixed x,
4100     fixed y,
4101     uint16_t StartFrame,
4102     uint16_t NumFrames,
4103     uint16_t Delay,
4104     uint16_t Class);
4105 
4106 void T_SpawnExplosion(
4107     objtype* obj);
4108 
4109 void T_ExplodeDamage(
4110     objtype* obj);
4111 
4112 void ExplodeRadius(
4113     objtype* obj,
4114     int16_t damage,
4115     bool damageplayer);
4116 
4117 extern statetype s_barrier_transition;
4118 extern statetype s_barrier_shutdown;
4119 
4120 void SpawnBarrier(
4121     enemy_t which,
4122     int16_t tilex,
4123     int16_t tiley,
4124     bool OnOff);
4125 
4126 void ToggleBarrier(
4127     objtype* obj);
4128 
4129 void InitAnim(
4130     objtype* obj,
4131     uint16_t ShapeNum,
4132     uint8_t StartOfs,
4133     uint8_t MaxOfs,
4134     animtype_t AnimType,
4135     animdir_t AnimDir,
4136     uint16_t Delay,
4137     uint16_t WaitDelay);
4138 
4139 objtype* FindObj(
4140     classtype which,
4141     int16_t tilex,
4142     int16_t tiley);
4143 
4144 objtype* FindHiddenOfs(
4145     classtype which);
4146 
4147 void SpawnHiddenOfs(
4148     enemy_t which,
4149     int16_t tilex,
4150     int16_t tiley);
4151 
4152 objtype* MoveHiddenOfs(
4153     classtype which_class,
4154     classtype new1,
4155     fixed x,
4156     fixed y);
4157 
4158 void CheckForSpecialTile(
4159     objtype* obj,
4160     uint16_t tilex,
4161     uint16_t tiley);
4162 
4163 void DropCargo(
4164     objtype* obj);
4165 
4166 
4167 /*
4168 =============================================================================
4169 
4170  3D_TEXT DEFINITIONS
4171 
4172 =============================================================================
4173 */
4174 
4175 extern char helpfilename[];
4176 extern char endfilename[];
4177 
4178 extern void HelpScreens();
4179 extern void EndText();
4180 
4181 
4182 /*
4183 =============================================================================
4184 
4185  3D_MSGS TEXT DEFINITIONS
4186 
4187 =============================================================================
4188 */
4189 
4190 
4191 using BonusMessages = std::vector<std::reference_wrapper<std::string>>;
4192 using ActorMessages = std::vector<std::reference_wrapper<std::string>>;
4193 
4194 
4195 extern std::string noeat_msg1;
4196 
4197 extern std::string bevs_msg1;
4198 extern std::string food_msg1;
4199 
4200 extern std::string bonus_msg7;
4201 
4202 extern std::string bonus_msg26;
4203 
4204 extern BonusMessages BonusMsg;
4205 extern ActorMessages ActorInfoMsg;
4206 extern std::string ekg_heartbeat_enabled;
4207 extern std::string ekg_heartbeat_disabled;
4208 extern std::string attacker_info_enabled;
4209 extern std::string attacker_info_disabled;
4210 extern std::string WeaponNotAvailMsg;
4211 extern std::string WeaponAvailMsg;
4212 extern std::string RadarAvailMsg;
4213 extern std::string RadarEnergyGoneMsg;
4214 extern std::string WeaponAutoSelectMsg;
4215 extern std::string EnergyPackDepleted;
4216 extern std::string NotEnoughEnergyForWeapon;
4217 
4218 extern std::string WeaponMalfunction;
4219 
4220 extern std::string SwitchNotActivateMsg;
4221 extern std::string NoFoodTokens;
4222 extern std::string ExtraMan;
4223 extern std::string OneMillion;
4224 extern std::string TenMillion;
4225 
4226 extern std::string NoAdLibCard;
4227 extern std::string MusicOn;
4228 extern std::string MusicOff;
4229 extern std::string SoundOn;
4230 extern std::string SoundOff;
4231 
4232 extern std::string pd_dropped;
4233 extern std::string pd_nomore;
4234 extern std::string pd_switching;
4235 extern std::string pd_notnear;
4236 extern std::string pd_getcloser;
4237 extern std::string pd_floorunlocked;
4238 extern std::string pd_donthaveany;
4239 extern std::string pd_no_computer;
4240 extern std::string pd_floornotlocked;
4241 
4242 
4243 /*
4244 =============================================================================
4245 
4246  3D_INTER DEFINITIONS
4247 
4248 =============================================================================
4249 */
4250 
4251 extern char BreifingText[];
4252 
4253 void UpdateScreenPic();
4254 
4255 void DisplayPrepingMsg(
4256     const char* text);
4257 
4258 bool Breifing(
4259     breifing_type BreifingType,
4260     uint16_t episode);
4261 
4262 void ShPrint(
4263     const char* text,
4264     int8_t shadow_color,
4265     bool single_char);
4266 
4267 uint16_t Random(
4268     uint16_t Max);
4269 
4270 
4271 // ===========================================================================
4272 //
4273 // 3D_MENU DEFINATIONS - WHICH NEED TO BE GLOBAL
4274 //
4275 // ===========================================================================
4276 
4277 extern bool EscPressed;
4278 
4279 void DrawInstructions(
4280     inst_type Type);
4281 
4282 void CacheMessage(
4283     uint16_t MessageNum);
4284 
4285 void TerminateStr(
4286     char* pos);
4287 
4288 uint32_t CacheCompData(
4289     uint16_t ItemNum,
4290     void** dest_loc);
4291 
4292 
4293 // ===========================================================================
4294 //
4295 // 3D_FREE DEFINATIONS - WHICH NEED TO BE GLOBAL
4296 //
4297 // ===========================================================================
4298 
4299 
4300 extern char JM_FREE_DATA_END[];
4301 extern char JM_FREE_DATA_START[];
4302 
4303 
4304 // BBi
4305 using Buffer = std::vector<unsigned char>;
4306 
4307 
4308 objtype* ui16_to_actor(
4309     uint16_t value);
4310 
4311 uint16_t actor_to_ui16(
4312     const objtype* actor);
4313 
4314 statobj_t* ui16_to_static_object(
4315     uint16_t value);
4316 
4317 uint16_t static_object_to_ui16(
4318     const statobj_t* static_object);
4319 
4320 doorobj_t* ui16_to_door_object(
4321     uint16_t value);
4322 
4323 uint16_t door_object_to_ui16(
4324     const doorobj_t* door_object);
4325 
4326 extern bool g_no_wall_hit_sound;
4327 extern bool g_always_run;
4328 
4329 // BBi AOG only options
4330 extern bool g_heart_beat_sound;
4331 extern bool g_rotated_automap;
4332 
4333 
4334 class ArchiveException : public std::exception {
4335 public:
4336     explicit ArchiveException(
4337         const char* message) throw ();
4338 
4339     ArchiveException(
4340         const ArchiveException& that) throw ();
4341 
4342     virtual ~ArchiveException() throw ();
4343 
4344     ArchiveException& operator=(
4345         const ArchiveException& that) throw ();
4346 
4347     virtual const char* what() const throw ();
4348 
4349 private:
4350     const char* message_;
4351 }; // ArchiveException
4352 
4353 
4354 template<typename T>
4355 class ArchiveIsContainter
4356 {
4357 public:
4358     static const bool value = false;
4359 }; // ArchiveIsContainter
4360 
4361 template<typename T, typename... TArgs>
4362 class ArchiveIsContainter<std::vector<T,TArgs...>>
4363 {
4364 public:
4365     static const bool value = true;
4366 }; // ArchiveIsContainter
4367 
4368 
4369 class ArchiveRemapU8Tag
4370 {
4371 public:
4372 }; // ArchiveRemapU8Tag
4373 
4374 class ArchiveRemapContainerTag
4375 {
4376 public:
4377 }; // ArchiveRemapContainerTag
4378 
4379 class ArchiveRemapNoneTag
4380 {
4381 public:
4382 }; // ArchiveRemapNoneTag
4383 
4384 
4385 template<typename T>
4386 class ArchiveRemapTag
4387 {
4388 public:
4389     using Type = typename std::conditional<
4390         std::is_same<T,char>::value ||
4391             std::is_same<T,bool>::value ||
4392             std::is_same<T,keytype>::value ||
4393             std::is_same<T,door_t>::value ||
4394             std::is_same<T,DoorAction>::value ||
4395             std::is_same<T,activetype>::value ||
4396             std::is_same<T,classtype>::value ||
4397             std::is_same<T,dirtype>::value ||
4398             std::is_same<T,ScanCode>::value,
4399         ArchiveRemapU8Tag,
4400         typename std::conditional<
4401             ArchiveIsContainter<T>::value,
4402             ArchiveRemapContainerTag,
4403             ArchiveRemapNoneTag>::type
4404     >::type;
4405 }; // RemapTag
4406 
4407 
4408 // Contains an id for enumeration or integral type.
4409 template<typename T>
4410 class ArchiveIEId {
4411 public:
4412     static const int value = (
4413         std::is_integral<T>::value ?
4414             1 : (std::is_enum<T>::value ? 2 : 0));
4415 };
4416 
4417 // Remaps enumeration or integral type to integral type.
4418 template<typename T, int>
4419 class ArchiveIETag;
4420 
4421 template<typename T>
4422 class ArchiveIETag<T,1>
4423 {
4424 public:
4425     using Type = T;
4426 };
4427 
4428 template<typename T>
4429 class ArchiveIETag<T,2>
4430 {
4431 public:
4432     using Type = typename std::underlying_type<T>::type;
4433 };
4434 
4435 template<typename T>
4436 using ArchiveIEType =
4437     typename ArchiveIETag<T, ArchiveIEId<T>::value>::Type;
4438 
4439 
4440 // Contains an id of signed or unsigned integral type.
4441 template<typename T>
4442 class ArchiveSignX8Id {
4443 public:
4444     static const int value = (
4445         std::is_integral<T>::value ?
4446             (std::is_signed<T>::value ? 1 : 2) :
4447             0);
4448 };
4449 
4450 // Remaps integral type to appropriate 8-bit signed/unsigned type.
4451 template<typename T, int>
4452 class ArchiveSignX8Tag;
4453 
4454 template<typename T>
4455 class ArchiveSignX8Tag<T,1>
4456 {
4457 public:
4458     using Type = int8_t;
4459 };
4460 
4461 template<typename T>
4462 class ArchiveSignX8Tag<T,2>
4463 {
4464 public:
4465     using Type = uint8_t;
4466 };
4467 
4468 template<typename T>
4469 using ArchiveX8Type =
4470     typename ArchiveSignX8Tag<T, ArchiveSignX8Id<T>::value>::Type;
4471 
4472 
4473 template<typename T>
serialize_field_internal(const T & value,bstone::BinaryWriter & writer,bstone::Crc32 & checksum,ArchiveRemapNoneTag)4474 inline void serialize_field_internal(
4475     const T& value,
4476     bstone::BinaryWriter& writer,
4477     bstone::Crc32& checksum,
4478     ArchiveRemapNoneTag)
4479 {
4480     checksum.update(value);
4481 
4482     if (!writer.write(bstone::Endian::le(value))) {
4483         throw ArchiveException("serialize_field");
4484     }
4485 }
4486 
4487 template<typename T>
serialize_field_internal(const T & value,bstone::BinaryWriter & writer,bstone::Crc32 & checksum,ArchiveRemapU8Tag)4488 inline void serialize_field_internal(
4489     const T& value,
4490     bstone::BinaryWriter& writer,
4491     bstone::Crc32& checksum,
4492     ArchiveRemapU8Tag)
4493 {
4494     auto target_value = static_cast<uint8_t>(value);
4495 
4496     checksum.update(target_value);
4497 
4498     if (!writer.write(target_value)) {
4499         throw ArchiveException("serialize_field");
4500     }
4501 }
4502 
4503 template<typename T>
4504 inline void serialize_field(
4505     const T& value,
4506     bstone::BinaryWriter& writer,
4507     bstone::Crc32& checksum);
4508 
4509 template<typename T>
serialize_field_internal(const T & container,bstone::BinaryWriter & writer,bstone::Crc32 & checksum,ArchiveRemapContainerTag)4510 inline void serialize_field_internal(
4511     const T& container,
4512     bstone::BinaryWriter& writer,
4513     bstone::Crc32& checksum,
4514     ArchiveRemapContainerTag)
4515 {
4516     for (auto& item : container) {
4517         ::serialize_field(item, writer, checksum);
4518     }
4519 }
4520 
4521 template<typename T>
serialize_field(const T & value,bstone::BinaryWriter & writer,bstone::Crc32 & checksum)4522 inline void serialize_field(
4523     const T& value,
4524     bstone::BinaryWriter& writer,
4525     bstone::Crc32& checksum)
4526 {
4527     ::serialize_field_internal(
4528         value,
4529         writer,
4530         checksum,
4531         typename ArchiveRemapTag<T>::Type());
4532 }
4533 
4534 template<typename T, size_t N>
serialize_field(const T (& value)[N],bstone::BinaryWriter & writer,bstone::Crc32 & checksum)4535 inline void serialize_field(
4536     const T(&value)[N],
4537     bstone::BinaryWriter& writer,
4538     bstone::Crc32& checksum)
4539 {
4540     for (size_t i = 0; i < N; ++i) {
4541         ::serialize_field(value[i], writer, checksum);
4542     }
4543 }
4544 
4545 template<typename T, size_t M, size_t N>
serialize_field(const T (& value)[M][N],bstone::BinaryWriter & writer,bstone::Crc32 & checksum)4546 inline void serialize_field(
4547     const T(&value)[M][N],
4548     bstone::BinaryWriter& writer,
4549     bstone::Crc32& checksum)
4550 {
4551     for (size_t i = 0; i < M; ++i) {
4552         for (size_t j = 0; j < N; ++j) {
4553             ::serialize_field(value[i][j], writer, checksum);
4554         }
4555     }
4556 }
4557 
4558 template<typename T>
4559 inline void deserialize_field(
4560     T& value,
4561     bstone::BinaryReader& reader,
4562     bstone::Crc32& checksum);
4563 
4564 template<typename T>
deserialize_field_internal(T & value,bstone::BinaryReader & reader,bstone::Crc32 & checksum,ArchiveRemapNoneTag)4565 inline void deserialize_field_internal(
4566     T& value,
4567     bstone::BinaryReader& reader,
4568     bstone::Crc32& checksum,
4569     ArchiveRemapNoneTag)
4570 {
4571     if (!reader.read(value)) {
4572         throw ArchiveException("deserialize_field");
4573     }
4574 
4575     bstone::Endian::lei(value);
4576 
4577     checksum.update(value);
4578 }
4579 
4580 template<typename T>
deserialize_field_internal(T & value,bstone::BinaryReader & reader,bstone::Crc32 & checksum,ArchiveRemapU8Tag)4581 inline void deserialize_field_internal(
4582     T& value,
4583     bstone::BinaryReader& reader,
4584     bstone::Crc32& checksum,
4585     ArchiveRemapU8Tag)
4586 {
4587     // Get proper signed/unsigned 8-bit type based on value's one.
4588     using ValueType = ArchiveIEType<T>;
4589     using ValueX8Type = ArchiveX8Type<ValueType>;
4590 
4591     ValueX8Type source_value = 0;
4592 
4593     if (!reader.read(source_value)) {
4594         throw ArchiveException("deserialize_field");
4595     }
4596 
4597     checksum.update(source_value);
4598 
4599     value = static_cast<T>(source_value);
4600 }
4601 
4602 template<>
4603 inline void deserialize_field_internal<bool>(
4604     bool& value,
4605     bstone::BinaryReader& reader,
4606     bstone::Crc32& checksum,
4607     ArchiveRemapU8Tag)
4608 {
4609     uint8_t source_value = 0;
4610 
4611     if (!reader.read(source_value)) {
4612         throw ArchiveException("deserialize_field");
4613     }
4614 
4615     checksum.update(source_value);
4616 
4617     value = (source_value != 0 ? true : false);
4618 }
4619 
4620 template<typename T>
deserialize_field_internal(T & container,bstone::BinaryReader & reader,bstone::Crc32 & checksum,ArchiveRemapContainerTag)4621 inline void deserialize_field_internal(
4622     T& container,
4623     bstone::BinaryReader& reader,
4624     bstone::Crc32& checksum,
4625     ArchiveRemapContainerTag)
4626 {
4627     for (auto& item : container) {
4628         ::deserialize_field(item, reader, checksum);
4629     }
4630 }
4631 
4632 template<typename T>
deserialize_field(T & value,bstone::BinaryReader & reader,bstone::Crc32 & checksum)4633 inline void deserialize_field(
4634     T& value,
4635     bstone::BinaryReader& reader,
4636     bstone::Crc32& checksum)
4637 {
4638     ::deserialize_field_internal(
4639         value,
4640         reader,
4641         checksum,
4642         typename ArchiveRemapTag<T>::Type());
4643 }
4644 
4645 template<typename T, size_t N>
deserialize_field(T (& value)[N],bstone::BinaryReader & reader,bstone::Crc32 & checksum)4646 inline void deserialize_field(
4647     T(&value)[N],
4648     bstone::BinaryReader& reader,
4649     bstone::Crc32& checksum)
4650 {
4651     for (size_t i = 0; i < N; ++i) {
4652         ::deserialize_field(value[i], reader, checksum);
4653     }
4654 }
4655 
4656 template<typename T, size_t M, size_t N>
deserialize_field(T (& value)[M][N],bstone::BinaryReader & reader,bstone::Crc32 & checksum)4657 inline void deserialize_field(
4658     T(&value)[M][N],
4659     bstone::BinaryReader& reader,
4660     bstone::Crc32& checksum)
4661 {
4662     for (size_t i = 0; i < M; ++i) {
4663         for (size_t j = 0; j < N; ++j) {
4664             ::deserialize_field(value[i][j], reader, checksum);
4665         }
4666     }
4667 }
4668 
4669 
4670 enum class GameType {
4671     none,
4672     aog_sw, // Aliens Of Gold (shareware, v3.0)
4673     aog_full_v1_0, // Aliens Of Gold (full, v1.0)
4674     aog_full_v2_x, // Aliens Of Gold (full, v2.0/v2.1)
4675     aog_full_v3_0, // Aliens Of Gold (full, v3.0)
4676     ps, // Planet Strike (full, v1.0/v1.1)
4677 }; // GameType
4678 
4679 extern GameType g_game_type;
4680 
4681 bool is_aog_full_v1_0();
4682 
4683 bool is_aog_full_v2_x();
4684 
4685 bool is_aog_full_v3_0();
4686 
4687 bool is_aog_full();
4688 
4689 bool is_aog_sw();
4690 
4691 bool is_aog();
4692 
4693 bool is_ps();
4694 
4695 
4696 void InitSmartSpeedAnim(
4697     objtype* obj,
4698     uint16_t ShapeNum,
4699     uint8_t StartOfs,
4700     uint8_t MaxOfs,
4701     animtype_t AnimType,
4702     animdir_t AnimDir,
4703     uint16_t Delay);
4704 
4705 void InitSmartAnim(
4706     objtype* obj,
4707     uint16_t ShapeNum,
4708     uint8_t StartOfs,
4709     uint8_t MaxOfs,
4710     animtype_t AnimType,
4711     animdir_t AnimDir);
4712 
4713 
m_pi()4714 inline double m_pi()
4715 {
4716     return 3.14159265358979323846;
4717 }
4718 
4719 
4720 void sys_sleep_for(
4721     int milliseconds);
4722 
4723 void sys_default_sleep_for();
4724 
4725 const std::string& get_version_string();
4726 
4727 const std::string& get_profile_dir();
4728 
4729 const std::string& get_default_data_dir();
4730 // BBi
4731 
4732 
4733 #endif // BSTONE_3D_DEF_INCLUDED
4734