Franklin Wei | 3f59fc8 | 2019-07-07 22:00:20 -0400 | [diff] [blame] | 1 | #ifndef WL_DEF_H |
| 2 | #define WL_DEF_H |
| 3 | |
| 4 | // Defines which version shall be built and configures supported extra features |
| 5 | #include "version.h" |
| 6 | |
| 7 | #define SOUND_ENABLE |
| 8 | |
| 9 | #include "fixedpoint.h" |
| 10 | #include <ctype.h> |
| 11 | #include <stdint.h> |
| 12 | #include <stdarg.h> |
| 13 | #include <SDL.h> |
| 14 | #include <SDL_mixer.h> |
| 15 | |
| 16 | #define open rb->open |
| 17 | #define read(a, b, c) rb->read((a), (b), (c)) |
| 18 | #define write(a, b, c) rb->write((a), (b), (c)) |
| 19 | #define close(a) rb->close(a) |
| 20 | |
| 21 | #if !defined O_BINARY |
| 22 | # define O_BINARY 0 |
| 23 | #endif |
| 24 | |
Franklin Wei | 152e415 | 2019-07-09 17:34:09 -0400 | [diff] [blame] | 25 | // needed by wolf, but is dangerous on ARM |
Franklin Wei | 3f59fc8 | 2019-07-07 22:00:20 -0400 | [diff] [blame] | 26 | #pragma pack(1) |
| 27 | |
| 28 | #if defined(_arch_dreamcast) |
| 29 | #define YESBUTTONNAME "A" |
| 30 | #define NOBUTTONNAME "B" |
| 31 | #elif defined(GP2X) |
| 32 | #define YESBUTTONNAME "Y" |
| 33 | #define NOBUTTONNAME "B" |
| 34 | #else |
| 35 | #define YESBUTTONNAME "Y" |
| 36 | #define NOBUTTONNAME "N" |
| 37 | #endif |
| 38 | |
| 39 | #include "foreign.h" |
| 40 | |
| 41 | #ifndef SPEAR |
| 42 | #include "audiowl6.h" |
| 43 | #ifdef UPLOAD |
| 44 | #include "gfxv_apo.h" |
| 45 | #else |
| 46 | #ifdef GOODTIMES |
| 47 | #include "gfxv_wl6.h" |
| 48 | #else |
| 49 | #include "gfxv_apo.h" |
| 50 | #endif |
| 51 | #endif |
| 52 | #else |
| 53 | #include "audiosod.h" |
| 54 | #include "gfxv_sod.h" |
| 55 | #include "f_spear.h" |
| 56 | #endif |
| 57 | |
| 58 | typedef uint8_t byte; |
| 59 | typedef uint16_t word; |
| 60 | typedef int32_t fixed; |
| 61 | typedef uint32_t longword; |
| 62 | typedef int8_t boolean; |
| 63 | typedef void * memptr; |
| 64 | |
| 65 | typedef struct |
| 66 | { |
| 67 | int x,y; |
| 68 | } Point; |
| 69 | typedef struct |
| 70 | { |
| 71 | Point ul,lr; |
| 72 | } Rect; |
| 73 | |
| 74 | void Quit(const char *errorStr, ...); |
| 75 | |
| 76 | #include "id_pm.h" |
| 77 | #include "id_sd.h" |
| 78 | #include "id_in.h" |
| 79 | #include "id_vl.h" |
| 80 | #include "id_vh.h" |
| 81 | #include "id_us.h" |
| 82 | #include "id_ca.h" |
| 83 | |
| 84 | #include "wl_menu.h" |
| 85 | |
| 86 | #define MAPSPOT(x,y,plane) (mapsegs[plane][((y)<<mapshift)+(x)]) |
| 87 | |
| 88 | #define SIGN(x) ((x)>0?1:-1) |
| 89 | #define ABS(x) ((int)(x)>0?(x):-(x)) |
| 90 | #define LABS(x) ((int32_t)(x)>0?(x):-(x)) |
| 91 | |
| 92 | #define abs(x) ABS(x) |
| 93 | |
| 94 | /* |
| 95 | ============================================================================= |
| 96 | |
| 97 | GLOBAL CONSTANTS |
| 98 | |
| 99 | ============================================================================= |
| 100 | */ |
| 101 | |
| 102 | #define MAXTICS 10 |
| 103 | #define DEMOTICS 4 |
| 104 | |
| 105 | #define MAXACTORS 150 // max number of nazis, etc / map |
| 106 | #define MAXSTATS 400 // max number of lamps, bonus, etc |
| 107 | #define MAXDOORS 64 // max number of sliding doors |
| 108 | #define MAXWALLTILES 64 // max number of wall tiles |
| 109 | |
| 110 | // |
| 111 | // tile constants |
| 112 | // |
| 113 | |
| 114 | #define ICONARROWS 90 |
| 115 | #define PUSHABLETILE 98 |
| 116 | #define EXITTILE 99 // at end of castle |
| 117 | #define AREATILE 107 // first of NUMAREAS floor tiles |
| 118 | #define NUMAREAS 37 |
| 119 | #define ELEVATORTILE 21 |
| 120 | #define AMBUSHTILE 106 |
| 121 | #define ALTELEVATORTILE 107 |
| 122 | |
| 123 | #define NUMBERCHARS 9 |
| 124 | |
| 125 | |
| 126 | //---------------- |
| 127 | |
| 128 | #define EXTRAPOINTS 40000 |
| 129 | |
| 130 | #define PLAYERSPEED 3000 |
| 131 | #define RUNSPEED 6000 |
| 132 | |
| 133 | #define SCREENSEG 0xa000 |
| 134 | |
| 135 | #define SCREENBWIDE 80 |
| 136 | |
| 137 | #define HEIGHTRATIO 0.50 // also defined in id_mm.c |
| 138 | |
| 139 | #define BORDERCOLOR 3 |
| 140 | #define FLASHCOLOR 5 |
| 141 | #define FLASHTICS 4 |
| 142 | |
| 143 | #ifndef SPEAR |
| 144 | #define LRpack 8 // # of levels to store in endgame |
| 145 | #else |
| 146 | #define LRpack 20 |
| 147 | #endif |
| 148 | |
| 149 | #define PLAYERSIZE MINDIST // player radius |
| 150 | #define MINACTORDIST 0x10000l // minimum dist from player center |
| 151 | // to any actor center |
| 152 | |
| 153 | #define NUMLATCHPICS 100 |
| 154 | |
| 155 | #undef M_PI |
| 156 | #define PI 3.141592657 |
| 157 | #define M_PI PI |
| 158 | |
| 159 | #define GLOBAL1 (1l<<16) |
| 160 | #define TILEGLOBAL GLOBAL1 |
| 161 | #define PIXGLOBAL (GLOBAL1/64) |
| 162 | #define TILESHIFT 16l |
| 163 | #define UNSIGNEDSHIFT 8 |
| 164 | |
| 165 | #define ANGLES 360 // must be divisable by 4 |
| 166 | #define ANGLEQUAD (ANGLES/4) |
| 167 | #define FINEANGLES 3600 |
| 168 | #define ANG90 (FINEANGLES/4) |
| 169 | #define ANG180 (ANG90*2) |
| 170 | #define ANG270 (ANG90*3) |
| 171 | #define ANG360 (ANG90*4) |
| 172 | #define VANG90 (ANGLES/4) |
| 173 | #define VANG180 (VANG90*2) |
| 174 | #define VANG270 (VANG90*3) |
| 175 | #define VANG360 (VANG90*4) |
| 176 | |
| 177 | #define MINDIST (0x5800l) |
| 178 | |
| 179 | #define mapshift 6 |
| 180 | #define MAPSIZE (1<<mapshift) |
| 181 | #define maparea MAPSIZE*MAPSIZE |
| 182 | |
| 183 | #define mapheight MAPSIZE |
| 184 | #define mapwidth MAPSIZE |
| 185 | |
| 186 | #ifdef USE_HIRES |
| 187 | |
| 188 | #define TEXTURESHIFT 7 |
| 189 | #define TEXTURESIZE (1<<TEXTURESHIFT) |
| 190 | #define TEXTUREFROMFIXEDSHIFT 2 |
| 191 | #define TEXTUREMASK (TEXTURESIZE*(TEXTURESIZE-1)) |
| 192 | |
| 193 | #define SPRITESCALEFACTOR 1 |
| 194 | |
| 195 | #else |
| 196 | |
| 197 | #define TEXTURESHIFT 6 |
| 198 | #define TEXTURESIZE (1<<TEXTURESHIFT) |
| 199 | #define TEXTUREFROMFIXEDSHIFT 4 |
| 200 | #define TEXTUREMASK (TEXTURESIZE*(TEXTURESIZE-1)) |
| 201 | |
| 202 | #define SPRITESCALEFACTOR 2 |
| 203 | |
| 204 | #endif |
| 205 | |
| 206 | #define NORTH 0 |
| 207 | #define EAST 1 |
| 208 | #define SOUTH 2 |
| 209 | #define WEST 3 |
| 210 | |
| 211 | |
| 212 | #define STATUSLINES 40 |
| 213 | |
| 214 | #define SCREENSIZE (SCREENBWIDE*208) |
| 215 | #define PAGE1START 0 |
| 216 | #define PAGE2START (SCREENSIZE) |
| 217 | #define PAGE3START (SCREENSIZE*2u) |
| 218 | #define FREESTART (SCREENSIZE*3u) |
| 219 | |
| 220 | |
| 221 | #define PIXRADIUS 512 |
| 222 | |
| 223 | #define STARTAMMO 8 |
| 224 | |
| 225 | |
| 226 | // object flag values |
| 227 | |
| 228 | typedef enum |
| 229 | { |
| 230 | FL_SHOOTABLE = 0x00000001, |
| 231 | FL_BONUS = 0x00000002, |
| 232 | FL_NEVERMARK = 0x00000004, |
| 233 | FL_VISABLE = 0x00000008, |
| 234 | FL_ATTACKMODE = 0x00000010, |
| 235 | FL_FIRSTATTACK = 0x00000020, |
| 236 | FL_AMBUSH = 0x00000040, |
| 237 | FL_NONMARK = 0x00000080, |
| 238 | FL_FULLBRIGHT = 0x00000100, |
| 239 | #ifdef USE_DIR3DSPR |
| 240 | // you can choose one of the following values in wl_act1.cpp |
| 241 | // to make a static sprite a directional 3d sprite |
| 242 | // (see example at the end of the statinfo array) |
| 243 | FL_DIR_HORIZ_MID = 0x00000200, |
| 244 | FL_DIR_HORIZ_FW = 0x00000400, |
| 245 | FL_DIR_HORIZ_BW = 0x00000600, |
| 246 | FL_DIR_VERT_MID = 0x00000a00, |
| 247 | FL_DIR_VERT_FW = 0x00000c00, |
| 248 | FL_DIR_VERT_BW = 0x00000e00, |
| 249 | |
| 250 | // these values are just used to improve readability of code |
| 251 | FL_DIR_NONE = 0x00000000, |
| 252 | FL_DIR_POS_MID = 0x00000200, |
| 253 | FL_DIR_POS_FW = 0x00000400, |
| 254 | FL_DIR_POS_BW = 0x00000600, |
| 255 | FL_DIR_POS_MASK = 0x00000600, |
| 256 | FL_DIR_VERT_FLAG = 0x00000800, |
| 257 | FL_DIR_MASK = 0x00000e00, |
| 258 | #endif |
| 259 | // next free bit is 0x00001000 |
| 260 | } objflag_t; |
| 261 | |
| 262 | |
| 263 | // |
| 264 | // sprite constants |
| 265 | // |
| 266 | |
| 267 | enum |
| 268 | { |
| 269 | SPR_DEMO, |
| 270 | #ifndef APOGEE_1_0 |
| 271 | SPR_DEATHCAM, |
| 272 | #endif |
| 273 | // |
| 274 | // static sprites |
| 275 | // |
| 276 | SPR_STAT_0,SPR_STAT_1,SPR_STAT_2,SPR_STAT_3, |
| 277 | SPR_STAT_4,SPR_STAT_5,SPR_STAT_6,SPR_STAT_7, |
| 278 | |
| 279 | SPR_STAT_8,SPR_STAT_9,SPR_STAT_10,SPR_STAT_11, |
| 280 | SPR_STAT_12,SPR_STAT_13,SPR_STAT_14,SPR_STAT_15, |
| 281 | |
| 282 | SPR_STAT_16,SPR_STAT_17,SPR_STAT_18,SPR_STAT_19, |
| 283 | SPR_STAT_20,SPR_STAT_21,SPR_STAT_22,SPR_STAT_23, |
| 284 | |
| 285 | SPR_STAT_24,SPR_STAT_25,SPR_STAT_26,SPR_STAT_27, |
| 286 | SPR_STAT_28,SPR_STAT_29,SPR_STAT_30,SPR_STAT_31, |
| 287 | |
| 288 | SPR_STAT_32,SPR_STAT_33,SPR_STAT_34,SPR_STAT_35, |
| 289 | SPR_STAT_36,SPR_STAT_37,SPR_STAT_38,SPR_STAT_39, |
| 290 | |
| 291 | SPR_STAT_40,SPR_STAT_41,SPR_STAT_42,SPR_STAT_43, |
| 292 | SPR_STAT_44,SPR_STAT_45,SPR_STAT_46,SPR_STAT_47, |
| 293 | |
| 294 | #ifdef SPEAR |
| 295 | SPR_STAT_48,SPR_STAT_49,SPR_STAT_50,SPR_STAT_51, |
| 296 | #endif |
| 297 | |
| 298 | // |
| 299 | // guard |
| 300 | // |
| 301 | SPR_GRD_S_1,SPR_GRD_S_2,SPR_GRD_S_3,SPR_GRD_S_4, |
| 302 | SPR_GRD_S_5,SPR_GRD_S_6,SPR_GRD_S_7,SPR_GRD_S_8, |
| 303 | |
| 304 | SPR_GRD_W1_1,SPR_GRD_W1_2,SPR_GRD_W1_3,SPR_GRD_W1_4, |
| 305 | SPR_GRD_W1_5,SPR_GRD_W1_6,SPR_GRD_W1_7,SPR_GRD_W1_8, |
| 306 | |
| 307 | SPR_GRD_W2_1,SPR_GRD_W2_2,SPR_GRD_W2_3,SPR_GRD_W2_4, |
| 308 | SPR_GRD_W2_5,SPR_GRD_W2_6,SPR_GRD_W2_7,SPR_GRD_W2_8, |
| 309 | |
| 310 | SPR_GRD_W3_1,SPR_GRD_W3_2,SPR_GRD_W3_3,SPR_GRD_W3_4, |
| 311 | SPR_GRD_W3_5,SPR_GRD_W3_6,SPR_GRD_W3_7,SPR_GRD_W3_8, |
| 312 | |
| 313 | SPR_GRD_W4_1,SPR_GRD_W4_2,SPR_GRD_W4_3,SPR_GRD_W4_4, |
| 314 | SPR_GRD_W4_5,SPR_GRD_W4_6,SPR_GRD_W4_7,SPR_GRD_W4_8, |
| 315 | |
| 316 | SPR_GRD_PAIN_1,SPR_GRD_DIE_1,SPR_GRD_DIE_2,SPR_GRD_DIE_3, |
| 317 | SPR_GRD_PAIN_2,SPR_GRD_DEAD, |
| 318 | |
| 319 | SPR_GRD_SHOOT1,SPR_GRD_SHOOT2,SPR_GRD_SHOOT3, |
| 320 | |
| 321 | // |
| 322 | // dogs |
| 323 | // |
| 324 | SPR_DOG_W1_1,SPR_DOG_W1_2,SPR_DOG_W1_3,SPR_DOG_W1_4, |
| 325 | SPR_DOG_W1_5,SPR_DOG_W1_6,SPR_DOG_W1_7,SPR_DOG_W1_8, |
| 326 | |
| 327 | SPR_DOG_W2_1,SPR_DOG_W2_2,SPR_DOG_W2_3,SPR_DOG_W2_4, |
| 328 | SPR_DOG_W2_5,SPR_DOG_W2_6,SPR_DOG_W2_7,SPR_DOG_W2_8, |
| 329 | |
| 330 | SPR_DOG_W3_1,SPR_DOG_W3_2,SPR_DOG_W3_3,SPR_DOG_W3_4, |
| 331 | SPR_DOG_W3_5,SPR_DOG_W3_6,SPR_DOG_W3_7,SPR_DOG_W3_8, |
| 332 | |
| 333 | SPR_DOG_W4_1,SPR_DOG_W4_2,SPR_DOG_W4_3,SPR_DOG_W4_4, |
| 334 | SPR_DOG_W4_5,SPR_DOG_W4_6,SPR_DOG_W4_7,SPR_DOG_W4_8, |
| 335 | |
| 336 | SPR_DOG_DIE_1,SPR_DOG_DIE_2,SPR_DOG_DIE_3,SPR_DOG_DEAD, |
| 337 | SPR_DOG_JUMP1,SPR_DOG_JUMP2,SPR_DOG_JUMP3, |
| 338 | |
| 339 | |
| 340 | |
| 341 | // |
| 342 | // ss |
| 343 | // |
| 344 | SPR_SS_S_1,SPR_SS_S_2,SPR_SS_S_3,SPR_SS_S_4, |
| 345 | SPR_SS_S_5,SPR_SS_S_6,SPR_SS_S_7,SPR_SS_S_8, |
| 346 | |
| 347 | SPR_SS_W1_1,SPR_SS_W1_2,SPR_SS_W1_3,SPR_SS_W1_4, |
| 348 | SPR_SS_W1_5,SPR_SS_W1_6,SPR_SS_W1_7,SPR_SS_W1_8, |
| 349 | |
| 350 | SPR_SS_W2_1,SPR_SS_W2_2,SPR_SS_W2_3,SPR_SS_W2_4, |
| 351 | SPR_SS_W2_5,SPR_SS_W2_6,SPR_SS_W2_7,SPR_SS_W2_8, |
| 352 | |
| 353 | SPR_SS_W3_1,SPR_SS_W3_2,SPR_SS_W3_3,SPR_SS_W3_4, |
| 354 | SPR_SS_W3_5,SPR_SS_W3_6,SPR_SS_W3_7,SPR_SS_W3_8, |
| 355 | |
| 356 | SPR_SS_W4_1,SPR_SS_W4_2,SPR_SS_W4_3,SPR_SS_W4_4, |
| 357 | SPR_SS_W4_5,SPR_SS_W4_6,SPR_SS_W4_7,SPR_SS_W4_8, |
| 358 | |
| 359 | SPR_SS_PAIN_1,SPR_SS_DIE_1,SPR_SS_DIE_2,SPR_SS_DIE_3, |
| 360 | SPR_SS_PAIN_2,SPR_SS_DEAD, |
| 361 | |
| 362 | SPR_SS_SHOOT1,SPR_SS_SHOOT2,SPR_SS_SHOOT3, |
| 363 | |
| 364 | // |
| 365 | // mutant |
| 366 | // |
| 367 | SPR_MUT_S_1,SPR_MUT_S_2,SPR_MUT_S_3,SPR_MUT_S_4, |
| 368 | SPR_MUT_S_5,SPR_MUT_S_6,SPR_MUT_S_7,SPR_MUT_S_8, |
| 369 | |
| 370 | SPR_MUT_W1_1,SPR_MUT_W1_2,SPR_MUT_W1_3,SPR_MUT_W1_4, |
| 371 | SPR_MUT_W1_5,SPR_MUT_W1_6,SPR_MUT_W1_7,SPR_MUT_W1_8, |
| 372 | |
| 373 | SPR_MUT_W2_1,SPR_MUT_W2_2,SPR_MUT_W2_3,SPR_MUT_W2_4, |
| 374 | SPR_MUT_W2_5,SPR_MUT_W2_6,SPR_MUT_W2_7,SPR_MUT_W2_8, |
| 375 | |
| 376 | SPR_MUT_W3_1,SPR_MUT_W3_2,SPR_MUT_W3_3,SPR_MUT_W3_4, |
| 377 | SPR_MUT_W3_5,SPR_MUT_W3_6,SPR_MUT_W3_7,SPR_MUT_W3_8, |
| 378 | |
| 379 | SPR_MUT_W4_1,SPR_MUT_W4_2,SPR_MUT_W4_3,SPR_MUT_W4_4, |
| 380 | SPR_MUT_W4_5,SPR_MUT_W4_6,SPR_MUT_W4_7,SPR_MUT_W4_8, |
| 381 | |
| 382 | SPR_MUT_PAIN_1,SPR_MUT_DIE_1,SPR_MUT_DIE_2,SPR_MUT_DIE_3, |
| 383 | SPR_MUT_PAIN_2,SPR_MUT_DIE_4,SPR_MUT_DEAD, |
| 384 | |
| 385 | SPR_MUT_SHOOT1,SPR_MUT_SHOOT2,SPR_MUT_SHOOT3,SPR_MUT_SHOOT4, |
| 386 | |
| 387 | // |
| 388 | // officer |
| 389 | // |
| 390 | SPR_OFC_S_1,SPR_OFC_S_2,SPR_OFC_S_3,SPR_OFC_S_4, |
| 391 | SPR_OFC_S_5,SPR_OFC_S_6,SPR_OFC_S_7,SPR_OFC_S_8, |
| 392 | |
| 393 | SPR_OFC_W1_1,SPR_OFC_W1_2,SPR_OFC_W1_3,SPR_OFC_W1_4, |
| 394 | SPR_OFC_W1_5,SPR_OFC_W1_6,SPR_OFC_W1_7,SPR_OFC_W1_8, |
| 395 | |
| 396 | SPR_OFC_W2_1,SPR_OFC_W2_2,SPR_OFC_W2_3,SPR_OFC_W2_4, |
| 397 | SPR_OFC_W2_5,SPR_OFC_W2_6,SPR_OFC_W2_7,SPR_OFC_W2_8, |
| 398 | |
| 399 | SPR_OFC_W3_1,SPR_OFC_W3_2,SPR_OFC_W3_3,SPR_OFC_W3_4, |
| 400 | SPR_OFC_W3_5,SPR_OFC_W3_6,SPR_OFC_W3_7,SPR_OFC_W3_8, |
| 401 | |
| 402 | SPR_OFC_W4_1,SPR_OFC_W4_2,SPR_OFC_W4_3,SPR_OFC_W4_4, |
| 403 | SPR_OFC_W4_5,SPR_OFC_W4_6,SPR_OFC_W4_7,SPR_OFC_W4_8, |
| 404 | |
| 405 | SPR_OFC_PAIN_1,SPR_OFC_DIE_1,SPR_OFC_DIE_2,SPR_OFC_DIE_3, |
| 406 | SPR_OFC_PAIN_2,SPR_OFC_DIE_4,SPR_OFC_DEAD, |
| 407 | |
| 408 | SPR_OFC_SHOOT1,SPR_OFC_SHOOT2,SPR_OFC_SHOOT3, |
| 409 | |
| 410 | #ifndef SPEAR |
| 411 | // |
| 412 | // ghosts |
| 413 | // |
| 414 | SPR_BLINKY_W1,SPR_BLINKY_W2,SPR_PINKY_W1,SPR_PINKY_W2, |
| 415 | SPR_CLYDE_W1,SPR_CLYDE_W2,SPR_INKY_W1,SPR_INKY_W2, |
| 416 | |
| 417 | // |
| 418 | // hans |
| 419 | // |
| 420 | SPR_BOSS_W1,SPR_BOSS_W2,SPR_BOSS_W3,SPR_BOSS_W4, |
| 421 | SPR_BOSS_SHOOT1,SPR_BOSS_SHOOT2,SPR_BOSS_SHOOT3,SPR_BOSS_DEAD, |
| 422 | |
| 423 | SPR_BOSS_DIE1,SPR_BOSS_DIE2,SPR_BOSS_DIE3, |
| 424 | |
| 425 | // |
| 426 | // schabbs |
| 427 | // |
| 428 | SPR_SCHABB_W1,SPR_SCHABB_W2,SPR_SCHABB_W3,SPR_SCHABB_W4, |
| 429 | SPR_SCHABB_SHOOT1,SPR_SCHABB_SHOOT2, |
| 430 | |
| 431 | SPR_SCHABB_DIE1,SPR_SCHABB_DIE2,SPR_SCHABB_DIE3,SPR_SCHABB_DEAD, |
| 432 | SPR_HYPO1,SPR_HYPO2,SPR_HYPO3,SPR_HYPO4, |
| 433 | |
| 434 | // |
| 435 | // fake |
| 436 | // |
| 437 | SPR_FAKE_W1,SPR_FAKE_W2,SPR_FAKE_W3,SPR_FAKE_W4, |
| 438 | SPR_FAKE_SHOOT,SPR_FIRE1,SPR_FIRE2, |
| 439 | |
| 440 | SPR_FAKE_DIE1,SPR_FAKE_DIE2,SPR_FAKE_DIE3,SPR_FAKE_DIE4, |
| 441 | SPR_FAKE_DIE5,SPR_FAKE_DEAD, |
| 442 | |
| 443 | // |
| 444 | // hitler |
| 445 | // |
| 446 | SPR_MECHA_W1,SPR_MECHA_W2,SPR_MECHA_W3,SPR_MECHA_W4, |
| 447 | SPR_MECHA_SHOOT1,SPR_MECHA_SHOOT2,SPR_MECHA_SHOOT3,SPR_MECHA_DEAD, |
| 448 | |
| 449 | SPR_MECHA_DIE1,SPR_MECHA_DIE2,SPR_MECHA_DIE3, |
| 450 | |
| 451 | SPR_HITLER_W1,SPR_HITLER_W2,SPR_HITLER_W3,SPR_HITLER_W4, |
| 452 | SPR_HITLER_SHOOT1,SPR_HITLER_SHOOT2,SPR_HITLER_SHOOT3,SPR_HITLER_DEAD, |
| 453 | |
| 454 | SPR_HITLER_DIE1,SPR_HITLER_DIE2,SPR_HITLER_DIE3,SPR_HITLER_DIE4, |
| 455 | SPR_HITLER_DIE5,SPR_HITLER_DIE6,SPR_HITLER_DIE7, |
| 456 | |
| 457 | // |
| 458 | // giftmacher |
| 459 | // |
| 460 | SPR_GIFT_W1,SPR_GIFT_W2,SPR_GIFT_W3,SPR_GIFT_W4, |
| 461 | SPR_GIFT_SHOOT1,SPR_GIFT_SHOOT2, |
| 462 | |
| 463 | SPR_GIFT_DIE1,SPR_GIFT_DIE2,SPR_GIFT_DIE3,SPR_GIFT_DEAD, |
| 464 | #endif |
| 465 | // |
| 466 | // Rocket, smoke and small explosion |
| 467 | // |
| 468 | SPR_ROCKET_1,SPR_ROCKET_2,SPR_ROCKET_3,SPR_ROCKET_4, |
| 469 | SPR_ROCKET_5,SPR_ROCKET_6,SPR_ROCKET_7,SPR_ROCKET_8, |
| 470 | |
| 471 | SPR_SMOKE_1,SPR_SMOKE_2,SPR_SMOKE_3,SPR_SMOKE_4, |
| 472 | SPR_BOOM_1,SPR_BOOM_2,SPR_BOOM_3, |
| 473 | |
| 474 | // |
| 475 | // Angel of Death's DeathSparks(tm) |
| 476 | // |
| 477 | #ifdef SPEAR |
| 478 | SPR_HROCKET_1,SPR_HROCKET_2,SPR_HROCKET_3,SPR_HROCKET_4, |
| 479 | SPR_HROCKET_5,SPR_HROCKET_6,SPR_HROCKET_7,SPR_HROCKET_8, |
| 480 | |
| 481 | SPR_HSMOKE_1,SPR_HSMOKE_2,SPR_HSMOKE_3,SPR_HSMOKE_4, |
| 482 | SPR_HBOOM_1,SPR_HBOOM_2,SPR_HBOOM_3, |
| 483 | |
| 484 | SPR_SPARK1,SPR_SPARK2,SPR_SPARK3,SPR_SPARK4, |
| 485 | #endif |
| 486 | |
| 487 | #ifndef SPEAR |
| 488 | // |
| 489 | // gretel |
| 490 | // |
| 491 | SPR_GRETEL_W1,SPR_GRETEL_W2,SPR_GRETEL_W3,SPR_GRETEL_W4, |
| 492 | SPR_GRETEL_SHOOT1,SPR_GRETEL_SHOOT2,SPR_GRETEL_SHOOT3,SPR_GRETEL_DEAD, |
| 493 | |
| 494 | SPR_GRETEL_DIE1,SPR_GRETEL_DIE2,SPR_GRETEL_DIE3, |
| 495 | |
| 496 | // |
| 497 | // fat face |
| 498 | // |
| 499 | SPR_FAT_W1,SPR_FAT_W2,SPR_FAT_W3,SPR_FAT_W4, |
| 500 | SPR_FAT_SHOOT1,SPR_FAT_SHOOT2,SPR_FAT_SHOOT3,SPR_FAT_SHOOT4, |
| 501 | |
| 502 | SPR_FAT_DIE1,SPR_FAT_DIE2,SPR_FAT_DIE3,SPR_FAT_DEAD, |
| 503 | |
| 504 | // |
| 505 | // bj |
| 506 | // |
| 507 | #ifdef APOGEE_1_0 |
| 508 | SPR_BJ_W1=360, |
| 509 | #elif defined(APOGEE_1_1) && defined(UPLOAD) |
| 510 | SPR_BJ_W1=406, |
| 511 | #else |
| 512 | SPR_BJ_W1, |
| 513 | #endif |
| 514 | SPR_BJ_W2,SPR_BJ_W3,SPR_BJ_W4, |
| 515 | SPR_BJ_JUMP1,SPR_BJ_JUMP2,SPR_BJ_JUMP3,SPR_BJ_JUMP4, |
| 516 | #else |
| 517 | // |
| 518 | // THESE ARE FOR 'SPEAR OF DESTINY' |
| 519 | // |
| 520 | |
| 521 | // |
| 522 | // Trans Grosse |
| 523 | // |
| 524 | SPR_TRANS_W1,SPR_TRANS_W2,SPR_TRANS_W3,SPR_TRANS_W4, |
| 525 | SPR_TRANS_SHOOT1,SPR_TRANS_SHOOT2,SPR_TRANS_SHOOT3,SPR_TRANS_DEAD, |
| 526 | |
| 527 | SPR_TRANS_DIE1,SPR_TRANS_DIE2,SPR_TRANS_DIE3, |
| 528 | |
| 529 | // |
| 530 | // Wilhelm |
| 531 | // |
| 532 | SPR_WILL_W1,SPR_WILL_W2,SPR_WILL_W3,SPR_WILL_W4, |
| 533 | SPR_WILL_SHOOT1,SPR_WILL_SHOOT2,SPR_WILL_SHOOT3,SPR_WILL_SHOOT4, |
| 534 | |
| 535 | SPR_WILL_DIE1,SPR_WILL_DIE2,SPR_WILL_DIE3,SPR_WILL_DEAD, |
| 536 | |
| 537 | // |
| 538 | // UberMutant |
| 539 | // |
| 540 | SPR_UBER_W1,SPR_UBER_W2,SPR_UBER_W3,SPR_UBER_W4, |
| 541 | SPR_UBER_SHOOT1,SPR_UBER_SHOOT2,SPR_UBER_SHOOT3,SPR_UBER_SHOOT4, |
| 542 | |
| 543 | SPR_UBER_DIE1,SPR_UBER_DIE2,SPR_UBER_DIE3,SPR_UBER_DIE4, |
| 544 | SPR_UBER_DEAD, |
| 545 | |
| 546 | // |
| 547 | // Death Knight |
| 548 | // |
| 549 | SPR_DEATH_W1,SPR_DEATH_W2,SPR_DEATH_W3,SPR_DEATH_W4, |
| 550 | SPR_DEATH_SHOOT1,SPR_DEATH_SHOOT2,SPR_DEATH_SHOOT3,SPR_DEATH_SHOOT4, |
| 551 | |
| 552 | SPR_DEATH_DIE1,SPR_DEATH_DIE2,SPR_DEATH_DIE3,SPR_DEATH_DIE4, |
| 553 | SPR_DEATH_DIE5,SPR_DEATH_DIE6,SPR_DEATH_DEAD, |
| 554 | |
| 555 | // |
| 556 | // Ghost |
| 557 | // |
| 558 | SPR_SPECTRE_W1,SPR_SPECTRE_W2,SPR_SPECTRE_W3,SPR_SPECTRE_W4, |
| 559 | SPR_SPECTRE_F1,SPR_SPECTRE_F2,SPR_SPECTRE_F3,SPR_SPECTRE_F4, |
| 560 | |
| 561 | // |
| 562 | // Angel of Death |
| 563 | // |
| 564 | SPR_ANGEL_W1,SPR_ANGEL_W2,SPR_ANGEL_W3,SPR_ANGEL_W4, |
| 565 | SPR_ANGEL_SHOOT1,SPR_ANGEL_SHOOT2,SPR_ANGEL_TIRED1,SPR_ANGEL_TIRED2, |
| 566 | |
| 567 | SPR_ANGEL_DIE1,SPR_ANGEL_DIE2,SPR_ANGEL_DIE3,SPR_ANGEL_DIE4, |
| 568 | SPR_ANGEL_DIE5,SPR_ANGEL_DIE6,SPR_ANGEL_DIE7,SPR_ANGEL_DEAD, |
| 569 | |
| 570 | #endif |
| 571 | |
| 572 | // |
| 573 | // player attack frames |
| 574 | // |
| 575 | SPR_KNIFEREADY,SPR_KNIFEATK1,SPR_KNIFEATK2,SPR_KNIFEATK3, |
| 576 | SPR_KNIFEATK4, |
| 577 | |
| 578 | SPR_PISTOLREADY,SPR_PISTOLATK1,SPR_PISTOLATK2,SPR_PISTOLATK3, |
| 579 | SPR_PISTOLATK4, |
| 580 | |
| 581 | SPR_MACHINEGUNREADY,SPR_MACHINEGUNATK1,SPR_MACHINEGUNATK2,MACHINEGUNATK3, |
| 582 | SPR_MACHINEGUNATK4, |
| 583 | |
| 584 | SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3, |
| 585 | SPR_CHAINATK4, |
| 586 | |
| 587 | }; |
| 588 | |
| 589 | |
| 590 | /* |
| 591 | ============================================================================= |
| 592 | |
| 593 | GLOBAL TYPES |
| 594 | |
| 595 | ============================================================================= |
| 596 | */ |
| 597 | |
| 598 | typedef enum { |
| 599 | di_north, |
| 600 | di_east, |
| 601 | di_south, |
| 602 | di_west |
| 603 | } controldir_t; |
| 604 | |
| 605 | typedef enum { |
| 606 | dr_normal, |
| 607 | dr_lock1, |
| 608 | dr_lock2, |
| 609 | dr_lock3, |
| 610 | dr_lock4, |
| 611 | dr_elevator |
| 612 | } door_t; |
| 613 | |
| 614 | typedef enum { |
| 615 | ac_badobject = -1, |
| 616 | ac_no, |
| 617 | ac_yes, |
| 618 | ac_allways |
| 619 | } activetype; |
| 620 | |
| 621 | typedef enum { |
| 622 | nothing, |
| 623 | playerobj, |
| 624 | inertobj, |
| 625 | guardobj, |
| 626 | officerobj, |
| 627 | ssobj, |
| 628 | dogobj, |
| 629 | bossobj, |
| 630 | schabbobj, |
| 631 | fakeobj, |
| 632 | mechahitlerobj, |
| 633 | mutantobj, |
| 634 | needleobj, |
| 635 | fireobj, |
| 636 | bjobj, |
| 637 | ghostobj, |
| 638 | realhitlerobj, |
| 639 | gretelobj, |
| 640 | giftobj, |
| 641 | fatobj, |
| 642 | rocketobj, |
| 643 | |
| 644 | spectreobj, |
| 645 | angelobj, |
| 646 | transobj, |
| 647 | uberobj, |
| 648 | willobj, |
| 649 | deathobj, |
| 650 | hrocketobj, |
| 651 | sparkobj |
| 652 | } classtype; |
| 653 | |
| 654 | typedef enum { |
| 655 | none, |
| 656 | block, |
| 657 | bo_gibs, |
| 658 | bo_alpo, |
| 659 | bo_firstaid, |
| 660 | bo_key1, |
| 661 | bo_key2, |
| 662 | bo_key3, |
| 663 | bo_key4, |
| 664 | bo_cross, |
| 665 | bo_chalice, |
| 666 | bo_bible, |
| 667 | bo_crown, |
| 668 | bo_clip, |
| 669 | bo_clip2, |
| 670 | bo_machinegun, |
| 671 | bo_chaingun, |
| 672 | bo_food, |
| 673 | bo_fullheal, |
| 674 | bo_25clip, |
| 675 | bo_spear |
| 676 | } wl_stat_t; |
| 677 | |
| 678 | typedef enum { |
| 679 | east, |
| 680 | northeast, |
| 681 | north, |
| 682 | northwest, |
| 683 | west, |
| 684 | southwest, |
| 685 | south, |
| 686 | southeast, |
| 687 | nodir |
| 688 | } dirtype; |
| 689 | |
| 690 | |
| 691 | #define NUMENEMIES 22 |
| 692 | typedef enum { |
| 693 | en_guard, |
| 694 | en_officer, |
| 695 | en_ss, |
| 696 | en_dog, |
| 697 | en_boss, |
| 698 | en_schabbs, |
| 699 | en_fake, |
| 700 | en_hitler, |
| 701 | en_mutant, |
| 702 | en_blinky, |
| 703 | en_clyde, |
| 704 | en_pinky, |
| 705 | en_inky, |
| 706 | en_gretel, |
| 707 | en_gift, |
| 708 | en_fat, |
| 709 | en_spectre, |
| 710 | en_angel, |
| 711 | en_trans, |
| 712 | en_uber, |
| 713 | en_will, |
| 714 | en_death |
| 715 | } enemy_t; |
| 716 | |
| 717 | typedef void (* statefunc) (void *); |
| 718 | |
| 719 | typedef struct statestruct |
| 720 | { |
| 721 | boolean rotate; |
| 722 | short shapenum; // a shapenum of -1 means get from ob->temp1 |
| 723 | short tictime; |
| 724 | void (*think) (void *),(*action) (void *); |
| 725 | struct statestruct *next; |
| 726 | } statetype; |
| 727 | |
| 728 | |
| 729 | //--------------------- |
| 730 | // |
| 731 | // trivial actor structure |
| 732 | // |
| 733 | //--------------------- |
| 734 | |
| 735 | typedef struct statstruct |
| 736 | { |
| 737 | byte tilex,tiley; |
| 738 | short shapenum; // if shapenum == -1 the obj has been removed |
| 739 | byte *visspot; |
| 740 | uint32_t flags; |
| 741 | byte itemnumber; |
| 742 | } statobj_t; |
| 743 | |
| 744 | |
| 745 | //--------------------- |
| 746 | // |
| 747 | // door actor structure |
| 748 | // |
| 749 | //--------------------- |
| 750 | |
| 751 | typedef enum |
| 752 | { |
| 753 | dr_open,dr_closed,dr_opening,dr_closing |
| 754 | } doortype; |
| 755 | |
| 756 | typedef struct doorstruct |
| 757 | { |
| 758 | byte tilex,tiley; |
| 759 | boolean vertical; |
| 760 | byte lock; |
| 761 | doortype action; |
| 762 | short ticcount; |
| 763 | } doorobj_t; |
| 764 | |
| 765 | |
| 766 | //-------------------- |
| 767 | // |
| 768 | // thinking actor structure |
| 769 | // |
| 770 | //-------------------- |
| 771 | |
| 772 | typedef struct objstruct |
| 773 | { |
| 774 | activetype active; |
| 775 | short ticcount; |
| 776 | classtype obclass; |
| 777 | statetype *state; |
| 778 | |
| 779 | uint32_t flags; // FL_SHOOTABLE, etc |
| 780 | |
| 781 | int32_t distance; // if negative, wait for that door to open |
| 782 | dirtype dir; |
| 783 | |
| 784 | fixed x,y; |
| 785 | word tilex,tiley; |
| 786 | byte areanumber; |
| 787 | |
| 788 | short viewx; |
| 789 | word viewheight; |
| 790 | fixed transx,transy; // in global coord |
| 791 | |
| 792 | short angle; |
| 793 | short hitpoints; |
| 794 | int32_t speed; |
| 795 | |
| 796 | short temp1,temp2,hidden; |
| 797 | struct objstruct *next,*prev; |
| 798 | } objtype; |
| 799 | |
| 800 | enum |
| 801 | { |
| 802 | bt_nobutton=-1, |
| 803 | bt_attack=0, |
| 804 | bt_strafe, |
| 805 | bt_run, |
| 806 | bt_use, |
| 807 | bt_readyknife, |
| 808 | bt_readypistol, |
| 809 | bt_readymachinegun, |
| 810 | bt_readychaingun, |
| 811 | bt_nextweapon, |
| 812 | bt_prevweapon, |
| 813 | bt_esc, |
| 814 | bt_pause, |
| 815 | bt_strafeleft, |
| 816 | bt_straferight, |
| 817 | bt_moveforward, |
| 818 | bt_movebackward, |
| 819 | bt_turnleft, |
| 820 | bt_turnright, |
| 821 | NUMBUTTONS |
| 822 | }; |
| 823 | |
| 824 | |
| 825 | #define NUMWEAPONS 4 |
| 826 | typedef enum |
| 827 | { |
| 828 | wp_knife, |
| 829 | wp_pistol, |
| 830 | wp_machinegun, |
| 831 | wp_chaingun |
| 832 | } weapontype; |
| 833 | |
| 834 | |
| 835 | enum |
| 836 | { |
| 837 | gd_baby, |
| 838 | gd_easy, |
| 839 | gd_medium, |
| 840 | gd_hard |
| 841 | }; |
| 842 | |
| 843 | //--------------- |
| 844 | // |
| 845 | // gamestate structure |
| 846 | // |
| 847 | //--------------- |
| 848 | |
| 849 | typedef struct |
| 850 | { |
| 851 | short difficulty; |
| 852 | short mapon; |
| 853 | int32_t oldscore,score,nextextra; |
| 854 | short lives; |
| 855 | short health; |
| 856 | short ammo; |
| 857 | short keys; |
| 858 | weapontype bestweapon,weapon,chosenweapon; |
| 859 | |
| 860 | short faceframe; |
| 861 | short attackframe,attackcount,weaponframe; |
| 862 | |
| 863 | short episode,secretcount,treasurecount,killcount, |
| 864 | secrettotal,treasuretotal,killtotal; |
| 865 | int32_t TimeCount; |
| 866 | int32_t killx,killy; |
| 867 | boolean victoryflag; // set during victory animations |
| 868 | } gametype; |
| 869 | |
| 870 | |
| 871 | typedef enum |
| 872 | { |
| 873 | ex_stillplaying, |
| 874 | ex_completed, |
| 875 | ex_died, |
| 876 | ex_warped, |
| 877 | ex_resetgame, |
| 878 | ex_loadedgame, |
| 879 | ex_victorious, |
| 880 | ex_abort, |
| 881 | ex_demodone, |
| 882 | ex_secretlevel |
| 883 | } exit_t; |
| 884 | |
| 885 | |
| 886 | extern word *mapsegs[MAPPLANES]; |
| 887 | extern int mapon; |
| 888 | |
| 889 | /* |
| 890 | ============================================================================= |
| 891 | |
| 892 | WL_MAIN DEFINITIONS |
| 893 | |
| 894 | ============================================================================= |
| 895 | */ |
| 896 | |
| 897 | extern boolean loadedgame; |
| 898 | extern fixed focallength; |
| 899 | extern int viewscreenx, viewscreeny; |
| 900 | extern int viewwidth; |
| 901 | extern int viewheight; |
| 902 | extern short centerx; |
| 903 | extern int32_t heightnumerator; |
| 904 | extern fixed scale; |
| 905 | |
| 906 | extern int dirangle[9]; |
| 907 | |
| 908 | extern int mouseadjustment; |
| 909 | extern int shootdelta; |
| 910 | extern unsigned screenofs; |
| 911 | |
| 912 | extern boolean startgame; |
| 913 | extern char str[80]; |
| 914 | extern char configdir[256]; |
| 915 | extern char configname[13]; |
| 916 | |
| 917 | // |
| 918 | // Command line parameter variables |
| 919 | // |
| 920 | extern boolean param_debugmode; |
| 921 | extern boolean param_nowait; |
| 922 | extern int param_difficulty; |
| 923 | extern int param_tedlevel; |
| 924 | extern int param_joystickindex; |
| 925 | extern int param_joystickhat; |
| 926 | extern int param_samplerate; |
| 927 | extern int param_audiobuffer; |
| 928 | extern int param_mission; |
| 929 | extern boolean param_goodtimes; |
| 930 | extern boolean param_ignorenumchunks; |
| 931 | |
| 932 | |
| 933 | void NewGame (int difficulty,int episode); |
| 934 | void CalcProjection (int32_t focal); |
| 935 | void NewViewSize (int width); |
| 936 | boolean SetViewSize (unsigned width, unsigned height); |
| 937 | boolean LoadTheGame(FILE *file,int x,int y); |
| 938 | boolean SaveTheGame(FILE *file,int x,int y); |
| 939 | void ShowViewSize (int width); |
| 940 | void ShutdownId (void); |
| 941 | |
| 942 | |
| 943 | /* |
| 944 | ============================================================================= |
| 945 | |
| 946 | WL_GAME DEFINITIONS |
| 947 | |
| 948 | ============================================================================= |
| 949 | */ |
| 950 | |
| 951 | extern gametype gamestate; |
| 952 | extern byte bordercol; |
| 953 | extern SDL_Surface *latchpics[NUMLATCHPICS]; |
| 954 | extern char demoname[13]; |
| 955 | |
| 956 | void SetupGameLevel (void); |
| 957 | void GameLoop (void); |
| 958 | void DrawPlayBorder (void); |
| 959 | void DrawStatusBorder (byte color); |
| 960 | void DrawPlayScreen (void); |
| 961 | void DrawPlayBorderSides (void); |
| 962 | void ShowActStatus(); |
| 963 | |
| 964 | void PlayDemo (int demonumber); |
| 965 | void RecordDemo (void); |
| 966 | |
| 967 | |
| 968 | #ifdef SPEAR |
| 969 | extern int32_t spearx,speary; |
| 970 | extern unsigned spearangle; |
| 971 | extern boolean spearflag; |
| 972 | #endif |
| 973 | |
| 974 | |
| 975 | #define ClearMemory SD_StopDigitized |
| 976 | |
| 977 | |
| 978 | // JAB |
| 979 | #define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(((int32_t)(tx) << TILESHIFT) + (1L << (TILESHIFT - 1))),(((int32_t)ty << TILESHIFT) + (1L << (TILESHIFT - 1)))) |
| 980 | #define PlaySoundLocActor(s,ob) PlaySoundLocGlobal(s,(ob)->x,(ob)->y) |
| 981 | void PlaySoundLocGlobal(word s,fixed gx,fixed gy); |
| 982 | void UpdateSoundLoc(void); |
| 983 | |
| 984 | |
| 985 | /* |
| 986 | ============================================================================= |
| 987 | |
| 988 | WL_PLAY DEFINITIONS |
| 989 | |
| 990 | ============================================================================= |
| 991 | */ |
| 992 | |
| 993 | #define BASEMOVE 35 |
| 994 | #define RUNMOVE 70 |
| 995 | #define BASETURN 35 |
| 996 | #define RUNTURN 70 |
| 997 | |
| 998 | #define JOYSCALE 2 |
| 999 | |
| 1000 | extern byte tilemap[MAPSIZE][MAPSIZE]; // wall values only |
| 1001 | extern byte spotvis[MAPSIZE][MAPSIZE]; |
| 1002 | extern objtype *actorat[MAPSIZE][MAPSIZE]; |
| 1003 | |
| 1004 | extern objtype *player; |
| 1005 | |
| 1006 | extern unsigned tics; |
| 1007 | extern int viewsize; |
| 1008 | |
| 1009 | extern int lastgamemusicoffset; |
| 1010 | |
| 1011 | // |
| 1012 | // current user input |
| 1013 | // |
| 1014 | extern int controlx,controly; // range from -100 to 100 |
| 1015 | extern boolean buttonstate[NUMBUTTONS]; |
| 1016 | extern objtype objlist[MAXACTORS]; |
| 1017 | extern boolean buttonheld[NUMBUTTONS]; |
| 1018 | extern exit_t playstate; |
| 1019 | extern boolean madenoise; |
| 1020 | extern statobj_t statobjlist[MAXSTATS]; |
| 1021 | extern statobj_t *laststatobj; |
| 1022 | extern objtype *newobj,*killerobj; |
| 1023 | extern doorobj_t doorobjlist[MAXDOORS]; |
| 1024 | extern doorobj_t *lastdoorobj; |
| 1025 | extern int godmode; |
| 1026 | |
| 1027 | extern boolean demorecord,demoplayback; |
| 1028 | extern int8_t *demoptr, *lastdemoptr; |
| 1029 | extern memptr demobuffer; |
| 1030 | |
| 1031 | // |
| 1032 | // control info |
| 1033 | // |
| 1034 | extern boolean mouseenabled,joystickenabled; |
| 1035 | extern int dirscan[4]; |
| 1036 | extern int buttonscan[NUMBUTTONS]; |
| 1037 | extern int buttonmouse[4]; |
| 1038 | extern int buttonjoy[32]; |
| 1039 | |
| 1040 | void InitActorList (void); |
| 1041 | void GetNewActor (void); |
| 1042 | void PlayLoop (void); |
| 1043 | |
| 1044 | void CenterWindow(word w,word h); |
| 1045 | |
| 1046 | void InitRedShifts (void); |
| 1047 | void FinishPaletteShifts (void); |
| 1048 | |
| 1049 | void RemoveObj (objtype *gone); |
| 1050 | void PollControls (void); |
| 1051 | int StopMusic(void); |
| 1052 | void StartMusic(void); |
| 1053 | void ContinueMusic(int offs); |
| 1054 | void StartDamageFlash (int damage); |
| 1055 | void StartBonusFlash (void); |
| 1056 | |
| 1057 | #ifdef SPEAR |
| 1058 | extern int32_t funnyticount; // FOR FUNNY BJ FACE |
| 1059 | #endif |
| 1060 | |
| 1061 | extern objtype *objfreelist; // *obj,*player,*lastobj, |
| 1062 | |
| 1063 | extern boolean noclip,ammocheat; |
| 1064 | extern int singlestep, extravbls; |
| 1065 | |
| 1066 | /* |
| 1067 | ============================================================================= |
| 1068 | |
| 1069 | WL_INTER |
| 1070 | |
| 1071 | ============================================================================= |
| 1072 | */ |
| 1073 | |
| 1074 | void IntroScreen (void); |
| 1075 | void PG13(void); |
| 1076 | void DrawHighScores(void); |
| 1077 | void CheckHighScore (int32_t score,word other); |
| 1078 | void Victory (void); |
| 1079 | void LevelCompleted (void); |
| 1080 | void ClearSplitVWB (void); |
| 1081 | |
| 1082 | void PreloadGraphics(void); |
| 1083 | |
| 1084 | |
| 1085 | /* |
| 1086 | ============================================================================= |
| 1087 | |
| 1088 | WL_DEBUG |
| 1089 | |
| 1090 | ============================================================================= |
| 1091 | */ |
| 1092 | |
| 1093 | int DebugKeys (void); |
| 1094 | |
| 1095 | /* |
| 1096 | ============================================================================= |
| 1097 | |
| 1098 | WL_DRAW DEFINITIONS |
| 1099 | |
| 1100 | ============================================================================= |
| 1101 | */ |
| 1102 | |
| 1103 | // |
| 1104 | // math tables |
| 1105 | // |
| 1106 | extern short *pixelangle; |
| 1107 | extern int32_t finetangent[FINEANGLES/4]; |
| 1108 | extern fixed sintable[]; |
| 1109 | extern fixed *costable; |
| 1110 | extern int *wallheight; |
| 1111 | extern word horizwall[],vertwall[]; |
| 1112 | extern int32_t lasttimecount; |
| 1113 | extern int32_t frameon; |
| 1114 | |
| 1115 | extern unsigned screenloc[3]; |
| 1116 | |
| 1117 | extern boolean fizzlein, fpscounter; |
| 1118 | |
| 1119 | extern fixed viewx,viewy; // the focal point |
| 1120 | extern fixed viewsin,viewcos; |
| 1121 | |
| 1122 | void ThreeDRefresh (void); |
| 1123 | void CalcTics (void); |
| 1124 | |
| 1125 | typedef struct |
| 1126 | { |
| 1127 | word leftpix,rightpix; |
| 1128 | word dataofs[64]; |
| 1129 | // table data after dataofs[rightpix-leftpix+1] |
| 1130 | } t_compshape; |
| 1131 | |
| 1132 | /* |
| 1133 | ============================================================================= |
| 1134 | |
| 1135 | WL_STATE DEFINITIONS |
| 1136 | |
| 1137 | ============================================================================= |
| 1138 | */ |
| 1139 | #define TURNTICS 10 |
| 1140 | #define SPDPATROL 512 |
| 1141 | #define SPDDOG 1500 |
| 1142 | |
| 1143 | |
| 1144 | void InitHitRect (objtype *ob, unsigned radius); |
| 1145 | void SpawnNewObj (unsigned tilex, unsigned tiley, statetype *state); |
| 1146 | void NewState (objtype *ob, statetype *state); |
| 1147 | |
| 1148 | boolean TryWalk (objtype *ob); |
| 1149 | void SelectChaseDir (objtype *ob); |
| 1150 | void SelectDodgeDir (objtype *ob); |
| 1151 | void SelectRunDir (objtype *ob); |
| 1152 | void MoveObj (objtype *ob, int32_t move); |
| 1153 | boolean SightPlayer (objtype *ob); |
| 1154 | |
| 1155 | void KillActor (objtype *ob); |
| 1156 | void DamageActor (objtype *ob, unsigned damage); |
| 1157 | |
| 1158 | boolean CheckLine (objtype *ob); |
| 1159 | boolean CheckSight (objtype *ob); |
| 1160 | |
| 1161 | /* |
| 1162 | ============================================================================= |
| 1163 | |
| 1164 | WL_AGENT DEFINITIONS |
| 1165 | |
| 1166 | ============================================================================= |
| 1167 | */ |
| 1168 | |
| 1169 | extern short anglefrac; |
| 1170 | extern int facecount, facetimes; |
| 1171 | extern word plux,pluy; // player coordinates scaled to unsigned |
| 1172 | extern int32_t thrustspeed; |
| 1173 | extern objtype *LastAttacker; |
| 1174 | |
| 1175 | void Thrust (int angle, int32_t speed); |
| 1176 | void SpawnPlayer (int tilex, int tiley, int dir); |
| 1177 | void TakeDamage (int points,objtype *attacker); |
| 1178 | void GivePoints (int32_t points); |
| 1179 | void GetBonus (statobj_t *check); |
| 1180 | void GiveWeapon (int weapon); |
| 1181 | void GiveAmmo (int ammo); |
| 1182 | void GiveKey (int key); |
| 1183 | |
| 1184 | // |
| 1185 | // player state info |
| 1186 | // |
| 1187 | |
| 1188 | void StatusDrawFace(unsigned picnum); |
| 1189 | void DrawFace (void); |
| 1190 | void DrawHealth (void); |
| 1191 | void HealSelf (int points); |
| 1192 | void DrawLevel (void); |
| 1193 | void DrawLives (void); |
| 1194 | void GiveExtraMan (void); |
| 1195 | void DrawScore (void); |
| 1196 | void DrawWeapon (void); |
| 1197 | void DrawKeys (void); |
| 1198 | void DrawAmmo (void); |
| 1199 | |
| 1200 | |
| 1201 | /* |
| 1202 | ============================================================================= |
| 1203 | |
| 1204 | WL_ACT1 DEFINITIONS |
| 1205 | |
| 1206 | ============================================================================= |
| 1207 | */ |
| 1208 | |
| 1209 | extern doorobj_t doorobjlist[MAXDOORS]; |
| 1210 | extern doorobj_t *lastdoorobj; |
| 1211 | extern short doornum; |
| 1212 | |
| 1213 | extern word doorposition[MAXDOORS]; |
| 1214 | |
| 1215 | extern byte areaconnect[NUMAREAS][NUMAREAS]; |
| 1216 | |
| 1217 | extern boolean areabyplayer[NUMAREAS]; |
| 1218 | |
| 1219 | extern word pwallstate; |
| 1220 | extern word pwallpos; // amount a pushable wall has been moved (0-63) |
| 1221 | extern word pwallx,pwally; |
| 1222 | extern byte pwalldir,pwalltile; |
| 1223 | |
| 1224 | |
| 1225 | void InitDoorList (void); |
| 1226 | void InitStaticList (void); |
| 1227 | void SpawnStatic (int tilex, int tiley, int type); |
| 1228 | void SpawnDoor (int tilex, int tiley, boolean vertical, int lock); |
| 1229 | void MoveDoors (void); |
| 1230 | void MovePWalls (void); |
| 1231 | void OpenDoor (int door); |
| 1232 | void PlaceItemType (int itemtype, int tilex, int tiley); |
| 1233 | void PushWall (int checkx, int checky, int dir); |
| 1234 | void OperateDoor (int door); |
| 1235 | void InitAreas (void); |
| 1236 | |
| 1237 | /* |
| 1238 | ============================================================================= |
| 1239 | |
| 1240 | WL_ACT2 DEFINITIONS |
| 1241 | |
| 1242 | ============================================================================= |
| 1243 | */ |
| 1244 | |
| 1245 | #define s_nakedbody s_static10 |
| 1246 | |
| 1247 | extern statetype s_grddie1; |
| 1248 | extern statetype s_dogdie1; |
| 1249 | extern statetype s_ofcdie1; |
| 1250 | extern statetype s_mutdie1; |
| 1251 | extern statetype s_ssdie1; |
| 1252 | extern statetype s_bossdie1; |
| 1253 | extern statetype s_schabbdie1; |
| 1254 | extern statetype s_fakedie1; |
| 1255 | extern statetype s_mechadie1; |
| 1256 | extern statetype s_hitlerdie1; |
| 1257 | extern statetype s_greteldie1; |
| 1258 | extern statetype s_giftdie1; |
| 1259 | extern statetype s_fatdie1; |
| 1260 | |
| 1261 | extern statetype s_spectredie1; |
| 1262 | extern statetype s_angeldie1; |
| 1263 | extern statetype s_transdie0; |
| 1264 | extern statetype s_uberdie0; |
| 1265 | extern statetype s_willdie1; |
| 1266 | extern statetype s_deathdie1; |
| 1267 | |
| 1268 | |
| 1269 | extern statetype s_grdchase1; |
| 1270 | extern statetype s_dogchase1; |
| 1271 | extern statetype s_ofcchase1; |
| 1272 | extern statetype s_sschase1; |
| 1273 | extern statetype s_mutchase1; |
| 1274 | extern statetype s_bosschase1; |
| 1275 | extern statetype s_schabbchase1; |
| 1276 | extern statetype s_fakechase1; |
| 1277 | extern statetype s_mechachase1; |
| 1278 | extern statetype s_gretelchase1; |
| 1279 | extern statetype s_giftchase1; |
| 1280 | extern statetype s_fatchase1; |
| 1281 | |
| 1282 | extern statetype s_spectrechase1; |
| 1283 | extern statetype s_angelchase1; |
| 1284 | extern statetype s_transchase1; |
| 1285 | extern statetype s_uberchase1; |
| 1286 | extern statetype s_willchase1; |
| 1287 | extern statetype s_deathchase1; |
| 1288 | |
| 1289 | extern statetype s_blinkychase1; |
| 1290 | extern statetype s_hitlerchase1; |
| 1291 | |
| 1292 | extern statetype s_grdpain; |
| 1293 | extern statetype s_grdpain1; |
| 1294 | extern statetype s_ofcpain; |
| 1295 | extern statetype s_ofcpain1; |
| 1296 | extern statetype s_sspain; |
| 1297 | extern statetype s_sspain1; |
| 1298 | extern statetype s_mutpain; |
| 1299 | extern statetype s_mutpain1; |
| 1300 | |
| 1301 | extern statetype s_deathcam; |
| 1302 | |
| 1303 | extern statetype s_schabbdeathcam2; |
| 1304 | extern statetype s_hitlerdeathcam2; |
| 1305 | extern statetype s_giftdeathcam2; |
| 1306 | extern statetype s_fatdeathcam2; |
| 1307 | |
| 1308 | void SpawnStand (enemy_t which, int tilex, int tiley, int dir); |
| 1309 | void SpawnPatrol (enemy_t which, int tilex, int tiley, int dir); |
| 1310 | void KillActor (objtype *ob); |
| 1311 | |
| 1312 | void SpawnDeadGuard (int tilex, int tiley); |
| 1313 | void SpawnBoss (int tilex, int tiley); |
| 1314 | void SpawnGretel (int tilex, int tiley); |
| 1315 | void SpawnTrans (int tilex, int tiley); |
| 1316 | void SpawnUber (int tilex, int tiley); |
| 1317 | void SpawnWill (int tilex, int tiley); |
| 1318 | void SpawnDeath (int tilex, int tiley); |
| 1319 | void SpawnAngel (int tilex, int tiley); |
| 1320 | void SpawnSpectre (int tilex, int tiley); |
| 1321 | void SpawnGhosts (int which, int tilex, int tiley); |
| 1322 | void SpawnSchabbs (int tilex, int tiley); |
| 1323 | void SpawnGift (int tilex, int tiley); |
| 1324 | void SpawnFat (int tilex, int tiley); |
| 1325 | void SpawnFakeHitler (int tilex, int tiley); |
| 1326 | void SpawnHitler (int tilex, int tiley); |
| 1327 | |
| 1328 | void A_DeathScream (objtype *ob); |
| 1329 | void SpawnBJVictory (void); |
| 1330 | |
| 1331 | /* |
| 1332 | ============================================================================= |
| 1333 | |
| 1334 | WL_TEXT DEFINITIONS |
| 1335 | |
| 1336 | ============================================================================= |
| 1337 | */ |
| 1338 | |
| 1339 | extern char helpfilename[],endfilename[]; |
| 1340 | |
| 1341 | extern void HelpScreens(void); |
| 1342 | extern void EndText(void); |
| 1343 | |
| 1344 | |
| 1345 | /* |
| 1346 | ============================================================================= |
| 1347 | |
| 1348 | GP2X DEFINITIONS |
| 1349 | |
| 1350 | ============================================================================= |
| 1351 | */ |
| 1352 | |
| 1353 | #if defined(GP2X) |
| 1354 | |
| 1355 | #if defined(GP2X_940) |
| 1356 | void GP2X_MemoryInit(void); |
| 1357 | void GP2X_Shutdown(void); |
| 1358 | #endif |
| 1359 | void GP2X_ButtonDown(int button); |
| 1360 | void GP2X_ButtonUp(int button); |
| 1361 | |
| 1362 | #endif |
| 1363 | |
| 1364 | |
| 1365 | /* |
| 1366 | ============================================================================= |
| 1367 | |
| 1368 | MISC DEFINITIONS |
| 1369 | |
| 1370 | ============================================================================= |
| 1371 | */ |
| 1372 | |
| 1373 | static fixed FixedMul(fixed a, fixed b) |
| 1374 | { |
| 1375 | return (fixed)(((int64_t)a * b + 0x8000) >> 16); |
| 1376 | } |
| 1377 | |
| 1378 | #ifdef PLAYDEMOLIKEORIGINAL |
| 1379 | #define DEMOCHOOSE_ORIG_SDL(orig, sdl) ((demorecord || demoplayback) ? (orig) : (sdl)) |
| 1380 | #define DEMOCOND_ORIG (demorecord || demoplayback) |
| 1381 | #define DEMOIF_SDL if(DEMOCOND_SDL) |
| 1382 | #else |
| 1383 | #define DEMOCHOOSE_ORIG_SDL(orig, sdl) (sdl) |
| 1384 | #define DEMOCOND_ORIG false |
| 1385 | #define DEMOIF_SDL |
| 1386 | #endif |
| 1387 | #define DEMOCOND_SDL (!DEMOCOND_ORIG) |
| 1388 | |
| 1389 | #define GetTicks() ((SDL_GetTicks()*7)/100) |
| 1390 | |
| 1391 | #define ISPOINTER(x) ((((uintptr_t)(x)) & ~0xffff) != 0) |
| 1392 | |
| 1393 | #define CHECKMALLOCRESULT(x) if(!(x)) Quit("Out of memory at %s:%i", __FILE__, __LINE__) |
| 1394 | |
Vencislav Atanasov | 183e45e | 2019-07-28 23:31:50 +0300 | [diff] [blame^] | 1395 | static char* itoa(int value, char* string, int radix) |
| 1396 | { |
| 1397 | sprintf(string, "%d", value); |
| 1398 | return string; |
| 1399 | } |
Franklin Wei | 3f59fc8 | 2019-07-07 22:00:20 -0400 | [diff] [blame] | 1400 | |
Vencislav Atanasov | 183e45e | 2019-07-28 23:31:50 +0300 | [diff] [blame^] | 1401 | static char* ltoa(long value, char* string, int radix) |
| 1402 | { |
| 1403 | sprintf(string, "%ld", value); |
| 1404 | return string; |
| 1405 | } |
Franklin Wei | 3f59fc8 | 2019-07-07 22:00:20 -0400 | [diff] [blame] | 1406 | |
| 1407 | #define lengthof(x) (sizeof(x) / sizeof(*(x))) |
| 1408 | #define endof(x) ((x) + lengthof(x)) |
| 1409 | |
| 1410 | static word READWORD(byte **ptr) |
| 1411 | { |
| 1412 | word val = (*ptr)[0] | (*ptr)[1] << 8; |
| 1413 | *ptr += 2; |
| 1414 | return val; |
| 1415 | } |
| 1416 | |
| 1417 | static longword READLONGWORD(byte **ptr) |
| 1418 | { |
| 1419 | longword val = (*ptr)[0] | (*ptr)[1] << 8 | (*ptr)[2] << 16 | (*ptr)[3] << 24; |
| 1420 | *ptr += 4; |
| 1421 | return val; |
| 1422 | } |
| 1423 | |
| 1424 | |
| 1425 | /* |
| 1426 | ============================================================================= |
| 1427 | |
| 1428 | FEATURE DEFINITIONS |
| 1429 | |
| 1430 | ============================================================================= |
| 1431 | */ |
| 1432 | |
| 1433 | #ifdef USE_FEATUREFLAGS |
| 1434 | // The currently available feature flags |
| 1435 | #define FF_STARSKY 0x0001 |
| 1436 | #define FF_PARALLAXSKY 0x0002 |
| 1437 | #define FF_CLOUDSKY 0x0004 |
| 1438 | #define FF_RAIN 0x0010 |
| 1439 | #define FF_SNOW 0x0020 |
| 1440 | |
| 1441 | // The ffData... variables contain the 16-bit values of the according corners of the current level. |
| 1442 | // The corners are overwritten with adjacent tiles after initialization in SetupGameLevel |
| 1443 | // to avoid interpretation as e.g. doors. |
| 1444 | extern int ffDataTopLeft, ffDataTopRight, ffDataBottomLeft, ffDataBottomRight; |
| 1445 | |
| 1446 | /************************************************************* |
| 1447 | * Current usage of ffData... variables: |
| 1448 | * ffDataTopLeft: lower 8-bit: ShadeDefID |
| 1449 | * ffDataTopRight: FeatureFlags |
| 1450 | * ffDataBottomLeft: CloudSkyDefID or ParallaxStartTexture |
| 1451 | * ffDataBottomRight: unused |
| 1452 | *************************************************************/ |
| 1453 | |
| 1454 | // The feature flags are stored as a wall in the upper right corner of each level |
| 1455 | static word GetFeatureFlags() |
| 1456 | { |
| 1457 | return ffDataTopRight; |
| 1458 | } |
| 1459 | |
| 1460 | #endif |
| 1461 | |
| 1462 | #ifdef USE_FLOORCEILINGTEX |
| 1463 | void DrawFloorAndCeiling(byte *vbuf, unsigned vbufPitch, int min_wallheight); |
| 1464 | #endif |
| 1465 | |
| 1466 | #ifdef USE_PARALLAX |
| 1467 | void DrawParallax(byte *vbuf, unsigned vbufPitch); |
| 1468 | #endif |
| 1469 | |
| 1470 | #ifdef USE_DIR3DSPR |
| 1471 | void Scale3DShape(byte *vbuf, unsigned vbufPitch, statobj_t *ob); |
| 1472 | #endif |
| 1473 | |
| 1474 | #endif |