123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241 |
- /*
- THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
- SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
- END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
- ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
- IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
- SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
- FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
- CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
- AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
- COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
- */
- /*
- * $Source: f:/miner/source/main/rcs/gauges.c $
- * $Revision: 2.1 $
- * $Author: john $
- * $Date: 1995/02/27 13:13:45 $
- *
- * Inferno gauge drivers
- *
- * $Log: gauges.c $
- * Revision 2.1 1995/02/27 13:13:45 john
- * Removed floating point.
- *
- * Revision 2.0 1995/02/27 11:29:06 john
- * New version 2.0, which has no anonymous unions, builds with
- * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
- *
- * Revision 1.203 1995/02/11 01:56:45 mike
- * move up weapons text on fullscreen hud, missiles was offscreen.
- *
- * Revision 1.202 1995/02/09 13:23:34 rob
- * Added reticle names in demo playback.
- *
- * Revision 1.201 1995/02/08 19:20:46 rob
- * Show cloaked teammates on H
- * UD. Get rid of show ID's in anarchy option.
- *
- * Revision 1.200 1995/02/07 21:09:00 mike
- * add flashing to invulnerability and cloak on fullscreen.
- *
- * Revision 1.199 1995/02/02 21:55:57 matt
- * Added new colored key icons for fullscreen
- *
- * Revision 1.198 1995/01/30 17:17:07 rob
- * Fixed teammate names on hud.
- *
- * Revision 1.197 1995/01/28 17:40:49 mike
- * fix gauge fontcolor.
- *
- * Revision 1.196 1995/01/27 17:03:14 mike
- * fix placement of weapon info in multiplayer fullscreen, as per AP request.
- *
- * Revision 1.195 1995/01/27 11:51:23 rob
- * Put deaths tally into cooperative mode
- *
- * Revision 1.194 1995/01/27 11:43:24 adam
- * fiddled with key display
- *
- * Revision 1.193 1995/01/25 23:38:35 mike
- * fix keys on fullscreen.
- *
- * Revision 1.192 1995/01/24 22:03:28 mike
- * Lotsa hud stuff, put a lot of messages up.
- *
- * Revision 1.191 1995/01/23 16:47:21 rob
- * Fixed problem with playing extra life noise in coop.
- *
- * Revision 1.190 1995/01/22 16:00:46 mike
- * remove unneeded string.
- *
- * Revision 1.189 1995/01/22 15:58:22 mike
- * localization
- *
- * Revision 1.188 1995/01/20 17:19:45 rob
- * Fixing colors of hud kill list players.
- *
- * Revision 1.187 1995/01/20 09:19:18 allender
- * record player flags when in CM_FULL_SCREEN
- *
- * Revision 1.186 1995/01/19 16:29:09 allender
- * made demo recording of weapon change be in this file for shareware only
- *
- * Revision 1.185 1995/01/19 15:00:33 allender
- * code to record shield, energy, and ammo in fullscreen
- *
- * Revision 1.184 1995/01/19 13:43:13 matt
- * Fixed "cheater" message on HUD
- *
- * Revision 1.183 1995/01/18 16:11:58 mike
- * Don't show added scores of 0.
- *
- * Revision 1.182 1995/01/17 17:42:39 allender
- * do ammo counts in demo recording
- *
- * Revision 1.181 1995/01/16 17:26:25 rob
- * Fixed problem with coloration of team kill list.
- *
- * Revision 1.180 1995/01/16 17:22:39 john
- * Made so that KB and framerate don't collide.
- *
- * Revision 1.179 1995/01/16 14:58:31 matt
- * Changed score_added display to print "Cheater!" when cheats enabled
- *
- * Revision 1.178 1995/01/15 19:42:07 matt
- * Ripped out hostage faces for registered version
- *
- * Revision 1.177 1995/01/15 19:25:07 mike
- * show vulcan ammo and secondary ammo in fullscreen view.
- *
- * Revision 1.176 1995/01/15 13:16:12 john
- * Made so that paging always happens, lowmem just loads less.
- * Also, make KB load print to hud.
- *
- * Revision 1.175 1995/01/14 19:17:32 john
- * First version of piggy paging.
- *
- * Revision 1.174 1995/01/05 21:25:23 rob
- * Re-did some changes lost due to RCS weirdness.
- *
- * Revision 1.173 1995/01/05 12:22:34 rob
- * Don't show player names for cloaked players.
- *
- * Revision 1.172 1995/01/04 17:14:50 allender
- * make init_gauges work properly on demo playback
- *
- * Revision 1.171 1995/01/04 15:04:42 allender
- * new demo calls for registered version
- *
- * Revision 1.167 1995/01/03 13:03:57 allender
- * pass score points instead of total points. Added ifdef for
- * multi_send_score
- *
- * Revision 1.166 1995/01/03 11:45:02 allender
- * add hook to record player score
- *
- * Revision 1.165 1995/01/03 11:25:19 allender
- * remove newdemo stuff around score display
- *
- * Revision 1.163 1995/01/02 21:03:53 rob
- * Fixing up the hud-score-list for coop games.
- *
- * Revision 1.162 1994/12/31 20:54:40 rob
- * Added coop mode HUD score list.
- * Added more generic system for player names on HUD.
- *
- * Revision 1.161 1994/12/30 20:13:01 rob
- * Ifdef reticle names on shareware.
- * Added robot reticle naming.
- *
- * Revision 1.160 1994/12/29 17:53:51 mike
- * move up energy/shield in fullscreen to get out of way of kill list.
- *
- * Revision 1.159 1994/12/29 16:44:05 mike
- * add energy and shield showing.
- *
- * Revision 1.158 1994/12/28 16:34:29 mike
- * make warning beep go away on Player_is_dead.
- *
- * Revision 1.157 1994/12/28 10:00:43 allender
- * change in init_gauges to for multiplayer demo playbacks
- *
- * Revision 1.156 1994/12/27 11:06:46 allender
- * removed some previous code to for demo playback stuff
- *
- * Revision 1.155 1994/12/23 14:23:06 john
- * Added floating reticle for VR helments.
- *
- * Revision 1.154 1994/12/21 12:56:41 allender
- * on multiplayer demo playback, show kills and deaths
- *
- * Revision 1.153 1994/12/19 20:28:42 rob
- * Get rid of kill list in coop games.
- *
- * Revision 1.152 1994/12/14 18:06:44 matt
- * Removed compile warnings
- *
- * Revision 1.151 1994/12/14 15:21:28 rob
- * Made gauges align in status_bar net game.
- *
- * Revision 1.150 1994/12/12 17:20:33 matt
- * Don't get bonus points when cheating
- *
- * Revision 1.149 1994/12/12 16:47:00 matt
- * When cheating, get no score. Change level cheat to prompt for and
- * jump to new level.
- *
- * Revision 1.148 1994/12/12 12:05:45 rob
- * Grey out players who are disconnected.
- *
- * Revision 1.147 1994/12/09 16:19:48 yuan
- * kill matrix stuff.
- *
- * Revision 1.146 1994/12/09 16:12:34 rob
- * Fixed up the status bar kills gauges for net play.
- *
- * Revision 1.145 1994/12/09 01:55:34 rob
- * Added kills list to HUD/status bar.
- * Added something for Mark.
- *
- * Revision 1.144 1994/12/08 21:03:30 allender
- * pass old player flags to record_player_flags
- *
- * Revision 1.143 1994/12/07 22:49:33 mike
- * no homing missile warning during endlevel sequence.
- *
- * Revision 1.142 1994/12/06 13:55:31 matt
- * Use new rounding func, f2ir()
- *
- * Revision 1.141 1994/12/03 19:03:37 matt
- * Fixed vulcan ammo HUD message
- *
- * Revision 1.140 1994/12/03 18:43:18 matt
- * Fixed (hopefully) claok gauge
- *
- * Revision 1.139 1994/12/03 14:26:21 yuan
- * Fixed dumb bug
- *
- * Revision 1.138 1994/12/03 14:17:30 yuan
- * Localization 320
- *
- */
- #pragma off (unreferenced)
- static char rcsid[] = "$Id: gauges.c 2.1 1995/02/27 13:13:45 john Exp $";
- #pragma on (unreferenced)
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <stdarg.h>
- #include "inferno.h"
- #include "game.h"
- #include "screens.h"
- #include "gauges.h"
- #include "physics.h"
- #include "error.h"
- #include "menu.h" // For the font.
- #include "mono.h"
- #include "collide.h"
- #include "newdemo.h"
- #include "player.h"
- #include "gamefont.h"
- #include "hostage.h"
- #include "bm.h"
- #include "text.h"
- #include "powerup.h"
- #include "sounds.h"
- #include "multi.h"
- #include "network.h"
- #include "endlevel.h"
- #include "wall.h"
- #include "text.h"
- #include "render.h"
- #include "piggy.h"
- bitmap_index Gauges[MAX_GAUGE_BMS]; // Array of all gauge bitmaps.
- grs_canvas *Canv_LeftEnergyGauge;
- grs_canvas *Canv_SBEnergyGauge;
- grs_canvas *Canv_RightEnergyGauge;
- grs_canvas *Canv_NumericalGauge;
- //bitmap numbers for gauges
- #define GAUGE_SHIELDS 0 //0..9, in decreasing order (100%,90%...0%)
- #define GAUGE_INVULNERABLE 10 //10..19
- #define N_INVULNERABLE_FRAMES 10
- #define GAUGE_SPEED 20 //unused
- #define GAUGE_ENERGY_LEFT 21
- #define GAUGE_ENERGY_RIGHT 22
- #define GAUGE_NUMERICAL 23
- #define GAUGE_BLUE_KEY 24
- #define GAUGE_GOLD_KEY 25
- #define GAUGE_RED_KEY 26
- #define GAUGE_BLUE_KEY_OFF 27
- #define GAUGE_GOLD_KEY_OFF 28
- #define GAUGE_RED_KEY_OFF 29
- #define SB_GAUGE_BLUE_KEY 30
- #define SB_GAUGE_GOLD_KEY 31
- #define SB_GAUGE_RED_KEY 32
- #define SB_GAUGE_BLUE_KEY_OFF 33
- #define SB_GAUGE_GOLD_KEY_OFF 34
- #define SB_GAUGE_RED_KEY_OFF 35
- #define SB_GAUGE_ENERGY 36
- #define GAUGE_LIVES 37
- #define GAUGE_SHIPS 38
- #define GAUGE_SHIPS_LAST 45
- #define RETICLE_CROSS 46
- #define RETICLE_PRIMARY 48
- #define RETICLE_SECONDARY 51
- #define RETICLE_LAST 55
- #define GAUGE_HOMING_WARNING_ON 56
- #define GAUGE_HOMING_WARNING_OFF 57
- #define SML_RETICLE_CROSS 58
- #define SML_RETICLE_PRIMARY 60
- #define SML_RETICLE_SECONDARY 63
- #define SML_RETICLE_LAST 67
- #define KEY_ICON_BLUE 68
- #define KEY_ICON_YELLOW 69
- #define KEY_ICON_RED 70
- //change MAX_GAUGE_BMS when adding gauges
- //Coordinats for gauges
- #define GAUGE_BLUE_KEY_X 45
- #define GAUGE_BLUE_KEY_Y 152
- #define GAUGE_GOLD_KEY_X 44
- #define GAUGE_GOLD_KEY_Y 162
- #define GAUGE_RED_KEY_X 43
- #define GAUGE_RED_KEY_Y 172
- #define SB_GAUGE_KEYS_X 11
- #define SB_GAUGE_BLUE_KEY_Y 153
- #define SB_GAUGE_GOLD_KEY_Y 169
- #define SB_GAUGE_RED_KEY_Y 185
- #define LEFT_ENERGY_GAUGE_X 70
- #define LEFT_ENERGY_GAUGE_Y 131
- #define LEFT_ENERGY_GAUGE_W 64
- #define LEFT_ENERGY_GAUGE_H 8
- #define RIGHT_ENERGY_GAUGE_X 190
- #define RIGHT_ENERGY_GAUGE_Y 131
- #define RIGHT_ENERGY_GAUGE_W 64
- #define RIGHT_ENERGY_GAUGE_H 8
- #define SB_ENERGY_GAUGE_X 98
- #define SB_ENERGY_GAUGE_Y 155
- #define SB_ENERGY_GAUGE_W 16
- #define SB_ENERGY_GAUGE_H 41
- #define SB_ENERGY_NUM_X (SB_ENERGY_GAUGE_X+2)
- #define SB_ENERGY_NUM_Y 190
- #define SHIELD_GAUGE_X 146
- #define SHIELD_GAUGE_Y 155
- #define SHIELD_GAUGE_W 35
- #define SHIELD_GAUGE_H 32
- #define SHIP_GAUGE_X (SHIELD_GAUGE_X+5)
- #define SHIP_GAUGE_Y (SHIELD_GAUGE_Y+5)
- #define SB_SHIELD_GAUGE_X 123 //139
- #define SB_SHIELD_GAUGE_Y 163
- #define SB_SHIP_GAUGE_X (SB_SHIELD_GAUGE_X+5)
- #define SB_SHIP_GAUGE_Y (SB_SHIELD_GAUGE_Y+5)
- #define SB_SHIELD_NUM_X (SB_SHIELD_GAUGE_X+12) //151
- #define SB_SHIELD_NUM_Y 156
- #define NUMERICAL_GAUGE_X 154
- #define NUMERICAL_GAUGE_Y 130
- #define NUMERICAL_GAUGE_W 19
- #define NUMERICAL_GAUGE_H 22
- #define PRIMARY_W_PIC_X 64
- #define PRIMARY_W_PIC_Y 154
- #define PRIMARY_W_TEXT_X 87
- #define PRIMARY_W_TEXT_Y 157
- #define PRIMARY_AMMO_X (96-3)
- #define PRIMARY_AMMO_Y 171
- #define SECONDARY_W_PIC_X 234
- #define SECONDARY_W_PIC_Y 154
- #define SECONDARY_W_TEXT_X 207
- #define SECONDARY_W_TEXT_Y 157
- #define SECONDARY_AMMO_X 213
- #define SECONDARY_AMMO_Y 171
- #define SB_LIVES_X 266
- #define SB_LIVES_Y 185
- #define SB_LIVES_LABEL_X 237
- #define SB_LIVES_LABEL_Y (SB_LIVES_Y+1)
- #define SB_SCORE_RIGHT 301
- #define SB_SCORE_Y 158
- #define SB_SCORE_LABEL_X 237
- #define SB_SCORE_ADDED_RIGHT 301
- #define SB_SCORE_ADDED_Y 165
- static int score_display;
- static fix score_time;
- static int old_score = -1;
- static int old_energy = -1;
- static int old_shields = -1;
- static int old_laser = -1;
- static int old_flags = -1;
- static int invulnerable_frame = 0;
- static int old_weapon[2] = {-1,-1};
- static int old_ammo_count[2] = {-1,-1};
- static int old_cloak = 0;
- static int old_lives = -1;
- static int cloak_fade_state; //0=steady, -1 fading out, 1 fading in
- #define WS_SET 0 //in correct state
- #define WS_FADING_OUT 1
- #define WS_FADING_IN 2
- int weapon_box_states[2];
- fix weapon_box_fade_values[2];
- #define FADE_SCALE (2*i2f(GR_FADE_LEVELS)/REARM_TIME) // fade out and back in REARM_TIME, in fade levels per seconds (int)
- typedef struct span {
- byte l,r;
- } span;
- //store delta x values from left of box
- span weapon_window_left[] = { //first span 67,154
- {4,53},
- {4,53},
- {4,53},
- {4,53},
- {4,53},
- {3,53},
- {3,53},
- {3,53},
- {3,53},
- {3,53},
- {3,53},
- {3,53},
- {3,53},
- {2,53},
- {2,53},
- {2,53},
- {2,53},
- {2,53},
- {2,53},
- {2,53},
- {2,53},
- {1,53},
- {1,53},
- {1,53},
- {1,53},
- {1,53},
- {1,53},
- {1,53},
- {1,53},
- {0,53},
- {0,53},
- {0,53},
- {0,53},
- {0,52},
- {1,52},
- {2,51},
- {3,51},
- {4,50},
- {5,50},
- };
- //store delta x values from left of box
- span weapon_window_right[] = { //first span 207,154
- {208-202,255-202},
- {206-202,257-202},
- {205-202,258-202},
- {204-202,259-202},
- {203-202,260-202},
- {203-202,260-202},
- {203-202,260-202},
- {203-202,260-202},
- {203-202,260-202},
- {203-202,261-202},
- {203-202,261-202},
- {203-202,261-202},
- {203-202,261-202},
- {203-202,261-202},
- {203-202,261-202},
- {203-202,261-202},
- {203-202,261-202},
- {203-202,261-202},
- {203-202,262-202},
- {203-202,262-202},
- {203-202,262-202},
- {203-202,262-202},
- {203-202,262-202},
- {203-202,262-202},
- {203-202,262-202},
- {203-202,262-202},
- {204-202,263-202},
- {204-202,263-202},
- {204-202,263-202},
- {204-202,263-202},
- {204-202,263-202},
- {204-202,263-202},
- {204-202,263-202},
- {204-202,263-202},
- {204-202,263-202},
- {204-202,263-202},
- {204-202,263-202},
- {204-202,263-202},
- {205-202,263-202},
- {206-202,262-202},
- {207-202,261-202},
- {208-202,260-202},
- {211-202,255-202},
- };
-
- #define N_LEFT_WINDOW_SPANS (sizeof(weapon_window_left)/sizeof(*weapon_window_left))
- #define N_RIGHT_WINDOW_SPANS (sizeof(weapon_window_right)/sizeof(*weapon_window_right))
- #define PRIMARY_W_BOX_LEFT 63
- #define PRIMARY_W_BOX_TOP 154
- #define PRIMARY_W_BOX_RIGHT (PRIMARY_W_BOX_LEFT+58)
- #define PRIMARY_W_BOX_BOT (PRIMARY_W_BOX_TOP+N_LEFT_WINDOW_SPANS-1)
-
- #define SECONDARY_W_BOX_LEFT 202 //207
- #define SECONDARY_W_BOX_TOP 151
- #define SECONDARY_W_BOX_RIGHT 263 //(SECONDARY_W_BOX_LEFT+54)
- #define SECONDARY_W_BOX_BOT (SECONDARY_W_BOX_TOP+N_RIGHT_WINDOW_SPANS-1)
- #define SB_PRIMARY_W_BOX_LEFT 34 //50
- #define SB_PRIMARY_W_BOX_TOP 153
- #define SB_PRIMARY_W_BOX_RIGHT (SB_PRIMARY_W_BOX_LEFT+53)
- #define SB_PRIMARY_W_BOX_BOT (195)
-
- #define SB_SECONDARY_W_BOX_LEFT 169 //210
- #define SB_SECONDARY_W_BOX_TOP 153
- #define SB_SECONDARY_W_BOX_RIGHT (SB_SECONDARY_W_BOX_LEFT+54)
- #define SB_SECONDARY_W_BOX_BOT (153+43)
- #define SB_PRIMARY_W_PIC_X (SB_PRIMARY_W_BOX_LEFT+1) //51
- #define SB_PRIMARY_W_PIC_Y 154
- #define SB_PRIMARY_W_TEXT_X (SB_PRIMARY_W_BOX_LEFT+24) //(51+23)
- #define SB_PRIMARY_W_TEXT_Y 157
- #define SB_PRIMARY_AMMO_X ((SB_PRIMARY_W_BOX_LEFT+33)-3) //(51+32)
- #define SB_PRIMARY_AMMO_Y 171
- #define SB_SECONDARY_W_PIC_X (SB_SECONDARY_W_BOX_LEFT+29) //(212+27)
- #define SB_SECONDARY_W_PIC_Y 154
- #define SB_SECONDARY_W_TEXT_X (SB_SECONDARY_W_BOX_LEFT+2) //212
- #define SB_SECONDARY_W_TEXT_Y 157
- #define SB_SECONDARY_AMMO_X (SB_SECONDARY_W_BOX_LEFT+11) //(212+9)
- #define SB_SECONDARY_AMMO_Y 171
- typedef struct gauge_box {
- int left,top;
- int right,bot; //maximal box
- span *spanlist; //list of left,right spans for copy
- } gauge_box;
- //first two are primary & secondary
- //seconds two are the same for the status bar
- gauge_box gauge_boxes[] = {
- {PRIMARY_W_BOX_LEFT,PRIMARY_W_BOX_TOP,PRIMARY_W_BOX_RIGHT,PRIMARY_W_BOX_BOT,weapon_window_left},
- {SECONDARY_W_BOX_LEFT,SECONDARY_W_BOX_TOP,SECONDARY_W_BOX_RIGHT,SECONDARY_W_BOX_BOT,weapon_window_right},
- {SB_PRIMARY_W_BOX_LEFT,SB_PRIMARY_W_BOX_TOP,SB_PRIMARY_W_BOX_RIGHT,SB_PRIMARY_W_BOX_BOT,NULL},
- {SB_SECONDARY_W_BOX_LEFT,SB_SECONDARY_W_BOX_TOP,SB_SECONDARY_W_BOX_RIGHT,SB_SECONDARY_W_BOX_BOT,NULL}
- };
- int Color_0_31_0 = -1;
- //copy a box from the off-screen buffer to the visible page
- copy_gauge_box(gauge_box *box,grs_bitmap *bm)
- {
- if (box->spanlist) {
- int n_spans = box->bot-box->top+1;
- int cnt,y;
- //gr_setcolor(BM_XRGB(31,0,0));
- for (cnt=0,y=box->top;cnt<n_spans;cnt++,y++)
- gr_bm_ubitblt(box->spanlist[cnt].r-box->spanlist[cnt].l+1,1,
- box->left+box->spanlist[cnt].l,y,box->left+box->spanlist[cnt].l,y,bm,&grd_curcanv->cv_bitmap);
- //gr_scanline(box->left+box->spanlist[cnt].l,box->left+box->spanlist[cnt].r,y);
- }
- else
- gr_bm_ubitblt(box->right-box->left+1,box->bot-box->top+1,
- box->left,box->top,box->left,box->top,
- bm,&grd_curcanv->cv_bitmap);
- }
- //fills in the coords of the hostage video window
- get_hostage_window_coords(int *x,int *y,int *w,int *h)
- {
- if (Cockpit_mode == CM_STATUS_BAR) {
- *x = SB_SECONDARY_W_BOX_LEFT;
- *y = SB_SECONDARY_W_BOX_TOP;
- *w = SB_SECONDARY_W_BOX_RIGHT - SB_SECONDARY_W_BOX_LEFT + 1;
- *h = SB_SECONDARY_W_BOX_BOT - SB_SECONDARY_W_BOX_TOP + 1;
- }
- else {
- *x = SECONDARY_W_BOX_LEFT;
- *y = SECONDARY_W_BOX_TOP;
- *w = SECONDARY_W_BOX_RIGHT - SECONDARY_W_BOX_LEFT + 1;
- *h = SECONDARY_W_BOX_BOT - SECONDARY_W_BOX_TOP + 1;
- }
- }
- //these should be in gr.h
- #define cv_w cv_bitmap.bm_w
- #define cv_h cv_bitmap.bm_h
- #define HUD_MESSAGE_LENGTH 150
- #define HUD_MAX_NUM 4
- extern int HUD_nmessages, hud_first; // From hud.c
- extern char HUD_messages[HUD_MAX_NUM][HUD_MESSAGE_LENGTH+5];
- void hud_show_score()
- {
- char score_str[20];
- int w, h, aw;
- if ((HUD_nmessages > 0) && (strlen(HUD_messages[hud_first]) > 38))
- return;
- gr_set_curfont( GAME_FONT );
- if ( ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) ) {
- sprintf(score_str, "%s: %5d", TXT_KILLS, Players[Player_num].net_kills_total);
- } else {
- sprintf(score_str, "%s: %5d", TXT_SCORE, Players[Player_num].score);
- }
- gr_get_string_size(score_str, &w, &h, &aw );
- if (Color_0_31_0 == -1)
- Color_0_31_0 = gr_getcolor(0,31,0);
- gr_set_fontcolor(Color_0_31_0, -1);
- gr_printf(grd_curcanv->cv_w-w-2, 3, score_str);
- }
- void hud_show_score_added()
- {
- int color;
- int w, h, aw;
- char score_str[20];
- if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
- return;
- if (score_display == 0)
- return;
- gr_set_curfont( GAME_FONT );
- score_time -= FrameTime;
- if (score_time > 0) {
- color = f2i(score_time * 20) + 10;
- if (color < 10) color = 10;
- if (color > 31) color = 31;
- if (Cheats_enabled)
- sprintf(score_str, "%s", TXT_CHEATER);
- else
- sprintf(score_str, "%5d", score_display);
- gr_get_string_size(score_str, &w, &h, &aw );
- gr_set_fontcolor(gr_getcolor(0, color, 0),-1 );
- gr_printf(grd_curcanv->cv_w-w-2-10, GAME_FONT->ft_h+5, score_str);
- } else {
- score_time = 0;
- score_display = 0;
- }
-
- }
- void sb_show_score()
- {
- char score_str[20];
- int x,y;
- int w, h, aw;
- static int last_x=SB_SCORE_RIGHT;
- int redraw_score;
- if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
- redraw_score = -99;
- else
- redraw_score = -1;
- if (old_score==redraw_score) {
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
- if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
- gr_printf(SB_SCORE_LABEL_X,SB_SCORE_Y,"%s:", TXT_KILLS);
- else
- gr_printf(SB_SCORE_LABEL_X,SB_SCORE_Y,"%s:", TXT_SCORE);
- }
- gr_set_curfont( GAME_FONT );
- if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
- sprintf(score_str, "%5d", Players[Player_num].net_kills_total);
- else
- sprintf(score_str, "%5d", Players[Player_num].score);
- gr_get_string_size(score_str, &w, &h, &aw );
- x = SB_SCORE_RIGHT-w-2;
- y = SB_SCORE_Y;
- //erase old score
- gr_setcolor(BM_XRGB(0,0,0));
- gr_rect(last_x,y,SB_SCORE_RIGHT,y+GAME_FONT->ft_h);
- if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
- gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
- else
- gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
- gr_printf(x,y,score_str);
- last_x = x;
- }
- void sb_show_score_added()
- {
- int color;
- int w, h, aw;
- char score_str[32];
- int x;
- static int last_x=SB_SCORE_ADDED_RIGHT;
- static int last_score_display = -1;
- if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) )
- return;
- if (score_display == 0)
- return;
- gr_set_curfont( GAME_FONT );
- score_time -= FrameTime;
- if (score_time > 0) {
- if (score_display != last_score_display) {
- gr_setcolor(BM_XRGB(0,0,0));
- gr_rect(last_x,SB_SCORE_ADDED_Y,SB_SCORE_ADDED_RIGHT,SB_SCORE_ADDED_Y+GAME_FONT->ft_h);
- last_score_display = score_display;
- }
- color = f2i(score_time * 20) + 10;
- if (color < 10) color = 10;
- if (color > 31) color = 31;
- if (Cheats_enabled)
- sprintf(score_str, "%s", TXT_CHEATER);
- else
- sprintf(score_str, "%5d", score_display);
- gr_get_string_size(score_str, &w, &h, &aw );
- x = SB_SCORE_ADDED_RIGHT-w-2;
- gr_set_fontcolor(gr_getcolor(0, color, 0),-1 );
- gr_printf(x, SB_SCORE_ADDED_Y, score_str);
- last_x = x;
- } else {
- //erase old score
- gr_setcolor(BM_XRGB(0,0,0));
- gr_rect(last_x,SB_SCORE_ADDED_Y,SB_SCORE_ADDED_RIGHT,SB_SCORE_ADDED_Y+GAME_FONT->ft_h);
- score_time = 0;
- score_display = 0;
- }
-
- }
- fix Last_warning_beep_time = 0; // Time we last played homing missile warning beep.
- // -----------------------------------------------------------------------------
- void play_homing_warning(void)
- {
- fix beep_delay;
- if (Endlevel_sequence || Player_is_dead)
- return;
- if (Players[Player_num].homing_object_dist >= 0) {
- beep_delay = Players[Player_num].homing_object_dist/128;
- if (beep_delay > F1_0)
- beep_delay = F1_0;
- else if (beep_delay < F1_0/8)
- beep_delay = F1_0/8;
- if (GameTime - Last_warning_beep_time > beep_delay/2) {
- digi_play_sample( SOUND_HOMING_WARNING, F1_0 );
- Last_warning_beep_time = GameTime;
- }
- }
- }
- int Last_homing_warning_shown=-1;
- // -----------------------------------------------------------------------------
- void show_homing_warning(void)
- {
- if ((Cockpit_mode == CM_STATUS_BAR) || (Endlevel_sequence)) {
- if (Last_homing_warning_shown == 1) {
- PIGGY_PAGE_IN( Gauges[GAUGE_HOMING_WARNING_OFF] );
- gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index] );
- Last_homing_warning_shown = 0;
- }
- return;
- }
- gr_set_current_canvas( get_current_game_screen() );
- if (Players[Player_num].homing_object_dist >= 0) {
- if (GameTime & 0x4000) {
- if (Last_homing_warning_shown != 1) {
- PIGGY_PAGE_IN(Gauges[GAUGE_HOMING_WARNING_ON]);
- gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_ON].index]);
- Last_homing_warning_shown = 1;
- }
- } else {
- if (Last_homing_warning_shown != 0) {
- PIGGY_PAGE_IN(Gauges[GAUGE_HOMING_WARNING_OFF]);
- gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index] );
- Last_homing_warning_shown = 0;
- }
- }
- } else if (Last_homing_warning_shown != 0) {
- PIGGY_PAGE_IN(Gauges[GAUGE_HOMING_WARNING_OFF]);
- gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index] );
- Last_homing_warning_shown = 0;
- }
- }
- #define MAX_SHOWN_LIVES 4
- void hud_show_homing_warning(void)
- {
- if (Players[Player_num].homing_object_dist >= 0) {
- if (GameTime & 0x4000) {
- gr_set_current_canvas(&VR_render_sub_buffer[0]); //render off-screen
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
- gr_printf(0x8000, grd_curcanv->cv_h-8,TXT_LOCK);
- }
- }
- }
- void hud_show_keys(void)
- {
- if (Players[Player_num].flags & PLAYER_FLAGS_BLUE_KEY) {
- PIGGY_PAGE_IN(Gauges[KEY_ICON_BLUE]);
- gr_ubitmapm(2,24,&GameBitmaps[Gauges[KEY_ICON_BLUE].index]);
- }
- if (Players[Player_num].flags & PLAYER_FLAGS_GOLD_KEY) {
- PIGGY_PAGE_IN(Gauges[KEY_ICON_YELLOW]);
- gr_ubitmapm(10,24,&GameBitmaps[Gauges[KEY_ICON_YELLOW].index]);
- }
- if (Players[Player_num].flags & PLAYER_FLAGS_RED_KEY) {
- PIGGY_PAGE_IN(Gauges[KEY_ICON_RED]);
- gr_ubitmapm(18,24,&GameBitmaps[Gauges[KEY_ICON_RED].index]);
- }
- }
- void hud_show_energy(void)
- {
- gr_set_current_canvas(&VR_render_sub_buffer[0]); //render off-screen
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
- if (Game_mode & GM_MULTI)
- gr_printf(2, grd_curcanv->cv_h-40,"%s: %i", TXT_ENERGY, f2ir(Players[Player_num].energy));
- else
- gr_printf(2, grd_curcanv->cv_h-8,"%s: %i", TXT_ENERGY, f2ir(Players[Player_num].energy));
- if (Newdemo_state==ND_STATE_RECORDING ) {
- int energy = f2ir(Players[Player_num].energy);
- if (energy != old_energy) {
- #ifdef SHAREWARE
- newdemo_record_player_energy(energy);
- #else
- newdemo_record_player_energy(old_energy, energy);
- #endif
- old_energy = energy;
- }
- }
- }
- void hud_show_weapons(void)
- {
- int w, h, aw;
- int y;
- char weapon_str[32], temp_str[10];
- gr_set_current_canvas(&VR_render_sub_buffer[0]); //render off-screen
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
- if (Game_mode & GM_MULTI)
- y = grd_curcanv->cv_h-32;
- else
- y = grd_curcanv->cv_h;
- // #ifndef RELEASE
- y -= 8;
- // #endif
- switch (Primary_weapon) {
- case 0:
- if (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS)
- sprintf(weapon_str, "%s %s %i", TXT_QUAD, TXT_LASER, Players[Player_num].laser_level+1);
- else
- sprintf(weapon_str, "%s %i", TXT_LASER, Players[Player_num].laser_level+1);
- break;
- case 1:
- sprintf(weapon_str, "%s: %i", TXT_W_VULCAN_S, f2i(Players[Player_num].primary_ammo[Primary_weapon] * VULCAN_AMMO_SCALE));
- break;
- case 2:
- strcpy(weapon_str, TXT_W_SPREADFIRE_S);
- break;
- #ifndef SHAREWARE
- case 3:
- strcpy(weapon_str, TXT_W_PLASMA_S);
- break;
- case 4:
- strcpy(weapon_str, TXT_W_FUSION_S);
- break;
- #endif
- }
- gr_get_string_size(weapon_str, &w, &h, &aw );
- gr_printf(315-w, y-8, weapon_str);
- if (Primary_weapon == VULCAN_INDEX) {
- #ifndef SHAREWARE
- if (Players[Player_num].primary_ammo[Primary_weapon] != old_ammo_count[0]) {
- if (Newdemo_state == ND_STATE_RECORDING)
- newdemo_record_primary_ammo(old_ammo_count[0], Players[Player_num].primary_ammo[Primary_weapon]);
- old_ammo_count[0] = Players[Player_num].primary_ammo[Primary_weapon];
- }
- #endif
- }
- switch (Secondary_weapon) {
- case 0: strcpy(weapon_str, TXT_CONCUSSION); break;
- case 1: strcpy(weapon_str, TXT_HOMING); break;
- case 2: strcpy(weapon_str, TXT_PROXBOMB ); break;
- #ifndef SHAREWARE
- case 3: strcpy(weapon_str, TXT_SMART); break;
- case 4: strcpy(weapon_str, TXT_MEGA); break;
- #endif
- default: Int3(); weapon_str[0] = 0; break;
- }
- #ifndef SHAREWARE
- if (Players[Player_num].secondary_ammo[Secondary_weapon] != old_ammo_count[1]) {
- if (Newdemo_state == ND_STATE_RECORDING)
- newdemo_record_secondary_ammo(old_ammo_count[1], Players[Player_num].secondary_ammo[Secondary_weapon]);
- old_ammo_count[1] = Players[Player_num].secondary_ammo[Secondary_weapon];
- }
- #endif
- strcat(weapon_str, " ");
- strcat(weapon_str, itoa(Players[Player_num].secondary_ammo[Secondary_weapon], temp_str, 10));
- gr_get_string_size(weapon_str, &w, &h, &aw );
- gr_printf(315-w, y, weapon_str);
- }
- void hud_show_cloak_invuln(void)
- {
- if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
- int y = grd_curcanv->cv_h;
- if (Game_mode & GM_MULTI)
- y -= 72;
- else
- y -= 32;
- if ((Players[Player_num].cloak_time+CLOAK_TIME_MAX - GameTime > F1_0*3 ) || (GameTime & 0x8000))
- gr_printf(2, y, "%s", TXT_CLOAKED);
- }
- if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
- int y = grd_curcanv->cv_h;
- if (Game_mode & GM_MULTI)
- y -= 80;
- else
- y -= 40;
- if (((Players[Player_num].invulnerable_time + INVULNERABLE_TIME_MAX - GameTime) > F1_0*4) || (GameTime & 0x8000))
- gr_printf(2, y, "%s", TXT_INVULNERABLE);
- }
- }
- void hud_show_shield(void)
- {
- gr_set_current_canvas(&VR_render_sub_buffer[0]); //render off-screen
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
- if (Game_mode & GM_MULTI)
- gr_printf(2, grd_curcanv->cv_h-48,"%s: %i", TXT_SHIELD, f2ir(Players[Player_num].shields));
- else
- gr_printf(2, grd_curcanv->cv_h-16,"%s: %i", TXT_SHIELD, f2ir(Players[Player_num].shields));
- if (Newdemo_state==ND_STATE_RECORDING ) {
- int shields = f2ir(Players[Player_num].shields);
- if (shields != old_shields) { // Draw the shield gauge
- #ifdef SHAREWARE
- newdemo_record_player_shields(shields);
- #else
- newdemo_record_player_shields(old_shields, shields);
- #endif
- old_shields = shields;
- }
- }
- }
- //draw the icons for number of lives
- hud_show_lives()
- {
- if ((HUD_nmessages > 0) && (strlen(HUD_messages[hud_first]) > 38))
- return;
- if (Game_mode & GM_MULTI) {
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
- gr_printf(10, 3, "%s: %d", TXT_DEATHS, Players[Player_num].net_killed_total);
- }
- else if (Players[Player_num].lives > 1) {
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
- PIGGY_PAGE_IN(Gauges[GAUGE_LIVES]);
- gr_ubitmapm(10,3,&GameBitmaps[Gauges[GAUGE_LIVES].index]);
- gr_printf(22, 3, "x %d", Players[Player_num].lives-1);
- }
- }
- sb_show_lives()
- {
- int x,y;
- grs_bitmap * bm = &GameBitmaps[Gauges[GAUGE_LIVES].index];
- x = SB_LIVES_X;
- y = SB_LIVES_Y;
- if (old_lives==-1) {
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
- if (Game_mode & GM_MULTI)
- gr_printf(SB_LIVES_LABEL_X,SB_LIVES_LABEL_Y,"%s:", TXT_DEATHS);
- else
- gr_printf(SB_LIVES_LABEL_X,SB_LIVES_LABEL_Y,"%s:", TXT_LIVES);
- }
- if (Game_mode & GM_MULTI)
- {
- char killed_str[20];
- int w, h, aw;
- static int last_x = SB_SCORE_RIGHT;
- int x;
- sprintf(killed_str, "%5d", Players[Player_num].net_killed_total);
- gr_get_string_size(killed_str, &w, &h, &aw);
- gr_setcolor(BM_XRGB(0,0,0));
- gr_rect(last_x, y+1, SB_SCORE_RIGHT, y+GAME_FONT->ft_h);
- gr_set_fontcolor(gr_getcolor(0,20,0),-1);
- x = SB_SCORE_RIGHT-w-2;
- gr_printf(x, y+1, killed_str);
- last_x = x;
- return;
- }
- if (old_lives==-1 || Players[Player_num].lives != old_lives) {
- //erase old icons
- gr_setcolor(BM_XRGB(0,0,0));
- gr_rect(x, y, x+32, y+bm->bm_h);
- if (Players[Player_num].lives-1 > 0) {
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
- PIGGY_PAGE_IN(Gauges[GAUGE_LIVES]);
- gr_ubitmapm(x, y,bm);
- gr_printf(x+12, y, "x %d", Players[Player_num].lives-1);
- }
- }
- // for (i=0;i<draw_count;i++,x+=bm->bm_w+2)
- // gr_ubitmapm(x,y,bm);
- }
- #ifndef RELEASE
- #ifdef PIGGY_USE_PAGING
- extern int Piggy_bitmap_cache_next;
- #endif
- void show_time()
- {
- int secs = f2i(Players[Player_num].time_level) % 60;
- int mins = f2i(Players[Player_num].time_level) / 60;
- gr_set_curfont( GAME_FONT );
- if (Color_0_31_0 == -1)
- Color_0_31_0 = gr_getcolor(0,31,0);
- gr_set_fontcolor(Color_0_31_0, -1 );
- gr_printf(grd_curcanv->cv_w-25,grd_curcanv->cv_h-28,"%d:%02d", mins, secs);
- #ifdef PIGGY_USE_PAGING
- {
- char text[25];
- int w,h,aw;
- sprintf( text, "%d KB", Piggy_bitmap_cache_next/1024 );
- gr_get_string_size( text, &w, &h, &aw );
- gr_printf(grd_curcanv->cv_w-10-w,grd_curcanv->cv_h/2, text );
- }
- #endif
- }
- #endif
- #define EXTRA_SHIP_SCORE 50000 //get new ship every this many points
- void add_points_to_score(int points)
- {
- int prev_score;
- score_time += f1_0*2;
- score_display += points;
- if (score_time > f1_0*4) score_time = f1_0*4;
- if (points == 0 || Cheats_enabled)
- return;
- if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))
- return;
- prev_score=Players[Player_num].score;
- Players[Player_num].score += points;
- #ifndef SHAREWARE
- if (Newdemo_state == ND_STATE_RECORDING)
- newdemo_record_player_score(points);
- #endif
- #ifndef SHAREWARE
- if (Game_mode & GM_MULTI_COOP)
- multi_send_score();
- #endif
- if (Game_mode & GM_MULTI)
- return;
- if (Players[Player_num].score/EXTRA_SHIP_SCORE != prev_score/EXTRA_SHIP_SCORE) {
- int snd;
- Players[Player_num].lives += Players[Player_num].score/EXTRA_SHIP_SCORE - prev_score/EXTRA_SHIP_SCORE;
- powerup_basic(20, 20, 20, 0, TXT_EXTRA_LIFE);
- if ((snd=Powerup_info[POW_EXTRA_LIFE].hit_sound) > -1 )
- digi_play_sample( snd, F1_0 );
- }
- }
- void add_bonus_points_to_score(int points)
- {
- int prev_score;
- if (points == 0 || Cheats_enabled)
- return;
- prev_score=Players[Player_num].score;
- Players[Player_num].score += points;
- #ifndef SHAREWARE
- if (Newdemo_state == ND_STATE_RECORDING)
- newdemo_record_player_score(points);
- #endif
- if (Game_mode & GM_MULTI)
- return;
- if (Players[Player_num].score/EXTRA_SHIP_SCORE != prev_score/EXTRA_SHIP_SCORE) {
- int snd;
- Players[Player_num].lives += Players[Player_num].score/EXTRA_SHIP_SCORE - prev_score/EXTRA_SHIP_SCORE;
- if ((snd=Powerup_info[POW_EXTRA_LIFE].hit_sound) > -1 )
- digi_play_sample( snd, F1_0 );
- }
- }
- void init_gauge_canvases()
- {
- Canv_LeftEnergyGauge = gr_create_canvas( LEFT_ENERGY_GAUGE_W, LEFT_ENERGY_GAUGE_H );
- Canv_SBEnergyGauge = gr_create_canvas( SB_ENERGY_GAUGE_W, SB_ENERGY_GAUGE_H );
- Canv_RightEnergyGauge = gr_create_canvas( RIGHT_ENERGY_GAUGE_W, RIGHT_ENERGY_GAUGE_H );
- Canv_NumericalGauge = gr_create_canvas( NUMERICAL_GAUGE_W, NUMERICAL_GAUGE_H );
- }
- void close_gauge_canvases()
- {
- gr_free_canvas( Canv_LeftEnergyGauge );
- gr_free_canvas( Canv_SBEnergyGauge );
- gr_free_canvas( Canv_RightEnergyGauge );
- gr_free_canvas( Canv_NumericalGauge );
- }
- void init_gauges()
- {
- //draw_gauges_on = 1;
- 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)) )
- old_score = -99;
- else
- old_score = -1;
- old_energy = -1;
- old_shields = -1;
- old_laser = -1;
- old_flags = -1;
- old_cloak = -1;
- old_lives = -1;
- old_weapon[0] = old_weapon[1]= -1;
- old_ammo_count[0] = old_ammo_count[1] = -1;
- cloak_fade_state = 0;
- }
- void draw_energy_bar(int energy)
- {
- int not_energy;
- int x1, x2, y;
- // Draw left energy bar
- gr_set_current_canvas( Canv_LeftEnergyGauge );
- PIGGY_PAGE_IN(Gauges[GAUGE_ENERGY_LEFT]);
- gr_ubitmapm( 0, 0, &GameBitmaps[Gauges[GAUGE_ENERGY_LEFT].index] );
- gr_setcolor( 0 );
- not_energy = 61 - (energy*61)/100;
- if (energy < 100)
- for (y=0; y<8; y++) {
- x1 = 7 - y;
- x2 = 7 - y + not_energy;
-
- if ( y>=0 && y<2 ) if (x2 > LEFT_ENERGY_GAUGE_W - 1) x2 = LEFT_ENERGY_GAUGE_W - 1;
- if ( y>=2 && y<6 ) if (x2 > LEFT_ENERGY_GAUGE_W - 2) x2 = LEFT_ENERGY_GAUGE_W - 2;
- if ( y>=6 ) if (x2 > LEFT_ENERGY_GAUGE_W - 3) x2 = LEFT_ENERGY_GAUGE_W - 3;
-
- if (x2 > x1) gr_uscanline( x1, x2, y );
- }
- gr_set_current_canvas( get_current_game_screen() );
- gr_ubitmapm( LEFT_ENERGY_GAUGE_X, LEFT_ENERGY_GAUGE_Y, &Canv_LeftEnergyGauge->cv_bitmap );
- // Draw right energy bar
- gr_set_current_canvas( Canv_RightEnergyGauge );
- PIGGY_PAGE_IN(Gauges[GAUGE_ENERGY_RIGHT]);
- gr_ubitmapm( 0, 0, &GameBitmaps[Gauges[GAUGE_ENERGY_RIGHT].index] );
- if (energy < 100)
- for (y=0; y<8; y++) {
- x1 = RIGHT_ENERGY_GAUGE_W - 8 + y - not_energy;
- x2 = RIGHT_ENERGY_GAUGE_W - 8 + y;
-
- if ( y>=0 && y<2 ) if (x1 < 0) x1 = 0;
- if ( y>=2 && y<6 ) if (x1 < 1) x1 = 1;
- if ( y>=6 ) if (x1 < 2) x1 = 2;
-
- if (x2 > x1) gr_uscanline( x1, x2, y );
- }
- gr_set_current_canvas( get_current_game_screen() );
- gr_ubitmapm( RIGHT_ENERGY_GAUGE_X, RIGHT_ENERGY_GAUGE_Y, &Canv_RightEnergyGauge->cv_bitmap );
- }
- void draw_shield_bar(int shield)
- {
- int bm_num = shield>=100?9:(shield / 10);
- PIGGY_PAGE_IN(Gauges[GAUGE_SHIELDS+9-bm_num] );
- gr_ubitmapm( SHIELD_GAUGE_X, SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_SHIELDS+9-bm_num].index] );
- }
- #define CLOAK_FADE_WAIT_TIME 0x400
- void draw_player_ship(int cloak_state,int old_cloak_state,int x, int y)
- {
- static fix cloak_fade_timer=0;
- static int cloak_fade_value=GR_FADE_LEVELS-1;
- grs_bitmap *bm;
- if (Game_mode & GM_TEAM) {
- PIGGY_PAGE_IN(Gauges[GAUGE_SHIPS+get_team(Player_num)]);
- bm = &GameBitmaps[Gauges[GAUGE_SHIPS+get_team(Player_num)].index];
- } else {
- PIGGY_PAGE_IN(Gauges[GAUGE_SHIPS+Player_num]);
- bm = &GameBitmaps[Gauges[GAUGE_SHIPS+Player_num].index];
- }
-
- if (old_cloak_state==-1 && cloak_state)
- cloak_fade_value=0;
- if (!cloak_state) {
- cloak_fade_value=GR_FADE_LEVELS-1;
- cloak_fade_state = 0;
- }
- if (cloak_state==1 && old_cloak_state==0)
- cloak_fade_state = -1;
- //else if (cloak_state==0 && old_cloak_state==1)
- // cloak_fade_state = 1;
- if (cloak_state==old_cloak_state) //doing "about-to-uncloak" effect
- if (cloak_fade_state==0)
- cloak_fade_state = 2;
-
- if (cloak_fade_state)
- cloak_fade_timer -= FrameTime;
- while (cloak_fade_state && cloak_fade_timer < 0) {
- cloak_fade_timer += CLOAK_FADE_WAIT_TIME;
- cloak_fade_value += cloak_fade_state;
- if (cloak_fade_value >= GR_FADE_LEVELS-1) {
- cloak_fade_value = GR_FADE_LEVELS-1;
- if (cloak_fade_state == 2 && cloak_state)
- cloak_fade_state = -2;
- else
- cloak_fade_state = 0;
- }
- else if (cloak_fade_value <= 0) {
- cloak_fade_value = 0;
- if (cloak_fade_state == -2)
- cloak_fade_state = 2;
- else
- cloak_fade_state = 0;
- }
- }
- gr_set_current_canvas(&VR_render_buffer[0]);
- gr_ubitmap( x, y, bm);
- Gr_scanline_darkening_level = cloak_fade_value;
- gr_rect(x, y, x+bm->bm_w-1, y+bm->bm_h-1);
- Gr_scanline_darkening_level = GR_FADE_LEVELS;
- gr_set_current_canvas(get_current_game_screen());
- gr_bm_ubitbltm( bm->bm_w, bm->bm_h, x, y, x, y, &VR_render_sub_buffer[0].cv_bitmap, &grd_curcanv->cv_bitmap);
- }
- #define INV_FRAME_TIME (f1_0/10) //how long for each frame
- void draw_numerical_display(int shield, int energy)
- {
- gr_set_current_canvas( Canv_NumericalGauge );
- gr_set_curfont( GAME_FONT );
- PIGGY_PAGE_IN(Gauges[GAUGE_NUMERICAL]);
- gr_ubitmap( 0, 0, &GameBitmaps[Gauges[GAUGE_NUMERICAL].index] );
- gr_set_fontcolor(gr_getcolor(14,14,23),-1 );
- gr_printf((shield>99)?3:((shield>9)?5:7),15,"%d",shield);
- gr_set_fontcolor(gr_getcolor(25,18,6),-1 );
- gr_printf((energy>99)?3:((energy>9)?5:7),2,"%d",energy);
-
- gr_set_current_canvas( get_current_game_screen() );
- gr_ubitmapm( NUMERICAL_GAUGE_X, NUMERICAL_GAUGE_Y, &Canv_NumericalGauge->cv_bitmap );
- }
- void draw_keys()
- {
- gr_set_current_canvas( get_current_game_screen() );
- if (Players[Player_num].flags & PLAYER_FLAGS_BLUE_KEY ) {
- PIGGY_PAGE_IN(Gauges[GAUGE_BLUE_KEY]);
- gr_ubitmapm( GAUGE_BLUE_KEY_X, GAUGE_BLUE_KEY_Y, &GameBitmaps[Gauges[GAUGE_BLUE_KEY].index] );
- } else {
- PIGGY_PAGE_IN(Gauges[GAUGE_BLUE_KEY_OFF]);
- gr_ubitmapm( GAUGE_BLUE_KEY_X, GAUGE_BLUE_KEY_Y, &GameBitmaps[Gauges[GAUGE_BLUE_KEY_OFF].index] );
- }
- if (Players[Player_num].flags & PLAYER_FLAGS_GOLD_KEY) {
- PIGGY_PAGE_IN(Gauges[GAUGE_GOLD_KEY]);
- gr_ubitmapm( GAUGE_GOLD_KEY_X, GAUGE_GOLD_KEY_Y, &GameBitmaps[Gauges[GAUGE_GOLD_KEY].index] );
- } else {
- PIGGY_PAGE_IN(Gauges[GAUGE_GOLD_KEY_OFF]);
- gr_ubitmapm( GAUGE_GOLD_KEY_X, GAUGE_GOLD_KEY_Y, &GameBitmaps[Gauges[GAUGE_GOLD_KEY_OFF].index] );
- }
- if (Players[Player_num].flags & PLAYER_FLAGS_RED_KEY) {
- PIGGY_PAGE_IN( Gauges[GAUGE_RED_KEY] );
- gr_ubitmapm( GAUGE_RED_KEY_X, GAUGE_RED_KEY_Y, &GameBitmaps[Gauges[GAUGE_RED_KEY].index] );
- } else {
- PIGGY_PAGE_IN(Gauges[GAUGE_RED_KEY_OFF]);
- gr_ubitmapm( GAUGE_RED_KEY_X, GAUGE_RED_KEY_Y, &GameBitmaps[Gauges[GAUGE_RED_KEY_OFF].index] );
- }
- }
- draw_weapon_info_sub(int info_index,gauge_box *box,int pic_x,int pic_y,char *name,int text_x,int text_y)
- {
- grs_bitmap *bm;
- char *p;
- //clear the window
- gr_setcolor(BM_XRGB(0,0,0));
- gr_rect(box->left,box->top,box->right,box->bot);
- bm=&GameBitmaps[Weapon_info[info_index].picture.index];
- Assert(bm != NULL);
- PIGGY_PAGE_IN( Weapon_info[info_index].picture );
- gr_ubitmapm(pic_x,pic_y,bm);
- gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
- if ((p=strchr(name,'\n'))!=NULL) {
- *p=0;
- gr_printf(text_x,text_y,name);
- gr_printf(text_x,text_y+grd_curcanv->cv_font->ft_h+1,p+1);
- *p='\n';
- } else
- gr_printf(text_x,text_y,name);
- // For laser, show level and quadness
- if (info_index == 0) {
- char temp_str[7];
- sprintf(temp_str, "%s: 0", TXT_LVL);
- temp_str[5] = Players[Player_num].laser_level+1 + '0';
- gr_printf(text_x,text_y+8, temp_str);
- if (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS) {
- strcpy(temp_str, TXT_QUAD);
- gr_printf(text_x,text_y+16, temp_str);
- }
- }
- }
- draw_weapon_info(int weapon_type,int weapon_num)
- {
- #ifdef SHAREWARE
- if (Newdemo_state==ND_STATE_RECORDING )
- newdemo_record_player_weapon(weapon_type, weapon_num);
- #endif
- if (weapon_type == 0)
- if (Cockpit_mode == CM_STATUS_BAR)
- draw_weapon_info_sub(Primary_weapon_to_weapon_info[weapon_num],
- &gauge_boxes[2],
- SB_PRIMARY_W_PIC_X,SB_PRIMARY_W_PIC_Y,
- PRIMARY_WEAPON_NAMES_SHORT(weapon_num),
- SB_PRIMARY_W_TEXT_X,SB_PRIMARY_W_TEXT_Y);
- else
- draw_weapon_info_sub(Primary_weapon_to_weapon_info[weapon_num],
- &gauge_boxes[0],
- PRIMARY_W_PIC_X,PRIMARY_W_PIC_Y,
- PRIMARY_WEAPON_NAMES_SHORT(weapon_num),
- PRIMARY_W_TEXT_X,PRIMARY_W_TEXT_Y);
- else
- if (Cockpit_mode == CM_STATUS_BAR)
- draw_weapon_info_sub(Secondary_weapon_to_weapon_info[weapon_num],
- &gauge_boxes[3],
- SB_SECONDARY_W_PIC_X,SB_SECONDARY_W_PIC_Y,
- SECONDARY_WEAPON_NAMES_SHORT(weapon_num),
- SB_SECONDARY_W_TEXT_X,SB_SECONDARY_W_TEXT_Y);
- else
- draw_weapon_info_sub(Secondary_weapon_to_weapon_info[weapon_num],
- &gauge_boxes[1],
- SECONDARY_W_PIC_X,SECONDARY_W_PIC_Y,
- SECONDARY_WEAPON_NAMES_SHORT(weapon_num),
- SECONDARY_W_TEXT_X,SECONDARY_W_TEXT_Y);
- }
- draw_ammo_info(int x,int y,int ammo_count,int primary)
- {
- int w;
- if (primary)
- w = (grd_curcanv->cv_font->ft_w*6)/2;
- else
- w = (grd_curcanv->cv_font->ft_w*5)/2;
- gr_setcolor(BM_XRGB(0,0,0));
- gr_rect(x,y,x+w,y+grd_curcanv->cv_font->ft_h);
- gr_set_fontcolor(gr_getcolor(20,0,0),-1 );
- gr_printf(x,y,"%03d",ammo_count);
- }
- draw_primary_ammo_info(int ammo_count)
- {
- if (Cockpit_mode == CM_STATUS_BAR)
- draw_ammo_info(SB_PRIMARY_AMMO_X,SB_PRIMARY_AMMO_Y,ammo_count,1);
- else
- draw_ammo_info(PRIMARY_AMMO_X,PRIMARY_AMMO_Y,ammo_count,1);
- }
- draw_secondary_ammo_info(int ammo_count)
- {
- if (Cockpit_mode == CM_STATUS_BAR)
- draw_ammo_info(SB_SECONDARY_AMMO_X,SB_SECONDARY_AMMO_Y,ammo_count,0);
- else
- draw_ammo_info(SECONDARY_AMMO_X,SECONDARY_AMMO_Y,ammo_count,0);
- }
- //returns true if drew picture
- int draw_weapon_box(int weapon_type,int weapon_num)
- {
- int drew_flag=0;
- gr_set_current_canvas(&VR_render_buffer[0]);
- gr_set_curfont( GAME_FONT );
- if (weapon_num != old_weapon[weapon_type] && weapon_box_states[weapon_type] == WS_SET) {
- weapon_box_states[weapon_type] = WS_FADING_OUT;
- weapon_box_fade_values[weapon_type]=i2f(GR_FADE_LEVELS-1);
- }
-
- if (old_weapon[weapon_type] == -1) {
- draw_weapon_info(weapon_type,weapon_num);
- old_weapon[weapon_type] = weapon_num;
- old_ammo_count[weapon_type]=-1;
- drew_flag=1;
- weapon_box_states[weapon_type] = WS_SET;
- }
- if (weapon_box_states[weapon_type] == WS_FADING_OUT) {
- draw_weapon_info(weapon_type,old_weapon[weapon_type]);
- old_ammo_count[weapon_type]=-1;
- drew_flag=1;
- weapon_box_fade_values[weapon_type] -= FrameTime * FADE_SCALE;
- if (weapon_box_fade_values[weapon_type] <= 0) {
- weapon_box_states[weapon_type] = WS_FADING_IN;
- old_weapon[weapon_type] = weapon_num;
- weapon_box_fade_values[weapon_type] = 0;
- }
- }
- else if (weapon_box_states[weapon_type] == WS_FADING_IN) {
- if (weapon_num != old_weapon[weapon_type]) {
- weapon_box_states[weapon_type] = WS_FADING_OUT;
- }
- else {
- draw_weapon_info(weapon_type,weapon_num);
- old_ammo_count[weapon_type]=-1;
- drew_flag=1;
- weapon_box_fade_values[weapon_type] += FrameTime * FADE_SCALE;
- if (weapon_box_fade_values[weapon_type] >= i2f(GR_FADE_LEVELS-1))
- weapon_box_states[weapon_type] = WS_SET;
- }
- }
- if (weapon_box_states[weapon_type] != WS_SET) { //fade gauge
- int fade_value = f2i(weapon_box_fade_values[weapon_type]);
- int boxofs = (Cockpit_mode==CM_STATUS_BAR)?2:0;
- Gr_scanline_darkening_level = fade_value;
- 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);
- Gr_scanline_darkening_level = GR_FADE_LEVELS;
- }
- gr_set_current_canvas(get_current_game_screen());
- return drew_flag;
- }
- draw_weapon_boxes()
- {
- int boxofs = (Cockpit_mode==CM_STATUS_BAR)?2:0;
- int drew;
- drew = draw_weapon_box(0,Primary_weapon);
- if (drew) copy_gauge_box(&gauge_boxes[boxofs+0],&VR_render_buffer[0].cv_bitmap);
- if (weapon_box_states[0] == WS_SET)
- if (Players[Player_num].primary_ammo[Primary_weapon] != old_ammo_count[0]) {
- if (Primary_weapon == VULCAN_INDEX) {
- #ifndef SHAREWARE
- if (Newdemo_state == ND_STATE_RECORDING)
- newdemo_record_primary_ammo(old_ammo_count[0], Players[Player_num].primary_ammo[Primary_weapon]);
- #endif
- draw_primary_ammo_info(f2i(VULCAN_AMMO_SCALE * Players[Player_num].primary_ammo[Primary_weapon]));
- old_ammo_count[0] = Players[Player_num].primary_ammo[Primary_weapon];
- }
- }
- if (!hostage_is_vclip_playing()) {
- drew = draw_weapon_box(1,Secondary_weapon);
- if (drew) copy_gauge_box(&gauge_boxes[boxofs+1],&VR_render_buffer[0].cv_bitmap);
- if (weapon_box_states[1] == WS_SET)
- if (Players[Player_num].secondary_ammo[Secondary_weapon] != old_ammo_count[1]) {
- #ifndef SHAREWARE
- if (Newdemo_state == ND_STATE_RECORDING)
- newdemo_record_secondary_ammo(old_ammo_count[1], Players[Player_num].secondary_ammo[Secondary_weapon]);
- #endif
- draw_secondary_ammo_info(Players[Player_num].secondary_ammo[Secondary_weapon]);
- old_ammo_count[1] = Players[Player_num].secondary_ammo[Secondary_weapon];
- }
- }
- }
- sb_draw_energy_bar(energy)
- {
- int erase_height;
- gr_set_current_canvas( Canv_SBEnergyGauge );
- PIGGY_PAGE_IN(Gauges[SB_GAUGE_ENERGY]);
- gr_ubitmapm( 0, 0, &GameBitmaps[Gauges[SB_GAUGE_ENERGY].index] );
- erase_height = (100 - energy) * SB_ENERGY_GAUGE_H / 100;
- if (erase_height > 0) {
- gr_setcolor( 0 );
- gr_rect(0,0,SB_ENERGY_GAUGE_W-1,erase_height-1);
- }
- gr_set_current_canvas( get_current_game_screen() );
- gr_ubitmapm( SB_ENERGY_GAUGE_X, SB_ENERGY_GAUGE_Y, &Canv_SBEnergyGauge->cv_bitmap );
- //draw numbers
- gr_set_fontcolor(gr_getcolor(25,18,6),-1 );
- 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);
-
- }
- sb_draw_shield_num(int shield)
- {
- grs_bitmap *bm = &GameBitmaps[cockpit_bitmap[Cockpit_mode].index];
- //draw numbers
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(14,14,23),-1 );
- //erase old one
- PIGGY_PAGE_IN( cockpit_bitmap[Cockpit_mode] );
- gr_setcolor(gr_gpixel(bm,SB_SHIELD_NUM_X,SB_SHIELD_NUM_Y-(VR_render_width-bm->bm_h)));
- gr_rect(SB_SHIELD_NUM_X,SB_SHIELD_NUM_Y,SB_SHIELD_NUM_X+13,SB_SHIELD_NUM_Y+GAME_FONT->ft_h);
- 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);
- }
- sb_draw_shield_bar(int shield)
- {
- int bm_num = shield>=100?9:(shield / 10);
- gr_set_current_canvas( get_current_game_screen() );
- PIGGY_PAGE_IN( Gauges[GAUGE_SHIELDS+9-bm_num] );
- gr_ubitmapm( SB_SHIELD_GAUGE_X, SB_SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_SHIELDS+9-bm_num].index] );
- }
- sb_draw_keys()
- {
- grs_bitmap * bm;
- int flags = Players[Player_num].flags;
- gr_set_current_canvas( get_current_game_screen() );
- bm = &GameBitmaps[Gauges[(flags&PLAYER_FLAGS_BLUE_KEY)?SB_GAUGE_BLUE_KEY:SB_GAUGE_BLUE_KEY_OFF].index];
- PIGGY_PAGE_IN(Gauges[(flags&PLAYER_FLAGS_BLUE_KEY)?SB_GAUGE_BLUE_KEY:SB_GAUGE_BLUE_KEY_OFF]);
- gr_ubitmapm( SB_GAUGE_KEYS_X, SB_GAUGE_BLUE_KEY_Y, bm );
- bm = &GameBitmaps[Gauges[(flags&PLAYER_FLAGS_GOLD_KEY)?SB_GAUGE_GOLD_KEY:SB_GAUGE_GOLD_KEY_OFF].index];
- PIGGY_PAGE_IN(Gauges[(flags&PLAYER_FLAGS_GOLD_KEY)?SB_GAUGE_GOLD_KEY:SB_GAUGE_GOLD_KEY_OFF]);
- gr_ubitmapm( SB_GAUGE_KEYS_X, SB_GAUGE_GOLD_KEY_Y, bm );
- bm = &GameBitmaps[Gauges[(flags&PLAYER_FLAGS_RED_KEY)?SB_GAUGE_RED_KEY:SB_GAUGE_RED_KEY_OFF].index];
- PIGGY_PAGE_IN(Gauges[(flags&PLAYER_FLAGS_RED_KEY)?SB_GAUGE_RED_KEY:SB_GAUGE_RED_KEY_OFF]);
- gr_ubitmapm( SB_GAUGE_KEYS_X, SB_GAUGE_RED_KEY_Y, bm );
- }
- // Draws invulnerable ship, or maybe the flashing ship, depending on invulnerability time left.
- void draw_invulnerable_ship()
- {
- static fix time=0;
- gr_set_current_canvas( get_current_game_screen() );
- if (((Players[Player_num].invulnerable_time + INVULNERABLE_TIME_MAX - GameTime) > F1_0*4) || (GameTime & 0x8000)) {
- if (Cockpit_mode == CM_STATUS_BAR) {
- PIGGY_PAGE_IN(Gauges[GAUGE_INVULNERABLE+invulnerable_frame]);
- gr_ubitmapm( SB_SHIELD_GAUGE_X, SB_SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_INVULNERABLE+invulnerable_frame].index] );
- } else {
- PIGGY_PAGE_IN(Gauges[GAUGE_INVULNERABLE+invulnerable_frame]);
- gr_ubitmapm( SHIELD_GAUGE_X, SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_INVULNERABLE+invulnerable_frame].index] );
- }
- time += FrameTime;
- while (time > INV_FRAME_TIME) {
- time -= INV_FRAME_TIME;
- if (++invulnerable_frame == N_INVULNERABLE_FRAMES)
- invulnerable_frame=0;
- }
- } else if (Cockpit_mode == CM_STATUS_BAR)
- sb_draw_shield_bar(f2ir(Players[Player_num].shields));
- else
- draw_shield_bar(f2ir(Players[Player_num].shields));
- }
- #ifdef HOSTAGE_FACES
- draw_hostage_gauge()
- {
- int drew;
- gr_set_current_canvas(Canv_game_offscrn);
- drew = do_hostage_effects();
- if (drew) {
- int boxofs = (Cockpit_mode==CM_STATUS_BAR)?2:0;
- gr_set_current_canvas(Canv_game);
- copy_gauge_box(&gauge_boxes[boxofs+1],&Canv_game_offscrn->cv_bitmap);
- old_weapon[1] = old_ammo_count[1] = -1;
- }
- }
- #endif
- extern int Missile_gun;
- extern int allowed_to_fire_laser(void);
- extern int allowed_to_fire_missile(void);
- rgb player_rgb[] = {
- {15,15,23},
- {27,0,0},
- {0,23,0},
- {30,11,31},
- {31,16,0},
- {24,17,6},
- {14,21,12},
- {29,29,0},
- };
- //draw the reticle
- show_reticle(int force_big_one)
- {
- int x,y;
- int laser_ready,missile_ready,laser_ammo,missile_ammo;
- int cross_bm_num,primary_bm_num,secondary_bm_num;
- x = grd_curcanv->cv_w/2;
- y = grd_curcanv->cv_h/2;
- laser_ready = allowed_to_fire_laser();
- missile_ready = allowed_to_fire_missile();
- laser_ammo = player_has_weapon(Primary_weapon,0);
- missile_ammo = player_has_weapon(Secondary_weapon,1);
- primary_bm_num = (laser_ready && laser_ammo==HAS_ALL);
- secondary_bm_num = (missile_ready && missile_ammo==HAS_ALL);
- if (primary_bm_num && Primary_weapon==LASER_INDEX && (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS))
- primary_bm_num++;
- if (Secondary_weapon!=CONCUSSION_INDEX && Secondary_weapon!=HOMING_INDEX)
- secondary_bm_num += 3; //now value is 0,1 or 3,4
- else if (secondary_bm_num && !(Missile_gun&1))
- secondary_bm_num++;
- cross_bm_num = ((primary_bm_num > 0) || (secondary_bm_num > 0));
- Assert(primary_bm_num <= 2);
- Assert(secondary_bm_num <= 4);
- Assert(cross_bm_num <= 1);
- if (grd_curcanv->cv_bitmap.bm_w > 200 || force_big_one) {
- PIGGY_PAGE_IN(Gauges[RETICLE_CROSS + cross_bm_num]);
- gr_ubitmapm(x-4 ,y-2,&GameBitmaps[Gauges[RETICLE_CROSS + cross_bm_num].index]);
- PIGGY_PAGE_IN(Gauges[RETICLE_PRIMARY + primary_bm_num]);
- gr_ubitmapm(x-15,y+6,&GameBitmaps[Gauges[RETICLE_PRIMARY + primary_bm_num].index]);
- PIGGY_PAGE_IN(Gauges[RETICLE_SECONDARY + secondary_bm_num]);
- gr_ubitmapm(x-12,y+1,&GameBitmaps[Gauges[RETICLE_SECONDARY + secondary_bm_num].index]);
- }
- else {
- PIGGY_PAGE_IN(Gauges[SML_RETICLE_CROSS + cross_bm_num]);
- gr_ubitmapm(x-2,y-1,&GameBitmaps[Gauges[SML_RETICLE_CROSS + cross_bm_num].index]);
- PIGGY_PAGE_IN(Gauges[SML_RETICLE_PRIMARY + primary_bm_num]);
- gr_ubitmapm(x-8,y+2,&GameBitmaps[Gauges[SML_RETICLE_PRIMARY + primary_bm_num].index]);
- PIGGY_PAGE_IN(Gauges[SML_RETICLE_SECONDARY + secondary_bm_num]);
- gr_ubitmapm(x-6,y-2,&GameBitmaps[Gauges[SML_RETICLE_SECONDARY + secondary_bm_num].index]);
- }
- #ifndef SHAREWARE
- if ((Newdemo_state == ND_STATE_PLAYBACK) || (((Game_mode & GM_MULTI_COOP) || (Game_mode & GM_TEAM)) && Show_reticle_name))
- {
- // Draw player callsign for player in sights
- fvi_query fq;
- vms_vector orient;
- int Hit_type;
- fvi_info Hit_data;
- fq.p0 = &ConsoleObject->pos;
- orient = ConsoleObject->orient.fvec;
- vm_vec_scale(&orient, F1_0*1024);
- vm_vec_add2(&orient, fq.p0);
- fq.p1 = &orient;
- fq.rad = 0;
- fq.thisobjnum = ConsoleObject - Objects;
- fq.flags = FQ_TRANSWALL | FQ_CHECK_OBJS;
- fq.startseg = ConsoleObject->segnum;
- fq.ignore_obj_list = NULL;
- Hit_type = find_vector_intersection(&fq, &Hit_data);
- if ((Hit_type == HIT_OBJECT) && (Objects[Hit_data.hit_object].type == OBJ_PLAYER))
- {
- // Draw callsign on HUD
- char s[CALLSIGN_LEN+1];
- int w, h, aw;
- int x1, y1;
- int pnum;
- int color_num;
- pnum = Objects[Hit_data.hit_object].id;
- if ((Game_mode & GM_TEAM) && (get_team(pnum) != get_team(Player_num)) && (Newdemo_state != ND_STATE_PLAYBACK))
- return;
- if (Game_mode & GM_TEAM)
- color_num = get_team(pnum);
- else
- color_num = pnum;
- sprintf(s, "%s", Players[pnum].callsign);
- gr_get_string_size(s, &w, &h, &aw);
- gr_set_fontcolor(gr_getcolor(player_rgb[color_num].r,player_rgb[color_num].g,player_rgb[color_num].b),-1 );
- x1 = x-(w/2);
- y1 = y+12;
- gr_string (x1, y1, s);
- // }
- }
- #ifndef NDEBUG
- else if ((Hit_type == HIT_OBJECT) && (Objects[Hit_data.hit_object].type == OBJ_ROBOT))
- {
- char s[CALLSIGN_LEN+1];
- int w, h, aw;
- int x1, y1;
- int color_num = 0;
- sprintf(s, "%d", Hit_data.hit_object);
- gr_get_string_size(s, &w, &h, &aw);
- gr_set_fontcolor(gr_getcolor(player_rgb[color_num].r,player_rgb[color_num].g,player_rgb[color_num].b),-1 );
- x1 = x-(w/2);
- y1 = y+12;
- gr_string (x1, y1, s);
- }
- #endif
- }
- #endif
- }
- hud_show_kill_list()
- {
- int n_players,player_list[MAX_NUM_NET_PLAYERS];
- int n_left,i,x0,x1,y,save_y,fth;
- if (Show_kill_list_timer > 0)
- {
- Show_kill_list_timer -= FrameTime;
- if (Show_kill_list_timer < 0)
- Show_kill_list = 0;
- }
-
- #ifdef SHAREWARE
- if (Game_mode & GM_MULTI_COOP)
- {
- Show_kill_list = 0;
- return;
- }
- #endif
- gr_set_curfont( GAME_FONT );
- n_players = multi_get_kill_list(player_list);
- if (Show_kill_list == 2)
- n_players = 2;
- if (n_players <= 4)
- n_left = n_players;
- else
- n_left = (n_players+1)/2;
- //If font size changes, this code might not work right anymore
- Assert(GAME_FONT->ft_h==5 && GAME_FONT->ft_w==7);
- fth = GAME_FONT->ft_h;
- x0 = 1; x1 = 43;
- #ifndef SHAREWARE
- if (Game_mode & GM_MULTI_COOP)
- x1 = 31;
- #endif
- save_y = y = grd_curcanv->cv_h - n_left*(fth+1);
- if (Cockpit_mode == CM_FULL_COCKPIT) {
- save_y = y -= 6;
- #ifndef SHAREWARE
- if (Game_mode & GM_MULTI_COOP)
- x1 = 33;
- else
- #endif
- x1 = 43;
- }
- for (i=0;i<n_players;i++) {
- int player_num;
- char name[9];
- int sw,sh,aw;
- if (i==n_left) {
- if (Cockpit_mode == CM_FULL_COCKPIT)
- x0 = grd_curcanv->cv_w - 53;
- else
- x0 = grd_curcanv->cv_w - 60;
- #ifndef SHAREWARE
- if (Game_mode & GM_MULTI_COOP)
- x1 = grd_curcanv->cv_w - 27;
- else
- #endif
- x1 = grd_curcanv->cv_w - 15;
- y = save_y;
- }
-
- if (Show_kill_list == 2)
- player_num = i;
- else
- player_num = player_list[i];
- if (Show_kill_list == 1)
- {
- int color;
- if (Players[player_num].connected != 1)
- gr_set_fontcolor(gr_getcolor(12, 12, 12), -1);
- else if (Game_mode & GM_TEAM) {
- color = get_team(player_num);
- gr_set_fontcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 );
- }
- else {
- color = player_num;
- gr_set_fontcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 );
- }
- }
- else
- {
- gr_set_fontcolor(gr_getcolor(player_rgb[player_num].r,player_rgb[player_num].g,player_rgb[player_num].b),-1 );
- }
- if (Show_kill_list == 2)
- strcpy(name, Netgame.team_name[i]);
- else
- strcpy(name,Players[player_num].callsign);
- gr_get_string_size(name,&sw,&sh,&aw);
- while (sw > (x1-x0-3)) {
- name[strlen(name)-1]=0;
- gr_get_string_size(name,&sw,&sh,&aw);
- }
- gr_printf(x0,y,"%s",name);
- if (Show_kill_list == 2)
- gr_printf(x1,y,"%3d",team_kills[i]);
- #ifndef SHAREWARE
- else if (Game_mode & GM_MULTI_COOP)
- gr_printf(x1,y,"%-6d",Players[player_num].score);
- #endif
- else
- gr_printf(x1,y,"%3d",Players[player_num].net_kills_total);
- y += fth+1;
- }
- }
- //draw all the things on the HUD
- void draw_hud()
- {
- // Show score so long as not in rearview
- if ( !Rear_view && Cockpit_mode!=CM_REAR_VIEW && Cockpit_mode!=CM_STATUS_BAR) {
- hud_show_score();
- if (score_time)
- hud_show_score_added();
- }
- // Show other stuff if not in rearview or letterbox.
- if (!Rear_view && Cockpit_mode!=CM_REAR_VIEW) { // && Cockpit_mode!=CM_LETTERBOX) {
- if (Cockpit_mode==CM_STATUS_BAR || Cockpit_mode==CM_FULL_SCREEN)
- hud_show_homing_warning();
- if (Cockpit_mode==CM_FULL_SCREEN) {
- hud_show_energy();
- hud_show_shield();
- hud_show_weapons();
- hud_show_keys();
- hud_show_cloak_invuln();
- if ( ( Newdemo_state==ND_STATE_RECORDING ) && ( Players[Player_num].flags != old_flags )) {
- newdemo_record_player_flags(old_flags, Players[Player_num].flags);
- old_flags = Players[Player_num].flags;
- }
- }
- #ifndef RELEASE
- if (!(Game_mode&GM_MULTI && Show_kill_list))
- show_time();
- #endif
- if (Cockpit_mode != CM_LETTERBOX && (!Use_player_head_angles))
- show_reticle(0);
- HUD_render_message_frame();
- if (Cockpit_mode!=CM_STATUS_BAR)
- hud_show_lives();
- if (Game_mode&GM_MULTI && Show_kill_list)
- hud_show_kill_list();
- }
- if (Rear_view && Cockpit_mode!=CM_REAR_VIEW) {
- HUD_render_message_frame();
- gr_set_curfont( GAME_FONT );
- gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
- gr_printf(0x8000,grd_curcanv->cv_h-10,TXT_REAR_VIEW);
- }
- }
- //print out some player statistics
- void render_gauges()
- {
- int energy = f2ir(Players[Player_num].energy);
- int shields = f2ir(Players[Player_num].shields);
- int cloak = ((Players[Player_num].flags&PLAYER_FLAGS_CLOAKED) != 0);
- Assert(Cockpit_mode==CM_FULL_COCKPIT || Cockpit_mode==CM_STATUS_BAR);
- #ifdef HOSTAGE_FACES
- draw_hostage_gauge();
- #endif
- if (shields < 0 ) shields = 0;
- gr_set_current_canvas(get_current_game_screen());
- gr_set_curfont( GAME_FONT );
- if (Newdemo_state == ND_STATE_RECORDING)
- if (Players[Player_num].homing_object_dist >= 0)
- newdemo_record_homing_distance(Players[Player_num].homing_object_dist);
- if (Cockpit_mode == CM_FULL_COCKPIT) {
- if (energy != old_energy) {
- if (Newdemo_state==ND_STATE_RECORDING ) {
- #ifdef SHAREWARE
- newdemo_record_player_energy(energy);
- #else
- newdemo_record_player_energy(old_energy, energy);
- #endif
- }
- draw_energy_bar(energy);
- draw_numerical_display(shields, energy);
- old_energy = energy;
- }
- if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
- draw_numerical_display(shields, energy);
- draw_invulnerable_ship();
- old_shields = shields ^ 1;
- } else if (shields != old_shields) { // Draw the shield gauge
- if (Newdemo_state==ND_STATE_RECORDING ) {
- #ifdef SHAREWARE
- newdemo_record_player_shields(shields);
- #else
- newdemo_record_player_shields(old_shields, shields);
- #endif
- }
- draw_shield_bar(shields);
- draw_numerical_display(shields, energy);
- old_shields = shields;
- }
-
- if (Players[Player_num].flags != old_flags) {
- if (Newdemo_state==ND_STATE_RECORDING )
- newdemo_record_player_flags(old_flags, Players[Player_num].flags);
- draw_keys();
- old_flags = Players[Player_num].flags;
- }
- show_homing_warning();
-
- } else if (Cockpit_mode == CM_STATUS_BAR) {
- if (energy != old_energy) {
- if (Newdemo_state==ND_STATE_RECORDING ) {
- #ifdef SHAREWARE
- newdemo_record_player_energy(energy);
- #else
- newdemo_record_player_energy(old_energy, energy);
- #endif
- }
- sb_draw_energy_bar(energy);
- old_energy = energy;
- }
-
- if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
- draw_invulnerable_ship();
- old_shields = shields ^ 1;
- sb_draw_shield_num(shields);
- }
- else
- if (shields != old_shields) { // Draw the shield gauge
- if (Newdemo_state==ND_STATE_RECORDING ) {
- #ifdef SHAREWARE
- newdemo_record_player_shields(shields);
- #else
- newdemo_record_player_shields(old_shields, shields);
- #endif
- }
- sb_draw_shield_bar(shields);
- old_shields = shields;
- sb_draw_shield_num(shields);
- }
- if (Players[Player_num].flags != old_flags) {
- if (Newdemo_state==ND_STATE_RECORDING )
- newdemo_record_player_flags(old_flags, Players[Player_num].flags);
- sb_draw_keys();
- old_flags = Players[Player_num].flags;
- }
-
- if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))
- {
- if (Players[Player_num].net_killed_total != old_lives) {
- sb_show_lives();
- old_lives = Players[Player_num].net_killed_total;
- }
- }
- else
- {
- if (Players[Player_num].lives != old_lives) {
- sb_show_lives();
- old_lives = Players[Player_num].lives;
- }
- }
- if ((Game_mode&GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) {
- if (Players[Player_num].net_kills_total != old_score) {
- sb_show_score();
- old_score = Players[Player_num].net_kills_total;
- }
- }
- else {
- if (Players[Player_num].score != old_score) {
- sb_show_score();
- old_score = Players[Player_num].score;
- }
- if (score_time)
- sb_show_score_added();
- }
- }
- if (cloak != old_cloak || cloak_fade_state || (cloak && GameTime>Players[Player_num].cloak_time+CLOAK_TIME_MAX-i2f(3))) {
- if (Cockpit_mode == CM_FULL_COCKPIT)
- draw_player_ship(cloak,old_cloak,SHIP_GAUGE_X,SHIP_GAUGE_Y);
- else
- draw_player_ship(cloak,old_cloak,SB_SHIP_GAUGE_X,SB_SHIP_GAUGE_Y);
- old_cloak=cloak;
- }
- draw_weapon_boxes();
- }
- // ---------------------------------------------------------------------------------------------------------
- // Call when picked up a laser powerup.
- // If laser is active, set old_weapon[0] to -1 to force redraw.
- void update_laser_weapon_info(void)
- {
- if (old_weapon[0] == 0)
- old_weapon[0] = -1;
- }
|