1 /*KJL**************************************************************************************
2 * ddplat.cpp - this contains all the display code for the HUD, menu screens and so forth. *
3 * *
4 **************************************************************************************KJL*/
5 extern "C" {
6
7 #include "3dc.h"
8 #include "module.h"
9 #include "inline.h"
10
11 #include "dxlog.h"
12
13 #include "stratdef.h"
14 #include "gamedef.h"
15 #include "gameplat.h"
16
17 #include "equipmnt.h"
18
19 #include "huddefs.h"
20 #include "hudgfx.h"
21
22 #include "font.h"
23
24 #include "kshape.h"
25 #include "chnktexi.h"
26 #include "awtexld.h"
27 #include "ffstdio.h"
28
29
30
31 #include "d3d_hud.h"
32
33 extern "C++"
34 {
35 #include "r2base.h"
36 #include "indexfnt.hpp"
37
38 #include "projload.hpp" // c++ header which ignores class definitions/member functions if __cplusplus is not defined ?
39 #include "chnkload.hpp" // c++ header which ignores class definitions/member functions if __cplusplus is not defined ?
40 #include "pcmenus.h"
41 };
42
43 //#include "alt_tab.h"
44
45 extern int ScanDrawMode;
46 extern int ZBufferMode;
47 extern IMAGEHEADER ImageHeaderArray[];
48 int BackdropImage;
49 //#define UseLocalAssert Yes
50 //#include "ourasert.h"
51
52
53 int UsingDataBase = 0;
54
55
56
57 /* HUD globals */
58 extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
59
60 #if 0 // SBF - unused
61 static int TrackerPolyBuffer[25];
62 static int ScanlinePolyBuffer[25];
63 static int MotionTrackerWidth;
64 static int MotionTrackerTextureSize;
65 static int MotionTrackerCentreY;
66 static int MotionTrackerCentreX;
67 static RECT MT_BarDestRect;
68 static int MT_BlipHeight;
69 static int MT_BlipWidth;
70 struct LittleMDescTag *MTLittleMPtr;
71 #endif
72
73 enum HUD_RES_ID HUDResolution;
74
75 /* display co-ords, etc. */
76 #include "hud_data.h"
77
78
79
80 static struct DDGraphicTag PauseDDInfo;
81 static struct DDGraphicTag E3FontDDInfo;
82
83
84 /*KJL****************************************************************************************
85 * P R O T O T Y P E S *
86 ****************************************************************************************KJL*/
87 void PlatformSpecificInitMarineHUD(void);
88 void PlatformSpecificInitPredatorHUD(void);
89
90 void PlatformSpecificExitingHUD(void);
91 void PlatformSpecificEnteringHUD(void);
92
93 void BLTMotionTrackerToHUD(int scanLineSize);
94 void BLTMotionTrackerBlipToHUD(int x, int y, int brightness);
95
96 #if 0
97 static void BLTDigitToHUD(char digit, int x, int y, int font);
98 void BLTPredatorOverlayToHUD(void);
99 static void DrawMotionTrackerPoly(void);
100 static void BLTPredatorDigitToHUD(char digit, int x, int y, int font);
101 #endif
102
103 void BLTGunSightToScreen(int screenX, int screenY, enum GUNSIGHT_SHAPE gunsightShape);
104 void BLTWeaponToHUD(PLAYER_WEAPON_DATA* weaponPtr);
105 int CueWeaponFrameFromSequence(struct WeaponFrameTag *weaponFramePtr, int timeOutCounter, int weaponIDNumber);
106
107
108
109 void BLTPredatorNumericsToHUD(void);
110
111 void LoadDDGraphic(struct DDGraphicTag *DDGfxPtr, char *Filename);
112
113 #if 0 // SBF - unused
114 static void SetupScanlinePoly(char const *filenamePtr, int width);
115 #endif
116
117 extern void D3D_InitialiseMarineHUD(void);
118 extern void D3D_BLTMotionTrackerToHUD(int scanLineSize);
119 extern void D3D_BLTMotionTrackerBlipToHUD(int x, int y, int brightness);
120 extern void D3D_BLTDigitToHUD(char digit, int x, int y, int font);
121 extern void D3D_BLTGunSightToHUD(int screenX, int screenY, enum GUNSIGHT_SHAPE gunsightShape);
122
123 extern void LoadCommonTextures(void);
124 /*KJL****************************************************************************************
125 * F U N C T I O N S *
126 ****************************************************************************************KJL*/
127
128
LoadDDGraphic(struct DDGraphicTag * DDGfxPtr,char * Filename)129 void LoadDDGraphic(struct DDGraphicTag *DDGfxPtr, char *Filename)
130 {
131 fprintf(stderr, "LoadDDGraphic(%p, %s)\n", DDGfxPtr, Filename);
132 }
133
134 /****************************************
135 * SETTING UP THE HUD *
136 ****************************************/
PlatformSpecificInitMarineHUD(void)137 void PlatformSpecificInitMarineHUD(void)
138 {
139 // SBF
140 // if ((ScanDrawMode != ScanDrawDirectDraw) && (ZBufferOn==ZBufferMode))
141
142 {
143 D3D_InitialiseMarineHUD();
144 LoadCommonTextures();
145 // ChromeImageNumber = CL_LoadImageOnce("Common\\chromelike.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
146 return;
147 }
148
149 #if 0 // SBF - unused
150 //SelectGenTexDirectory(ITI_TEXTURE);
151
152 /* set game mode: different, though for multiplayer game */
153 if(AvP.Network==I_No_Network)
154 cl_pszGameMode = "marine";
155 else
156 cl_pszGameMode = "multip";
157
158 // SetCurrentImageGroup(0);
159
160 // load_rif("avp_huds\\marine.rif");
161
162 // copy_chunks_from_environment(0);
163
164 /* load HUD gfx */
165 int gfxID = NO_OF_MARINE_HUD_GFX;
166 if (ScreenDescriptorBlock.SDB_Width>=800)
167 {
168 HUDResolution = HUD_RES_HI;
169 /* load Medres gfx */
170 while(gfxID--)
171 {
172 HUDDDInfo[gfxID].LPDDS = 0; // ensure 0 just in case one doesn't load and we try to delete it
173 LoadDDGraphic
174 (
175 &HUDDDInfo[gfxID],
176 HiresMarineHUDGfxFilenamePtr[gfxID]
177 );
178 }
179
180 TrackerPolyBuffer[3] = CL_LoadImageOnce("trakHiRz",(ScanDrawDirectDraw == ScanDrawMode ? LIO_CHIMAGE : LIO_D3DTEXTURE)|LIO_TRANSPARENT|LIO_RIFFPATH|LIO_RESTORABLE);
181 MotionTrackerWidth = 244;
182 MotionTrackerTextureSize = 243<<16;
183 MTLittleMPtr = &HiresHUDLittleM;
184
185 SetupScanlinePoly("scanhirz",MotionTrackerTextureSize);
186
187 LoadDDGraphic(&E3FontDDInfo,"e3fontMR");
188 }
189 else if (ScreenDescriptorBlock.SDB_Width>=640)
190 {
191 HUDResolution = HUD_RES_MED;
192 /* load Medres gfx */
193 while(gfxID--)
194 {
195 HUDDDInfo[gfxID].LPDDS = 0; // ensure 0 just in case one doesn't load and we try to delete it
196 LoadDDGraphic
197 (
198 &HUDDDInfo[gfxID],
199 MedresMarineHUDGfxFilenamePtr[gfxID]
200 );
201 }
202
203 TrackerPolyBuffer[3] = CL_LoadImageOnce("trakMdRz",(ScanDrawDirectDraw == ScanDrawMode ? LIO_CHIMAGE : LIO_D3DTEXTURE)|LIO_TRANSPARENT|LIO_RIFFPATH|LIO_RESTORABLE);
204 MotionTrackerWidth = 195;
205 MotionTrackerTextureSize = 194<<16;
206 MTLittleMPtr = &MedresHUDLittleM;
207
208 SetupScanlinePoly("scanmdrz",MotionTrackerTextureSize);
209
210 LoadDDGraphic(&E3FontDDInfo,"e3fontMR");
211 }
212 else
213 {
214 HUDResolution = HUD_RES_LO;
215
216 /* load lores gfx */
217 while(gfxID--)
218 {
219 HUDDDInfo[gfxID].LPDDS = 0; // ensure 0 just in case one doesn't load and we try to delete it
220 LoadDDGraphic
221 (
222 &HUDDDInfo[gfxID],
223 LoresMarineHUDGfxFilenamePtr[gfxID]
224 );
225 }
226 TrackerPolyBuffer[3] = CL_LoadImageOnce("tracker",(ScanDrawDirectDraw == ScanDrawMode ? LIO_CHIMAGE : LIO_D3DTEXTURE)|LIO_TRANSPARENT|LIO_RIFFPATH|LIO_RESTORABLE);
227 MotionTrackerWidth = 97;
228 MotionTrackerTextureSize = 96<<16;
229 MTLittleMPtr = &LoresHUDLittleM;
230
231 /* lores scanline slightly smaller than tracker... */
232 SetupScanlinePoly("scan",MotionTrackerTextureSize-65536);
233
234 LoadDDGraphic(&E3FontDDInfo,"e3font");
235 }
236
237 TrackerPolyBuffer[0] = I_2dTexturedPolygon;
238 TrackerPolyBuffer[2] = iflag_nolight|iflag_ignore0;
239
240 ScanlinePolyBuffer[0] = I_2dTexturedPolygon;
241 ScanlinePolyBuffer[2] = iflag_nolight|iflag_ignore0;
242
243 /* screen dest of blue bar under motion tracker */
244 MT_BarDestRect.bottom = ScreenDescriptorBlock.SDB_Height-1;
245 MT_BarDestRect.top = MT_BarDestRect.bottom - HUDDDInfo[MARINE_HUD_GFX_BLUEBAR].SrcRect.bottom;
246 MT_BarDestRect.left = 0;//MotionTrackerWidth/4;
247 MT_BarDestRect.right = MT_BarDestRect.left + HUDDDInfo[MARINE_HUD_GFX_BLUEBAR].SrcRect.right;
248
249 /* centre of motion tracker */
250 MotionTrackerCentreY = MT_BarDestRect.top+1;
251 MotionTrackerCentreX = (MT_BarDestRect.left+MT_BarDestRect.right)/2;
252
253 /* motion tracker blips */
254 MT_BlipHeight = HUDDDInfo[MARINE_HUD_GFX_MOTIONTRACKERBLIP].SrcRect.bottom/5;
255 MT_BlipWidth = HUDDDInfo[MARINE_HUD_GFX_MOTIONTRACKERBLIP].SrcRect.right;
256
257
258 LoadDDGraphic(&PauseDDInfo,"paused");
259 #endif // SBF
260 }
261
PlatformSpecificInitPredatorHUD(void)262 void PlatformSpecificInitPredatorHUD(void)
263 {
264 //SelectGenTexDirectory(ITI_TEXTURE);
265 /* set game mode: different, though for multiplayer game */
266 if(AvP.Network==I_No_Network)
267 {
268 cl_pszGameMode = "predator";
269 /* load in sfx */
270 LoadCommonTextures();
271 }
272 else
273 {
274 cl_pszGameMode = "multip";
275 /* load in sfx */
276 LoadCommonTextures();
277 //load marine stuff as well
278 D3D_InitialiseMarineHUD();
279 }
280 return;
281
282 #if 0 // SBF - unused
283 int gfxID = NO_OF_PREDATOR_HUD_GFX;
284
285 if (ScreenDescriptorBlock.SDB_Width>=640)
286 {
287 HUDResolution = HUD_RES_MED;
288 /* load Medres gfx */
289 while(gfxID--)
290 {
291 HUDDDInfo[gfxID].LPDDS = 0; // ensure 0 just in case one doesn't load and we try to delete it
292 LoadDDGraphic
293 (
294 &HUDDDInfo[gfxID],
295 MedresPredatorHUDGfxFilenamePtr[gfxID]
296 );
297 }
298 LoadDDGraphic(&E3FontDDInfo,"e3fontmr");
299 }
300 else
301 {
302 /* load Lores gfx */
303 int gfxID = NO_OF_PREDATOR_HUD_GFX;
304 while(gfxID--)
305 {
306 HUDDDInfo[gfxID].LPDDS = 0; // ensure 0 just in case one doesn't load and we try to delete it
307 LoadDDGraphic
308 (
309 &HUDDDInfo[gfxID],
310 LoresPredatorHUDGfxFilenamePtr[gfxID]
311 );
312 }
313 LoadDDGraphic(&E3FontDDInfo,"e3font");
314 }
315 LoadDDGraphic(&PauseDDInfo,"paused");
316 #endif // SBF
317 }
318
319
PlatformSpecificInitAlienHUD(void)320 void PlatformSpecificInitAlienHUD(void)
321 {
322 //SelectGenTexDirectory(ITI_TEXTURE);
323 /* set game mode: different, though for multiplayer game */
324 if(AvP.Network==I_No_Network)
325 {
326 cl_pszGameMode = "alien";
327 LoadCommonTextures();
328 }
329 else
330 {
331 cl_pszGameMode = "multip";
332 /* load in sfx */
333 LoadCommonTextures();
334 //load marine stuff as well
335 D3D_InitialiseMarineHUD();
336 }
337
338 return;
339
340 #if 0 // SBF - unused
341 int gfxID = NO_OF_ALIEN_HUD_GFX;
342
343 if (ScreenDescriptorBlock.SDB_Width==640)
344 {
345 HUDResolution = HUD_RES_MED;
346 /* load Medres gfx */
347 while(gfxID--)
348 {
349 HUDDDInfo[gfxID].LPDDS = 0; // ensure 0 just in case one doesn't load and we try to delete it
350 LoadDDGraphic
351 (
352 &HUDDDInfo[gfxID],
353 MedresAlienHUDGfxFilenamePtr[gfxID]
354 );
355 }
356 LoadDDGraphic(&E3FontDDInfo,"e3fontmr");
357 }
358 else
359 {
360 HUDResolution = HUD_RES_LO;
361
362 /* load lores gfx */
363 while(gfxID--)
364 {
365 HUDDDInfo[gfxID].LPDDS = 0; // ensure 0 just in case one doesn't load and we try to delete it
366 LoadDDGraphic
367 (
368 &HUDDDInfo[gfxID],
369 LoresAlienHUDGfxFilenamePtr[gfxID]
370 );
371 }
372 LoadDDGraphic(&E3FontDDInfo,"e3font");
373 }
374 LoadDDGraphic(&PauseDDInfo,"paused");
375 #endif // SBF
376 }
377
378
379 /*JH 14/5/97*****************************
380 * KILLING THE HUD *
381 ************************************JH**/
382
383
PlatformSpecificKillMarineHUD(void)384 void PlatformSpecificKillMarineHUD(void)
385 {
386 int gfxID = NO_OF_MARINE_HUD_GFX;
387
388 while(gfxID--)
389 {
390 if (HUDDDInfo[gfxID].hBackup)
391 {
392 ATRemoveSurface(HUDDDInfo[gfxID].LPDDS);
393 AwDestroyBackupTexture( HUDDDInfo[gfxID].hBackup );
394 }
395 if (HUDDDInfo[gfxID].LPDDS)
396 // HUDDDInfo[gfxID].LPDDS->Release();
397 fprintf(stderr, "PlatformSpecificKillMarineHUD: HUDDDInfo[gfxID].LPDDS\n");
398
399 HUDDDInfo[gfxID].LPDDS = 0;
400 HUDDDInfo[gfxID].hBackup = 0;
401 }
402
403 if (PauseDDInfo.hBackup)
404 {
405 ATRemoveSurface(PauseDDInfo.LPDDS);
406 AwDestroyBackupTexture( PauseDDInfo.hBackup );
407 }
408 if (PauseDDInfo.LPDDS)
409 // PauseDDInfo.LPDDS->Release();
410 fprintf(stderr, "PlatformSpecificKillMarineHUD: PauseDDInfo.LPDDS\n");
411
412 PauseDDInfo.LPDDS = 0;
413 PauseDDInfo.hBackup = 0;
414
415 if (E3FontDDInfo.hBackup)
416 {
417 ATRemoveSurface(E3FontDDInfo.LPDDS);
418 AwDestroyBackupTexture( E3FontDDInfo.hBackup );
419 }
420 if (E3FontDDInfo.LPDDS)
421 // E3FontDDInfo.LPDDS->Release();
422 fprintf(stderr, "PlatformSpecificKillMarineHUD: E3FontDDInfo.LPDDS\n");
423
424 E3FontDDInfo.LPDDS = 0;
425 E3FontDDInfo.hBackup = 0;
426 }
427
PlatformSpecificKillPredatorHUD(void)428 void PlatformSpecificKillPredatorHUD(void)
429 {
430 /* load HUD gfx */
431 int gfxID = NO_OF_PREDATOR_HUD_GFX;
432
433 while(gfxID--)
434 {
435 if (HUDDDInfo[gfxID].hBackup)
436 {
437 ATRemoveSurface(HUDDDInfo[gfxID].LPDDS);
438 AwDestroyBackupTexture( HUDDDInfo[gfxID].hBackup );
439 }
440 if (HUDDDInfo[gfxID].LPDDS)
441 // HUDDDInfo[gfxID].LPDDS->Release();
442 fprintf(stderr, "PlatformSpecificKillPredatorHUD: HUDDDInfo[gfxID].LPDDS\n");
443
444 HUDDDInfo[gfxID].LPDDS = 0;
445 HUDDDInfo[gfxID].hBackup = 0;
446 }
447
448 if (PauseDDInfo.hBackup)
449 {
450 ATRemoveSurface(PauseDDInfo.LPDDS);
451 AwDestroyBackupTexture( PauseDDInfo.hBackup );
452 }
453 if (PauseDDInfo.LPDDS)
454 // PauseDDInfo.LPDDS->Release();
455 fprintf(stderr, "PlatformSpecificKillPredatorHUD: PauseDDInfo.LPDDS\n");
456
457 PauseDDInfo.LPDDS = 0;
458 PauseDDInfo.hBackup = 0;
459
460 if (E3FontDDInfo.hBackup)
461 {
462 ATRemoveSurface(E3FontDDInfo.LPDDS);
463 AwDestroyBackupTexture( E3FontDDInfo.hBackup );
464 }
465 if (E3FontDDInfo.LPDDS)
466 // E3FontDDInfo.LPDDS->Release();
467 fprintf(stderr, "PlatformSpecificKillPredatorHUD: E3FontDDInfo.LPDDS\n");
468
469 E3FontDDInfo.LPDDS = 0;
470 E3FontDDInfo.hBackup = 0;
471 }
472
473
PlatformSpecificKillAlienHUD(void)474 void PlatformSpecificKillAlienHUD(void)
475 {
476 int gfxID = NO_OF_ALIEN_HUD_GFX;
477 while(gfxID--)
478 {
479 if (HUDDDInfo[gfxID].hBackup)
480 {
481 ATRemoveSurface(HUDDDInfo[gfxID].LPDDS);
482 AwDestroyBackupTexture( HUDDDInfo[gfxID].hBackup );
483 }
484 if (HUDDDInfo[gfxID].LPDDS)
485 // HUDDDInfo[gfxID].LPDDS->Release();
486 fprintf(stderr, "PlatformSpecificKillAlienHUD: HUDDDInfo[gfxID].LPDDS\n");
487
488 HUDDDInfo[gfxID].LPDDS = 0;
489 HUDDDInfo[gfxID].hBackup = 0;
490 }
491
492 if (PauseDDInfo.hBackup)
493 {
494 ATRemoveSurface(PauseDDInfo.LPDDS);
495 AwDestroyBackupTexture( PauseDDInfo.hBackup );
496 }
497 if (PauseDDInfo.LPDDS)
498 // PauseDDInfo.LPDDS->Release();
499 fprintf(stderr, "PlatformSpecificKillAlienHUD: PauseDDInfo.LPDDS\n");
500
501 PauseDDInfo.LPDDS = 0;
502 PauseDDInfo.hBackup = 0;
503
504 if (E3FontDDInfo.hBackup)
505 {
506 ATRemoveSurface(E3FontDDInfo.LPDDS);
507 AwDestroyBackupTexture( E3FontDDInfo.hBackup );
508 }
509 if (E3FontDDInfo.LPDDS)
510 // E3FontDDInfo.LPDDS->Release();
511 fprintf(stderr, "PlatformSpecificKillAlienHUD: E3FontDDInfo.LPDDS\n");
512
513 E3FontDDInfo.LPDDS = 0;
514 E3FontDDInfo.hBackup = 0;
515 }
516
517
518 /*********************/
519 /* RUNTIME HUD STUFF */
520 /*********************/
521
PlatformSpecificExitingHUD(void)522 void PlatformSpecificExitingHUD(void)
523 {
524 #if 0
525 /* KJL 11:37:19 06/14/97 - draw whatever is in the execute buffer */
526 if (ScanDrawMode != ScanDrawDirectDraw)
527 {
528 WriteEndCodeToExecuteBuffer();
529 UnlockExecuteBufferAndPrepareForUse();
530 ExecuteBuffer();
531 EndD3DScene();
532 }
533 #endif
534 }
535
PlatformSpecificEnteringHUD(void)536 void PlatformSpecificEnteringHUD(void)
537 {
538 /* JH 13/5/97 */
539 /* Flush the ZBuffer so the weapons don't sink into the wall! */
540 #if SupportZBuffering
541 if ((ScanDrawMode != ScanDrawDirectDraw) && (ZBufferMode != ZBufferOff))
542 {
543 // FlushD3DZBuffer();
544 }
545 #endif
546
547 #if 0
548 /* KJL 11:37:49 06/14/97 - reinit execute buffer */
549 if (ScanDrawMode != ScanDrawDirectDraw)
550 {
551 BeginD3DScene();
552 LockExecuteBuffer();
553 }
554 #endif
555 }
556
557 /*KJL**********************
558 * MARINE DRAWING ROUTINES *
559 **********************KJL*/
BLTMotionTrackerToHUD(int scanLineSize)560 void BLTMotionTrackerToHUD(int scanLineSize)
561 {
562 // if (VideoModeType_8 != VideoModeTypeScreen) return;
563 if ((ScanDrawMode != ScanDrawDirectDraw) && (ZBufferOn==ZBufferMode))
564 {
565 D3D_BLTMotionTrackerToHUD(scanLineSize);
566 }
567 return;
568
569 }
570
BLTMotionTrackerBlipToHUD(int x,int y,int brightness)571 void BLTMotionTrackerBlipToHUD(int x, int y, int brightness)
572 {
573 if ((ScanDrawMode != ScanDrawDirectDraw) && (ZBufferOn==ZBufferMode))
574 {
575 D3D_BLTMotionTrackerBlipToHUD(x,y,brightness);
576 }
577 return;
578
579 }
580
581
582 /*KJL*******************
583 * Draw numerics to HUD *
584 *******************KJL*/
BLTMarineNumericsToHUD(enum MARINE_HUD_DIGIT digitsToDraw)585 extern void BLTMarineNumericsToHUD(enum MARINE_HUD_DIGIT digitsToDraw)
586 {
587 int digit = digitsToDraw;
588 struct DigitPropertiesTag *propertiesPtr;
589
590
591 if (HUDResolution == HUD_RES_LO)
592 {
593 propertiesPtr = &LoresMarineHUDDigitProperties[digit];
594 }
595 else if (HUDResolution == HUD_RES_MED)
596 {
597 propertiesPtr = &MedresMarineHUDDigitProperties[digit];
598 }
599 else
600 {
601 propertiesPtr = &HiresMarineHUDDigitProperties[digit];
602 }
603
604 do
605 {
606 /* paranoia check */
607 LOCALASSERT(ValueOfHUDDigit[digit]>=0 && ValueOfHUDDigit[digit]<=9);
608
609 if ((ScanDrawMode != ScanDrawDirectDraw) && (ZBufferOn==ZBufferMode))
610 {
611 D3D_BLTDigitToHUD
612 (
613 ValueOfHUDDigit[digit],
614 propertiesPtr->X,
615 propertiesPtr->Y,
616 propertiesPtr->Font
617 );
618 }
619 propertiesPtr--;
620 }
621 while(digit--);
622 }
623
624 #if 0 /* SBF - TODO: remove */
625 static void BLTDigitToHUD(char digit, int x, int y, int font)
626 {
627 // HRESULT ddrval;
628 struct HUDFontDescTag *FontDescPtr;
629 RECT srcRect;
630 int gfxID;
631
632 switch (font)
633 {
634 case MARINE_HUD_FONT_MT_SMALL:
635 case MARINE_HUD_FONT_MT_BIG:
636 {
637 gfxID = MARINE_HUD_GFX_TRACKERFONT;
638 y+=MotionTrackerCentreY;
639 x+=MotionTrackerCentreX;
640 break;
641 }
642 case MARINE_HUD_FONT_RED:
643 case MARINE_HUD_FONT_BLUE:
644 {
645 if (x<0) x+=ScreenDescriptorBlock.SDB_Width;
646 gfxID = MARINE_HUD_GFX_NUMERALS;
647 break;
648 }
649 case ALIEN_HUD_FONT:
650 {
651 gfxID = ALIEN_HUD_GFX_NUMBERS;
652 break;
653 }
654 default:
655 LOCALASSERT(0);
656 break;
657 }
658
659
660 if (HUDResolution == HUD_RES_LO)
661 {
662 FontDescPtr = &LoresHUDFontDesc[font];
663 }
664 else if (HUDResolution == HUD_RES_MED)
665 {
666 FontDescPtr = &MedresHUDFontDesc[font];
667 }
668 else
669 {
670 FontDescPtr = &HiresHUDFontDesc[font];
671 }
672
673 srcRect.top = digit*FontDescPtr->Height;
674 srcRect.bottom =srcRect.top + FontDescPtr->Height;
675 srcRect.left = FontDescPtr->XOffset;
676 srcRect.right = srcRect.left + FontDescPtr->Width;
677 /*
678 ddrval = lpDDSBack->BltFast
679 (
680 x,y,
681 HUDDDInfo[gfxID].LPDDS,
682 &srcRect,
683 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
684 );
685
686 if(ddrval != DD_OK)
687 {
688 ReleaseDirect3D();
689 exit(0x666004);
690 }
691 */
692 fprintf(stderr, "BLTDigitToHUD(%d, %d, %d, %d)\n", digit, x, y, font);
693 }
694 #endif
695
696
BLTGunSightToScreen(int screenX,int screenY,enum GUNSIGHT_SHAPE gunsightShape)697 void BLTGunSightToScreen(int screenX, int screenY, enum GUNSIGHT_SHAPE gunsightShape)
698 {
699 if ((ScanDrawMode != ScanDrawDirectDraw) && (ZBufferOn==ZBufferMode))
700 {
701 D3D_BLTGunSightToHUD(screenX,screenY,gunsightShape);
702 return;
703 }
704 }
705
706
707 #if 0 /* SBF - TODO: remove this directdraw code */
708
709
710 /*KJL************************
711 * PREDATOR DRAWING ROUTINES *
712 ************************KJL*/
713 void BLTPredatorOverlayToHUD(void)
714 {
715 /* KJL 11:37:19 06/14/97 - draw whatever is in the execute buffer */
716 if (ScanDrawMode != ScanDrawDirectDraw)
717 {
718 WriteEndCodeToExecuteBuffer();
719 UnlockExecuteBufferAndPrepareForUse();
720 ExecuteBuffer();
721 EndD3DScene();
722 }
723
724 // HRESULT ddrval;
725 if ((ScreenDescriptorBlock.SDB_Height ==200) ||(ScreenDescriptorBlock.SDB_Width ==320) )
726 {
727 /*
728 ddrval = lpDDSBack->BltFast
729 (
730 0,
731 13,
732 HUDDDInfo[PREDATOR_HUD_GFX_TOP].LPDDS,
733 &(HUDDDInfo[PREDATOR_HUD_GFX_TOP].SrcRect),
734 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
735 );
736 ddrval = lpDDSBack->BltFast
737 (
738 0,
739 136,
740 HUDDDInfo[PREDATOR_HUD_GFX_BOTTOM].LPDDS,
741 &(HUDDDInfo[PREDATOR_HUD_GFX_BOTTOM].SrcRect),
742 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
743 );
744 */
745 fprintf(stderr, "BLTPredatorOverlayToHUD: blit 1\n");
746 }
747 else if ((ScreenDescriptorBlock.SDB_Height ==480) ||(ScreenDescriptorBlock.SDB_Width ==640) )
748 {
749 /*
750 ddrval = lpDDSBack->BltFast
751 (
752 1,
753 13*2,
754 HUDDDInfo[PREDATOR_HUD_GFX_TOP].LPDDS,
755 &(HUDDDInfo[PREDATOR_HUD_GFX_TOP].SrcRect),
756 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
757 );
758 ddrval = lpDDSBack->BltFast
759 (
760 1,
761 136*2+80,
762 HUDDDInfo[PREDATOR_HUD_GFX_BOTTOM].LPDDS,
763 &(HUDDDInfo[PREDATOR_HUD_GFX_BOTTOM].SrcRect),
764 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
765 );
766 */
767 fprintf(stderr, "BLTPredatorOverlayToHUD: blit 2\n");
768 }
769 }
770 void BLTPredatorNumericsToHUD(void)
771 {
772 int digit = MAX_NO_OF_PREDATOR_HUD_DIGITS;
773
774 struct DigitPropertiesTag *propertiesPtr;
775
776 if (HUDResolution == HUD_RES_LO)
777 {
778 propertiesPtr = &LoresPredatorHUDDigitProperties[digit];
779 }
780 else
781 {
782 propertiesPtr = &MedresPredatorHUDDigitProperties[digit];
783 }
784
785 while(digit)
786 {
787 digit--;
788 propertiesPtr--;
789 /* paranoia check */
790 LOCALASSERT(ValueOfHUDDigit[digit]>=0 && ValueOfHUDDigit[digit]<=9);
791
792 BLTPredatorDigitToHUD
793 (
794 ValueOfHUDDigit[digit],
795 propertiesPtr->X,
796 propertiesPtr->Y,
797 propertiesPtr->Font
798 );
799 }
800 }
801 static void BLTPredatorDigitToHUD(char digit, int x, int y, int font)
802 {
803 // HRESULT ddrval;
804 RECT srcRect;
805
806 srcRect.top = digit*12;
807 srcRect.bottom = digit*12+12;
808
809 srcRect.left = 0;
810 srcRect.right = HUDDDInfo[font].SrcRect.right;
811
812 /*
813 ddrval = lpDDSBack->BltFast
814 (
815 x,
816 y,
817 HUDDDInfo[font].LPDDS,
818 &srcRect,
819 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
820 );
821
822 if(ddrval != DD_OK)
823 {
824 ReleaseDirect3D();
825 exit(0x666004);
826 }
827 */
828 fprintf(stderr, "BLTPredatorDigitToHUD(%d, %d, %d, %d)\n", digit, x, y, font);
829 }
830
831 /*KJL*********************
832 * ALIEN DRAWING ROUTINES *
833 *********************KJL*/
834 extern void BLTAlienOverlayToHUD(void)
835 {
836 /* KJL 11:37:19 06/14/97 - draw whatever is in the execute buffer */
837 if (ScanDrawMode != ScanDrawDirectDraw)
838 {
839 WriteEndCodeToExecuteBuffer();
840 UnlockExecuteBufferAndPrepareForUse();
841 ExecuteBuffer();
842 EndD3DScene();
843 }
844
845 /* KJL 10:24:49 7/17/97 - no overlay, please */
846 return;
847
848 // HRESULT ddrval;
849 if ((ScreenDescriptorBlock.SDB_Height ==200)&&(ScreenDescriptorBlock.SDB_Width ==320))
850 {
851 /*
852 ddrval = lpDDSBack->BltFast
853 (
854 0,
855 0,
856 HUDDDInfo[ALIEN_HUD_GFX_TOP].LPDDS,
857 &(HUDDDInfo[ALIEN_HUD_GFX_TOP].SrcRect),
858 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
859 );
860 ddrval = lpDDSBack->BltFast
861 (
862 0,
863 25,
864 HUDDDInfo[ALIEN_HUD_GFX_LEFT].LPDDS,
865 &(HUDDDInfo[ALIEN_HUD_GFX_LEFT].SrcRect),
866 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
867 );
868 ddrval = lpDDSBack->BltFast
869 (
870 320-48,
871 25,
872 HUDDDInfo[ALIEN_HUD_GFX_RIGHT].LPDDS,
873 &(HUDDDInfo[ALIEN_HUD_GFX_RIGHT].SrcRect),
874 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
875 );
876 ddrval = lpDDSBack->BltFast
877 (
878 0,
879 160,
880 HUDDDInfo[ALIEN_HUD_GFX_BOTTOM].LPDDS,
881 &(HUDDDInfo[ALIEN_HUD_GFX_BOTTOM].SrcRect),
882 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
883 );
884 */
885 fprintf(stderr, "BLTAlienOverlayToHUD: blit 1\n");
886 }
887 else if ((ScreenDescriptorBlock.SDB_Height ==480)&&(ScreenDescriptorBlock.SDB_Width ==640))
888 {
889 /*
890 ddrval = lpDDSBack->BltFast
891 (
892 0,
893 0,
894 HUDDDInfo[ALIEN_HUD_GFX_TOP].LPDDS,
895 &(HUDDDInfo[ALIEN_HUD_GFX_TOP].SrcRect),
896 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
897 );
898 ddrval = lpDDSBack->BltFast
899 (
900 0,
901 52,
902 HUDDDInfo[ALIEN_HUD_GFX_LEFT].LPDDS,
903 &(HUDDDInfo[ALIEN_HUD_GFX_LEFT].SrcRect),
904 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
905 );
906 ddrval = lpDDSBack->BltFast
907 (
908 640-97,
909 52,
910 HUDDDInfo[ALIEN_HUD_GFX_RIGHT].LPDDS,
911 &(HUDDDInfo[ALIEN_HUD_GFX_RIGHT].SrcRect),
912 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
913 );
914 ddrval = lpDDSBack->BltFast
915 (
916 0,
917 480-97,
918 HUDDDInfo[ALIEN_HUD_GFX_BOTTOM].LPDDS,
919 &(HUDDDInfo[ALIEN_HUD_GFX_BOTTOM].SrcRect),
920 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
921 );
922 */
923 fprintf(stderr, "BLTAlienOverlayToHUD: blit 2\n");
924 }
925
926 }
927 void BLTAlienNumericsToHUD(void)
928 {
929
930 if ((ScreenDescriptorBlock.SDB_Height ==200)&&(ScreenDescriptorBlock.SDB_Width ==320))
931 {
932 int digit = MAX_NO_OF_ALIEN_HUD_DIGITS;
933
934 while(digit)
935 {
936 digit--;
937 /* paranoia check */
938 LOCALASSERT(ValueOfHUDDigit[digit]>=0 && ValueOfHUDDigit[digit]<=9);
939
940 BLTDigitToHUD
941 (
942 ValueOfHUDDigit[digit],
943 LoresAlienHUDDigitProperties[digit].X,
944 LoresAlienHUDDigitProperties[digit].Y,
945 LoresAlienHUDDigitProperties[digit].Font
946 );
947 }
948 }
949 else if ((ScreenDescriptorBlock.SDB_Height ==480)&&(ScreenDescriptorBlock.SDB_Width ==640))
950 {
951 int digit = MAX_NO_OF_ALIEN_HUD_DIGITS;
952
953 while(digit)
954 {
955 digit--;
956 /* paranoia check */
957 LOCALASSERT(ValueOfHUDDigit[digit]>=0 && ValueOfHUDDigit[digit]<=9);
958
959 BLTDigitToHUD
960 (
961 ValueOfHUDDigit[digit],
962 MedresAlienHUDDigitProperties[digit].X,
963 MedresAlienHUDDigitProperties[digit].Y,
964 MedresAlienHUDDigitProperties[digit].Font
965 );
966 }
967 }
968 }
969
970
971
972
973 void BLTPausedToScreen(void)
974 {
975 /*
976 lpDDSBack->BltFast
977 (
978 (ScreenDescriptorBlock.SDB_Width-PauseDDInfo.SrcRect.right)/2,
979 (ScreenDescriptorBlock.SDB_Height-PauseDDInfo.SrcRect.bottom)/2,
980 PauseDDInfo.LPDDS,
981 &(PauseDDInfo.SrcRect),
982 DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY
983 );
984 */
985 fprintf(stderr, "BLTPausedToScreen()\n");
986 }
987
988
989
990 void LoadDDGraphic(struct DDGraphicTag *DDGfxPtr, char *Filename)
991 {
992 /*
993 set up the direct draw surface. we can take the width and height
994 from the imageheader image
995 */
996
997 GLOBALASSERT(DDGfxPtr);
998 GLOBALASSERT(Filename);
999
1000 // get the filename that we need
1001 char szAbsFileName[MAX_PATH];
1002 char * pszRet = CL_GetImageFileName(szAbsFileName,sizeof szAbsFileName / sizeof szAbsFileName[0], Filename, LIO_DDSURFACE|LIO_SYSMEM|LIO_TRANSPARENT|LIO_CHROMAKEY|LIO_RIFFPATH|LIO_RESTORABLE);
1003 GLOBALASSERT(pszRet);
1004
1005 // we'll put the width and height in here
1006 unsigned nWidth, nHeight;
1007
1008 // is it in a fast file?
1009 unsigned nFastFileLen;
1010 void const * pFastFileData = ffreadbuf(szAbsFileName,&nFastFileLen);
1011
1012 if (pFastFileData)
1013 {
1014 DDGfxPtr->LPDDS =
1015 AwCreateSurface
1016 (
1017 "pxfXYB",
1018 pFastFileData,
1019 nFastFileLen,
1020 AW_TLF_TRANSP|AW_TLF_CHROMAKEY,
1021 &nWidth,
1022 &nHeight,
1023 &DDGfxPtr->hBackup
1024 );
1025 }
1026 else
1027 {
1028 DDGfxPtr->LPDDS =
1029 AwCreateSurface
1030 (
1031 "sfXYB",
1032 &szAbsFileName[0],
1033 AW_TLF_TRANSP|AW_TLF_CHROMAKEY,
1034 &nWidth,
1035 &nHeight,
1036 &DDGfxPtr->hBackup
1037 );
1038 }
1039
1040 GLOBALASSERT(DDGfxPtr->LPDDS);
1041 GLOBALASSERT(DDGfxPtr->hBackup);
1042 ATIncludeSurface(DDGfxPtr->LPDDS,DDGfxPtr->hBackup);
1043
1044 // set the rectangle size for blitting before padding to 4x4 has been done
1045 DDGfxPtr->SrcRect.left = 0;
1046 DDGfxPtr->SrcRect.right = nWidth;
1047 DDGfxPtr->SrcRect.top = 0;
1048 DDGfxPtr->SrcRect.bottom = nHeight;
1049
1050 /*move the width and height to four byte bounadries*/
1051
1052 GLOBALASSERT((DDGfxPtr->SrcRect.right > 0));
1053 GLOBALASSERT((DDGfxPtr->SrcRect.bottom > 0));
1054 }
1055
1056
1057 /* JH 3/6/97 functions to remove dd surfaces from hud graphics
1058 so that the video mode can be completely changed,
1059 but then everything can still be restored */
1060 /* perhaps not a final solution since it will be occupying memory */
1061
1062 void MinimizeAllDDGraphics(void)
1063 {
1064 /* do all in array - don't care how many actually are used
1065 because the array is static (hence initially filled with zeros)
1066 The release functions should replace with NULL a pointer
1067 that is no longer valid */
1068
1069 int gfxID = sizeof HUDDDInfo / sizeof (DDGraphicTag); // number of DDGraphicTags in array
1070
1071 while(gfxID--)
1072 {
1073 if (HUDDDInfo[gfxID].LPDDS)
1074 {
1075 ATRemoveSurface(HUDDDInfo[gfxID].LPDDS);
1076 // HUDDDInfo[gfxID].LPDDS->Release();
1077 fprintf(stderr, "MinimizeAllDDGraphics: HUDDDInfo[gfxID].LPDDS\n");
1078 HUDDDInfo[gfxID].LPDDS = 0;
1079 }
1080 }
1081
1082 if (PauseDDInfo.LPDDS)
1083 {
1084 ATRemoveSurface(PauseDDInfo.LPDDS);
1085 // PauseDDInfo.LPDDS->Release();
1086 fprintf(stderr, "MinimizeAllDDGraphics: PauseDDInfo.LPDDS\n");
1087 PauseDDInfo.LPDDS = 0;
1088 }
1089
1090 if (E3FontDDInfo.LPDDS)
1091 {
1092 ATRemoveSurface(E3FontDDInfo.LPDDS);
1093 // E3FontDDInfo.LPDDS->Release();
1094 fprintf(stderr, "MinimizeAllDDGraphics: E3FontDDInfo.LPDDS\n");
1095 E3FontDDInfo.LPDDS = 0;
1096 }
1097 }
1098
1099 void RestoreAllDDGraphics(void)
1100 {
1101 /* do all in array - don't care how many actually are used
1102 because the array is static (hence initially filled with zeros)
1103 The release functions should replace with NULL a pointer
1104 that is no longer valid */
1105
1106 int gfxID = sizeof HUDDDInfo / sizeof (DDGraphicTag); // number of DDGraphicTags in array
1107
1108 while(gfxID--)
1109 {
1110 if (HUDDDInfo[gfxID].hBackup)
1111 {
1112 HUDDDInfo[gfxID].LPDDS = AwCreateSurface("rf",HUDDDInfo[gfxID].hBackup,AW_TLF_PREVSRC|AW_TLF_CHROMAKEY);
1113 GLOBALASSERT(HUDDDInfo[gfxID].LPDDS);
1114 ATIncludeSurface(HUDDDInfo[gfxID].LPDDS,HUDDDInfo[gfxID].hBackup);
1115 }
1116 }
1117
1118 if (PauseDDInfo.hBackup)
1119 {
1120 PauseDDInfo.LPDDS = AwCreateSurface("rf",PauseDDInfo.hBackup,AW_TLF_PREVSRC|AW_TLF_CHROMAKEY);
1121 GLOBALASSERT(PauseDDInfo.LPDDS);
1122 ATIncludeSurface(PauseDDInfo.LPDDS,PauseDDInfo.hBackup);
1123 }
1124
1125 if (E3FontDDInfo.hBackup)
1126 {
1127 E3FontDDInfo.LPDDS = AwCreateSurface("rf",E3FontDDInfo.hBackup,AW_TLF_PREVSRC|AW_TLF_CHROMAKEY);
1128 GLOBALASSERT(E3FontDDInfo.LPDDS);
1129 ATIncludeSurface(E3FontDDInfo.LPDDS,E3FontDDInfo.hBackup);
1130 }
1131 }
1132
1133
1134 /************************** FONTS *************************/
1135 /**********************************************************/
1136 /**********************************************************/
1137
1138 //static int BLTFontCharToHUD(PFFONT* font , int xdest, int ydest, char todraw);
1139
1140 LPDIRECTDRAWSURFACE FontLPDDS[NUM_FONTS];
1141
1142 PFFONT AvpFonts[] =
1143 {
1144 {
1145 FontLPDDS[0],
1146 "menufont.bmp",
1147 18, // font height
1148 118, // num chars
1149 I_FONT_UCLC_NUMERIC,
1150 {0} //flags
1151
1152 },
1153 {
1154 FontLPDDS[1],
1155 "Common\\fontdark.RIM",
1156 14, // font height
1157 59, // num chars
1158 I_FONT_UC_NUMERIC
1159 },
1160 {
1161 FontLPDDS[2],
1162 "Common\\fontlite.RIM",
1163 14, // font height
1164 59, // num chars
1165 I_FONT_UC_NUMERIC
1166 },
1167 {
1168 FontLPDDS[3],
1169 "Common\\dbfont.RIM",
1170 11, // font height
1171 59, // num chars
1172 I_FONT_UC_NUMERIC
1173 }
1174 };
1175
1176 extern int VideoModeColourDepth;
1177
1178 void LoadFont(PFFONT *pffont)
1179 {
1180 GLOBALASSERT(pffont);
1181 GLOBALASSERT(pffont->filename);
1182
1183 // get the filename that we need
1184 char szAbsFileName[MAX_PATH];
1185 char * pszRet = CL_GetImageFileName(szAbsFileName,sizeof szAbsFileName / sizeof szAbsFileName[0], pffont->filename, LIO_DDSURFACE|LIO_SYSMEM|LIO_CHROMAKEY|LIO_TRANSPARENT
1186 // hack for the moment so that the menu font is correctly loaded into an 8-bit vid mode
1187 |(strchr(pffont->filename,'\\') ? LIO_RELATIVEPATH : LIO_RIFFPATH));
1188 GLOBALASSERT(pszRet);
1189
1190
1191 // we'll put the width and height in here
1192 unsigned nWidth, nHeight;
1193
1194 // is it in a fast file?
1195 unsigned nFastFileLen;
1196 void const * pFastFileData = ffreadbuf(szAbsFileName,&nFastFileLen);
1197
1198 if (pFastFileData)
1199 {
1200 pffont->data =
1201 AwCreateSurface
1202 (
1203 "pxfXYB",
1204 pFastFileData,
1205 nFastFileLen,
1206 AW_TLF_TRANSP|AW_TLF_CHROMAKEY,
1207 &nWidth,
1208 &nHeight,
1209 &pffont->hBackup
1210 );
1211 }
1212 else
1213 {
1214 pffont->data =
1215 AwCreateSurface
1216 (
1217 "sfXYB",
1218 &szAbsFileName[0],
1219 AW_TLF_TRANSP|AW_TLF_CHROMAKEY,
1220 &nWidth,
1221 &nHeight,
1222 &pffont->hBackup
1223 );
1224 }
1225
1226 GLOBALASSERT(pffont->data);
1227 GLOBALASSERT(pffont->hBackup);
1228
1229 ATIncludeSurface(pffont->data,pffont->hBackup);
1230
1231 pffont->fttexBitDepth = VideoModeColourDepth;
1232
1233 pffont->fttexWidth = nWidth;
1234 pffont->fttexHeight = nHeight;
1235
1236 GLOBALASSERT((nHeight > 0));
1237 GLOBALASSERT((nWidth > 0));
1238
1239 pffont->flags.loaded = 1;
1240 }
1241
1242
1243 void * FontLock(PFFONT const * pFont, unsigned * pPitch)
1244 {
1245 GLOBALASSERT(pFont);
1246 GLOBALASSERT(pFont->data);
1247
1248 fprintf(stderr, "FontLock(%p, %p)\n", pFont, pPitch);
1249 /*
1250 DDSURFACEDESC ddsd;
1251 memset(&ddsd,0,sizeof ddsd);
1252 ddsd.dwSize = sizeof ddsd;
1253 HRESULT hResult = pFont->data->Lock(NULL,&ddsd,DDLOCK_NOSYSLOCK,NULL);
1254 GLOBALASSERT(DD_OK == hResult);
1255
1256 *pPitch = ddsd.lPitch;
1257 return ddsd.lpSurface;
1258 */
1259 return NULL;
1260 }
1261
1262 void FontUnlock(PFFONT const * pFont)
1263 {
1264 GLOBALASSERT(pFont);
1265 GLOBALASSERT(pFont->data);
1266
1267 // HRESULT hResult = pFont->data->Unlock(NULL);
1268 // GLOBALASSERT(DD_OK == hResult);
1269 fprintf(stderr, "FontUnlock(%p)\n", pFont);
1270 }
1271
1272
1273 void UnloadFont(PFFONT *pffont)
1274 {
1275 GLOBALASSERT(pffont);
1276
1277 if (pffont->hBackup)
1278 {
1279 ATRemoveSurface(pffont->data);
1280 AwDestroyBackupTexture(pffont->hBackup);
1281 pffont->hBackup = NULL;
1282 }
1283
1284 if(pffont->data)
1285 {
1286 ReleaseDDSurface(pffont->data);
1287 pffont->data = NULL;
1288 }
1289
1290 IndexedFont_Proportional_PF :: PFUnLoadHook
1291 (
1292 (FontIndex)
1293 (
1294 (pffont - &AvpFonts[0]) / sizeof(PFFONT)
1295 )
1296 // FontIndex I_Font_Old,
1297 // very ugly way to get at the index
1298 );
1299 }
1300
1301
1302 void FillCharacterSlot(int u, int v,
1303 int width, int height,
1304 int charnum, PFFONT* font)
1305
1306 {
1307
1308 /*
1309 simply set the srcRect.top to null in order to tell the drawing easily that
1310 this char dosn't exist
1311 */
1312
1313 GLOBALASSERT(width > -1);
1314 GLOBALASSERT(height > -1);
1315 GLOBALASSERT(u > -1);
1316 GLOBALASSERT(v > -1);
1317
1318 GLOBALASSERT(font);
1319 GLOBALASSERT(charnum < font->num_chars_in_font);
1320 font->srcRect[charnum].left = u;
1321 font->srcRect[charnum].right = u + width;
1322 font->srcRect[charnum].top = v;
1323 font->srcRect[charnum].bottom = v + height;
1324 }
1325
1326
1327
1328 int BLTFontOffsetToHUD(PFFONT* font , int xdest, int ydest, int offset)
1329 {
1330 // HRESULT ddrval;
1331
1332 RECT *rect = &(font->srcRect[offset]);
1333
1334 if(rect->right - rect->left <= 0)
1335 return 0;
1336
1337 if(rect->bottom - rect->top <= 0)
1338 return(rect->right - rect->left + 1);
1339
1340 /*
1341 ddrval = lpDDSBack->BltFast(xdest, ydest, font->data, rect, DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY);
1342
1343 LOGDXERR(ddrval);
1344
1345 if(ddrval != DD_OK)
1346 {
1347 LOGDXERR(ddrval);
1348 GLOBALASSERT(0);
1349 finiObjects();
1350 exit(ddrval);
1351 }
1352 */
1353 fprintf(stderr, "BLTFontOffsetToHUD(%p, %d, %d, %d)\n", font, xdest, ydest, offset);
1354
1355 return(font->srcRect[offset].right - font->srcRect[offset].left);
1356 }
1357
1358
1359
1360 #endif // SBF
1361
1362
1363
1364
1365
1366 void YClipMotionTrackerVertices(struct VertexTag *v1, struct VertexTag *v2);
1367 void XClipMotionTrackerVertices(struct VertexTag *v1, struct VertexTag *v2);
1368
1369 #if 0 /* SBF - not used */
1370 static void DrawMotionTrackerPoly(void)
1371 {
1372 struct VertexTag vertex[4];
1373 int widthCos,widthSin;
1374
1375 {
1376 int angle = 4095 - Player->ObEuler.EulerY;
1377
1378 widthCos = MUL_FIXED
1379 (
1380 MotionTrackerWidth,
1381 GetCos(angle)
1382 );
1383 widthSin = MUL_FIXED
1384 (
1385 MotionTrackerWidth,
1386 GetSin(angle)
1387 );
1388 }
1389
1390 /* I've put these -1s in here to help clipping 45 degree cases,
1391 where two vertices can end up around the clipping line of Y=0 */
1392 vertex[0].X = (-widthCos - (-widthSin))/2;
1393 vertex[0].Y = (-widthSin + (-widthCos))/2 -1;
1394 vertex[0].U = 0;
1395 vertex[0].V = 0;
1396 vertex[1].X = (widthCos - (-widthSin))/2;
1397 vertex[1].Y = (widthSin + (-widthCos))/2 -1;
1398 vertex[1].U = MotionTrackerTextureSize;
1399 vertex[1].V = 0;
1400 vertex[2].X = (widthCos - widthSin)/2;
1401 vertex[2].Y = (widthSin + widthCos)/2 -1;
1402 vertex[2].U = MotionTrackerTextureSize;
1403 vertex[2].V = MotionTrackerTextureSize;
1404 vertex[3].X = ((-widthCos) - widthSin)/2;
1405 vertex[3].Y = ((-widthSin) + widthCos)/2 -1;
1406 vertex[3].U = 0;
1407 vertex[3].V = MotionTrackerTextureSize;
1408
1409 /* clip to Y<=0 */
1410 YClipMotionTrackerVertices(&vertex[0],&vertex[1]);
1411 YClipMotionTrackerVertices(&vertex[1],&vertex[2]);
1412 YClipMotionTrackerVertices(&vertex[2],&vertex[3]);
1413 YClipMotionTrackerVertices(&vertex[3],&vertex[0]);
1414
1415 /* translate into screen coords */
1416 vertex[0].X += MotionTrackerCentreX;
1417 vertex[1].X += MotionTrackerCentreX;
1418 vertex[2].X += MotionTrackerCentreX;
1419 vertex[3].X += MotionTrackerCentreX;
1420 vertex[0].Y += MotionTrackerCentreY;
1421 vertex[1].Y += MotionTrackerCentreY;
1422 vertex[2].Y += MotionTrackerCentreY;
1423 vertex[3].Y += MotionTrackerCentreY;
1424 #if 0
1425 textprint("%d %d %d %d\n%d %d %d %d\n%d %d %d %d\n%d %d %d %d\n",
1426 vertex[0].X,vertex[0].Y,vertex[0].U,vertex[0].V,
1427 vertex[1].X,vertex[1].Y,vertex[1].U,vertex[1].V,
1428 vertex[2].X,vertex[2].Y,vertex[2].U,vertex[2].V,
1429 vertex[3].X,vertex[3].Y,vertex[3].U,vertex[3].V);
1430 #endif
1431
1432 /* dodgy offset 'cos I'm not x clipping */
1433 if (vertex[0].X==-1) vertex[0].X = 0;
1434 if (vertex[1].X==-1) vertex[1].X = 0;
1435 if (vertex[2].X==-1) vertex[2].X = 0;
1436 if (vertex[3].X==-1) vertex[3].X = 0;
1437
1438 /* setup polygon in item format */
1439 {
1440 int *itemDataPtr = TrackerPolyBuffer+4;
1441 *itemDataPtr++ = vertex[3].X;
1442 *itemDataPtr++ = vertex[3].Y;
1443 *itemDataPtr++ = vertex[3].U;
1444 *itemDataPtr++ = vertex[3].V;
1445
1446 *itemDataPtr++ = vertex[2].X;
1447 *itemDataPtr++ = vertex[2].Y;
1448 *itemDataPtr++ = vertex[2].U;
1449 *itemDataPtr++ = vertex[2].V;
1450
1451 *itemDataPtr++ = vertex[1].X;
1452 *itemDataPtr++ = vertex[1].Y;
1453 *itemDataPtr++ = vertex[1].U;
1454 *itemDataPtr++ = vertex[1].V;
1455
1456 *itemDataPtr++ = vertex[0].X;
1457 *itemDataPtr++ = vertex[0].Y;
1458 *itemDataPtr++ = vertex[0].U;
1459 *itemDataPtr++ = vertex[0].V;
1460
1461 *itemDataPtr = Term;
1462
1463
1464 /* draw polygon */
1465 Draw_Item_2dTexturePolygon(TrackerPolyBuffer);
1466 }
1467 }
1468 #endif /* SBF */
1469
YClipMotionTrackerVertices(struct VertexTag * v1,struct VertexTag * v2)1470 void YClipMotionTrackerVertices(struct VertexTag *v1, struct VertexTag *v2)
1471 {
1472 char vertex1Inside=0,vertex2Inside=0;
1473
1474 if (v1->Y<0) vertex1Inside = 1;
1475 if (v2->Y<0) vertex2Inside = 1;
1476
1477 /* if both vertices inside clip region no clipping required */
1478 if (vertex1Inside && vertex2Inside) return;
1479
1480 /* if both vertices outside clip region no action required
1481 (the other lines will be clipped) */
1482 if (!vertex1Inside && !vertex2Inside) return;
1483
1484 /* okay, let's clip */
1485 if (vertex1Inside)
1486 {
1487 int lambda = DIV_FIXED(v1->Y,v2->Y - v1->Y);
1488
1489 v2->X = v1->X - MUL_FIXED(v2->X - v1->X,lambda);
1490 v2->Y=0;
1491
1492 v2->U = v1->U - MUL_FIXED(v2->U - v1->U,lambda);
1493 v2->V = v1->V - MUL_FIXED(v2->V - v1->V,lambda);
1494 }
1495 else
1496 {
1497 int lambda = DIV_FIXED(v2->Y,v1->Y - v2->Y);
1498
1499 v1->X = v2->X - MUL_FIXED(v1->X - v2->X,lambda);
1500 v1->Y=0;
1501
1502 v1->U = v2->U - MUL_FIXED(v1->U - v2->U,lambda);
1503 v1->V = v2->V - MUL_FIXED(v1->V - v2->V,lambda);
1504 }
1505 }
XClipMotionTrackerVertices(struct VertexTag * v1,struct VertexTag * v2)1506 void XClipMotionTrackerVertices(struct VertexTag *v1, struct VertexTag *v2)
1507 {
1508 char vertex1Inside=0,vertex2Inside=0;
1509
1510 if (v1->X>0) vertex1Inside = 1;
1511 if (v1->X>0) vertex1Inside = 1;
1512
1513 /* if both vertices inside clip region no clipping required */
1514 if (vertex1Inside && vertex2Inside) return;
1515
1516 /* if both vertices outside clip region no action required
1517 (the other lines will be clipped) */
1518 if (!vertex1Inside && !vertex2Inside) return;
1519
1520 /* okay, let's clip */
1521 if (vertex1Inside)
1522 {
1523 int lambda = DIV_FIXED(v1->X,v2->X - v1->X);
1524
1525 v2->Y = v1->Y - MUL_FIXED(v2->Y - v1->Y,lambda);
1526 v2->X=0;
1527
1528 v2->U = v1->U - MUL_FIXED(v2->U - v1->U,lambda);
1529 v2->V = v1->V - MUL_FIXED(v2->V - v1->V,lambda);
1530 }
1531 else
1532 {
1533 int lambda = DIV_FIXED(v2->X,v1->X - v2->X);
1534
1535 v1->Y = v2->Y - MUL_FIXED(v1->Y - v2->Y,lambda);
1536 v1->X=0;
1537
1538 v1->U = v2->U - MUL_FIXED(v1->U - v2->U,lambda);
1539 v1->V = v2->V - MUL_FIXED(v1->V - v2->V,lambda);
1540 }
1541 }
1542
1543 #if 0 // SBF - unused
1544 static void SetupScanlinePoly(char const *filenamePtr, int width)
1545 {
1546 int imageNumber;
1547 int height;
1548
1549 imageNumber = CL_LoadImageOnce(filenamePtr, (ScanDrawDirectDraw == ScanDrawMode ? LIO_CHIMAGE : LIO_D3DTEXTURE)|LIO_TRANSPARENT|LIO_RIFFPATH|LIO_RESTORABLE);
1550 height = width/2;
1551
1552 ScanlinePolyBuffer[3] = imageNumber;
1553
1554 ScanlinePolyBuffer[6] = 0;
1555 ScanlinePolyBuffer[7] = height;
1556
1557 ScanlinePolyBuffer[10] = width;
1558 ScanlinePolyBuffer[11] = height;
1559
1560 ScanlinePolyBuffer[14] = width;
1561 ScanlinePolyBuffer[15] = 0;
1562
1563 ScanlinePolyBuffer[18] = 0;
1564 ScanlinePolyBuffer[19] = 0;
1565
1566 ScanlinePolyBuffer[20] = Term;
1567 }
1568 #endif // SBF
1569
1570 }; // extern
1571