Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
cockpt.c
Go to the documentation of this file.
1/*
2 * Cockpit displays, HUD messages and VDUs.
3 *
4 * Retail object 0x4380B0-0x43FABF (link order; see docs/ORDER.md).
5 */
6#define COCKPT_C
7#include "game.h"
8
9short g_bTargetLockActive = 0; /* 0x0049ae80 */
10short g_nCommDeathSequenceFrame = 0; /* 0x0049ae84 */
11short g_nCommMessageIndex = -1; /* 0x0049ae88 */
12ShortPoint g_stWeaponDisplayOffset = { 0, 0x10 }; /* 0x0049ae8c */
13ShortPoint g_stHudMessageOrigin = { 0 }; /* 0x0049ae90 */
14ShortPoint g_aCockpitDamagePositions[4] = { 0 }; /* 0x0049ae98 */
15short g_asCockpitLightX[7] = { 0 }; /* 0x0049aea8 */
16short g_asCockpitLightY[7] = { 0 }; /* 0x0049aeb8 */
17signed char g_acCockpitLightOffFrame[7] = { 0 }; /* 0x0049aec8 */
18signed char g_acCockpitLightOnFrame[7] = { 0 }; /* 0x0049aed0 */
20ShortPoint g_aCockpitReadoutOrigins[4] = { 0 }; /* 0x0049af58 */
21ShortRect g_stLeftVduBounds = { 0 }; /* 0x0049af68 */
22ShortRect g_stRightVduBounds = { 0 }; /* 0x0049af70 */
24ShortRect g_stPilotHandBounds = { 0 }; /* 0x0049af88 */
25ShortPoint g_stPilotHandOrigin = { 0 }; /* 0x0049af90 */
26signed char g_cHazardBaseTravelTime = 0; /* 0x0049af94 */
27short g_nHazardPitchRange = 0; /* 0x0049af98 */
28ShortPoint g_aDefaultWeaponDisplayPositions[16] = { 0 }; /* 0x0049afa0 */
29short g_bTargetLockDisplayEnabled = 0; /* 0x0049afe0 */
30short g_asVduSelectionSound[2] = { 0x7f, 0 }; /* 0x0049afe4 */
31short g_nTargetLeadIndicatorX = (short)0x8001; /* 0x0049afe8 */
32char *g_pszPendingHudMessage = 0; /* 0x0049afec */
33char *g_pszDisplayedHudMessage = 0; /* 0x0049aff0 */
34signed char g_cLastPilotHandFrame = (signed char)0xff; /* 0x0049aff4 */
36 6, -3, 7, 2, 7, 9, 7, 12, 8, 13, 0, -1, -1, -1,
37 -4, -1, -6, -1, 6, 0, 8, 0, 10, 0, 13, 3, 8, -7,
38 6, -9, 5, -11, 5, -14
39}; /* 0x0049aff8 */
40unsigned char *g_pPendingCockpitDamageShape = 0; /* 0x0049b03c */
41unsigned char *g_pCockpitExplosionBackground = 0; /* 0x0049b040 */
42unsigned char *g_pCockpitHudBackground = 0; /* 0x0049b044 */
43unsigned char * volatile g_pCockpitExplosionShape = 0; /* 0x0049b048 */
44volatile short g_nCockpitExplosionFrame = 8; /* 0x0049b04c */
46short g_bFuelGaugeDamaged = 0; /* 0x0049b054 */
47short g_bForceCriticalDamageWarning = 0; /* 0x0049b058 */
48unsigned char *g_pReleaseWeaponDisplayBackground = 0; /* 0x0049b05c */
49signed char g_cReleaseWeaponDisplayFrame = -1; /* 0x0049b060 */
50signed char g_cReleaseWeaponDisplayTicks = 0; /* 0x0049b064 */
51signed char g_cReleaseWeaponDisplayState = 0; /* 0x0049b068 */
52static char g_szNoWeaponSelected[8] = "None"; /* 0x0049b070 */
53int g_nDisplayedObjectiveRange = 40000; /* 0x0049b078 */
54short g_nScannerTargetObject = -1; /* 0x0049b07c */
56 5, 13, 16, -1,
57 5, 13, 16, -1,
58 5, 13, 16, -1,
59 4, 13, 16, -1,
60 4, 12, 16, -1,
61 2, 3, 4, 12, 15, -1,
62 0, 1, 5, 12, 15, -1,
63 6, 11, 15, -1,
64 7, 11, 14, -1,
65 8, 10, 14, -1,
66 9, 13, -1,
67 8, 13, -1,
68 6, 7, 12, -1,
69 4, 5, 11, -1,
70 0, 1, 2, 3, 10, -1,
71 9, -1,
72 7, 8, -1,
73 4, 5, 6, -1,
74 0, 1, 2, 3,
75 -2
76}; /* 0x0049b080 */
78 5, 13, -1,
79 5, 13, -1,
80 5, 13, -1,
81 4, 13, -1,
82 4, 12, -1,
83 2, 3, 4, 12, -1,
84 0, 1, 5, 11, 12, -1,
85 6, 11, -1,
86 7, 11, -1,
87 8, 10, -1,
88 9, -1,
89 8, -1,
90 6, 7, -1,
91 4, 5, -1,
92 0, 1, 2, 3,
93 -2
94}; /* 0x0049b1b8 */
95const char *g_pszMissileLocked = "MISSILE LOCKED "; /* 0x0049b280 */
96signed char g_bTargetBracketVisible = 1; /* 0x0049b284 */
97unsigned char *g_pHudMessageFrameShape = 0; /* 0x0049b288 */
98unsigned char *g_pHudMessageBackground = 0; /* 0x0049b28c */
99short g_bCaptureHudMessageBackground = 1; /* 0x0049b290 */
100short g_nHudMessageBackgroundDepth = 0; /* 0x0049b294 */
101short g_nTargetLockMarkerX = -0x7fff; /* 0x0049b298 */
102ShortRect g_stTargetBracketBounds = { -0x7fff, 0, 0, 0 }; /* 0x0049b2a0 */
103ShortRect g_stCommTargetBracketBounds = { -0x7fff, 0, 0, 0 }; /* 0x0049b2a8 */
104short g_bMissileLockAcquired = 0; /* 0x0049b2b0 */
105short g_bCockpitDamageFrame0Shown = 0; /* 0x0049b2b4 */
106short g_bCockpitDamageFrame2Shown = 0; /* 0x0049b2b8 */
107int g_nCommPortraitFrame = -1; /* 0x0049b2bc */
108Viewport g_stTrainSimRightVduSource = { 0 }; /* 0x0049b2c0 */
109Viewport g_stTrainSimLeftVduSource = { 0 }; /* 0x0049b2d8 */
110int g_bForceDamageDisplayRedraw = 0; /* 0x0049b2ec */
111char g_szAutopilotWaitReason[28] = "Wait for ??????????????????"; /* 0x0049b2f0 */
112
113
114/* Clearing the communication resources sets the speaker to -1. WC2's
115 * unchecked side-table load then treats the last two bytes of
116 * g_acShipLastAttacker as a signed word. Reassemble that
117 * layout-derived value without crossing a native global's sanitizer redzone. */
118#define COMM_SPEAKER_SIDE(obj) g_asShipSide[obj]
119
120/* Function start: 0x4380B0 */
121void FatalErrorAndExit(const char *format, ...)
122{
123 char text[0xfc];
124 va_list argList;
125
126 va_start(argList, format);
127 vsprintf(text, format, argList);
128 va_end(argList);
129 exit_squadron(text);
130}
131
132/* Function start: 0x4380FD */
134{
135 return g_nCockpitExplosionFrame < 8;
136}
137
138/* Function start: 0x438129 */
139void EraseCockpitReadoutRegion(Viewport *viewport, short left,
140 short top, short right, short bottom,
141 short colour)
142{
143 Viewport clippedViewport;
144
145 clippedViewport = *viewport;
146 if (right >= left && bottom >= top) {
147 clippedViewport.left = left;
148 clippedViewport.top = top;
149 clippedViewport.right = right;
150 clippedViewport.bottom = bottom;
151 ClearViewport(&clippedViewport, colour);
152 }
153}
154
155/* Function start: 0x438194 */
156void vdu_polygon(signed char bar, short percent)
157{
158 CockpitBarDefinition definition;
159 short barLeft;
160 unsigned char *sprite;
161 short length;
162 short tmp;
163 short barDirection;
164 short barTop;
165 signed char frameNumberFilled;
166 short barRight;
167 short barBottom;
168 signed char frameNumberEmpty;
169
170 if (g_nCurrentView == 0) {
171 definition = g_aCockpitBarDefinitions[(int)bar];
172 sprite = g_4_pCockpitPanelShape;
173 } else {
174 definition = ((CockpitBarDefinition (*)[2])
176 g_8_nGunDisplaySlot][(int)bar];
179 }
180 length = definition.length;
181 percent = (short)(((int)percent * (int)length) / 100);
182 g_9_stCockpitMeterPort.left = definition.left;
184 if (barLeft == -99)
185 return;
187 barRight = g_9_stCockpitMeterPort.right;
188 g_9_stCockpitMeterPort.top = definition.top;
191 barBottom = g_9_stCockpitMeterPort.bottom;
192 frameNumberEmpty = (signed char)definition.emptyFrame;
193 frameNumberFilled = (signed char)definition.filledFrame;
194 barDirection = definition.direction;
195 if (barDirection < 2) {
196 if (barDirection == 1) {
197 percent = (short)(length - percent);
198 tmp = frameNumberEmpty;
199 frameNumberEmpty = frameNumberFilled;
200 frameNumberFilled = (signed char)tmp;
201 }
206 sprite, frameNumberFilled);
208 (short)(g_9_stCockpitMeterPort.bottom + 1);
209 g_9_stCockpitMeterPort.bottom = barBottom;
213 sprite, frameNumberEmpty);
214 } else {
215 if (barDirection == 3) {
216 percent = (short)(length - percent);
217 tmp = frameNumberEmpty;
218 frameNumberEmpty = frameNumberFilled;
219 frameNumberFilled = (signed char)tmp;
220 }
221 g_9_stCockpitMeterPort.right -= percent;
225 sprite, frameNumberFilled);
227 (short)(g_9_stCockpitMeterPort.right + 1);
228 g_9_stCockpitMeterPort.right = barRight;
232 sprite, frameNumberEmpty);
233 }
234}
235
236/* Function start: 0x438454 */
237unsigned int InitializeCockpitReadout(signed char slot,
238 TextContext *context)
239{
240 g_9_aConsoleMetersTable[(int)slot].context = context;
241 g_9_aConsoleMetersTable[(int)slot].x = context->cursorX;
242 g_9_aConsoleMetersTable[(int)slot].y = context->cursorY;
243 g_9_aConsoleMetersTable[(int)slot].previousRight = 0;
244}
245
246/* Function start: 0x4384AD */
247void DrawCockpitReadout(signed char slot, const char *text)
248{
249 if (g_9_aConsoleMetersTable[(int)slot].x == -99)
250 return;
251 SetTextContext(g_9_aConsoleMetersTable[(int)slot].context);
252 SetTextCursor((unsigned short)g_9_aConsoleMetersTable[(int)slot].x,
253 (unsigned short)g_9_aConsoleMetersTable[(int)slot].y);
254 DrawFormattedText(text);
257 g_9_aConsoleMetersTable[(int)slot].context->cursorX,
258 g_9_aConsoleMetersTable[(int)slot].y,
260 (short)(*(unsigned short *)
262 g_9_aConsoleMetersTable[(int)slot].y - 1),
264 g_9_aConsoleMetersTable[(int)slot].previousRight =
266}
267
268/* Function start: 0x4385B3 */
270{
271 short textColour;
272 short previousDrawColour;
273 short blinkOff;
274
275 if (g_nCurrentView != 0)
276 return 1;
277
278 previousDrawColour = slot->drawColour;
279 if (((int)g_196_nInputTimerTicks / 40) % 3 == 0)
281 else
282 slot->drawColour = slot->colour;
283
284 if (slot->flashCount != -1) {
286 previousDrawColour == slot->colour) {
287 slot->flashCount = (signed char)MaxShort(
288 0, (short)(slot->flashCount - 1));
289 }
290 if (slot->flashCount == 0)
292 }
293
294 blinkOff = slot->drawColour == g_cSecondaryViewBufferColour;
295 textColour = slot->context->colour;
296 slot->context->colour = (unsigned char)slot->drawColour;
297 DrawTextAt(slot->context, slot->x, slot->y, slot->text, 2);
298 slot->context->colour = (unsigned char)textColour;
299 return blinkOff;
300}
301
302/* Function start: 0x438711 */
304{
305 slot->flashCount = 0;
306 if (slot->text != 0)
307 DrawHudMessageSlot(slot);
308 if (slot->text != 0) {
309 slot->text = 0;
310 if (slot->text == 0 && g_nCurrentView == 0 &&
311 get_mode(0) == 1 && IsCockpitWeaponShapeLoaded() != 0)
313 } else {
314 slot->text = 0;
315 }
316}
317
318/* Function start: 0x4387A7 */
319void ClearHudMessageIfMatching(HudMessageSlot *slot, const char *text)
320{
321 if (slot->text == text)
323}
324
325/* Function start: 0x4387CD */
333
334/* Function start: 0x4387FA */
336 short x, short y, const char *text,
337 unsigned short colour, signed char flashCount)
338{
339 if (slot->text != 0)
341 slot->context = context;
342 slot->x = x;
343 slot->y = y;
344 slot->colour = colour;
345 slot->drawColour = colour;
346 slot->text = text;
347 slot->flashCount = flashCount;
348}
349
350/* Function start: 0x438864 */
352{
353 short showingEraseColour;
354
355 if (slot->text != 0) {
356 showingEraseColour = DrawHudMessageSlot(slot);
357 if (slot->flashCount == 0 && showingEraseColour != 0)
359 }
360}
361
362/* Function start: 0x4388B6 */
363void set_global_message(const char *text, unsigned short colour,
364 int flashCount)
365{
368 (short)(g_4_stRightVduView.bottom - 6),
369 text, colour, (signed char)flashCount);
370}
371
372/* Function start: 0x4388F5 */
373void CockpitMessage(const char *text, unsigned short colour,
374 int flashCount)
375{
376 if (text != g_12_aHudTextSlotsArray[1].text)
377 set_global_message(text, colour, flashCount);
378}
379
380/* Function start: 0x438923 */
381/* Nothing in the shipped executable calls this. Clears the global message
382 * slot. */
387
388/* Function start: 0x43893F */
389void remove_message(const char *text)
390{
392}
393
394/* Function start: 0x43895F */
395short kilrathi_near(short obj, short range)
396{
397 short ship;
398
399 for (ship = 1; ship < 10; ship++) {
400 if (g_aeObjectClass[ship] >= OBJECT_CLASS_SHIP &&
401 g_asShipSide[ship] == SIDE_KILRATHI &&
403 &g_aShipPosition[ship],
404 range) != 0)
405 return 1;
406 }
407 return 0;
408}
409
410/* Function start: 0x4389FE */
411short IsMissionObjectiveOutOfSystem(short objectiveIndex)
412{
413 short navPoint;
414 MissionObjective *record;
415
416 record = &g_aMissionObjectives[objectiveIndex];
417 switch (record->type) {
418 case 1:
419 case 2:
420 case 3:
421 case 4:
422 case 6:
423 navPoint = find_ships_sphere(record->index);
424 if (navPoint == -1)
425 return 0;
426 break;
427 case 0:
428 case 5:
429 navPoint = record->index;
430 break;
431 }
432 if (g_aMissionNavPoints[navPoint].systemIndex ==
434 return 0;
435 else
436 return 1;
437}
438
439/* Function start: 0x438ADD */
440short auto_pilot_valid(short showReason)
441{
442 const char *reason;
443 short range;
444 short object;
445
446 reason = 0;
448 return 0;
449 if (g_asShipSide[0] == SIDE_KILRATHI)
450 return 0;
451 if (IsCockpitExplosionActive() != 0)
452 return 0;
454 (short)g_cCurrentObjective) != 0)
455 reason = "Jump Point";
456 range = distance_from_point(
458 (signed char)g_cCurrentObjective].position);
459 for (object = 1; object < 10; object++) {
461 g_asShipMissionType[object] ==
463 g_asShipMissionParameter[object] ==
467 (signed char)g_cCurrentObjective].position,
468 &g_aShipDestination[object]) == 0) {
469 sprintf(g_pszAutopilotWaitReason, "Wait for %s",
470 g_apShipMissionRecord[object]->name);
472 break;
473 }
474 }
475 if (range < 8000) {
476 reason = "Already Near";
477 } else if (kilrathi_near(0, 16000) != 0) {
478 reason = "Enemy Near";
479 } else if (g_pActiveHazardField != 0) {
480 reason = "Hazard Near";
481 }
482 if (showReason != 0 && reason != 0)
484 return reason == 0;
485}
486
487/* Function start: 0x438CEB */
489{
490 short light;
491
492 for (light = 0; light < 7; light++) {
493 g_4_abCockpitLightMode[light] = 0;
495 }
496}
497
498/* Function start: 0x438D30 */
499void SetCockpitLightBlink(signed char light, short interval)
500{
501 if (interval < 20) {
502 if (interval == 0) {
503 g_12_abCockpitLightGoalTable[(int)light] ^= 1;
504 } else if (g_nSpaceFrame % interval == 0) {
505 g_12_abCockpitLightGoalTable[(int)light] ^= 1;
506 }
507 } else {
508 g_12_abCockpitLightGoalTable[(int)light] = 0;
509 }
510}
511
512/* Function start: 0x438DAD */
514{
515 signed char light;
516 short x;
517 short frame;
518 short y;
519
520 if (g_nRenderedSpaceFrame % 4 == 0) {
521 if (auto_pilot_valid(0) != 0)
523 else
525 }
526 for (light = 0; light < 7; light++) {
527 if (g_nCockpitDisplayMode != 0) {
528 x = g_asCockpitLightX[(int)light];
529 y = g_asCockpitLightY[(int)light];
530 if (g_12_abCockpitLightGoalTable[(int)light] == 1)
531 frame = g_acCockpitLightOnFrame[(int)light];
532 else
533 frame = g_acCockpitLightOffFrame[(int)light];
536 g_4_abCockpitLightMode[(int)light] =
538 } else if (g_4_abCockpitLightMode[(int)light] !=
539 g_12_abCockpitLightGoalTable[(int)light]) {
540 x = g_asCockpitLightX[(int)light];
541 y = g_asCockpitLightY[(int)light];
542 if (g_12_abCockpitLightGoalTable[(int)light] == 1)
543 frame = g_acCockpitLightOnFrame[(int)light];
544 else
545 frame = g_acCockpitLightOffFrame[(int)light];
548 g_4_abCockpitLightMode[(int)light] =
550 }
551 }
552}
553
554/* Function start: 0x438F62 */
556{
557 short energy;
558 short fuelPercent;
559
560 if (g_bFuelGaugeDamaged == 0) {
561 fuelPercent = (short)(
562 (g_anShipFuel[0] * 100) /
563 *(int *)&g_aObjectTypeData[0].lifetime);
564 SetCockpitLightBlink(6, fuelPercent);
565 vdu_polygon(0, fuelPercent);
566 }
567 energy = g_asShipWeaponEnergy[0];
568 vdu_polygon(1, energy);
569 if ((calculate_damage_level() >= 3 &&
570 (int)g_aasShipShield[0][1] +
571 (int)g_aasShipShield[0][0] <
572 10) ||
576 g_nSpaceFrame % 10 == 0)
577 PlaySfxWaveFileByNumber(0x20, -1, 0);
578 } else if (g_4_nSevereDmgWarningSfxHandle != 0) {
583 }
584}
585
586/* Function start: 0x439076 */
587void update_bars(void)
588{
589 ObjectTypeData *typeData;
590 short ratio;
591 short shieldPercent;
592 short shieldShown;
593
594 typeData = &g_aObjectTypeData[g_acObjectType[0]];
595 ratio = (short)((g_aasShipArmor[0][0] * 100) /
596 typeData->armorFront);
597 vdu_polygon(2, ratio);
598 ratio = (short)((g_aasShipArmor[0][1] * 100) /
599 typeData->armorRear);
600 vdu_polygon(3, ratio);
601 ratio = (short)((g_aasShipArmor[0][2] * 100) /
602 typeData->armorRight);
603 vdu_polygon(4, ratio);
604 ratio = (short)((g_aasShipArmor[0][3] * 100) /
605 typeData->armorLeft);
606 vdu_polygon(5, ratio);
607 shieldPercent = (short)((g_aasShipShield[0][0] * 100) /
608 typeData->shieldFore);
609 SetCockpitLightBlink(0, shieldPercent);
610 vdu_polygon(6, shieldPercent);
611 shieldShown = g_aasShipShield[0][0];
612 if (g_asObjectType[0] == 0x33)
613 shieldShown = (short)(shieldShown / 10);
615 4, itoa((int)shieldShown,
617 shieldPercent = (short)((g_aasShipShield[0][1] * 100) /
618 typeData->shieldAft);
619 SetCockpitLightBlink(1, shieldPercent);
620 vdu_polygon(7, shieldPercent);
621 shieldShown = g_aasShipShield[0][1];
622 if (g_asObjectType[0] == 0x33)
623 shieldShown = (short)(shieldShown / 10);
625 5, itoa((int)shieldShown,
627}
628
629/* Function start: 0x439264 */
630short get_mode(short i)
631{
632 return (short)g_aaiVduModeStack[(int)i][
633 (int)g_acVduModeStackDepth[(int)i]];
634}
635
636/* Function start: 0x43928E */
637void set_mode(short i, int state)
638{
639 if (get_mode(i) != state)
641 g_acVduModeStackDepth[(int)i] = 0;
642 g_aaiVduModeStack[(int)i][
643 (int)g_acVduModeStackDepth[(int)i]] = state;
644}
645
646/* Function start: 0x4392F1 */
647unsigned short SetVduModeIfChanged(short i, int state)
648{
649 short changed;
650
651 changed = get_mode(i) != state;
652 if (changed != 0)
653 set_mode(i, state);
654 return changed;
655}
656
657/* Function start: 0x43934D */
659{
660 return g_acVduModeStackDepth[(int)i];
661}
662
663/* Function start: 0x439369 */
664void push_mode(short i, int state)
665{
667 g_acVduModeStackDepth[(int)i]++;
668 g_aaiVduModeStack[(int)i][
669 (int)g_acVduModeStackDepth[(int)i]] = state;
670}
671
672/* Function start: 0x4393B3 */
673void pop_mode(short i)
674{
676 g_acVduModeStackDepth[(int)i]--;
677}
678
679/* Function start: 0x4393E1 */
680void set_new_vdu(short vdu)
681{
682 if (get_mode(vdu) == 0) {
683 malf_noise(vdu, 1, g_cDarkGreenColour, 0x17, 0);
684 } else {
685 switch (vdu) {
686 case 1:
690 break;
691 case 0:
695 break;
696 }
697 }
698 g_anLastDrawnVduMode[(int)vdu] = get_mode(vdu);
699}
700
701/* Function start: 0x4394A0 */
702short update_vid_disp(short vdu)
703{
704 short changed;
705
706 changed =
707 get_mode(vdu) != g_anLastDrawnVduMode[(int)vdu];
708 if (changed != 0)
709 set_new_vdu(vdu);
710 return changed;
711}
712
713/* Function start: 0x439500 */
714void InvalidateVduMode(short i)
715{
716 g_anLastDrawnVduMode[(int)i] = 0;
717}
718
719/* Function start: 0x43951A */
724
725/* Function start: 0x43952E */
727{
729}
730
731/* Function start: 0x439559 */
732void set_message_time(short duration)
733{
737}
738
739/* Function start: 0x439588 */
741{
742 if (message_showing() != 0) {
744 if (g_bSpeechPlaybackDone != 0) {
751 } else {
752 EndCommMenu();
753 }
757 g_acObjectType[0]].resourceType,
758 1);
759 g_anShipFuel[0] =
760 *(int *)&g_aObjectTypeData[
761 g_acObjectType[0]].lifetime;
763 }
764 }
765 } else {
768 EndCommMenu();
772 g_acObjectType[0]].resourceType,
773 1);
774 g_anShipFuel[0] =
775 *(int *)&g_aObjectTypeData[
776 g_acObjectType[0]].lifetime;
778 }
779 }
780 }
781 }
782}
783
784/* Function start: 0x4396BF */
786{
787 short speed;
788 short velocity;
789
791 speed = (short)(g_anShipSpeed[0] >> 8);
792 speed = (short)(speed * 10);
794 2, itoa(speed, g_16_szTextBufferBuffer, 10));
795 velocity = (short)(MultiplyFixed(
796 Vector_magnitude(&g_aShipVelocity[0]), 0xa00) >> 8);
798 3, itoa(velocity, g_16_szTextBufferBuffer, 10));
799}
800
801/* Function start: 0x439753 */
802void malf_sound(void)
803{
806 0, 0x7f, 0x64, 1, 1);
807 PlaySfxWaveFileByNumber(0x1f, -1, 0);
808}
809
810/* Function start: 0x439789 */
811short malf(char component)
812{
813 return g_acPlayerComponentDamage[(int)component] *
814 g_acPlayerComponentDamage[(int)component] >
815 (unsigned short)RandomInRange(0, 15);
816}
817
818/* Function start: 0x4397D5 */
819void vdu_malf(short vdu, short sound)
820{
821 if (g_nCurrentView == 0 &&
822 ((vdu == 0 && g_2_stLeftwardVduPortBlock.top > 0) ||
823 (vdu == 1 && g_4_stRightVduView.top > 0))) {
824 malf_noise(vdu, 1, g_cDarkGreenColour, sound, 0);
825 set_mode(vdu, 0);
826 }
827}
828
829/* Function start: 0x43984F */
830void ShowComponentHitHudMessage(const char *text, unsigned short colour,
831 short flashCount)
832{
833 if (get_mode(0) != 0) {
834 if (g_12_aHudTextSlotsArray[0].text != 0)
841 colour, (signed char)flashCount);
842 }
843}
844
845/* Function start: 0x4398CB */
846signed char damage_your_component(char component, char amount,
847 char maximum)
848{
849 char text[40];
850
851 g_acPlayerComponentDamage[(int)component] =
852 (signed char)MinShort(
853 (short)(g_acPlayerComponentDamage[(int)component] + amount),
854 (short)maximum);
855 if (malf(component) != 0) {
856 switch (component) {
857 case 3:
858 vdu_malf(0, 0x18);
859 vdu_malf(1, 0x18);
860 break;
861 }
862 }
863 if (get_mode(0) == 2 || get_mode(0) == 1) {
864 sprintf(text, "%s HIT",
865 g_apszComponentNames[(int)component]);
867 }
868 return g_acPlayerComponentDamage[(int)component];
869}
870
871/* Function start: 0x4399C6 */
890
891/* Function start: 0x439A5A */
893{
894 short visible;
895
897 visible = g_nCurrentView == 0 && get_mode(0) == 1;
907 }
916 if (visible != 0) {
930 }
931 g_cReleaseWeaponDisplayState = (signed char)visible;
932 } else {
934 }
935 }
936}
937
938/* Function start: 0x439BB7 */
940{
941 signed char slotIndex;
942 const char *releaseLabel;
943 const char *gunCaption;
944 short x;
945 ShipWeaponSlot *entry;
946 short frame;
947 unsigned char *weapons;
948 short y;
949
950 weapons = g_aShipWeapons[0];
951 entry = (ShipWeaponSlot *)(
953 sizeof(ShipWeaponSlot) +
954 1);
955 set_new_vdu(0);
958 g_2_stLeftwardVduPortBlock.top, "WEAPON DISPLAY", 2);
965
967 case -1:
968 releaseLabel = g_szNoWeaponSelected;
969 break;
970 default:
971 releaseLabel = g_aObjectTypeData[
972 (int)entry->weaponType].displayName;
973 }
974 switch (g_nSelectedGunType) {
975 case -1:
976 gunCaption = g_szNoWeaponSelected;
977 break;
978 case 0x80:
979 gunCaption = "Full Guns";
980 break;
981 default:
982 gunCaption = g_aObjectTypeData[
984 }
985 DrawFormattedText("\nWeapon:%s", releaseLabel);
986 DrawFormattedText("\nGun:%s", gunCaption);
987
992 (short)(g_stWeaponDisplayOffset.y +
999
1000 entry = (ShipWeaponSlot *)(weapons + 1);
1001 for (slotIndex = 0; slotIndex < (signed char)weapons[0];
1002 slotIndex++, entry++) {
1004 (int)entry->weaponType].field_18 == 0x0b) {
1005 frame = 0x1a;
1007 (int)slotIndex].x > 0x29)
1008 frame = (short)(frame + 2);
1010 (int)slotIndex].x < 0x1f)
1011 frame++;
1012 } else if (g_aObjectTypeData[
1013 (int)entry->weaponType].objectClass == 8) {
1014 frame = (short)((entry->type - 7) * 2 + entry->disabled + 3);
1015 } else {
1016 frame = (short)(
1017 (((ShipWeaponSlot *)&g_aShipWeapons[0][1])[
1019 entry->type) + 1);
1020 }
1021
1022 x = g_116_aWeaponDisplayPositions[(int)slotIndex].x;
1023 y = g_116_aWeaponDisplayPositions[(int)slotIndex].y;
1025 (int)entry->weaponType].field_18 != 0x14) {
1028 (short)(g_5_nWeaponDisplayOriginXValue + x),
1029 (short)(g_nArmsDisplayOriginY + y),
1030 g_1_pDashWeaponPicture, frame);
1031 }
1032 if ((int)slotIndex == g_nSelectedReleaseWeaponIndex &&
1034 (int)entry->weaponType].field_18 == 0x14) {
1037 (short)(g_5_nWeaponDisplayOriginXValue + 10),
1038 (short)(g_nArmsDisplayOriginY + 13),
1040 (short)(entry->type + 4));
1043 (short)(g_5_nWeaponDisplayOriginXValue + 60),
1044 (short)(g_nArmsDisplayOriginY + 13),
1046 (short)(entry->type + 4));
1047 }
1048 }
1049}
1050
1051short get_mode(short i);
1052
1053/* Function start: 0x439F5F */
1055{
1056 short x;
1057 short frame;
1058 short y;
1059 short i;
1060
1061 for (i = 0;
1062 i < (signed char)g_aShipWeapons[0][0];
1063 i++) {
1064 if (((ShipWeaponSlot *)&g_aShipWeapons[0][1])[
1065 i].type == 11) {
1070 (short)(g_stWeaponDisplayOffset.y +
1074
1075 if (g_12_aHudTextSlotsArray[0].text == 0 &&
1076 x < 0x29 && x > 0x1f) {
1077 if (g_27_aasGunCooldown[0][0] > 0) {
1078 frame = 0x1d;
1081 (short)(g_5_nWeaponDisplayOriginXValue + x),
1082 (short)(g_nArmsDisplayOriginY + y),
1083 g_1_pDashWeaponPicture, frame);
1084 } else {
1085 frame = 0x1a;
1088 (short)(g_5_nWeaponDisplayOriginXValue + x),
1089 (short)(g_nArmsDisplayOriginY + y),
1090 g_1_pDashWeaponPicture, frame);
1091 }
1092 }
1093
1094 if (g_cReleaseWeaponDisplayFrame == -1 && x < 0x1f) {
1095 if (g_27_aasGunCooldown[0][1] > 0) {
1096 frame = 0x1e;
1099 (short)(g_5_nWeaponDisplayOriginXValue + x),
1100 (short)(g_nArmsDisplayOriginY + y),
1101 g_1_pDashWeaponPicture, frame);
1102 } else {
1103 frame = 0x1b;
1106 (short)(g_5_nWeaponDisplayOriginXValue + x),
1107 (short)(g_nArmsDisplayOriginY + y),
1108 g_1_pDashWeaponPicture, frame);
1109 }
1110 }
1111
1112 if (g_cReleaseWeaponDisplayFrame == -1 && x > 0x29) {
1113 if (g_27_aasGunCooldown[0][2] > 0) {
1114 frame = 0x1f;
1117 (short)(g_5_nWeaponDisplayOriginXValue + x),
1118 (short)(g_nArmsDisplayOriginY + y),
1119 g_1_pDashWeaponPicture, frame);
1120 } else {
1121 frame = 0x1c;
1124 (short)(g_5_nWeaponDisplayOriginXValue + x),
1125 (short)(g_nArmsDisplayOriginY + y),
1126 g_1_pDashWeaponPicture, frame);
1127 }
1128 }
1129 }
1130 }
1131}
1132
1133/* Function start: 0x43A1EB */
1134short sighted(short objective)
1135{
1136 return (g_aMissionObjectives[objective].flags & 4) == 4;
1137}
1138
1139/* Function start: 0x43A21E */
1140short visited(short objective)
1141{
1142 return (g_aMissionObjectives[objective].flags & 1) == 1;
1143}
1144
1145/* Function start: 0x43A251 */
1146short achieved(short objective)
1147{
1148 return (g_aMissionObjectives[objective].flags & 2) == 2 ||
1149 g_aMissionObjectives[objective].type == -1;
1150}
1151
1152/* Function start: 0x43A29E */
1153void flag_objective(short objective, unsigned char flags)
1154{
1155 g_aMissionObjectives[objective].flags |= flags;
1156}
1157
1158#pragma function(strcpy, strlen)
1159/* Function start: 0x43A2CD */
1161{
1163 (short)g_cCurrentObjective) != 0) {
1164 DrawCockpitReadout(0, "Out-system");
1165 } else {
1166 if (g_nCurrentObjectiveRange <= 0) {
1167 DrawCockpitReadout(0, "CALCULATING");
1168 } else {
1170 strlen(ltoa((long)g_nCurrentObjectiveRange,
1172 " km");
1174 }
1177 }
1178}
1179
1180/* Function start: 0x43A374 */
1181const char *objective_name(short objective)
1182{
1183 if (objective >= (short)g_cMissionObjectiveCount)
1184 return "NONE";
1185 else if (*g_aMissionObjectives[objective].name != '?' ||
1186 sighted(objective) != 0)
1187 return g_aMissionObjectives[objective].displayName;
1188 else
1189 return "UNKNOWN";
1190}
1191
1192/* Function start: 0x43A3F8 */
1194{
1196 "COMP NAVIGATION", 2);
1197 DrawFormattedText("\n\nDESTINATION\n %s",
1199 DrawFormattedText("\n\nRANGE\n ");
1201 DrawFormattedText("\n\n(N)ew Objective");
1203}
1204
1205/* Function start: 0x43A474 */
1206short hidden_objective(short objective)
1207{
1208 short concealed;
1209 short navPoint;
1210 short record;
1211 short ship;
1212
1213 concealed = 0;
1214 if (g_aMissionObjectives[objective].type == 0 ||
1215 g_aMissionObjectives[objective].type == 5) {
1217 g_aMissionObjectives[objective].index].type != 0)
1218 concealed = 0;
1219 else
1220 return 1;
1221 }
1222 if (mobile_objective(objective) != 0 &&
1223 is_team_member(g_aMissionObjectives[objective].index) == 0) {
1224 concealed = 1;
1225 for (navPoint = 0; navPoint < 10; navPoint++) {
1226 if (g_aMissionNavPoints[navPoint].type == 0)
1227 continue;
1228 for (record = 0; record < 10; record++) {
1229 if (g_aMissionNavPoints[navPoint].missionShips[
1230 record] ==
1231 g_aMissionObjectives[objective].index)
1232 break;
1233 }
1234 if (record < 10) {
1235 concealed = 0;
1236 break;
1237 }
1238 }
1239 }
1240 if (concealed != 0 ||
1241 *g_aMissionObjectives[objective].displayName == '.')
1242 concealed = 1;
1243 else
1244 concealed = 0;
1245 if (concealed != 0 ||
1246 *g_aMissionObjectives[objective].name == '.')
1247 concealed = 1;
1248 else
1249 concealed = 0;
1250 if (concealed != 0 ||
1251 (mobile_objective(objective) != 0 &&
1253 g_aMissionObjectives[objective].index].state != 0))
1254 concealed = 1;
1255 else
1256 concealed = 0;
1257 if (concealed == 0 && mobile_objective(objective) != 0 &&
1259 g_cMissionObjectiveCount].type == 0) {
1260 ship = find_ship_index(
1261 g_aMissionObjectives[objective].index);
1262 if (g_aMissionShips[
1263 g_aMissionObjectives[objective].index].missionType ==
1265 ship != -1)
1266 concealed = 1;
1267 }
1268 return concealed;
1269}
1270
1271/* Function start: 0x43A75E */
1272short set_new_objective(short pathIndex)
1273{
1274 if (pathIndex < 0) {
1275 pathIndex = -1;
1276 while (g_abFlightPath[++pathIndex] != -1 &&
1277 pathIndex < (short)g_cMissionObjectiveCount)
1278 ;
1279 pathIndex--;
1280 }
1281 if (pathIndex >= (short)g_cMissionObjectiveCount)
1282 pathIndex = 0;
1283 if (g_abFlightPath[pathIndex] == -1)
1284 pathIndex = 0;
1285 g_cCurrentNavPointIndex = (signed char)pathIndex;
1286 if (hidden_objective(
1287 (short)g_abFlightPath[pathIndex]) != 0)
1288 return 0;
1293 (short)g_cCurrentObjective].type;
1295 return 1;
1296}
1297
1298/* Function start: 0x43A851 */
1300{
1301 short wraps;
1302
1303 wraps = 0;
1304 while (wraps < 3 &&
1306 (short)((short)g_cCurrentNavPointIndex + 1)) == 0) {
1307 if (g_cCurrentNavPointIndex == 0)
1308 wraps++;
1309 }
1310 if (wraps >= 3) {
1314 }
1315 return wraps < 3;
1316}
1317
1318/* Function start: 0x43A8EA */
1320{
1322 while (set_new_objective(
1323 (short)g_cCurrentNavPointIndex) == 0 ||
1324 visited((short)g_abFlightPath[
1325 g_cCurrentNavPointIndex]) != 0) {
1331 break;
1332 }
1336 g_cCurrentNavPointIndex] == -1) {
1339 }
1340 if (get_mode(1) == 5)
1342}
1343
1344/* Function start: 0x43A9D7 */
1345short LocateMobileObjective(short objective)
1346{
1347 short ship = -1;
1348
1349 if (mobile_objective(objective) != 0) {
1350 ship = locate_ship(
1351 g_aMissionObjectives[objective].index,
1352 &g_aMissionObjectives[objective].position);
1353 }
1354 return ship;
1355}
1356
1357/* Function start: 0x43AA3F */
1359{
1360 short ship;
1361
1362 for (ship = 0; ship < 10; ship++) {
1363 if (g_aeObjectClass[ship] >= OBJECT_CLASS_SHIP &&
1366 return 1;
1367 }
1368 return 0;
1369}
1370
1371/* Function start: 0x43AAC3 */
1377
1378/* Function start: 0x43AAFF */
1379void flag_reached(short objective, short reached)
1380{
1381 short visit;
1382 short carrierShip;
1383 short moveOn;
1384 short type;
1385 short carrierObject;
1386
1387 type = g_aMissionObjectives[objective].type;
1388 carrierShip = g_asShipMissionParameter[0];
1389 carrierObject = find_ship_index(g_asShipMissionParameter[0]);
1390 if (g_cCurrentObjective != objective)
1391 visit = 1;
1392 else
1393 visit = 0;
1394 moveOn = 0;
1395 if (g_cCurrentObjective == objective) {
1396 if (reached != 0 || escorting_a_ship() == 0 ||
1397 carrierObject == -1 ||
1398 g_aMissionObjectives[objective].index ==
1400 if (visited(objective) != 0) {
1401 CockpitMessage("Already Visited",
1402 g_cYellowColour, 4);
1403 } else {
1404 CockpitMessage("Objective Reached",
1405 g_cYellowColour, 4);
1406 }
1407 moveOn = visit = 1;
1408 } else if (type != 1 ||
1409 g_aMissionShips[carrierShip].state != 1) {
1411 "Wait for %s",
1412 g_apShipMissionRecord[carrierObject]->name);
1414 g_cYellowColour, 4);
1415 }
1416 }
1417 if (type != 1 && visit != 0) {
1418 if (visited(objective) == 0 && carrierObject != -1 &&
1419 g_aMissionObjectives[objective].index ==
1421 g_asShipSide[carrierObject] ==
1422 g_asShipSide[0] &&
1423 g_asShipMissionIndex[carrierObject] !=
1425 g_13_abShipArrivalMessageSent[carrierObject] == 0) {
1426 send_message(carrierObject, 0x16);
1427 g_13_abShipArrivalMessageSent[carrierObject]++;
1428 }
1429 flag_objective(objective, 1);
1430 }
1431 if (moveOn != 0)
1433}
1434
1435/* Function start: 0x43AD61 */
1436void check_sighting(short objective, short range, short object)
1437{
1438 if (sighted(objective) == 0 && range < 16000 &&
1439 (object == -1 ||
1440 g_asObjectScreenX[object] != (short)0x8001))
1441 flag_objective(objective, 4);
1442}
1443
1444/* Function start: 0x43ADC4 */
1445void check_visit(short objective, short range)
1446{
1447 short type;
1448 int reachedRange;
1449
1450 type = g_aMissionObjectives[objective].type;
1451 if (type == 3 || type == 4)
1452 reachedRange = 6000;
1453 else
1454 reachedRange = 1500;
1455 if (range < reachedRange)
1456 flag_reached(objective, 1);
1457}
1458
1459/* Function start: 0x43AE2F */
1460void update_objective_location(short objective)
1461{
1462 short savedSystem;
1463 FixedVector delta;
1464 short object;
1465 short range;
1466
1467 if (g_aMissionObjectives[objective].type == 6 ||
1468 g_aMissionObjectives[objective].type == 5)
1469 return;
1470 object = LocateMobileObjective(objective);
1471 savedSystem = g_1_stElapsedCampaignDate.year;
1473 if (IsObjectiveInDisplayedSystem(objective) == 0) {
1474 g_1_stElapsedCampaignDate.year = savedSystem;
1475 return;
1476 }
1477 if (sighted(objective) == 0 || visited(objective) == 0 ||
1478 g_cCurrentObjective == objective) {
1480 &g_aShipPosition[0],
1481 &g_aMissionObjectives[objective].position, &delta);
1483 check_sighting(objective, range, object);
1484 if (mobile_objective(objective) != 0) {
1485 if (object != -1)
1486 check_visit(objective, range);
1487 } else if (g_aMissionNavPoints[
1488 g_aMissionObjectives[objective].index]
1489 .type >= 1) {
1490 check_visit(objective, range);
1491 }
1492 }
1493 g_1_stElapsedCampaignDate.year = savedSystem;
1494}
1495
1496/* Function start: 0x43AFD3 */
1497short objective_lost(short objective)
1498{
1499 short state;
1500
1501 state = g_aMissionShips[
1502 g_aMissionObjectives[objective].index].state;
1503 switch (g_aMissionObjectives[objective].type) {
1504 case 2:
1505 case 3:
1506 return state != 0;
1507 case 4:
1508 return state == 3;
1509 default:
1510 return 0;
1511 }
1512}
1513
1514/* Function start: 0x43B089 */
1527
1528#pragma function(abs)
1529/* Function start: 0x43B0EB */
1530void rotational_pos_to_scanner_pos(signed char object,
1531 const SphericalVector *position,
1532 CockpitScannerGeometry geometry)
1533{
1534 if (abs((int)position->yaw) < 45)
1536 (short)(geometry.centerX + position->yaw / 4);
1537 else
1539 (short)(geometry.centerX + position->yaw / 6);
1540
1542 (short)(geometry.centerY + -(position->pitch / 3));
1551 g_15_asScannerObjectX[(int)object] =
1553 g_10_asScannerObjectYTable[(int)object] =
1555}
1556
1557/* Function start: 0x43B1F0 */
1558short mobile_objective(short objective)
1559{
1560 short type;
1561
1562 type = g_aMissionObjectives[objective].type;
1563 return type == 1 || type == 3 || type == 4 || type == 2;
1564}
1565
1566/* Function start: 0x43B258 */
1568{
1569 short i;
1570
1571 for (i = 10; i > 0; i--)
1572 g_15_asScannerObjectX[i] = 0;
1574}
1575
1576/* Function start: 0x43B29D */
1578{
1579 short object;
1580
1581 if (g_nCurrentView == 4)
1583 if (g_nScannerTargetObject != -1) {
1605 }
1606 if (g_15_asScannerObjectX[10] != 0 &&
1607 g_nCurrentView != 4 &&
1609 (short)g_cCurrentObjective) == 0) {
1615 g_15_asScannerObjectX[10] = 0;
1616 }
1617 for (object = 9; object > 0; object--) {
1618 if (g_15_asScannerObjectX[object] != 0) {
1620 g_15_asScannerObjectX[object],
1623 g_15_asScannerObjectX[object] = 0;
1624 }
1625 }
1627}
1628
1629/* Function start: 0x43B4CF */
1630void set_objective_range(short showOnScanner)
1631{
1632 FixedVector delta;
1633 FixedVector rotated;
1634 SphericalVector polar;
1635
1639 (short)g_cCurrentObjective].position,
1640 &delta);
1641 transform_to_objects_frame(&delta, &rotated, 0);
1642 rectangular_to_spherical(&rotated, &polar);
1643 if (showOnScanner != 0)
1645 10, &polar, g_stCockpitScannerGeometry);
1646 g_nCurrentObjectiveRange = polar.radius >> 8;
1647}
1648
1649/* Function start: 0x43B570 */
1651 int range, short *colour)
1652{
1653 short increment;
1654
1655 increment = 2;
1657 return;
1658 if (*colour == g_bPrimaryViewBufferColour)
1659 *colour = 0xa0;
1660 if (*colour == g_cYellowColour)
1661 increment = 1;
1662 if (range < 0x138800)
1663 return;
1664 else if (range < 0x61a800)
1665 *colour = (short)(*colour + increment);
1666 else
1667 *colour = (short)(*colour + increment * 2);
1668}
1669
1670/* Function start: 0x43B61F */
1671short get_color(short object, unsigned short *colour)
1672{
1673 short objectClass;
1674
1675 objectClass = g_aeObjectClass[object];
1676 if (objectClass != OBJECT_CLASS_NULL &&
1677 (g_asObjectType[object] == 0x3d ||
1678 g_asObjectType[object] == 0x2c)) {
1679 *colour = g_cYellowColour;
1680 return 1;
1681 }
1682 if (objectClass < OBJECT_CLASS_MISSILE)
1683 return 0;
1684 else if (objectClass == OBJECT_CLASS_SHIP) {
1685 if (g_asShipSide[object] == SIDE_KILRATHI)
1686 *colour = g_cRedColour;
1687 else if (g_asShipSide[object] == SIDE_IMPERIAL)
1688 *colour = g_cBlueColour;
1689 else
1690 *colour = g_ucPrimaryTextColour;
1691 } else if (objectClass >= OBJECT_CLASS_CAPITAL_SHIP) {
1692 if (g_asShipSide[object] == SIDE_KILRATHI)
1694 else if (g_asShipMissionIndex[object] ==
1697 else
1699 } else {
1700 if (g_acShipTarget[object] == 0)
1701 *colour = g_cYellowColour;
1702 else
1703 return 0;
1704 }
1705 return 1;
1706}
1707
1708/* Function start: 0x43B7C0 */
1710{
1711 int cell;
1712 int lineBits;
1713 int gridIndex;
1714 CockpitScannerGeometry geometry;
1715 short obj;
1716 int baseColour;
1717 FixedVector difference;
1718 FixedVector inShipFrame;
1719 const int *gridPattern;
1720 unsigned int markerColour;
1721 SphericalVector angles;
1722
1723 if (g_nCurrentView == 0) {
1724 geometry = g_stCockpitScannerGeometry;
1725 gridPattern = g_aiForwardScannerGridRows;
1726 baseColour = 0x5b;
1727 } else if (g_nCurrentView == 4) {
1728 geometry = ((CockpitScannerGeometry *)(
1731 gridPattern = g_aiTargetCameraScannerGridRows;
1732 baseColour = 0x25;
1733 }
1734
1735 if (g_nCockpitDisplayMode != 0) {
1736 lineBits = 0;
1737 for (gridIndex = 0; gridPattern[gridIndex] != -2; gridIndex++) {
1738 if (gridPattern[gridIndex] == -1) {
1739 lineBits++;
1740 } else {
1741 cell = gridPattern[gridIndex];
1744 (short)(geometry.centerX + lineBits),
1745 (short)(geometry.centerY + cell),
1746 (short)baseColour);
1747 if (cell != 0)
1750 (short)(geometry.centerX + lineBits),
1751 (short)(geometry.centerY - cell),
1752 (short)baseColour);
1753 if (lineBits != 0) {
1756 (short)(geometry.centerX - lineBits),
1757 (short)(geometry.centerY + cell),
1758 (short)baseColour);
1759 if (cell != 0)
1762 (short)(geometry.centerX - lineBits),
1763 (short)(geometry.centerY - cell),
1764 (short)baseColour);
1765 }
1766 }
1767 }
1768 }
1769
1772 if ((g_nScannerTargetObject != -1 &&
1778
1779 for (obj = 1; obj <= 9; obj++) {
1780 if (g_anShipCloakState[obj] != 1 &&
1781 get_color(obj, (unsigned short *)&markerColour) != 0) {
1784 &g_aShipPosition[obj], &difference);
1786 &difference, &inShipFrame, EYE_OBJECT);
1787 rectangular_to_spherical(&inShipFrame, &angles);
1788 if (angles.radius < 0xea6000) {
1790 angles.radius, (short *)&markerColour);
1792 (signed char)obj, &angles, geometry);
1793 if (g_nScannerTargetObject != obj) {
1795 (short)GetViewportPixel(
1803 (short)markerColour);
1804 }
1805 }
1806 }
1807 }
1808
1809 if (get_mode(1) == 5 &&
1810 g_nCurrentView != 4 &&
1812 (short)g_cCurrentObjective) == 0) {
1825 }
1826
1827 if (g_nScannerTargetObject != -1 &&
1829 g_nScannerTargetObject] != 1 &&
1831 (unsigned short *)&markerColour) != 0) {
1834 &g_aShipPosition[obj], &difference);
1836 &difference, &inShipFrame, EYE_OBJECT);
1837 rectangular_to_spherical(&inShipFrame, &angles);
1838 if (angles.radius < 0xea6000)
1840 angles.radius, (short *)&markerColour);
1841
1843 (short)GetViewportPixel(
1848 (short)GetViewportPixel(
1853 (short)GetViewportPixel(
1858 (short)GetViewportPixel(
1863 (short)GetViewportPixel(
1883 (short)markerColour);
1888 (short)markerColour);
1889 }
1890 if (g_nCurrentView == 4)
1893}
1894
1895/* Function start: 0x43BE1B */
1896void start_lock(unsigned short v)
1897{
1902 RandomBelowOrEqual(0x167);
1903}
1904
1905/* Function start: 0x43BE55 */
1906short starting_lock(unsigned short v)
1907{
1908 if (g_nTargetLockCountdown == -1) {
1909 start_lock(v);
1910 return 1;
1911 }
1912 return 0;
1913}
1914
1915/* Function start: 0x43BE8D */
1916void lock_off(void)
1917{
1918 if (g_nTargetLockCountdown > -1) {
1920 if (
1921 ((ShipWeaponSlot *)&g_aShipWeapons[0][1])[
1922 g_nSelectedReleaseWeaponIndex].type == 0x13) {
1923 StopMusic(0);
1925 }
1926 }
1930}
1931
1932/* Function start: 0x43BEFF */
1934{
1935 if (malf(5) != 0) {
1937 lock_off();
1939 (short)(0 - (RandomBelowOrEqual(30) + 10));
1940 PlaySfxWaveFileByNumber(7, -1, 0);
1941 return 1;
1942 }
1943 return 0;
1944}
1945
1946/* Function start: 0x43BF67 */
1947short decrement_lock_time(short screenX)
1948{
1949 (void)screenX;
1950 if (g_nTargetLockCountdown > 0) {
1951 if (malf(5) == 0) {
1955 if (g_bTargetLockAcquired != 0) {
1956 if (CheckTargetLockMalfunction() == 0)
1957 PlaySfxWaveFileByNumber(0x16, -1, 0);
1959 g_cRedColour, 2);
1960 } else if (((ShipWeaponSlot *)(
1961 g_aShipWeapons[0] + 1))[
1963 .type != OBJECT_DATA_TORPEDO) {
1964 PlaySfxWaveFileByNumber(0x15, -1, 0);
1965 }
1966 }
1967 return 1;
1968 }
1969 return 0;
1970}
1971
1972/* Function start: 0x43C048 */
1973void target_locking(signed char target)
1974{
1975 short x;
1976 short y;
1977
1978 if (g_nCurrentView == 4)
1979 return;
1980 if (target == -1 ||
1981 g_asShipSide[(short)target] == g_asShipSide[0] ||
1982 g_acPlayerComponentDamage[5] >= 4) {
1984 lock_off();
1985 return;
1986 }
1987 if (g_asObjectScreenX[(short)target] == -0x7fff)
1988 return;
1989 x = g_asObjectScreenX[(short)target];
1990 y = g_asObjectScreenY[(short)target];
1991 if (g_nTargetLockCountdown < -1) {
1993 return;
1994 }
1995 if (y * y + x * x > 0xe10) {
1996 lock_off();
1997 return;
1998 }
1999 switch (((ShipWeaponSlot *)(g_aShipWeapons[0] + 1))[
2002 get_facing_range_from_object(0, (short)target);
2003 if (g_nTargetFacing > -0x41 ||
2004 CanShipWeaponDamageTarget(0, (short)target) == 0)
2005 lock_off();
2006 else if (starting_lock(0x0c) == 0)
2008 break;
2010 if (CanShipWeaponDamageTarget(0, (short)target) == 0)
2011 lock_off();
2012 else if (starting_lock(0x16) == 0)
2014 break;
2016 if (IsCapitalShipObject((short)target) == 0)
2017 lock_off();
2018 else if (g_nCurrentView != 4) {
2019 get_facing_range_from_object(0, (short)target);
2020 if (g_bTargetLockMode == 0 ||
2023 4) {
2024 lock_off();
2025 } else {
2030 if (starting_lock(300) != 0)
2031 ProcessMusicScriptCommand(0x2a, 1, 0);
2032 else
2034 }
2035 }
2036 break;
2037 default:
2038 lock_off();
2039 break;
2040 }
2041}
2042
2043/* Function start: 0x43C30D */
2044void SetRectBounds(Viewport *viewport, unsigned short a, unsigned short b,
2045 unsigned short c, unsigned short d)
2046{
2047 viewport->left = (short)a;
2048 viewport->top = (short)b;
2049 viewport->right = (short)c;
2050 viewport->bottom = (short)d;
2051}
2052
2053/* Function start: 0x43C344 */
2054short GetRectHeight(const Viewport *viewport)
2055{
2056 return viewport->right - viewport->left;
2057}
2058
2059/* Function start: 0x43C364 */
2060void print_message_text(char *text, unsigned short colour)
2061{
2062 Viewport menuViewport;
2063 char sourceText[84];
2064 short charsPerLine;
2065 char wrappedText[84];
2066 Viewport flightView;
2067 char *in;
2068 TextContext menuContext;
2069 TextContext flightText;
2070 short topY;
2071 short position;
2072 char *out;
2073 short breakPos;
2074
2075 breakPos = -1;
2076 DosStrcpy(sourceText, text);
2077 strcpy(wrappedText, "");
2078 menuViewport = *g_3_stDefaultStringContext.viewport;
2079 menuContext = g_3_stDefaultStringContext;
2080 menuContext.viewport = &menuViewport;
2081 topY = (short)(g_stHudMessageOrigin.y +
2083 SetRectBounds(&menuViewport,
2085 topY,
2086 (short)(319 - g_stHudMessageOrigin.x),
2087 (short)(topY + 60));
2088 menuContext.colour = (unsigned char)colour;
2089 menuContext.backgroundColour = 0xff;
2090 flightView = *g_168_stFlightTextContext.viewport;
2091 flightText = g_168_stFlightTextContext;
2092 flightText.viewport = &flightView;
2093 SetRectBounds(&flightView,
2096 (short)(319 - g_stHudMessageOrigin.x),
2097 (short)(g_stHudMessageOrigin.y + 60));
2098 flightText.colour = (unsigned char)colour;
2099 flightText.backgroundColour = 0xff;
2100 charsPerLine = (short)(GetRectHeight(&menuViewport) / 6);
2101 in = sourceText;
2102 out = wrappedText;
2103 position = 0;
2104 while (*in != 0) {
2105 *out = *in;
2106 if (*out == ' ')
2107 breakPos = position;
2108 if ((position + 1) % charsPerLine == 0) {
2109 if (breakPos == -1) {
2110 out++;
2111 *out = '\n';
2112 } else {
2113 *(out + position - breakPos) = '\n';
2114 }
2115 }
2116 in++;
2117 out++;
2118 position++;
2119 }
2120 *out = 0;
2121 DrawTextAt(&menuContext,
2123 topY,
2124 wrappedText, 2);
2126}
2127
2128/* Function start: 0x43C570 */
2141
2142/* Function start: 0x43C5B0 */
2157
2158/* Function start: 0x43C601 */
2159void SetHudTextColour(char *text, unsigned short colour)
2160{
2164 }
2168}
2169
2170/* Function start: 0x43C64D */
2186
2187/* Function start: 0x43C6D8 */
2188void draw_target_box(unsigned short colour, signed char object,
2189 short solid, short drawLockMarker, short padding,
2190 ShortRect *savedBounds)
2191{
2192 short midY;
2193 ShortRect bounds;
2194 short midX;
2195 short size;
2196 short segment;
2197 short visible;
2198
2199 if ((int)(unsigned char)g_cPrimaryViewBufferColour ==
2200 (int)(short)colour) {
2201 visible = savedBounds->left != -0x7fff;
2202 bounds = *savedBounds;
2203 } else {
2204 visible = object != -1 &&
2205 g_asObjectScreenX[object] != -0x7fff;
2206 if (visible != 0) {
2207 midX = (short)(g_asObjectScreenX[object] +
2209 midY = (short)(g_asObjectScreenY[object] +
2211 if ((short)GetTransformedShapeBounds(
2212 &g_27_stViewScratchInfo, midX, midY,
2213 g_apObjectShape[object],
2214 g_asObjectViewFrame[object],
2215 g_asObjectScreenAngle[object],
2216 g_asObjectScreenScale[object],
2217 g_asObjectFlip[object],
2218 (short *)&bounds) != 0) {
2219 bounds.left = (short)(bounds.left - padding);
2220 bounds.top = (short)(bounds.top - padding);
2221 bounds.right = (short)(bounds.right + padding);
2222 bounds.bottom = (short)(bounds.bottom + padding);
2223 } else {
2224 visible = 0;
2225 }
2226 }
2227 }
2228 if (visible != 0) {
2229 if ((int)(unsigned char)g_cRedColour ==
2230 (int)(short)colour &&
2231 g_asShipIdentified[object] == 0) {
2232 colour = g_cYellowColour;
2233 }
2234 if ((int)(unsigned char)g_cRedColour ==
2235 (int)(short)colour &&
2236 g_asShipSide[object] == SIDE_IMPERIAL) {
2237 colour = g_cBlueColour;
2238 }
2239 if (solid != 0) {
2241 bounds.right, bounds.bottom, colour);
2242 } else {
2243 segment =
2244 (short)(((int)bounds.right - bounds.left) / 6 + 1);
2246 (short)(bounds.left + segment), bounds.top,
2247 colour);
2249 (short)(bounds.left + segment), bounds.bottom,
2250 colour);
2252 (short)(bounds.right - segment), bounds.top,
2253 colour);
2255 (short)(bounds.right - segment), bounds.bottom,
2256 colour);
2257 segment =
2258 (short)(((int)bounds.bottom - bounds.top) / 6 + 1);
2260 bounds.left, (short)(bounds.top + segment),
2261 colour);
2263 bounds.left,
2264 (short)(bounds.bottom - segment), colour);
2266 bounds.right, (short)(bounds.top + segment),
2267 colour);
2269 bounds.right,
2270 (short)(bounds.bottom - segment), colour);
2271 }
2272 if (drawLockMarker != 0) {
2273 if ((int)(short)colour != (int)(unsigned char)g_cPrimaryViewBufferColour) {
2274 if (g_nTargetLockCountdown > -1) {
2275 g_nTargetLockMarkerAngle = (short)(
2279 size =
2280 (short)(g_nTargetLockCountdown * 2);
2281 if (((ShipWeaponSlot *)(g_aShipWeapons[0] +
2283 .type == 0x13)
2284 size >>= 3;
2285 midX = (short)(midX +
2287 size) >> 8));
2288 midY = (short)(midY +
2290 size) >> 8));
2293 g_nTargetLockMarkerX = midX;
2295 }
2296 } else if (g_nTargetLockMarkerX != -0x7fff) {
2302 g_nTargetLockMarkerX = -0x7fff;
2303 }
2304 }
2305 if ((int)(unsigned char)g_cPrimaryViewBufferColour == (int)(short)colour) {
2306 savedBounds->left = -0x7fff;
2307 } else {
2308 *savedBounds = bounds;
2309 }
2310 } else {
2311 savedBounds->left = -0x7fff;
2312 }
2313}
2314
2315/* Function start: 0x43CBD3 */
2317{
2318 if (g_nNavPointerObject != -1)
2320}
2321
2322/* Function start: 0x43CBFD */
2324{
2325 int screenCoord;
2326 int projected;
2327 int magnitude;
2328 FixedVector direction;
2329 int scale;
2330 FixedVector eyePos;
2331 FixedVector objectivePos;
2332 short onScreen;
2333
2334 if (get_mode(1) == 5 &&
2335 g_nTrainSimActive != 4 &&
2336 g_nCannedSceneMode == 0 &&
2337 (g_nCurrentView == 0 || g_nCurrentView == 5) &&
2339 (short)g_cCurrentObjective) == 0)
2340 onScreen = 1;
2341 else
2342 onScreen = 0;
2343 if (onScreen == 0) {
2345 return;
2346 }
2347 if (g_nNavPointerObject == -1) {
2349 if (g_nNavPointerObject == -1)
2350 return;
2359 }
2360 g_asObjectScreenX[g_nNavPointerObject] = (short)0x8001;
2362 objectivePos = g_aMissionObjectives[
2363 (signed char)g_cCurrentObjective].position;
2365 &objectivePos, &direction);
2366 magnitude = Vector_magnitude(&direction);
2368 magnitude) {
2369 transform_to_objects_frame(&direction, &eyePos,
2370 EYE_OBJECT);
2372 eyePos.z) {
2373 if (DivideFixed(eyePos.z, magnitude) >= 0) {
2374 scale = ((g_nScreenWidth >> 1) << 1) << 7;
2375 projected = MultiplyFixed(scale, eyePos.x);
2376 screenCoord = DivideFixed(projected, eyePos.z);
2379 (short)(screenCoord >> 8);
2380 projected = MultiplyFixed(scale, eyePos.y);
2381 screenCoord = DivideFixed(projected, eyePos.z);
2384 (short)(screenCoord >> 8);
2386 g_nNavPointerObject] = 0x4a38;
2387 }
2388 }
2389 }
2390}
2391
2392/* Function start: 0x43CE8F */
2393short HasInRangeGunForTargetLead(short targetRange)
2394{
2395 short prior;
2396 short count;
2397
2398 count = (signed char)g_aShipWeapons[0][0];
2399 while ((prior = count--) > 0) {
2400 if (((ShipWeaponSlot *)(
2401 g_aShipWeapons[0] + 1))[count].disabled == 0 &&
2402 g_aObjectTypeData[(signed char)((ShipWeaponSlot *)(
2403 g_aShipWeapons[0] + 1))[count].weaponType]
2404 .objectClass == OBJECT_CLASS_PROJECTILE &&
2405 g_aObjectTypeData[(signed char)((ShipWeaponSlot *)(
2406 g_aShipWeapons[0] + 1))[count].weaponType]
2407 .maximumVelocity *
2408 g_aObjectTypeData[(signed char)(
2409 (ShipWeaponSlot *)(
2410 g_aShipWeapons[0] + 1))[count]
2411 .weaponType]
2412 .lifetime >
2413 targetRange)
2414 return 1;
2415 }
2416 return 0;
2417}
2418
2419/* Function start: 0x43CF5A */
2421{
2422 FixedVector combinedProjectileVelocity;
2423 short tracked;
2424 short gun;
2425 short boltSpeed;
2426 FixedVector scratch;
2427 short rangeToTarget;
2428 int targetDistance;
2429 short frames;
2430 FixedVector targetMotion;
2431 FixedVector meetPoint;
2432 FixedVector eyeRelative;
2433
2434 if ((signed char)g_bTargetLockDisplayEnabled == 0)
2435 return;
2436 if (g_bTargetLockMode == 0) {
2438 return;
2439 }
2440
2441 tracked = g_acShipTarget[0];
2442 rangeToTarget = distance_from_object(0, tracked);
2443 boltSpeed = 100;
2444 if (g_nCurrentView == 4) {
2445 boltSpeed =
2448 } else {
2449 gun = (signed char)g_aShipWeapons[0][0];
2450 while (gun-- > 0) {
2451 if (((ShipWeaponSlot *)(
2452 g_aShipWeapons[0] + 1))[gun].disabled == 0 &&
2454 ((ShipWeaponSlot *)(g_aShipWeapons[0] + 1))[
2455 gun].weaponType].objectClass ==
2457 boltSpeed <
2459 ((ShipWeaponSlot *)(
2460 g_aShipWeapons[0] + 1))[
2461 gun].weaponType].maximumVelocity)
2462 boltSpeed =
2464 ((ShipWeaponSlot *)(
2465 g_aShipWeapons[0] + 1))[
2466 gun].weaponType].maximumVelocity;
2467 }
2468 }
2469
2471 &g_aShipVelocity[0],
2473 &combinedProjectileVelocity);
2476 (int)boltSpeed << 8, &scratch);
2478 &scratch, &combinedProjectileVelocity,
2479 &combinedProjectileVelocity);
2480 boltSpeed =
2481 (short)((Vector_magnitude(&combinedProjectileVelocity) >> 8) + 1);
2482 frames = (short)(rangeToTarget / boltSpeed);
2483 zero_vector(&targetMotion);
2484 if (frames > 0)
2486 &g_aShipVelocity[tracked],
2487 (int)frames << 8, &targetMotion);
2489 &g_aShipPosition[tracked],
2490 &targetMotion, &meetPoint);
2492 distance_from_point(0, &meetPoint)) == 0) {
2494 "OUT OF RANGE",
2495 g_cRedColour, 20);
2497 return;
2498 }
2499
2501 &g_aShipPosition[0], &meetPoint, &scratch);
2502 targetDistance = Vector_magnitude(&scratch);
2504 EYE_OBJECT] * 0x100 < targetDistance) {
2506 &scratch, &eyeRelative, EYE_OBJECT);
2507 if ((int)g_asObjectCollisionRadius[0] * 0x100 <=
2508 eyeRelative.z &&
2509 DivideFixed(eyeRelative.z, targetDistance) >= 0) {
2511 (short)DivideFixed(
2513 eyeRelative.x),
2514 eyeRelative.z);
2519 (short)DivideFixed(
2521 eyeRelative.y),
2522 eyeRelative.z);
2524 (short)(g_37_nViewCenterY +
2526 }
2527 }
2528 if (g_nTargetLeadIndicatorX >= 10 &&
2529 g_nTargetLeadIndicatorX <= 310 &&
2543 } else {
2544 g_nTargetLeadIndicatorX = 0x7fff;
2545 }
2546}
2547
2548/* Function start: 0x43D323 */
2562
2563/* Function start: 0x43D386 */
2565{
2566 ShortRect reticleBounds;
2567
2568 reticleBounds.left = (short)(g_15_nStoredScreenViewCentreX - 2);
2569 reticleBounds.right = (short)(g_15_nStoredScreenViewCentreX + 2);
2570 reticleBounds.top = (short)(g_37_nViewCenterY - 2);
2571 reticleBounds.bottom = (short)(g_37_nViewCenterY + 2);
2573 if (g_nTargetCameraFrame == 0 &&
2574 g_acShipTarget[0] != -1 &&
2576 g_acShipTarget[0]] <
2578 g_bTargetLockActive == 0 &&
2580 g_bTargetLockMode != 0 &&
2583 0, g_acShipTarget[0])) != 0 &&
2584 (signed char)g_bTargetLockDisplayEnabled != 0) {
2587 "ITTS ENGAGED",
2588 g_cRedColour, 20);
2589 }
2590 if (g_acShipTarget[0] == -1 ||
2592 g_acShipTarget[0]] == 1 &&
2594 g_acShipTarget[0]] >= 40)) {
2597 }
2598 if (g_bTargetLockActive != 0 &&
2601 if (message_showing() && g_nCommSpeakerObject != -1) {
2603 (signed char)g_nCommSpeakerObject;
2606 0, 0, 2,
2608 }
2609 if (g_nCurrentView == 4 &&
2610 g_nAimCameraMode == 1 &&
2611 g_acShipTarget[0] != -1) {
2612 if (g_nTargetCameraFrame == 0) {
2614 g_acShipTarget[0],
2616 1, 1,
2618 g_nTargetCameraZoom = 0x42;
2619 } else if (g_aObjectTypeData[
2620 g_nObjectType62Index].shapeSet == 0) {
2622 g_acShipTarget[0],
2624 1, 1,
2626 }
2627 }
2628 if (g_nCurrentView != 4 ||
2629 g_nAimCameraMode != 1) {
2630 if (g_nTargetLockCountdown == 0) {
2631 if (g_nRenderedSpaceFrame % 2 == 0)
2633 if (g_bTargetBracketVisible == 1)
2636 g_acShipTarget[0],
2639 } else {
2642 g_acShipTarget[0],
2645 }
2646 }
2647 if (g_nCurrentView != 4 ||
2648 g_nAimCameraMode != 1) {
2650 &reticleBounds,
2653 g_66_pCabinHudImage, 5) != 0) {
2657 (short)(g_15_nStoredScreenViewCentreX + 1),
2660 } else {
2667 }
2668 } else {
2674 }
2676 if (g_nCockpitControlState == 1) {
2688 }
2689}
2690
2691/* Function start: 0x43D7F2 */
2699
2700/* Function start: 0x43D81F */
2740
2741/* Function start: 0x43D956 */
2742void SetHudMessageText(char *text, unsigned short colour,
2743 unsigned short duration)
2744{
2746 return;
2747 if (message_showing())
2750 g_18_nHudMessageColour = colour;
2751 set_message_time(duration);
2752}
2753
2754/* Function start: 0x43D9AB */
2755/* Take a HUD message down early so the next transmission can replace it. */
2757{
2758 if (message_showing() != 0)
2760 set_message_time(-1);
2761}
2762
2763/* Function start: 0x43D9DA */
2764void malf_noise(short vdu, int effect, unsigned short colour,
2765 short sound, short refresh)
2766{
2767 Viewport *viewport = vdu == 0 ? &g_2_stLeftwardVduPortBlock : &g_4_stRightVduView;
2768
2769 if (sound != -1) {
2770 if (sound == 0x17)
2772 else
2773 PlaySfxWaveFileByNumber(sound, -1, 0);
2774 }
2775 snow_viewport(viewport, effect, colour);
2776 if (refresh != 0)
2777 set_new_vdu(vdu);
2778}
2779
2780/* Function start: 0x43DA68 */
2781void build_your_target_list(short *hasEnemy)
2782{
2783 short frameBounds[4];
2784 unsigned char specialSlot;
2785 short posY;
2786 short posX;
2787 unsigned short distance;
2788 signed char contact;
2789
2790 *hasEnemy = 0;
2792 if (g_nCurrentView == 4 &&
2793 g_nAimCameraMode == 1) {
2794 if (g_nTargetCameraZoom >= 33) {
2795 for (specialSlot = 0; specialSlot < 10;
2796 specialSlot++) {
2797 if (((g_aeObjectClass[specialSlot] !=
2799 g_asObjectType[specialSlot] == 0x3d) ||
2800 g_asObjectType[specialSlot] == 0x2c) &&
2801 g_asObjectScreenX[specialSlot] !=
2802 (short)0x8001) {
2803 posX = (short)(
2804 g_asObjectScreenX[specialSlot] +
2806 posY = (short)(
2807 g_asObjectScreenY[specialSlot] +
2810 &g_27_stViewScratchInfo, posX, posY,
2811 g_apObjectShape[specialSlot],
2812 g_asObjectViewFrame[specialSlot],
2813 g_asObjectScreenAngle[specialSlot],
2814 g_asObjectScreenScale[specialSlot],
2815 g_asObjectFlip[specialSlot], frameBounds);
2817 (const ShortRect *)frameBounds,
2821 0) != 0) {
2822 distance = (unsigned short)
2823 g_asObjectDistance[specialSlot];
2824 if (distance < 4000) {
2826 (int)g_cViableTargetCount] =
2827 (signed char)specialSlot;
2829 (int)g_cViableTargetCount] =
2830 (short)distance;
2832 }
2833 }
2834 }
2835 }
2836 }
2837 } else {
2838 for (contact = 1; contact <= 9; contact++) {
2839 if (g_aeObjectClass[(int)contact] >=
2841 g_aeSpecialManeuver[(int)contact] !=
2843 g_asObjectScreenX[(int)contact] !=
2844 (short)0x8001) {
2845 distance = (unsigned short)
2846 g_asObjectDistance[(int)contact];
2847 if (distance < 12000) {
2849 (int)g_cViableTargetCount] = contact;
2851 (int)g_cViableTargetCount] =
2852 (short)distance;
2854 if (g_asShipSide[(int)contact] !=
2855 g_asShipSide[0])
2856 *hasEnemy = 1;
2857 }
2858 }
2859 }
2860 }
2861 if (g_cViableTargetCount > 1)
2863}
2864
2865void build_your_target_list(short *hasEnemy);
2866short distance_from_object(short obj, short other);
2867short malf(char component);
2868short FindNearestMissileTargetingObject(short obj);
2869
2870/* Function start: 0x43DD1B */
2872{
2873 short anyEnemy;
2874 signed char index;
2875 short entryTarget;
2876
2877 entryTarget = g_acShipTarget[0];
2878 build_your_target_list(&anyEnemy);
2879 if (g_cViableTargetCount == 0) {
2880 g_acShipTarget[0] = -1;
2881 } else {
2882 index = 0;
2883 while (index < g_cViableTargetCount &&
2884 g_acViableTarget[(int)index] !=
2885 g_acShipTarget[0])
2886 index++;
2887 do {
2888 index = (signed char)((index + 1) %
2890 g_acShipTarget[0] =
2891 g_acViableTarget[(int)index];
2892 } while (anyEnemy != 0 &&
2894 g_asShipSide[0]);
2895 }
2896 if (g_acShipTarget[0] != entryTarget)
2898}
2899
2900/* Function start: 0x43DDFC */
2902{
2903 short reselect;
2904 short anyEnemy;
2905 short targetIndex;
2906 short previousTarget;
2907 short target;
2908
2909 target = g_acShipTarget[0];
2910 reselect = 1;
2911 if (g_nTargetCameraFrame == 1)
2912 return;
2913 if (target != -1 &&
2914 g_aeSpecialManeuver[target] ==
2916 g_acShipTarget[0] = -1;
2917 target = g_acShipTarget[0];
2918 }
2919 previousTarget = target;
2920 if (g_bTargetLockMode != 0 &&
2921 g_nRenderedSpaceFrame % 8 == 0 &&
2922 malf(5) != 0) {
2925 malf_sound();
2926 }
2927
2928 /* Keep the current target while the lock holds it, or while it is on
2929 * screen and hostile; otherwise fall through and pick a new one. */
2930 if (target == -1 ||
2931 (g_bTargetLockMode == 0 &&
2932 g_asObjectScreenX[target] == (short)0x8001) ||
2933 (g_bTargetLockMode == 0 &&
2934 g_asShipSide[target] == g_asShipSide[0])) {
2935 if (target == -1 && g_nCurrentView != 4)
2937
2938 build_your_target_list(&anyEnemy);
2939 if (g_cViableTargetCount == 0) {
2940 if (g_nCurrentView == 4 &&
2941 g_nAimCameraMode == 1) {
2942 g_acShipTarget[0] = -1;
2943 if (previousTarget != -1)
2944 g_nTargetCameraZoom = 0x21;
2945 } else if (g_bTargetLockMode != 0) {
2946 g_acShipTarget[0] = (signed char)previousTarget;
2947 } else {
2948 g_acShipTarget[0] = -1;
2949 }
2950 } else {
2951 if (anyEnemy == 0 && previousTarget != -1 &&
2952 g_asShipSide[previousTarget] ==
2953 g_asShipSide[0] &&
2954 (g_bTargetLockMode != 0 ||
2955 g_asObjectScreenX[target] != (short)0x8001)) {
2956 g_acShipTarget[0] = (signed char)previousTarget;
2957 reselect = 0;
2958 }
2959 if (reselect != 0) {
2960 targetIndex = 0;
2961 while (g_cViableTargetCount > targetIndex &&
2963 (short)g_acViableTarget[
2964 targetIndex]] ==
2965 g_asShipSide[0])
2966 targetIndex++;
2967 g_acShipTarget[0] =
2969 targetIndex %
2970 (short)g_cViableTargetCount];
2971 }
2972 }
2973 if (g_acShipTarget[0] != previousTarget) {
2974 if (g_nCurrentView != 4 && previousTarget != -1 &&
2975 (g_acShipTarget[0] == -1 ||
2976 g_asShipSide[target] !=
2977 g_asShipSide[previousTarget]))
2980 }
2981 }
2982}
2983
2984/* Function start: 0x43E101 */
2985/* The closest missile locked onto this object, or zero if none is. */
2987{
2988 short nearest;
2989 short other;
2990 short distance;
2991
2992 nearest = 0;
2993 for (other = 1; other < 10; other++) {
2994 if (g_aeObjectClass[other] == OBJECT_CLASS_MISSILE &&
2995 g_acShipTarget[other] == obj) {
2996 distance = distance_from_object(other, obj);
2997 if (nearest == 0 ||
2998 distance_from_object(nearest, obj) > distance)
2999 nearest = other;
3000 }
3001 }
3002 return nearest;
3003}
3004
3005/* Function start: 0x43E1B2 */
3007{
3008 short period;
3009 short distance;
3010 short missile;
3011
3012 if (FindMissileTargetingObject(0) != 0) {
3014 distance = distance_from_object(0, missile);
3015 if (distance < 500)
3016 period = 6;
3017 else if (distance < 1000)
3018 period = 5;
3019 else if (distance < 2000)
3020 period = 4;
3021 else if (distance < 4000)
3022 period = 3;
3023 else if (distance < 8000)
3024 period = 2;
3025 else
3026 period = 1;
3027 SetCockpitLightBlink(2, period);
3028 } else {
3030 }
3031}
3032
3033/* Function start: 0x43E297 */
3035{
3036 short yaw;
3037 short pitch;
3038
3039 yaw = g_anFlightInput[1] / 2;
3040 pitch = g_anFlightInput[0] / 2;
3041 if (yaw > 0) {
3043 (unsigned char)MinShort((short)(yaw + 8), 12);
3044 return;
3045 }
3046 if (yaw < 0) {
3048 (unsigned char)MinShort((short)(4 - yaw), 8);
3049 return;
3050 }
3051 if (pitch > 0) {
3053 (unsigned char)MinShort((short)(pitch + 12), 16);
3054 return;
3055 }
3056 if (pitch < 0) {
3058 (unsigned char)MinShort((short)-pitch, 4);
3059 return;
3060 }
3062}
3063
3064/* Function start: 0x43E371 */
3090
3091/* Function start: 0x43E43A */
3100
3101/* Function start: 0x43E472 */
3111
3112void vid_equiv(short obj, short message);
3113void real_vid_transmit(short obj, short message);
3114
3115/* Function start: 0x43E4A8 */
3116void send_message(short obj, signed char message)
3117{
3118 if (g_aeObjectClass[obj] == OBJECT_CLASS_NULL ||
3119 g_nTrainSimActive != 0)
3120 return;
3121 if (g_nYourWingman != -1 &&
3122 g_nYourWingman == obj &&
3123 g_bRadioSilence != 0) {
3124 g_acShipPendingMessage[obj] = -1;
3125 } else if (obj > -1 && obj < 10 &&
3127 if (g_acShipPortrait[obj] != -1) {
3128 g_acShipPendingMessage[obj] = message;
3129 } else if (g_asShipMissionIndex[obj] ==
3131 g_asShipMissionIndex[obj] ==
3133 g_acShipPendingMessage[obj] = message;
3134 } else if (g_asShipSide[obj] == SIDE_KILRATHI) {
3135 g_acShipPendingMessage[obj] = message;
3136 }
3137 }
3138}
3139
3140/* Function start: 0x43E5DA */
3142{
3143 signed char keptPortrait;
3144 signed char caller;
3145 signed char oldIndex;
3146 MissionShipRecord *savedRecord;
3147 signed char i;
3148
3149 if (g_nTrainSimActive == 0) {
3150 if (g_cQueuedNpcPortrait != -1) {
3151 keptPortrait = g_acShipPortrait[0];
3152 oldIndex = (signed char)g_asShipMissionIndex[0];
3153 savedRecord = g_apShipMissionRecord[0];
3155 for (i = 0; i < 16; i++) {
3156 if (g_aMissionShips[i].portrait ==
3158 break;
3159 }
3160 if (i == 16)
3161 ShowOnScreenMessage(0x270f, "SHOW_MESSAGE failed");
3162 g_asShipMissionIndex[0] = i;
3167 g_acShipPortrait[0] = keptPortrait;
3168 g_asShipMissionIndex[0] = oldIndex;
3170 }
3171 for (caller = 1;
3173 caller <= 9;
3174 caller++) {
3175 if (g_aeObjectClass[caller] >= OBJECT_CLASS_SHIP &&
3176 g_acShipPendingMessage[caller] != -1) {
3177 vid_equiv(caller, g_acShipPendingMessage[caller]);
3178 g_acShipPendingMessage[caller] = -1;
3179 }
3180 }
3181 if (RandomBelowOrEqual(5000) > 4998) {
3182 for (caller = 1;
3183 g_nCommSpeakerObject == -1 && caller <= 9;
3184 caller++) {
3185 if (g_aeObjectClass[caller] >= OBJECT_CLASS_SHIP &&
3186 g_asShipSide[caller] == SIDE_KILRATHI &&
3189 (g_asPilotLevel[caller] == 5 ||
3190 RandomBelowOrEqual(100) < 20)) {
3191 g_acShipPendingMessage[caller] =
3192 (signed char)(RandomBelowOrEqual(2) + 0x19);
3193 break;
3194 }
3195 }
3196 }
3197 }
3198}
3199
3200/* Function start: 0x43E870 */
3202{
3203 short *damageState;
3204 short damage;
3205
3206 damageState = g_69_asCockpitDmgStateList;
3207 for (damage = 0; damage < 4; damage++, damageState++)
3208 *damageState = 0;
3209}
3210
3211/* Function start: 0x43E8B2 */
3212void explosion_draw(int useBackgroundViewport)
3213{
3214 short hits;
3215 short x;
3216 short y;
3217
3219 return;
3220 for (hits = 0; hits < 4; hits++) {
3221 if (g_69_asCockpitDmgStateList[hits] == 1) {
3222 switch (hits) {
3223 case 0:
3225 break;
3226 case 2:
3228 break;
3229 case 3:
3231 break;
3232 }
3233 x = g_aCockpitDamagePositions[hits].x;
3234 y = g_aCockpitDamagePositions[hits].y;
3235 if (useBackgroundViewport == 0) {
3237 &g_101_stScrViewInfo, x, y,
3239 } else {
3243 }
3244 }
3245 }
3247}
3248
3249/* Function start: 0x43E9E2 */
3282
3283/* Function start: 0x43EAE3 */
3298
3299/* Function start: 0x43EB46 */
3332
3333/* Function start: 0x43EC50 */
3334void place_damage_on_cockpit(short damage)
3335{
3336 if (g_nCurrentView == 0 &&
3337 g_69_asCockpitDmgStateList[damage] == 0) {
3338 g_69_asCockpitDmgStateList[damage] = 1;
3340 if (g_pCockpitExplosionShape == 0) {
3341 explosion_draw(0);
3342 } else if (IsCockpitExplosionActive() == 0) {
3345 g_nCockpitExplosionFrame = 0x7fff;
3346 }
3347 }
3348}
3349
3350/* Function start: 0x43ECD9 */
3352{
3353 short frame;
3354
3355 if (g_nCommDeathSequenceFrame != 0) {
3356 if (g_nCommDeathSequenceFrame == 1) {
3366 } else if (g_nCommDeathSequenceFrame == 2) {
3376 } else if (g_nCommDeathSequenceFrame == 3) {
3382 } else {
3385 }
3386 } else if (g_bCommSpeechPlaying == 0 &&
3388 SIDE_NEUTRAL) {
3389 EndCommMenu();
3390 } else if (((g_nRenderedSpaceFrame % 2 != 0 &&
3391 g_nCockpitDisplayMode == 0) ||
3392 g_nCockpitDisplayMode != 0) &&
3393 g_nCommPortraitIndex != -1 &&
3398 g_bCommSpeechPlaying == 0 &&
3400 g_nCommSpeakerObject] < 7) {
3402 g_nCommSpeakerObject] < 3) {
3407 } else {
3410 frame = 5;
3413 frame = 6;
3422 }
3423 } else {
3424 if (g_nCommPortraitFrame == -1)
3438 (short)g_nCommPortraitFrame);
3439 }
3440 }
3441}
3442
3443/* Function start: 0x43F042 */
3444void vid_equiv(short obj, short message)
3445{
3446 if (get_mode(1) != 4 &&
3447 g_nTrainSimActive == 0 &&
3448 g_nCurrentView == 0 &&
3449 message_showing() == 0)
3450 real_vid_transmit(obj, message);
3451}
3452
3453/* Function start: 0x43F09D */
3454void update_dead_disp(short a)
3455{
3456 malf_noise(a, 1, g_cDarkGreenColour, 0x17, 0);
3457}
3458
3459/* Function start: 0x43F0C3 */
3461{
3462 if (g_aMissionShips[
3464 any_enemy(0, 30000) == 0)
3465 g_nArcadeState = 3;
3466}
3467
3468/* Function start: 0x43F110 */
3470{
3471 ShortRect rightBounds;
3472 ShortRect cockpitBounds;
3473 Viewport handViewport;
3474 ShortRect overlap;
3475 ShortRect leftBounds;
3476
3478 rightBounds.left = g_4_stRightVduView.left;
3479 rightBounds.top = g_4_stRightVduView.top;
3480 rightBounds.right = g_4_stRightVduView.right;
3481 rightBounds.bottom = g_4_stRightVduView.bottom;
3483 leftBounds.top = g_2_stLeftwardVduPortBlock.top;
3486 cockpitBounds.left = g_3_stDashViewport.left;
3487 cockpitBounds.top = g_3_stDashViewport.top;
3488 cockpitBounds.right = g_3_stDashViewport.right;
3489 cockpitBounds.bottom = g_3_stDashViewport.bottom;
3490
3491 if (GetViewportIntersection(&overlap, &cockpitBounds,
3492 &rightBounds) != 0) {
3504 }
3505 handViewport.left = (short)(g_stTrainSimRightVduSource.left -
3507 handViewport.bottom =
3511 &handViewport);
3512 }
3513
3514 if (GetViewportIntersection(&overlap, &cockpitBounds,
3515 &leftBounds) != 0) {
3527 }
3528 handViewport.left = (short)(g_stTrainSimLeftVduSource.left -
3530 handViewport.bottom =
3534 &handViewport);
3535 }
3536}
3537
3538/* Function start: 0x43F2F5 */
3539void update_VDUs(void)
3540{
3541 if (g_nCurrentView == 4)
3542 return;
3543 if (g_nCockpitDisplayMode != 0) {
3544 if (IsCockpitWeaponShapeLoaded() != 0) {
3551 }
3558 }
3559 if (IsCockpitWeaponShapeLoaded() != 0) {
3561 if (update_vid_disp(0) != 0) {
3562 switch (get_mode(0)) {
3563 case 0:
3565 break;
3566 case 2:
3568 break;
3569 case 1:
3571 break;
3572 }
3573 } else {
3574 switch (get_mode(0)) {
3575 case 0:
3577 break;
3578 case 2:
3579 if (g_nCockpitDisplayMode != 0) {
3583 }
3585 break;
3586 case 1:
3587 if (g_nCockpitDisplayMode != 0)
3590 break;
3591 }
3592 }
3593 if (get_mode(0) == 0)
3595 else
3597 }
3598
3600 if (update_vid_disp(1) != 0) {
3601 switch (get_mode(1)) {
3602 case 0:
3604 break;
3605 case 4:
3607 break;
3608 case 5:
3610 break;
3611 case 3:
3612 case 9:
3614 break;
3615 case 6:
3616 vid_transmit();
3617 break;
3618 }
3619 } else {
3620 switch (get_mode(1)) {
3621 case 0:
3623 break;
3624 case 4:
3625 if (g_nCockpitDisplayMode != 0)
3628 break;
3629 case 5:
3630 if (g_nCockpitDisplayMode != 0)
3633 break;
3634 case 3:
3635 case 9:
3636 if (g_nCockpitDisplayMode != 0)
3639 break;
3640 case 6:
3641 vid_transmit();
3642 break;
3643 }
3644 }
3645 if (get_mode(1) == 6 || get_mode(1) == 0)
3647 else
3649 if (g_nCockpitDisplayMode == 0 &&
3652}
3653
3654/* Function start: 0x43F6C9 */
3697
3698/* Function start: 0x43F81B */
3700{
3701 if (g_1_pDashWeaponPicture != 0)
3702 return 1;
3703 else
3704 return 0;
3705}
3706
3707/* Function start: 0x43F849 */
3708void PlayCockpitSelectionSfx(short selectionSound)
3709{
3710 (void)selectionSound;
3711 PlaySfxWaveFileByNumber(0x19, -1, 0);
3712}
3713
3714/* Function start: 0x43F862 */
3715void vdu_pop_all(short vdu)
3716{
3717 while ((short)GetVduModeStackDepth(vdu) > 0) {
3718 switch (get_mode(vdu)) {
3719 case 6:
3720 EndCommMenu();
3721 break;
3722 default:
3723 pop_mode(vdu);
3724 }
3725 }
3726}
3727
3728/* Function start: 0x43F8CD */
3729void SelectCockpitVduMode(short vdu, int mode)
3730{
3731 short changed;
3732
3733 if (vdu == 1 && mode == 9 && get_mode(vdu) == mode)
3734 return;
3735 if (g_nCurrentView == 0) {
3736 if (malf(3) != 0 ||
3737 (mode == 4 && malf(4) != 0)) {
3738 vdu_malf(vdu, 0x17);
3739 return;
3740 }
3742 changed = get_mode(vdu) != mode;
3743 if (changed != 0) {
3744 vdu_pop_all(vdu);
3745 InvalidateVduMode(vdu);
3746 if (mode != 4)
3747 set_mode(vdu, mode);
3748 else
3750 update_VDUs();
3751 return;
3752 }
3753 switch (mode) {
3754 case 0:
3755 break;
3756 case 2:
3758 break;
3759 case 4:
3761 break;
3762 case 5:
3764 break;
3765 case 3:
3767 break;
3768 case 9:
3769 break;
3770 case 1:
3771 if (g_cCurrentKey == 0x22) {
3773 } else if (g_cCurrentKey == 0x11) {
3774 lock_off();
3776 }
3777 break;
3778 }
3779 }
3780}
3781
3782/* Linker commons defined here. LINK lays a unit's commons out by the
3783 * identifiers' hash keys, so these spellings follow the original addresses. */
3785short g_3_nReleaseWeaponShowKindWord; /* 0x005d1c28 */
3786short g_1_nTargetLeadingIndicatorY; /* 0x005d1c2a */
3787unsigned char *g_4_pScannerBlipUnderlayPointer; /* 0x005d1c2c */
3788signed char g_14_cPilotHandFrameCode; /* 0x005d1c30 */
3789short g_9_nScreenMessageTimeNumber; /* 0x005d1c32 */
3790short g_36_nPendingDashDamageValue; /* 0x005d1c34 */
3791char g_4_nSpareCockptSlot; /* 0x005d1c36 */ /* never referenced */
3792signed char g_3_cOverlayMessageView; /* 0x005d1c37 */
3793char g_16_szTextBufferBuffer[256]; /* 0x005d1c40 */
3795int g_28_nUnusedCockptWordWord[3]; /* 0x005d1d70 */ /* never referenced */
3796short g_14_asScannerTargetUnderlay[5]; /* 0x005d1d80 */
3797char g_12_nUnusedCockptWord1; /* 0x005d1d8a */ /* never referenced */
3798short g_16_nUnusedCockptWord2; /* 0x005d1d8c */ /* never referenced */
3799signed char g_2_cEarlierTargetObjectValue; /* 0x005d1d8e */
3800int g_14_nUnusedCockptWord3; /* 0x005d1d90 */ /* never referenced */
3802char g_16_szComponentHitMsg[40]; /* 0x005d1da0 */
3803signed char g_13_abShipArrivalMessageSent[16]; /* 0x005d1dd0 */
3805short g_36_nTargetLockonMarkerY; /* 0x005d1e20 */
3808short g_8_nScopePointerX; /* 0x005d1e6c */
3809short g_9_nScannerCursorYValue; /* 0x005d1e6e */
3810signed char g_4_abCockpitLightMode[7]; /* 0x005d1e70 */
3811short g_nTargetLockMusicCooldown; /* 0x005d1e78 */
3812short g_10_asScannerObjectYTable[11]; /* 0x005d1e80 */
3814short g_15_asScannerObjectX[11]; /* 0x005d1ea0 */
3815signed char g_12_abCockpitLightGoalTable[7]; /* 0x005d1eb8 */
3817short g_47_asScannerBackgroundColourList[10]; /* 0x005d1ed0 */
3818short g_69_asCockpitDmgStateList[4]; /* 0x005d1ee8 */
3819unsigned short g_18_nHudMessageColour; /* 0x005d1ef0 */
3820char g_12_szSoundTraceScratch[0x200]; /* 0x005d1f00 */
3822short g_128_nShotHotspotLeft; /* 0x005d2120 */
3823short g_27_nSceneHotspotTopValue; /* 0x005d2122 */
3824short g_8_nSceneRegionRightWord; /* 0x005d2124 */
3825short g_15_nSceneAreaLowestWord; /* 0x005d2126 */
3826char g_1_nUnusedCockptSlotWord; /* 0x005d2128 */ /* never referenced */
3827void *g_13_pStartupStellarPacket; /* 0x005d212c */
3828char g_1_szLegacySaveFolder[0x30]; /* 0x005d2130 */
3834unsigned char *g_66_pCabinHudImage; /* 0x005d21f4 */
3835unsigned char *g_36_apTextGlyphs[4]; /* 0x005d2200 */
3839short g_78_bHighMemoryBuffersSetState; /* 0x005d2ad8 */
3844unsigned char *g_1_pDashWeaponPicture; /* 0x005d2b54 */
char g_1_nUnusedCockptSlotWord
Definition cockpt.c:3826
int g_14_nUnusedCockptWord3
Definition cockpt.c:3800
static char g_szNoWeaponSelected[8]
Definition cockpt.c:52
char g_12_szSoundTraceScratch[0x200]
Definition cockpt.c:3820
char g_4_nSpareCockptSlot
Definition cockpt.c:3791
short g_16_nUnusedCockptWord2
Definition cockpt.c:3798
char g_12_nUnusedCockptWord1
Definition cockpt.c:3797
int g_28_nUnusedCockptWordWord[3]
Definition cockpt.c:3795
short g_asVduSelectionSound[2]
Definition cockpt.c:30
#define COMM_SPEAKER_SIDE(obj)
Definition cockpt.c:118
void(__cdecl *g_pIxFree)(void *)
void vid_equiv(short obj, short message)
Definition cockpt.c:3444
void AdjustScannerContactColourForRange(int range, short *colour)
Definition cockpt.c:1650
void transform_to_objects_frame(const FixedVector *source, FixedVector *destination, short obj)
Definition geom.c:495
void set_message_time(short duration)
Definition cockpt.c:732
short find_ships_sphere(short missionShip)
Definition logic.c:816
void ComputeVectorDelta(FixedVector *from, FixedVector *to, FixedVector *delta)
Definition geom.c:229
void show_communications_disp(void)
Definition comm.c:355
void UpdateTargetCameraTracking(void)
Definition turret.c:849
short get_mode(short i)
Definition cockpt.c:630
void update_bars(void)
Definition cockpt.c:587
short kilrathi_near(short obj, short range)
Definition cockpt.c:395
void DrawViewportLine(Viewport *viewport, short x1, short y1, short x2, short y2, short colour)
Definition gr.c:1060
void SetRectBounds(Viewport *viewport, unsigned short left, unsigned short top, unsigned short right, unsigned short bottom)
Definition cockpt.c:2044
void DrawCockpitReadout(signed char slot, const char *text)
Definition cockpt.c:247
short MaxShort(short a, short b)
Definition disk.c:36
long MultiplyFixed(int left, int right)
Definition eventmgr.c:51
void DrawTargetCameraAttitudeIndicators(unsigned short colour)
Definition turret.c:995
short DrawHudMessageSlot(HudMessageSlot *slot)
Definition cockpt.c:269
void cockpit_explosion(void)
Definition cockpt.c:3300
void snow_viewport(Viewport *viewport, int effect, unsigned short colour)
Definition gr.c:1665
void set_next_destination(void)
Definition cockpt.c:1319
void place_damage_on_cockpit(short damage)
Definition cockpt.c:3334
void draw_3d_scanner(void)
Definition cockpt.c:1709
short distance_from_point(short obj, const FixedVector *point)
Definition geom.c:538
void check_message(void)
Definition cockpt.c:740
void start_lock(unsigned short v)
Definition cockpt.c:1896
signed char damage_your_component(char component, char amount, char maximum)
Definition cockpt.c:846
short LocateMobileObjective(short objective)
Definition cockpt.c:1345
void show_target_disp(void)
Definition target.c:23
short GetTransformedShapeBounds(Viewport *viewport, short x, short y, unsigned char *shape, short frame, short angle, short scale, short flip, short *bounds)
Definition gr.c:1518
void remove_object(short obj)
Definition geom.c:858
void UpdateDamageDisplay(void)
Definition damage.c:92
void DrawPendingCockpitDamage(void)
Definition cockpt.c:3250
void build_your_target_list(short *hasEnemy)
Definition cockpt.c:2781
short HasInRangeGunForTargetLead(short targetRange)
Definition cockpt.c:2393
void malf_noise(short vdu, int effect, unsigned short colour, short sound, short refresh)
Definition cockpt.c:2764
short GetRectHeight(const Viewport *viewport)
Definition cockpt.c:2054
long Vector_magnitude(const FixedVector *vector)
Definition eventmgr.c:157
void ejection_sequence(short outcome, signed char restoreCockpit)
Definition midscene.c:63
void update_missile_warning(void)
Definition cockpt.c:3006
short is_team_member(short missionShip)
Definition mission.c:1217
void update_objective_location(short objective)
Definition cockpt.c:1460
void AddFixedVectors(const FixedVector *left, const FixedVector *right, FixedVector *sum)
Definition geom.c:211
void check_objectives(void)
Definition cockpt.c:1515
void draw_nav_pointer(void)
Definition cockpt.c:2323
short sighted(short objective)
Definition cockpt.c:1134
void EndCommMenu(void)
Definition comm.c:441
void DrawViewportPixel(Viewport *viewport, short x, short y, short colour)
Definition gr.c:1038
void repair_internal_damage(void)
Definition ship.c:1439
void PlaySnowStaticSound(void)
Definition sound.c:347
void clear_cockpit_damage(void)
Definition cockpt.c:3201
short CheckTargetLockMalfunction(void)
Definition cockpt.c:1933
void ResetPilotHandAnimation(void)
Definition cockpt.c:3102
void explosion_draw(int useBackgroundViewport)
Definition cockpt.c:3212
void flag_reached(short objective, short reached)
Definition cockpt.c:1379
void SetTextContext(TextContext *context)
Definition eventmgr.c:179
void ClearHudMessageSlot(HudMessageSlot *slot)
Definition cockpt.c:303
void ScaleFixedVector(FixedVector *vector, int scale, FixedVector *result)
Definition geom.c:237
short update_vid_disp(short vdu)
Definition cockpt.c:702
void reset_cockpit(void)
Definition cockpt.c:488
void StopMusic(short enabled)
Definition music.c:30
void check_visit(short objective, short range)
Definition cockpt.c:1445
void PlayCockpitSelectionSfx(short selectionSound)
Definition cockpt.c:3708
void update_status_text(void)
Definition cockpt.c:1054
short starting_lock(unsigned short v)
Definition cockpt.c:1906
short GetViewportIntersection(ShortRect *intersection, const ShortRect *first, const ShortRect *second)
Definition eventmgr.c:2277
void DrawSolidColourSprite(Viewport *viewport, short x, short y, unsigned char *shape, short frame, unsigned short colour)
Definition gr.c:981
void DrawSpriteDefault(Viewport *viewport, short x, short y, unsigned char *shape, short frame)
Definition gr.c:682
void update_lights(void)
Definition cockpt.c:555
void RestoreCockpitExplosionBackground(void)
Definition cockpt.c:3284
short FixedToShortSaturating(int value)
Definition geom.c:122
void clear_head_up_display(void)
Definition cockpt.c:1577
long SinFixed(short degrees)
Definition eventmgr.c:80
short MinShort(short a, short b)
Definition disk.c:27
short any_enemy(short obj, short range)
Definition logic.c:610
void ClearHudMessageIfMatching(HudMessageSlot *slot, const char *text)
Definition cockpt.c:319
void show_navigation_disp(void)
Definition cockpt.c:1193
void InvalidateVduMode(short i)
Definition cockpt.c:714
void ClearHudGunReadouts(void)
Definition cockpt.c:326
void RefreshCommunicationMenu(void)
Definition comm.c:329
void ShowOnScreenMessage(short duration, const char *format,...)
Definition message.c:151
short CanShipWeaponDamageTarget(short ship, short target)
Definition ship.c:87
void CockpitMessage(const char *text, unsigned short colour, int flashCount)
Definition cockpt.c:373
void remove_message(const char *text)
Definition cockpt.c:389
void real_vid_transmit(short obj, short message)
Definition comm.c:510
void set_objective_range(short showOnScanner)
Definition cockpt.c:1630
void DrawFilledViewportRect(Viewport *viewport, short left, short top, short right, short bottom, short colour)
Definition gr.c:1339
short distance_from_object(short obj, short other)
Definition geom.c:547
const char * objective_name(short objective)
Definition cockpt.c:1181
void EndCommSessionWithWingman(void)
Definition comm.c:430
void ClearHudMessageDisplay(short closeCommMenu)
Definition cockpt.c:2171
void clear_message_time(void)
Definition cockpt.c:720
unsigned short SetVduModeIfChanged(short i, int state)
Definition cockpt.c:647
void show_damage_disp(void)
Definition damage.c:36
short visited(short objective)
Definition cockpt.c:1140
short achieved(short objective)
Definition cockpt.c:1146
void update_cockpit(void)
Definition cockpt.c:3655
void EraseCockpitReadoutRegion(Viewport *viewport, short left, short top, short right, short bottom, short colour)
Definition cockpt.c:139
unsigned char * GetInputCursorShape(void)
Definition eventmgr.c:2413
int LogUnknownSoundEffect(const unsigned char *definition, short sourceObject, short pan, short volume, short looping, short priority)
Definition music.c:422
short objective_lost(short objective)
Definition cockpt.c:1497
void CaptureSpriteBackground(Viewport *viewport, unsigned char *background, short x, short y, unsigned char *shape, short frame)
Definition gr.c:705
long CosFixed(short degrees)
Definition eventmgr.c:91
short IsCockpitExplosionActive(void)
Definition cockpt.c:133
void cycle_onscreen_targets(void)
Definition cockpt.c:2871
short IsMissionObjectiveOutOfSystem(short objective)
Definition cockpt.c:411
void RemovePlayerReleaseWeapon(signed char weapon)
Definition cockpt.c:872
void rotational_pos_to_scanner_pos(signed char object, const SphericalVector *position, CockpitScannerGeometry geometry)
Definition cockpt.c:1530
void check_target(void)
Definition cockpt.c:2901
void npc_communication(void)
Definition cockpt.c:3141
void ShowComponentHitHudMessage(const char *text, unsigned short colour, short flashCount)
Definition cockpt.c:830
void lock_off(void)
Definition cockpt.c:1916
short IsCockpitWeaponShapeLoaded(void)
Definition cockpt.c:3699
short auto_pilot_valid(short showReason)
Definition cockpt.c:440
void UpdateMessage(HudMessageSlot *slot)
Definition cockpt.c:351
void pop_mode(short i)
Definition cockpt.c:673
void overlay_head_up_display(void)
Definition cockpt.c:2564
void InflightComputer(void)
Definition nav.c:1096
void RestoreSpriteBackground(Viewport *viewport, unsigned char *background, short x, short y, unsigned char *shape, short frame)
Definition gr.c:846
void malf_sound(void)
Definition cockpt.c:802
void update_dead_disp(short a)
Definition cockpt.c:3454
long DivideFixed(int numerator, int denominator)
Definition eventmgr.c:64
void zero_vector(FixedVector *vector)
Definition geom.c:197
void print_message_text(char *text, unsigned short colour)
Definition cockpt.c:2060
void check_stranded(void)
Definition cockpt.c:3460
char * DosStrcpy(char *dst, const char *src)
Definition eventmgr.c:465
void UpdateTargetLeadIndicator(void)
Definition cockpt.c:2420
void UpdateTargetCameraCockpitHook(void)
Definition turret.c:1222
void vdu_polygon(signed char bar, short percent)
Definition cockpt.c:156
void SortViableTargetsByDistance(void)
Definition ship.c:720
void select_new_gun(void)
Definition select.c:74
void RestoreTransientCockpitGraphics(void)
Definition cockpt.c:2701
short is_any_ship_returning_to_current_nav_point(void)
Definition cockpt.c:1358
short locate_ship(short missionShip, FixedVector *point)
Definition logic.c:848
void DrawViewportBorder(Viewport *viewport, short left, short top, short right, short bottom, short colour)
Definition gr.c:1360
void RestoreTargetLeadIndicator(void)
Definition cockpt.c:2549
void remove_nav_pointer(void)
Definition cockpt.c:2316
short malf(char component)
Definition cockpt.c:811
void ClearViewport(Viewport *viewport, short colour)
Definition gr.c:1027
void DrawPilotHandFrame(void)
Definition cockpt.c:3065
short escorting_a_ship(void)
Definition cockpt.c:1372
short calculate_damage_level(void)
Definition main.c:1890
void remove_weapon(short obj, short weapon)
Definition ship.c:283
short find_vacant_3d_object(void)
Definition geom.c:841
unsigned short ProcessMusicScriptCommand(int track, int command, short enabled)
Definition music.c:89
short FindMissileTargetingObject(short obj)
Definition logic.c:357
short IsCapitalShipObject(short obj)
Definition ship.c:98
void SetHudMessageText(char *text, unsigned short colour, unsigned short duration)
Definition cockpt.c:2742
void get_facing_range_from_object(short obj, short other)
Definition geom.c:578
short GetVduModeStackDepth(short i)
Definition cockpt.c:658
void draw_target_box(unsigned short colour, signed char object, short solid, short drawLockMarker, short padding, ShortRect *savedBounds)
Definition cockpt.c:2188
void FlushSoundEffectsAndLog(void *effect, short flags)
Definition music.c:439
void push_mode(short i, int state)
Definition cockpt.c:664
void SetHudTextColour(char *text, unsigned short colour)
Definition cockpt.c:2159
void set_new_vdu(short vdu)
Definition cockpt.c:680
void PlaySfxWaveFileByNumber(int soundNumber, int sourceObject, int looping)
Definition music.c:490
void ResetScannerContacts(void)
Definition cockpt.c:1567
void vdu_malf(short vdu, short sound)
Definition cockpt.c:819
void vdu_pop_all(short vdu)
Definition cockpt.c:3715
short hidden_objective(short objective)
Definition cockpt.c:1206
unsigned int InitializeCockpitReadout(signed char slot, TextContext *context)
Definition cockpt.c:237
void rectangular_to_spherical(const FixedVector *rectangular, SphericalVector *spherical)
Definition geom.c:289
void draw_cockpit_lights(void)
Definition cockpt.c:513
void set_mode(short i, int state)
Definition cockpt.c:637
void ClearGlobalMessage(void)
Definition cockpt.c:383
void send_message(short obj, signed char message)
Definition cockpt.c:3116
void DismissHudMessageIfShowing(void)
Definition cockpt.c:2756
void DrawTargetRangeReadout(void)
Definition target.c:131
void flag_objective(short objective, unsigned char flags)
Definition cockpt.c:1153
void check_sighting(short objective, short range, short object)
Definition cockpt.c:1436
short IsObjectiveInDisplayedSystem(short objective)
Definition nav.c:580
void determine_pilot_hand(void)
Definition cockpt.c:3034
void DrawCalculatingLabel(void)
Definition cockpt.c:1160
short mobile_objective(short objective)
Definition cockpt.c:1558
short decrement_lock_time(short screenX)
Definition cockpt.c:1947
void SetTextCursor(unsigned short a, unsigned short b)
Definition eventmgr.c:172
void SetCockpitLightBlink(signed char light, short interval)
Definition cockpt.c:499
void select_new_release_weapon(short preferredType)
Definition select.c:83
void update_digital_readouts(void)
Definition cockpt.c:785
void RestoreHudMessageBackground(void)
Definition cockpt.c:2143
short IsPointWithinRange(FixedVector *from, FixedVector *to, short range)
Definition geom.c:760
void exit_squadron(const char *msg,...)
Definition message.c:44
void vector_component_in_dir(const FixedVector *vector, const FixedVector *direction, FixedVector *component)
Definition geom.c:375
short equ_vector(const FixedVector *left, const FixedVector *right)
Definition geom.c:182
void fire_computer_graphic_missile(void)
Definition cockpt.c:892
short GetViewportPixel(Viewport *viewport, short x, short y)
Definition gr.c:1049
void RestoreCockpitExplosionIfVisible(void)
Definition cockpt.c:2692
short set_new_objective(short pathIndex)
Definition cockpt.c:1272
void SetHudMessageSlot(HudMessageSlot *slot, TextContext *context, short x, short y, const char *text, unsigned short colour, signed char flashCount)
Definition cockpt.c:335
unsigned short RandomInRange(unsigned short lo, unsigned short hi)
Definition eventmgr.c:31
void FatalErrorAndExit(const char *format,...)
Definition cockpt.c:121
void FreePacketAndClear(void *slot, unsigned short releaseFlags)
Definition disk.c:45
void CopyTrainSimPilotViewToVdus(void)
Definition cockpt.c:3469
short find_ship_index(short missionShip)
Definition logic.c:251
void update_VDUs(void)
Definition cockpt.c:3539
void target_locking(signed char target)
Definition cockpt.c:1973
short FindNearestMissileTargetingObject(short obj)
Definition cockpt.c:2986
void show_weapon_disp(void)
Definition cockpt.c:939
void DrawFormattedText(const char *format,...)
Definition textfmt.c:103
short IsSpriteFrameOverlappingRect(const ShortRect *rectangle, short x, short y, unsigned char *shape, short frame)
Definition eventmgr.c:2235
void vid_transmit(void)
Definition cockpt.c:3351
short RandomBelowOrEqual(short n)
Definition eventmgr.c:43
void SelectCockpitVduMode(short vdu, int mode)
Definition cockpt.c:3729
short get_color(short object, unsigned short *colour)
Definition cockpt.c:1671
void CopyViewportContents(Viewport *source, Viewport *destination)
Definition gr.c:995
void set_global_message(const char *text, unsigned short colour, int flashCount)
Definition cockpt.c:363
void ShowHudTextLine(void)
Definition cockpt.c:2129
void RestoreTargetCameraAttitudeIndicators(void)
Definition turret.c:1087
short cycle_next_objective(void)
Definition cockpt.c:1299
void DrawTextAt(TextContext *context, int x, int y, const char *text, unsigned char alignment)
void animate_pilot(void)
Definition cockpt.c:3092
short message_showing(void)
Definition cockpt.c:726
Shared Win32 declarations, types and library interfaces.
@ MISSION_TYPE_ESCORT
Definition game_data.h:123
@ MISSION_TYPE_WARP_ARRIVE
Definition game_data.h:129
@ MISSION_TYPE_GOTO_WARP
Definition game_data.h:128
@ MISSION_TYPE_COME_HOME
Definition game_data.h:131
#define DIRECTION_VIEW_COUNT
Definition game_data.h:1582
#define EYE_OBJECT
Definition game_data.h:1580
ObjectType
Definition game_data.h:54
@ OBJECT_TYPE_TIGERS_CLAW
Definition game_data.h:63
@ SIDE_IMPERIAL
Definition game_data.h:175
@ SIDE_KILRATHI
Definition game_data.h:176
@ SIDE_NEUTRAL
Definition game_data.h:177
ShipObjective
Definition game_data.h:137
@ OBJECTIVE_ENGAGE_ENEMY
Definition game_data.h:145
@ OBJECTIVE_DESTROY_SHIP
Definition game_data.h:143
#define OBJECT_DATA_TORPEDO
Definition game_data.h:1613
@ OBJECT_DATA_SPICULUM_IMAGE_RECOGNITION_MISSILE
Definition game_data.h:443
@ OBJECT_DATA_JAVELIN_HEAT_SEEKING_MISSILE
Definition game_data.h:441
@ SPECIAL_MANEUVER_UNKNOWN_9
Definition game_data.h:269
@ OBJECT_CLASS_PLANET
Definition game_data.h:40
@ OBJECT_CLASS_MISSILE
Definition game_data.h:48
@ OBJECT_CLASS_SHIP
Definition game_data.h:49
@ OBJECT_CLASS_CAPITAL_SHIP
Definition game_data.h:50
@ OBJECT_CLASS_PROJECTILE
Definition game_data.h:45
@ OBJECT_CLASS_NULL
Definition game_data.h:37
short g_nObjectType62Index
Definition ship.c:12
short g_asObjectScreenAngle[SPACE_OBJECT_COUNT]
Definition viewrect.c:97
MissionShipRecord * g_apShipMissionRecord[10]
Definition viewrect.c:161
HazardField * g_pActiveHazardField
Definition viewrect.c:60
signed char g_14_cPilotHandFrameCode
Definition cockpt.c:3788
CockpitScannerGeometry g_stCockpitScannerGeometry
Definition cockpt.c:23
short g_27_aasGunCooldown[10][3]
Definition turret.c:1283
short g_asObjectCollisionRadius[SPACE_OBJECT_COUNT]
Definition viewrect.c:120
unsigned char * g_pHudMessageFrameShape
Definition cockpt.c:97
ShortPoint g_aCockpitDamagePositions[4]
Definition cockpt.c:14
short g_anFlightInput[3]
Definition viewrect.c:50
short g_nCommMessageIndex
Definition cockpt.c:11
short g_bCockpitDamageFrame2Shown
Definition cockpt.c:106
short g_nTargetLockMarkerX
Definition cockpt.c:101
short g_bCockpitDamageFrame0Shown
Definition cockpt.c:105
unsigned char * g_apCockpitVduOverlayShapes[2]
Definition personnel.c:9
short g_asShipMissionParameter[12]
Definition viewrect.c:164
short g_bCommSpeechPlaying
Definition comm.c:22
short g_8_nGunDisplaySlot
Definition turret.c:1288
unsigned char * g_apObjectShape[SPACE_OBJECT_COUNT]
Definition viewrect.c:100
short g_nScannerTargetObject
Definition cockpt.c:54
short g_8_nSceneRegionRightWord
Definition cockpt.c:3824
short g_nCurStellarSystem
Definition nav.c:1238
unsigned char * g_4_pCockpitPanelShape
Definition message.c:236
char * g_3_apszPersonnelImportCaptionsTable[8]
Definition cockpt.c:3821
short g_27_nSceneHotspotTopValue
Definition cockpt.c:3823
signed char g_acPlayerComponentDamage[9]
Definition viewrect.c:76
short g_asObjectDistance[SPACE_OBJECT_COUNT]
Definition viewrect.c:104
short g_nYourWingman
Definition viewrect.c:75
int g_nCockpitDisplayMode
Definition main.c:1929
short g_78_bHighMemoryBuffersSetState
Definition cockpt.c:3839
short g_asPilotLevel[12]
Definition viewrect.c:157
signed char g_bVideoImagesSuppressed
Definition comm.c:15
short g_nTargetLeadIndicatorX
Definition cockpt.c:31
ShortPoint g_stPilotHandOrigin
Definition cockpt.c:25
short g_nTargetLockMusicCooldown
Definition cockpt.c:3811
Viewport g_stTrainSimRightVduSource
Definition cockpt.c:108
short g_bFuelGaugeDamaged
Definition cockpt.c:46
short g_anObjectRollRotation[SPACE_OBJECT_COUNT]
Definition viewrect.c:119
ShortPoint ReleaseWeaponPosition
Definition globals.h:1393
short g_nFacingToTarget
Definition viewrect.c:45
signed char g_acCockpitLightOnFrame[7]
Definition cockpt.c:18
ShortPoint g_aCockpitReadoutOrigins[4]
Definition cockpt.c:20
short g_nTargetLockMarkerAngle
Definition viewrect.c:88
int g_nCurrentView
Definition spc.c:11
short g_7_asShipBurstStageCountdown[10]
Definition ship.c:3063
signed char g_abFlightPath[MISSION_OBJECTIVE_COUNT]
Definition viewrect.c:68
unsigned char * g_pCockpitExplosionBackground
Definition cockpt.c:41
TextContext g_168_stFlightTextContext
Definition cockpt.c:3832
short g_aeObjectClass[SPACE_OBJECT_COUNT]
Definition viewrect.c:125
short g_asViableTargetDistance[10]
Definition viewrect.c:199
short g_nSelectedReleaseWeaponIndex
Definition viewrect.c:84
short g_asShipIdentified[12]
Definition viewrect.c:182
char * g_pszPendingHudMessage
Definition cockpt.c:32
short g_asPilotHandOffsets[34]
Definition cockpt.c:35
signed char g_acShipTarget[16]
Definition viewrect.c:167
signed char g_13_abShipArrivalMessageSent[16]
Definition cockpt.c:3803
ShortPoint g_stHudMessageOrigin
Definition cockpt.c:13
signed char g_2_cEarlierTargetObjectValue
Definition cockpt.c:3799
signed char g_cCurrentObjective
Definition viewrect.c:57
short g_asObjectType[SPACE_OBJECT_COUNT]
Definition viewrect.c:124
ShortRect g_stPilotHandBounds
Definition cockpt.c:24
short g_nCockpitResetState
Definition viewrect.c:85
unsigned char g_cYellowColour
Definition startup.c:547
HudMessageSlot g_12_aHudTextSlotsArray[2]
Definition cockpt.c:3794
short g_aasShipShield[10][2]
Definition viewrect.c:134
short g_bTargetLockReadoutDirty
Definition viewrect.c:86
short g_asObjectFlip[SPACE_OBJECT_COUNT]
Definition viewrect.c:102
signed char g_acCockpitLightOffFrame[7]
Definition cockpt.c:17
Viewport g_stPilotHandViewportRecord
Definition message.c:233
unsigned char * g_pPilotHandAnimationShapePtr
Definition message.c:232
Viewport g_9_stCockpitMeterPort
Definition cockpt.c:3833
short g_69_asCockpitDmgStateList[4]
Definition cockpt.c:3818
ObjectTypeData g_aObjectTypeData[OBJECT_DATA_COUNT]
Definition campglob.c:310
MissionNavPoint g_aMissionNavPoints[MISSION_NAV_POINT_COUNT]
Definition hotspot.c:237
signed char g_acVduModeStackDepth[2]
Definition viewrect.c:81
FixedVector g_137_aDirectionViewUpVectorArray[DIRECTION_VIEW_COUNT]
Definition cockpt.c:3837
unsigned char * g_1_pDashWeaponPicture
Definition cockpt.c:3844
FixedVector g_aShipForwardVector[SPACE_OBJECT_COUNT]
Definition viewrect.c:107
signed char g_bRadioSilence
Definition comm.c:14
int g_aaiVduModeStack[3][4]
Definition viewrect.c:80
short g_asObjectScreenX[SPACE_OBJECT_COUNT]
Definition viewrect.c:95
unsigned char * g_66_pCabinHudImage
Definition cockpt.c:3834
short g_68_nDamageShowTicksNumber
Definition damage.c:267
signed char g_cReleaseWeaponDisplayState
Definition cockpt.c:51
FixedVector g_2_aDirectionViewForwardAxisTable[DIRECTION_VIEW_COUNT]
Definition cockpt.c:3838
signed char g_cMissionObjectiveCount
Definition viewrect.c:66
MouseCursorState g_37_stPersonnelMousePointerState
Definition eventmgr.c:2544
int g_nDisplayedObjectiveRange
Definition cockpt.c:53
unsigned char * g_pCockpitHudBackground
Definition cockpt.c:42
short g_asShipCloakElapsedFrames[10]
Definition viewrect.c:181
short g_15_asScannerObjectX[11]
Definition cockpt.c:3814
short g_aeSpecialManeuver[12]
Definition viewrect.c:141
signed char g_4_abCockpitLightMode[7]
Definition cockpt.c:3810
unsigned char * g_pCommVduFrameResource
Definition comm.c:17
unsigned short g_18_nHudMessageColour
Definition cockpt.c:3819
short g_14_asScannerTargetUnderlay[5]
Definition cockpt.c:3796
signed char g_acShipPortrait[12]
Definition viewrect.c:159
int g_anLastDrawnVduMode[3]
Definition viewrect.c:82
volatile short g_nCockpitExplosionFrame
Definition cockpt.c:44
int g_anShipFuel[10]
Definition viewrect.c:144
int g_bSpeechPlaybackDone
Definition sound.c:23
short g_nCommDeathSequenceFrame
Definition cockpt.c:10
short g_asShipWeaponEnergy[10]
Definition viewrect.c:136
short g_bMissileLockAcquired
Definition cockpt.c:104
ShortPoint g_stWeaponDisplayOffset
Definition cockpt.c:12
short g_19_nCommPortraitAnimationTickWord
Definition cockpt.c:3801
unsigned char g_cBlueColour
Definition startup.c:546
short g_asCockpitLightX[7]
Definition cockpt.c:15
unsigned char * g_pReleaseWeaponDisplayBackground
Definition cockpt.c:48
volatile ShortPoint g_8_stCockpitExplosionPosBlock
Definition cockpt.c:3813
signed char g_acViableTarget[16]
Definition viewrect.c:198
signed char g_acObjectOwner[SPACE_OBJECT_COUNT]
Definition viewrect.c:122
signed char g_bTargetBracketVisible
Definition cockpt.c:96
short g_47_asScannerBackgroundColourList[10]
Definition cockpt.c:3817
signed char g_abShipNavPointIndex[16]
Definition viewrect.c:170
short g_8_nScopePointerX
Definition cockpt.c:3808
signed char g_cReleaseWeaponDisplayFrame
Definition globals.h:1388
char g_1_szLegacySaveFolder[0x30]
Definition cockpt.c:3828
short g_nSpaceFrame
Definition viewrect.c:32
short g_6_nHomeOperationShipIndexValue
Definition cockpt.c:3806
short g_asObjectScreenScale[SPACE_OBJECT_COUNT]
Definition viewrect.c:103
short g_bTargetLockMode
Definition viewrect.c:92
short g_anObjectPitchRotation[SPACE_OBJECT_COUNT]
Definition viewrect.c:117
short g_nArmsDisplayOriginY
Definition damage.c:270
ShortPoint g_116_aWeaponDisplayPositions[16]
Definition cockpt.c:3804
short g_bDisplayWingmanTargetData
Definition viewrect.c:77
short g_nRenderedSpaceFrame
Definition viewrect.c:33
Viewport g_3_stDashViewport
Definition cockpt.c:3829
short g_nTargetFacing
Definition viewrect.c:46
FixedVector g_9_aDirectionLookRightVector[DIRECTION_VIEW_COUNT]
Definition cockpt.c:3836
signed char g_cQueuedNpcPortrait
Definition mission.c:17
unsigned char g_cSecondaryViewBufferColour
Definition startup.c:544
char g_szCommMessageTextText[0x58]
Definition comm.c:585
signed char g_3_cOverlayMessageView
Definition cockpt.c:3792
unsigned char g_abSoundEffectDefinitions[0x1b8]
Definition music.c:547
Viewport g_stPilotHandBackgroundViewportBlock
Definition cockpt.c:3843
int g_nArcadeState
Definition main.c:1938
unsigned char g_abGunDisplayConfiguration[0xa4]
Definition turret.c:1237
short g_3_nReleaseWeaponShowKindWord
Definition cockpt.c:3785
short g_bRewritePacketExtensions
Definition startup.c:543
short g_37_nViewCenterY
Definition eventmgr.c:2502
Viewport g_stCockpitBackgroundViewportRecord
Definition fltsetup.c:1068
int g_anShipSpeed[SPACE_OBJECT_COUNT]
Definition viewrect.c:116
short g_36_nPendingDashDamageValue
Definition cockpt.c:3790
short g_nHudMessageBackgroundDepth
Definition cockpt.c:100
unsigned char g_ucHomeCarrierScannerColour
Definition startup.c:553
unsigned char g_aShipWeapons[10][0xA1]
Definition viewrect.c:150
unsigned char g_cRedColour
Definition startup.c:548
Viewport g_27_stViewScratchInfo
Definition cockpt.c:3841
Viewport g_4_stRightVduView
Definition cockpt.c:3842
ShortRect g_stCommTargetBracketBounds
Definition cockpt.c:103
char g_16_szComponentHitMsg[40]
Definition cockpt.c:3802
short g_36_nTargetLockonMarkerY
Definition cockpt.c:3805
unsigned char g_ucPrimaryTextColour
Definition startup.c:550
short g_nNavPointerObject
Definition viewrect.c:52
short g_9_nScreenMessageTimeNumber
Definition cockpt.c:3789
ReleaseWeaponPosition g_3_stReleaseWeaponReadoutLocationBlock
Definition cockpt.c:3784
short g_nCockpitControlState
Definition main.c:1958
unsigned char * g_pHudMessageBackground
Definition cockpt.c:98
int g_anShipCloakState[10]
Definition viewrect.c:179
int g_nCurrentObjectiveRange
Definition viewrect.c:56
char g_szAutopilotWaitReason[28]
Definition cockpt.c:111
signed char g_acShipPendingMessage[16]
Definition viewrect.c:160
unsigned char g_bPrimaryViewBufferColour
Definition startup.c:545
short g_128_nShotHotspotLeft
Definition cockpt.c:3822
signed char g_cCurrentNavPointIndex
Definition viewrect.c:67
ShortRect g_stLeftVduBounds
Definition cockpt.c:21
Viewport g_stTrainSimLeftVduSource
Definition cockpt.c:109
char g_16_szTextBufferBuffer[256]
Definition cockpt.c:3793
volatile int g_196_nInputTimerTicks
Definition eventmgr.c:2550
FixedVector g_aShipPosition[SPACE_OBJECT_COUNT]
Definition viewrect.c:108
short g_15_nSceneAreaLowestWord
Definition cockpt.c:3825
unsigned char g_cPrimaryViewBufferColour
Definition startup.c:559
unsigned char g_ucDefaultTextColour
Definition startup.c:556
unsigned char g_ucHostileCapitalScannerColour
Definition startup.c:551
CockpitReadout g_9_aConsoleMetersTable[6]
Definition cockpt.c:3807
unsigned char * g_pPendingCockpitDamageShape
Definition cockpt.c:40
CockpitBarDefinition g_aCockpitBarDefinitions[8]
Definition cockpt.c:19
short g_nTargetCameraFrame
Definition turret.c:1239
short g_nCommPortraitIndex
Definition comm.c:21
unsigned char g_cDarkGreenColour
Definition startup.c:549
Viewport g_101_stScrViewInfo
Definition cockpt.c:3831
int g_nCommPortraitFrame
Definition cockpt.c:107
FixedVector g_aShipVelocity[SPACE_OBJECT_COUNT]
Definition viewrect.c:109
short g_asShipMissionIndex[12]
Definition viewrect.c:153
short g_bCaptureHudMessageBackground
Definition cockpt.c:99
int g_4_nSevereDmgWarningSfxHandle
Definition cockpt.c:3816
int g_aiTargetCameraScannerGridRows[50]
Definition cockpt.c:77
short g_bTargetLockActive
Definition cockpt.c:9
signed char g_cReleaseWeaponDisplayTicks
Definition cockpt.c:50
TextContext g_1_stRightVduTextContextBlock
Definition message.c:237
int g_nTrainSimActive
Definition main.c:1937
signed char g_cQueuedNpcMessage
Definition mission.c:18
short g_nCommSpeakerObject
Definition comm.c:19
int g_bInflightComputerActive
Definition nav.c:63
short g_bTargetLockAcquired
Definition viewrect.c:91
short g_aeShipObjective[12]
Definition viewrect.c:166
signed char g_cCurrentKey
Definition viewrect.c:29
ShortRect g_stRightVduBounds
Definition cockpt.c:22
FixedVector g_aShipDestination[10]
Definition viewrect.c:128
Viewport g_2_stLeftwardVduPortBlock
Definition cockpt.c:3830
unsigned char * g_4_pScannerBlipUnderlayPointer
Definition cockpt.c:3787
MissionObjective g_aMissionObjectives[MISSION_OBJECTIVE_COUNT]
Definition viewrect.c:69
short g_nTargetCameraZoom
Definition turret.c:1238
short g_5_nWeaponDisplayOriginXValue
Definition damage.c:269
unsigned char *volatile g_pCockpitExplosionShape
Definition cockpt.c:43
TextContext g_5_stLeftVduStringContextRecord
Definition cockpt.c:3840
signed char g_cViableTargetCount
Definition viewrect.c:197
short g_10_asScannerObjectYTable[11]
Definition cockpt.c:3812
ShortRect g_stTargetBracketBounds
Definition cockpt.c:102
CampaignDate g_1_stElapsedCampaignDate
Definition nav.c:1248
short g_asCockpitLightY[7]
Definition cockpt.c:16
void * g_13_pStartupStellarPacket
Definition cockpt.c:3827
MissionShipRecord g_aMissionShips[MISSION_SHIP_COUNT]
Definition hotspot.c:240
ShortPoint g_aDefaultWeaponDisplayPositions[16]
Definition cockpt.c:28
unsigned char * g_pCommPortraitResource
Definition comm.c:16
short g_nSelectedGunType
Definition viewrect.c:83
short g_bTargetLockDisplayEnabled
Definition cockpt.c:29
short g_aasShipArmor[10][4]
Definition viewrect.c:135
int g_bForceDamageDisplayRedraw
Definition cockpt.c:110
signed char g_cLastPilotHandFrame
Definition cockpt.c:34
TextContext g_16_stCockpitTextSettingsRecord
Definition message.c:238
short g_15_nStoredScreenViewCentreX
Definition eventmgr.c:2501
signed char g_cHazardBaseTravelTime
Definition cockpt.c:26
char * g_pszAutopilotWaitReason
Definition cockpt.c:45
short g_nScreenWidth
Definition eventmgr.c:2430
short g_asShipMissionType[12]
Definition viewrect.c:163
const char * g_pszMissileLocked
Definition cockpt.c:95
TextContext g_3_stDefaultStringContext
Definition message.c:239
short g_1_nTargetLeadingIndicatorY
Definition cockpt.c:3786
short g_asShipSide[12]
Definition viewrect.c:139
char * g_pszDisplayedHudMessage
Definition cockpt.c:33
signed char g_acObjectType[SPACE_OBJECT_COUNT]
Definition viewrect.c:101
short g_bEjectionSequencePending
Definition orders.c:8
unsigned char * g_36_apTextGlyphs[4]
Definition cockpt.c:3835
short g_nCurrentNavPoint
Definition viewrect.c:53
int g_nAimCameraMode
Definition turret.c:1279
short g_49_nViewportOffsetY
Definition eventmgr.c:2547
short g_asObjectScreenY[SPACE_OBJECT_COUNT]
Definition viewrect.c:96
short g_nCannedSceneMode
Definition taperec.c:14
short g_1_nGunShowEnergyPercent
Definition turret.c:1278
short g_9_nScannerCursorYValue
Definition cockpt.c:3809
short g_bForceCriticalDamageWarning
Definition cockpt.c:47
signed char g_12_abCockpitLightGoalTable[7]
Definition cockpt.c:3815
short g_nTargetLockCountdown
Definition viewrect.c:87
const char * g_apszComponentNames[9]
Definition damage.c:13
short g_asObjectViewFrame[SPACE_OBJECT_COUNT]
Definition viewrect.c:94
short g_nHazardPitchRange
Definition cockpt.c:27
int g_aiForwardScannerGridRows[78]
Definition cockpt.c:55
short y
Definition game.h:301
short previousRight
Definition game.h:302
TextContext * context
Definition game.h:299
TextContext * context
Definition game.h:321
signed char flashCount
Definition game.h:326
short colour
Definition game.h:324
short drawColour
Definition game.h:325
short x
Definition game.h:322
short y
Definition game.h:323
const char * text
Definition game.h:327
const char * displayName
Definition game_data.h:1420
signed char flags
Definition game_data.h:1419
signed char index
Definition game_data.h:1417
signed char state
Definition game_data.h:1380
void * scratchBuffer
Definition game.h:174
volatile short y
Definition game.h:166
short frame
Definition game.h:173
volatile short x
Definition game.h:165
short maximumVelocity
Definition game_data.h:377
short objectClass
Definition game_data.h:367
char displayName[20]
Definition game_data.h:366
signed char weaponType
Definition game_data.h:418
signed char disabled
Definition game_data.h:417
short top
Definition game_data.h:480
short left
Definition game_data.h:479
short right
Definition game_data.h:481
short bottom
Definition game_data.h:482
unsigned char colour
Definition game.h:288
short cursorY
Definition game.h:286
unsigned char * font
Definition game.h:287
unsigned char backgroundColour
Definition game.h:289
short cursorX
Definition game.h:285
Viewport * viewport
Definition game.h:284
short right
Definition game.h:154
short bottom
Definition game.h:155
short left
Definition game.h:152
short top
Definition game.h:153