1 /* KJL 14:43:27 10/6/97 - d3d_hud.cpp
2
3 Things just got too messy with ddplat.cpp & d3_func.cpp,
4 so this file will hold all Direct 3D hud code.
5
6 */
7 extern "C" {
8
9 // Mysterious definition required by objbase.h
10 // (included via one of the include files below)
11 // to start definition of obscure unique in the
12 // universe IDs required by Direct3D before it
13 // will deign to cough up with anything useful...
14
15 #include "3dc.h"
16 #include "module.h"
17 #include "stratdef.h"
18 #include "gamedef.h"
19 #include "bh_types.h"
20
21 #include "hudgfx.h"
22 #include "huddefs.h"
23 //#include "hud_data.h"
24 #include "kshape.h"
25 #include "chnktexi.h"
26
27
28 #include "hud_layout.h"
29 #include "language.h"
30
31
32 extern void D3D_RenderHUDString_Centred(char *stringPtr, int centreX, int y, int colour);
33 extern void D3D_RenderHUDNumber_Centred(unsigned int number,int x,int y,int colour);
34
35 extern "C++"
36 {
37 #include "r2base.h"
38 #include "pcmenus.h"
39 //#include "projload.hpp" // c++ header which ignores class definitions/member functions if __cplusplus is not defined ?
40 #include "chnkload.hpp" // c++ header which ignores class definitions/member functions if __cplusplus is not defined ?
41 };
42
43 #include "d3d_hud.h"
44
45
46 #define UseLocalAssert No
47 #include "ourasert.h"
48
49
50 #include "vision.h"
51 #define RGBLIGHT_MAKE(rr,gg,bb) \
52 ( \
53 LCCM_NORMAL == d3d_light_ctrl.ctrl ? \
54 RGB_MAKE(rr,gg,bb) \
55 : LCCM_CONSTCOLOUR == d3d_light_ctrl.ctrl ? \
56 RGB_MAKE(MUL_FIXED(rr,d3d_light_ctrl.r),MUL_FIXED(gg,d3d_light_ctrl.g),MUL_FIXED(bb,d3d_light_ctrl.b)) \
57 : \
58 RGB_MAKE(d3d_light_ctrl.GetR(rr),d3d_light_ctrl.GetG(gg),d3d_light_ctrl.GetB(bb)) \
59 )
60 #define RGBALIGHT_MAKE(rr,gg,bb,aa) \
61 ( \
62 RGBA_MAKE(rr,gg,bb,aa) \
63 )
64
65
66 void D3D_DrawHUDFontCharacter(HUDCharDesc *charDescPtr);
67 void D3D_DrawHUDDigit(HUDCharDesc *charDescPtr);
68
69 extern void YClipMotionTrackerVertices(struct VertexTag *v1, struct VertexTag *v2);
70 extern void XClipMotionTrackerVertices(struct VertexTag *v1, struct VertexTag *v2);
71 /* HUD globals */
72 extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
73
74 extern enum HUD_RES_ID HUDResolution;
75
76 signed int HUDTranslucencyLevel=64;
77
78 static int MotionTrackerHalfWidth;
79 static int MotionTrackerTextureSize;
80 static int MotionTrackerCentreY;
81 static int MotionTrackerCentreX;
82 static int MT_BlipHeight;
83 static int MT_BlipWidth;
84 static HUDImageDesc BlueBar;
85
86
87 int HUDImageNumber;
88 int SpecialFXImageNumber;
89 int SmokyImageNumber;
90 int ChromeImageNumber;
91 int CloudyImageNumber;
92 int BurningImageNumber;
93 int HUDFontsImageNumber;
94 int RebellionLogoImageNumber;
95 int FoxLogoImageNumber;
96 int MotionTrackerScale;
97 int PredatorVisionChangeImageNumber;
98 int PredatorNumbersImageNumber;
99 int StaticImageNumber;
100 int AlienTongueImageNumber;
101 int AAFontImageNumber;
102 int WaterShaftImageNumber;
103
104
105 int HUDScaleFactor;
106
107 static struct HUDFontDescTag HUDFontDesc[] =
108 {
109 //MARINE_HUD_FONT_BLUE,
110 {
111 225,//XOffset
112 24,//Height
113 16,//Width
114 },
115 //MARINE_HUD_FONT_RED,
116 {
117 242,//XOffset
118 24,//Height
119 14,//Width
120 },
121 //MARINE_HUD_FONT_MT_SMALL,
122 {
123 232,//XOffset
124 12,//Height
125 8,//Width
126 },
127 //MARINE_HUD_FONT_MT_BIG,
128 {
129 241,//XOffset
130 24,//Height
131 14,//Width
132 },
133 };
134 #define BLUE_BAR_WIDTH ((203-0)+1)
135 #define BLUE_BAR_HEIGHT ((226-195)+1)
136
137 void D3D_BLTDigitToHUD(char digit, int x, int y, int font);
138
139
Draw_HUDImage(HUDImageDesc * imageDescPtr)140 void Draw_HUDImage(HUDImageDesc *imageDescPtr)
141 {
142 struct VertexTag quadVertices[4];
143 int scaledWidth;
144 int scaledHeight;
145
146 if (imageDescPtr->Scale == ONE_FIXED)
147 {
148 scaledWidth = imageDescPtr->Width;
149 scaledHeight = imageDescPtr->Height;
150 }
151 else
152 {
153 scaledWidth = MUL_FIXED(imageDescPtr->Scale,imageDescPtr->Width);
154 scaledHeight = MUL_FIXED(imageDescPtr->Scale,imageDescPtr->Height);
155 }
156
157 quadVertices[0].U = imageDescPtr->TopLeftU;
158 quadVertices[0].V = imageDescPtr->TopLeftV;
159 quadVertices[1].U = imageDescPtr->TopLeftU + imageDescPtr->Width;
160 quadVertices[1].V = imageDescPtr->TopLeftV;
161 quadVertices[2].U = imageDescPtr->TopLeftU + imageDescPtr->Width;
162 quadVertices[2].V = imageDescPtr->TopLeftV + imageDescPtr->Height;
163 quadVertices[3].U = imageDescPtr->TopLeftU;
164 quadVertices[3].V = imageDescPtr->TopLeftV + imageDescPtr->Height;
165
166 quadVertices[0].X = imageDescPtr->TopLeftX;
167 quadVertices[0].Y = imageDescPtr->TopLeftY;
168 quadVertices[1].X = imageDescPtr->TopLeftX + scaledWidth;
169 quadVertices[1].Y = imageDescPtr->TopLeftY;
170 quadVertices[2].X = imageDescPtr->TopLeftX + scaledWidth;
171 quadVertices[2].Y = imageDescPtr->TopLeftY + scaledHeight;
172 quadVertices[3].X = imageDescPtr->TopLeftX;
173 quadVertices[3].Y = imageDescPtr->TopLeftY + scaledHeight;
174
175 D3D_HUDQuad_Output
176 (
177 imageDescPtr->ImageNumber,
178 quadVertices,
179 RGBALIGHT_MAKE
180 (
181 imageDescPtr->Red,
182 imageDescPtr->Green,
183 imageDescPtr->Blue,
184 imageDescPtr->Translucency
185 )
186 );
187 }
188
189
D3D_InitialiseMarineHUD(void)190 void D3D_InitialiseMarineHUD(void)
191 {
192 //SelectGenTexDirectory(ITI_TEXTURE);
193
194 /* set game mode: different though for multiplayer game */
195 if(AvP.Network==I_No_Network)
196 cl_pszGameMode = "marine";
197 else
198 cl_pszGameMode = "multip";
199
200 /* load HUD gfx of correct resolution */
201 {
202 HUDResolution = HUD_RES_MED;
203 HUDImageNumber = CL_LoadImageOnce("Huds\\Marine\\MarineHUD.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
204 MotionTrackerHalfWidth = 127/2;
205 MotionTrackerTextureSize = 128;
206
207 BlueBar.ImageNumber = HUDImageNumber;
208 BlueBar.TopLeftX = 0;
209 BlueBar.TopLeftY = ScreenDescriptorBlock.SDB_Height-40;
210 BlueBar.TopLeftU = 1;
211 BlueBar.TopLeftV = 223;
212 BlueBar.Red = 255;
213 BlueBar.Green = 255;
214 BlueBar.Blue = 255;
215
216 BlueBar.Height = BLUE_BAR_HEIGHT;
217 BlueBar.Width = BLUE_BAR_WIDTH;
218
219 /* motion tracker blips */
220 MT_BlipHeight = 12;
221 MT_BlipWidth = 12;
222
223 /* load in sfx */
224 SpecialFXImageNumber = CL_LoadImageOnce("Common\\partclfx.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
225
226 // SpecialFXImageNumber = CL_LoadImageOnceEx("flame1",IRF_D3D,DDSCAPS_SYSTEMMEMORY,0);;
227 // SpecialFXImageNumber = CL_LoadImageOnceEx("star",IRF_D3D,DDSCAPS_SYSTEMMEMORY,0);;
228 // SmokyImageNumber = CL_LoadImageOnceEx("smoky",IRF_D3D,DDSCAPS_SYSTEMMEMORY,0);
229
230 }
231
232 /* centre of motion tracker */
233 MotionTrackerCentreY = BlueBar.TopLeftY;
234 MotionTrackerCentreX = BlueBar.TopLeftX+(BlueBar.Width/2);
235 MotionTrackerScale = 65536;
236
237 HUDScaleFactor = DIV_FIXED(ScreenDescriptorBlock.SDB_Width,640);
238
239 #if UseGadgets
240 // MotionTrackerGadget::SetCentre(r2pos(100,100));
241 #endif
242 }
243
LoadCommonTextures(void)244 void LoadCommonTextures(void)
245 {
246 // PredatorVisionChangeImageNumber = CL_LoadImageOnce("HUDs\\Predator\\predvisfx.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
247 if(AvP.Network==I_No_Network)
248 {
249 switch(AvP.PlayerType)
250 {
251 case I_Predator:
252 {
253 PredatorNumbersImageNumber = CL_LoadImageOnce("HUDs\\Predator\\predNumbers.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
254 StaticImageNumber = CL_LoadImageOnce("Common\\static.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
255 break;
256 }
257 case I_Alien:
258 {
259 AlienTongueImageNumber = CL_LoadImageOnce("HUDs\\Alien\\AlienTongue.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
260 break;
261 }
262 case I_Marine:
263 {
264 StaticImageNumber = CL_LoadImageOnce("Common\\static.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
265 // ChromeImageNumber = CL_LoadImageOnce("Common\\water2.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
266 break;
267 }
268 default:
269 break;
270 }
271 }
272 else
273 {
274 PredatorNumbersImageNumber = CL_LoadImageOnce("HUDs\\Predator\\predNumbers.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
275 StaticImageNumber = CL_LoadImageOnce("Common\\static.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
276 AlienTongueImageNumber = CL_LoadImageOnce("HUDs\\Alien\\AlienTongue.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
277 // ChromeImageNumber = CL_LoadImageOnce("Common\\water2.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
278 }
279
280 HUDFontsImageNumber = CL_LoadImageOnce("Common\\HUDfonts.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
281 SpecialFXImageNumber = CL_LoadImageOnce("Common\\partclfx.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE/*|LIO_TRANSPARENT*/);
282 CloudyImageNumber = CL_LoadImageOnce("Common\\cloudy.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
283 BurningImageNumber = CL_LoadImageOnce("Common\\burn.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
284 // RebellionLogoImageNumber = CL_LoadImageOnce("Common\\logo.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
285 // FoxLogoImageNumber = CL_LoadImageOnce("Common\\foxlogo.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
286
287
288 {
289 extern char LevelName[];
290 if (!strcmp(LevelName,"invasion_a"))
291 {
292 #if !ALIEN_DEMO
293 ChromeImageNumber = CL_LoadImageOnce("Envrnmts\\Invasion\\water2.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
294 WaterShaftImageNumber = CL_LoadImageOnce("Envrnmts\\Invasion\\water-shaft.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
295 #else /* alien demo has these in common */
296 ChromeImageNumber = CL_LoadImageOnce("Common\\water2.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
297 WaterShaftImageNumber = CL_LoadImageOnce("Common\\water-shaft.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
298 #endif
299 }
300 else if (!strcmp(LevelName,"genshd1"))
301 {
302 WaterShaftImageNumber = CL_LoadImageOnce("Envrnmts\\GenShd1\\colonywater.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
303 }
304 else if (!strcmp(LevelName,"fall")||!strcmp(LevelName,"fall_m"))
305 {
306 ChromeImageNumber = CL_LoadImageOnce("Envrnmts\\fall\\stream_water.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
307 }
308 else if (!strcmp(LevelName,"derelict"))
309 {
310 ChromeImageNumber = CL_LoadImageOnce("Envrnmts\\derelict\\water.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE|LIO_TRANSPARENT);
311 }
312
313 }
314
315 #if 1
316 {
317 extern void InitDrawTest(void);
318 InitDrawTest();
319 }
320 #endif
321
322 }
D3D_BLTMotionTrackerToHUD(int scanLineSize)323 void D3D_BLTMotionTrackerToHUD(int scanLineSize)
324 {
325
326 struct VertexTag quadVertices[4];
327 int widthCos,widthSin;
328
329 BlueBar.TopLeftY = ScreenDescriptorBlock.SDB_Height-MUL_FIXED(MotionTrackerScale,40);
330 MotionTrackerCentreY = BlueBar.TopLeftY;
331 MotionTrackerCentreX = BlueBar.TopLeftX+MUL_FIXED(MotionTrackerScale,(BlueBar.Width/2));
332 BlueBar.Scale = MotionTrackerScale;
333
334 int motionTrackerScaledHalfWidth = MUL_FIXED(MotionTrackerScale*3,MotionTrackerHalfWidth/2);
335
336 {
337 int angle = 4095 - Player->ObEuler.EulerY;
338
339 widthCos = MUL_FIXED
340 (
341 motionTrackerScaledHalfWidth,
342 GetCos(angle)
343 );
344 widthSin = MUL_FIXED
345 (
346 motionTrackerScaledHalfWidth,
347 GetSin(angle)
348 );
349 }
350
351 /* I've put these -1s in here to help clipping 45 degree cases,
352 where two vertices can end up around the clipping line of Y=0 */
353 quadVertices[0].X = (-widthCos - (-widthSin));
354 quadVertices[0].Y = (-widthSin + (-widthCos)) -1;
355 quadVertices[0].U = 1;
356 quadVertices[0].V = 1;
357 quadVertices[1].X = (widthCos - (-widthSin));
358 quadVertices[1].Y = (widthSin + (-widthCos)) -1;
359 quadVertices[1].U = 1+MotionTrackerTextureSize;
360 quadVertices[1].V = 1;
361 quadVertices[2].X = (widthCos - widthSin);
362 quadVertices[2].Y = (widthSin + widthCos) -1;
363 quadVertices[2].U = 1+MotionTrackerTextureSize;
364 quadVertices[2].V = 1+MotionTrackerTextureSize;
365 quadVertices[3].X = ((-widthCos) - widthSin);
366 quadVertices[3].Y = ((-widthSin) + widthCos) -1;
367 quadVertices[3].U = 1;
368 quadVertices[3].V = 1+MotionTrackerTextureSize;
369
370 /* clip to Y<=0 */
371 YClipMotionTrackerVertices(&quadVertices[0],&quadVertices[1]);
372 YClipMotionTrackerVertices(&quadVertices[1],&quadVertices[2]);
373 YClipMotionTrackerVertices(&quadVertices[2],&quadVertices[3]);
374 YClipMotionTrackerVertices(&quadVertices[3],&quadVertices[0]);
375
376 /* translate into screen coords */
377 quadVertices[0].X += MotionTrackerCentreX;
378 quadVertices[1].X += MotionTrackerCentreX;
379 quadVertices[2].X += MotionTrackerCentreX;
380 quadVertices[3].X += MotionTrackerCentreX;
381 quadVertices[0].Y += MotionTrackerCentreY;
382 quadVertices[1].Y += MotionTrackerCentreY;
383 quadVertices[2].Y += MotionTrackerCentreY;
384 quadVertices[3].Y += MotionTrackerCentreY;
385
386 /* dodgy offset 'cos I'm not x clipping */
387 if (quadVertices[0].X==-1) quadVertices[0].X = 0;
388 if (quadVertices[1].X==-1) quadVertices[1].X = 0;
389 if (quadVertices[2].X==-1) quadVertices[2].X = 0;
390 if (quadVertices[3].X==-1) quadVertices[3].X = 0;
391
392 /* check u & v are >0 */
393 if (quadVertices[0].V<0) quadVertices[0].V = 0;
394 if (quadVertices[1].V<0) quadVertices[1].V = 0;
395 if (quadVertices[2].V<0) quadVertices[2].V = 0;
396 if (quadVertices[3].V<0) quadVertices[3].V = 0;
397
398 if (quadVertices[0].U<0) quadVertices[0].U = 0;
399 if (quadVertices[1].U<0) quadVertices[1].U = 0;
400 if (quadVertices[2].U<0) quadVertices[2].U = 0;
401 if (quadVertices[3].U<0) quadVertices[3].U = 0;
402
403 D3D_HUD_Setup();
404 D3D_HUDQuad_Output(HUDImageNumber,quadVertices,RGBALIGHT_MAKE(255,255,255,HUDTranslucencyLevel));
405
406 #if 1
407 {
408 HUDImageDesc imageDesc;
409
410 imageDesc.ImageNumber = HUDImageNumber;
411 imageDesc.Scale = MUL_FIXED(MotionTrackerScale*3,scanLineSize/2);
412 imageDesc.TopLeftX = MotionTrackerCentreX - MUL_FIXED(motionTrackerScaledHalfWidth,scanLineSize);
413 imageDesc.TopLeftY = MotionTrackerCentreY - MUL_FIXED(motionTrackerScaledHalfWidth,scanLineSize);
414 imageDesc.TopLeftU = 1;
415 imageDesc.TopLeftV = 132;
416 imageDesc.Height = 64;
417 imageDesc.Width = 128;
418 imageDesc.Red = 255;
419 imageDesc.Green = 255;
420 imageDesc.Blue = 255;
421 imageDesc.Translucency = HUDTranslucencyLevel;
422
423 Draw_HUDImage(&imageDesc);
424 }
425 #endif
426
427 /* KJL 16:14:29 30/01/98 - draw bottom bar of MT */
428 {
429 BlueBar.Translucency = HUDTranslucencyLevel;
430 Draw_HUDImage(&BlueBar);
431 }
432
433 D3D_BLTDigitToHUD(ValueOfHUDDigit[MARINE_HUD_MOTIONTRACKER_UNITS],17, -4, MARINE_HUD_FONT_MT_SMALL);
434 D3D_BLTDigitToHUD(ValueOfHUDDigit[MARINE_HUD_MOTIONTRACKER_TENS],9, -4, MARINE_HUD_FONT_MT_SMALL);
435 D3D_BLTDigitToHUD(ValueOfHUDDigit[MARINE_HUD_MOTIONTRACKER_HUNDREDS],-9, -4, MARINE_HUD_FONT_MT_BIG);
436 D3D_BLTDigitToHUD(ValueOfHUDDigit[MARINE_HUD_MOTIONTRACKER_THOUSANDS],-25, -4,MARINE_HUD_FONT_MT_BIG);
437 }
438
439
D3D_BLTMotionTrackerBlipToHUD(int x,int y,int brightness)440 void D3D_BLTMotionTrackerBlipToHUD(int x, int y, int brightness)
441 {
442 HUDImageDesc imageDesc;
443 int frame;
444 int motionTrackerScaledHalfWidth = MUL_FIXED(MotionTrackerScale*3,MotionTrackerHalfWidth/2);
445
446 GLOBALASSERT(brightness<=65536);
447
448 frame = (brightness*5)/65537;
449 GLOBALASSERT(frame>=0 && frame<5);
450
451 frame = 4 - frame; // frames bloody wrong way round
452 imageDesc.ImageNumber = HUDImageNumber;
453 imageDesc.Scale = MUL_FIXED(MotionTrackerScale*3,(brightness+ONE_FIXED)/4);
454 imageDesc.TopLeftX = MotionTrackerCentreX - MUL_FIXED(MT_BlipWidth/2,imageDesc.Scale) + MUL_FIXED(x,motionTrackerScaledHalfWidth);
455 imageDesc.TopLeftY = MotionTrackerCentreY - MUL_FIXED(MT_BlipHeight/2,imageDesc.Scale) - MUL_FIXED(y,motionTrackerScaledHalfWidth);
456 imageDesc.TopLeftU = 227;
457 imageDesc.TopLeftV = 187;
458 imageDesc.Height = MT_BlipHeight;
459 imageDesc.Width = MT_BlipWidth;
460 {
461 int trans = MUL_FIXED(brightness*2,HUDTranslucencyLevel);
462 if (trans>255) trans = 255;
463 imageDesc.Translucency = trans;
464 }
465 imageDesc.Red = 255;
466 imageDesc.Green = 255;
467 imageDesc.Blue = 255;
468 if (imageDesc.TopLeftX<0) /* then we need to clip */
469 {
470 imageDesc.Width += imageDesc.TopLeftX;
471 imageDesc.TopLeftU -= imageDesc.TopLeftX;
472 imageDesc.TopLeftX = 0;
473 }
474 Draw_HUDImage(&imageDesc);
475 }
D3D_BlitWhiteChar(int x,int y,unsigned char c)476 extern void D3D_BlitWhiteChar(int x, int y, unsigned char c)
477 {
478 HUDImageDesc imageDesc;
479
480 // if (c>='a' && c<='z') c-='a'-'A';
481
482 // if (c<' ' || c>'_') return;
483 if (c==' ') return;
484
485 #if 0
486 imageDesc.ImageNumber = HUDFontsImageNumber;
487
488 imageDesc.TopLeftX = x;
489 imageDesc.TopLeftY = y;
490 imageDesc.TopLeftU = 1+((c-32)&15)*7;
491 imageDesc.TopLeftV = 2+((c-32)>>4)*11;
492 imageDesc.Height = 8;
493 imageDesc.Width = 5;
494 #else
495 imageDesc.ImageNumber = AAFontImageNumber;
496
497 imageDesc.TopLeftX = x;
498 imageDesc.TopLeftY = y;
499 imageDesc.TopLeftU = 1+((c-32)&15)*16;
500 imageDesc.TopLeftV = 1+((c-32)>>4)*16;
501 imageDesc.Height = 15;
502 imageDesc.Width = 15;
503 #endif
504 imageDesc.Scale = ONE_FIXED;
505 imageDesc.Translucency = 255;
506 imageDesc.Red = 255;
507 imageDesc.Green = 255;
508 imageDesc.Blue = 255;
509
510 Draw_HUDImage(&imageDesc);
511 }
512
D3D_DrawHUDFontCharacter(HUDCharDesc * charDescPtr)513 void D3D_DrawHUDFontCharacter(HUDCharDesc *charDescPtr)
514 {
515 HUDImageDesc imageDesc;
516
517 // if (charDescPtr->Character<' ' || charDescPtr->Character>'_') return;
518 if (charDescPtr->Character == ' ') return;
519
520 imageDesc.ImageNumber = AAFontImageNumber;
521
522 imageDesc.TopLeftX = charDescPtr->X-1;
523 imageDesc.TopLeftY = charDescPtr->Y-1;
524 imageDesc.TopLeftU = 0+((charDescPtr->Character-32)&15)*16;
525 imageDesc.TopLeftV = 0+((charDescPtr->Character-32)>>4)*16;
526 imageDesc.Height = HUD_FONT_HEIGHT+2;
527 imageDesc.Width = HUD_FONT_WIDTH+2;
528
529 imageDesc.Scale = ONE_FIXED;
530 imageDesc.Translucency = charDescPtr->Alpha;
531 imageDesc.Red = charDescPtr->Red;
532 imageDesc.Green = charDescPtr->Green;
533 imageDesc.Blue = charDescPtr->Blue;
534
535 Draw_HUDImage(&imageDesc);
536
537 }
D3D_DrawHUDDigit(HUDCharDesc * charDescPtr)538 void D3D_DrawHUDDigit(HUDCharDesc *charDescPtr)
539 {
540 HUDImageDesc imageDesc;
541
542 imageDesc.ImageNumber = HUDFontsImageNumber;
543
544 imageDesc.TopLeftX = charDescPtr->X;
545 imageDesc.TopLeftY = charDescPtr->Y;
546
547 if (charDescPtr->Character<8)
548 {
549 imageDesc.TopLeftU = 1+(charDescPtr->Character)*16;
550 imageDesc.TopLeftV = 81;
551 }
552 else
553 {
554 imageDesc.TopLeftU = 1+(charDescPtr->Character-8)*16;
555 imageDesc.TopLeftV = 81+24;
556 }
557
558
559 imageDesc.Height = HUD_DIGITAL_NUMBERS_HEIGHT;
560 imageDesc.Width = HUD_DIGITAL_NUMBERS_WIDTH;
561 imageDesc.Scale = ONE_FIXED;
562 imageDesc.Translucency = charDescPtr->Alpha;
563 imageDesc.Red = charDescPtr->Red;
564 imageDesc.Green = charDescPtr->Green;
565 imageDesc.Blue = charDescPtr->Blue;
566
567 Draw_HUDImage(&imageDesc);
568
569 }
D3D_DrawHUDPredatorDigit(HUDCharDesc * charDescPtr,int scale)570 void D3D_DrawHUDPredatorDigit(HUDCharDesc *charDescPtr, int scale)
571 {
572 HUDImageDesc imageDesc;
573
574 imageDesc.ImageNumber = PredatorNumbersImageNumber;
575
576 imageDesc.TopLeftX = charDescPtr->X;
577 imageDesc.TopLeftY = charDescPtr->Y;
578
579 if (charDescPtr->Character<5)
580 {
581 imageDesc.TopLeftU = (charDescPtr->Character)*51;
582 imageDesc.TopLeftV = 1;
583 }
584 else
585 {
586 imageDesc.TopLeftU = (charDescPtr->Character-5)*51;
587 imageDesc.TopLeftV = 52;
588 }
589
590
591 imageDesc.Height = 50;
592 imageDesc.Width = 50;
593 imageDesc.Scale = scale;
594 imageDesc.Translucency = charDescPtr->Alpha;
595 imageDesc.Red = charDescPtr->Red;
596 imageDesc.Green = charDescPtr->Green;
597 imageDesc.Blue = charDescPtr->Blue;
598
599 Draw_HUDImage(&imageDesc);
600
601 }
602
D3D_BLTDigitToHUD(char digit,int x,int y,int font)603 void D3D_BLTDigitToHUD(char digit, int x, int y, int font)
604 {
605 HUDImageDesc imageDesc;
606 struct HUDFontDescTag *FontDescPtr;
607 int gfxID;
608
609 switch (font)
610 {
611 case MARINE_HUD_FONT_MT_SMALL:
612 case MARINE_HUD_FONT_MT_BIG:
613 {
614 gfxID = MARINE_HUD_GFX_TRACKERFONT;
615 imageDesc.Scale = MotionTrackerScale;
616 x = MUL_FIXED(x,MotionTrackerScale) + MotionTrackerCentreX;
617 y = MUL_FIXED(y,MotionTrackerScale) + MotionTrackerCentreY;
618 break;
619 }
620 case MARINE_HUD_FONT_RED:
621 case MARINE_HUD_FONT_BLUE:
622 {
623 if (x<0) x+=ScreenDescriptorBlock.SDB_Width;
624 gfxID = MARINE_HUD_GFX_NUMERALS;
625 imageDesc.Scale=ONE_FIXED;
626 break;
627 }
628 case ALIEN_HUD_FONT:
629 {
630 gfxID = ALIEN_HUD_GFX_NUMBERS;
631 imageDesc.Scale=ONE_FIXED;
632 break;
633 }
634 default:
635 LOCALASSERT(0);
636 break;
637 }
638
639
640 if (HUDResolution == HUD_RES_LO)
641 {
642 FontDescPtr = &HUDFontDesc[font];
643 }
644 else if (HUDResolution == HUD_RES_MED)
645 {
646 FontDescPtr = &HUDFontDesc[font];
647 }
648 else
649 {
650 FontDescPtr = &HUDFontDesc[font];
651 }
652
653
654
655 imageDesc.ImageNumber = HUDImageNumber;
656 imageDesc.TopLeftX = x;
657 imageDesc.TopLeftY = y;
658 imageDesc.TopLeftU = FontDescPtr->XOffset;
659 imageDesc.TopLeftV = digit*(FontDescPtr->Height+1)+1;
660
661 imageDesc.Height = FontDescPtr->Height;
662 imageDesc.Width = FontDescPtr->Width;
663 imageDesc.Translucency = HUDTranslucencyLevel;
664 imageDesc.Red = 255;
665 imageDesc.Green = 255;
666 imageDesc.Blue = 255;
667
668 Draw_HUDImage(&imageDesc);
669
670 }
671
D3D_BLTGunSightToHUD(int screenX,int screenY,enum GUNSIGHT_SHAPE gunsightShape)672 void D3D_BLTGunSightToHUD(int screenX, int screenY, enum GUNSIGHT_SHAPE gunsightShape)
673 {
674 HUDImageDesc imageDesc;
675 int gunsightSize=13;
676
677 screenX = (screenX-(gunsightSize/2));
678 screenY = (screenY-(gunsightSize/2));
679
680 imageDesc.ImageNumber = HUDImageNumber;
681 imageDesc.TopLeftX = screenX;
682 imageDesc.TopLeftY = screenY;
683 imageDesc.TopLeftU = 227;
684 imageDesc.TopLeftV = 131+(gunsightShape*(gunsightSize+1));
685 imageDesc.Height = gunsightSize;
686 imageDesc.Width = gunsightSize;
687 imageDesc.Scale = ONE_FIXED;
688 imageDesc.Translucency = 128;
689 imageDesc.Red = 255;
690 imageDesc.Green = 255;
691 imageDesc.Blue = 255;
692
693 Draw_HUDImage(&imageDesc);
694 }
695
Render_HealthAndArmour(unsigned int health,unsigned int armour)696 void Render_HealthAndArmour(unsigned int health, unsigned int armour)
697 {
698 unsigned int healthColour;
699 unsigned int armourColour;
700
701 if (AvP.PlayerType == I_Marine)
702 {
703 int xCentre = MUL_FIXED(HUDLayout_RightmostTextCentre,HUDScaleFactor)+ScreenDescriptorBlock.SDB_Width;
704 healthColour = HUDLayout_Colour_MarineGreen;
705 armourColour = HUDLayout_Colour_MarineGreen;
706 D3D_RenderHUDString_Centred
707 (
708 GetTextString(TEXTSTRING_INGAME_HEALTH),
709 xCentre,
710 MUL_FIXED(HUDLayout_Health_TopY,HUDScaleFactor),
711 HUDLayout_Colour_BrightWhite
712 );
713 D3D_RenderHUDNumber_Centred
714 (
715 health,
716 xCentre,
717 MUL_FIXED(HUDLayout_Health_TopY+HUDLayout_Linespacing,HUDScaleFactor),
718 healthColour
719 );
720 D3D_RenderHUDString_Centred
721 (
722 GetTextString(TEXTSTRING_INGAME_ARMOUR),
723 xCentre,
724 MUL_FIXED(HUDLayout_Armour_TopY,HUDScaleFactor),
725 HUDLayout_Colour_BrightWhite
726 );
727 D3D_RenderHUDNumber_Centred
728 (
729 armour,
730 xCentre,
731 MUL_FIXED(HUDLayout_Armour_TopY+HUDLayout_Linespacing,HUDScaleFactor),
732 armourColour
733 );
734 }
735 else
736 {
737 if (health>100)
738 {
739 healthColour = HUDLayout_Colour_BrightWhite;
740 }
741 else
742 {
743 int r = ((health)*128)/100;
744 healthColour = 0xff000000 + ((128-r)<<16) + (r<<8);
745 }
746 if (armour>100)
747 {
748 armourColour = HUDLayout_Colour_BrightWhite;
749 }
750 else
751 {
752 int r = ((armour)*128)/100;
753 armourColour = 0xff000000 + ((128-r)<<16) + (r<<8);
754 }
755
756 {
757
758 struct VertexTag quadVertices[4];
759 int scaledWidth;
760 int scaledHeight;
761 int x,y;
762
763 if (health<100)
764 {
765 scaledWidth = WideMulNarrowDiv(ScreenDescriptorBlock.SDB_Width,health,100);
766 scaledHeight = scaledWidth/32;
767 }
768 else
769 {
770 scaledWidth = ScreenDescriptorBlock.SDB_Width;
771 scaledHeight = scaledWidth/32;
772 }
773 x = (ScreenDescriptorBlock.SDB_Width - scaledWidth)/2;
774 y = ScreenDescriptorBlock.SDB_Height - ScreenDescriptorBlock.SDB_Width/32 + x/32;
775
776 quadVertices[0].U = 8;
777 quadVertices[0].V = 5;
778 quadVertices[1].U = 57;//255;
779 quadVertices[1].V = 5;
780 quadVertices[2].U = 57;//255;
781 quadVertices[2].V = 55;//255;
782 quadVertices[3].U = 8;
783 quadVertices[3].V = 55;//255;
784
785 quadVertices[0].X = x;
786 quadVertices[0].Y = y;
787 quadVertices[1].X = x + scaledWidth;
788 quadVertices[1].Y = y;
789 quadVertices[2].X = x + scaledWidth;
790 quadVertices[2].Y = y + scaledHeight;
791 quadVertices[3].X = x;
792 quadVertices[3].Y = y + scaledHeight;
793
794 D3D_HUDQuad_Output
795 (
796 SpecialFXImageNumber,// AlienEnergyBarImageNumber,
797 quadVertices,
798 0xff003fff
799 );
800
801 health = (health/2);
802 if (health<0) health=0;
803
804 if (health<100)
805 {
806 scaledWidth = WideMulNarrowDiv(ScreenDescriptorBlock.SDB_Width,health,100);
807 scaledHeight = scaledWidth/32;
808 }
809 else
810 {
811 scaledWidth = ScreenDescriptorBlock.SDB_Width;
812 scaledHeight = scaledWidth/32;
813 }
814
815 x = (ScreenDescriptorBlock.SDB_Width - scaledWidth)/2;
816 y = ScreenDescriptorBlock.SDB_Height - ScreenDescriptorBlock.SDB_Width/32 + x/32;
817
818 quadVertices[0].X = x;
819 quadVertices[0].Y = y;
820 quadVertices[1].X = x + scaledWidth;
821 quadVertices[1].Y = y;
822 quadVertices[2].X = x + scaledWidth;
823 quadVertices[2].Y = y + scaledHeight;
824 quadVertices[3].X = x;
825 quadVertices[3].Y = y + scaledHeight;
826
827 D3D_HUDQuad_Output
828 (
829 SpecialFXImageNumber,// AlienEnergyBarImageNumber,
830 quadVertices,
831 0xffffffff
832 );
833
834 }
835
836 }
837
838
839
840 }
Render_MarineAmmo(enum TEXTSTRING_ID ammoText,enum TEXTSTRING_ID magazinesText,unsigned int magazines,enum TEXTSTRING_ID roundsText,unsigned int rounds,int primaryAmmo)841 void Render_MarineAmmo(enum TEXTSTRING_ID ammoText, enum TEXTSTRING_ID magazinesText, unsigned int magazines, enum TEXTSTRING_ID roundsText, unsigned int rounds, int primaryAmmo)
842 {
843 int xCentre = MUL_FIXED(HUDLayout_RightmostTextCentre,HUDScaleFactor)+ScreenDescriptorBlock.SDB_Width;
844 if(!primaryAmmo) xCentre+=MUL_FIXED(HUDScaleFactor,HUDLayout_RightmostTextCentre*2);
845
846 D3D_RenderHUDString_Centred
847 (
848 GetTextString(ammoText),
849 xCentre,
850 ScreenDescriptorBlock.SDB_Height - MUL_FIXED(HUDScaleFactor,HUDLayout_AmmoDesc_TopY),
851 HUDLayout_Colour_BrightWhite
852 );
853 D3D_RenderHUDString_Centred
854 (
855 GetTextString(magazinesText),
856 xCentre,
857 ScreenDescriptorBlock.SDB_Height -MUL_FIXED(HUDScaleFactor, HUDLayout_Magazines_TopY),
858 HUDLayout_Colour_BrightWhite
859 );
860 D3D_RenderHUDNumber_Centred
861 (
862 magazines,
863 xCentre,
864 ScreenDescriptorBlock.SDB_Height - MUL_FIXED(HUDScaleFactor,HUDLayout_Magazines_TopY - HUDLayout_Linespacing),
865 HUDLayout_Colour_MarineRed
866 );
867 D3D_RenderHUDString_Centred
868 (
869 GetTextString(roundsText),
870 xCentre,
871 ScreenDescriptorBlock.SDB_Height - MUL_FIXED(HUDScaleFactor,HUDLayout_Rounds_TopY),
872 HUDLayout_Colour_BrightWhite
873 );
874 D3D_RenderHUDNumber_Centred
875 (
876 rounds,
877 xCentre,
878 ScreenDescriptorBlock.SDB_Height - MUL_FIXED(HUDScaleFactor,HUDLayout_Rounds_TopY - HUDLayout_Linespacing),
879 HUDLayout_Colour_MarineRed
880 );
881
882
883 }
DrawPredatorEnergyBar(void)884 void DrawPredatorEnergyBar(void)
885 {
886 PLAYER_STATUS *playerStatusPtr= (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr);
887 PLAYER_WEAPON_DATA *weaponPtr = &(playerStatusPtr->WeaponSlot[playerStatusPtr->SelectedWeaponSlot]);
888 int maxHeight = ScreenDescriptorBlock.SDB_Height*3/4;
889 int h;
890 {
891 h = MUL_FIXED(DIV_FIXED(playerStatusPtr->FieldCharge,PLAYERCLOAK_MAXENERGY),maxHeight);
892
893 r2rect rectangle
894 (
895 ScreenDescriptorBlock.SDB_Width+HUDLayout_RightmostTextCentre*3/2,
896 ScreenDescriptorBlock.SDB_Height-h,
897 ScreenDescriptorBlock.SDB_Width+HUDLayout_RightmostTextCentre/2,
898 ScreenDescriptorBlock.SDB_Height
899
900 );
901 rectangle . AlphaFill
902 (
903 0xff, // unsigned char R,
904 0x00,// unsigned char G,
905 0x00,// unsigned char B,
906 128 // unsigned char translucency
907 );
908 }
909 if (weaponPtr->WeaponIDNumber == WEAPON_PRED_SHOULDERCANNON)
910 {
911 h = MUL_FIXED(playerStatusPtr->PlasmaCasterCharge,maxHeight);
912
913 r2rect rectangle
914 (
915 ScreenDescriptorBlock.SDB_Width+HUDLayout_RightmostTextCentre*3,
916 ScreenDescriptorBlock.SDB_Height-h,
917 ScreenDescriptorBlock.SDB_Width+HUDLayout_RightmostTextCentre*2,
918 ScreenDescriptorBlock.SDB_Height
919
920 );
921 rectangle . AlphaFill
922 (
923 0x00, // unsigned char R,
924 0xff,// unsigned char G,
925 0xff,// unsigned char B,
926 128 // unsigned char translucency
927 );
928 }
929
930 }
931
932 };
933