Wing Commander
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
nav.c
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup flight
4 * @brief Navigation map, objective labels and the in-flight computer.
5 *
6 * Address range 40d090-40e88f.
7 */
8#include "wc1.h"
9#include <dos.h>
10#include <float.h>
11
12short nNavMapCoordinateScaling = 0; /* 0x00468660 */
13short nNavMapScale = 1; /* 0x00468664 */
14/* 0x00468668 */
24 { 2, 3, &cRedColour, &cRedColour,
26 { 0, 0, 0, 0, 0 },
27 { 0, 0, 0, 0, 0 },
28 { 0, 0, 0, 0, 0 },
29 { 0, 0, 0, 0, 0 },
30 { 0, 0, 0, 0, 0 }
31};
32static struct Shape *pNavMapShape = 0; /* 0x00468708 */
33static short nNavMapLabelCount = 0; /* 0x0046870c */
34static short nNavMapReservedAreaCount = 0; /* 0x00468710 */
35static char szCampaignSector[16] = "Vega XR-231.3"; /* 0x00468718 */
36static
37/* 0x00468728 */
39 "Patrol",
40 "Escort",
41 "Strike",
42 "Defend",
43 "Wingman",
44 "Flee",
45 "Goto Warp",
46 "err",
47 "err",
48 "Rendezvous",
49 "err"
50};
51int bInflightComputerActive = 0; /* 0x00468754 */
52
53/* 0x00475e80 */
55/* 0x00475f48 */
57
58short nNavMapCenterPositionY; /* 0x005a817c */
60short nCurrentActiveInputDevice; /* 0x005a819c */
61int nJoystickVertDeadZoneValue; /* 0x005a81a0 */
62int nJoystickHorizontalDeadZone; /* 0x005a81a4 */
63int nJoystickUpScale; /* 0x005a81a8 */
64int nCurrentJoystickLeftScale; /* 0x005a81ac */
65int nStickMaxX; /* 0x005a81b0 */
66int nStickMaxY; /* 0x005a81b4 */
67int nStickMinimumPositionX; /* 0x005a81b8 */
68int nStickMinimumPositionY; /* 0x005a81bc */
69int nCurrentJoystickRawCoordX; /* 0x005a81c0 */
70int nCurrentJoystickRawCoordY; /* 0x005a81c4 */
71int nJoystickVerticalRange; /* 0x005a81c8 */
72int nJoystickHorizontalRangeValue; /* 0x005a81cc */
73int nJoystickRightScale; /* 0x005a81d0 */
74int nJoystickDownScaleValue; /* 0x005a81d4 */
75int nJoystickCentreY; /* 0x005a81d8 */
76int nJoystickCentreX; /* 0x005a81dc */
77int nCurrentJoystickFailureValue; /* 0x005a81e0 */
79
80/* Function start: 0x40D090 */
81short NavMapPointInsideReservedArea(short area, short x, short y)
82{
83 return aNavMapExclusionRects[area].left <= x &&
84 x <= aNavMapExclusionRects[area].right &&
85 aNavMapExclusionRects[area].top <= y &&
87}
88
89/* Function start: 0x40D0E0 */
90short NavMapLabelFits(short x, short y, short width, short height)
91{
92 return x > 0 && y > 0 && x + width < 150 && y + height < 135;
93}
94
95/* Function start: 0x40D120 */
96short NavMapLabelPositionAvailable(short x, short y,
97 short width, short height)
98{
99 short available;
100 short area;
101 short checkX;
102 short checkY;
103
104 available = NavMapLabelFits(x, y, width, height);
105 if (available == 1) {
106 area = 0;
107 while (area < nNavMapReservedAreaCount &&
108 available != 0) {
109 checkX = x;
110 while (checkX < x + width && available != 0) {
111 checkY = y;
112 while (checkY < y + height && available != 0) {
113 available = (short)((unsigned short)
114 NavMapPointInsideReservedArea(area, checkX, checkY) == 0);
115 checkY++;
116 }
117 checkX++;
118 }
119 area++;
120 }
121 }
122 return available;
123}
124
125/* Function start: 0x40D1D0 */
130
131/* Function start: 0x40D1E0 */
132void ReserveNavMapArea(short x, short y, short width, short height)
133{
134 short area;
135
137 aNavMapExclusionRects[area].left = x;
138 aNavMapExclusionRects[area].top = y;
139 aNavMapExclusionRects[area].right = (short)(x + width);
140 aNavMapExclusionRects[area].bottom = (short)(y + height);
141 area++;
143}
144
145/* Function start: 0x40D240 */
147{
149}
150
151/* Function start: 0x40D250 */
152short TryPlaceNavMapLabel(short x, short y, short width, short force)
153{
154 short placed;
155
156 placed = 0;
157 if (NavMapLabelPositionAvailable(x, y, width, 6) != 0 ||
158 (force != 0 && NavMapLabelFits(x, y, width, 6) != 0)) {
161 placed = 1;
162 }
163 return placed;
164}
165
166/* Function start: 0x40D2C0 */
167void PlaceNavMapLabel(short x, short y, unsigned short colour,
168 const char *text)
169{
170 short width;
171 short offset;
172
173 width = (short)(strlen(text) * 4 + 2);
176 offset = -1;
177 do {
178 offset++;
179 if (TryPlaceNavMapLabel((short)(x + offset + 4), y,
180 width, 0) != 0)
181 break;
182 if (TryPlaceNavMapLabel((short)(x - width / 2),
183 (short)(y + offset + 5),
184 width, offset == 12) != 0)
185 break;
186 if (TryPlaceNavMapLabel((short)(x - offset - width - 3), y,
187 width, offset == 12) != 0)
188 break;
189 if (TryPlaceNavMapLabel(x, (short)(y + offset + 5),
190 width, offset == 12) != 0)
191 break;
192 if (TryPlaceNavMapLabel((short)(x - width / 2),
193 (short)(y - offset - 9),
194 width, offset == 12) != 0)
195 break;
196 } while (offset != 12);
200 width, 6);
202}
203
204/* Function start: 0x40D410 */
205void AddUniqueObjectiveNavLabel(short x, short y,
206 unsigned short colour, const char *text,
207 short objective, short missionShip)
208{
209 short previous;
210
211 if (missionShip == -1) {
212 PlaceNavMapLabel(x, y, colour, text);
213 return;
214 }
215 for (previous = 0; previous < objective; previous++) {
216 if (aMissionObjectivesArray[previous].index == missionShip)
217 break;
218 }
219 if (previous < objective)
220 return;
221 else
222 PlaceNavMapLabel(x, y, colour, text);
223}
224
225/* Shared display and input declarations, repeated here: their placement
226 * reproduces this unit's compiler context. */
227void DrawFormattedText(const char *format, ...);
228void DrawViewportEllipse(Viewport *viewport, short x, short y,
229 short verticalRadius, short horizontalRadius,
230 short colour);
231void DrawViewportEllipseShadow(Viewport *viewport, short x, short y,
232 short verticalRadius,
233 short horizontalRadius,
234 short colour);
235void DrawViewportBorder(Viewport *viewport, short left, short top,
236 short right, short bottom,
237 short colour);
238void DrawViewportLine(Viewport *viewport, short x1, short y1,
239 short x2, short y2, short colour);
240short achieved(short objective);
241short hidden_objective(short objective);
242short visited(short objective);
243const char *objective_name(short objective);
244void DrawNavTextLine(unsigned char alignment, unsigned short colour,
245 const char *format, ...);
246void ClearViewport(Viewport *viewport, short colour);
247void CopyViewportContents(Viewport *source, Viewport *destination);
248unsigned short __stdcall AllocateViewport(Viewport *viewport,
249 short clearColour,
250 short flags);
251void *FetchDiskPacketRetrying(short logicalFile, short section,
252 short flags);
253void ReportOutOfMemoryAndExit(const char *resource);
254short LocateMobileObjective(short objective);
255void __stdcall free_viewport(Viewport *viewport);
256void ReleasePacketHandle(void *handle);
257unsigned int ReleaseTextFont(short fontIndex);
258int set_new_objective(short pathIndex);
259void __stdcall WarpMouseTo(short x, short y);
260void __stdcall SetEventManagerPump(void (*pump)(void));
261void __stdcall SetFrameTimerAndWait(short period);
262void DrawViewportPixel(Viewport *viewport, short x, short y,
263 short colour);
265unsigned int force_view(int view, short obj);
266void __stdcall SetViewportRect(Viewport *viewport, unsigned short left,
267 unsigned short top, unsigned short right,
268 unsigned short bottom);
269
270/* Function start: 0x40D490 */
271short IsPointInNavMapLabel(short labelIndex, short x, short y)
272{
273 short left;
274
275 left = aNavMapLabels[labelIndex].x;
276 if (left <= x &&
277 (unsigned int)x <=
278 (unsigned int)(left +
279 strlen(aNavMapLabels[
280 labelIndex].text) * 4) &&
281 aNavMapLabels[labelIndex].y <= y &&
282 y <= aNavMapLabels[labelIndex].y + 6)
283 return 1;
284 return 0;
285}
286
287/* Function start: 0x40D500 */
288/* Nothing in the shipped executable calls this. Returns the index of the
289 last-placed nav map label containing the point, or -1. */
290short FindNavMapLabelAtPoint(short x, short y)
291{
292 short label;
293
294 label = nNavMapLabelCount;
295 while (--label > -1) {
296 if (IsPointInNavMapLabel(label, x, y))
297 break;
298 }
299 return label;
300}
301
302/* Function start: 0x40D540 */
304{
305 short label;
306
307 for (label = 0; label < (short)nNavMapLabelCount; label++) {
308 DrawFormattedText("%X%Y%F%s",
309 aNavMapLabels[label].x,
310 aNavMapLabels[label].y,
311 aNavMapLabels[label].colour,
312 aNavMapLabels[label].text);
313 }
314}
315
316/* Function start: 0x40D5A0 */
317void DrawNavRectangleMarker(short x, short y, short size, short shadow,
318 unsigned short colour, short reserve)
319{
320 if (shadow == 0)
322 x, y, size, (short)((size * 7) / 8),
323 (short)colour);
324 else
327 x, y, size, (short)((size * 7) / 8), (short)colour);
328 if (reserve != 0 && size < 5)
329 ReserveNavMapArea((short)(x - size), (short)(y - size),
330 (short)(size * 2 + 1),
331 (short)(size * 2 + 1));
332}
333
334/* Viewport bounds used by SetScreenClipRect. */
335void SetRectBounds(Viewport *viewport, unsigned short left,
336 unsigned short top, unsigned short right,
337 unsigned short bottom);
338
339/* Function start: 0x40D640 */
340void DrawNavSquareOutline(Viewport *viewport, short x, short y,
341 unsigned short size, signed char colour)
342{
343 DrawViewportBorder(viewport, (short)(x - size), (short)(y - size),
344 (short)(x + size), (short)(y + size),
345 (short)colour);
346}
347
348/* Map-vector addition used by hazard markers. */
349void AddFixedVectors(const FixedVector *left, const FixedVector *right,
350 FixedVector *sum);
351
352/* Function start: 0x40D680 */
353void DrawNavSquareMarker(short x, short y, short size, short shadow,
354 short colour, short reserve)
355{
356 if (size == 0) {
358 x, y, colour);
360 (short)(x + 1), y, colour);
362 x, (short)(y + 1), colour);
364 (short)(x + 1),
365 (short)(y + 1), colour);
366 } else {
368 x, y, size,
369 (signed char)colour);
370 }
371 if (reserve != 0 && size < 5)
372 ReserveNavMapArea((short)(x - size), (short)(y - size),
373 (short)(size * 2 + 1),
374 (short)(size * 2 + 1));
375 (void)shadow;
376}
377
378/* Function start: 0x40D740 */
379void DrawNavTriangleOutline(Viewport *viewport, short x, short y,
380 short size, signed char colour)
381{
382 DrawViewportLine(viewport, x, (short)(y - size),
383 (short)(x + size), (short)(y + size), colour);
384 DrawViewportLine(viewport, (short)(x + size), (short)(y + size),
385 (short)(x - size), (short)(y + size), colour);
386 DrawViewportLine(viewport, (short)(x - size), (short)(y + size),
387 x, (short)(y - size), colour);
388}
389
390/* Function start: 0x40D7D0 */
391void DrawNavTriangleMarker(short x, short y, short size, short shadow,
392 unsigned short colour, short reserve)
393{
395 x, y, size,
396 (signed char)colour);
397 if (reserve != 0 && size < 5)
398 ReserveNavMapArea((short)(x - size), (short)(y - size),
399 (short)(size * 2 + 1),
400 (short)(size * 2 + 1));
401 (void)shadow;
402}
403
404/* Map geometry, text, sprites, and event input. */
405void __stdcall SetMouseCursorShape(struct Shape *shape, short frame);
406short __stdcall PollInputEvent(InputEventState *event, short filter);
407void ScaleNavMapCoordinates(short *x, short *y,
408 short mapX, short mapY);
409void ScaleNavMapMarkerSize(short *size);
410void nav_getxy(short *x, short *y, int worldX, int worldZ);
411void DrawSpriteDefault(Viewport *viewport, short x, short y,
412 struct Shape *shape, short frame);
413unsigned int InitializeTextContextFromFont(TextContext *context,
414 short fontIndex,
415 unsigned char colour,
416 signed char background);
417void __stdcall SetTextContext(TextContext *context);
418short mobile_objective(short objective);
419
420/* Function start: 0x40D830 */
421void DrawNavCrossMarker(short x, short y, short size, short shadow,
422 unsigned short colour, short reserve)
423{
425 (short)(x - size), (short)(y - size),
426 (short)(x + size), (short)(y + size),
427 (short)colour);
429 (short)(x - size), (short)(y + size),
430 (short)(x + size), (short)(y - size),
431 (short)colour);
432 if (reserve != 0 && size < 5)
433 ReserveNavMapArea((short)(x - size), (short)(y - size),
434 (short)(size * 2 + 1),
435 (short)(size * 2 + 1));
436 (void)shadow;
437}
438
439/* Function start: 0x40D8C0 */
440void SetScreenClipRect(unsigned short a, unsigned short b,
441 unsigned short c, unsigned short d)
442{
443 SetRectBounds(&stSceneBuffer, a, b, c, d);
444}
445
446/* Function start: 0x40D8F0 */
448 short size, unsigned short markerColour,
449 unsigned short textColour, const char *text)
450{
451 short x;
452 short y;
453
454 AddFixedVectors(&navPosition, &offset, &navPosition);
456 nav_getxy(&x, &y, navPosition.x, navPosition.z);
457 DrawNavRectangleMarker(x, y, size, 0, markerColour, 1);
458 PlaceNavMapLabel(x, y, textColour, text);
459}
460
461/* Function start: 0x40D980 */
462void DrawNavPlayerMarker(short colour, short reserve)
463{
464 short x;
465 short y;
466
467 nav_getxy(&x, &y, aShipPositionsArray[0].x,
472 x, y, colour);
473 DrawNavSquareMarker(x, y, 0, 0, colour, reserve);
474}
475
476/* Function start: 0x40DA00 */
477void BuildMap(short showPlayer)
478{
479 MissionNavPoint *navPoint;
480 MissionShipRecord *missionShip;
481 const NavMapObjectiveStyle *style;
482 unsigned short labelColour;
483 short missionShipIndex;
484 short objectiveIndex;
485 short slot;
486 short x;
487 short y;
488
489 SetScreenClipRect(1, 1, 153, 138);
491 SetScreenClipRect(2, 2, 152, 137);
495 2, cPrimaryTextColour, -1);
498 navPoint = aMissionNavPoints;
501 SetScale();
502
503 for (; navPoint->type != 0;
504 navPoint++) {
505 for (slot = 0; slot < 10; slot++) {
506 missionShipIndex = navPoint->missionShips[slot];
507 if (missionShipIndex != -1) {
508 missionShip = &aMissionShips[missionShipIndex];
509 switch (missionShip->type) {
512 missionShip->position,
513 missionShip->speed,
515 "Asteroids");
516 break;
519 missionShip->position,
520 missionShip->speed,
522 "Mines");
523 break;
524 }
525 }
526 }
527 }
528
529 for (objectiveIndex = 0;
530 objectiveIndex < (short)cMissionObjectiveCountValue;
531 objectiveIndex++) {
532 if (mobile_objective(objectiveIndex) == 0 ||
534 (signed char)aMissionObjectivesArray[objectiveIndex].index]
535 .state == 0 &&
536 achieved(objectiveIndex) == 0)) {
538 aMissionObjectivesArray[objectiveIndex].mapX,
539 aMissionObjectivesArray[objectiveIndex].mapY);
540 if (hidden_objective(objectiveIndex) == 0) {
541 style = &aNavMapObjectiveStyles[
542 aMissionObjectivesArray[objectiveIndex].type];
543 if (visited(objectiveIndex) == 0)
545 *style->unvisitedColour);
546 switch (style->markerType) {
547 case 1:
548 DrawNavSquareMarker(x, y, style->markerSize, 0,
549 *style->markerColour, 1);
550 break;
551 case 2:
552 DrawNavRectangleMarker(x, y, style->markerSize, 0,
553 *style->markerColour, 1);
554 break;
555 case 3:
556 DrawNavTriangleMarker(x, y, style->markerSize, 0,
557 *style->markerColour, 1);
558 break;
559 case 4:
560 DrawNavCrossMarker(x, y, style->markerSize, 0,
561 *style->markerColour, 1);
562 break;
563 }
564 if (cCurrentObjective == objectiveIndex)
565 labelColour = cYellowColour;
566 else
567 labelColour = *style->labelColour;
568 awMapNavObjectiveLabelIndex[objectiveIndex] =
571 x, y, labelColour, objective_name(objectiveIndex),
572 objectiveIndex,
573 (short)aMissionObjectivesArray[objectiveIndex].index);
574 }
575 }
576 }
577 if (showPlayer != 0) {
579 nav_getxy(&x, &y, aShipPositionsArray[0].x,
582 x, y, cLightGreyColour,
584 }
586 SetScreenClipRect(0, 0, 259, 155);
587}
588
589/* Function start: 0x40DDA0 */
590void UpdateInflightNavText(short showColon)
591{
592 char time[12];
593 short colonVisible;
594
596 sprintf(time, "%02d",
597 (int)((signed char *)pElapsedCampaignDatePtr)[0]);
599 "%X%YStandard time %s",
600 (int)(short)(stCurrentNavMapTxtCtx.viewport->left + 150),
601 (int)(short)(stCurrentNavMapTxtCtx.viewport->top + 140),
602 time);
603 /* Keep the flag while reusing its parameter for the saved cursor. */
604 colonVisible = showColon;
605 showColon = stCurrentNavMapTxtCtx.cursorX;
606 if (colonVisible == 0) {
608 } else {
610 (short)(stCurrentNavMapTxtCtx.cursorX + 4);
611 }
612 sprintf(time, "%02d ",
613 (int)((signed char *)pElapsedCampaignDatePtr)[1]);
614 DrawFormattedText(time);
615 stCurrentNavMapTxtCtx.cursorX = showColon;
616 if (colonVisible != 0)
618}
619
620/* Function start: 0x40DE70 */
621void FormatNavCoordinates(unsigned char *out)
622{
623 unsigned char tmp[4];
624
626 out[1] = tmp[2];
627 out[0] = tmp[3];
628}
629
630/* Function start: 0x40DEA0 */
631void DrawSelectedNavLegendEntry(const char *text, short navPoint)
632{
633 if ((short)cCurrentNavPtIdx == navPoint) {
634 DrawNavTextLine(0, (unsigned short)cYellowColour, text);
635 DrawNavTextLine(0, (unsigned short)cYellowColour,
636 "\n");
637 }
638}
639
640/* Function start: 0x40DEE0 */
642{
643 short objective;
644
645 for (objective = 0; objective < (short)cMissionObjectiveCountValue; objective++) {
646 if (visited(objective) == 0 && hidden_objective(objective) == 0)
647 break;
648 }
649 SetTextCursor((unsigned short)stSceneBuffer.left, 120);
650 DrawSelectedNavLegendEntry("MISSION FLIGHT PATH",
651 objective);
653 "HOME BASE",
654 (short)((short)cMissionObjectiveCountValue - 1));
655}
656
657/* Function start: 0x40DF50 */
658char *nav_note(short objective)
659{
660 char *note;
661
662 note = aMissionObjectivesArray[objective].name;
663 if (*note == '?')
664 note++;
665 return note;
666}
667
668/* Function start: 0x40DF70 */
669void DrawNavLocationReadout(const char *title, short showFlightData)
670{
671 enum ShipMissionType playerMissionType;
672
674 SetScreenClipRect(155, 2, 259, 155);
684 "\n");
686 "%s\n\n", title);
688 "Sector: %s\n",
691 "System: %s\n\n",
694 "* %s *\n",
696 playerMissionType = aMissionShips[
699 "* %s *\n",
701 playerMissionType]);
703 "\nNotes\n");
705 "%s\n",
707 if (showFlightData != 0)
709 BuildMap(showFlightData);
710 if (showFlightData != 0) {
711 SetScreenClipRect(0, 0, 259, 155);
714 "%X%Y Location: %d.%d.%d",
715 8, 142,
719 }
721 DIBslam();
722 DIBslamReal();
723}
724
725/* Function start: 0x40E190 */
727{
728 short objective;
729
732 SetScreenClipRect(0, 0, 259, 155);
734 (short)cBlackColour, 0) == 0)
735 ReportOutOfMemoryAndExit("VSCREEN");
736 for (objective = 0; objective < (short)cMissionObjectiveCountValue; objective++) {
737 LocateMobileObjective(objective);
738 }
739}
740
741/* Function start: 0x40E210 */
743{
744 Viewport savedViewport;
745
746 savedViewport = stSceneBuffer;
749 stScreenView.top = 4;
750 DrawNavLocationReadout("Briefing Nav Map", 0);
755 stSceneBuffer = savedViewport;
757}
758
759/* Function start: 0x40E2B0 */
760short SelectNavObjectiveAtPoint(short mouseX, short mouseY)
761{
762 short mapY;
763 short oldNavPoint;
764 short pathIndex;
765 short mapX;
766 short selected;
767
768 selected = 0;
769 oldNavPoint = cCurrentNavPtIdx;
770 mouseX -= 30;
771 mouseY -= 22;
772 for (pathIndex = 0; abFlightPathList[pathIndex] != -1; pathIndex++) {
773 if (hidden_objective(abFlightPathList[pathIndex]))
774 continue;
776 &mapX, &mapY,
779 if ((short)(abs(mouseX - mapX) + abs(mouseY - mapY)) < 6 ||
781 mouseX, mouseY)) {
782 selected = 1;
783 set_new_objective(pathIndex);
784 if (pathIndex == oldNavPoint)
785 return selected;
786 }
787 }
788 return selected;
789}
790
791/* Function start: 0x40E3C0 */
793{
794 short x;
795 short y;
796 signed char objective;
797
798 objective = abFlightPathList[
801 &x, &y,
802 aMissionObjectivesArray[objective].mapX,
803 aMissionObjectivesArray[objective].mapY);
804 x = (short)(x + 30);
805 y = (short)(y + 22);
807 WarpMouseTo(x, y);
809}
810
811/* Function start: 0x40E430 */
813{
814 SetRectBounds(&stScreenView, 30, 22, 289, 177);
816 DrawNavLocationReadout("ConFed Nav Scan", 1);
818 SetRectBounds(&stScreenView, 0, 0, 319, 199);
819}
820
821/* Function start: 0x40E480 */
823{
824 short done;
825 short hasObjectives;
826 short savedInputMode;
827 short objective;
828 short displayedNavPoint;
829 short eventType;
830 /* Original storage is four bytes; the saved value uses its low word. */
831 int savedNavPoint;
832 int frame;
833 struct Shape *background;
834 InputEventState event;
835 Viewport pointerViewport;
836 MouseCursorState savedInputState;
837
838 *(short *)&savedNavPoint = (short)cCurrentNavPtIdx;
839 done = 0;
840 hasObjectives = 0;
841 displayedNavPoint = *(short *)&savedNavPoint;
843 savedInputState = stMouseCursorState;
844
845 if (message_showing() != 0)
846 EndCommMenu();
848 cScreenViewMode = -1;
849 background = FetchDiskPacketRetrying(8, 1, 0);
851 DrawSpriteDefault(&stScreenView, 0, 0, background, 0);
852 ReleasePacketHandle(background);
853
854 objective = 0;
857 for (; objective < (short)cMissionObjectiveCountValue; objective++) {
858 if (hidden_objective(objective) == 0)
859 hasObjectives = 1;
860 }
861
862 if (hasObjectives == 0) {
867 } else {
868 pointerViewport = stScreenView;
869 SetRectBounds(&pointerViewport, 32, 24, 182, 159);
870 stMouseCursorState.viewport = &pointerViewport;
871 savedInputMode = (short)(signed char)bInputModeState;
872 bInputModeState = 1;
878
879 do {
880 if (displayedNavPoint !=
881 (short)cCurrentNavPtIdx) {
882 displayedNavPoint =
883 (short)cCurrentNavPtIdx;
884 PlaySfxWaveFileByNumber(0x19, -1, 0);
886 }
887 SetRectBounds(&stScreenView, 32, 24, 289, 177);
890 (unsigned char *)pElapsedCampaignDatePtr);
892 frame = (int)nTickCount60Hz / 15;
894 : cDarkGreyColour, 0);
896 UpdateInflightNavText((short)((frame / 4) % 2));
897 SetRectBounds(&stScreenView, 0, 0, 319, 199);
898
899 eventType = PollInputEvent(&event, 0xff);
900 switch (eventType) {
901 case 2:
902 case 10:
903 done = 1;
904 break;
905 case 3:
906 case 5:
907 if ((short)event.value == 0x1c ||
908 (short)event.value == 0x39) {
909 done = 1;
910 } else if ((short)event.value == 0x31) {
913 } else {
915 }
916 break;
917 }
920 DIBslam();
921 DIBslamReal();
922 } while (done == 0 && bEscapePressedFlag == 0);
923
924 if (bEscapePressedFlag != 0) {
927 *(signed char *)&savedNavPoint;
929 }
934 bInputModeState = (unsigned char)savedInputMode;
935 }
936
939 PlaySfxWaveFileByNumber(0x19, -1, 0);
940 stMouseCursorState = savedInputState;
941 WarpMouseTo(savedInputState.x, savedInputState.y);
942 if (bCockpitlessView == 0) {
943 force_view(0, 0);
944 } else {
947 (unsigned short)(nScreenWidth - 1),
948 (unsigned short)(nScreenHeight - 1));
950 force_view(0, 0);
953 SetViewportRect(&stSpaceBufferViewport, 0, 0, 319, 199);
955 }
957}
void(__cdecl *pIxFree)(void *)
unsigned char bEscapePressedFlag
Definition mathfp.c:24
InputDeviceSample aInputDevSamples[2]
Definition nav.c:78
unsigned char cYellowColour
Definition init.c:15
unsigned char cLightGreyColour
Definition init.c:22
MissionHeaderDisk stCurrentMissionHeader
Definition mission.c:57
unsigned char cRedColour
Definition init.c:16
int nJoystickCentreY
Definition nav.c:75
short nNavMapCoordinateScaling
Definition nav.c:12
TextContext stDefaultTxtContext
Definition targ.c:14
unsigned char cBlackColour
Definition init.c:12
CampaignDate * pElapsedCampaignDatePtr
Definition mission.c:59
signed char cMissionObjectiveCountValue
Definition game.c:554
int nCurrentJoystickFailureValue
Definition nav.c:77
int nJoystickCentreX
Definition nav.c:76
unsigned char abSeriesAuxData[0x28]
Definition mission.c:55
int nStickMaxX
Definition nav.c:65
unsigned char cViewportClearColour
Definition init.c:13
int bInflightComputerActive
Definition nav.c:51
signed char abFlightPathList[MISSION_OBJECTIVE_COUNT]
Definition smart.c:20
int nJoystickDownScaleValue
Definition nav.c:74
int bCockpitlessView
Definition main.c:39
int nStickMinimumPositionX
Definition nav.c:67
unsigned char bInputModeState
Definition eventmgr.c:21
TextContext stCurrentNavMapTxtCtx
Definition nearheap.c:22
int nJoystickRightScale
Definition nav.c:73
MissionNavPoint aMissionNavPoints[MISSION_NAV_POINT_COUNT]
Definition game.c:199
int nCurrentJoystickLeftScale
Definition nav.c:64
TextContext stMapNavigationLabelTextContext
Definition nav.c:59
MouseCursorState stMouseCursorState
Definition strdos.c:19
Viewport stSceneBuffer
Definition select.c:17
int nJoystickHorizontalRangeValue
Definition nav.c:72
int nJoystickHorizontalDeadZone
Definition nav.c:62
unsigned short awMapNavObjectiveLabelIndex[16]
Definition nearheap.c:18
unsigned char cMagentaColour
Definition init.c:23
int nStickMinimumPositionY
Definition nav.c:68
unsigned char cAsteroidColour
Definition init.c:26
char szDefaultTxtBuf[0xc8]
Definition timer.c:18
unsigned char cDefaultTextColour
Definition init.c:24
short nScreenWidth
Definition data.c:34
Viewport stScreenView
Definition launch.c:50
int nCurrentJoystickRawCoordX
Definition nav.c:69
Viewport stSpaceBufferViewport
Definition timer.c:13
int nTickCount60Hz
Definition mathfp.c:23
unsigned char cPrimaryTextColour
Definition init.c:18
signed char cCurrentObjective
Definition game.c:37
CampaignState stCampaignState
Definition dib.c:107
int nJoystickUpScale
Definition nav.c:63
MissionObjective aMissionObjectivesArray[MISSION_OBJECTIVE_COUNT]
Definition screen.c:24
short nCurrentActiveInputDevice
Definition nav.c:60
signed char cScreenViewMode
Definition strdos.c:13
int nJoystickVertDeadZoneValue
Definition nav.c:61
short nMenuInputRepeatDelay
Definition objdata.c:597
int nCurrentJoystickRawCoordY
Definition nav.c:70
short nNavMapCenterPositionY
Definition nav.c:58
MissionShipRecord aMissionShips[MISSION_SHIP_STORAGE_COUNT]
Definition game.c:230
short nScreenHeight
Definition data.c:37
FixedVector aShipPositionsArray[SPACE_OBJECT_COUNT]
Definition game.c:556
short nNavMapScale
Definition nav.c:13
signed char cCurrentNavPtIdx
Definition dib.c:96
int nStickMaxY
Definition nav.c:66
unsigned char cDarkGreyColour
Definition init.c:21
int nJoystickVerticalRange
Definition nav.c:71
unsigned char abMissionAuxData[0x28]
Definition objdata.c:598
static char szCampaignSector[16]
Definition nav.c:35
static ShortRect aNavMapExclusionRects[21]
Definition nav.c:56
static char * apszShipMissionTypeNames[11]
Definition nav.c:38
static NavMapLabel aNavMapLabels[20]
Definition nav.c:54
static NavMapObjectiveStyle aNavMapObjectiveStyles[10]
Definition nav.c:15
static short nNavMapReservedAreaCount
Definition nav.c:34
static struct Shape * pNavMapShape
Definition nav.c:32
short FindNavMapLabelAtPoint(short x, short y)
Definition nav.c:290
static short nNavMapLabelCount
Definition nav.c:33
PilotRecord * currentPilot
Definition wcdata.h:710
unsigned int value
Definition wc1base.h:140
short playerMissionShip
Definition wcdata.h:565
FixedVector position
Definition wcdata.h:859
short missionShips[10]
Definition wcdata.h:863
signed char type
Definition wcdata.h:858
enum ShipMissionType missionType
Definition wcdata.h:884
enum ObjectType type
Definition wcdata.h:880
FixedVector position
Definition wcdata.h:886
Viewport * viewport
Definition wc1base.h:110
struct Shape * shape
Definition wc1base.h:107
short colour
Definition wcdata.h:529
short x
Definition wcdata.h:527
short y
Definition wcdata.h:528
const char * text
Definition wcdata.h:530
unsigned char * labelColour
Definition wcdata.h:543
unsigned char * unvisitedColour
Definition wcdata.h:541
unsigned char * markerColour
Definition wcdata.h:542
char callsign[14]
Definition wcdata.h:598
short top
Definition wcdata.h:441
short left
Definition wcdata.h:440
short right
Definition wcdata.h:442
short bottom
Definition wcdata.h:443
short cursorY
Definition wc1base.h:238
char * text
Definition wc1base.h:242
short cursorX
Definition wc1base.h:237
Viewport * viewport
Definition wc1base.h:236
unsigned char alignment
Definition wc1base.h:244
short left
Definition wc1base.h:76
short top
Definition wc1base.h:77
Umbrella header for the game core.
void LeaveAllocationScope(void)
Definition eventmgr.c:556
void DrawViewportLine(Viewport *viewport, short x1, short y1, short x2, short y2, short colour)
Definition gr.c:995
void DrawViewportEllipseShadow(Viewport *viewport, short x, short y, short verticalRadius, short horizontalRadius, short colour)
Definition gr.c:1099
void SetRectBounds(Viewport *viewport, unsigned short left, unsigned short top, unsigned short right, unsigned short bottom)
Definition cockpt.c:1762
void PollJoystickButtonEvents(void)
Definition input.c:76
void DIBslam(void)
Definition dib.c:513
void MoveMenuPointerFromKeyboard(InputEventState *event)
Definition disk.c:551
unsigned int InitializeTextContextFromFont(TextContext *context, short fontIndex, unsigned char colour, signed char background)
Definition disk.c:192
short __stdcall PollInputEvent(InputEventState *event, short filter)
Definition eventmgr.c:336
short LocateMobileObjective(short objective)
Definition cockpt.c:1204
unsigned short __stdcall AllocateViewport(Viewport *viewport, short clearColour, short flags)
Definition view.c:758
void DrawNavHazardMarker(FixedVector navPosition, FixedVector offset, short size, unsigned short markerColour, unsigned short textColour, const char *text)
Definition nav.c:447
unsigned int force_view(int view, short obj)
Definition spc.c:464
short NavMapPointInsideReservedArea(short area, short x, short y)
Definition nav.c:81
void DrawNavTextLine(unsigned char alignment, unsigned short colour, const char *format,...)
Definition mission.c:1001
short NavMapLabelPositionAvailable(short x, short y, short width, short height)
Definition nav.c:96
void * FetchDiskPacketRetrying(short logicalFile, short section, short flags)
Definition disk.c:126
void AddFixedVectors(const FixedVector *left, const FixedVector *right, FixedVector *sum)
Definition geom.c:296
void __stdcall SetTextCursor(unsigned short a, unsigned short b)
Definition mathfp.c:145
void EndCommMenu(void)
Definition comm.c:427
void __stdcall SetFrameTimerAndWait(short period)
Definition eventmgr.c:610
void DrawViewportPixel(Viewport *viewport, short x, short y, short colour)
Definition gr.c:976
void DrawNavMapLegend(void)
Definition nav.c:641
short IsPointInNavMapLabel(short label, short x, short y)
Definition nav.c:271
void get_player_input(void)
Definition main.c:575
void DrawNavSquareOutline(Viewport *viewport, short x, short y, unsigned short size, signed char colour)
Definition nav.c:340
void DrawNavTriangleOutline(Viewport *viewport, short x, short y, short size, signed char colour)
Definition nav.c:379
void DrawSpriteDefault(Viewport *viewport, short x, short y, struct Shape *shape, short frame)
Definition gr.c:660
void DIBslamReal(void)
Definition dib.c:519
short WaitForInputKey(void)
Definition disk.c:467
unsigned int GetScreenUpdateFlag(void)
Definition main.c:361
void __stdcall SetEventManagerPump(void(*pump)(void))
Definition strdos.c:126
void __stdcall SetTextContext(TextContext *context)
Definition mathfp.c:152
const char * objective_name(short objective)
Definition cockpt.c:1070
void EnterAllocationScope(void)
Definition eventmgr.c:550
void ReserveNavMapArea(short x, short y, short width, short height)
Definition nav.c:132
void BuildMap(short showPlayer)
Definition nav.c:477
void DrawNavMapLabels(void)
Definition nav.c:303
void ResetMouseCursorFrame(void)
Definition main.c:2175
unsigned int initialize_view_buffer(void)
Definition main.c:371
void DrawNavTriangleMarker(short x, short y, short size, short shadow, unsigned short colour, short reserve)
Definition nav.c:391
short NavMapLabelFits(short x, short y, short width, short height)
Definition nav.c:90
int set_new_objective(short pathIndex)
Definition cockpt.c:1131
short visited(short objective)
Definition cockpt.c:1036
short achieved(short objective)
Definition cockpt.c:1042
void ResetNavMapReservedAreas(void)
Definition nav.c:126
void ResetNavMapLabels(void)
Definition nav.c:146
char * nav_note(short objective)
Definition nav.c:658
void BriefingMap_LoadShapes(void)
Definition nav.c:726
short SelectNavObjectiveAtPoint(short mouseX, short mouseY)
Definition nav.c:760
short TryPlaceNavMapLabel(short x, short y, short width, short force)
Definition nav.c:152
void __stdcall WarpMouseTo(short x, short y)
Definition winmain.c:501
void InflightComputer(void)
Definition nav.c:822
void CentreMouseOnCurrentNavObjective(void)
Definition nav.c:792
void DrawNavLocationReadout(const char *title, short showFlightData)
Definition nav.c:669
void SetScreenClipRect(unsigned short a, unsigned short b, unsigned short c, unsigned short d)
Definition nav.c:440
void __stdcall SplitGameClockTicks(unsigned char *parts)
Definition mono.c:307
void ReportOutOfMemoryAndExit(const char *resource)
Definition main.c:1277
void PlaceNavMapLabel(short x, short y, unsigned short colour, const char *text)
Definition nav.c:167
void DrawNavCrossMarker(short x, short y, short size, short shadow, unsigned short colour, short reserve)
Definition nav.c:421
void DrawNavSquareMarker(short x, short y, short size, short shadow, short colour, short reserve)
Definition nav.c:353
void DrawViewportEllipse(Viewport *viewport, short x, short y, short verticalRadius, short horizontalRadius, short colour)
Definition gr.c:1075
void DrawViewportBorder(Viewport *viewport, short left, short top, short right, short bottom, short colour)
Definition gr.c:1052
void DrawSelectedNavLegendEntry(const char *text, short navPoint)
Definition nav.c:631
void ClearViewport(Viewport *viewport, short colour)
Definition gr.c:963
void AddUniqueObjectiveNavLabel(short x, short y, unsigned short colour, const char *text, short objective, short missionShip)
Definition nav.c:205
void PollMenuInputDevices(void)
Definition input.c:110
void SetScale(void)
Definition mission.c:1081
short hidden_objective(short objective)
Definition cockpt.c:1098
void nav_getxy(short *x, short *y, int worldX, int worldZ)
Definition mission.c:1039
void PlaySfxWaveFileByNumber()
void FormatNavCoordinates(unsigned char *out)
Definition nav.c:621
void ShowConfedNavScan(void)
Definition nav.c:812
void __stdcall free_viewport(Viewport *viewport)
Definition gameflow.c:420
void ReleasePacketHandle(void *handle)
Definition ending.c:50
void ScaleNavMapCoordinates(short *x, short *y, short mapX, short mapY)
Definition mission.c:1030
void BriefingMap_DisplayMap(void)
Definition nav.c:742
short mobile_objective(short objective)
Definition cockpt.c:1433
void __stdcall SetViewportRect(Viewport *viewport, unsigned short left, unsigned short top, unsigned short right, unsigned short bottom)
Definition screens.c:1560
void __stdcall SetMouseCursorShape(struct Shape *shape, short frame)
Definition eventmgr.c:562
void __stdcall EventManagerHook(void(*callback)(void))
Definition strdos.c:120
void ScaleNavMapMarkerSize(short *size)
Definition mission.c:1024
unsigned int ReleaseTextFont(short fontIndex)
Definition disk.c:222
void DrawFormattedText(const char *format,...)
Definition cockpt.c:197
void DrawNavRectangleMarker(short x, short y, short size, short shadow, unsigned short colour, short reserve)
Definition nav.c:317
void CopyViewportContents(Viewport *source, Viewport *destination)
Definition gr.c:945
void UpdateInflightNavText(short showColon)
Definition nav.c:590
short cycle_next_objective(void)
Definition cockpt.c:1159
short message_showing(void)
Definition cockpt.c:776
void DrawNavPlayerMarker(short colour, short reserve)
Definition nav.c:462
ShipMissionType
Definition wcdata.h:120
@ OBJECT_TYPE_MINE_FIELD
Definition wcdata.h:78
@ OBJECT_TYPE_ASTEROID_FIELD
Definition wcdata.h:77