G.C 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/main/rcs/gauges.c $
  15. * $Revision: 2.1 $
  16. * $Author: john $
  17. * $Date: 1995/02/27 13:13:45 $
  18. *
  19. * Inferno gauge drivers
  20. *
  21. * $Log: gauges.c $
  22. * Revision 2.1 1995/02/27 13:13:45 john
  23. * Removed floating point.
  24. *
  25. * Revision 2.0 1995/02/27 11:29:06 john
  26. * New version 2.0, which has no anonymous unions, builds with
  27. * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  28. *
  29. * Revision 1.203 1995/02/11 01:56:45 mike
  30. * move up weapons text on fullscreen hud, missiles was offscreen.
  31. *
  32. * Revision 1.202 1995/02/09 13:23:34 rob
  33. * Added reticle names in demo playback.
  34. *
  35. * Revision 1.201 1995/02/08 19:20:46 rob
  36. * Show cloaked teammates on H
  37. * UD. Get rid of show ID's in anarchy option.
  38. *
  39. * Revision 1.200 1995/02/07 21:09:00 mike
  40. * add flashing to invulnerability and cloak on fullscreen.
  41. *
  42. * Revision 1.199 1995/02/02 21:55:57 matt
  43. * Added new colored key icons for fullscreen
  44. *
  45. * Revision 1.198 1995/01/30 17:17:07 rob
  46. * Fixed teammate names on hud.
  47. *
  48. * Revision 1.197 1995/01/28 17:40:49 mike
  49. * fix gauge fontcolor.
  50. *
  51. * Revision 1.196 1995/01/27 17:03:14 mike
  52. * fix placement of weapon info in multiplayer fullscreen, as per AP request.
  53. *
  54. * Revision 1.195 1995/01/27 11:51:23 rob
  55. * Put deaths tally into cooperative mode
  56. *
  57. * Revision 1.194 1995/01/27 11:43:24 adam
  58. * fiddled with key display
  59. *
  60. * Revision 1.193 1995/01/25 23:38:35 mike
  61. * fix keys on fullscreen.
  62. *
  63. * Revision 1.192 1995/01/24 22:03:28 mike
  64. * Lotsa hud stuff, put a lot of messages up.
  65. *
  66. * Revision 1.191 1995/01/23 16:47:21 rob
  67. * Fixed problem with playing extra life noise in coop.
  68. *
  69. * Revision 1.190 1995/01/22 16:00:46 mike
  70. * remove unneeded string.
  71. *
  72. * Revision 1.189 1995/01/22 15:58:22 mike
  73. * localization
  74. *
  75. * Revision 1.188 1995/01/20 17:19:45 rob
  76. * Fixing colors of hud kill list players.
  77. *
  78. * Revision 1.187 1995/01/20 09:19:18 allender
  79. * record player flags when in CM_FULL_SCREEN
  80. *
  81. * Revision 1.186 1995/01/19 16:29:09 allender
  82. * made demo recording of weapon change be in this file for shareware only
  83. *
  84. * Revision 1.185 1995/01/19 15:00:33 allender
  85. * code to record shield, energy, and ammo in fullscreen
  86. *
  87. * Revision 1.184 1995/01/19 13:43:13 matt
  88. * Fixed "cheater" message on HUD
  89. *
  90. * Revision 1.183 1995/01/18 16:11:58 mike
  91. * Don't show added scores of 0.
  92. *
  93. * Revision 1.182 1995/01/17 17:42:39 allender
  94. * do ammo counts in demo recording
  95. *
  96. * Revision 1.181 1995/01/16 17:26:25 rob
  97. * Fixed problem with coloration of team kill list.
  98. *
  99. * Revision 1.180 1995/01/16 17:22:39 john
  100. * Made so that KB and framerate don't collide.
  101. *
  102. * Revision 1.179 1995/01/16 14:58:31 matt
  103. * Changed score_added display to print "Cheater!" when cheats enabled
  104. *
  105. * Revision 1.178 1995/01/15 19:42:07 matt
  106. * Ripped out hostage faces for registered version
  107. *
  108. * Revision 1.177 1995/01/15 19:25:07 mike
  109. * show vulcan ammo and secondary ammo in fullscreen view.
  110. *
  111. * Revision 1.176 1995/01/15 13:16:12 john
  112. * Made so that paging always happens, lowmem just loads less.
  113. * Also, make KB load print to hud.
  114. *
  115. * Revision 1.175 1995/01/14 19:17:32 john
  116. * First version of piggy paging.
  117. *
  118. * Revision 1.174 1995/01/05 21:25:23 rob
  119. * Re-did some changes lost due to RCS weirdness.
  120. *
  121. * Revision 1.173 1995/01/05 12:22:34 rob
  122. * Don't show player names for cloaked players.
  123. *
  124. * Revision 1.172 1995/01/04 17:14:50 allender
  125. * make init_gauges work properly on demo playback
  126. *
  127. * Revision 1.171 1995/01/04 15:04:42 allender
  128. * new demo calls for registered version
  129. *
  130. * Revision 1.167 1995/01/03 13:03:57 allender
  131. * pass score points instead of total points. Added ifdef for
  132. * multi_send_score
  133. *
  134. * Revision 1.166 1995/01/03 11:45:02 allender
  135. * add hook to record player score
  136. *
  137. * Revision 1.165 1995/01/03 11:25:19 allender
  138. * remove newdemo stuff around score display
  139. *
  140. * Revision 1.163 1995/01/02 21:03:53 rob
  141. * Fixing up the hud-score-list for coop games.
  142. *
  143. * Revision 1.162 1994/12/31 20:54:40 rob
  144. * Added coop mode HUD score list.
  145. * Added more generic system for player names on HUD.
  146. *
  147. * Revision 1.161 1994/12/30 20:13:01 rob
  148. * Ifdef reticle names on shareware.
  149. * Added robot reticle naming.
  150. *
  151. * Revision 1.160 1994/12/29 17:53:51 mike
  152. * move up energy/shield in fullscreen to get out of way of kill list.
  153. *
  154. * Revision 1.159 1994/12/29 16:44:05 mike
  155. * add energy and shield showing.
  156. *
  157. * Revision 1.158 1994/12/28 16:34:29 mike
  158. * make warning beep go away on Player_is_dead.
  159. *
  160. * Revision 1.157 1994/12/28 10:00:43 allender
  161. * change in init_gauges to for multiplayer demo playbacks
  162. *
  163. * Revision 1.156 1994/12/27 11:06:46 allender
  164. * removed some previous code to for demo playback stuff
  165. *
  166. * Revision 1.155 1994/12/23 14:23:06 john
  167. * Added floating reticle for VR helments.
  168. *
  169. * Revision 1.154 1994/12/21 12:56:41 allender
  170. * on multiplayer demo playback, show kills and deaths
  171. *
  172. * Revision 1.153 1994/12/19 20:28:42 rob
  173. * Get rid of kill list in coop games.
  174. *
  175. * Revision 1.152 1994/12/14 18:06:44 matt
  176. * Removed compile warnings
  177. *
  178. * Revision 1.151 1994/12/14 15:21:28 rob
  179. * Made gauges align in status_bar net game.
  180. *
  181. * Revision 1.150 1994/12/12 17:20:33 matt
  182. * Don't get bonus points when cheating
  183. *
  184. * Revision 1.149 1994/12/12 16:47:00 matt
  185. * When cheating, get no score. Change level cheat to prompt for and
  186. * jump to new level.
  187. *
  188. * Revision 1.148 1994/12/12 12:05:45 rob
  189. * Grey out players who are disconnected.
  190. *
  191. * Revision 1.147 1994/12/09 16:19:48 yuan
  192. * kill matrix stuff.
  193. *
  194. * Revision 1.146 1994/12/09 16:12:34 rob
  195. * Fixed up the status bar kills gauges for net play.
  196. *
  197. * Revision 1.145 1994/12/09 01:55:34 rob
  198. * Added kills list to HUD/status bar.
  199. * Added something for Mark.
  200. *
  201. * Revision 1.144 1994/12/08 21:03:30 allender
  202. * pass old player flags to record_player_flags
  203. *
  204. * Revision 1.143 1994/12/07 22:49:33 mike
  205. * no homing missile warning during endlevel sequence.
  206. *
  207. * Revision 1.142 1994/12/06 13:55:31 matt
  208. * Use new rounding func, f2ir()
  209. *
  210. * Revision 1.141 1994/12/03 19:03:37 matt
  211. * Fixed vulcan ammo HUD message
  212. *
  213. * Revision 1.140 1994/12/03 18:43:18 matt
  214. * Fixed (hopefully) claok gauge
  215. *
  216. * Revision 1.139 1994/12/03 14:26:21 yuan
  217. * Fixed dumb bug
  218. *
  219. * Revision 1.138 1994/12/03 14:17:30 yuan
  220. * Localization 320
  221. *
  222. */
  223. #pragma off (unreferenced)
  224. static char rcsid[] = "$Id: gauges.c 2.1 1995/02/27 13:13:45 john Exp $";
  225. #pragma on (unreferenced)
  226. #include <stdio.h>
  227. #include <string.h>
  228. #include <stdlib.h>
  229. #include <stdarg.h>
  230. #include "inferno.h"
  231. #include "game.h"
  232. #include "screens.h"
  233. #include "gauges.h"
  234. #include "physics.h"
  235. #include "error.h"
  236. #include "menu.h" // For the font.
  237. #include "mono.h"
  238. #include "collide.h"
  239. #include "newdemo.h"
  240. #include "player.h"
  241. #include "gamefont.h"
  242. #include "hostage.h"
  243. #include "bm.h"
  244. #include "text.h"
  245. #include "powerup.h"
  246. #include "sounds.h"
  247. #include "multi.h"
  248. #include "network.h"
  249. #include "endlevel.h"
  250. #include "wall.h"
  251. #include "text.h"
  252. #include "render.h"
  253. #include "piggy.h"
  254. bitmap_index Gauges[MAX_GAUGE_BMS]; // Array of all gauge bitmaps.
  255. grs_canvas *Canv_LeftEnergyGauge;
  256. grs_canvas *Canv_SBEnergyGauge;
  257. grs_canvas *Canv_RightEnergyGauge;
  258. grs_canvas *Canv_NumericalGauge;
  259. //bitmap numbers for gauges
  260. #define GAUGE_SHIELDS 0 //0..9, in decreasing order (100%,90%...0%)
  261. #define GAUGE_INVULNERABLE 10 //10..19
  262. #define N_INVULNERABLE_FRAMES 10
  263. #define GAUGE_SPEED 20 //unused
  264. #define GAUGE_ENERGY_LEFT 21
  265. #define GAUGE_ENERGY_RIGHT 22
  266. #define GAUGE_NUMERICAL 23
  267. #define GAUGE_BLUE_KEY 24
  268. #define GAUGE_GOLD_KEY 25
  269. #define GAUGE_RED_KEY 26
  270. #define GAUGE_BLUE_KEY_OFF 27
  271. #define GAUGE_GOLD_KEY_OFF 28
  272. #define GAUGE_RED_KEY_OFF 29
  273. #define SB_GAUGE_BLUE_KEY 30
  274. #define SB_GAUGE_GOLD_KEY 31
  275. #define SB_GAUGE_RED_KEY 32
  276. #define SB_GAUGE_BLUE_KEY_OFF 33
  277. #define SB_GAUGE_GOLD_KEY_OFF 34
  278. #define SB_GAUGE_RED_KEY_OFF 35
  279. #define SB_GAUGE_ENERGY 36
  280. #define GAUGE_LIVES 37
  281. #define GAUGE_SHIPS 38
  282. #define GAUGE_SHIPS_LAST 45
  283. #define RETICLE_CROSS 46
  284. #define RETICLE_PRIMARY 48
  285. #define RETICLE_SECONDARY 51
  286. #define RETICLE_LAST 55
  287. #define GAUGE_HOMING_WARNING_ON 56
  288. #define GAUGE_HOMING_WARNING_OFF 57
  289. #define SML_RETICLE_CROSS 58
  290. #define SML_RETICLE_PRIMARY 60
  291. #define SML_RETICLE_SECONDARY 63
  292. #define SML_RETICLE_LAST 67
  293. #define KEY_ICON_BLUE 68
  294. #define KEY_ICON_YELLOW 69
  295. #define KEY_ICON_RED 70
  296. //change MAX_GAUGE_BMS when adding gauges
  297. //Coordinats for gauges
  298. #define GAUGE_BLUE_KEY_X 45
  299. #define GAUGE_BLUE_KEY_Y 152
  300. #define GAUGE_GOLD_KEY_X 44
  301. #define GAUGE_GOLD_KEY_Y 162
  302. #define GAUGE_RED_KEY_X 43
  303. #define GAUGE_RED_KEY_Y 172
  304. #define SB_GAUGE_KEYS_X 11
  305. #define SB_GAUGE_BLUE_KEY_Y 153
  306. #define SB_GAUGE_GOLD_KEY_Y 169
  307. #define SB_GAUGE_RED_KEY_Y 185
  308. #define LEFT_ENERGY_GAUGE_X 70
  309. #define LEFT_ENERGY_GAUGE_Y 131
  310. #define LEFT_ENERGY_GAUGE_W 64
  311. #define LEFT_ENERGY_GAUGE_H 8
  312. #define RIGHT_ENERGY_GAUGE_X 190
  313. #define RIGHT_ENERGY_GAUGE_Y 131
  314. #define RIGHT_ENERGY_GAUGE_W 64
  315. #define RIGHT_ENERGY_GAUGE_H 8
  316. #define SB_ENERGY_GAUGE_X 98
  317. #define SB_ENERGY_GAUGE_Y 155
  318. #define SB_ENERGY_GAUGE_W 16
  319. #define SB_ENERGY_GAUGE_H 41
  320. #define SB_ENERGY_NUM_X (SB_ENERGY_GAUGE_X+2)
  321. #define SB_ENERGY_NUM_Y 190
  322. #define SHIELD_GAUGE_X 146
  323. #define SHIELD_GAUGE_Y 155
  324. #define SHIELD_GAUGE_W 35
  325. #define SHIELD_GAUGE_H 32
  326. #define SHIP_GAUGE_X (SHIELD_GAUGE_X+5)
  327. #define SHIP_GAUGE_Y (SHIELD_GAUGE_Y+5)
  328. #define SB_SHIELD_GAUGE_X 123 //139
  329. #define SB_SHIELD_GAUGE_Y 163
  330. #define SB_SHIP_GAUGE_X (SB_SHIELD_GAUGE_X+5)
  331. #define SB_SHIP_GAUGE_Y (SB_SHIELD_GAUGE_Y+5)
  332. #define SB_SHIELD_NUM_X (SB_SHIELD_GAUGE_X+12) //151
  333. #define SB_SHIELD_NUM_Y 156
  334. #define NUMERICAL_GAUGE_X 154
  335. #define NUMERICAL_GAUGE_Y 130
  336. #define NUMERICAL_GAUGE_W 19
  337. #define NUMERICAL_GAUGE_H 22
  338. #define PRIMARY_W_PIC_X 64
  339. #define PRIMARY_W_PIC_Y 154
  340. #define PRIMARY_W_TEXT_X 87
  341. #define PRIMARY_W_TEXT_Y 157
  342. #define PRIMARY_AMMO_X (96-3)
  343. #define PRIMARY_AMMO_Y 171
  344. #define SECONDARY_W_PIC_X 234
  345. #define SECONDARY_W_PIC_Y 154
  346. #define SECONDARY_W_TEXT_X 207
  347. #define SECONDARY_W_TEXT_Y 157
  348. #define SECONDARY_AMMO_X 213
  349. #define SECONDARY_AMMO_Y 171
  350. #define SB_LIVES_X 266
  351. #define SB_LIVES_Y 185
  352. #define SB_LIVES_LABEL_X 237
  353. #define SB_LIVES_LABEL_Y (SB_LIVES_Y+1)
  354. #define SB_SCORE_RIGHT 301
  355. #define SB_SCORE_Y 158
  356. #define SB_SCORE_LABEL_X 237
  357. #define SB_SCORE_ADDED_RIGHT 301
  358. #define SB_SCORE_ADDED_Y 165
  359. static int score_display;
  360. static fix score_time;
  361. static int old_score = -1;
  362. static int old_energy = -1;
  363. static int old_shields = -1;
  364. static int old_laser = -1;
  365. static int old_flags = -1;
  366. static int invulnerable_frame = 0;
  367. static int old_weapon[2] = {-1,-1};
  368. static int old_ammo_count[2] = {-1,-1};
  369. static int old_cloak = 0;
  370. static int old_lives = -1;
  371. static int cloak_fade_state; //0=steady, -1 fading out, 1 fading in
  372. #define WS_SET 0 //in correct state
  373. #define WS_FADING_OUT 1
  374. #define WS_FADING_IN 2
  375. int weapon_box_states[2];
  376. fix weapon_box_fade_values[2];
  377. #define FADE_SCALE (2*i2f(GR_FADE_LEVELS)/REARM_TIME) // fade out and back in REARM_TIME, in fade levels per seconds (int)
  378. typedef struct span {
  379. byte l,r;
  380. } span;
  381. //store delta x values from left of box
  382. span weapon_window_left[] = { //first span 67,154
  383. {4,53},
  384. {4,53},
  385. {4,53},
  386. {4,53},
  387. {4,53},
  388. {3,53},
  389. {3,53},
  390. {3,53},
  391. {3,53},
  392. {3,53},
  393. {3,53},
  394. {3,53},
  395. {3,53},
  396. {2,53},
  397. {2,53},
  398. {2,53},
  399. {2,53},
  400. {2,53},
  401. {2,53},
  402. {2,53},
  403. {2,53},
  404. {1,53},
  405. {1,53},
  406. {1,53},
  407. {1,53},
  408. {1,53},
  409. {1,53},
  410. {1,53},
  411. {1,53},
  412. {0,53},
  413. {0,53},
  414. {0,53},
  415. {0,53},
  416. {0,52},
  417. {1,52},
  418. {2,51},
  419. {3,51},
  420. {4,50},
  421. {5,50},
  422. };
  423. //store delta x values from left of box
  424. span weapon_window_right[] = { //first span 207,154
  425. {208-202,255-202},
  426. {206-202,257-202},
  427. {205-202,258-202},
  428. {204-202,259-202},
  429. {203-202,260-202},
  430. {203-202,260-202},
  431. {203-202,260-202},
  432. {203-202,260-202},
  433. {203-202,260-202},
  434. {203-202,261-202},
  435. {203-202,261-202},
  436. {203-202,261-202},
  437. {203-202,261-202},
  438. {203-202,261-202},
  439. {203-202,261-202},
  440. {203-202,261-202},
  441. {203-202,261-202},
  442. {203-202,261-202},
  443. {203-202,262-202},
  444. {203-202,262-202},
  445. {203-202,262-202},
  446. {203-202,262-202},
  447. {203-202,262-202},
  448. {203-202,262-202},
  449. {203-202,262-202},
  450. {203-202,262-202},
  451. {204-202,263-202},
  452. {204-202,263-202},
  453. {204-202,263-202},
  454. {204-202,263-202},
  455. {204-202,263-202},
  456. {204-202,263-202},
  457. {204-202,263-202},
  458. {204-202,263-202},
  459. {204-202,263-202},
  460. {204-202,263-202},
  461. {204-202,263-202},
  462. {204-202,263-202},
  463. {205-202,263-202},
  464. {206-202,262-202},
  465. {207-202,261-202},
  466. {208-202,260-202},
  467. {211-202,255-202},
  468. };
  469. #define N_LEFT_WINDOW_SPANS (sizeof(weapon_window_left)/sizeof(*weapon_window_left))
  470. #define N_RIGHT_WINDOW_SPANS (sizeof(weapon_window_right)/sizeof(*weapon_window_right))
  471. #define PRIMARY_W_BOX_LEFT 63
  472. #define PRIMARY_W_BOX_TOP 154
  473. #define PRIMARY_W_BOX_RIGHT (PRIMARY_W_BOX_LEFT+58)
  474. #define PRIMARY_W_BOX_BOT (PRIMARY_W_BOX_TOP+N_LEFT_WINDOW_SPANS-1)
  475. #define SECONDARY_W_BOX_LEFT 202 //207
  476. #define SECONDARY_W_BOX_TOP 151
  477. #define SECONDARY_W_BOX_RIGHT 263 //(SECONDARY_W_BOX_LEFT+54)
  478. #define SECONDARY_W_BOX_BOT (SECONDARY_W_BOX_TOP+N_RIGHT_WINDOW_SPANS-1)
  479. #define SB_PRIMARY_W_BOX_LEFT 34 //50
  480. #define SB_PRIMARY_W_BOX_TOP 153
  481. #define SB_PRIMARY_W_BOX_RIGHT (SB_PRIMARY_W_BOX_LEFT+53)
  482. #define SB_PRIMARY_W_BOX_BOT (195)
  483. #define SB_SECONDARY_W_BOX_LEFT 169 //210
  484. #define SB_SECONDARY_W_BOX_TOP 153
  485. #define SB_SECONDARY_W_BOX_RIGHT (SB_SECONDARY_W_BOX_LEFT+54)
  486. #define SB_SECONDARY_W_BOX_BOT (153+43)
  487. #define SB_PRIMARY_W_PIC_X (SB_PRIMARY_W_BOX_LEFT+1) //51
  488. #define SB_PRIMARY_W_PIC_Y 154
  489. #define SB_PRIMARY_W_TEXT_X (SB_PRIMARY_W_BOX_LEFT+24) //(51+23)
  490. #define SB_PRIMARY_W_TEXT_Y 157
  491. #define SB_PRIMARY_AMMO_X ((SB_PRIMARY_W_BOX_LEFT+33)-3) //(51+32)
  492. #define SB_PRIMARY_AMMO_Y 171
  493. #define SB_SECONDARY_W_PIC_X (SB_SECONDARY_W_BOX_LEFT+29) //(212+27)
  494. #define SB_SECONDARY_W_PIC_Y 154
  495. #define SB_SECONDARY_W_TEXT_X (SB_SECONDARY_W_BOX_LEFT+2) //212
  496. #define SB_SECONDARY_W_TEXT_Y 157
  497. #define SB_SECONDARY_AMMO_X (SB_SECONDARY_W_BOX_LEFT+11) //(212+9)
  498. #define SB_SECONDARY_AMMO_Y 171
  499. typedef struct gauge_box {
  500. int left,top;
  501. int right,bot; //maximal box
  502. span *spanlist; //list of left,right spans for copy
  503. } gauge_box;
  504. //first two are primary & secondary
  505. //seconds two are the same for the status bar
  506. gauge_box gauge_boxes[] = {
  507. {PRIMARY_W_BOX_LEFT,PRIMARY_W_BOX_TOP,PRIMARY_W_BOX_RIGHT,PRIMARY_W_BOX_BOT,weapon_window_left},
  508. {SECONDARY_W_BOX_LEFT,SECONDARY_W_BOX_TOP,SECONDARY_W_BOX_RIGHT,SECONDARY_W_BOX_BOT,weapon_window_right},
  509. {SB_PRIMARY_W_BOX_LEFT,SB_PRIMARY_W_BOX_TOP,SB_PRIMARY_W_BOX_RIGHT,SB_PRIMARY_W_BOX_BOT,NULL},
  510. {SB_SECONDARY_W_BOX_LEFT,SB_SECONDARY_W_BOX_TOP,SB_SECONDARY_W_BOX_RIGHT,SB_SECONDARY_W_BOX_BOT,NULL}
  511. };
  512. int Color_0_31_0 = -1;
  513. //copy a box from the off-screen buffer to the visible page
  514. copy_gauge_box(gauge_box *box,grs_bitmap *bm)
  515. {
  516. if (box->spanlist) {
  517. int n_spans = box->bot-box->top+1;
  518. int cnt,y;
  519. //gr_setcolor(BM_XRGB(31,0,0));
  520. for (cnt=0,y=box->top;cnt<n_spans;cnt++,y++)
  521. gr_bm_ubitblt(box->spanlist[cnt].r-box->spanlist[cnt].l+1,1,
  522. box->left+box->spanlist[cnt].l,y,box->left+box->spanlist[cnt].l,y,bm,&grd_curcanv->cv_bitmap);
  523. //gr_scanline(box->left+box->spanlist[cnt].l,box->left+box->spanlist[cnt].r,y);
  524. }
  525. else
  526. gr_bm_ubitblt(box->right-box->left+1,box->bot-box->top+1,
  527. box->left,box->top,box->left,box->top,
  528. bm,&grd_curcanv->cv_bitmap);
  529. }
  530. //fills in the coords of the hostage video window
  531. get_hostage_window_coords(int *x,int *y,int *w,int *h)
  532. {
  533. if (Cockpit_mode == CM_STATUS_BAR) {
  534. *x = SB_SECONDARY_W_BOX_LEFT;
  535. *y = SB_SECONDARY_W_BOX_TOP;
  536. *w = SB_SECONDARY_W_BOX_RIGHT - SB_SECONDARY_W_BOX_LEFT + 1;
  537. *h = SB_SECONDARY_W_BOX_BOT - SB_SECONDARY_W_BOX_TOP + 1;
  538. }
  539. else {
  540. *x = SECONDARY_W_BOX_LEFT;
  541. *y = SECONDARY_W_BOX_TOP;
  542. *w = SECONDARY_W_BOX_RIGHT - SECONDARY_W_BOX_LEFT + 1;
  543. *h = SECONDARY_W_BOX_BOT - SECONDARY_W_BOX_TOP + 1;
  544. }
  545. }
  546. //these should be in gr.h
  547. #define cv_w cv_bitmap.bm_w
  548. #define cv_h cv_bitmap.bm_h
  549. #define HUD_MESSAGE_LENGTH 150
  550. #define HUD_MAX_NUM 4
  551. extern int HUD_nmessages, hud_first; // From hud.c
  552. extern char HUD_messages[HUD_MAX_NUM][HUD_MESSAGE_LENGTH+5];
  553. void hud_show_score()
  554. {
  555. char score_str[20];
  556. int w, h, aw;
  557. if ((HUD_nmessages > 0) && (strlen(HUD_messages[hud_first]) > 38))
  558. return;
  559. gr_set_curfont( GAME_FONT );
  560. if ( ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) ) {
  561. sprintf(score_str, "%s: %5d", TXT_KILLS, Players[Player_num].net_kills_total);
  562. } else {
  563. sprintf(score_str, "%s: %5d", TXT_SCORE, Players[Player_num].score);
  564. }
  565. gr_get_string_size(score_str, &w, &h, &aw );
  566. if (Color_0_31_0 == -1)
  567. Color_0_31_0 = gr_getcolor(0,31,0);
  568. gr_set_fontcolor(Color_0_31_0, -1);
  569. gr_printf(grd_curcanv->cv_w-w-2, 3, score_str);
  570. }
  571. void hud_show_score_added()
  572. {
  573. int color;
  574. int w, h, aw;
  575. char score_str[20];
  576. if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
  577. return;
  578. if (score_display == 0)
  579. return;
  580. gr_set_curfont( GAME_FONT );
  581. score_time -= FrameTime;
  582. if (score_time > 0) {
  583. color = f2i(score_time * 20) + 10;
  584. if (color < 10) color = 10;
  585. if (color > 31) color = 31;
  586. if (Cheats_enabled)
  587. sprintf(score_str, "%s", TXT_CHEATER);
  588. else
  589. sprintf(score_str, "%5d", score_display);
  590. gr_get_string_size(score_str, &w, &h, &aw );
  591. gr_set_fontcolor(gr_getcolor(0, color, 0),-1 );
  592. gr_printf(grd_curcanv->cv_w-w-2-10, GAME_FONT->ft_h+5, score_str);
  593. } else {
  594. score_time = 0;
  595. score_display = 0;
  596. }
  597. }
  598. void sb_show_score()
  599. {
  600. char score_str[20];
  601. int x,y;
  602. int w, h, aw;
  603. static int last_x=SB_SCORE_RIGHT;
  604. int redraw_score;
  605. if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
  606. redraw_score = -99;
  607. else
  608. redraw_score = -1;
  609. if (old_score==redraw_score) {
  610. gr_set_curfont( GAME_FONT );
  611. gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
  612. if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
  613. gr_printf(SB_SCORE_LABEL_X,SB_SCORE_Y,"%s:", TXT_KILLS);
  614. else
  615. gr_printf(SB_SCORE_LABEL_X,SB_SCORE_Y,"%s:", TXT_SCORE);
  616. }
  617. gr_set_curfont( GAME_FONT );
  618. if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
  619. sprintf(score_str, "%5d", Players[Player_num].net_kills_total);
  620. else
  621. sprintf(score_str, "%5d", Players[Player_num].score);
  622. gr_get_string_size(score_str, &w, &h, &aw );
  623. x = SB_SCORE_RIGHT-w-2;
  624. y = SB_SCORE_Y;
  625. //erase old score
  626. gr_setcolor(BM_XRGB(0,0,0));
  627. gr_rect(last_x,y,SB_SCORE_RIGHT,y+GAME_FONT->ft_h);
  628. if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
  629. gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
  630. else
  631. gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
  632. gr_printf(x,y,score_str);
  633. last_x = x;
  634. }
  635. void sb_show_score_added()
  636. {
  637. int color;
  638. int w, h, aw;
  639. char score_str[32];
  640. int x;
  641. static int last_x=SB_SCORE_ADDED_RIGHT;
  642. static int last_score_display = -1;
  643. if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
  644. return;
  645. if (score_display == 0)
  646. return;
  647. gr_set_curfont( GAME_FONT );
  648. score_time -= FrameTime;
  649. if (score_time > 0) {
  650. if (score_display != last_score_display) {
  651. gr_setcolor(BM_XRGB(0,0,0));
  652. gr_rect(last_x,SB_SCORE_ADDED_Y,SB_SCORE_ADDED_RIGHT,SB_SCORE_ADDED_Y+GAME_FONT->ft_h);
  653. last_score_display = score_display;
  654. }
  655. color = f2i(score_time * 20) + 10;
  656. if (color < 10) color = 10;
  657. if (color > 31) color = 31;
  658. if (Cheats_enabled)
  659. sprintf(score_str, "%s", TXT_CHEATER);
  660. else
  661. sprintf(score_str, "%5d", score_display);
  662. gr_get_string_size(score_str, &w, &h, &aw );
  663. x = SB_SCORE_ADDED_RIGHT-w-2;
  664. gr_set_fontcolor(gr_getcolor(0, color, 0),-1 );
  665. gr_printf(x, SB_SCORE_ADDED_Y, score_str);
  666. last_x = x;
  667. } else {
  668. //erase old score
  669. gr_setcolor(BM_XRGB(0,0,0));
  670. gr_rect(last_x,SB_SCORE_ADDED_Y,SB_SCORE_ADDED_RIGHT,SB_SCORE_ADDED_Y+GAME_FONT->ft_h);
  671. score_time = 0;
  672. score_display = 0;
  673. }
  674. }
  675. fix Last_warning_beep_time = 0; // Time we last played homing missile warning beep.
  676. // -----------------------------------------------------------------------------
  677. void play_homing_warning(void)
  678. {
  679. fix beep_delay;
  680. if (Endlevel_sequence || Player_is_dead)
  681. return;
  682. if (Players[Player_num].homing_object_dist >= 0) {
  683. beep_delay = Players[Player_num].homing_object_dist/128;
  684. if (beep_delay > F1_0)
  685. beep_delay = F1_0;
  686. else if (beep_delay < F1_0/8)
  687. beep_delay = F1_0/8;
  688. if (GameTime - Last_warning_beep_time > beep_delay/2) {
  689. digi_play_sample( SOUND_HOMING_WARNING, F1_0 );
  690. Last_warning_beep_time = GameTime;
  691. }
  692. }
  693. }
  694. int Last_homing_warning_shown=-1;
  695. // -----------------------------------------------------------------------------
  696. void show_homing_warning(void)
  697. {
  698. if ((Cockpit_mode == CM_STATUS_BAR) || (Endlevel_sequence)) {
  699. if (Last_homing_warning_shown == 1) {
  700. PIGGY_PAGE_IN( Gauges[GAUGE_HOMING_WARNING_OFF] );
  701. gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index] );
  702. Last_homing_warning_shown = 0;
  703. }
  704. return;
  705. }
  706. gr_set_current_canvas( get_current_game_screen() );
  707. if (Players[Player_num].homing_object_dist >= 0) {
  708. if (GameTime & 0x4000) {
  709. if (Last_homing_warning_shown != 1) {
  710. PIGGY_PAGE_IN(Gauges[GAUGE_HOMING_WARNING_ON]);
  711. gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_ON].index]);
  712. Last_homing_warning_shown = 1;
  713. }
  714. } else {
  715. if (Last_homing_warning_shown != 0) {
  716. PIGGY_PAGE_IN(Gauges[GAUGE_HOMING_WARNING_OFF]);
  717. gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index] );
  718. Last_homing_warning_shown = 0;
  719. }
  720. }
  721. } else if (Last_homing_warning_shown != 0) {
  722. PIGGY_PAGE_IN(Gauges[GAUGE_HOMING_WARNING_OFF]);
  723. gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index] );
  724. Last_homing_warning_shown = 0;
  725. }
  726. }
  727. #define MAX_SHOWN_LIVES 4
  728. void hud_show_homing_warning(void)
  729. {
  730. if (Players[Player_num].homing_object_dist >= 0) {
  731. if (GameTime & 0x4000) {
  732. gr_set_current_canvas(&VR_render_sub_buffer[0]); //render off-screen
  733. gr_set_curfont( GAME_FONT );
  734. gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
  735. gr_printf(0x8000, grd_curcanv->cv_h-8,TXT_LOCK);
  736. }
  737. }
  738. }
  739. void hud_show_keys(void)
  740. {
  741. if (Players[Player_num].flags & PLAYER_FLAGS_BLUE_KEY) {
  742. PIGGY_PAGE_IN(Gauges[KEY_ICON_BLUE]);
  743. gr_ubitmapm(2,24,&GameBitmaps[Gauges[KEY_ICON_BLUE].index]);
  744. }
  745. if (Players[Player_num].flags & PLAYER_FLAGS_GOLD_KEY) {
  746. PIGGY_PAGE_IN(Gauges[KEY_ICON_YELLOW]);
  747. gr_ubitmapm(10,24,&GameBitmaps[Gauges[KEY_ICON_YELLOW].index]);
  748. }
  749. if (Players[Player_num].flags & PLAYER_FLAGS_RED_KEY) {
  750. PIGGY_PAGE_IN(Gauges[KEY_ICON_RED]);
  751. gr_ubitmapm(18,24,&GameBitmaps[Gauges[KEY_ICON_RED].index]);
  752. }
  753. }
  754. void hud_show_energy(void)
  755. {
  756. gr_set_current_canvas(&VR_render_sub_buffer[0]); //render off-screen
  757. gr_set_curfont( GAME_FONT );
  758. gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
  759. if (Game_mode & GM_MULTI)
  760. gr_printf(2, grd_curcanv->cv_h-40,"%s: %i", TXT_ENERGY, f2ir(Players[Player_num].energy));
  761. else
  762. gr_printf(2, grd_curcanv->cv_h-8,"%s: %i", TXT_ENERGY, f2ir(Players[Player_num].energy));
  763. if (Newdemo_state==ND_STATE_RECORDING ) {
  764. int energy = f2ir(Players[Player_num].energy);
  765. if (energy != old_energy) {
  766. #ifdef SHAREWARE
  767. newdemo_record_player_energy(energy);
  768. #else
  769. newdemo_record_player_energy(old_energy, energy);
  770. #endif
  771. old_energy = energy;
  772. }
  773. }
  774. }
  775. void hud_show_weapons(void)
  776. {
  777. int w, h, aw;
  778. int y;
  779. char weapon_str[32], temp_str[10];
  780. gr_set_current_canvas(&VR_render_sub_buffer[0]); //render off-screen
  781. gr_set_curfont( GAME_FONT );
  782. gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
  783. if (Game_mode & GM_MULTI)
  784. y = grd_curcanv->cv_h-32;
  785. else
  786. y = grd_curcanv->cv_h;
  787. // #ifndef RELEASE
  788. y -= 8;
  789. // #endif
  790. switch (Primary_weapon) {
  791. case 0:
  792. if (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS)
  793. sprintf(weapon_str, "%s %s %i", TXT_QUAD, TXT_LASER, Players[Player_num].laser_level+1);
  794. else
  795. sprintf(weapon_str, "%s %i", TXT_LASER, Players[Player_num].laser_level+1);
  796. break;
  797. case 1:
  798. sprintf(weapon_str, "%s: %i", TXT_W_VULCAN_S, f2i(Players[Player_num].primary_ammo[Primary_weapon] * VULCAN_AMMO_SCALE));
  799. break;
  800. case 2:
  801. strcpy(weapon_str, TXT_W_SPREADFIRE_S);
  802. break;
  803. #ifndef SHAREWARE
  804. case 3:
  805. strcpy(weapon_str, TXT_W_PLASMA_S);
  806. break;
  807. case 4:
  808. strcpy(weapon_str, TXT_W_FUSION_S);
  809. break;
  810. #endif
  811. }
  812. gr_get_string_size(weapon_str, &w, &h, &aw );
  813. gr_printf(315-w, y-8, weapon_str);
  814. if (Primary_weapon == VULCAN_INDEX) {
  815. #ifndef SHAREWARE
  816. if (Players[Player_num].primary_ammo[Primary_weapon] != old_ammo_count[0]) {
  817. if (Newdemo_state == ND_STATE_RECORDING)
  818. newdemo_record_primary_ammo(old_ammo_count[0], Players[Player_num].primary_ammo[Primary_weapon]);
  819. old_ammo_count[0] = Players[Player_num].primary_ammo[Primary_weapon];
  820. }
  821. #endif
  822. }
  823. switch (Secondary_weapon) {
  824. case 0: strcpy(weapon_str, TXT_CONCUSSION); break;
  825. case 1: strcpy(weapon_str, TXT_HOMING); break;
  826. case 2: strcpy(weapon_str, TXT_PROXBOMB ); break;
  827. #ifndef SHAREWARE
  828. case 3: strcpy(weapon_str, TXT_SMART); break;
  829. case 4: strcpy(weapon_str, TXT_MEGA); break;
  830. #endif
  831. default: Int3(); weapon_str[0] = 0; break;
  832. }
  833. #ifndef SHAREWARE
  834. if (Players[Player_num].secondary_ammo[Secondary_weapon] != old_ammo_count[1]) {
  835. if (Newdemo_state == ND_STATE_RECORDING)
  836. newdemo_record_secondary_ammo(old_ammo_count[1], Players[Player_num].secondary_ammo[Secondary_weapon]);
  837. old_ammo_count[1] = Players[Player_num].secondary_ammo[Secondary_weapon];
  838. }
  839. #endif
  840. strcat(weapon_str, " ");
  841. strcat(weapon_str, itoa(Players[Player_num].secondary_ammo[Secondary_weapon], temp_str, 10));
  842. gr_get_string_size(weapon_str, &w, &h, &aw );
  843. gr_printf(315-w, y, weapon_str);
  844. }
  845. void hud_show_cloak_invuln(void)
  846. {
  847. if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
  848. int y = grd_curcanv->cv_h;
  849. if (Game_mode & GM_MULTI)
  850. y -= 72;
  851. else
  852. y -= 32;
  853. if ((Players[Player_num].cloak_time+CLOAK_TIME_MAX - GameTime > F1_0*3 ) || (GameTime & 0x8000))
  854. gr_printf(2, y, "%s", TXT_CLOAKED);
  855. }
  856. if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
  857. int y = grd_curcanv->cv_h;
  858. if (Game_mode & GM_MULTI)
  859. y -= 80;
  860. else
  861. y -= 40;
  862. if (((Players[Player_num].invulnerable_time + INVULNERABLE_TIME_MAX - GameTime) > F1_0*4) || (GameTime & 0x8000))
  863. gr_printf(2, y, "%s", TXT_INVULNERABLE);
  864. }
  865. }
  866. void hud_show_shield(void)
  867. {
  868. gr_set_current_canvas(&VR_render_sub_buffer[0]); //render off-screen
  869. gr_set_curfont( GAME_FONT );
  870. gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
  871. if (Game_mode & GM_MULTI)
  872. gr_printf(2, grd_curcanv->cv_h-48,"%s: %i", TXT_SHIELD, f2ir(Players[Player_num].shields));
  873. else
  874. gr_printf(2, grd_curcanv->cv_h-16,"%s: %i", TXT_SHIELD, f2ir(Players[Player_num].shields));
  875. if (Newdemo_state==ND_STATE_RECORDING ) {
  876. int shields = f2ir(Players[Player_num].shields);
  877. if (shields != old_shields) { // Draw the shield gauge
  878. #ifdef SHAREWARE
  879. newdemo_record_player_shields(shields);
  880. #else
  881. newdemo_record_player_shields(old_shields, shields);
  882. #endif
  883. old_shields = shields;
  884. }
  885. }
  886. }
  887. //draw the icons for number of lives
  888. hud_show_lives()
  889. {
  890. if ((HUD_nmessages > 0) && (strlen(HUD_messages[hud_first]) > 38))
  891. return;
  892. if (Game_mode & GM_MULTI) {
  893. gr_set_curfont( GAME_FONT );
  894. gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
  895. gr_printf(10, 3, "%s: %d", TXT_DEATHS, Players[Player_num].net_killed_total);
  896. }
  897. else if (Players[Player_num].lives > 1) {
  898. gr_set_curfont( GAME_FONT );
  899. gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
  900. PIGGY_PAGE_IN(Gauges[GAUGE_LIVES]);
  901. gr_ubitmapm(10,3,&GameBitmaps[Gauges[GAUGE_LIVES].index]);
  902. gr_printf(22, 3, "x %d", Players[Player_num].lives-1);
  903. }
  904. }
  905. sb_show_lives()
  906. {
  907. int x,y;
  908. grs_bitmap * bm = &GameBitmaps[Gauges[GAUGE_LIVES].index];
  909. x = SB_LIVES_X;
  910. y = SB_LIVES_Y;
  911. if (old_lives==-1) {
  912. gr_set_curfont( GAME_FONT );
  913. gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
  914. if (Game_mode & GM_MULTI)
  915. gr_printf(SB_LIVES_LABEL_X,SB_LIVES_LABEL_Y,"%s:", TXT_DEATHS);
  916. else
  917. gr_printf(SB_LIVES_LABEL_X,SB_LIVES_LABEL_Y,"%s:", TXT_LIVES);
  918. }
  919. if (Game_mode & GM_MULTI)
  920. {
  921. char killed_str[20];
  922. int w, h, aw;
  923. static int last_x = SB_SCORE_RIGHT;
  924. int x;
  925. sprintf(killed_str, "%5d", Players[Player_num].net_killed_total);
  926. gr_get_string_size(killed_str, &w, &h, &aw);
  927. gr_setcolor(BM_XRGB(0,0,0));
  928. gr_rect(last_x, y+1, SB_SCORE_RIGHT, y+GAME_FONT->ft_h);
  929. gr_set_fontcolor(gr_getcolor(0,20,0),-1);
  930. x = SB_SCORE_RIGHT-w-2;
  931. gr_printf(x, y+1, killed_str);
  932. last_x = x;
  933. return;
  934. }
  935. if (old_lives==-1 || Players[Player_num].lives != old_lives) {
  936. //erase old icons
  937. gr_setcolor(BM_XRGB(0,0,0));
  938. gr_rect(x, y, x+32, y+bm->bm_h);
  939. if (Players[Player_num].lives-1 > 0) {
  940. gr_set_curfont( GAME_FONT );
  941. gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
  942. PIGGY_PAGE_IN(Gauges[GAUGE_LIVES]);
  943. gr_ubitmapm(x, y,bm);
  944. gr_printf(x+12, y, "x %d", Players[Player_num].lives-1);
  945. }
  946. }
  947. // for (i=0;i<draw_count;i++,x+=bm->bm_w+2)
  948. // gr_ubitmapm(x,y,bm);
  949. }
  950. #ifndef RELEASE
  951. #ifdef PIGGY_USE_PAGING
  952. extern int Piggy_bitmap_cache_next;
  953. #endif
  954. void show_time()
  955. {
  956. int secs = f2i(Players[Player_num].time_level) % 60;
  957. int mins = f2i(Players[Player_num].time_level) / 60;
  958. gr_set_curfont( GAME_FONT );
  959. if (Color_0_31_0 == -1)
  960. Color_0_31_0 = gr_getcolor(0,31,0);
  961. gr_set_fontcolor(Color_0_31_0, -1 );
  962. gr_printf(grd_curcanv->cv_w-25,grd_curcanv->cv_h-28,"%d:%02d", mins, secs);
  963. #ifdef PIGGY_USE_PAGING
  964. {
  965. char text[25];
  966. int w,h,aw;
  967. sprintf( text, "%d KB", Piggy_bitmap_cache_next/1024 );
  968. gr_get_string_size( text, &w, &h, &aw );
  969. gr_printf(grd_curcanv->cv_w-10-w,grd_curcanv->cv_h/2, text );
  970. }
  971. #endif
  972. }
  973. #endif
  974. #define EXTRA_SHIP_SCORE 50000 //get new ship every this many points
  975. void add_points_to_score(int points)
  976. {
  977. int prev_score;
  978. score_time += f1_0*2;
  979. score_display += points;
  980. if (score_time > f1_0*4) score_time = f1_0*4;
  981. if (points == 0 || Cheats_enabled)
  982. return;
  983. if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))
  984. return;
  985. prev_score=Players[Player_num].score;
  986. Players[Player_num].score += points;
  987. #ifndef SHAREWARE
  988. if (Newdemo_state == ND_STATE_RECORDING)
  989. newdemo_record_player_score(points);
  990. #endif
  991. #ifndef SHAREWARE
  992. if (Game_mode & GM_MULTI_COOP)
  993. multi_send_score();
  994. #endif
  995. if (Game_mode & GM_MULTI)
  996. return;
  997. if (Players[Player_num].score/EXTRA_SHIP_SCORE != prev_score/EXTRA_SHIP_SCORE) {
  998. int snd;
  999. Players[Player_num].lives += Players[Player_num].score/EXTRA_SHIP_SCORE - prev_score/EXTRA_SHIP_SCORE;
  1000. powerup_basic(20, 20, 20, 0, TXT_EXTRA_LIFE);
  1001. if ((snd=Powerup_info[POW_EXTRA_LIFE].hit_sound) > -1 )
  1002. digi_play_sample( snd, F1_0 );
  1003. }
  1004. }
  1005. void add_bonus_points_to_score(int points)
  1006. {
  1007. int prev_score;
  1008. if (points == 0 || Cheats_enabled)
  1009. return;
  1010. prev_score=Players[Player_num].score;
  1011. Players[Player_num].score += points;
  1012. #ifndef SHAREWARE
  1013. if (Newdemo_state == ND_STATE_RECORDING)
  1014. newdemo_record_player_score(points);
  1015. #endif
  1016. if (Game_mode & GM_MULTI)
  1017. return;
  1018. if (Players[Player_num].score/EXTRA_SHIP_SCORE != prev_score/EXTRA_SHIP_SCORE) {
  1019. int snd;
  1020. Players[Player_num].lives += Players[Player_num].score/EXTRA_SHIP_SCORE - prev_score/EXTRA_SHIP_SCORE;
  1021. if ((snd=Powerup_info[POW_EXTRA_LIFE].hit_sound) > -1 )
  1022. digi_play_sample( snd, F1_0 );
  1023. }
  1024. }
  1025. void init_gauge_canvases()
  1026. {
  1027. Canv_LeftEnergyGauge = gr_create_canvas( LEFT_ENERGY_GAUGE_W, LEFT_ENERGY_GAUGE_H );
  1028. Canv_SBEnergyGauge = gr_create_canvas( SB_ENERGY_GAUGE_W, SB_ENERGY_GAUGE_H );
  1029. Canv_RightEnergyGauge = gr_create_canvas( RIGHT_ENERGY_GAUGE_W, RIGHT_ENERGY_GAUGE_H );
  1030. Canv_NumericalGauge = gr_create_canvas( NUMERICAL_GAUGE_W, NUMERICAL_GAUGE_H );
  1031. }
  1032. void close_gauge_canvases()
  1033. {
  1034. gr_free_canvas( Canv_LeftEnergyGauge );
  1035. gr_free_canvas( Canv_SBEnergyGauge );
  1036. gr_free_canvas( Canv_RightEnergyGauge );
  1037. gr_free_canvas( Canv_NumericalGauge );
  1038. }
  1039. void init_gauges()
  1040. {
  1041. //draw_gauges_on = 1;
  1042. if ( ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) || ((Newdemo_state == ND_STATE_PLAYBACK) && (Newdemo_game_mode & GM_MULTI) && !(Newdemo_game_mode & GM_MULTI_COOP)) )
  1043. old_score = -99;
  1044. else
  1045. old_score = -1;
  1046. old_energy = -1;
  1047. old_shields = -1;
  1048. old_laser = -1;
  1049. old_flags = -1;
  1050. old_cloak = -1;
  1051. old_lives = -1;
  1052. old_weapon[0] = old_weapon[1]= -1;
  1053. old_ammo_count[0] = old_ammo_count[1] = -1;
  1054. cloak_fade_state = 0;
  1055. }
  1056. void draw_energy_bar(int energy)
  1057. {
  1058. int not_energy;
  1059. int x1, x2, y;
  1060. // Draw left energy bar
  1061. gr_set_current_canvas( Canv_LeftEnergyGauge );
  1062. PIGGY_PAGE_IN(Gauges[GAUGE_ENERGY_LEFT]);
  1063. gr_ubitmapm( 0, 0, &GameBitmaps[Gauges[GAUGE_ENERGY_LEFT].index] );
  1064. gr_setcolor( 0 );
  1065. not_energy = 61 - (energy*61)/100;
  1066. if (energy < 100)
  1067. for (y=0; y<8; y++) {
  1068. x1 = 7 - y;
  1069. x2 = 7 - y + not_energy;
  1070. if ( y>=0 && y<2 ) if (x2 > LEFT_ENERGY_GAUGE_W - 1) x2 = LEFT_ENERGY_GAUGE_W - 1;
  1071. if ( y>=2 && y<6 ) if (x2 > LEFT_ENERGY_GAUGE_W - 2) x2 = LEFT_ENERGY_GAUGE_W - 2;
  1072. if ( y>=6 ) if (x2 > LEFT_ENERGY_GAUGE_W - 3) x2 = LEFT_ENERGY_GAUGE_W - 3;
  1073. if (x2 > x1) gr_uscanline( x1, x2, y );
  1074. }
  1075. gr_set_current_canvas( get_current_game_screen() );
  1076. gr_ubitmapm( LEFT_ENERGY_GAUGE_X, LEFT_ENERGY_GAUGE_Y, &Canv_LeftEnergyGauge->cv_bitmap );
  1077. // Draw right energy bar
  1078. gr_set_current_canvas( Canv_RightEnergyGauge );
  1079. PIGGY_PAGE_IN(Gauges[GAUGE_ENERGY_RIGHT]);
  1080. gr_ubitmapm( 0, 0, &GameBitmaps[Gauges[GAUGE_ENERGY_RIGHT].index] );
  1081. if (energy < 100)
  1082. for (y=0; y<8; y++) {
  1083. x1 = RIGHT_ENERGY_GAUGE_W - 8 + y - not_energy;
  1084. x2 = RIGHT_ENERGY_GAUGE_W - 8 + y;
  1085. if ( y>=0 && y<2 ) if (x1 < 0) x1 = 0;
  1086. if ( y>=2 && y<6 ) if (x1 < 1) x1 = 1;
  1087. if ( y>=6 ) if (x1 < 2) x1 = 2;
  1088. if (x2 > x1) gr_uscanline( x1, x2, y );
  1089. }
  1090. gr_set_current_canvas( get_current_game_screen() );
  1091. gr_ubitmapm( RIGHT_ENERGY_GAUGE_X, RIGHT_ENERGY_GAUGE_Y, &Canv_RightEnergyGauge->cv_bitmap );
  1092. }
  1093. void draw_shield_bar(int shield)
  1094. {
  1095. int bm_num = shield>=100?9:(shield / 10);
  1096. PIGGY_PAGE_IN(Gauges[GAUGE_SHIELDS+9-bm_num] );
  1097. gr_ubitmapm( SHIELD_GAUGE_X, SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_SHIELDS+9-bm_num].index] );
  1098. }
  1099. #define CLOAK_FADE_WAIT_TIME 0x400
  1100. void draw_player_ship(int cloak_state,int old_cloak_state,int x, int y)
  1101. {
  1102. static fix cloak_fade_timer=0;
  1103. static int cloak_fade_value=GR_FADE_LEVELS-1;
  1104. grs_bitmap *bm;
  1105. if (Game_mode & GM_TEAM) {
  1106. PIGGY_PAGE_IN(Gauges[GAUGE_SHIPS+get_team(Player_num)]);
  1107. bm = &GameBitmaps[Gauges[GAUGE_SHIPS+get_team(Player_num)].index];
  1108. } else {
  1109. PIGGY_PAGE_IN(Gauges[GAUGE_SHIPS+Player_num]);
  1110. bm = &GameBitmaps[Gauges[GAUGE_SHIPS+Player_num].index];
  1111. }
  1112. if (old_cloak_state==-1 && cloak_state)
  1113. cloak_fade_value=0;
  1114. if (!cloak_state) {
  1115. cloak_fade_value=GR_FADE_LEVELS-1;
  1116. cloak_fade_state = 0;
  1117. }
  1118. if (cloak_state==1 && old_cloak_state==0)
  1119. cloak_fade_state = -1;
  1120. //else if (cloak_state==0 && old_cloak_state==1)
  1121. // cloak_fade_state = 1;
  1122. if (cloak_state==old_cloak_state) //doing "about-to-uncloak" effect
  1123. if (cloak_fade_state==0)
  1124. cloak_fade_state = 2;
  1125. if (cloak_fade_state)
  1126. cloak_fade_timer -= FrameTime;
  1127. while (cloak_fade_state && cloak_fade_timer < 0) {
  1128. cloak_fade_timer += CLOAK_FADE_WAIT_TIME;
  1129. cloak_fade_value += cloak_fade_state;
  1130. if (cloak_fade_value >= GR_FADE_LEVELS-1) {
  1131. cloak_fade_value = GR_FADE_LEVELS-1;
  1132. if (cloak_fade_state == 2 && cloak_state)
  1133. cloak_fade_state = -2;
  1134. else
  1135. cloak_fade_state = 0;
  1136. }
  1137. else if (cloak_fade_value <= 0) {
  1138. cloak_fade_value = 0;
  1139. if (cloak_fade_state == -2)
  1140. cloak_fade_state = 2;
  1141. else
  1142. cloak_fade_state = 0;
  1143. }
  1144. }
  1145. gr_set_current_canvas(&VR_render_buffer[0]);
  1146. gr_ubitmap( x, y, bm);
  1147. Gr_scanline_darkening_level = cloak_fade_value;
  1148. gr_rect(x, y, x+bm->bm_w-1, y+bm->bm_h-1);
  1149. Gr_scanline_darkening_level = GR_FADE_LEVELS;
  1150. gr_set_current_canvas(get_current_game_screen());
  1151. gr_bm_ubitbltm( bm->bm_w, bm->bm_h, x, y, x, y, &VR_render_sub_buffer[0].cv_bitmap, &grd_curcanv->cv_bitmap);
  1152. }
  1153. #define INV_FRAME_TIME (f1_0/10) //how long for each frame
  1154. void draw_numerical_display(int shield, int energy)
  1155. {
  1156. gr_set_current_canvas( Canv_NumericalGauge );
  1157. gr_set_curfont( GAME_FONT );
  1158. PIGGY_PAGE_IN(Gauges[GAUGE_NUMERICAL]);
  1159. gr_ubitmap( 0, 0, &GameBitmaps[Gauges[GAUGE_NUMERICAL].index] );
  1160. gr_set_fontcolor(gr_getcolor(14,14,23),-1 );
  1161. gr_printf((shield>99)?3:((shield>9)?5:7),15,"%d",shield);
  1162. gr_set_fontcolor(gr_getcolor(25,18,6),-1 );
  1163. gr_printf((energy>99)?3:((energy>9)?5:7),2,"%d",energy);
  1164. gr_set_current_canvas( get_current_game_screen() );
  1165. gr_ubitmapm( NUMERICAL_GAUGE_X, NUMERICAL_GAUGE_Y, &Canv_NumericalGauge->cv_bitmap );
  1166. }
  1167. void draw_keys()
  1168. {
  1169. gr_set_current_canvas( get_current_game_screen() );
  1170. if (Players[Player_num].flags & PLAYER_FLAGS_BLUE_KEY ) {
  1171. PIGGY_PAGE_IN(Gauges[GAUGE_BLUE_KEY]);
  1172. gr_ubitmapm( GAUGE_BLUE_KEY_X, GAUGE_BLUE_KEY_Y, &GameBitmaps[Gauges[GAUGE_BLUE_KEY].index] );
  1173. } else {
  1174. PIGGY_PAGE_IN(Gauges[GAUGE_BLUE_KEY_OFF]);
  1175. gr_ubitmapm( GAUGE_BLUE_KEY_X, GAUGE_BLUE_KEY_Y, &GameBitmaps[Gauges[GAUGE_BLUE_KEY_OFF].index] );
  1176. }
  1177. if (Players[Player_num].flags & PLAYER_FLAGS_GOLD_KEY) {
  1178. PIGGY_PAGE_IN(Gauges[GAUGE_GOLD_KEY]);
  1179. gr_ubitmapm( GAUGE_GOLD_KEY_X, GAUGE_GOLD_KEY_Y, &GameBitmaps[Gauges[GAUGE_GOLD_KEY].index] );
  1180. } else {
  1181. PIGGY_PAGE_IN(Gauges[GAUGE_GOLD_KEY_OFF]);
  1182. gr_ubitmapm( GAUGE_GOLD_KEY_X, GAUGE_GOLD_KEY_Y, &GameBitmaps[Gauges[GAUGE_GOLD_KEY_OFF].index] );
  1183. }
  1184. if (Players[Player_num].flags & PLAYER_FLAGS_RED_KEY) {
  1185. PIGGY_PAGE_IN( Gauges[GAUGE_RED_KEY] );
  1186. gr_ubitmapm( GAUGE_RED_KEY_X, GAUGE_RED_KEY_Y, &GameBitmaps[Gauges[GAUGE_RED_KEY].index] );
  1187. } else {
  1188. PIGGY_PAGE_IN(Gauges[GAUGE_RED_KEY_OFF]);
  1189. gr_ubitmapm( GAUGE_RED_KEY_X, GAUGE_RED_KEY_Y, &GameBitmaps[Gauges[GAUGE_RED_KEY_OFF].index] );
  1190. }
  1191. }
  1192. draw_weapon_info_sub(int info_index,gauge_box *box,int pic_x,int pic_y,char *name,int text_x,int text_y)
  1193. {
  1194. grs_bitmap *bm;
  1195. char *p;
  1196. //clear the window
  1197. gr_setcolor(BM_XRGB(0,0,0));
  1198. gr_rect(box->left,box->top,box->right,box->bot);
  1199. bm=&GameBitmaps[Weapon_info[info_index].picture.index];
  1200. Assert(bm != NULL);
  1201. PIGGY_PAGE_IN( Weapon_info[info_index].picture );
  1202. gr_ubitmapm(pic_x,pic_y,bm);
  1203. gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
  1204. if ((p=strchr(name,'\n'))!=NULL) {
  1205. *p=0;
  1206. gr_printf(text_x,text_y,name);
  1207. gr_printf(text_x,text_y+grd_curcanv->cv_font->ft_h+1,p+1);
  1208. *p='\n';
  1209. } else
  1210. gr_printf(text_x,text_y,name);
  1211. // For laser, show level and quadness
  1212. if (info_index == 0) {
  1213. char temp_str[7];
  1214. sprintf(temp_str, "%s: 0", TXT_LVL);
  1215. temp_str[5] = Players[Player_num].laser_level+1 + '0';
  1216. gr_printf(text_x,text_y+8, temp_str);
  1217. if (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS) {
  1218. strcpy(temp_str, TXT_QUAD);
  1219. gr_printf(text_x,text_y+16, temp_str);
  1220. }
  1221. }
  1222. }
  1223. draw_weapon_info(int weapon_type,int weapon_num)
  1224. {
  1225. #ifdef SHAREWARE
  1226. if (Newdemo_state==ND_STATE_RECORDING )
  1227. newdemo_record_player_weapon(weapon_type, weapon_num);
  1228. #endif
  1229. if (weapon_type == 0)
  1230. if (Cockpit_mode == CM_STATUS_BAR)
  1231. draw_weapon_info_sub(Primary_weapon_to_weapon_info[weapon_num],
  1232. &gauge_boxes[2],
  1233. SB_PRIMARY_W_PIC_X,SB_PRIMARY_W_PIC_Y,
  1234. PRIMARY_WEAPON_NAMES_SHORT(weapon_num),
  1235. SB_PRIMARY_W_TEXT_X,SB_PRIMARY_W_TEXT_Y);
  1236. else
  1237. draw_weapon_info_sub(Primary_weapon_to_weapon_info[weapon_num],
  1238. &gauge_boxes[0],
  1239. PRIMARY_W_PIC_X,PRIMARY_W_PIC_Y,
  1240. PRIMARY_WEAPON_NAMES_SHORT(weapon_num),
  1241. PRIMARY_W_TEXT_X,PRIMARY_W_TEXT_Y);
  1242. else
  1243. if (Cockpit_mode == CM_STATUS_BAR)
  1244. draw_weapon_info_sub(Secondary_weapon_to_weapon_info[weapon_num],
  1245. &gauge_boxes[3],
  1246. SB_SECONDARY_W_PIC_X,SB_SECONDARY_W_PIC_Y,
  1247. SECONDARY_WEAPON_NAMES_SHORT(weapon_num),
  1248. SB_SECONDARY_W_TEXT_X,SB_SECONDARY_W_TEXT_Y);
  1249. else
  1250. draw_weapon_info_sub(Secondary_weapon_to_weapon_info[weapon_num],
  1251. &gauge_boxes[1],
  1252. SECONDARY_W_PIC_X,SECONDARY_W_PIC_Y,
  1253. SECONDARY_WEAPON_NAMES_SHORT(weapon_num),
  1254. SECONDARY_W_TEXT_X,SECONDARY_W_TEXT_Y);
  1255. }
  1256. draw_ammo_info(int x,int y,int ammo_count,int primary)
  1257. {
  1258. int w;
  1259. if (primary)
  1260. w = (grd_curcanv->cv_font->ft_w*6)/2;
  1261. else
  1262. w = (grd_curcanv->cv_font->ft_w*5)/2;
  1263. gr_setcolor(BM_XRGB(0,0,0));
  1264. gr_rect(x,y,x+w,y+grd_curcanv->cv_font->ft_h);
  1265. gr_set_fontcolor(gr_getcolor(20,0,0),-1 );
  1266. gr_printf(x,y,"%03d",ammo_count);
  1267. }
  1268. draw_primary_ammo_info(int ammo_count)
  1269. {
  1270. if (Cockpit_mode == CM_STATUS_BAR)
  1271. draw_ammo_info(SB_PRIMARY_AMMO_X,SB_PRIMARY_AMMO_Y,ammo_count,1);
  1272. else
  1273. draw_ammo_info(PRIMARY_AMMO_X,PRIMARY_AMMO_Y,ammo_count,1);
  1274. }
  1275. draw_secondary_ammo_info(int ammo_count)
  1276. {
  1277. if (Cockpit_mode == CM_STATUS_BAR)
  1278. draw_ammo_info(SB_SECONDARY_AMMO_X,SB_SECONDARY_AMMO_Y,ammo_count,0);
  1279. else
  1280. draw_ammo_info(SECONDARY_AMMO_X,SECONDARY_AMMO_Y,ammo_count,0);
  1281. }
  1282. //returns true if drew picture
  1283. int draw_weapon_box(int weapon_type,int weapon_num)
  1284. {
  1285. int drew_flag=0;
  1286. gr_set_current_canvas(&VR_render_buffer[0]);
  1287. gr_set_curfont( GAME_FONT );
  1288. if (weapon_num != old_weapon[weapon_type] && weapon_box_states[weapon_type] == WS_SET) {
  1289. weapon_box_states[weapon_type] = WS_FADING_OUT;
  1290. weapon_box_fade_values[weapon_type]=i2f(GR_FADE_LEVELS-1);
  1291. }
  1292. if (old_weapon[weapon_type] == -1) {
  1293. draw_weapon_info(weapon_type,weapon_num);
  1294. old_weapon[weapon_type] = weapon_num;
  1295. old_ammo_count[weapon_type]=-1;
  1296. drew_flag=1;
  1297. weapon_box_states[weapon_type] = WS_SET;
  1298. }
  1299. if (weapon_box_states[weapon_type] == WS_FADING_OUT) {
  1300. draw_weapon_info(weapon_type,old_weapon[weapon_type]);
  1301. old_ammo_count[weapon_type]=-1;
  1302. drew_flag=1;
  1303. weapon_box_fade_values[weapon_type] -= FrameTime * FADE_SCALE;
  1304. if (weapon_box_fade_values[weapon_type] <= 0) {
  1305. weapon_box_states[weapon_type] = WS_FADING_IN;
  1306. old_weapon[weapon_type] = weapon_num;
  1307. weapon_box_fade_values[weapon_type] = 0;
  1308. }
  1309. }
  1310. else if (weapon_box_states[weapon_type] == WS_FADING_IN) {
  1311. if (weapon_num != old_weapon[weapon_type]) {
  1312. weapon_box_states[weapon_type] = WS_FADING_OUT;
  1313. }
  1314. else {
  1315. draw_weapon_info(weapon_type,weapon_num);
  1316. old_ammo_count[weapon_type]=-1;
  1317. drew_flag=1;
  1318. weapon_box_fade_values[weapon_type] += FrameTime * FADE_SCALE;
  1319. if (weapon_box_fade_values[weapon_type] >= i2f(GR_FADE_LEVELS-1))
  1320. weapon_box_states[weapon_type] = WS_SET;
  1321. }
  1322. }
  1323. if (weapon_box_states[weapon_type] != WS_SET) { //fade gauge
  1324. int fade_value = f2i(weapon_box_fade_values[weapon_type]);
  1325. int boxofs = (Cockpit_mode==CM_STATUS_BAR)?2:0;
  1326. Gr_scanline_darkening_level = fade_value;
  1327. gr_rect(gauge_boxes[boxofs+weapon_type].left,gauge_boxes[boxofs+weapon_type].top,gauge_boxes[boxofs+weapon_type].right,gauge_boxes[boxofs+weapon_type].bot);
  1328. Gr_scanline_darkening_level = GR_FADE_LEVELS;
  1329. }
  1330. gr_set_current_canvas(get_current_game_screen());
  1331. return drew_flag;
  1332. }
  1333. draw_weapon_boxes()
  1334. {
  1335. int boxofs = (Cockpit_mode==CM_STATUS_BAR)?2:0;
  1336. int drew;
  1337. drew = draw_weapon_box(0,Primary_weapon);
  1338. if (drew) copy_gauge_box(&gauge_boxes[boxofs+0],&VR_render_buffer[0].cv_bitmap);
  1339. if (weapon_box_states[0] == WS_SET)
  1340. if (Players[Player_num].primary_ammo[Primary_weapon] != old_ammo_count[0]) {
  1341. if (Primary_weapon == VULCAN_INDEX) {
  1342. #ifndef SHAREWARE
  1343. if (Newdemo_state == ND_STATE_RECORDING)
  1344. newdemo_record_primary_ammo(old_ammo_count[0], Players[Player_num].primary_ammo[Primary_weapon]);
  1345. #endif
  1346. draw_primary_ammo_info(f2i(VULCAN_AMMO_SCALE * Players[Player_num].primary_ammo[Primary_weapon]));
  1347. old_ammo_count[0] = Players[Player_num].primary_ammo[Primary_weapon];
  1348. }
  1349. }
  1350. if (!hostage_is_vclip_playing()) {
  1351. drew = draw_weapon_box(1,Secondary_weapon);
  1352. if (drew) copy_gauge_box(&gauge_boxes[boxofs+1],&VR_render_buffer[0].cv_bitmap);
  1353. if (weapon_box_states[1] == WS_SET)
  1354. if (Players[Player_num].secondary_ammo[Secondary_weapon] != old_ammo_count[1]) {
  1355. #ifndef SHAREWARE
  1356. if (Newdemo_state == ND_STATE_RECORDING)
  1357. newdemo_record_secondary_ammo(old_ammo_count[1], Players[Player_num].secondary_ammo[Secondary_weapon]);
  1358. #endif
  1359. draw_secondary_ammo_info(Players[Player_num].secondary_ammo[Secondary_weapon]);
  1360. old_ammo_count[1] = Players[Player_num].secondary_ammo[Secondary_weapon];
  1361. }
  1362. }
  1363. }
  1364. sb_draw_energy_bar(energy)
  1365. {
  1366. int erase_height;
  1367. gr_set_current_canvas( Canv_SBEnergyGauge );
  1368. PIGGY_PAGE_IN(Gauges[SB_GAUGE_ENERGY]);
  1369. gr_ubitmapm( 0, 0, &GameBitmaps[Gauges[SB_GAUGE_ENERGY].index] );
  1370. erase_height = (100 - energy) * SB_ENERGY_GAUGE_H / 100;
  1371. if (erase_height > 0) {
  1372. gr_setcolor( 0 );
  1373. gr_rect(0,0,SB_ENERGY_GAUGE_W-1,erase_height-1);
  1374. }
  1375. gr_set_current_canvas( get_current_game_screen() );
  1376. gr_ubitmapm( SB_ENERGY_GAUGE_X, SB_ENERGY_GAUGE_Y, &Canv_SBEnergyGauge->cv_bitmap );
  1377. //draw numbers
  1378. gr_set_fontcolor(gr_getcolor(25,18,6),-1 );
  1379. gr_printf((energy>99)?SB_ENERGY_NUM_X:((energy>9)?SB_ENERGY_NUM_X+2:SB_ENERGY_NUM_X+4),SB_ENERGY_NUM_Y,"%d",energy);
  1380. }
  1381. sb_draw_shield_num(int shield)
  1382. {
  1383. grs_bitmap *bm = &GameBitmaps[cockpit_bitmap[Cockpit_mode].index];
  1384. //draw numbers
  1385. gr_set_curfont( GAME_FONT );
  1386. gr_set_fontcolor(gr_getcolor(14,14,23),-1 );
  1387. //erase old one
  1388. PIGGY_PAGE_IN( cockpit_bitmap[Cockpit_mode] );
  1389. gr_setcolor(gr_gpixel(bm,SB_SHIELD_NUM_X,SB_SHIELD_NUM_Y-(VR_render_width-bm->bm_h)));
  1390. gr_rect(SB_SHIELD_NUM_X,SB_SHIELD_NUM_Y,SB_SHIELD_NUM_X+13,SB_SHIELD_NUM_Y+GAME_FONT->ft_h);
  1391. gr_printf((shield>99)?SB_SHIELD_NUM_X:((shield>9)?SB_SHIELD_NUM_X+2:SB_SHIELD_NUM_X+4),SB_SHIELD_NUM_Y,"%d",shield);
  1392. }
  1393. sb_draw_shield_bar(int shield)
  1394. {
  1395. int bm_num = shield>=100?9:(shield / 10);
  1396. gr_set_current_canvas( get_current_game_screen() );
  1397. PIGGY_PAGE_IN( Gauges[GAUGE_SHIELDS+9-bm_num] );
  1398. gr_ubitmapm( SB_SHIELD_GAUGE_X, SB_SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_SHIELDS+9-bm_num].index] );
  1399. }
  1400. sb_draw_keys()
  1401. {
  1402. grs_bitmap * bm;
  1403. int flags = Players[Player_num].flags;
  1404. gr_set_current_canvas( get_current_game_screen() );
  1405. bm = &GameBitmaps[Gauges[(flags&PLAYER_FLAGS_BLUE_KEY)?SB_GAUGE_BLUE_KEY:SB_GAUGE_BLUE_KEY_OFF].index];
  1406. PIGGY_PAGE_IN(Gauges[(flags&PLAYER_FLAGS_BLUE_KEY)?SB_GAUGE_BLUE_KEY:SB_GAUGE_BLUE_KEY_OFF]);
  1407. gr_ubitmapm( SB_GAUGE_KEYS_X, SB_GAUGE_BLUE_KEY_Y, bm );
  1408. bm = &GameBitmaps[Gauges[(flags&PLAYER_FLAGS_GOLD_KEY)?SB_GAUGE_GOLD_KEY:SB_GAUGE_GOLD_KEY_OFF].index];
  1409. PIGGY_PAGE_IN(Gauges[(flags&PLAYER_FLAGS_GOLD_KEY)?SB_GAUGE_GOLD_KEY:SB_GAUGE_GOLD_KEY_OFF]);
  1410. gr_ubitmapm( SB_GAUGE_KEYS_X, SB_GAUGE_GOLD_KEY_Y, bm );
  1411. bm = &GameBitmaps[Gauges[(flags&PLAYER_FLAGS_RED_KEY)?SB_GAUGE_RED_KEY:SB_GAUGE_RED_KEY_OFF].index];
  1412. PIGGY_PAGE_IN(Gauges[(flags&PLAYER_FLAGS_RED_KEY)?SB_GAUGE_RED_KEY:SB_GAUGE_RED_KEY_OFF]);
  1413. gr_ubitmapm( SB_GAUGE_KEYS_X, SB_GAUGE_RED_KEY_Y, bm );
  1414. }
  1415. // Draws invulnerable ship, or maybe the flashing ship, depending on invulnerability time left.
  1416. void draw_invulnerable_ship()
  1417. {
  1418. static fix time=0;
  1419. gr_set_current_canvas( get_current_game_screen() );
  1420. if (((Players[Player_num].invulnerable_time + INVULNERABLE_TIME_MAX - GameTime) > F1_0*4) || (GameTime & 0x8000)) {
  1421. if (Cockpit_mode == CM_STATUS_BAR) {
  1422. PIGGY_PAGE_IN(Gauges[GAUGE_INVULNERABLE+invulnerable_frame]);
  1423. gr_ubitmapm( SB_SHIELD_GAUGE_X, SB_SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_INVULNERABLE+invulnerable_frame].index] );
  1424. } else {
  1425. PIGGY_PAGE_IN(Gauges[GAUGE_INVULNERABLE+invulnerable_frame]);
  1426. gr_ubitmapm( SHIELD_GAUGE_X, SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_INVULNERABLE+invulnerable_frame].index] );
  1427. }
  1428. time += FrameTime;
  1429. while (time > INV_FRAME_TIME) {
  1430. time -= INV_FRAME_TIME;
  1431. if (++invulnerable_frame == N_INVULNERABLE_FRAMES)
  1432. invulnerable_frame=0;
  1433. }
  1434. } else if (Cockpit_mode == CM_STATUS_BAR)
  1435. sb_draw_shield_bar(f2ir(Players[Player_num].shields));
  1436. else
  1437. draw_shield_bar(f2ir(Players[Player_num].shields));
  1438. }
  1439. #ifdef HOSTAGE_FACES
  1440. draw_hostage_gauge()
  1441. {
  1442. int drew;
  1443. gr_set_current_canvas(Canv_game_offscrn);
  1444. drew = do_hostage_effects();
  1445. if (drew) {
  1446. int boxofs = (Cockpit_mode==CM_STATUS_BAR)?2:0;
  1447. gr_set_current_canvas(Canv_game);
  1448. copy_gauge_box(&gauge_boxes[boxofs+1],&Canv_game_offscrn->cv_bitmap);
  1449. old_weapon[1] = old_ammo_count[1] = -1;
  1450. }
  1451. }
  1452. #endif
  1453. extern int Missile_gun;
  1454. extern int allowed_to_fire_laser(void);
  1455. extern int allowed_to_fire_missile(void);
  1456. rgb player_rgb[] = {
  1457. {15,15,23},
  1458. {27,0,0},
  1459. {0,23,0},
  1460. {30,11,31},
  1461. {31,16,0},
  1462. {24,17,6},
  1463. {14,21,12},
  1464. {29,29,0},
  1465. };
  1466. //draw the reticle
  1467. show_reticle(int force_big_one)
  1468. {
  1469. int x,y;
  1470. int laser_ready,missile_ready,laser_ammo,missile_ammo;
  1471. int cross_bm_num,primary_bm_num,secondary_bm_num;
  1472. x = grd_curcanv->cv_w/2;
  1473. y = grd_curcanv->cv_h/2;
  1474. laser_ready = allowed_to_fire_laser();
  1475. missile_ready = allowed_to_fire_missile();
  1476. laser_ammo = player_has_weapon(Primary_weapon,0);
  1477. missile_ammo = player_has_weapon(Secondary_weapon,1);
  1478. primary_bm_num = (laser_ready && laser_ammo==HAS_ALL);
  1479. secondary_bm_num = (missile_ready && missile_ammo==HAS_ALL);
  1480. if (primary_bm_num && Primary_weapon==LASER_INDEX && (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
  1481. primary_bm_num++;
  1482. if (Secondary_weapon!=CONCUSSION_INDEX && Secondary_weapon!=HOMING_INDEX)
  1483. secondary_bm_num += 3; //now value is 0,1 or 3,4
  1484. else if (secondary_bm_num && !(Missile_gun&1))
  1485. secondary_bm_num++;
  1486. cross_bm_num = ((primary_bm_num > 0) || (secondary_bm_num > 0));
  1487. Assert(primary_bm_num <= 2);
  1488. Assert(secondary_bm_num <= 4);
  1489. Assert(cross_bm_num <= 1);
  1490. if (grd_curcanv->cv_bitmap.bm_w > 200 || force_big_one) {
  1491. PIGGY_PAGE_IN(Gauges[RETICLE_CROSS + cross_bm_num]);
  1492. gr_ubitmapm(x-4 ,y-2,&GameBitmaps[Gauges[RETICLE_CROSS + cross_bm_num].index]);
  1493. PIGGY_PAGE_IN(Gauges[RETICLE_PRIMARY + primary_bm_num]);
  1494. gr_ubitmapm(x-15,y+6,&GameBitmaps[Gauges[RETICLE_PRIMARY + primary_bm_num].index]);
  1495. PIGGY_PAGE_IN(Gauges[RETICLE_SECONDARY + secondary_bm_num]);
  1496. gr_ubitmapm(x-12,y+1,&GameBitmaps[Gauges[RETICLE_SECONDARY + secondary_bm_num].index]);
  1497. }
  1498. else {
  1499. PIGGY_PAGE_IN(Gauges[SML_RETICLE_CROSS + cross_bm_num]);
  1500. gr_ubitmapm(x-2,y-1,&GameBitmaps[Gauges[SML_RETICLE_CROSS + cross_bm_num].index]);
  1501. PIGGY_PAGE_IN(Gauges[SML_RETICLE_PRIMARY + primary_bm_num]);
  1502. gr_ubitmapm(x-8,y+2,&GameBitmaps[Gauges[SML_RETICLE_PRIMARY + primary_bm_num].index]);
  1503. PIGGY_PAGE_IN(Gauges[SML_RETICLE_SECONDARY + secondary_bm_num]);
  1504. gr_ubitmapm(x-6,y-2,&GameBitmaps[Gauges[SML_RETICLE_SECONDARY + secondary_bm_num].index]);
  1505. }
  1506. #ifndef SHAREWARE
  1507. if ((Newdemo_state == ND_STATE_PLAYBACK) || (((Game_mode & GM_MULTI_COOP) || (Game_mode & GM_TEAM)) && Show_reticle_name))
  1508. {
  1509. // Draw player callsign for player in sights
  1510. fvi_query fq;
  1511. vms_vector orient;
  1512. int Hit_type;
  1513. fvi_info Hit_data;
  1514. fq.p0 = &ConsoleObject->pos;
  1515. orient = ConsoleObject->orient.fvec;
  1516. vm_vec_scale(&orient, F1_0*1024);
  1517. vm_vec_add2(&orient, fq.p0);
  1518. fq.p1 = &orient;
  1519. fq.rad = 0;
  1520. fq.thisobjnum = ConsoleObject - Objects;
  1521. fq.flags = FQ_TRANSWALL | FQ_CHECK_OBJS;
  1522. fq.startseg = ConsoleObject->segnum;
  1523. fq.ignore_obj_list = NULL;
  1524. Hit_type = find_vector_intersection(&fq, &Hit_data);
  1525. if ((Hit_type == HIT_OBJECT) && (Objects[Hit_data.hit_object].type == OBJ_PLAYER))
  1526. {
  1527. // Draw callsign on HUD
  1528. char s[CALLSIGN_LEN+1];
  1529. int w, h, aw;
  1530. int x1, y1;
  1531. int pnum;
  1532. int color_num;
  1533. pnum = Objects[Hit_data.hit_object].id;
  1534. if ((Game_mode & GM_TEAM) && (get_team(pnum) != get_team(Player_num)) && (Newdemo_state != ND_STATE_PLAYBACK))
  1535. return;
  1536. if (Game_mode & GM_TEAM)
  1537. color_num = get_team(pnum);
  1538. else
  1539. color_num = pnum;
  1540. sprintf(s, "%s", Players[pnum].callsign);
  1541. gr_get_string_size(s, &w, &h, &aw);
  1542. gr_set_fontcolor(gr_getcolor(player_rgb[color_num].r,player_rgb[color_num].g,player_rgb[color_num].b),-1 );
  1543. x1 = x-(w/2);
  1544. y1 = y+12;
  1545. gr_string (x1, y1, s);
  1546. // }
  1547. }
  1548. #ifndef NDEBUG
  1549. else if ((Hit_type == HIT_OBJECT) && (Objects[Hit_data.hit_object].type == OBJ_ROBOT))
  1550. {
  1551. char s[CALLSIGN_LEN+1];
  1552. int w, h, aw;
  1553. int x1, y1;
  1554. int color_num = 0;
  1555. sprintf(s, "%d", Hit_data.hit_object);
  1556. gr_get_string_size(s, &w, &h, &aw);
  1557. gr_set_fontcolor(gr_getcolor(player_rgb[color_num].r,player_rgb[color_num].g,player_rgb[color_num].b),-1 );
  1558. x1 = x-(w/2);
  1559. y1 = y+12;
  1560. gr_string (x1, y1, s);
  1561. }
  1562. #endif
  1563. }
  1564. #endif
  1565. }
  1566. hud_show_kill_list()
  1567. {
  1568. int n_players,player_list[MAX_NUM_NET_PLAYERS];
  1569. int n_left,i,x0,x1,y,save_y,fth;
  1570. if (Show_kill_list_timer > 0)
  1571. {
  1572. Show_kill_list_timer -= FrameTime;
  1573. if (Show_kill_list_timer < 0)
  1574. Show_kill_list = 0;
  1575. }
  1576. #ifdef SHAREWARE
  1577. if (Game_mode & GM_MULTI_COOP)
  1578. {
  1579. Show_kill_list = 0;
  1580. return;
  1581. }
  1582. #endif
  1583. gr_set_curfont( GAME_FONT );
  1584. n_players = multi_get_kill_list(player_list);
  1585. if (Show_kill_list == 2)
  1586. n_players = 2;
  1587. if (n_players <= 4)
  1588. n_left = n_players;
  1589. else
  1590. n_left = (n_players+1)/2;
  1591. //If font size changes, this code might not work right anymore
  1592. Assert(GAME_FONT->ft_h==5 && GAME_FONT->ft_w==7);
  1593. fth = GAME_FONT->ft_h;
  1594. x0 = 1; x1 = 43;
  1595. #ifndef SHAREWARE
  1596. if (Game_mode & GM_MULTI_COOP)
  1597. x1 = 31;
  1598. #endif
  1599. save_y = y = grd_curcanv->cv_h - n_left*(fth+1);
  1600. if (Cockpit_mode == CM_FULL_COCKPIT) {
  1601. save_y = y -= 6;
  1602. #ifndef SHAREWARE
  1603. if (Game_mode & GM_MULTI_COOP)
  1604. x1 = 33;
  1605. else
  1606. #endif
  1607. x1 = 43;
  1608. }
  1609. for (i=0;i<n_players;i++) {
  1610. int player_num;
  1611. char name[9];
  1612. int sw,sh,aw;
  1613. if (i==n_left) {
  1614. if (Cockpit_mode == CM_FULL_COCKPIT)
  1615. x0 = grd_curcanv->cv_w - 53;
  1616. else
  1617. x0 = grd_curcanv->cv_w - 60;
  1618. #ifndef SHAREWARE
  1619. if (Game_mode & GM_MULTI_COOP)
  1620. x1 = grd_curcanv->cv_w - 27;
  1621. else
  1622. #endif
  1623. x1 = grd_curcanv->cv_w - 15;
  1624. y = save_y;
  1625. }
  1626. if (Show_kill_list == 2)
  1627. player_num = i;
  1628. else
  1629. player_num = player_list[i];
  1630. if (Show_kill_list == 1)
  1631. {
  1632. int color;
  1633. if (Players[player_num].connected != 1)
  1634. gr_set_fontcolor(gr_getcolor(12, 12, 12), -1);
  1635. else if (Game_mode & GM_TEAM) {
  1636. color = get_team(player_num);
  1637. gr_set_fontcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 );
  1638. }
  1639. else {
  1640. color = player_num;
  1641. gr_set_fontcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 );
  1642. }
  1643. }
  1644. else
  1645. {
  1646. gr_set_fontcolor(gr_getcolor(player_rgb[player_num].r,player_rgb[player_num].g,player_rgb[player_num].b),-1 );
  1647. }
  1648. if (Show_kill_list == 2)
  1649. strcpy(name, Netgame.team_name[i]);
  1650. else
  1651. strcpy(name,Players[player_num].callsign);
  1652. gr_get_string_size(name,&sw,&sh,&aw);
  1653. while (sw > (x1-x0-3)) {
  1654. name[strlen(name)-1]=0;
  1655. gr_get_string_size(name,&sw,&sh,&aw);
  1656. }
  1657. gr_printf(x0,y,"%s",name);
  1658. if (Show_kill_list == 2)
  1659. gr_printf(x1,y,"%3d",team_kills[i]);
  1660. #ifndef SHAREWARE
  1661. else if (Game_mode & GM_MULTI_COOP)
  1662. gr_printf(x1,y,"%-6d",Players[player_num].score);
  1663. #endif
  1664. else
  1665. gr_printf(x1,y,"%3d",Players[player_num].net_kills_total);
  1666. y += fth+1;
  1667. }
  1668. }
  1669. //draw all the things on the HUD
  1670. void draw_hud()
  1671. {
  1672. // Show score so long as not in rearview
  1673. if ( !Rear_view && Cockpit_mode!=CM_REAR_VIEW && Cockpit_mode!=CM_STATUS_BAR) {
  1674. hud_show_score();
  1675. if (score_time)
  1676. hud_show_score_added();
  1677. }
  1678. // Show other stuff if not in rearview or letterbox.
  1679. if (!Rear_view && Cockpit_mode!=CM_REAR_VIEW) { // && Cockpit_mode!=CM_LETTERBOX) {
  1680. if (Cockpit_mode==CM_STATUS_BAR || Cockpit_mode==CM_FULL_SCREEN)
  1681. hud_show_homing_warning();
  1682. if (Cockpit_mode==CM_FULL_SCREEN) {
  1683. hud_show_energy();
  1684. hud_show_shield();
  1685. hud_show_weapons();
  1686. hud_show_keys();
  1687. hud_show_cloak_invuln();
  1688. if ( ( Newdemo_state==ND_STATE_RECORDING ) && ( Players[Player_num].flags != old_flags )) {
  1689. newdemo_record_player_flags(old_flags, Players[Player_num].flags);
  1690. old_flags = Players[Player_num].flags;
  1691. }
  1692. }
  1693. #ifndef RELEASE
  1694. if (!(Game_mode&GM_MULTI && Show_kill_list))
  1695. show_time();
  1696. #endif
  1697. if (Cockpit_mode != CM_LETTERBOX && (!Use_player_head_angles))
  1698. show_reticle(0);
  1699. HUD_render_message_frame();
  1700. if (Cockpit_mode!=CM_STATUS_BAR)
  1701. hud_show_lives();
  1702. if (Game_mode&GM_MULTI && Show_kill_list)
  1703. hud_show_kill_list();
  1704. }
  1705. if (Rear_view && Cockpit_mode!=CM_REAR_VIEW) {
  1706. HUD_render_message_frame();
  1707. gr_set_curfont( GAME_FONT );
  1708. gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
  1709. gr_printf(0x8000,grd_curcanv->cv_h-10,TXT_REAR_VIEW);
  1710. }
  1711. }
  1712. //print out some player statistics
  1713. void render_gauges()
  1714. {
  1715. int energy = f2ir(Players[Player_num].energy);
  1716. int shields = f2ir(Players[Player_num].shields);
  1717. int cloak = ((Players[Player_num].flags&PLAYER_FLAGS_CLOAKED) != 0);
  1718. Assert(Cockpit_mode==CM_FULL_COCKPIT || Cockpit_mode==CM_STATUS_BAR);
  1719. #ifdef HOSTAGE_FACES
  1720. draw_hostage_gauge();
  1721. #endif
  1722. if (shields < 0 ) shields = 0;
  1723. gr_set_current_canvas(get_current_game_screen());
  1724. gr_set_curfont( GAME_FONT );
  1725. if (Newdemo_state == ND_STATE_RECORDING)
  1726. if (Players[Player_num].homing_object_dist >= 0)
  1727. newdemo_record_homing_distance(Players[Player_num].homing_object_dist);
  1728. if (Cockpit_mode == CM_FULL_COCKPIT) {
  1729. if (energy != old_energy) {
  1730. if (Newdemo_state==ND_STATE_RECORDING ) {
  1731. #ifdef SHAREWARE
  1732. newdemo_record_player_energy(energy);
  1733. #else
  1734. newdemo_record_player_energy(old_energy, energy);
  1735. #endif
  1736. }
  1737. draw_energy_bar(energy);
  1738. draw_numerical_display(shields, energy);
  1739. old_energy = energy;
  1740. }
  1741. if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
  1742. draw_numerical_display(shields, energy);
  1743. draw_invulnerable_ship();
  1744. old_shields = shields ^ 1;
  1745. } else if (shields != old_shields) { // Draw the shield gauge
  1746. if (Newdemo_state==ND_STATE_RECORDING ) {
  1747. #ifdef SHAREWARE
  1748. newdemo_record_player_shields(shields);
  1749. #else
  1750. newdemo_record_player_shields(old_shields, shields);
  1751. #endif
  1752. }
  1753. draw_shield_bar(shields);
  1754. draw_numerical_display(shields, energy);
  1755. old_shields = shields;
  1756. }
  1757. if (Players[Player_num].flags != old_flags) {
  1758. if (Newdemo_state==ND_STATE_RECORDING )
  1759. newdemo_record_player_flags(old_flags, Players[Player_num].flags);
  1760. draw_keys();
  1761. old_flags = Players[Player_num].flags;
  1762. }
  1763. show_homing_warning();
  1764. } else if (Cockpit_mode == CM_STATUS_BAR) {
  1765. if (energy != old_energy) {
  1766. if (Newdemo_state==ND_STATE_RECORDING ) {
  1767. #ifdef SHAREWARE
  1768. newdemo_record_player_energy(energy);
  1769. #else
  1770. newdemo_record_player_energy(old_energy, energy);
  1771. #endif
  1772. }
  1773. sb_draw_energy_bar(energy);
  1774. old_energy = energy;
  1775. }
  1776. if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
  1777. draw_invulnerable_ship();
  1778. old_shields = shields ^ 1;
  1779. sb_draw_shield_num(shields);
  1780. }
  1781. else
  1782. if (shields != old_shields) { // Draw the shield gauge
  1783. if (Newdemo_state==ND_STATE_RECORDING ) {
  1784. #ifdef SHAREWARE
  1785. newdemo_record_player_shields(shields);
  1786. #else
  1787. newdemo_record_player_shields(old_shields, shields);
  1788. #endif
  1789. }
  1790. sb_draw_shield_bar(shields);
  1791. old_shields = shields;
  1792. sb_draw_shield_num(shields);
  1793. }
  1794. if (Players[Player_num].flags != old_flags) {
  1795. if (Newdemo_state==ND_STATE_RECORDING )
  1796. newdemo_record_player_flags(old_flags, Players[Player_num].flags);
  1797. sb_draw_keys();
  1798. old_flags = Players[Player_num].flags;
  1799. }
  1800. if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))
  1801. {
  1802. if (Players[Player_num].net_killed_total != old_lives) {
  1803. sb_show_lives();
  1804. old_lives = Players[Player_num].net_killed_total;
  1805. }
  1806. }
  1807. else
  1808. {
  1809. if (Players[Player_num].lives != old_lives) {
  1810. sb_show_lives();
  1811. old_lives = Players[Player_num].lives;
  1812. }
  1813. }
  1814. if ((Game_mode&GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) {
  1815. if (Players[Player_num].net_kills_total != old_score) {
  1816. sb_show_score();
  1817. old_score = Players[Player_num].net_kills_total;
  1818. }
  1819. }
  1820. else {
  1821. if (Players[Player_num].score != old_score) {
  1822. sb_show_score();
  1823. old_score = Players[Player_num].score;
  1824. }
  1825. if (score_time)
  1826. sb_show_score_added();
  1827. }
  1828. }
  1829. if (cloak != old_cloak || cloak_fade_state || (cloak && GameTime>Players[Player_num].cloak_time+CLOAK_TIME_MAX-i2f(3))) {
  1830. if (Cockpit_mode == CM_FULL_COCKPIT)
  1831. draw_player_ship(cloak,old_cloak,SHIP_GAUGE_X,SHIP_GAUGE_Y);
  1832. else
  1833. draw_player_ship(cloak,old_cloak,SB_SHIP_GAUGE_X,SB_SHIP_GAUGE_Y);
  1834. old_cloak=cloak;
  1835. }
  1836. draw_weapon_boxes();
  1837. }
  1838. // ---------------------------------------------------------------------------------------------------------
  1839. // Call when picked up a laser powerup.
  1840. // If laser is active, set old_weapon[0] to -1 to force redraw.
  1841. void update_laser_weapon_info(void)
  1842. {
  1843. if (old_weapon[0] == 0)
  1844. old_weapon[0] = -1;
  1845. }
  1846.