Subversion Repositories Kolibri OS

Rev

Rev 9097 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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