home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / games / doom / pmdoom / src / st_stuff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-17  |  32.5 KB  |  1,486 lines

  1. /*  Emacs style mode select   -*- C++ -*-  */
  2. /* ----------------------------------------------------------------------------- */
  3. /*  */
  4. /*  $Id:$ */
  5. /*  */
  6. /*  Copyright (C) 1993-1996 by id Software, Inc. */
  7. /*  */
  8. /*  This source is available for distribution and/or modification */
  9. /*  only under the terms of the DOOM Source Code License as */
  10. /*  published by id Software. All rights reserved. */
  11. /*  */
  12. /*  The source is distributed in the hope that it will be useful, */
  13. /*  but WITHOUT ANY WARRANTY; without even the implied warranty of */
  14. /*  FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License */
  15. /*  for more details. */
  16. /*  */
  17. /*  $Log:$ */
  18. /*  */
  19. /*  DESCRIPTION: */
  20. /*     Status bar code. */
  21. /*     Does the face/direction indicator animatin. */
  22. /*     Does palette indicators as well (red pain/berserk, bright pickup) */
  23. /*  */
  24. /* ----------------------------------------------------------------------------- */
  25.  
  26. #include <stdio.h>
  27.  
  28. #include "i_system.h"
  29. #include "i_video.h"
  30. #include "z_zone.h"
  31. #include "m_random.h"
  32. #include "w_wad.h"
  33.  
  34. #include "doomdef.h"
  35.  
  36. #include "g_game.h"
  37.  
  38. #include "st_stuff.h"
  39. #include "st_lib.h"
  40. #include "r_local.h"
  41.  
  42. #include "p_local.h"
  43. #include "p_inter.h"
  44.  
  45. #include "am_map.h"
  46. #include "m_cheat.h"
  47.  
  48. #include "s_sound.h"
  49.  
  50. /*  Needs access to LFB. */
  51. #include "v_video.h"
  52.  
  53. /*  State. */
  54. #include "doomstat.h"
  55.  
  56. /*  Data. */
  57. #include "dstrings.h"
  58. #include "sounds.h"
  59.  
  60. /*  */
  61. /*  STATUS BAR DATA */
  62. /*  */
  63.  
  64. /*  Palette indices. */
  65. /*  For damage/bonus red-/gold-shifts */
  66. #define STARTREDPALS        1
  67. #define STARTBONUSPALS        9
  68. #define NUMREDPALS            8
  69. #define NUMBONUSPALS        4
  70. /*  Radiation suit, green shift. */
  71. #define RADIATIONPAL        13
  72.  
  73. /*  N/256*100% probability */
  74. /*   that the normal face state will change */
  75. #define ST_FACEPROBABILITY        96
  76.  
  77. /*  For Responder */
  78. #define ST_TOGGLECHAT        KEY_ENTER
  79.  
  80. /*  Location of status bar */
  81. #define ST_X                0
  82. #define ST_X2                104
  83.  
  84. #define ST_FX              143
  85. #define ST_FY              169
  86.  
  87. /*  Should be set to patch width */
  88. /*   for tall numbers later on */
  89. #define ST_TALLNUMWIDTH        (tallnum[0]->width)
  90.  
  91. /*  Number of status faces. */
  92. #define ST_NUMPAINFACES        5
  93. #define ST_NUMSTRAIGHTFACES    3
  94. #define ST_NUMTURNFACES        2
  95. #define ST_NUMSPECIALFACES        3
  96.  
  97. #define ST_FACESTRIDE \
  98.           (ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES)
  99.  
  100. #define ST_NUMEXTRAFACES        2
  101.  
  102. #define ST_NUMFACES \
  103.           (ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES)
  104.  
  105. #define ST_TURNOFFSET        (ST_NUMSTRAIGHTFACES)
  106. #define ST_OUCHOFFSET        (ST_TURNOFFSET + ST_NUMTURNFACES)
  107. #define ST_EVILGRINOFFSET        (ST_OUCHOFFSET + 1)
  108. #define ST_RAMPAGEOFFSET        (ST_EVILGRINOFFSET + 1)
  109. #define ST_GODFACE            (ST_NUMPAINFACES*ST_FACESTRIDE)
  110. #define ST_DEADFACE            (ST_GODFACE+1)
  111.  
  112. #define ST_FACESX            143
  113. #define ST_FACESY            168
  114.  
  115. #define ST_EVILGRINCOUNT        (2*TICRATE)
  116. #define ST_STRAIGHTFACECOUNT    (TICRATE/2)
  117. #define ST_TURNCOUNT        (1*TICRATE)
  118. #define ST_OUCHCOUNT        (1*TICRATE)
  119. #define ST_RAMPAGEDELAY        (2*TICRATE)
  120.  
  121. #define ST_MUCHPAIN            20
  122.  
  123.  
  124. /*  Location and size of statistics, */
  125. /*   justified according to widget type. */
  126. /*  Problem is, within which space? STbar? Screen? */
  127. /*  Note: this could be read in by a lump. */
  128. /*        Problem is, is the stuff rendered */
  129. /*        into a buffer, */
  130. /*        or into the frame buffer? */
  131.  
  132. /*  AMMO number pos. */
  133. #define ST_AMMOWIDTH        3    
  134. #define ST_AMMOX            44
  135. #define ST_AMMOY            171
  136.  
  137. /*  HEALTH number pos. */
  138. #define ST_HEALTHWIDTH        3    
  139. #define ST_HEALTHX            90
  140. #define ST_HEALTHY            171
  141.  
  142. /*  Weapon pos. */
  143. #define ST_ARMSX            111
  144. #define ST_ARMSY            172
  145. #define ST_ARMSBGX            104
  146. #define ST_ARMSBGY            168
  147. #define ST_ARMSXSPACE        12
  148. #define ST_ARMSYSPACE        10
  149.  
  150. /*  Frags pos. */
  151. #define ST_FRAGSX            138
  152. #define ST_FRAGSY            171    
  153. #define ST_FRAGSWIDTH        2
  154.  
  155. /*  ARMOR number pos. */
  156. #define ST_ARMORWIDTH        3
  157. #define ST_ARMORX            221
  158. #define ST_ARMORY            171
  159.  
  160. /*  Key icon positions. */
  161. #define ST_KEY0WIDTH        8
  162. #define ST_KEY0HEIGHT        5
  163. #define ST_KEY0X            239
  164. #define ST_KEY0Y            171
  165. #define ST_KEY1WIDTH        ST_KEY0WIDTH
  166. #define ST_KEY1X            239
  167. #define ST_KEY1Y            181
  168. #define ST_KEY2WIDTH        ST_KEY0WIDTH
  169. #define ST_KEY2X            239
  170. #define ST_KEY2Y            191
  171.  
  172. /*  Ammunition counter. */
  173. #define ST_AMMO0WIDTH        3
  174. #define ST_AMMO0HEIGHT        6
  175. #define ST_AMMO0X            288
  176. #define ST_AMMO0Y            173
  177. #define ST_AMMO1WIDTH        ST_AMMO0WIDTH
  178. #define ST_AMMO1X            288
  179. #define ST_AMMO1Y            179
  180. #define ST_AMMO2WIDTH        ST_AMMO0WIDTH
  181. #define ST_AMMO2X            288
  182. #define ST_AMMO2Y            191
  183. #define ST_AMMO3WIDTH        ST_AMMO0WIDTH
  184. #define ST_AMMO3X            288
  185. #define ST_AMMO3Y            185
  186.  
  187. /*  Indicate maximum ammunition. */
  188. /*  Only needed because backpack exists. */
  189. #define ST_MAXAMMO0WIDTH        3
  190. #define ST_MAXAMMO0HEIGHT        5
  191. #define ST_MAXAMMO0X        314
  192. #define ST_MAXAMMO0Y        173
  193. #define ST_MAXAMMO1WIDTH        ST_MAXAMMO0WIDTH
  194. #define ST_MAXAMMO1X        314
  195. #define ST_MAXAMMO1Y        179
  196. #define ST_MAXAMMO2WIDTH        ST_MAXAMMO0WIDTH
  197. #define ST_MAXAMMO2X        314
  198. #define ST_MAXAMMO2Y        191
  199. #define ST_MAXAMMO3WIDTH        ST_MAXAMMO0WIDTH
  200. #define ST_MAXAMMO3X        314
  201. #define ST_MAXAMMO3Y        185
  202.  
  203. /*  pistol */
  204. #define ST_WEAPON0X            110 
  205. #define ST_WEAPON0Y            172
  206.  
  207. /*  shotgun */
  208. #define ST_WEAPON1X            122 
  209. #define ST_WEAPON1Y            172
  210.  
  211. /*  chain gun */
  212. #define ST_WEAPON2X            134 
  213. #define ST_WEAPON2Y            172
  214.  
  215. /*  missile launcher */
  216. #define ST_WEAPON3X            110 
  217. #define ST_WEAPON3Y            181
  218.  
  219. /*  plasma gun */
  220. #define ST_WEAPON4X            122 
  221. #define ST_WEAPON4Y            181
  222.  
  223.  /*  bfg */
  224. #define ST_WEAPON5X            134
  225. #define ST_WEAPON5Y            181
  226.  
  227. /*  WPNS title */
  228. #define ST_WPNSX            109 
  229. #define ST_WPNSY            191
  230.  
  231.  /*  DETH title */
  232. #define ST_DETHX            109
  233. #define ST_DETHY            191
  234.  
  235. /* Incoming messages window location */
  236. /* UNUSED */
  237. /*  #define ST_MSGTEXTX       (viewwindowx) */
  238. /*  #define ST_MSGTEXTY       (viewwindowy+viewheight-18) */
  239. #define ST_MSGTEXTX            0
  240. #define ST_MSGTEXTY            0
  241. /*  Dimensions given in characters. */
  242. #define ST_MSGWIDTH            52
  243. /*  Or shall I say, in lines? */
  244. #define ST_MSGHEIGHT        1
  245.  
  246. #define ST_OUTTEXTX            0
  247. #define ST_OUTTEXTY            6
  248.  
  249. /*  Width, in characters again. */
  250. #define ST_OUTWIDTH            52 
  251.  /*  Height, in lines.  */
  252. #define ST_OUTHEIGHT        1
  253.  
  254. #define ST_MAPWIDTH    \
  255.     (strlen(mapnames[(gameepisode-1)*9+(gamemap-1)]))
  256.  
  257. #define ST_MAPTITLEX \
  258.     (SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH)
  259.  
  260. #define ST_MAPTITLEY        0
  261. #define ST_MAPHEIGHT        1
  262.  
  263. extern int fbnum;  /* defined in i_$(VIDEO).c , frame buffer to refresh */  
  264.  
  265. /*  main player in game */
  266. static player_t*    plyr; 
  267.  
  268. /*  ST_Start() has just been called */
  269. boolean        st_firsttime[2];
  270.  
  271. /*  used to execute ST_Init() only once */
  272. static int        veryfirsttime = 1;
  273.  
  274. /*  lump number for PLAYPAL */
  275. static int        lu_palette;
  276.  
  277. /*  used for timing */
  278. static unsigned int    st_clock;
  279.  
  280. /*  used for making messages go away */
  281. static int        st_msgcounter=0;
  282.  
  283. /*  used when in chat  */
  284. static st_chatstateenum_t    st_chatstate;
  285.  
  286. /*  whether in automap or first-person */
  287. static st_stateenum_t    st_gamestate;
  288.  
  289. /*  whether left-side main status bar is active */
  290. static boolean        st_statusbaron;
  291.  
  292. /*  whether status bar chat is active */
  293. static boolean        st_chat;
  294.  
  295. /*  value of st_chat before message popped up */
  296. static boolean        st_oldchat;
  297.  
  298. /*  whether chat window has the cursor on */
  299. static boolean        st_cursoron;
  300.  
  301. /*  !deathmatch */
  302. static boolean        st_notdeathmatch; 
  303.  
  304. /*  !deathmatch && st_statusbaron */
  305. static boolean        st_armson;
  306.  
  307. /*  !deathmatch */
  308. static boolean        st_fragson; 
  309.  
  310. /*  main bar left */
  311. static patch_t*        sbar;
  312.  
  313. /*  0-9, tall numbers */
  314. static patch_t*        tallnum[10];
  315.  
  316. /*  tall % sign */
  317. static patch_t*        tallpercent;
  318.  
  319. /*  0-9, short, yellow (,different!) numbers */
  320. static patch_t*        shortnum[10];
  321. patch_t    *        ext_shortnum[10]={
  322.     NULL,NULL,NULL,NULL,NULL,
  323.     NULL,NULL,NULL,NULL,NULL
  324. };
  325.  
  326. /*  3 key-cards, 3 skulls */
  327. static patch_t*        keys[NUMCARDS]; 
  328.  
  329. /*  face status patches */
  330. static patch_t*        faces[ST_NUMFACES];
  331.  
  332. /*  face background */
  333. static patch_t*        faceback;
  334.  
  335.  /*  main bar right */
  336. static patch_t*        armsbg;
  337.  
  338. /*  weapon ownership patches */
  339. static patch_t*        arms[6][2]; 
  340.  
  341. /*  ready-weapon widget */
  342. static st_number_t    w_ready;
  343.  
  344.  /*  in deathmatch only, summary of frags stats */
  345. static st_number_t    w_frags;
  346.  
  347. /*  health widget */
  348. static st_percent_t    w_health;
  349.  
  350. /*  arms background */
  351. static st_binicon_t    w_armsbg; 
  352.  
  353.  
  354. /*  weapon ownership widgets */
  355. static st_multicon_t    w_arms[6];
  356.  
  357. /*  face status widget */
  358. static st_multicon_t    w_faces; 
  359.  
  360. /*  keycard widgets */
  361. static st_multicon_t    w_keyboxes[3];
  362.  
  363. /*  armor widget */
  364. static st_percent_t    w_armor;
  365.  
  366. /*  ammo widgets */
  367. static st_number_t    w_ammo[4];
  368.  
  369. /*  max ammo widgets */
  370. static st_number_t    w_maxammo[4]; 
  371.  
  372.  
  373.  
  374.  /*  number of frags so far in deathmatch */
  375. static int    st_fragscount;
  376.  
  377. /*  used to use appopriately pained face */
  378. static int    st_oldhealth = -1;
  379.  
  380. /*  used for evil grin */
  381. static boolean    oldweaponsowned[NUMWEAPONS]; 
  382.  
  383.  /*  count until face changes */
  384. static int    st_facecount = 0;
  385.  
  386. /*  current face index, used by w_faces */
  387. static int    st_faceindex = 0;
  388.  
  389. /*  holds key-type for each key box on bar */
  390. static int    keyboxes[3]; 
  391.  
  392. /*  a random number per tick */
  393. static int    st_randomnumber;  
  394.  
  395.  
  396.  
  397. /*  Massive bunches of cheat shit */
  398. /*   to keep it from being easy to figure them out. */
  399. /*  Yeah, right... */
  400. unsigned char    cheat_mus_seq[] =
  401. {
  402.     0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff
  403. };
  404.  
  405. unsigned char    cheat_choppers_seq[] =
  406. {
  407.     0xb2, 0x26, 0xe2, 0x32, 0xf6, 0x2a, 0x2a, 0xa6, 0x6a, 0xea, 0xff /*  id... */
  408. };
  409.  
  410. unsigned char    cheat_god_seq[] =
  411. {
  412.     0xb2, 0x26, 0x26, 0xaa, 0x26, 0xff  /*  iddqd */
  413. };
  414.  
  415. unsigned char    cheat_ammo_seq[] =
  416. {
  417.     0xb2, 0x26, 0xf2, 0x66, 0xa2, 0xff    /*  idkfa */
  418. };
  419.  
  420. unsigned char    cheat_ammonokey_seq[] =
  421. {
  422.     0xb2, 0x26, 0x66, 0xa2, 0xff    /*  idfa */
  423. };
  424.  
  425.  
  426. /*  Smashing Pumpkins Into Samml Piles Of Putried Debris.  */
  427. unsigned char    cheat_noclip_seq[] =
  428. {
  429.     0xb2, 0x26, 0xea, 0x2a, 0xb2,    /*  idspispopd */
  430.     0xea, 0x2a, 0xf6, 0x2a, 0x26, 0xff
  431. };
  432.  
  433. /*  */
  434. unsigned char    cheat_commercial_noclip_seq[] =
  435. {
  436.     0xb2, 0x26, 0xe2, 0x36, 0xb2, 0x2a, 0xff    /*  idclip */
  437. }; 
  438.  
  439.  
  440.  
  441. unsigned char    cheat_powerup_seq[7][10] =
  442. {
  443.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6e, 0xff },     /*  beholdv */
  444.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xea, 0xff },     /*  beholds */
  445.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xb2, 0xff },     /*  beholdi */
  446.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6a, 0xff },     /*  beholdr */
  447.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xa2, 0xff },     /*  beholda */
  448.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x36, 0xff },     /*  beholdl */
  449.     { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xff }        /*  behold */
  450. };
  451.  
  452.  
  453. unsigned char    cheat_clev_seq[] =
  454. {
  455.     0xb2, 0x26,  0xe2, 0x36, 0xa6, 0x6e, 1, 0, 0, 0xff    /*  idclev */
  456. };
  457.  
  458.  
  459. /*  my position cheat */
  460. unsigned char    cheat_mypos_seq[] =
  461. {
  462.     0xb2, 0x26, 0xb6, 0xba, 0x2a, 0xf6, 0xea, 0xff    /*  idmypos */
  463. }; 
  464.  
  465.  
  466. /*  Now what? */
  467. cheatseq_t    cheat_mus = { cheat_mus_seq, 0 };
  468. cheatseq_t    cheat_god = { cheat_god_seq, 0 };
  469. cheatseq_t    cheat_ammo = { cheat_ammo_seq, 0 };
  470. cheatseq_t    cheat_ammonokey = { cheat_ammonokey_seq, 0 };
  471. cheatseq_t    cheat_noclip = { cheat_noclip_seq, 0 };
  472. cheatseq_t    cheat_commercial_noclip = { cheat_commercial_noclip_seq, 0 };
  473.  
  474. cheatseq_t    cheat_powerup[7] =
  475. {
  476.     { cheat_powerup_seq[0], 0 },
  477.     { cheat_powerup_seq[1], 0 },
  478.     { cheat_powerup_seq[2], 0 },
  479.     { cheat_powerup_seq[3], 0 },
  480.     { cheat_powerup_seq[4], 0 },
  481.     { cheat_powerup_seq[5], 0 },
  482.     { cheat_powerup_seq[6], 0 }
  483. };
  484.  
  485. cheatseq_t    cheat_choppers = { cheat_choppers_seq, 0 };
  486. cheatseq_t    cheat_clev = { cheat_clev_seq, 0 };
  487. cheatseq_t    cheat_mypos = { cheat_mypos_seq, 0 };
  488.  
  489.  
  490. /*   */
  491. extern char*    mapnames[];
  492.  
  493.  
  494. /*  */
  495. /*  STATUS BAR CODE */
  496. /*  */
  497. void ST_Stop(void);
  498.  
  499. void ST_refreshBackground(void)
  500. {
  501.  
  502.     if (st_statusbaron)
  503.     {
  504.     V_DrawPatch(ST_X, 0, BG, sbar);
  505.  
  506.     if (netgame)
  507.         V_DrawPatch(ST_FX, 0, BG, faceback);
  508.  
  509.     V_CopyRect(ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG);
  510.     }
  511.  
  512. }
  513.  
  514.  
  515. /*  Respond to keyboard input events, */
  516. /*   intercept cheats. */
  517. boolean
  518. ST_Responder (event_t* ev)
  519. {
  520.   int        i;
  521.     
  522.   /*  Filter automap on/off. */
  523.   if (ev->type == ev_keyup
  524.       && ((ev->data1 & 0xffff0000) == AM_MSGHEADER))
  525.   {
  526.     switch(ev->data1)
  527.     {
  528.       case AM_MSGENTERED:
  529.     st_gamestate = AutomapState;
  530.     st_firsttime[fbnum] = true;
  531.     break;
  532.     
  533.       case AM_MSGEXITED:
  534.     /*     fprintf(stderr, "AM exited\n"); */
  535.     st_gamestate = FirstPersonState;
  536.     break;
  537.     }
  538.   }
  539.  
  540.   /*  if a user keypress... */
  541.   else if (ev->type == ev_keydown)
  542.   {
  543.     if (!netgame)
  544.     {
  545.       /*  b. - enabled for more debug fun. */
  546.       /*  if (gameskill != sk_nightmare) { */
  547.       
  548.       /*  'dqd' cheat for toggleable god mode */
  549.       if (cht_CheckCheat(&cheat_god, ev->data1))
  550.       {
  551.     plyr->cheats ^= CF_GODMODE;
  552.     if (plyr->cheats & CF_GODMODE)
  553.     {
  554.       if (plyr->mo)
  555.         plyr->mo->health = 100;
  556.       
  557.       plyr->health = 100;
  558.       plyr->message = STSTR_DQDON;
  559.     }
  560.     else 
  561.       plyr->message = STSTR_DQDOFF;
  562.       }
  563.       /*  'fa' cheat for killer fucking arsenal */
  564.       else if (cht_CheckCheat(&cheat_ammonokey, ev->data1))
  565.       {
  566.     plyr->armorpoints = 200;
  567.     plyr->armortype = 2;
  568.     
  569.     for (i=0;i<NUMWEAPONS;i++)
  570.       plyr->weaponowned[i] = true;
  571.     
  572.     for (i=0;i<NUMAMMO;i++)
  573.       plyr->ammo[i] = plyr->maxammo[i];
  574.     
  575.     plyr->message = STSTR_FAADDED;
  576.       }
  577.       /*  'kfa' cheat for key full ammo */
  578.       else if (cht_CheckCheat(&cheat_ammo, ev->data1))
  579.       {
  580.     plyr->armorpoints = 200;
  581.     plyr->armortype = 2;
  582.     
  583.     for (i=0;i<NUMWEAPONS;i++)
  584.       plyr->weaponowned[i] = true;
  585.     
  586.     for (i=0;i<NUMAMMO;i++)
  587.       plyr->ammo[i] = plyr->maxammo[i];
  588.     
  589.     for (i=0;i<NUMCARDS;i++)
  590.       plyr->cards[i] = true;
  591.     
  592.     plyr->message = STSTR_KFAADDED;
  593.       }
  594.       /*  'mus' cheat for changing music */
  595.       else if (cht_CheckCheat(&cheat_mus, ev->data1))
  596.       {
  597.     
  598.     char    buf[3];
  599.     int        musnum;
  600.     
  601.     plyr->message = STSTR_MUS;
  602.     cht_GetParam(&cheat_mus, buf);
  603.     
  604.     if (gamemode == commercial)
  605.     {
  606.       musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1;
  607.       
  608.       if (((buf[0]-'0')*10 + buf[1]-'0') > 35)
  609.         plyr->message = STSTR_NOMUS;
  610.       else
  611.         S_ChangeMusic(musnum, 1);
  612.     }
  613.     else
  614.     {
  615.       musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1');
  616.       
  617.       if (((buf[0]-'1')*9 + buf[1]-'1') > 31)
  618.         plyr->message = STSTR_NOMUS;
  619.       else
  620.         S_ChangeMusic(musnum, 1);
  621.     }
  622.       }
  623.       /*  Simplified, accepting both "noclip" and "idspispopd". */
  624.       /*  no clipping mode cheat */
  625.       else if ( cht_CheckCheat(&cheat_noclip, ev->data1) 
  626.         || cht_CheckCheat(&cheat_commercial_noclip,ev->data1) )
  627.       {    
  628.     plyr->cheats ^= CF_NOCLIP;
  629.     
  630.     if (plyr->cheats & CF_NOCLIP)
  631.       plyr->message = STSTR_NCON;
  632.     else
  633.       plyr->message = STSTR_NCOFF;
  634.       }
  635.       /*  'behold?' power-up cheats */
  636.       for (i=0;i<6;i++)
  637.       {
  638.     if (cht_CheckCheat(&cheat_powerup[i], ev->data1))
  639.     {
  640.       if (!plyr->powers[i])
  641.         P_GivePower( plyr, i);
  642.       else if (i!=pw_strength)
  643.         plyr->powers[i] = 1;
  644.       else
  645.         plyr->powers[i] = 0;
  646.       
  647.       plyr->message = STSTR_BEHOLDX;
  648.     }
  649.       }
  650.       
  651.       /*  'behold' power-up menu */
  652.       if (cht_CheckCheat(&cheat_powerup[6], ev->data1))
  653.       {
  654.     plyr->message = STSTR_BEHOLD;
  655.       }
  656.       /*  'choppers' invulnerability & chainsaw */
  657.       else if (cht_CheckCheat(&cheat_choppers, ev->data1))
  658.       {
  659.     plyr->weaponowned[wp_chainsaw] = true;
  660.     plyr->powers[pw_invulnerability] = true;
  661.     plyr->message = STSTR_CHOPPERS;
  662.       }
  663.       /*  'mypos' for player position */
  664.       else if (cht_CheckCheat(&cheat_mypos, ev->data1))
  665.       {
  666.     static char    buf[ST_MSGWIDTH];
  667.     sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)",
  668.         players[consoleplayer].mo->angle,
  669.         players[consoleplayer].mo->x,
  670.         players[consoleplayer].mo->y);
  671.     plyr->message = buf;
  672.       }
  673.     }
  674.     
  675.     /*  'clev' change-level cheat */
  676.     if (cht_CheckCheat(&cheat_clev, ev->data1))
  677.     {
  678.       char        buf[3];
  679.       int        epsd;
  680.       int        map;
  681.       
  682.       cht_GetParam(&cheat_clev, buf);
  683.       
  684.       if (gamemode == commercial)
  685.       {
  686.     epsd = 1;
  687.     map = (buf[0] - '0')*10 + buf[1] - '0';
  688.       }
  689.       else
  690.       {
  691.     epsd = buf[0] - '0';
  692.     map = buf[1] - '0';
  693.       }
  694.  
  695.       /*  Catch invalid maps. */
  696.       if (epsd < 1)
  697.     return false;
  698.  
  699.       if (map < 1)
  700.     return false;
  701.       
  702.       /*  Ohmygod - this is not going to work. */
  703.       if ((gamemode == retail)
  704.       && ((epsd > 4) || (map > 9)))
  705.     return false;
  706.  
  707.       if ((gamemode == registered)
  708.       && ((epsd > 3) || (map > 9)))
  709.     return false;
  710.  
  711.       if ((gamemode == shareware)
  712.       && ((epsd > 1) || (map > 9)))
  713.     return false;
  714.  
  715.       if ((gamemode == commercial)
  716.     && (( epsd > 1) || (map > 34)))
  717.     return false;
  718.  
  719.       /*  So be it. */
  720.       plyr->message = STSTR_CLEV;
  721.       G_DeferedInitNew(gameskill, epsd, map);
  722.     }    
  723.   }
  724.   return false;
  725. }
  726.  
  727.  
  728.  
  729. int ST_calcPainOffset(void)
  730. {
  731.     int        health;
  732.     static int    lastcalc;
  733.     static int    oldhealth = -1;
  734.     
  735.     health = plyr->health > 100 ? 100 : plyr->health;
  736.  
  737.     if (health != oldhealth)
  738.     {
  739.     lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101);
  740.     oldhealth = health;
  741.     }
  742.     return lastcalc;
  743. }
  744.  
  745.  
  746. /*  */
  747. /*  This is a not-very-pretty routine which handles */
  748. /*   the face states and their timing. */
  749. /*  the precedence of expressions is: */
  750. /*   dead > evil grin > turned head > straight ahead */
  751. /*  */
  752. void ST_updateFaceWidget(void)
  753. {
  754.     int        i;
  755.     angle_t    badguyangle;
  756.     angle_t    diffang;
  757.     static int    lastattackdown = -1;
  758.     static int    priority = 0;
  759.     boolean    doevilgrin;
  760.  
  761.     if (priority < 10)
  762.     {
  763.     /*  dead */
  764.     if (!plyr->health)
  765.     {
  766.         priority = 9;
  767.         st_faceindex = ST_DEADFACE;
  768.         st_facecount = 1;
  769.     }
  770.     }
  771.  
  772.     if (priority < 9)
  773.     {
  774.     if (plyr->bonuscount)
  775.     {
  776.         /*  picking up bonus */
  777.         doevilgrin = false;
  778.  
  779.         for (i=0;i<NUMWEAPONS;i++)
  780.         {
  781.         if (oldweaponsowned[i] != plyr->weaponowned[i])
  782.         {
  783.             doevilgrin = true;
  784.             oldweaponsowned[i] = plyr->weaponowned[i];
  785.         }
  786.         }
  787.         if (doevilgrin) 
  788.         {
  789.         /*  evil grin if just picked up weapon */
  790.         priority = 8;
  791.         st_facecount = ST_EVILGRINCOUNT;
  792.         st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
  793.         }
  794.     }
  795.  
  796.     }
  797.   
  798.     if (priority < 8)
  799.     {
  800.     if (plyr->damagecount
  801.         && plyr->attacker
  802.         && plyr->attacker != plyr->mo)
  803.     {
  804.         /*  being attacked */
  805.         priority = 7;
  806.         
  807.         if (plyr->health - st_oldhealth > ST_MUCHPAIN)
  808.         {
  809.         st_facecount = ST_TURNCOUNT;
  810.         st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
  811.         }
  812.         else
  813.         {
  814.         badguyangle = R_PointToAngle2(plyr->mo->x,
  815.                           plyr->mo->y,
  816.                           plyr->attacker->x,
  817.                           plyr->attacker->y);
  818.         
  819.         if (badguyangle > plyr->mo->angle)
  820.         {
  821.             /*  whether right or left */
  822.             diffang = badguyangle - plyr->mo->angle;
  823.             i = diffang > ANG180; 
  824.         }
  825.         else
  826.         {
  827.             /*  whether left or right */
  828.             diffang = plyr->mo->angle - badguyangle;
  829.             i = diffang <= ANG180; 
  830.         } /*  confusing, aint it? */
  831.  
  832.         
  833.         st_facecount = ST_TURNCOUNT;
  834.         st_faceindex = ST_calcPainOffset();
  835.         
  836.         if (diffang < ANG45)
  837.         {
  838.             /*  head-on     */
  839.             st_faceindex += ST_RAMPAGEOFFSET;
  840.         }
  841.         else if (i)
  842.         {
  843.             /*  turn face right */
  844.             st_faceindex += ST_TURNOFFSET;
  845.         }
  846.         else
  847.         {
  848.             /*  turn face left */
  849.             st_faceindex += ST_TURNOFFSET+1;
  850.         }
  851.         }
  852.     }
  853.     }
  854.   
  855.     if (priority < 7)
  856.     {
  857.     /*  getting hurt because of your own damn stupidity */
  858.     if (plyr->damagecount)
  859.     {
  860.         if (plyr->health - st_oldhealth > ST_MUCHPAIN)
  861.         {
  862.         priority = 7;
  863.         st_facecount = ST_TURNCOUNT;
  864.         st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
  865.         }
  866.         else
  867.         {
  868.         priority = 6;
  869.         st_facecount = ST_TURNCOUNT;
  870.         st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
  871.         }
  872.  
  873.     }
  874.  
  875.     }
  876.   
  877.     if (priority < 6)
  878.     {
  879.     /*  rapid firing */
  880.     if (plyr->attackdown)
  881.     {
  882.         if (lastattackdown==-1)
  883.         lastattackdown = ST_RAMPAGEDELAY;
  884.         else if (!--lastattackdown)
  885.         {
  886.         priority = 5;
  887.         st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
  888.         st_facecount = 1;
  889.         lastattackdown = 1;
  890.         }
  891.     }
  892.     else
  893.         lastattackdown = -1;
  894.  
  895.     }
  896.   
  897.     if (priority < 5)
  898.     {
  899.     /*  invulnerability */
  900.     if ((plyr->cheats & CF_GODMODE)
  901.         || plyr->powers[pw_invulnerability])
  902.     {
  903.         priority = 4;
  904.  
  905.         st_faceindex = ST_GODFACE;
  906.         st_facecount = 1;
  907.  
  908.     }
  909.  
  910.     }
  911.  
  912.     /*  look left or look right if the facecount has timed out */
  913.     if (!st_facecount)
  914.     {
  915.     st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3);
  916.     st_facecount = ST_STRAIGHTFACECOUNT;
  917.     priority = 0;
  918.     }
  919.  
  920.     st_facecount--;
  921.  
  922. }
  923.  
  924. void ST_updateWidgets(void)
  925. {
  926.     static int    largeammo = 1994; /*  means "n/a" */
  927.     int        i;
  928.  
  929.     /*  must redirect the pointer if the ready weapon has changed. */
  930.     /*   if (w_ready.data != plyr->readyweapon) */
  931.     /*   { */
  932.     if (weaponinfo[plyr->readyweapon].ammo == am_noammo)
  933.     w_ready.num = &largeammo;
  934.     else
  935.     w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo];
  936.     /* { */
  937.     /*  static int tic=0; */
  938.     /*  static int dir=-1; */
  939.     /*  if (!(tic&15)) */
  940.     /*    plyr->ammo[weaponinfo[plyr->readyweapon].ammo]+=dir; */
  941.     /*  if (plyr->ammo[weaponinfo[plyr->readyweapon].ammo] == -100) */
  942.     /*    dir = 1; */
  943.     /*  tic++; */
  944.     /*  } */
  945.     w_ready.data = plyr->readyweapon;
  946.  
  947.     /*  if (*w_ready.on) */
  948.     /*   STlib_updateNum(&w_ready, true); */
  949.     /*  refresh weapon change */
  950.     /*   } */
  951.  
  952.     /*  update keycard multiple widgets */
  953.     for (i=0;i<3;i++)
  954.     {
  955.     keyboxes[i] = plyr->cards[i] ? i : -1;
  956.  
  957.     if (plyr->cards[i+3])
  958.         keyboxes[i] = i+3;
  959.     }
  960.  
  961.     /*  refresh everything if this is him coming back to life */
  962.     ST_updateFaceWidget();
  963.  
  964.     /*  used by the w_armsbg widget */
  965.     st_notdeathmatch = !deathmatch;
  966.     
  967.     /*  used by w_arms[] widgets */
  968.     st_armson = st_statusbaron && !deathmatch; 
  969.  
  970.     /*  used by w_frags widget */
  971.     st_fragson = deathmatch && st_statusbaron; 
  972.     st_fragscount = 0;
  973.  
  974.     for (i=0 ; i<MAXPLAYERS ; i++)
  975.     {
  976.     if (i != consoleplayer)
  977.         st_fragscount += plyr->frags[i];
  978.     else
  979.         st_fragscount -= plyr->frags[i];
  980.     }
  981.  
  982.     /*  get rid of chat window if up because of message */
  983.     if (!--st_msgcounter)
  984.     st_chat = st_oldchat;
  985.  
  986. }
  987.  
  988. void ST_Ticker (void)
  989. {
  990.  
  991.     st_clock++;
  992.     st_randomnumber = M_Random();
  993.     ST_updateWidgets();
  994.     st_oldhealth = plyr->health;
  995.  
  996. }
  997.  
  998. static int st_palette = 0;
  999.  
  1000. void ST_doRefresh(void);
  1001.  
  1002. void ST_doPaletteStuff(void)
  1003. {
  1004.  
  1005.     int        palette;
  1006.     byte*    pal;
  1007.     int        cnt;
  1008.     int        bzc;
  1009.  
  1010.     cnt = plyr->damagecount;
  1011.  
  1012.     if (plyr->powers[pw_strength])
  1013.     {
  1014.     /*  slowly fade the berzerk out */
  1015.       bzc = 12 - (plyr->powers[pw_strength]>>6);
  1016.  
  1017.     if (bzc > cnt)
  1018.         cnt = bzc;
  1019.     }
  1020.     
  1021.     if (cnt)
  1022.     {
  1023.     palette = (cnt+7)>>3;
  1024.     
  1025.     if (palette >= NUMREDPALS)
  1026.         palette = NUMREDPALS-1;
  1027.  
  1028.     palette += STARTREDPALS;
  1029.     }
  1030.  
  1031.     else if (plyr->bonuscount)
  1032.     {
  1033.     palette = (plyr->bonuscount+7)>>3;
  1034.  
  1035.     if (palette >= NUMBONUSPALS)
  1036.         palette = NUMBONUSPALS-1;
  1037.  
  1038.     palette += STARTBONUSPALS;
  1039.     }
  1040.  
  1041.     else if ( plyr->powers[pw_ironfeet] > 4*32
  1042.           || plyr->powers[pw_ironfeet]&8)
  1043.     palette = RADIATIONPAL;
  1044.     else
  1045.     palette = 0;
  1046.  
  1047.     if (palette != st_palette)
  1048.     {
  1049.     st_palette = palette;
  1050.     pal = (byte *) W_CacheLumpNum (lu_palette, PU_CACHE)+palette*768;
  1051.     I_SetPalette (pal);
  1052.     /*  Redraw in Truecolor mode */
  1053.     if (pixel_size!=1)
  1054.     {
  1055.         st_firsttime[0]=true;
  1056.         st_firsttime[1]=true;
  1057.  
  1058. /*        ST_doRefresh();*/
  1059.     }
  1060.     }
  1061. }
  1062.  
  1063. void ST_drawWidgets(boolean refresh)
  1064. {
  1065.     int        i;
  1066.  
  1067.     /*  used by w_arms[] widgets */
  1068.     st_armson = st_statusbaron && !deathmatch;
  1069.  
  1070.     /*  used by w_frags widget */
  1071.     st_fragson = deathmatch && st_statusbaron; 
  1072.  
  1073.     STlib_updateNum(&w_ready, refresh);
  1074.  
  1075.     for (i=0;i<4;i++)
  1076.     {
  1077.     STlib_updateNum(&w_ammo[i], refresh);
  1078.     STlib_updateNum(&w_maxammo[i], refresh);
  1079.     }
  1080.  
  1081.     STlib_updatePercent(&w_health, refresh);
  1082.     STlib_updatePercent(&w_armor, refresh);
  1083.  
  1084.     STlib_updateBinIcon(&w_armsbg, refresh);
  1085.  
  1086.     for (i=0;i<6;i++)
  1087.     STlib_updateMultIcon(&w_arms[i], refresh);
  1088.  
  1089.     STlib_updateMultIcon(&w_faces, refresh);
  1090.  
  1091.     for (i=0;i<3;i++)
  1092.     STlib_updateMultIcon(&w_keyboxes[i], refresh);
  1093.  
  1094.     STlib_updateNum(&w_frags, refresh);
  1095.  
  1096. }
  1097.  
  1098. void ST_doRefresh(void)
  1099. {
  1100.  
  1101.     st_firsttime[fbnum] = false;
  1102.  
  1103.     /*  draw status bar background to off-screen buff */
  1104.     ST_refreshBackground();
  1105.  
  1106.     /*  and refresh all widgets */
  1107.     ST_drawWidgets(true);
  1108.  
  1109. }
  1110.  
  1111. void ST_diffDraw(void)
  1112. {
  1113.     /*  update all widgets */
  1114. /* PM: was    ST_drawWidgets(false); */
  1115.     ST_drawWidgets(dblbuffer);
  1116. }
  1117.  
  1118. void ST_Drawer (boolean fullscreen, boolean refresh)
  1119. {
  1120.   
  1121.     st_statusbaron = (!fullscreen) || automapactive;
  1122.     st_firsttime[fbnum] = st_firsttime[fbnum] || refresh;
  1123.  
  1124.     /*  Do red-/gold-shifts from damage/items */
  1125.     ST_doPaletteStuff();
  1126.  
  1127.     /*  If just after ST_Start(), refresh all */
  1128.     if (st_firsttime[fbnum]) ST_doRefresh();
  1129.     /*  Otherwise, update as little as possible */
  1130.     else ST_diffDraw();
  1131.  
  1132. }
  1133.  
  1134. void ST_loadGraphics(void)
  1135. {
  1136.  
  1137.     int        i;
  1138.     int        j;
  1139.     int        facenum;
  1140.     
  1141.     char    namebuf[9];
  1142.  
  1143.     /*  Load the numbers, tall and short */
  1144.     for (i=0;i<10;i++)
  1145.     {
  1146.     sprintf(namebuf, "STTNUM%d", i);
  1147.     tallnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
  1148.  
  1149.     sprintf(namebuf, "STYSNUM%d", i);
  1150.     shortnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
  1151.     ext_shortnum[i]=shortnum[i];
  1152.     }
  1153.  
  1154.     /*  Load percent key. */
  1155.     /* Note: why not load STMINUS here, too? */
  1156.     tallpercent = (patch_t *) W_CacheLumpName("STTPRCNT", PU_STATIC);
  1157.  
  1158.     /*  key cards */
  1159.     for (i=0;i<NUMCARDS;i++)
  1160.     {
  1161.     sprintf(namebuf, "STKEYS%d", i);
  1162.     keys[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
  1163.     }
  1164.  
  1165.     /*  arms background */
  1166.     armsbg = (patch_t *) W_CacheLumpName("STARMS", PU_STATIC);
  1167.  
  1168.     /*  arms ownership widgets */
  1169.     for (i=0;i<6;i++)
  1170.     {
  1171.     sprintf(namebuf, "STGNUM%d", i+2);
  1172.  
  1173.     /*  gray # */
  1174.     arms[i][0] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
  1175.  
  1176.     /*  yellow # */
  1177.     arms[i][1] = shortnum[i+2]; 
  1178.     }
  1179.  
  1180.     /*  face backgrounds for different color players */
  1181.     sprintf(namebuf, "STFB%d", consoleplayer);
  1182.     faceback = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
  1183.  
  1184.     /*  status bar background bits */
  1185.     sbar = (patch_t *) W_CacheLumpName("STBAR", PU_STATIC);
  1186.  
  1187.     /*  face states */
  1188.     facenum = 0;
  1189.     for (i=0;i<ST_NUMPAINFACES;i++)
  1190.     {
  1191.     for (j=0;j<ST_NUMSTRAIGHTFACES;j++)
  1192.     {
  1193.         sprintf(namebuf, "STFST%d%d", i, j);
  1194.         faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1195.     }
  1196.     sprintf(namebuf, "STFTR%d0", i);    /*  turn right */
  1197.     faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1198.     sprintf(namebuf, "STFTL%d0", i);    /*  turn left */
  1199.     faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1200.     sprintf(namebuf, "STFOUCH%d", i);    /*  ouch! */
  1201.     faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1202.     sprintf(namebuf, "STFEVL%d", i);    /*  evil grin ;) */
  1203.     faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1204.     sprintf(namebuf, "STFKILL%d", i);    /*  pissed off */
  1205.     faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
  1206.     }
  1207.     faces[facenum++] = W_CacheLumpName("STFGOD0", PU_STATIC);
  1208.     faces[facenum++] = W_CacheLumpName("STFDEAD0", PU_STATIC);
  1209.  
  1210. }
  1211.  
  1212. void ST_loadData(void)
  1213. {
  1214.     lu_palette = W_GetNumForName ("PLAYPAL");
  1215.     ST_loadGraphics();
  1216. }
  1217.  
  1218. void ST_unloadGraphics(void)
  1219. {
  1220.  
  1221.     int i;
  1222.  
  1223.     /*  unload the numbers, tall and short */
  1224.     for (i=0;i<10;i++)
  1225.     {
  1226.     Z_ChangeTag(tallnum[i], PU_CACHE);
  1227.     Z_ChangeTag(shortnum[i], PU_CACHE);
  1228.     }
  1229.     /*  unload tall percent */
  1230.     Z_ChangeTag(tallpercent, PU_CACHE); 
  1231.  
  1232.     /*  unload arms background */
  1233.     Z_ChangeTag(armsbg, PU_CACHE); 
  1234.  
  1235.     /*  unload gray #'s */
  1236.     for (i=0;i<6;i++)
  1237.     Z_ChangeTag(arms[i][0], PU_CACHE);
  1238.     
  1239.     /*  unload the key cards */
  1240.     for (i=0;i<NUMCARDS;i++)
  1241.     Z_ChangeTag(keys[i], PU_CACHE);
  1242.  
  1243.     Z_ChangeTag(sbar, PU_CACHE);
  1244.     Z_ChangeTag(faceback, PU_CACHE);
  1245.  
  1246.     for (i=0;i<ST_NUMFACES;i++)
  1247.     Z_ChangeTag(faces[i], PU_CACHE);
  1248.  
  1249.     /*  Note: nobody ain't seen no unloading */
  1250.     /*    of stminus yet. Dude. */
  1251.     
  1252.  
  1253. }
  1254.  
  1255. void ST_unloadData(void)
  1256. {
  1257.     ST_unloadGraphics();
  1258. }
  1259.  
  1260. void ST_initData(void)
  1261. {
  1262.  
  1263.     int        i;
  1264.  
  1265.     st_firsttime[0] = true;
  1266.     st_firsttime[1] = true;
  1267.     plyr = &players[consoleplayer];
  1268.  
  1269.     st_clock = 0;
  1270.     st_chatstate = StartChatState;
  1271.     st_gamestate = FirstPersonState;
  1272.  
  1273.     st_statusbaron = true;
  1274.     st_oldchat = st_chat = false;
  1275.     st_cursoron = false;
  1276.  
  1277.     st_faceindex = 0;
  1278.     st_palette = -1;
  1279.  
  1280.     st_oldhealth = -1;
  1281.  
  1282.     for (i=0;i<NUMWEAPONS;i++)
  1283.     oldweaponsowned[i] = plyr->weaponowned[i];
  1284.  
  1285.     for (i=0;i<3;i++)
  1286.     keyboxes[i] = -1;
  1287.  
  1288.     STlib_init();
  1289.  
  1290. }
  1291.  
  1292.  
  1293.  
  1294. void ST_createWidgets(void)
  1295. {
  1296.  
  1297.     int i;
  1298.  
  1299.     /*  ready weapon ammo */
  1300.     STlib_initNum(&w_ready,
  1301.           ST_AMMOX,
  1302.           ST_AMMOY,
  1303.           tallnum,
  1304.           &plyr->ammo[weaponinfo[plyr->readyweapon].ammo],
  1305.           &st_statusbaron,
  1306.           ST_AMMOWIDTH );
  1307.  
  1308.     /*  the last weapon type */
  1309.     w_ready.data = plyr->readyweapon; 
  1310.  
  1311.     /*  health percentage */
  1312.     STlib_initPercent(&w_health,
  1313.               ST_HEALTHX,
  1314.               ST_HEALTHY,
  1315.               tallnum,
  1316.               &plyr->health,
  1317.               &st_statusbaron,
  1318.               tallpercent);
  1319.  
  1320.     /*  arms background */
  1321.     STlib_initBinIcon(&w_armsbg,
  1322.               ST_ARMSBGX,
  1323.               ST_ARMSBGY,
  1324.               armsbg,
  1325.               &st_notdeathmatch,
  1326.               &st_statusbaron);
  1327.  
  1328.     /*  weapons owned */
  1329.     for(i=0;i<6;i++)
  1330.     {
  1331.     STlib_initMultIcon(&w_arms[i],
  1332.                ST_ARMSX+(i%3)*ST_ARMSXSPACE,
  1333.                ST_ARMSY+(i/3)*ST_ARMSYSPACE,
  1334.                arms[i], (int *) &plyr->weaponowned[i+1],
  1335.                &st_armson);
  1336.     }
  1337.  
  1338.     /*  frags sum */
  1339.     STlib_initNum(&w_frags,
  1340.           ST_FRAGSX,
  1341.           ST_FRAGSY,
  1342.           tallnum,
  1343.           &st_fragscount,
  1344.           &st_fragson,
  1345.           ST_FRAGSWIDTH);
  1346.  
  1347.     /*  faces */
  1348.     STlib_initMultIcon(&w_faces,
  1349.                ST_FACESX,
  1350.                ST_FACESY,
  1351.                faces,
  1352.                &st_faceindex,
  1353.                &st_statusbaron);
  1354.  
  1355.     /*  armor percentage - should be colored later */
  1356.     STlib_initPercent(&w_armor,
  1357.               ST_ARMORX,
  1358.               ST_ARMORY,
  1359.               tallnum,
  1360.               &plyr->armorpoints,
  1361.               &st_statusbaron, tallpercent);
  1362.  
  1363.     /*  keyboxes 0-2 */
  1364.     STlib_initMultIcon(&w_keyboxes[0],
  1365.                ST_KEY0X,
  1366.                ST_KEY0Y,
  1367.                keys,
  1368.                &keyboxes[0],
  1369.                &st_statusbaron);
  1370.     
  1371.     STlib_initMultIcon(&w_keyboxes[1],
  1372.                ST_KEY1X,
  1373.                ST_KEY1Y,
  1374.                keys,
  1375.                &keyboxes[1],
  1376.                &st_statusbaron);
  1377.  
  1378.     STlib_initMultIcon(&w_keyboxes[2],
  1379.                ST_KEY2X,
  1380.                ST_KEY2Y,
  1381.                keys,
  1382.                &keyboxes[2],
  1383.                &st_statusbaron);
  1384.  
  1385.     /*  ammo count (all four kinds) */
  1386.     STlib_initNum(&w_ammo[0],
  1387.           ST_AMMO0X,
  1388.           ST_AMMO0Y,
  1389.           shortnum,
  1390.           &plyr->ammo[0],
  1391.           &st_statusbaron,
  1392.           ST_AMMO0WIDTH);
  1393.  
  1394.     STlib_initNum(&w_ammo[1],
  1395.           ST_AMMO1X,
  1396.           ST_AMMO1Y,
  1397.           shortnum,
  1398.           &plyr->ammo[1],
  1399.           &st_statusbaron,
  1400.           ST_AMMO1WIDTH);
  1401.  
  1402.     STlib_initNum(&w_ammo[2],
  1403.           ST_AMMO2X,
  1404.           ST_AMMO2Y,
  1405.           shortnum,
  1406.           &plyr->ammo[2],
  1407.           &st_statusbaron,
  1408.           ST_AMMO2WIDTH);
  1409.     
  1410.     STlib_initNum(&w_ammo[3],
  1411.           ST_AMMO3X,
  1412.           ST_AMMO3Y,
  1413.           shortnum,
  1414.           &plyr->ammo[3],
  1415.           &st_statusbaron,
  1416.           ST_AMMO3WIDTH);
  1417.  
  1418.     /*  max ammo count (all four kinds) */
  1419.     STlib_initNum(&w_maxammo[0],
  1420.           ST_MAXAMMO0X,
  1421.           ST_MAXAMMO0Y,
  1422.           shortnum,
  1423.           &plyr->maxammo[0],
  1424.           &st_statusbaron,
  1425.           ST_MAXAMMO0WIDTH);
  1426.  
  1427.     STlib_initNum(&w_maxammo[1],
  1428.           ST_MAXAMMO1X,
  1429.           ST_MAXAMMO1Y,
  1430.           shortnum,
  1431.           &plyr->maxammo[1],
  1432.           &st_statusbaron,
  1433.           ST_MAXAMMO1WIDTH);
  1434.  
  1435.     STlib_initNum(&w_maxammo[2],
  1436.           ST_MAXAMMO2X,
  1437.           ST_MAXAMMO2Y,
  1438.           shortnum,
  1439.           &plyr->maxammo[2],
  1440.           &st_statusbaron,
  1441.           ST_MAXAMMO2WIDTH);
  1442.     
  1443.     STlib_initNum(&w_maxammo[3],
  1444.           ST_MAXAMMO3X,
  1445.           ST_MAXAMMO3Y,
  1446.           shortnum,
  1447.           &plyr->maxammo[3],
  1448.           &st_statusbaron,
  1449.           ST_MAXAMMO3WIDTH);
  1450.  
  1451. }
  1452.  
  1453. static boolean    st_stopped = true;
  1454.  
  1455.  
  1456. void ST_Start (void)
  1457. {
  1458.  
  1459.     if (!st_stopped)
  1460.     ST_Stop();
  1461.  
  1462.     ST_initData();
  1463.     ST_createWidgets();
  1464.     st_stopped = false;
  1465.  
  1466. }
  1467.  
  1468. void ST_Stop (void)
  1469. {
  1470.     if (st_stopped)
  1471.     return;
  1472.  
  1473.     I_SetPalette (W_CacheLumpNum (lu_palette, PU_CACHE));
  1474.  
  1475.     st_stopped = true;
  1476. }
  1477.  
  1478. void ST_Init (void)
  1479. {
  1480.     veryfirsttime = 0;
  1481.     ST_loadData();
  1482. /*     screens[4] = (byte *) Z_Malloc(ST_WIDTH*ST_HEIGHT*3, PU_STATIC, 0); */
  1483.  
  1484.     screens[4]=screens[1]+(SCREENHEIGHT-SBARHEIGHT)*SCREENWIDTH*pixel_size;
  1485. }
  1486.