Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
target.c
Go to the documentation of this file.
1/*
2 * Target display.
3 *
4 * Retail object 0x43FAC0-0x4401BF (link order; see docs/ORDER.md).
5 */
6#include "game.h"
7
9 { 12, -20, 29, 20 },
10 { -11, 1, 11, 20 },
11 { -11, -20, 11, 0 },
12 { -29, -20, -12, 20 }
13}; /* 0x0049b470 */
14char g_szEmptyTargetDisplayText[4] = ""; /* 0x0049b490 */
15
16/* WC2 reads the manoeuvre slot before it has checked the target, so with
17 * nothing targeted it reads the two bytes in front of the array. What lives
18 * there is not the blowing-up marker, so the port answers "no manoeuvre" for
19 * an unset target rather than reproduce the overrun. */
20#define SPECIAL_MANEUVER_OF(obj) g_aeSpecialManeuver[obj]
21
22/* Function start: 0x43FAC0 */
24{
25 short *maximumArmor;
26 short ship;
27 short cel;
28 short x;
29 Viewport clip;
30 short armor;
31 short y;
32 ObjectTypeData *typeData;
33
38 if (g_bTargetLockMode != 0 &&
41 "%F%s%F",
42 (unsigned int)g_cRedColour,
43 " LOCKED TARGET",
44 (unsigned int)g_ucDefaultTextColour);
45 } else {
46 DrawFormattedText("%F%s",
47 (unsigned int)g_ucDefaultTextColour,
48 " AUTO TARGETTING");
49 }
50 ship = g_acShipTarget[0];
51 if (ship != -1 && g_anShipCloakState[ship] == 1 &&
52 (g_asShipCloakElapsedFrames[ship] >= 40 ||
53 (g_asShipCloakElapsedFrames[ship] >= 20 &&
55 g_asShipCloakElapsedFrames[ship] - 20] == 1)))
56 ship = -1;
58 ship = g_nYourWingman;
59 if (ship != -1 &&
61 g_aeSpecialManeuver[ship] ==
63 g_acShipTarget[0] = -1;
64 ship = g_acShipTarget[0];
66 }
67 g_cTargetDisplayObject = (signed char)ship;
68 DrawFormattedText("\nTarget:");
69 if (ship == -1) {
70 DrawFormattedText(" None");
71 return;
72 }
73 typeData = &g_aObjectTypeData[g_acObjectType[ship]];
74 if (g_asShipIdentified[ship] != 0) {
76 g_apShipMissionRecord[ship]->name);
77 } else {
79 "UNKNOWN");
80 }
81 DrawFormattedText("\nRange : ");
83 if (g_asObjectScreenX[ship] == -32767 &&
86 return;
87 }
88 if (g_asShipIdentified[ship] != 0) {
89 x = (short)(g_4_stRightVduView.left + 0x25);
90 y = (short)(g_4_stRightVduView.top + 0x26);
91 cel = (short)(g_aasShipShield[ship][1] * 6 /
92 typeData->shieldAft);
93 cel = (short)((3 - MinShort(cel, 3)) * 2);
94 if (cel < 6) {
97 }
98 clip = g_4_stRightVduView;
99 maximumArmor = &typeData->armorFront;
100 for (armor = 0; armor < 4; armor++) {
101 clip.left =
102 (short)(g_aTargetArmorClipRects[armor].left + x);
103 clip.top =
104 (short)(g_aTargetArmorClipRects[armor].top + y);
105 clip.right =
106 (short)(g_aTargetArmorClipRects[armor].right + x);
107 clip.bottom =
108 (short)(g_aTargetArmorClipRects[armor].bottom + y);
109 if (g_aasShipArmor[ship][armor] >
110 maximumArmor[armor] >> 1) {
111 DrawSpriteDefault(&clip, x, y, typeData->shape, 0);
112 } else {
113 DrawSpriteDefault(&clip, x, y, typeData->shape, 1);
114 }
115 }
117 typeData->shape, 2);
118 cel = (short)(g_aasShipShield[ship][0] * 6 /
119 typeData->shieldFore);
120 cel = (short)((3 - MinShort(cel, 3)) * 2);
121 if (cel < 6) {
124 (short)(cel + 1));
125 }
126 }
127}
128
129#pragma function(strcpy, strlen)
130/* Function start: 0x43FF40 */
132{
133 short target;
134
135 target = g_acShipTarget[0];
137 target = g_nYourWingman;
139 g_acShipTarget[0] = -1;
142 return;
143 }
144 if (target != -1 &&
146 g_acShipTarget[0] = -1;
147 target = g_acShipTarget[0];
148 }
149 if (g_cTargetDisplayObject != target ||
150 g_nRenderedSpaceFrame % 8 == 0 ||
151 (target != -1 && g_anShipCloakState[target] == 1 &&
152 g_asShipCloakElapsedFrames[target] < 40)) {
153 set_new_vdu(1);
155 }
156 if (target != -1) {
157 if (g_asObjectScreenX[target] != -32767) {
158 if ((unsigned short)g_asObjectDistance[target] >
159 30000 ||
160 (unsigned short)g_asObjectDistance[target] < 0) {
162 "TOO FAR");
163 } else {
165 strlen(itoa((unsigned short)
167 target],
169 " m");
170 }
171 } else {
173 "----- m");
174 }
177 "DATA XMIT");
178 }
180 if (g_nTargetLockCountdown == 0) {
181 if (g_bTargetLockAcquired == 1)
183 } else if (g_bTargetLockReadoutDirty != 0) {
187 (short)(g_4_stRightVduView.bottom - 6),
192 }
193 }
194}
void DrawCockpitReadout(signed char slot, const char *text)
Definition cockpt.c:247
void show_target_disp(void)
Definition target.c:23
void DrawSpriteDefault(Viewport *viewport, short x, short y, unsigned char *shape, short frame)
Definition gr.c:682
short MinShort(short a, short b)
Definition disk.c:27
void InvalidateVduMode(short i)
Definition cockpt.c:714
void EraseCockpitReadoutRegion(Viewport *viewport, short left, short top, short right, short bottom, short colour)
Definition cockpt.c:139
void set_new_vdu(short vdu)
Definition cockpt.c:680
unsigned int InitializeCockpitReadout(signed char slot, TextContext *context)
Definition cockpt.c:237
void DrawTargetRangeReadout(void)
Definition target.c:131
void DrawFormattedText(const char *format,...)
Definition textfmt.c:103
void DrawTextAt(TextContext *context, int x, int y, const char *text, unsigned char alignment)
Shared Win32 declarations, types and library interfaces.
@ SPECIAL_MANEUVER_UNKNOWN_9
Definition game_data.h:269
@ OBJECT_CLASS_SHIP
Definition game_data.h:49
MissionShipRecord * g_apShipMissionRecord[10]
Definition viewrect.c:161
char g_szEmptyTargetDisplayText[4]
Definition target.c:14
short g_asObjectDistance[SPACE_OBJECT_COUNT]
Definition viewrect.c:104
short g_nYourWingman
Definition viewrect.c:75
unsigned char * g_18_pCockpitIndicatorShape
Definition message.c:229
short g_aeObjectClass[SPACE_OBJECT_COUNT]
Definition viewrect.c:125
short g_asShipIdentified[12]
Definition viewrect.c:182
signed char g_acShipTarget[16]
Definition viewrect.c:167
short g_aasShipShield[10][2]
Definition viewrect.c:134
short g_bTargetLockReadoutDirty
Definition viewrect.c:86
ObjectTypeData g_aObjectTypeData[OBJECT_DATA_COUNT]
Definition campglob.c:310
short g_asObjectScreenX[SPACE_OBJECT_COUNT]
Definition viewrect.c:95
short g_asShipCloakElapsedFrames[10]
Definition viewrect.c:181
short g_aeSpecialManeuver[12]
Definition viewrect.c:141
int g_anCloakVisibilityPattern[20]
Definition geom.c:555
short g_bTargetLockMode
Definition viewrect.c:92
short g_bDisplayWingmanTargetData
Definition viewrect.c:77
short g_nRenderedSpaceFrame
Definition viewrect.c:33
unsigned char g_cSecondaryViewBufferColour
Definition startup.c:544
ShortRect g_aTargetArmorClipRects[4]
Definition target.c:8
signed char g_cTargetDisplayObject
Definition viewrect.c:89
unsigned char g_cRedColour
Definition startup.c:548
Viewport g_4_stRightVduView
Definition cockpt.c:3842
int g_anShipCloakState[10]
Definition viewrect.c:179
char g_16_szTextBufferBuffer[256]
Definition cockpt.c:3793
unsigned char g_ucDefaultTextColour
Definition startup.c:556
TextContext g_1_stRightVduTextContextBlock
Definition message.c:237
short g_bTargetLockAcquired
Definition viewrect.c:91
short g_aasShipArmor[10][4]
Definition viewrect.c:135
signed char g_acObjectType[SPACE_OBJECT_COUNT]
Definition viewrect.c:101
short g_nTargetLockCountdown
Definition viewrect.c:87
unsigned char * shape
Definition game_data.h:393
short right
Definition game.h:154
short bottom
Definition game.h:155
short left
Definition game.h:152
short top
Definition game.h:153
#define SPECIAL_MANEUVER_OF(obj)
Definition target.c:20