Wing Commander
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
eject.c
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup flight
4 * @brief Ejection and stranded-pilot sequences.
5 *
6 * Address range 4046a0-404ccf. The ejection data and literals precede the
7 * campaign unit's mouth-animation table.
8 */
9#include "wc1.h"
10
11static short asEjectionPrimaryFrames[8] = {
12 0, 1, 1, 3, 3, 0, 0, 0
13}; /* 0x00465550 */
14
15static short asEjectionSecondaryFrames[8] = {
16 -1, -1, 2, -1, 4, 0, 0, 0
17}; /* 0x00465560 */
18
19static short asEjectionViewScript[12] = {
20 3, 11, 14, 70, 3, 10, 14, 80, 3, 4, -1, 0
21}; /* 0x00465570 */
22
23static const char *pStrandedMessage =
24 "\nWith your carrier\ndestroyed, you drift\nendlessly through\n"
25 "the void..."; /* 0x00465588 */
26
27/* Linker commons defined here; LINK orders them by identifier hash. */
28char szSoundDebugMsg[512]; /* 0x005a8760 */
29struct Shape *pIntroFont; /* 0x005a8960 */
30
31/* Function start: 0x4046A0 */
32unsigned int ejection_sequence(void)
33{
34 FixedVector viewOffset;
35 short frame;
36 struct Shape *background;
37 short y;
38 struct Shape *ejectionShape;
39 short descentSpeed;
40 short spriteFrame;
41
45 spacetrack(0x1f, 2, 1);
46 frame = 0;
47 new_view(9, 0);
48 background = FetchDiskPacketRetrying(
49 (short)cCockpitLogicalFile, 3, 0);
50 ejectionShape = FetchDiskPacketRetrying(2, 1, 0);
51 PlaySfxWaveFileByNumber(0x21, -1, 0);
52 y = 199;
54 descentSpeed = 4;
56 do {
57 if (RefreshCockpitStatus() != 0) {
58 DrawSpriteDefault(&stSpaceBufferViewport, 0, 0, background, 0);
59 spriteFrame = MinShort(frame, 4);
61 &stSpaceBufferViewport, 160, y, ejectionShape,
62 asEjectionPrimaryFrames[spriteFrame]);
63 if (asEjectionSecondaryFrames[spriteFrame] != -1)
65 &stSpaceBufferViewport, 160, y, ejectionShape,
66 asEjectionSecondaryFrames[spriteFrame]);
67 DrawSpriteDefault(&stSpaceBufferViewport, 160, (short)(y + 1),
68 ejectionShape, 5);
70 }
71 if (frame > 1) {
72 y = (short)(y - descentSpeed);
73 descentSpeed = MinShort((short)(descentSpeed + 4), 20);
74 }
75 if (bEscapePressedFlag == 1)
76 break;
77 frame++;
78 DIBslam();
80 } while (frame < 10);
81
82 ReleasePacketHandle(ejectionShape);
83 ReleasePacketHandle(background);
85 if (bEscapePressedFlag != 1) {
90 0x40);
92 ReportOutOfMemoryAndExit("View Templates");
93 else
96
103 32000;
109 -0x500,
113 &aShipVelocity[0],
116
117 background = FetchDiskPacketRetrying(
118 (short)cCockpitLogicalFile, 0, 0);
119 ejectionShape = FetchDiskPacketRetrying(
120 (short)cCockpitLogicalFile, 5, 0);
121 PlaySfxWaveFileByNumber(0x22, -1, 0);
122 y = 40;
123 frame = 0;
125 do {
126 if (RefreshCockpitStatus() != 0) {
128 background, 0);
129 DrawSpriteDefault(&stSpaceBufferViewport, 0, (short)(y - 1),
130 ejectionShape, 0);
132 }
133 if (bEscapePressedFlag == 1)
134 break;
135 y = (short)(y + descentSpeed);
136 DIBslam();
137 frame++;
138 DIBslamReal();
139 } while (frame < 10);
140
141 ReleasePacketHandle(ejectionShape);
142 ReleasePacketHandle(background);
143 if (bEscapePressedFlag != 1) {
146 aShipUpVector[0];
150 aShipFwdVec[0];
154 -0x25800, &viewOffset);
157 &viewOffset,
163 SetMusBreakpt(0, 0);
164 frame = 0;
165 while (1) {
167 if (RefreshCockpitStatus() != 0)
169 switch (frame) {
170 case 10:
171 Explosion(0);
172 PlaySfxWaveFileByNumber(4, -1, 0);
173 break;
174 }
175 frame++;
176 if (frame > 200 || bEscapePressedFlag != 0)
177 break;
178 DIBslam();
179 DIBslamReal();
180 }
181 }
182 }
183
185 bScriptedView = 0;
186 if (pCurrentScreenViewportPkt != 0) {
189 }
192 DIBslam();
193 DIBslamReal();
198 return 0;
199}
200
201/* Function start: 0x404BE0 */
203{
204 short frame;
205
207 free_cockpit();
208 force_view(13, 0);
210 frame = 0;
211 do {
212 if (RefreshCockpitStatus() != 0) {
213 if (frame >= 300)
215 "THE END");
216 else if (frame >= 160)
220 }
221 if (bEscapePressedFlag != 0)
222 break;
223 frame++;
224 DIBslam();
225 DIBslamReal();
226 } while (frame < 400);
229 stScreenView.top = 0;
230 stScreenView.bottom = 199;
235}
static short asEjectionSecondaryFrames[8]
Definition eject.c:15
static const char * pStrandedMessage
Definition eject.c:23
static short asEjectionPrimaryFrames[8]
Definition eject.c:11
static short asEjectionViewScript[12]
Definition eject.c:19
unsigned char bEscapePressedFlag
Definition mathfp.c:24
ObjectTypeData aObjectTypeData[OBJECT_TYPE_COUNT]
Definition objdata.c:86
unsigned char cBlackColour
Definition init.c:12
short nFrameSkipCounter
Definition main.c:23
FixedVector aShipRightVector[64]
Definition smart.c:15
FixedVector aShipVelocity[SPACE_OBJECT_COUNT]
Definition smart.c:21
int bScriptedView
Definition view.c:14
signed char cCockpitLogicalFile
Definition logic.c:107
short nScriptedViewObject
Definition view.c:13
Viewport stScreenView
Definition launch.c:50
Viewport stSpaceBufferViewport
Definition timer.c:13
short asObjectCounterArray[SPACE_OBJECT_COUNT]
Definition game.c:547
int nCannedSceneMode
Definition main.c:21
FixedVector aShipUpVector[64]
Definition smart.c:16
short nEjectedPilotObject
Definition game.c:55
char szSoundDebugMsg[512]
Definition eject.c:28
ScreenViewportPacket * pCurrentScreenViewportPkt
Definition launch.c:49
FixedVector aShipPositionsArray[SPACE_OBJECT_COUNT]
Definition game.c:556
DiskFileRecord * pDiskFileRecords
Definition disk.c:36
FixedVector aShipFwdVec[64]
Definition smart.c:17
struct Shape * pIntroFont
Definition eject.c:29
struct Shape * shapeSet
Definition wcdata.h:393
short bottom
Definition wc1base.h:79
short top
Definition wc1base.h:77
Umbrella header for the game core.
void * AllocateTaggedMemory(int size, unsigned short flags)
Definition ending.c:31
unsigned int free_cockpit(void)
Definition logic.c:1876
void DIBslam(void)
Definition dib.c:513
unsigned int __stdcall GetPacketSize(const char *filename, short section)
Definition screen.c:368
void alter_pitch(short angle, short obj)
Definition geom.c:619
unsigned int force_view(int view, short obj)
Definition spc.c:464
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 set_objects_data(short obj, enum ObjectType type, short owner)
Definition ship.c:173
void __stdcall PromptInsertNumberedDisk(short logicalFile)
Definition disk.c:322
unsigned int spacetrack(int track, int mode, short enabled)
Definition music.c:411
void DrawSpriteDefault(Viewport *viewport, short x, short y, struct Shape *shape, short frame)
Definition gr.c:660
void RestoreGamePalette(void)
Definition winmain.c:76
void StopMusicUnlessSuppressed(void)
Definition music.c:419
short MinShort(short a, short b)
Definition mathutil.c:20
void * LoadPacketIntoBuffer(short logicalFile, short section, void *destination)
Definition disk.c:80
void stranded_sequence(void)
Definition eject.c:202
void DIBslamReal(void)
Definition dib.c:519
unsigned int PreloadMusicTrackHook(short track)
Definition logic.c:2044
unsigned int GetScreenUpdateFlag(void)
Definition main.c:361
void SetMusBreakpt(int first, int second)
Definition music.c:124
int free_all_slots(void)
Definition mission.c:397
void initialize_scripted_view(const short *script)
Definition view.c:175
void copy_frame(short source, short destination)
Definition geom.c:585
void __stdcall FadeViewportPaletteToColour(Viewport *viewport, unsigned short colour, short enabled)
Definition main.c:2213
int print_subtitle(Viewport *viewport, short colour, const char *text)
Definition mono.c:197
void ScaleFixedVector(const FixedVector *vector, int scale, FixedVector *result)
Definition geom.c:322
unsigned int ReleaseMusicTrackHook(short track)
Definition logic.c:2051
void ReportOutOfMemoryAndExit(const char *resource)
Definition main.c:1277
void ClearViewport(Viewport *viewport, short colour)
Definition gr.c:963
short find_vacant_3d_object(void)
Definition geom.c:987
unsigned int RefreshCockpitStatus(void)
Definition main.c:1948
short Explosion(short obj)
Definition ship.c:1200
void PlaySfxWaveFileByNumber()
unsigned int new_view(int view, short obj)
Definition spc.c:472
void ReleasePacketHandle(void *handle)
Definition ending.c:50
unsigned int ejection_sequence(void)
Definition eject.c:32
void FreePacketAndClear(void *slot, unsigned short releaseFlags)
Definition mathutil.c:37
int load_all_slots(void)
Definition mission.c:413
void negate_vector(FixedVector *vector)
Definition geom.c:288
unsigned int dump_buffer_to_screen(void)
Definition main.c:383
#define EYE_OBJECT
Definition wcdata.h:1006
@ OBJECT_TYPE_EJECTED_PILOT
Definition wcdata.h:111