1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
6 // Copyright (C) 1993-1996 by id Software, Inc.
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.
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
21 // Does the face/direction indicator animatin.
22 // Does palette indicators as well (red pain/berserk, bright pickup)
24 //-----------------------------------------------------------------------------
27 rcsid[] = "$Id: st_stuff.c,v 1.6 1997/02/03 22:45:13 b1 Exp $";
51 // Needs access to LFB.
67 // For damage/bonus red-/gold-shifts
68 #define STARTREDPALS 1
69 #define STARTBONUSPALS 9
71 #define NUMBONUSPALS 4
72 // Radiation suit, green shift.
73 #define RADIATIONPAL 13
75 // N/256*100% probability
76 // that the normal face state will change
77 #define ST_FACEPROBABILITY 96
80 #define ST_TOGGLECHAT KEY_ENTER
82 // Location of status bar
89 // Should be set to patch width
90 // for tall numbers later on
91 #define ST_TALLNUMWIDTH (tallnum[0]->width)
93 // Number of status faces.
94 #define ST_NUMPAINFACES 5
95 #define ST_NUMSTRAIGHTFACES 3
96 #define ST_NUMTURNFACES 2
97 #define ST_NUMSPECIALFACES 3
99 #define ST_FACESTRIDE \
100 (ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES)
102 #define ST_NUMEXTRAFACES 2
104 #define ST_NUMFACES \
105 (ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES)
107 #define ST_TURNOFFSET (ST_NUMSTRAIGHTFACES)
108 #define ST_OUCHOFFSET (ST_TURNOFFSET + ST_NUMTURNFACES)
109 #define ST_EVILGRINOFFSET (ST_OUCHOFFSET + 1)
110 #define ST_RAMPAGEOFFSET (ST_EVILGRINOFFSET + 1)
111 #define ST_GODFACE (ST_NUMPAINFACES*ST_FACESTRIDE)
112 #define ST_DEADFACE (ST_GODFACE+1)
114 #define ST_FACESX 143
115 #define ST_FACESY 168
117 #define ST_EVILGRINCOUNT (2*TICRATE)
118 #define ST_STRAIGHTFACECOUNT (TICRATE/2)
119 #define ST_TURNCOUNT (1*TICRATE)
120 #define ST_OUCHCOUNT (1*TICRATE)
121 #define ST_RAMPAGEDELAY (2*TICRATE)
123 #define ST_MUCHPAIN 20
126 // Location and size of statistics,
127 // justified according to widget type.
128 // Problem is, within which space? STbar? Screen?
129 // Note: this could be read in by a lump.
130 // Problem is, is the stuff rendered
132 // or into the frame buffer?
135 #define ST_AMMOWIDTH 3
139 // HEALTH number pos.
140 #define ST_HEALTHWIDTH 3
141 #define ST_HEALTHX 90
142 #define ST_HEALTHY 171
147 #define ST_ARMSBGX 104
148 #define ST_ARMSBGY 168
149 #define ST_ARMSXSPACE 12
150 #define ST_ARMSYSPACE 10
153 #define ST_FRAGSX 138
154 #define ST_FRAGSY 171
155 #define ST_FRAGSWIDTH 2
158 #define ST_ARMORWIDTH 3
159 #define ST_ARMORX 221
160 #define ST_ARMORY 171
162 // Key icon positions.
163 #define ST_KEY0WIDTH 8
164 #define ST_KEY0HEIGHT 5
167 #define ST_KEY1WIDTH ST_KEY0WIDTH
170 #define ST_KEY2WIDTH ST_KEY0WIDTH
174 // Ammunition counter.
175 #define ST_AMMO0WIDTH 3
176 #define ST_AMMO0HEIGHT 6
177 #define ST_AMMO0X 288
178 #define ST_AMMO0Y 173
179 #define ST_AMMO1WIDTH ST_AMMO0WIDTH
180 #define ST_AMMO1X 288
181 #define ST_AMMO1Y 179
182 #define ST_AMMO2WIDTH ST_AMMO0WIDTH
183 #define ST_AMMO2X 288
184 #define ST_AMMO2Y 191
185 #define ST_AMMO3WIDTH ST_AMMO0WIDTH
186 #define ST_AMMO3X 288
187 #define ST_AMMO3Y 185
189 // Indicate maximum ammunition.
190 // Only needed because backpack exists.
191 #define ST_MAXAMMO0WIDTH 3
192 #define ST_MAXAMMO0HEIGHT 5
193 #define ST_MAXAMMO0X 314
194 #define ST_MAXAMMO0Y 173
195 #define ST_MAXAMMO1WIDTH ST_MAXAMMO0WIDTH
196 #define ST_MAXAMMO1X 314
197 #define ST_MAXAMMO1Y 179
198 #define ST_MAXAMMO2WIDTH ST_MAXAMMO0WIDTH
199 #define ST_MAXAMMO2X 314
200 #define ST_MAXAMMO2Y 191
201 #define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH
202 #define ST_MAXAMMO3X 314
203 #define ST_MAXAMMO3Y 185
206 #define ST_WEAPON0X 110
207 #define ST_WEAPON0Y 172
210 #define ST_WEAPON1X 122
211 #define ST_WEAPON1Y 172
214 #define ST_WEAPON2X 134
215 #define ST_WEAPON2Y 172
218 #define ST_WEAPON3X 110
219 #define ST_WEAPON3Y 181
222 #define ST_WEAPON4X 122
223 #define ST_WEAPON4Y 181
226 #define ST_WEAPON5X 134
227 #define ST_WEAPON5Y 181
237 //Incoming messages window location
239 // #define ST_MSGTEXTX (viewwindowx)
240 // #define ST_MSGTEXTY (viewwindowy+viewheight-18)
241 #define ST_MSGTEXTX 0
242 #define ST_MSGTEXTY 0
243 // Dimensions given in characters.
244 #define ST_MSGWIDTH 52
245 // Or shall I say, in lines?
246 #define ST_MSGHEIGHT 1
248 #define ST_OUTTEXTX 0
249 #define ST_OUTTEXTY 6
251 // Width, in characters again.
252 #define ST_OUTWIDTH 52
254 #define ST_OUTHEIGHT 1
256 #define ST_MAPWIDTH \
257 (strlen(mapnames[(gameepisode-1)*9+(gamemap-1)]))
259 #define ST_MAPTITLEX \
260 (SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH)
262 #define ST_MAPTITLEY 0
263 #define ST_MAPHEIGHT 1
266 // main player in game
267 static player_t* plyr;
269 // ST_Start() has just been called
270 static boolean st_firsttime;
272 // used to execute ST_Init() only once
273 static int veryfirsttime = 1;
275 // lump number for PLAYPAL
276 static int lu_palette;
279 static unsigned int st_clock;
281 // used for making messages go away
282 static int st_msgcounter=0;
285 static st_chatstateenum_t st_chatstate;
287 // whether in automap or first-person
288 static st_stateenum_t st_gamestate;
290 // whether left-side main status bar is active
291 static boolean st_statusbaron;
293 // whether status bar chat is active
294 static boolean st_chat;
296 // value of st_chat before message popped up
297 static boolean st_oldchat;
299 // whether chat window has the cursor on
300 static boolean st_cursoron;
303 static boolean st_notdeathmatch;
305 // !deathmatch && st_statusbaron
306 static boolean st_armson;
309 static boolean st_fragson;
312 static patch_t* sbar;
315 static patch_t* tallnum[10];
318 static patch_t* tallpercent;
320 // 0-9, short, yellow (,different!) numbers
321 static patch_t* shortnum[10];
323 // 3 key-cards, 3 skulls
324 static patch_t* keys[NUMCARDS];
326 // face status patches
327 static patch_t* faces[ST_NUMFACES];
330 static patch_t* faceback;
333 static patch_t* armsbg;
335 // weapon ownership patches
336 static patch_t* arms[6][2];
338 // ready-weapon widget
339 static st_number_t w_ready;
341 // in deathmatch only, summary of frags stats
342 static st_number_t w_frags;
345 static st_percent_t w_health;
348 static st_binicon_t w_armsbg;
351 // weapon ownership widgets
352 static st_multicon_t w_arms[6];
354 // face status widget
355 static st_multicon_t w_faces;
358 static st_multicon_t w_keyboxes[3];
361 static st_percent_t w_armor;
364 static st_number_t w_ammo[4];
367 static st_number_t w_maxammo[4];
371 // number of frags so far in deathmatch
372 static int st_fragscount;
374 // used to use appopriately pained face
375 static int st_oldhealth = -1;
377 // used for evil grin
378 static boolean oldweaponsowned[NUMWEAPONS];
380 // count until face changes
381 static int st_facecount = 0;
383 // current face index, used by w_faces
384 static int st_faceindex = 0;
386 // holds key-type for each key box on bar
387 static int keyboxes[3];
389 // a random number per tick
390 static int st_randomnumber;
394 // Massive bunches of cheat shit
395 // to keep it from being easy to figure them out.
397 unsigned char cheat_mus_seq[] =
399 0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff
402 unsigned char cheat_choppers_seq[] =
404 0xb2, 0x26, 0xe2, 0x32, 0xf6, 0x2a, 0x2a, 0xa6, 0x6a, 0xea, 0xff // id...
407 unsigned char cheat_god_seq[] =
409 0xb2, 0x26, 0x26, 0xaa, 0x26, 0xff // iddqd
412 unsigned char cheat_ammo_seq[] =
414 0xb2, 0x26, 0xf2, 0x66, 0xa2, 0xff // idkfa
417 unsigned char cheat_ammonokey_seq[] =
419 0xb2, 0x26, 0x66, 0xa2, 0xff // idfa
423 // Smashing Pumpkins Into Samml Piles Of Putried Debris.
424 unsigned char cheat_noclip_seq[] =
426 0xb2, 0x26, 0xea, 0x2a, 0xb2, // idspispopd
427 0xea, 0x2a, 0xf6, 0x2a, 0x26, 0xff
431 unsigned char cheat_commercial_noclip_seq[] =
433 0xb2, 0x26, 0xe2, 0x36, 0xb2, 0x2a, 0xff // idclip
438 unsigned char cheat_powerup_seq[7][10] =
440 { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6e, 0xff }, // beholdv
441 { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xea, 0xff }, // beholds
442 { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xb2, 0xff }, // beholdi
443 { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6a, 0xff }, // beholdr
444 { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xa2, 0xff }, // beholda
445 { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x36, 0xff }, // beholdl
446 { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xff } // behold
450 unsigned char cheat_clev_seq[] =
452 0xb2, 0x26, 0xe2, 0x36, 0xa6, 0x6e, 1, 0, 0, 0xff // idclev
457 unsigned char cheat_mypos_seq[] =
459 0xb2, 0x26, 0xb6, 0xba, 0x2a, 0xf6, 0xea, 0xff // idmypos
464 cheatseq_t cheat_mus = { cheat_mus_seq, 0 };
465 cheatseq_t cheat_god = { cheat_god_seq, 0 };
466 cheatseq_t cheat_ammo = { cheat_ammo_seq, 0 };
467 cheatseq_t cheat_ammonokey = { cheat_ammonokey_seq, 0 };
468 cheatseq_t cheat_noclip = { cheat_noclip_seq, 0 };
469 cheatseq_t cheat_commercial_noclip = { cheat_commercial_noclip_seq, 0 };
471 cheatseq_t cheat_powerup[7] =
473 { cheat_powerup_seq[0], 0 },
474 { cheat_powerup_seq[1], 0 },
475 { cheat_powerup_seq[2], 0 },
476 { cheat_powerup_seq[3], 0 },
477 { cheat_powerup_seq[4], 0 },
478 { cheat_powerup_seq[5], 0 },
479 { cheat_powerup_seq[6], 0 }
482 cheatseq_t cheat_choppers = { cheat_choppers_seq, 0 };
483 cheatseq_t cheat_clev = { cheat_clev_seq, 0 };
484 cheatseq_t cheat_mypos = { cheat_mypos_seq, 0 };
488 extern char* mapnames[];
496 void ST_refreshBackground(void)
501 V_DrawPatch(ST_X, 0, BG, sbar);
504 V_DrawPatch(ST_FX, 0, BG, faceback);
506 V_CopyRect(ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG);
512 // Respond to keyboard input events,
515 ST_Responder (event_t* ev)
519 // Filter automap on/off.
520 if (ev->type == ev_keyup
521 && ((ev->data1 & 0xffff0000) == AM_MSGHEADER))
526 st_gamestate = AutomapState;
531 // fprintf(stderr, "AM exited\n");
532 st_gamestate = FirstPersonState;
537 // if a user keypress...
538 else if (ev->type == ev_keydown)
542 // b. - enabled for more debug fun.
543 // if (gameskill != sk_nightmare) {
545 // 'dqd' cheat for toggleable god mode
546 if (cht_CheckCheat(&cheat_god, ev->data1))
548 plyr->cheats ^= CF_GODMODE;
549 if (plyr->cheats & CF_GODMODE)
552 plyr->mo->health = 100;
555 plyr->message = STSTR_DQDON;
558 plyr->message = STSTR_DQDOFF;
560 // 'fa' cheat for killer fucking arsenal
561 else if (cht_CheckCheat(&cheat_ammonokey, ev->data1))
563 plyr->armorpoints = 200;
566 for (i=0;i<NUMWEAPONS;i++)
567 plyr->weaponowned[i] = true;
569 for (i=0;i<NUMAMMO;i++)
570 plyr->ammo[i] = plyr->maxammo[i];
572 plyr->message = STSTR_FAADDED;
574 // 'kfa' cheat for key full ammo
575 else if (cht_CheckCheat(&cheat_ammo, ev->data1))
577 plyr->armorpoints = 200;
580 for (i=0;i<NUMWEAPONS;i++)
581 plyr->weaponowned[i] = true;
583 for (i=0;i<NUMAMMO;i++)
584 plyr->ammo[i] = plyr->maxammo[i];
586 for (i=0;i<NUMCARDS;i++)
587 plyr->cards[i] = true;
589 plyr->message = STSTR_KFAADDED;
591 // 'mus' cheat for changing music
592 else if (cht_CheckCheat(&cheat_mus, ev->data1))
598 plyr->message = STSTR_MUS;
599 cht_GetParam(&cheat_mus, buf);
601 if (gamemode == commercial)
603 musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1;
605 if (((buf[0]-'0')*10 + buf[1]-'0') > 35)
606 plyr->message = STSTR_NOMUS;
608 S_ChangeMusic(musnum, 1);
612 musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1');
614 if (((buf[0]-'1')*9 + buf[1]-'1') > 31)
615 plyr->message = STSTR_NOMUS;
617 S_ChangeMusic(musnum, 1);
620 // Simplified, accepting both "noclip" and "idspispopd".
621 // no clipping mode cheat
622 else if ( cht_CheckCheat(&cheat_noclip, ev->data1)
623 || cht_CheckCheat(&cheat_commercial_noclip,ev->data1) )
625 plyr->cheats ^= CF_NOCLIP;
627 if (plyr->cheats & CF_NOCLIP)
628 plyr->message = STSTR_NCON;
630 plyr->message = STSTR_NCOFF;
632 // 'behold?' power-up cheats
635 if (cht_CheckCheat(&cheat_powerup[i], ev->data1))
637 if (!plyr->powers[i])
638 P_GivePower( plyr, i);
639 else if (i!=pw_strength)
644 plyr->message = STSTR_BEHOLDX;
648 // 'behold' power-up menu
649 if (cht_CheckCheat(&cheat_powerup[6], ev->data1))
651 plyr->message = STSTR_BEHOLD;
653 // 'choppers' invulnerability & chainsaw
654 else if (cht_CheckCheat(&cheat_choppers, ev->data1))
656 plyr->weaponowned[wp_chainsaw] = true;
657 plyr->powers[pw_invulnerability] = true;
658 plyr->message = STSTR_CHOPPERS;
660 // 'mypos' for player position
661 else if (cht_CheckCheat(&cheat_mypos, ev->data1))
663 static char buf[ST_MSGWIDTH];
664 sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)",
665 players[consoleplayer].mo->angle,
666 players[consoleplayer].mo->x,
667 players[consoleplayer].mo->y);
672 // 'clev' change-level cheat
673 if (cht_CheckCheat(&cheat_clev, ev->data1))
679 cht_GetParam(&cheat_clev, buf);
681 if (gamemode == commercial)
684 map = (buf[0] - '0')*10 + buf[1] - '0';
692 // Catch invalid maps.
699 // Ohmygod - this is not going to work.
700 if ((gamemode == retail)
701 && ((epsd > 4) || (map > 9)))
704 if ((gamemode == registered)
705 && ((epsd > 3) || (map > 9)))
708 if ((gamemode == shareware)
709 && ((epsd > 1) || (map > 9)))
712 if ((gamemode == commercial)
713 && (( epsd > 1) || (map > 34)))
717 plyr->message = STSTR_CLEV;
718 G_DeferedInitNew(gameskill, epsd, map);
726 int ST_calcPainOffset(void)
730 static int oldhealth = -1;
732 health = plyr->health > 100 ? 100 : plyr->health;
734 if (health != oldhealth)
736 lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101);
744 // This is a not-very-pretty routine which handles
745 // the face states and their timing.
746 // the precedence of expressions is:
747 // dead > evil grin > turned head > straight ahead
749 void ST_updateFaceWidget(void)
754 static int lastattackdown = -1;
755 static int priority = 0;
764 st_faceindex = ST_DEADFACE;
771 if (plyr->bonuscount)
776 for (i=0;i<NUMWEAPONS;i++)
778 if (oldweaponsowned[i] != plyr->weaponowned[i])
781 oldweaponsowned[i] = plyr->weaponowned[i];
786 // evil grin if just picked up weapon
788 st_facecount = ST_EVILGRINCOUNT;
789 st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
797 if (plyr->damagecount
799 && plyr->attacker != plyr->mo)
804 if (st_oldhealth - plyr->health > ST_MUCHPAIN)
806 st_facecount = ST_TURNCOUNT;
807 st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
811 badguyangle = R_PointToAngle2(plyr->mo->x,
816 if (badguyangle > plyr->mo->angle)
818 // whether right or left
819 diffang = badguyangle - plyr->mo->angle;
820 i = diffang > ANG180;
824 // whether left or right
825 diffang = plyr->mo->angle - badguyangle;
826 i = diffang <= ANG180;
827 } // confusing, aint it?
830 st_facecount = ST_TURNCOUNT;
831 st_faceindex = ST_calcPainOffset();
836 st_faceindex += ST_RAMPAGEOFFSET;
841 st_faceindex += ST_TURNOFFSET;
846 st_faceindex += ST_TURNOFFSET+1;
854 // getting hurt because of your own damn stupidity
855 if (plyr->damagecount)
857 if (st_oldhealth - plyr->health > ST_MUCHPAIN)
860 st_facecount = ST_TURNCOUNT;
861 st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
866 st_facecount = ST_TURNCOUNT;
867 st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
877 if (plyr->attackdown)
879 if (lastattackdown==-1)
880 lastattackdown = ST_RAMPAGEDELAY;
881 else if (!--lastattackdown)
884 st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
897 if ((plyr->cheats & CF_GODMODE)
898 || plyr->powers[pw_invulnerability])
902 st_faceindex = ST_GODFACE;
909 // look left or look right if the facecount has timed out
912 st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3);
913 st_facecount = ST_STRAIGHTFACECOUNT;
921 void ST_updateWidgets(void)
923 static int largeammo = 1994; // means "n/a"
926 // must redirect the pointer if the ready weapon has changed.
927 // if (w_ready.data != plyr->readyweapon)
929 if (weaponinfo[plyr->readyweapon].ammo == am_noammo)
930 w_ready.num = &largeammo;
932 w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo];
935 // static int dir=-1;
937 // plyr->ammo[weaponinfo[plyr->readyweapon].ammo]+=dir;
938 // if (plyr->ammo[weaponinfo[plyr->readyweapon].ammo] == -100)
942 w_ready.data = plyr->readyweapon;
945 // STlib_updateNum(&w_ready, true);
946 // refresh weapon change
949 // update keycard multiple widgets
952 keyboxes[i] = plyr->cards[i] ? i : -1;
954 if (plyr->cards[i+3])
958 // refresh everything if this is him coming back to life
959 ST_updateFaceWidget();
961 // used by the w_armsbg widget
962 st_notdeathmatch = !deathmatch;
964 // used by w_arms[] widgets
965 st_armson = st_statusbaron && !deathmatch;
967 // used by w_frags widget
968 st_fragson = deathmatch && st_statusbaron;
971 for (i=0 ; i<MAXPLAYERS ; i++)
973 if (i != consoleplayer)
974 st_fragscount += plyr->frags[i];
976 st_fragscount -= plyr->frags[i];
979 // get rid of chat window if up because of message
980 if (!--st_msgcounter)
981 st_chat = st_oldchat;
985 void ST_Ticker (void)
989 st_randomnumber = M_Random();
991 st_oldhealth = plyr->health;
995 static int st_palette = 0;
997 void ST_doPaletteStuff(void)
1005 cnt = plyr->damagecount;
1007 if (plyr->powers[pw_strength])
1009 // slowly fade the berzerk out
1010 bzc = 12 - (plyr->powers[pw_strength]>>6);
1018 palette = (cnt+7)>>3;
1020 if (palette >= NUMREDPALS)
1021 palette = NUMREDPALS-1;
1023 palette += STARTREDPALS;
1026 else if (plyr->bonuscount)
1028 palette = (plyr->bonuscount+7)>>3;
1030 if (palette >= NUMBONUSPALS)
1031 palette = NUMBONUSPALS-1;
1033 palette += STARTBONUSPALS;
1036 else if ( plyr->powers[pw_ironfeet] > 4*32
1037 || plyr->powers[pw_ironfeet]&8)
1038 palette = RADIATIONPAL;
1042 if (palette != st_palette)
1044 st_palette = palette;
1045 pal = (byte *) W_CacheLumpNum (lu_palette, PU_CACHE)+palette*768;
1051 void ST_drawWidgets(boolean refresh)
1055 // used by w_arms[] widgets
1056 st_armson = st_statusbaron && !deathmatch;
1058 // used by w_frags widget
1059 st_fragson = deathmatch && st_statusbaron;
1061 STlib_updateNum(&w_ready, refresh);
1065 STlib_updateNum(&w_ammo[i], refresh);
1066 STlib_updateNum(&w_maxammo[i], refresh);
1069 STlib_updatePercent(&w_health, refresh);
1070 STlib_updatePercent(&w_armor, refresh);
1072 STlib_updateBinIcon(&w_armsbg, refresh);
1075 STlib_updateMultIcon(&w_arms[i], refresh);
1077 STlib_updateMultIcon(&w_faces, refresh);
1080 STlib_updateMultIcon(&w_keyboxes[i], refresh);
1082 STlib_updateNum(&w_frags, refresh);
1086 void ST_doRefresh(void)
1089 st_firsttime = false;
1091 // draw status bar background to off-screen buff
1092 ST_refreshBackground();
1094 // and refresh all widgets
1095 ST_drawWidgets(true);
1099 void ST_diffDraw(void)
1101 // update all widgets
1102 ST_drawWidgets(false);
1105 void ST_Drawer (boolean fullscreen, boolean refresh)
1108 st_statusbaron = (!fullscreen) || automapactive;
1109 st_firsttime = st_firsttime || refresh;
1111 // Do red-/gold-shifts from damage/items
1112 ST_doPaletteStuff();
1114 // If just after ST_Start(), refresh all
1115 if (st_firsttime) ST_doRefresh();
1116 // Otherwise, update as little as possible
1121 void ST_loadGraphics(void)
1130 // Load the numbers, tall and short
1133 sprintf(namebuf, "STTNUM%d", i);
1134 tallnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
1136 sprintf(namebuf, "STYSNUM%d", i);
1137 shortnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
1140 // Load percent key.
1141 //Note: why not load STMINUS here, too?
1142 tallpercent = (patch_t *) W_CacheLumpName("STTPRCNT", PU_STATIC);
1145 for (i=0;i<NUMCARDS;i++)
1147 sprintf(namebuf, "STKEYS%d", i);
1148 keys[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
1152 armsbg = (patch_t *) W_CacheLumpName("STARMS", PU_STATIC);
1154 // arms ownership widgets
1157 sprintf(namebuf, "STGNUM%d", i+2);
1160 arms[i][0] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
1163 arms[i][1] = shortnum[i+2];
1166 // face backgrounds for different color players
1167 sprintf(namebuf, "STFB%d", consoleplayer);
1168 faceback = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
1170 // status bar background bits
1171 sbar = (patch_t *) W_CacheLumpName("STBAR", PU_STATIC);
1175 for (i=0;i<ST_NUMPAINFACES;i++)
1177 for (j=0;j<ST_NUMSTRAIGHTFACES;j++)
1179 sprintf(namebuf, "STFST%d%d", i, j);
1180 faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
1182 sprintf(namebuf, "STFTR%d0", i); // turn right
1183 faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
1184 sprintf(namebuf, "STFTL%d0", i); // turn left
1185 faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
1186 sprintf(namebuf, "STFOUCH%d", i); // ouch!
1187 faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
1188 sprintf(namebuf, "STFEVL%d", i); // evil grin ;)
1189 faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
1190 sprintf(namebuf, "STFKILL%d", i); // pissed off
1191 faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
1193 faces[facenum++] = W_CacheLumpName("STFGOD0", PU_STATIC);
1194 faces[facenum ] = W_CacheLumpName("STFDEAD0", PU_STATIC);
1198 void ST_loadData(void)
1200 lu_palette = W_GetNumForName ("PLAYPAL");
1204 void ST_unloadGraphics(void)
1209 // unload the numbers, tall and short
1212 Z_ChangeTag(tallnum[i], PU_CACHE);
1213 Z_ChangeTag(shortnum[i], PU_CACHE);
1215 // unload tall percent
1216 Z_ChangeTag(tallpercent, PU_CACHE);
1218 // unload arms background
1219 Z_ChangeTag(armsbg, PU_CACHE);
1223 Z_ChangeTag(arms[i][0], PU_CACHE);
1225 // unload the key cards
1226 for (i=0;i<NUMCARDS;i++)
1227 Z_ChangeTag(keys[i], PU_CACHE);
1229 Z_ChangeTag(sbar, PU_CACHE);
1230 Z_ChangeTag(faceback, PU_CACHE);
1232 for (i=0;i<ST_NUMFACES;i++)
1233 Z_ChangeTag(faces[i], PU_CACHE);
1235 // Note: nobody ain't seen no unloading
1236 // of stminus yet. Dude.
1241 void ST_unloadData(void)
1243 ST_unloadGraphics();
1246 void ST_initData(void)
1251 st_firsttime = true;
1252 plyr = &players[consoleplayer];
1255 st_chatstate = StartChatState;
1256 st_gamestate = FirstPersonState;
1258 st_statusbaron = true;
1259 st_oldchat = st_chat = false;
1260 st_cursoron = false;
1267 for (i=0;i<NUMWEAPONS;i++)
1268 oldweaponsowned[i] = plyr->weaponowned[i];
1279 void ST_createWidgets(void)
1284 // ready weapon ammo
1285 STlib_initNum(&w_ready,
1289 &plyr->ammo[weaponinfo[plyr->readyweapon].ammo],
1293 // the last weapon type
1294 w_ready.data = plyr->readyweapon;
1296 // health percentage
1297 STlib_initPercent(&w_health,
1306 STlib_initBinIcon(&w_armsbg,
1316 STlib_initMultIcon(&w_arms[i],
1317 ST_ARMSX+(i%3)*ST_ARMSXSPACE,
1318 ST_ARMSY+(i/3)*ST_ARMSYSPACE,
1319 arms[i], (int *) &plyr->weaponowned[i+1],
1324 STlib_initNum(&w_frags,
1333 STlib_initMultIcon(&w_faces,
1340 // armor percentage - should be colored later
1341 STlib_initPercent(&w_armor,
1346 &st_statusbaron, tallpercent);
1349 STlib_initMultIcon(&w_keyboxes[0],
1356 STlib_initMultIcon(&w_keyboxes[1],
1363 STlib_initMultIcon(&w_keyboxes[2],
1370 // ammo count (all four kinds)
1371 STlib_initNum(&w_ammo[0],
1379 STlib_initNum(&w_ammo[1],
1387 STlib_initNum(&w_ammo[2],
1395 STlib_initNum(&w_ammo[3],
1403 // max ammo count (all four kinds)
1404 STlib_initNum(&w_maxammo[0],
1412 STlib_initNum(&w_maxammo[1],
1420 STlib_initNum(&w_maxammo[2],
1428 STlib_initNum(&w_maxammo[3],
1438 static boolean st_stopped = true;
1441 void ST_Start (void)
1458 I_SetPalette (W_CacheLumpNum (lu_palette, PU_CACHE));
1467 screens[4] = (byte *) Z_Malloc(ST_WIDTH*ST_HEIGHT, PU_STATIC, 0);