Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1/*
2 * Main application loop and spaceflight frame.
3 *
4 * Retail object 0x465780-0x46979F (link order; see docs/ORDER.md).
5 */
6/* This unit owns storage declared in globals.h as statics. */
7#define MAIN_C
8#include "game.h"
9
10extern unsigned char g_128_abPauseInputState[0x100]; /* 0x005c85d0 */
11
12extern unsigned char g_13_abPreviousPauseKeyStatuses[0x100]; /* 0x005c86e0 */
13
14#pragma function(strcpy)
15/* Function start: 0x465780 */
16void SetPersonnelCursorPosition(int x, int y, short unused1,
17 short unused2)
18{
21}
22
23/* Function start: 0x46579D */
24short LogMemoryUsage(void)
25{
26 /* WC2's system.c declares the canned-scene tape file as a pointer where
27 * it is really the string itself, so the unlink is handed the first four
28 * bytes of "tape.tmp" and always fails. The port cannot dereference a
29 * 32-bit value as a pointer, so it removes the file as intended. */
30 _unlink(*(char *const *)g_szCannedSceneTapeFile);
32 EMShutDown();
33 if (g_bSpeechEnabledFlag != 0)
36 _chdir("..");
38 }
40 if (g_nOriginDevUnlock != 0) {
41 printf("Series %d, Mission %d (%c)\n",
42 (int)g_nCurSeries,
43 (int)g_nCurrentLevel,
44 (int)g_nCurrentLevel + 'A');
45 }
46 if (g_nShowMemoryStatus != 0) {
47 printf(
48 "initial far: %lu. current far: %lu. current near: %u.\n",
51 }
54 if (g_pMemoryAdjustment != 0)
56 return 0;
57}
58
59/* Function start: 0x46589D */
60void AdjustSpaceFramePeriod(short adjustment)
61{
63 MaxShort((short)(g_nSpaceFramePeriod + adjustment), 1),
64 0x13);
65 ShowOnScreenMessage(0, "%d/60th SEC FRAME DURATION.",
67}
68
69/* Function start: 0x4658E9 */
70/* Nothing in the shipped executable calls this. The DOS near-heap check;
71 * the Win32 port always reports a sound heap. */
72short CheckHeap(void)
73{
74 short status;
75
76 status = 1;
77 return status;
78}
79
80/* Function start: 0x465906 */
81/* Nothing in the shipped executable calls this. The DOS Ctrl-Break
82 * handler: returning 1 lets the program continue. */
84{
85 return 1;
86}
87
88/* Function start: 0x46591A */
89void RunGameApplication(short argc, char **argv)
90{
91 short argumentCount;
92 int memoryBytes;
93 short selectionMade;
94
95 selectionMade = 0;
96 argumentCount = LoadWingCmdrCfgFile(argc, argv);
97 _chdir("gamedat");
98 printf("Loading WING COMMANDER 2. Please wait...\n");
104 main(argumentCount, g_pInitialArguments);
105
107 memoryBytes = (unsigned short)g_5_nStorageAdjustmentKbValue << 10;
109 AllocateTaggedMemory((unsigned int)memoryBytes, 0x40);
110 if (g_pMemoryAdjustment != 0)
111 /* This unit passed the short as a full dword (MOV EAX,[g]),
112 * so the next global's bytes ride along in the high half. */
113 printf("Adjusting Mem size by %dK\n",
115 }
116
130 } else {
134 }
135
136 if (g_stDirectMissionSelection.launch == 0) {
138 for (;;) {
139 if (g_nOriginDevUnlock != 0 &&
143 while (RunSelectedCampaign() != 0) {
144 }
145 } else {
146 while (selectionMade == 0) {
147 switch (RunTitleScreen()) {
148 case 0:
153 selectionMade = RunPilotDatabaseMenu();
154 break;
155 case 1:
158 selectionMade = 1;
159 break;
160 }
161 }
162 selectionMade = 0;
163 if (g_nOriginDevUnlock != 0) {
165 "CHEATER");
167 "CHEATER");
168 }
169 while (RunSelectedCampaign() != 0) {
170 }
171 }
172 }
173 } else {
185 printf("You ");
186 switch (g_nArcadeState) {
187 case 1:
188 printf("have landed.\n");
189 break;
190 case 3:
191 printf("are stranded.\n");
192 break;
193 case 4:
194 printf("have died.\n");
195 break;
196 case 2:
197 printf("have ejected.\n");
198 break;
199 }
200 }
201 if (g_pMemoryAdjustment != 0) {
203 }
204}
205
206#pragma intrinsic(strcpy)
207/* Function start: 0x465CBC */
215
216/* Function start: 0x465CF6 */
218{
219 short allocated;
220
221 if (g_bSpaceViewBufferEnabled != 0 &&
223 allocated = (short)AllocateViewport(
225 (short)g_cPrimaryViewBufferColour, 0x20);
226 if (allocated == 0)
227 ReportOutOfMemoryAndExit("SPACE BUFFER");
228 }
229}
230
231/* Function start: 0x465D55 */
259
260/* Function start: 0x465E25 */
262{
263 signed char object;
264
265 object = g_cViewObject;
266 g_cViewObject = -1;
267 while (g_cViewObject == -1) {
268 object++;
269 if (object > 9)
270 object = 0;
271 if (g_aeObjectClass[object] >= OBJECT_CLASS_SHIP)
272 g_cViewObject = object;
273 }
274}
275
276/* Function start: 0x465E88 */
277unsigned int clear_view_buffer(void)
278{
280}
281
282/* Function start: 0x465EA9 */
292
293/* Function start: 0x465EE9 */
307
308/* Function start: 0x465F3A */
310{
311 if (g_nCurrentView <= 4)
312 g_1_asSpacePaletteFade[0] = 0x30;
313}
314
315/* Function start: 0x465F5B */
316void FadeFlightPaletteEntry(short *entry)
317{
318 if (entry[0] != 0) {
319 entry[0] = (short)(entry[0] - 4);
320 entry[1] = 0;
321 entry[2] = 0;
322 } else
323 entry[1] = 0;
324}
325
326/* Function start: 0x465FA3 */
328{
329 if (g_1_asSpacePaletteFade[0] != 0) {
330 switch ((int)(short)g_nSpacePaletteFadeMode) {
331 case 0x13:
333 (short)(g_1_asSpacePaletteFade[0] - 0x10);
336 break;
337 case 9:
338 case 13:
343 break;
344 }
345 }
346}
347
348/* Function start: 0x46604F */
349void house_keep(void)
350{
351 unsigned char palette;
352 short sequenceState;
353
354 if (g_nTrainSimActive == 0 &&
355 g_nCannedSceneMode == 0) {
356 if (g_ucPendingEjectionTransition != 0xff &&
358 sequenceState = g_nEjectionSequenceState;
360 if (sequenceState == 0x28) {
365 }
366 }
367 if ((g_nSpaceFrame & 0x1f) == 0)
369 if (g_nHazardFieldCount != 0 &&
370 (g_nSpaceFrame & 0xf) == 0)
372 }
373 if (g_nCurrentView == 0 || g_nCurrentView == 4) {
374 for (palette = 0; palette < 6; palette++) {
377 SetPaletteEntry((short)(palette + 0xf9),
379 }
380 } else if (g_4_nSevereDmgWarningSfxHandle != 0) {
381 ((void (__cdecl *)(int, int))FlushSoundEffectsAndLog)(
385 }
386}
387
388/* Function start: 0x4661C2 */
390{
391 /* t and ev held the DOS double-click logic; the port left them unused. */
392 long t;
393 short buttons;
394 short ev;
395
397 return;
399 buttons = (short)(g_aInputDeviceSamplesList[
400 g_8_nActiveInputDeviceWord].buttons & 3);
404 g_wFlightInputButtonState &= (short)~0x1f;
405 g_wFlightInputButtonState |= buttons;
408 if ((buttons & 1) != 0) {
409 TranslatePolledInputEvent(10, (unsigned int)buttons);
411 } else if (g_bFlightButtonOneHeld != 0) {
414 }
415 if ((buttons & 2) != 0) {
416 TranslatePolledInputEvent(10, (unsigned int)buttons);
418 } else if (g_bFlightButtonTwoHeld != 0) {
421 }
426 TranslatePolledInputEvent(7, (unsigned int)buttons);
427 } else if (g_aInputDeviceSamplesList[
433 TranslatePolledInputEvent(7, (unsigned int)buttons);
434 }
439}
440
441/* Function start: 0x4663A2 */
443{
444 short finished;
445 short shift;
446
447 {
448 short keys[4];
449
450 {
451 short *key;
452 short handled;
453
454 handled = 0;
455 finished = 0;
456 shift = (short)GetShiftKeyState();
457 key = keys;
458 switch (g_cCurrentKey) {
459 case 0x47:
460 *key++ = 0x48;
461 *key++ = 0x4b;
462 break;
463 case 0x49:
464 *key++ = 0x48;
465 *key++ = 0x4d;
466 break;
467 case 0x4f:
468 *key++ = 0x50;
469 *key++ = 0x4b;
470 break;
471 case 0x51:
472 *key++ = 0x50;
473 *key++ = 0x4d;
474 break;
475 default:
476 *key++ = (short)g_cCurrentKey;
477 }
478 *key = -1;
479
480 key = keys;
481 while (finished == 0) {
482 switch (*key++) {
483 case -1:
484 finished++;
485 break;
486 case 0x4c:
490 g_anFlightInput[1] =
491 g_anFlightInput[0] =
492 g_anFlightInput[2] = 0;
493 handled = 1;
494 break;
495 case 0x48:
497 if (g_anFlightInput[0] < 0) {
498 g_anFlightInput[0] = 0;
499 } else {
500 if (shift != 0)
501 g_anFlightInput[0] = 9;
502 if (g_anFlightInput[0] < 9)
503 g_anFlightInput[0]++;
504 else if (g_cPreviousKey < 0)
505 g_anFlightInput[0]++;
506 else
507 g_anFlightInput[0]--;
508 }
509 handled = 1;
510 break;
511 case 0x50:
513 if (g_anFlightInput[0] > 0) {
514 g_anFlightInput[0] = 0;
515 } else {
516 if (shift != 0)
517 g_anFlightInput[0] = -9;
518 if (g_anFlightInput[0] > -9) {
519 g_anFlightInput[0]--;
520 } else {
521 if (g_cPreviousKey < 0)
522 g_anFlightInput[0]--;
523 else
524 g_anFlightInput[0]++;
525 }
526 }
527 handled = 1;
528 break;
529 case 0x34:
530 case 0x53:
532 if (g_anFlightInput[2] < 0) {
533 g_anFlightInput[2] = 0;
534 } else {
535 if (shift != 0)
536 g_anFlightInput[2] = 9;
537 if (g_anFlightInput[2] < 9)
538 g_anFlightInput[2]++;
539 else if (g_cPreviousKey < 0)
540 g_anFlightInput[2]++;
541 else
542 g_anFlightInput[2]--;
543 }
544 handled = 1;
545 break;
546 case 0x33:
547 case 0x52:
549 if (g_anFlightInput[2] > 0) {
550 g_anFlightInput[2] = 0;
551 } else {
552 if (shift != 0)
553 g_anFlightInput[2] = -9;
554 if (g_anFlightInput[2] > -9) {
555 g_anFlightInput[2]--;
556 } else {
557 if (g_cPreviousKey < 0)
558 g_anFlightInput[2]--;
559 else
560 g_anFlightInput[2]++;
561 }
562 }
563 handled = 1;
564 break;
565 case 0x4d:
567 if (g_anFlightInput[1] < 0) {
568 g_anFlightInput[1] = 0;
569 } else {
570 if (shift != 0)
571 g_anFlightInput[1] = 9;
572 if (g_anFlightInput[1] < 9)
573 g_anFlightInput[1]++;
574 else if (g_cPreviousKey < 0)
575 g_anFlightInput[1]++;
576 else
577 g_anFlightInput[1]--;
578 }
579 handled = 1;
580 break;
581 case 0x4b:
583 if (g_anFlightInput[1] > 0) {
584 g_anFlightInput[1] = 0;
585 } else {
586 if (shift != 0)
587 g_anFlightInput[1] = -9;
588 if (g_anFlightInput[1] > -9) {
589 g_anFlightInput[1]--;
590 } else {
591 if (g_cPreviousKey < 0)
592 g_anFlightInput[1]--;
593 else
594 g_anFlightInput[1]++;
595 }
596 }
597 handled = 1;
598 break;
599 default:
600 break;
601 }
602 }
603 }
604 }
605}
606
607/* Function start: 0x466908 */
608unsigned int fire_players_lasers(void)
609{
610 if (g_asObjectCounter[0] == -1 &&
611 g_asShipWeaponEnergy[0] > 0) {
613 if (g_acShipTarget[0] != -1 &&
614 get_mode(1) == 5)
616 }
617}
618
619/* Function start: 0x46696E */
621{
622 if (g_aeSpecialManeuver[0] ==
624 if (g_asObjectCounter[0] == -1) {
626 g_acObjectType[0]].pitchRate >
629 g_acObjectType[0]].yawRate >
632 g_acObjectType[0]].rollRate >
635 } else {
638 }
639 }
640 } else {
641 g_anObjectPitchRotation[0] = (short)(
643 g_acObjectType[0]].yawRate *
644 g_anFlightInput[0]) / 8);
645 g_anObjectYawRotation[0] = (short)-(
647 g_acObjectType[0]].pitchRate *
648 g_anFlightInput[1]) / 8);
649 g_anObjectRollRotation[0] = (short)-(
651 g_acObjectType[0]].rollRate *
652 g_anFlightInput[2]) / 8);
653 }
654}
655
656/* Function start: 0x466AD2 */
657short IsInputEventQueued(int type)
658{
659 return FindQueuedInputEvent(type) != 0;
660}
661
662#pragma function(abs)
663
664/* Function start: 0x466B02 */
665short player_input(void)
666{
667 InputEventState message;
668 short keyHandled;
669 unsigned int buttons;
670 int inputPolled;
671 short inputCode;
672 short boostControl;
673 short absX;
674 short verticalDistance;
675 short threshold;
676 short dx;
677 short mouseY;
678 int savedPlayerInputActive;
679 HostMouseMessage *mouse;
680
681 keyHandled = 0;
683 buttons = 0;
684 inputPolled = 0;
689 savedPlayerInputActive = g_10_bPlayerInputActive;
694 (signed char)IsInputEventQueued(3);
696 (short)(IsInputEventQueued(4) | IsInputEventQueued(6));
698 g_cCurrentKey |= (signed char)0x80;
699 if (IsInputEventQueued(5) != 0) {
700 g_cCurrentKey |= (signed char)0x80;
703 g_anFlightInput[1] =
704 g_anFlightInput[0] =
705 g_anFlightInput[2] =
707 }
708 }
709
710 buttons = mouse->secondaryButton * 2 | mouse->primaryButton;
711 if (buttons != 0) {
712 if ((buttons & 1) != 0) {
713 if ((buttons & 2) != 0) {
716 else
717 g_cCurrentKey = 0x1c;
718 } else {
720 }
721 }
722 if (buttons == 3)
723 g_cCurrentKey = 0x1c;
724 } else {
726 }
727
728 while ((inputCode = GetNextInputEvent(&message)) != 0) {
729 switch (inputCode) {
730 case 3:
731 if (inputPolled != 0)
732 break;
733 boostControl = (short)(message.modifiers & 2);
734 if (boostControl != 0 &&
737 boostControl = 0;
738 if (g_nCockpitControlState == 0) {
742 (short)((g_27_stViewScratchInfo.top +
746 }
747 dx = (short)(message.x -
750 mouseY = (short)(message.y -
755 absX = (short)abs((int)dx);
756 verticalDistance = (short)abs((int)mouseY);
757 threshold = 0;
758 while (g_asMouseYawThresholds[threshold] <=
759 absX)
760 threshold++;
761 if (dx < 0)
762 dx = (short)-threshold;
763 else
764 dx = threshold;
765 threshold = 0;
766 while (g_asMousePitchThresholds[threshold] <=
767 verticalDistance)
768 threshold++;
769 if (mouseY < 0)
770 mouseY = (short)-threshold;
771 else
772 mouseY = threshold;
773 if ((int)message.x - 4 <= (int)g_27_stViewScratchInfo.left)
774 dx = -8;
775 if ((int)message.x + 4 >= (int)g_27_stViewScratchInfo.right)
776 dx = 8;
777 if ((int)message.y - 4 <= (int)g_27_stViewScratchInfo.top)
778 mouseY = -8;
779 if ((int)message.y + 4 >= (int)g_27_stViewScratchInfo.bottom)
780 mouseY = 8;
781 if (dx >= 9)
782 dx = 8;
783 if (dx <= -9)
784 dx = -8;
785 if (mouseY >= 9)
786 mouseY = 8;
787 if (mouseY <= -9)
788 mouseY = -8;
789 if (boostControl != 0) {
791 g_anFlightInput[2] =
792 g_nMouseYawInput = dx;
793 g_nMousePitchInput = (short)-mouseY;
794 accelerate((short)(g_nMousePitchInput / 2));
795 } else if (g_nCockpitControlGoal == 1) {
797 g_anFlightInput[2] = 0;
803 (short)((g_27_stViewScratchInfo.top +
805 } else {
806 g_anFlightInput[2] = 0;
807 g_anFlightInput[1] =
808 g_nMouseYawInput = dx;
809 g_anFlightInput[0] =
810 g_nMousePitchInput = mouseY;
811 }
812 break;
813 case 7:
814 inputPolled = 1;
815 g_cCurrentKey = (signed char)PollKeyboardState();
816 if (g_cCurrentKey != 0)
821 boostControl = (short)(message.modifiers & 2);
822 if (boostControl != 0 &&
825 boostControl = 0;
826 if (boostControl != 0) {
827 g_anFlightInput[2] =
829 accelerate((short)-(
831 } else {
832 if (g_anFlightInput[2] != 0 &&
833 g_cCurrentKey == 0) {
834 g_anFlightInput[2] = 0;
836 }
841 g_anFlightInput[1] =
843 g_anFlightInput[0] =
845 }
846 }
847 break;
848 case 2:
849 if (message.value == 2)
851 break;
852 case 1:
853 if ((message.modifiers & 1) != 0) {
854 g_cCurrentKey = 0x39;
855 if ((message.modifiers & 2) != 0) {
858 else
859 g_cCurrentKey = 0x1c;
860 } else {
862 }
863 }
864 if (message.value == 2 && message.status > 1)
866 break;
867 case 6:
868 keyHandled = 1;
869 case 4:
871 g_cCurrentKey = (signed char)message.status;
873 break;
874 }
875 }
876
878 g_cCurrentKey = 0xf;
879 if ((g_cCurrentKey & 0x80) != 0 &&
881 g_cCurrentKey = 0x39;
882 if ((g_cCurrentKey & 0x80) != 0 &&
883 (g_6_wQueuedButtonsState & 1) != 0)
884 g_cCurrentKey = 0x39;
887 g_10_bPlayerInputActive = savedPlayerInputActive;
888 return keyHandled;
889}
890
891#pragma function(strlen)
892
893/* Function start: 0x4672C5 */
894/* Message dwell time: grows with text length, scaled by the speed setting. */
895short MeasureMessageWidth(const char *text)
896{
897 return (short)((MinShort(5, (short)(strlen(text) >> 1)) + 5) *
898 ((char)g_cMessageSpeed + 1));
899}
900
901/* Function start: 0x467300 */
910
911/* Function start: 0x46733D */
913{
914 /* The DOS dynamic-intelligence display used these two buffers. Its
915 * Win32 command was removed, but the retail frame retains their slots. */
916 char debugText[60];
917 char decimalText[30];
918 short inputConsumed;
919 short notRepeated;
920 short controlHeld;
921 short modifierMask;
922 short pauseScan;
923 short object;
924
927 if (g_nCurrentView == 4) {
928 inputConsumed = HandleFleetOverviewInput();
929 } else {
930 inputConsumed = player_input();
932 }
933 notRepeated =
935 inputConsumed == 0;
936 controlHeld = (short)GetControlKeyState();
937 modifierMask = (short)GetKeyboardModifiers();
938
939 if (g_4_bMenuBHotkey != 0 &&
941 g_nYourWingman != -1 &&
944 any_enemy(0, 14000) != 0) {
947 }
952 }
953 if (g_2_bAltFHotkeyFlag != 0 &&
955 g_nYourWingman != -1) {
958 }
959 if (g_bMenuAHotkey != 0 &&
961 g_nYourWingman != -1 &&
962 g_acShipTarget[0] != -1) {
965 }
966 if (g_2_bAltHHotkey != 0 &&
968 g_nYourWingman != -1 &&
969 any_enemy(0, 14000) != 0) {
972 }
973 if (g_6_bAltDChordState != 0 &&
975 g_nYourWingman != -1) {
978 }
979 if (g_6_bMenuTHotkeySwitch != 0 &&
981 g_acShipTarget[0] != -1 &&
986 (short)((unsigned short)RandomInRange(0, 2) +
989 }
994 }
999 }
1000
1001 switch ((signed char)g_cCurrentKey) {
1002 case 0x13:
1003 if (notRepeated && g_78_bHighMemoryBuffersSetState != 0) {
1006 }
1007 break;
1008 case 0x1e:
1009 if (notRepeated && controlHeld == 0) {
1011 if (get_mode(1) != 5)
1013 if (g_nCockpitDisplayMode == 0) {
1015 } else {
1019 (short)(g_nScreenWidth - 1),
1020 (short)(g_nScreenHeight - 1));
1027 0, 0, 319, 199);
1029 }
1030 }
1031 break;
1032 case 0x2e:
1033 if (notRepeated) {
1035 if (message_showing() != 0) {
1036 EndCommMenu();
1037 } else if (get_mode(1) != 4) {
1039 } else {
1041 }
1042 }
1043 break;
1044 case 0x12:
1045 if (notRepeated && controlHeld != 0 &&
1046 g_acPlayerComponentDamage[7] != 4) {
1047 if (RandomInRange(
1048 0, g_acPlayerComponentDamage[7]) == 0)
1049 g_nArcadeState = 2;
1050 else
1051 malf_sound();
1052 }
1053 break;
1054 case 0x31:
1055 if (notRepeated) {
1058 }
1059 break;
1060 case 0x32:
1061 if (notRepeated && controlHeld == 0)
1063 break;
1064 case 0x2f:
1065 if (notRepeated && controlHeld == 0) {
1068 if (g_bVideoImagesSuppressed != 0)
1070 "VIDEO IMAGES SUPRESSED",
1071 g_cRedColour, 20);
1072 else
1073 SetHudMessageText("VIDEO IMAGES ENABLED",
1075 }
1076 break;
1077 case 2:
1078 case 3:
1079 case 4:
1080 case 5:
1081 case 6:
1082 case 7:
1083 case 8:
1084 case 9:
1085 case 10:
1086 if (notRepeated && get_mode(1) == 4 &&
1087 g_nCurrentView == 0 && (signed char)g_cCurrentKey >= 2 &&
1088 (signed char)g_cCurrentKey <=
1090 get_mode(1) == 4) {
1092 (short)((signed char)g_cCurrentKey - 2));
1093 }
1094 break;
1095 case 0x1f:
1096 if (controlHeld != 0 && notRepeated) {
1097 if (g_nSfxVolumeSetting == 0)
1099 else
1103 g_nSfxVolumeSetting / 2]);
1104 ShowOnScreenMessage(0, "SFX VOLUME: %d.",
1106 }
1107 break;
1108 case 0x3b:
1109 if (g_nTargetCameraFrame == 1)
1112 if (GetF1KeyLatch() == 0)
1113 break;
1118 if (g_nCockpitDisplayMode != 0) {
1121 0, 0, 319, 199);
1124 } else {
1128 (short)(g_nScreenWidth - 1),
1129 (short)(g_nScreenHeight - 1));
1132 }
1133 } else {
1135 if (g_nCockpitDisplayMode == 0) {
1136 new_view(0, 0);
1137 } else {
1141 (short)(g_nScreenWidth - 1),
1142 (short)(g_nScreenHeight - 1));
1144 new_view(0, 0);
1146 SetViewportRect(&g_27_stViewScratchInfo, 0, 0, 319, 199);
1148 }
1149 }
1151 break;
1152 case 0x3c:
1153 if (g_nTargetCameraFrame == 1)
1159 if (g_nCockpitDisplayMode != 0) {
1162 0, 0, 319, 199);
1164 } else {
1168 (short)(g_nScreenWidth - 1),
1169 (short)(g_nScreenHeight - 1));
1171 }
1172 } else {
1174 if (g_nCockpitDisplayMode == 0) {
1175 new_view(2, 0);
1176 } else {
1180 (short)(g_nScreenWidth - 1),
1181 (short)(g_nScreenHeight - 1));
1183 new_view(2, 0);
1186 0, 0, 319, 199);
1188 }
1189 }
1190 break;
1191 case 0x3d:
1192 if (g_nTargetCameraFrame == 1)
1198 if (g_nCockpitDisplayMode != 0) {
1201 0, 0, 319, 199);
1203 } else {
1207 (short)(g_nScreenWidth - 1),
1208 (short)(g_nScreenHeight - 1));
1210 }
1211 } else {
1213 if (g_nCockpitDisplayMode == 0) {
1214 new_view(1, 0);
1215 } else {
1219 (short)(g_nScreenWidth - 1),
1220 (short)(g_nScreenHeight - 1));
1222 new_view(1, 0);
1225 0, 0, 319, 199);
1227 }
1228 }
1229 break;
1230 case 0x3e:
1231 if (g_nTargetCameraFrame == 1)
1237 if (g_nCockpitDisplayMode != 0) {
1240 0, 0, 319, 199);
1242 } else {
1246 (short)(g_nScreenWidth - 1),
1247 (short)(g_nScreenHeight - 1));
1249 }
1250 } else {
1252 if (g_nCockpitDisplayMode == 0) {
1253 new_view(3, 0);
1254 } else {
1258 (short)(g_nScreenWidth - 1),
1259 (short)(g_nScreenHeight - 1));
1261 new_view(3, 0);
1264 0, 0, 319, 199);
1266 }
1267 }
1268 break;
1269 case 0x3f:
1270 if (g_nTargetCameraFrame == 1)
1276 if (g_nCockpitDisplayMode != 0) {
1279 0, 0, 319, 199);
1281 } else {
1285 (short)(g_nScreenWidth - 1),
1286 (short)(g_nScreenHeight - 1));
1288 }
1289 } else {
1291 if (g_nCockpitDisplayMode == 0) {
1292 new_view(5, 0);
1293 } else {
1297 (short)(g_nScreenWidth - 1),
1298 (short)(g_nScreenHeight - 1));
1300 new_view(5, 0);
1303 0, 0, 319, 199);
1305 }
1306 }
1307 break;
1308 case 0x40:
1309 if (g_nTargetCameraFrame == 1)
1315 if (g_nCockpitDisplayMode != 0) {
1318 0, 0, 319, 199);
1320 } else {
1324 (short)(g_nScreenWidth - 1),
1325 (short)(g_nScreenHeight - 1));
1327 }
1328 } else {
1330 if (g_nCockpitDisplayMode == 0) {
1331 new_view(15, 0);
1332 } else {
1336 (short)(g_nScreenWidth - 1),
1337 (short)(g_nScreenHeight - 1));
1339 new_view(15, 0);
1342 0, 0, 319, 199);
1344 }
1345 }
1346 break;
1347 case 0x41:
1348 if (g_nTargetCameraFrame == 1)
1354 if (g_nCockpitDisplayMode != 0) {
1357 0, 0, 319, 199);
1359 } else {
1363 (short)(g_nScreenWidth - 1),
1364 (short)(g_nScreenHeight - 1));
1366 }
1367 } else if (g_acShipTarget[0] != -1) {
1369 if (g_nCockpitDisplayMode == 0) {
1370 new_view(8, 0);
1371 } else {
1375 (short)(g_nScreenWidth - 1),
1376 (short)(g_nScreenHeight - 1));
1378 new_view(8, 0);
1381 0, 0, 319, 199);
1383 }
1384 }
1385 break;
1386 case 0x42:
1387 if (g_nTargetCameraFrame == 1)
1389 if (notRepeated) {
1392 if (g_bMissileCameraEnabled != 0)
1393 SetHudMessageText("MISSILE CAMERA ON",
1394 g_cRedColour, 20);
1395 else
1396 SetHudMessageText("MISSILE CAMERA OFF",
1398 }
1399 break;
1400 case 0x43:
1401 if (notRepeated) {
1404 if (g_nCockpitDisplayMode == 0) {
1405 new_view(5, 0);
1406 } else {
1410 (short)(g_nScreenWidth - 1),
1411 (short)(g_nScreenHeight - 1));
1413 force_view(5, 0);
1416 0, 0, 319, 199);
1418 }
1419 }
1420 break;
1421 }
1422
1423 switch ((signed char)g_cCurrentKey) {
1424 case 0x0d:
1425 case 0x4e:
1426 if (controlHeld != 0) {
1428 } else {
1429 accelerate(1);
1430 }
1431 break;
1432 case 0x2b:
1433 accelerate(9000);
1434 break;
1435 case 0x0c:
1436 case 0x4a:
1437 if (controlHeld != 0) {
1439 } else {
1440 accelerate(-1);
1441 }
1442 break;
1443 case 0x0e:
1444 g_anShipSpeed[0] = 0;
1445 break;
1446 case 0x1c:
1447 if (notRepeated && g_nSelectedReleaseWeaponIndex != -1 &&
1448 g_nExternalViewShip == -1) {
1450 if (g_nExternalViewShip != -1 &&
1452 0x14) {
1454 } else if (g_bMissileCameraEnabled == 1 &&
1455 g_nExternalViewShip != -1) {
1457 }
1458 }
1459 break;
1460 case 0x39:
1461 if (g_nCurrentView == 4)
1463 else
1465 break;
1466 case 0x0f:
1467 case 0x37:
1468 if (g_asObjectType[0] != 0x33)
1470 break;
1471 case 1:
1473 if (get_mode(1) == 4) {
1475 }
1476 break;
1477 case 0x14:
1478 if (notRepeated && controlHeld == 0) {
1481 }
1482 break;
1483 case 0x11:
1484 if (notRepeated) {
1485 if (g_nCurrentView == 4) {
1487 } else if (IsCockpitWeaponShapeLoaded() != 0) {
1489 }
1490 }
1491 break;
1492 case 0x2f:
1493 if (notRepeated && controlHeld != 0)
1495 break;
1496 case 0x24:
1497 if (notRepeated && controlHeld != 0)
1499 else if (notRepeated)
1501 break;
1502 case 0x19:
1504 ShowGamePausedBanner((short)(controlHeld == 0));
1507 for (pauseScan = 0; pauseScan < 0x100; pauseScan++) {
1508 g_128_abPauseInputState[pauseScan] = 0;
1510 g_128_abPauseInputState[pauseScan];
1511 }
1516 break;
1517 case 0x20:
1518 if (notRepeated && controlHeld == 0 &&
1521 break;
1522 case 0x22:
1523 if (notRepeated) {
1524 if (g_nCurrentView == 4) {
1526 } else if (IsCockpitWeaponShapeLoaded() != 0) {
1528 }
1529 }
1530 break;
1531 case 0x26:
1532 if (notRepeated) {
1534 (short)(g_bTargetLockMode == 0);
1535 PlaySfxWaveFileByNumber(0x19, -1, 0);
1536 if (get_mode(1) == 3)
1538 }
1539 break;
1540 case 0x32:
1541 if (notRepeated && controlHeld != 0) {
1542 if (g_nMusicVolumeSetting == 0)
1544 else
1547 (unsigned short)g_anVolumeLevels[
1549 ShowOnScreenMessage(0, "MUSIC VOLUME: %d.",
1551 }
1552 break;
1553 }
1554
1555 switch ((signed char)g_cCurrentKey) {
1556 case 0x48:
1557 if (controlHeld != 0) {
1559 if (g_nSfxVolumeSetting > 20)
1564 g_nSfxVolumeSetting / 2]);
1565 ShowOnScreenMessage(0, "SFX VOLUME: %d.",
1567 return 0;
1568 }
1569 break;
1570 case 0x50:
1571 if (controlHeld != 0) {
1573 if (g_nSfxVolumeSetting < 0)
1577 g_nSfxVolumeSetting / 2]);
1579 ShowOnScreenMessage(0, "SFX VOLUME: %d.",
1581 return 0;
1582 }
1583 break;
1584 case 0x4d:
1585 if (controlHeld != 0) {
1587 if (g_nMusicVolumeSetting > 20)
1591 (unsigned short)g_anVolumeLevels[
1593 ShowOnScreenMessage(0, "MUSIC VOLUME: %d.",
1595 return 0;
1596 }
1597 break;
1598 case 0x4b:
1599 if (controlHeld != 0) {
1601 if (g_nMusicVolumeSetting < 0)
1605 (unsigned short)g_anVolumeLevels[
1607 ShowOnScreenMessage(0, "MUSIC VOLUME: %d.",
1609 return 0;
1610 }
1611 break;
1612 }
1613
1614 if (g_nOriginDevUnlock != 0) {
1615 switch ((signed char)g_cCurrentKey) {
1616 case 0x52:
1617 if (notRepeated && controlHeld != 0) {
1618 for (object = 1; object < 10; object++) {
1619 if (g_asShipSide[object] !=
1620 g_asShipSide[0] &&
1621 g_aeObjectClass[object] ==
1623 while (explode(0, object) == 0) {
1624 }
1625 }
1626 }
1627 }
1628 break;
1629 case 0x53:
1630 if (notRepeated && controlHeld != 0 &&
1631 g_bDebugBreakEnabled != 0) {
1632 object = g_acShipTarget[0];
1633 if (object != -1) {
1634 while (explode(0, object) == 0) {
1635 }
1636 }
1637 }
1638 break;
1639 }
1640 }
1641 return 0;
1642}
1643
1644/* Function start: 0x468E7A */
1645unsigned int DrawSpaceSceneFrame(void)
1646{
1647 short paletteCycleActive;
1648 short hidePlayer;
1649
1650 paletteCycleActive = 0;
1651 hidePlayer = 0;
1653 if ((short)g_nSpacePaletteFadeMode == 0x13) {
1656 paletteCycleActive++;
1658 g_nSpaceBlastFlashIncrement][0] != 0) {
1668 } else {
1671 g_1_asSpacePaletteFade[2] = 0x20;
1673 }
1676 }
1677 } else {
1679 }
1681 if (g_nFrameSkipCountdown > 0)
1682 return 0;
1690 if (g_bJumpSequenceActive != 0 &&
1692 hidePlayer = 1;
1694 }
1695 if (paletteCycleActive == 0)
1697 if (hidePlayer != 0)
1699 if (g_nCurrentView == 0 || g_nCurrentView == 4)
1701 return 1;
1702}
1703
1704/* Function start: 0x46903F */
1706{
1707 int displayMode;
1708
1709 if (DrawSpaceSceneFrame() == 0)
1710 return;
1711 check_message();
1717 }
1718 if (g_nCockpitDisplayMode > 0) {
1719 displayMode = g_nCockpitDisplayMode;
1721 }
1723 if (g_nCockpitDisplayMode == 9)
1724 g_nCockpitDisplayMode = displayMode;
1725 if (g_nCurrentView == 0 || g_nCurrentView == 4)
1729}
1730
1731/* Function start: 0x4690FF */
1733{
1734 Update_3Space();
1735 if (g_nArcadeState != 0)
1736 return 0;
1737 if (g_nFrameSkipCountdown <= 1)
1739 return (unsigned short)DrawSpaceSceneFrame();
1740}
1741
1742/* Function start: 0x469143 */
1743short GetShipDistanceToNavPoint(short ship, MissionNavPoint *navPoint)
1744{
1745 FixedVector delta;
1746
1748 &navPoint->position, &delta);
1750}
1751
1752/* Function start: 0x46918D */
1753short FindNearestNavPoint(short ship)
1754{
1756 short navPointIndex = 0;
1757
1758 for (; navPointIndex < 10; navPointIndex++, entry++) {
1759 if (entry->type == 1 &&
1760 entry->systemIndex == g_nCurStellarSystem &&
1761 GetShipDistanceToNavPoint(ship, entry) <
1762 entry->proximityRadius)
1763 return navPointIndex;
1764 }
1765 return g_nCurrentNavPoint;
1766}
1767
1768/* Function start: 0x469223 */
1769unsigned int ReleaseStaleNavTarget(void)
1770{
1771 short v = FindNearestNavPoint(0);
1772
1773 if (g_nCurrentNavPoint != v)
1775}
1776
1777/* Function start: 0x46925E */
1778int RunSpaceFlight(short entryNavPoint)
1779{
1780 InputPumpContext *savedInputContext;
1781 unsigned char savedInputDelay;
1782 short savedUiInputMode;
1783 short savedCursor;
1784 short result;
1785 short i;
1786
1787 savedUiInputMode = g_18_nInterfaceEventMode;
1790 if (g_bFullScreenSpaceView == 0)
1792 for (i = 0; i < 7; i++)
1799 savedInputDelay = g_88_nEventRepeatDelayState;
1800 savedInputContext = g_37_stPersonnelMousePointerState.context;
1803
1804 if (entryNavPoint == -1)
1805 entryNavPoint = g_aMissionShips[
1807 set_up_action_sphere(entryNavPoint);
1808 force_view(0, 0);
1810
1811 if (g_nCockpitDisplayMode != 0) {
1814 (unsigned short)(g_nScreenWidth - 1),
1815 (unsigned short)(g_nScreenHeight - 1));
1817 new_view(0, 0);
1819 SetViewportRect(&g_27_stViewScratchInfo, 0, 0, 319, 199);
1826 }
1827
1828 copy_frame(0, 0x44);
1830 (short)((g_27_stViewScratchInfo.left +
1832 (short)((g_27_stViewScratchInfo.top +
1835 g_nArcadeState = 0;
1836
1837 while (g_nArcadeState == 0) {
1839 if (g_nCannedSceneMode != 0) {
1841 result = 0;
1846 }
1847 }
1848 if (g_nCannedSceneMode == 0 &&
1850 result = (short)HandleSpaceFlightControls();
1851 if (result == -1) {
1852 g_nArcadeState = 5;
1853 } else {
1854 Update_3Space();
1855 if (g_nArcadeState != 0)
1856 break;
1861 if (g_pszPendingHudMessage != 0)
1864 }
1865 MarkDibDirty();
1866 DIBslamReal();
1868 }
1869
1871 (unsigned short)(g_nScreenWidth - 1),
1872 (unsigned short)(g_nScreenHeight - 1));
1874 if (g_nArcadeState == 1)
1875 flag_objective(find_objective(1, -1), 2);
1878 if (savedInputContext != 0)
1879 SetInputViewport(savedInputContext->viewport);
1881 ConfigureInputPump(1, 0);
1883 g_18_nInterfaceEventMode = savedUiInputMode;
1884 g_88_nEventRepeatDelayState = savedInputDelay;
1886 return g_nArcadeState;
1887}
1888
1889/* Function start: 0x4695FD */
1891{
1892 ObjectTypeData *typeData;
1893 int damage;
1894 int armorDamage;
1895
1896 armorDamage = 0;
1897 typeData = &g_aObjectTypeData[g_acObjectType[0]];
1898 damage = g_asObjectDamage[0] * 5;
1899 damage += (g_acShipDamage[0] * 30) /
1900 typeData->damageCapacity;
1901 if (typeData->armorFront < g_aasShipArmor[0][0])
1902 armorDamage += (typeData->armorFront * 100) /
1903 g_aasShipArmor[0][0];
1904 if (typeData->armorRear < g_aasShipArmor[0][1])
1905 armorDamage += (typeData->armorRear * 100) /
1906 g_aasShipArmor[0][1];
1907 if (typeData->armorLeft < g_aasShipArmor[0][2])
1908 armorDamage += (typeData->armorLeft * 100) /
1909 g_aasShipArmor[0][2];
1910 if (typeData->armorRight < g_aasShipArmor[0][3])
1911 armorDamage += (typeData->armorRight * 100) /
1912 g_aasShipArmor[0][3];
1913 armorDamage /= 4;
1914 damage += armorDamage;
1915
1916 if (damage < 5)
1917 return 0;
1918 else if (damage < 40)
1919 return 1;
1920 else if (damage < 70)
1921 return 2;
1922 else
1923 return 3;
1924}
1925
1926/* This unit's initialized data, after its functions so that it does not
1927 * move the functions' symbol keys. */
1928int g_bFullScreenSpaceView = 1; /* 0x0049d718 */
1929int g_nCockpitDisplayMode = 0; /* 0x0049d71c */
1931 0, 500, 1000, 2500, 5000, 11000,
1932 22500, 34000, 44000, 54000, 64000
1933}; /* 0x0049d720 */
1934int g_nSfxVolumeSetting = 0x14; /* 0x0049d74c */
1935int g_nMusicVolumeSetting = 0x14; /* 0x0049d750 */
1936int g_nUnusedMainWord1 = 0x1370; /* 0x0049d754 */
1937int g_nTrainSimActive = 0; /* 0x0049d758 */
1938int g_nArcadeState = 0; /* 0x0049d75c */
1939short g_nFrameSkipCountdown = 1; /* 0x0049d760 */
1940short g_nFrameSkip = 0; /* 0x0049d764 */
1941short g_nSpaceFramePeriod = 4; /* 0x0049d768 */
1942short g_bViewportDirty = 0; /* 0x0049d76c */
1943short g_nCockpitCameraObject = 0; /* 0x0049d770 */
1944short g_nOriginDevUnlock = 0; /* 0x0049d774 */
1945short g_bCarrierLandingEnabled = 1; /* 0x0049d778 */
1946short g_bPlayerDamageEnabled = 1; /* 0x0049d77c */
1947short g_bPlayerCollisionEnabled = 1; /* 0x0049d780 */
1948short g_nShowMemoryStatus = 0; /* 0x0049d784 */
1949void *g_pMemoryAdjustment = 0; /* 0x0049d788 */
1950signed char g_bParentDirectorySelected = 0; /* 0x0049d78c */
1951short g_nMissionEntryNavOverride = -1; /* 0x0049d790 */
1952int g_nUnusedMainWord2 = 0; /* 0x0049d794 */
1953struct DirectMissionSelection g_stDirectMissionSelection = { 0, 0 }; /* 0x0049d798 */
1954short g_nDirectSeries = 1; /* 0x0049d79c */
1955int g_nUnusedMainWord3 = 0; /* 0x0049d7a0 */
1956short g_bSpaceViewBufferEnabled = 0; /* 0x0049d7a4 */
1957int g_nUnusedMainWord4 = 0; /* 0x0049d7a8 */
1958short g_nCockpitControlState = 0; /* 0x0049d7ac */
1960int g_nUnusedMainWord5 = 0; /* 0x0049d7bc */
1961short g_wFlightInputButtonState = 0; /* 0x0049d7c0 */
1962int g_nUnusedMainWord6 = 0; /* 0x0049d7c4 */
1963int g_bFlightButtonTwoHeld = 0; /* 0x0049d7c8 */
1964int g_bFlightButtonOneHeld = 0; /* 0x0049d7cc */
1965short g_nCockpitControlGoal = 0; /* 0x0049d7d0 */
1967 10, 37, 52, 57, 62, 1070
1968}; /* 0x0049d7d8 */
1970 5, 18, 27, 35, 38, 1040
1971}; /* 0x0049d7e8 */
1972signed char g_bSecondaryMouseButtonHeld = 0; /* 0x0049d7f4 */
1973int g_nUnusedMainWord7 = 0; /* 0x0049d7f8 */
1974signed char g_bMouseMoveEventQueued = 0; /* 0x0049d7fc */
1975short g_nMouseYawInput = 0; /* 0x0049d800 */
1976short g_nMousePitchInput = 0; /* 0x0049d804 */
1978 {63, 63, 35},
1979 {63, 63, 35},
1980 {63, 63, 63},
1981 {63, 63, 63},
1982 {63, 63, 63},
1983 {58, 58, 58},
1984 {50, 50, 50},
1985 {42, 42, 42},
1986 {33, 33, 33},
1987 {25, 25, 25},
1988 {17, 17, 17},
1989 {8, 8, 8},
1990 {0, 0, 0}
1991}; /* 0x0049d808 */
1992int g_bRenderingSpaceFrame = 0; /* 0x0049d858 */
1993
1994/* Linker commons defined here. LINK lays a unit's commons out by the
1995 * identifiers' hash keys, so these spellings follow the original addresses. */
1997short g_bMapPrimaryInputQueued; /* 0x005c57dc */
1998int g_6_nUnusedMainNumber1; /* 0x005c57e0 */ /* never referenced */
1999short g_1_bDiscreteFlightInputWaiting; /* 0x005c57e4 */
2000short g_1_nResourcePaletteState; /* 0x005c57e6 */
2001short g_3_nOptionMessageColour; /* 0x005c57e8 */
2002short g_2_bFleetMouseMovePosted; /* 0x005c57ea */
2003char *g_pInitialArguments[31]; /* 0x005c57f0 */
2004int g_1_bSpaceFlightActive; /* 0x005c586c */
2005short g_nCurSeries; /* 0x005c5870 */
2006short g_nSpaceBlastFlashIncrement; /* 0x005c5872 */
2007short g_nMenuSelectedCol; /* 0x005c5874 */
2008short g_10_nMenuDarkColour; /* 0x005c5876 */
2009short g_nCurrentLevel; /* 0x005c5878 */
2010short g_19_bPolledFlightInputQueued; /* 0x005c587a */
2011int g_39_nIdleMainNumber[4]; /* 0x005c5880 */ /* never referenced */
2012InputEvent g_3_aInputEventArray[0x100]; /* 0x005c5890 */
2013int g_10_bPlayerInputActive; /* 0x005c8090 */
2014int g_47_nUnusedMainValue1; /* 0x005c8094 */ /* never referenced */
2015int g_47_nUnusedMainValue2[2]; /* 0x005c8098 */ /* never referenced */
2016int g_129_nUnusedMainNumber2[2]; /* 0x005c80a0 */ /* never referenced */
void(__cdecl *g_pIxFree)(void *)
unsigned char g_128_abPauseInputState[0x100]
Definition eventmgr.c:2554
unsigned char g_13_abPreviousPauseKeyStatuses[0x100]
Definition eventmgr.c:2556
void ShowGamePausedBanner(short showBanner)
Definition message.c:187
void InitializeNewPilotCampaign(short campaignSlot)
Definition campaign.c:14
void ComputeVectorDelta(FixedVector *from, FixedVector *to, FixedVector *delta)
Definition geom.c:229
void SaveAndFreeTemporaryCampaignGlobals(void)
Definition campglob.c:188
short get_mode(short i)
Definition cockpt.c:630
void init_mission(short series, short mission)
Definition mission.c:87
void ShutdownSoundBlaster(void)
Definition speech.c:269
int ConfigureInputPump(int slot, void(*pump)(void))
Definition eventmgr.c:2112
short HandleSpaceFlightControls(void)
Definition main.c:912
void SetInputViewport(Viewport *viewport)
Definition eventmgr.c:2093
void PollJoystickButtonEvents(void)
Definition input.c:74
short fire_missile(short ship)
Definition ship.c:2681
short MaxShort(short a, short b)
Definition disk.c:36
void initialize_view_buffer(void)
Definition main.c:217
void BuildObjectDepthOrder(void)
Definition eventmgr.c:1643
short LogMemoryUsage(void)
Definition main.c:24
void SetViewportRect(Viewport *viewport, unsigned short left, unsigned short top, unsigned short right, unsigned short bottom)
Definition viewrect.c:9
short explode(short attacker, short victim)
Definition ship.c:1915
void SaveVolumeSettingsToRegistry(void)
Definition sound.c:471
short GetShipDistanceToNavPoint(short ship, MissionNavPoint *navPoint)
Definition main.c:1743
void main(short argc, char **argv)
Definition startup.c:425
void SetMusicStreamVolume(unsigned short volume)
Definition stream.cpp:248
void dump_buffer_to_screen(void)
Definition main.c:232
void check_message(void)
Definition cockpt.c:740
short ServiceInputDevices(short deviceMask)
Definition eventmgr.c:2071
void SetPaletteEntry(short index, short *rgb)
Definition gr.c:676
void house_keep_objects(void)
Definition spc.c:819
short AllocateViewport(Viewport *viewport, short clearColour, short flags)
Definition vpalloc.c:32
long Vector_magnitude(const FixedVector *vector)
Definition eventmgr.c:157
void ejection_sequence(short outcome, signed char restoreCockpit)
Definition midscene.c:63
unsigned int fire_players_lasers(void)
Definition main.c:608
void AdjustSpaceFramePeriod(short adjustment)
Definition main.c:60
void CalibrateJoystickInteractive()
Definition titlemnu.c:10
int RunSpaceFlight(short entryNavPoint)
Definition main.c:1778
void FinishCannedScenePlayback(void)
Definition replay.c:25
void FireTargetCameraGuns(void)
Definition turret.c:327
void SetSpaceFlightFrameTiming(void)
Definition dib.cpp:192
unsigned int DrawSpaceSceneFrame(void)
Definition main.c:1645
void InitializeSpaceFlightInput(void)
Definition message.c:16
void your_afterburner(void)
Definition ship.c:3028
void free_viewport(Viewport *viewport)
Definition vpfree.c:10
void free_inflight_music(void)
Definition fltsetup.c:944
void EndCommMenu(void)
Definition comm.c:441
InputEventState * FindQueuedInputEvent(int type)
Definition eventmgr.c:969
void RefreshMemoryStatusOverlay(void)
Definition main.c:283
void IssueQuickCommCommand(short recipient, short command)
Definition comm.c:413
unsigned int PollKeyboardState(void)
Definition winmain.c:991
void get_player_input(void)
Definition main.c:389
short HandleFleetOverviewInput(void)
Definition turret.c:33
unsigned int GetLargestFreeMemoryBlockByType(short memoryType)
Definition memapi.c:139
void SetPersonnelCursorPosition(int x, int y, short unused1, short unused2)
Definition main.c:16
void TryBeginStarSystemJump(void)
Definition jump.c:135
void auto_pilot_sequence(void)
Definition auto.c:100
void ClearTargetCameraView(void)
Definition turret.c:718
void set_up_action_sphere(short navPoint)
Definition mission.c:923
short FixedToShortSaturating(int value)
Definition geom.c:122
void FlushInputEvents(void)
Definition eventmgr.c:1014
short MinShort(short a, short b)
Definition disk.c:27
short any_enemy(short obj, short range)
Definition logic.c:610
void DIBslamReal(void)
Definition dib.cpp:562
unsigned int clear_view_buffer(void)
Definition main.c:277
void ReportFramesSkipped(short adjustment)
Definition message.c:217
void InvalidateVduMode(short i)
Definition cockpt.c:714
void players_flight_dynamics(void)
Definition main.c:620
void ShowOnScreenMessage(short duration, const char *format,...)
Definition message.c:151
void CopyViewportRuns(Viewport *source, Viewport *destination, const short *runs)
Definition gr.c:1614
void SetFrameTimerPeriodDirect(short p)
Definition eventmgr.c:1418
void CloseCommChoiceMenu(void)
Definition comm.c:105
void RenderSpaceViewFrame(void)
Definition main.c:1705
void LoadOriginFxDrivers(void)
Definition startup.c:70
void ClearHudMessageDisplay(short closeCommMenu)
Definition cockpt.c:2171
short RunSelectedCampaign(void)
Definition campaign.c:346
void copy_frame(short source, short destination)
Definition geom.c:470
short RunPilotDatabaseMenu(void)
Definition personnel.c:1400
void ShowMemoryStatusDebug(void)
Definition message.c:54
short RunTitleScreen(void)
Definition titlemnu.c:262
void CheckAllGuardedAllocations(void)
Definition winmain.c:801
short BarracksScreen(void)
Definition titlemnu.c:499
void * AllocateTaggedMemory(unsigned int size, short flags)
Definition memapi.c:92
short LoadWingCmdrCfgFile(short argc, char **argv)
Definition config.c:10
void update_cockpit(void)
Definition cockpt.c:3655
void StopMusicIfDriverActive(void)
Definition startup.c:381
void SelectNextExternalViewObject(void)
Definition main.c:261
void WaitForVerticalBlankThunk(void)
Definition eventmgr.c:189
void force_view(int view, short obj)
Definition spc.c:423
void Chosen_communicate_option(short choice)
Definition comm.c:378
void TranslatePolledInputEvent(unsigned short type, unsigned int value)
Definition eventmgr.c:550
void ProcessCannedSceneInput(void)
Definition replay.c:244
unsigned int GetF1KeyLatch(void)
Definition winmain.c:17
void draw_sorted_objects_to_buffer(void)
Definition eventmgr.c:1700
short IsCockpitWeaponShapeLoaded(void)
Definition cockpt.c:3699
void overlay_head_up_display(void)
Definition cockpt.c:2564
void fire_fixed_projectile_weapon(short obj)
Definition ship.c:2714
short LoadSelectedPilotCampaign(void)
Definition personnel.c:244
void malf_sound(void)
Definition cockpt.c:802
short ReadCalibratedJoystick(void)
Definition joycal.c:147
void ResetCockpitPaletteEntries(void)
Definition fltsetup.c:76
void FinalizeInputManagerHook(void)
Definition eventmgr.c:1896
void LoadTemporaryCampaignGlobals(void)
Definition campglob.c:180
void UpdateSpacePaletteFade(void)
Definition main.c:327
int GetControlKeyState(void)
Definition winmain.c:1136
unsigned int update_star_field(void)
Definition spc.c:710
void ReportOutOfMemoryAndExit(const char *resource)
Definition message.c:101
void Update_3Space(void)
Definition main.c:294
void RestoreTransientCockpitGraphics(void)
Definition cockpt.c:2701
short FindNearestNavPoint(short ship)
Definition main.c:1753
void BeginInflightReplayHook(void)
Definition replay.c:11
short MeasureMessageWidth(const char *text)
Definition main.c:895
void WaitForFrameTick(void)
Definition eventmgr.c:1424
void ClearViewport(Viewport *viewport, short colour)
Definition gr.c:1027
void init_inflight_music(void)
Definition fltsetup.c:935
short calculate_damage_level(void)
Definition main.c:1890
void SetMessageDisplaySpeed(void)
Definition message.c:205
void place_exhaust_on_ships(void)
Definition ship.c:2771
void SetHudMessageText(char *text, unsigned short colour, unsigned short duration)
Definition cockpt.c:2742
void reposition_fixed_child_objects(void)
Definition ship.c:2863
short player_input(void)
Definition main.c:665
void FlushSoundEffectsAndLog(void *effect, short flags)
Definition music.c:439
void SetHudTextColour(char *text, unsigned short colour)
Definition cockpt.c:2159
void ToggleTargetCameraOverlay(void)
Definition turret.c:676
void SetPersonnelMousePosition(short x, short y)
Definition mousepos.c:9
void PlaySfxWaveFileByNumber(int soundNumber, int sourceObject, int looping)
Definition music.c:490
void FadeFlightPaletteEntry(short *entry)
Definition main.c:316
void process_player_input(void)
Definition main.c:442
void initialize_cockpit(signed char mode)
Definition fltsetup.c:100
unsigned int new_view(int view, short obj)
Definition spc.c:451
void house_keep(void)
Definition main.c:349
void RunGameApplication(short argc, char **argv)
Definition main.c:89
void transform_objects_to_your_view(void)
Definition geom.c:1022
void SetMenuInputPump(void)
Definition eventmgr.c:2106
short IsInputEventQueued(int type)
Definition main.c:657
void ReleaseSceneMusicPacket(void)
Definition gameflow.c:894
void ConfigureDefaultSpacePalette(short mode)
Definition palalloc.c:11
void flag_objective(short objective, unsigned char flags)
Definition cockpt.c:1153
void InitializeCampaignConstellationState(CampaignGlobals *globals, short copyPosition)
Definition campglob.c:98
void TriggerPlayerHitPaletteFlash(void)
Definition main.c:309
void AcknowledgeModalMessage(void)
Definition main.c:902
unsigned int ReleaseStaleNavTarget(void)
Definition main.c:1769
short Draw_3Space_Frame(void)
Definition main.c:1732
void ShowVersionBanner(void)
Definition message.c:198
int GetShiftKeyState(void)
Definition winmain.c:1124
unsigned int set_eye_direction_and_position(void)
Definition spc.c:72
void accelerate(short amount)
Definition ship.c:3017
void MessagePumpHook(int mode)
Definition memapi.c:24
void RestoreCockpitExplosionIfVisible(void)
Definition cockpt.c:2692
void SetSoundEffectsVolume(int volume)
Definition sound.c:413
void free_view_buffer(void)
Definition main.c:208
unsigned short RandomInRange(unsigned short lo, unsigned short hi)
Definition eventmgr.c:31
void servicetrack(void)
Definition music.c:318
void update_objects_in_space(void)
Definition spc.c:1051
unsigned int GetKeyboardModifiers(void)
Definition winmain.c:1130
void SetFrameTimerAndWait(short period)
Definition eventmgr.c:1411
void EMShutDown(void)
Definition startup.c:38
void MarkDibDirty(void)
Definition dib.cpp:532
void SelectCockpitVduMode(short vdu, int mode)
Definition cockpt.c:3729
void SetDefaultFrameTiming(void)
Definition dib.cpp:202
int GetNextInputEvent(InputEventState *event)
Definition eventmgr.c:800
void ResetCannedSceneRecording(void)
Definition taperec.c:20
void CopyViewportContents(Viewport *source, Viewport *destination)
Definition gr.c:995
void FlushPendingInputEvents(void)
Definition eventmgr.c:2157
void check_hazards(void)
Definition fields.c:428
short find_objective(short type, short index)
Definition jump.c:14
short message_showing(void)
Definition cockpt.c:726
Shared Win32 declarations, types and library interfaces.
@ SIDE_KILRATHI
Definition game_data.h:176
@ OBJECTIVE_HOLD_FORMATION
Definition game_data.h:147
@ SPECIAL_MANEUVER_BLOWING_UP
Definition game_data.h:268
@ SPECIAL_MANEUVER_AFTERBURNER
Definition game_data.h:261
@ SPECIAL_MANEUVER_NONE
Definition game_data.h:259
@ MANEUVER_WARPING_OUT
Definition game_data.h:210
@ OBJECT_CLASS_SHIP
Definition game_data.h:49
@ OBJECT_CLASS_NULL
Definition game_data.h:37
short g_nShowMemoryStatus
Definition main.c:1948
HostMouseMessage g_6_stHostMouseTextBlock
Definition winmain.c:1384
short g_anFlightInput[3]
Definition viewrect.c:50
int g_27_nLastAltCommandScanNumberWord
Definition winmain.c:1393
short g_1_bDiscreteFlightInputWaiting
Definition main.c:1999
int g_1_bSpaceFlightActive
Definition main.c:2004
short g_nExternalViewShip
Definition viewrect.c:74
short g_nSpaceBlastFlashIncrement
Definition main.c:2006
short g_nCurStellarSystem
Definition nav.c:1238
signed char g_acPlayerComponentDamage[9]
Definition viewrect.c:76
short g_nEnemyTauntCommandBase
Definition comm.c:9
short g_nFrameSkip
Definition main.c:1940
short g_nYourWingman
Definition viewrect.c:75
int g_nCockpitDisplayMode
Definition main.c:1929
short g_78_bHighMemoryBuffersSetState
Definition cockpt.c:3839
signed char g_bVideoImagesSuppressed
Definition comm.c:15
short g_anObjectRollRotation[SPACE_OBJECT_COUNT]
Definition viewrect.c:119
short g_anPreviousFlightInput[3]
Definition viewrect.c:51
InputDeviceSample g_10_stPrevFlightControls
Definition main.c:1996
short g_bSpeechEnabledFlag
Definition startup.c:598
short g_asMousePitchThresholds[6]
Definition main.c:1969
int g_bJoystickCalibrationHotkey
Definition winmain.c:1397
short g_nPendingEjectionSequenceCount
Definition mission.c:14
int g_bFlightButtonOneHeld
Definition main.c:1964
signed char g_bSceneEscapeRequested
Definition eventmgr.c:2420
const ScreenViewportGeometry *volatile g_15_pScreenViewportGeometry
Definition eventmgr.c:2519
int g_nCurrentView
Definition spc.c:11
unsigned int g_dwInitialSpareMemory
Definition startup.c:590
short g_nMouseYawInput
Definition main.c:1975
short g_aeObjectClass[SPACE_OBJECT_COUNT]
Definition viewrect.c:125
short g_nSelectedReleaseWeaponIndex
Definition viewrect.c:84
char * g_pszPendingHudMessage
Definition cockpt.c:32
short g_nCurSeries
Definition main.c:2005
short g_bDirectCampaignSelection
Definition startup.c:580
signed char g_acShipTarget[16]
Definition viewrect.c:167
short g_anObjectYawRotation[SPACE_OBJECT_COUNT]
Definition viewrect.c:118
short g_asObjectType[SPACE_OBJECT_COUNT]
Definition viewrect.c:124
char * g_pInitialArguments[31]
Definition main.c:2003
short g_nCannedSceneRecordedFrameCountNumber
Definition taperec.c:324
int g_bFullScreenSpaceView
Definition main.c:1928
short g_9_aasCockpitHitPaletteFades[6][3]
Definition message.c:235
short g_nEjectionSequenceState
Definition mission.c:16
CampaignGlobals * g_pCampaignGlobals
Definition gameflow.c:3707
int g_2_bAltFHotkeyFlag
Definition winmain.c:1395
InputDeviceSample g_stCurrentFlightInput
Definition main.c:1959
ObjectTypeData g_aObjectTypeData[OBJECT_DATA_COUNT]
Definition campglob.c:310
MissionNavPoint g_aMissionNavPoints[MISSION_NAV_POINT_COUNT]
Definition hotspot.c:237
short g_5_nStorageAdjustmentKbValue
Definition startup.c:593
short g_nCockpitControlGoal
Definition main.c:1965
short g_nSpaceFramePeriod
Definition main.c:1941
signed char g_cViewObject
Definition viewrect.c:34
short g_19_bPolledFlightInputQueued
Definition main.c:2010
int g_bFlightButtonTwoHeld
Definition main.c:1963
MouseCursorState g_37_stPersonnelMousePointerState
Definition eventmgr.c:2544
short g_nSpaceExplosionFlashActive
Definition spc.c:14
short g_aeSpecialManeuver[12]
Definition viewrect.c:141
int g_bDebugBreakEnabled
Definition winmain.c:1346
short g_nSelectedCampaignSlot
Definition campaign.c:354
signed char g_acMissionShipStatusFlagsBytes[8]
Definition logic.c:1054
void * g_pMemoryAdjustment
Definition main.c:1949
unsigned short g_18_nHudMessageColour
Definition cockpt.c:3819
signed char g_bMouseMoveEventQueued
Definition main.c:1974
short g_bJumpSequenceActive
Definition jump.c:10
short g_asShipWeaponEnergy[10]
Definition viewrect.c:136
short g_12_wInputDeviceButtonStatus
Definition eventmgr.c:2531
unsigned char g_ucPendingEjectionTransition
Definition mission.c:11
short g_nCurrentLevel
Definition main.c:2009
short g_nMenuSelectedCol
Definition main.c:2007
short g_bViewportDirty
Definition main.c:1942
short g_nDirectSeries
Definition main.c:1954
int g_bMenuAHotkey
Definition winmain.c:1401
short g_bPlayerCollisionEnabled
Definition main.c:1947
short g_nSpaceFrame
Definition viewrect.c:32
short g_6_wQueuedButtonsState
Definition eventmgr.c:2499
short g_6_bMissionWingmanState
Definition turret.c:1287
short g_asObjectDamage[SPACE_OBJECT_COUNT]
Definition viewrect.c:121
unsigned char g_26_bMouseCursorEnabled
Definition eventmgr.c:2506
short g_bMissileCameraEnabled
Definition viewrect.c:93
short g_bTargetLockMode
Definition viewrect.c:92
short g_anObjectPitchRotation[SPACE_OBJECT_COUNT]
Definition viewrect.c:117
short g_bDisplayWingmanTargetData
Definition viewrect.c:77
short g_nRenderedSpaceFrame
Definition viewrect.c:33
signed char g_cPreviousKey
Definition viewrect.c:30
int g_4_bMenuBHotkey
Definition winmain.c:1400
short g_nSpacePaletteFadeMode
Definition palalloc.c:8
short g_bCarrierLandingEnabled
Definition main.c:1945
int g_nArcadeState
Definition main.c:1938
int g_bAltNumpadSubtractShortcut
Definition winmain.c:1406
MAIN_STATIC short g_wSavedInputDeviceButtonState
Definition globals.h:1715
short g_bRewritePacketExtensions
Definition startup.c:543
int g_anShipSpeed[SPACE_OBJECT_COUNT]
Definition viewrect.c:116
PilotProfile g_stDefaultPilotProfile
Definition campaign.c:8
short g_nMissionEntryNavOverride
Definition main.c:1951
short g_aSpaceExplosionFlashPalette[13][3]
Definition main.c:1977
unsigned char g_88_nEventRepeatDelayState
Definition eventmgr.c:2500
short g_nScreenHeight
Definition eventmgr.c:2431
int g_10_bPlayerInputActive
Definition main.c:2013
unsigned char g_cRedColour
Definition startup.c:548
Viewport g_27_stViewScratchInfo
Definition cockpt.c:3841
unsigned char g_ucPrimaryTextColour
Definition startup.c:550
short g_nCockpitControlState
Definition main.c:1958
short g_1_asSpacePaletteFade[3]
Definition message.c:241
int g_6_bAltDChordState
Definition winmain.c:1396
int g_6_bMenuTHotkeySwitch
Definition winmain.c:1402
int g_nSfxVolumeSetting
Definition main.c:1934
short g_14_nCurrentGraphicsModeDetectedValue
Definition eventmgr.c:2498
short g_bDeveloperCampaignReady
Definition campaign.c:10
FixedVector g_aShipPosition[SPACE_OBJECT_COUNT]
Definition viewrect.c:108
int g_39_bAltNumpadAddHotkeySwitch
Definition winmain.c:1392
unsigned char g_cPrimaryViewBufferColour
Definition startup.c:559
signed char g_cMessageSpeed
Definition comm.c:12
short g_nTargetCameraFrame
Definition turret.c:1239
short g_asShipManeuver[12]
Definition viewrect.c:169
int g_anVolumeLevels[11]
Definition main.c:1930
short g_19_bStoredHighMemoryEnabled
Definition eventmgr.c:2505
InputDeviceSample g_aInputDeviceSamplesList[2]
Definition joystick.c:75
short g_bPlayerDamageEnabled
Definition main.c:1946
Viewport g_101_stScrViewInfo
Definition cockpt.c:3831
int g_4_nSevereDmgWarningSfxHandle
Definition cockpt.c:3816
MAIN_STATIC int g_bMouseFireButtonLatched
Definition globals.h:1714
short g_asMouseYawThresholds[6]
Definition main.c:1966
short g_nCommMenuChoiceCount
Definition comm.c:10
short g_nMousePitchInput
Definition main.c:1976
int g_nTrainSimActive
Definition main.c:1937
signed char g_1_cStoredViewDisplayModeValue
Definition eventmgr.c:2515
int g_2_bAltHHotkey
Definition winmain.c:1399
int g_bRenderingSpaceFrame
Definition main.c:1992
InputEvent g_3_aInputEventArray[0x100]
Definition main.c:2012
short g_aeShipObjective[12]
Definition viewrect.c:166
PilotNameVariables g_stPilotNameVariables
Definition gameflow.c:3762
signed char g_cCurrentKey
Definition viewrect.c:29
int g_bPauseInputActive
Definition message.c:13
Viewport g_stSecondaryViewBufferBlock
Definition message.c:234
signed char g_bSecondaryMouseButtonHeld
Definition main.c:1972
short g_wFlightInputButtonState
Definition main.c:1961
short g_8_nActiveInputDeviceWord
Definition joystick.c:57
short g_nOriginDevUnlock
Definition main.c:1944
MissionShipRecord g_aMissionShips[MISSION_SHIP_COUNT]
Definition hotspot.c:240
short g_bSpaceViewBufferEnabled
Definition main.c:1956
char g_szCannedSceneTapeFile[9]
Definition taperec.c:11
short g_aasShipArmor[10][4]
Definition viewrect.c:135
signed char g_acShipDamage[16]
Definition viewrect.c:148
short g_3_nOptionMessageColour
Definition main.c:2001
PilotProfile g_stCurrentPilotProfile
Definition viewrect.c:73
short g_nScreenWidth
Definition eventmgr.c:2430
short g_18_nInterfaceEventMode
Definition eventmgr.c:2570
signed char g_bParentDirectorySelected
Definition main.c:1950
int g_nMusicVolumeSetting
Definition main.c:1935
short g_nFrameSkipCountdown
Definition main.c:1939
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_nCurrentNavPoint
Definition viewrect.c:53
short g_5_nCannedSceneFrameCount
Definition taperec.c:329
short g_asObjectCounter[SPACE_OBJECT_COUNT]
Definition viewrect.c:110
short g_nCannedSceneMode
Definition taperec.c:14
MissionHeader g_13_stMissionHeaderBlock
Definition hotspot.c:253
signed char g_12_abCockpitLightGoalTable[7]
Definition cockpt.c:3815
short g_bMissionDeathSequencePending
Definition destroy.c:8
short g_nHazardFieldCount
Definition viewrect.c:58
short g_1_nResourcePaletteState
Definition main.c:2000
short g_bMemoryAdjustmentEnabled
Definition startup.c:584
short g_10_nMenuDarkColour
Definition main.c:2008
int g_6_nUnusedMainNumber1
Definition main.c:1998
int g_nUnusedMainWord6
Definition main.c:1962
int g_129_nUnusedMainNumber2[2]
Definition main.c:2016
int g_nUnusedMainWord2
Definition main.c:1952
int g_47_nUnusedMainValue1
Definition main.c:2014
short g_nCockpitCameraObject
Definition main.c:1943
int g_nUnusedMainWord4
Definition main.c:1957
short g_bMapPrimaryInputQueued
Definition main.c:1997
int g_47_nUnusedMainValue2[2]
Definition main.c:2015
int g_nUnusedMainWord7
Definition main.c:1973
int g_nUnusedMainWord3
Definition main.c:1955
struct DirectMissionSelection g_stDirectMissionSelection
Definition main.c:1953
short CtrlBreakHandler(void)
Definition main.c:83
int g_nUnusedMainWord1
Definition main.c:1936
int g_nUnusedMainWord5
Definition main.c:1960
short CheckHeap(void)
Definition main.c:72
int g_39_nIdleMainNumber[4]
Definition main.c:2011
short g_2_bFleetMouseMovePosted
Definition main.c:2002
int primaryButton
Definition game.h:182
int secondaryButton
Definition game.h:183
unsigned int buttons
Definition game.h:224
short status
Definition game.h:213
unsigned short modifiers
Definition game.h:215
short value
Definition game.h:212
struct Viewport * viewport
Definition game_data.h:610
short playerMissionShip
Definition game_data.h:1346
signed char systemIndex
Definition game_data.h:1329
FixedVector position
Definition game_data.h:1327
short proximityRadius
Definition game_data.h:1328
signed char type
Definition game_data.h:1326
signed char navPoint
Definition game_data.h:1371
volatile short y
Definition game.h:166
short frame
Definition game.h:173
struct InputPumpContext * context
Definition game.h:175
volatile short x
Definition game.h:165
short damageCapacity
Definition game_data.h:375
char callsign[24]
Definition globals.h:1692
char callsign[13]
Definition game_data.h:1115
unsigned char * pixels
Definition game.h:150
short right
Definition game.h:154
short bottom
Definition game.h:155
short left
Definition game.h:152
short top
Definition game.h:153