Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
damage.c
Go to the documentation of this file.
1/*
2 * Cockpit damage display.
3 *
4 * Retail object 0x401120-0x40181F (link order; see docs/ORDER.md).
5 */
6#include "game.h"
7
8unsigned char *g_pDamageDisplayBackground = 0; /* 0x00490060 */
10 {36, 37}, {36, 28}, {36, 30}, {36, 23}, {36, 19},
11 {36, 15}, {36, 24}, {36, 16}, {36, 22}
12}; /* 0x00490068 */
13const char *g_apszComponentNames[9] = {
14 "Ion drive",
15 "Power plant",
16 "Shield gen'r",
17 "Computer sys",
18 "InterCom unit",
19 "Target track",
20 "Acc. absorbers",
21 "Ejector system",
22 "Repair systems"
23}; /* 0x00490090 */
24unsigned char g_abDamageDisplayFrames[9] = {
25 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28
26}; /* 0x004900b8 */
27const char *g_apszDamageSeverityNames[5] = {
28 "Ok",
29 "Light",
30 "Moderate",
31 "Heavy",
32 "Destroyed"
33}; /* 0x004900c8 */
34
35/* Function start: 0x401120 */
37{
38 char message[40];
39 signed char plural;
40 signed char component;
41
44 for (component = 0; component < 9; component++) {
45 if (g_acPlayerComponentDamage[component] >= 1)
47 }
48
49 set_new_vdu(0);
53 "DAMAGE REPORT", 2);
60 if (g_cDamagedPartCount == 0) {
64 "NO INTERNAL\n\nDAMAGE", 2);
65 } else {
79 }
80 if (g_cDamagedPartCount != 1)
81 plural = 's';
82 else
83 plural = ' ';
84 sprintf(message, "%d Unit%c Damaged",
85 (int)g_cDamagedPartCount, (int)plural);
88 }
89}
90
91/* Function start: 0x4012E1 */
93{
94 short componentCount;
95 signed char component;
96 signed char attempts;
97 signed char damage;
98
99 componentCount = (short)g_cDamagedPartCount;
101 for (attempts = 0; attempts < 9; attempts++) {
102 if (g_acPlayerComponentDamage[attempts] >= 1)
104 }
105
106 if ((short)g_cDamagedPartCount != componentCount) {
108 return;
109 }
110 if (g_cDamagedPartCount == 0)
111 return;
112
113 if (g_nCockpitDisplayMode == 0) {
118 component = g_cDamageDisplayPart;
119 for (attempts = 0; attempts < 9; attempts++) {
120 component++;
121 if (component >= 9)
122 component = 0;
123 damage = g_acPlayerComponentDamage[component];
124 if (damage >= 1) {
125 g_cDamageDisplayPart = component;
126 break;
127 }
128 }
129
130 sprintf(
132 "%s\nDamage: %s",
135 g_apszDamageSeverityNames[(int)damage]);
141 (signed char)g_abDamageDisplayFrames[
146 /* CL 4.1 folds ~~ after ordering operands, preserving the
147 * retail origin-first loads without extra instructions. */
149 (short)(g_stHarmSpritePosition.x +
152 (short)(g_stHarmSpritePosition.y +
160 (short)g_cDamageDisplayFrame);
172 (short)g_cDamageDisplayFrame);
173 } else {
180 (short)g_cDamageDisplayFrame);
197 }
200 }
201 } else {
206 component = g_cDamageDisplayPart;
207 for (attempts = 0; attempts < 9; attempts++) {
208 component++;
209 if (component >= 9)
210 component = 0;
211 damage = g_acPlayerComponentDamage[component];
212 if (damage >= 1) {
213 g_cDamageDisplayPart = component;
214 g_nDisplayedComponentDamage = (int)damage;
215 break;
216 }
217 }
218 }
221 }
222
223 sprintf(
225 "%s\nDamage: %s",
234 (signed char)g_abDamageDisplayFrames[
240 (short)(g_stHarmSpritePosition.x +
243 (short)(g_stHarmSpritePosition.y +
251 (short)g_cDamageDisplayFrame);
261 (short)g_cDamageDisplayFrame);
262 }
263}
264
265/* Linker commons defined here. LINK lays a unit's commons out by the
266 * identifiers' hash keys, so these spellings follow the original addresses. */
267short g_68_nDamageShowTicksNumber; /* 0x005d4250 */
268char g_15_nUnusedDamageWordNumber; /* 0x005d4252 */ /* never referenced */
269short g_5_nWeaponDisplayOriginXValue; /* 0x005d4254 */
270short g_nArmsDisplayOriginY; /* 0x005d4256 */
271char g_12_szDamageStatusText[70]; /* 0x005d4260 */
272signed char g_cDamageDisplayPart; /* 0x005d42a6 */
273signed char g_cDamagedPartCount; /* 0x005d42a7 */
274int g_nDisplayedComponentDamage; /* 0x005d42a8 */
275signed char g_cDamageDisplayFrame; /* 0x005d42ac */
276short g_15_nDamageDisplayState; /* 0x005d42ae */
278short g_104_nHarmDisplayPhaseValue; /* 0x005d42b4 */
char g_15_nUnusedDamageWordNumber
Definition damage.c:268
void DrawViewportLine(Viewport *viewport, short x1, short y1, short x2, short y2, short colour)
Definition gr.c:1060
void UpdateDamageDisplay(void)
Definition damage.c:92
void DrawSpriteDefault(Viewport *viewport, short x, short y, unsigned char *shape, short frame)
Definition gr.c:682
void InvalidateVduMode(short i)
Definition cockpt.c:714
void show_damage_disp(void)
Definition damage.c:36
void CaptureSpriteBackground(Viewport *viewport, unsigned char *background, short x, short y, unsigned char *shape, short frame)
Definition gr.c:705
void ShowComponentHitHudMessage(const char *text, unsigned short colour, short flashCount)
Definition cockpt.c:830
void RestoreSpriteBackground(Viewport *viewport, unsigned char *background, short x, short y, unsigned char *shape, short frame)
Definition gr.c:846
void set_new_vdu(short vdu)
Definition cockpt.c:680
void DrawTextAt(TextContext *context, int x, int y, const char *text, unsigned char alignment)
Shared Win32 declarations, types and library interfaces.
short g_104_nHarmDisplayPhaseValue
Definition damage.c:278
signed char g_acPlayerComponentDamage[9]
Definition viewrect.c:76
int g_nCockpitDisplayMode
Definition main.c:1929
short g_15_nDamageDisplayState
Definition damage.c:276
unsigned char * g_1_pDashWeaponPicture
Definition cockpt.c:3844
short g_68_nDamageShowTicksNumber
Definition damage.c:267
ShortPoint g_stWeaponDisplayOffset
Definition cockpt.c:12
short g_nArmsDisplayOriginY
Definition damage.c:270
unsigned char g_cSecondaryViewBufferColour
Definition startup.c:544
unsigned char g_abDamageDisplayFrames[9]
Definition damage.c:24
ShortPoint g_stHarmSpritePosition
Definition damage.c:277
unsigned char g_ucPrimaryTextColour
Definition startup.c:550
signed char g_cDamagedPartCount
Definition damage.c:273
Viewport g_2_stLeftwardVduPortBlock
Definition cockpt.c:3830
char g_12_szDamageStatusText[70]
Definition damage.c:271
short g_5_nWeaponDisplayOriginXValue
Definition damage.c:269
TextContext g_5_stLeftVduStringContextRecord
Definition cockpt.c:3840
unsigned char * g_pDamageDisplayBackground
Definition damage.c:8
int g_bForceDamageDisplayRedraw
Definition cockpt.c:110
signed char g_cDamageDisplayFrame
Definition damage.c:275
ShortPoint g_aDamageDisplayPositions[9]
Definition damage.c:9
int g_nDisplayedComponentDamage
Definition damage.c:274
signed char g_cDamageDisplayPart
Definition damage.c:272
const char * g_apszDamageSeverityNames[5]
Definition damage.c:27
const char * g_apszComponentNames[9]
Definition damage.c:13
unsigned char colour
Definition game.h:288
short right
Definition game.h:154
short left
Definition game.h:152
short top
Definition game.h:153