Wing Commander
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
title.c
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup campaign
4 * @brief Opening cinematic, credits and title menu.
5 *
6 * Address range 40fa30-4102af.
7 */
8#include "wc1.h"
9#include <sys/stat.h>
10
11/* 0x00468910 */
12static char *pszIntroOpeningText =
13 "In the distant future,\n"
14 "mankind is locked in a deadly war...";
15/* Retained original message; no references survive in the shipped code. */
16/* 0x00468918 */
18 "The SECRET MISSIONS files are not present on your WING COMMANDER game disk\n\n"
19 "If you have not obtained the SECRET MISSIONS disk package, purchase it from "
20 "ORIGIN for $19.95 (US dollars) by calling 1-800-999-4939, Mon-Fri 8am-5pm "
21 "central.\n(Price and availability subject to change).";
22static int nIntroCreditCount = 11; /* 0x00468a30 */
23/* 0x00468a38 */
24static char *apszIntroCredits[20] = {
25 "Design\nby\nChris Roberts",
26 "Software Engineers\nChris Roberts\nKen Demarest III\nPaul C. Isaac\nSteve Muchow\nHerman Miller\nSteve Beeman\n",
27 "Dogfight Intelligence\nKen Demarest III\n\nDogfight Choreography\nSteve Beeman\nErin Roberts",
28 "3Space System\nby\nChris Roberts\n\nOriginFX Graphic System\nChris Roberts\nJohn Miles",
29 "OriginFX Sound System\nby\nHerman Miller",
30 "Artwork\nDenis Loubet\nGlen Johnson\nDaniel Bourbonnais\nKeith Berdak\nJohn Watson",
31 "Screenplay by Jeff George\n\nAdditional Writing\nSteve Cantrell\nPhilip Brogden",
32 "Soundtrack by\nGeorge A. Sanger and Dave Govett",
33 "Sound Effects by Marc Schaefgen",
34 "Produced by\nChris Roberts and Warren Spector",
35 "Directed by\nChris Roberts",
36 "Windows 95 Team",
37 "Combat Programmers\n\nJeff Mangler Everett\nJeff jefftep Grills\nChuck Bishop Karpiak\nKris Goblin Pelley",
38 "Sound System\n\nRichard Cupcake Lyle",
39 "Soundtrack Rescored by\n\nI Need Names",
40 "Head Whiner\n\nAnthony Sommers",
41 "Whiners\n\nMonte Mathis\nHal Milton\nDieter Martin",
42 "Richard Zinser\nKanon Lillemon\n",
43 "Special Thanks To\n\nSocks\nand\nCaffeine",
44 0
45};
46
47/* 0x00468a88 */
49 { 1, 49, 48, 283, 99 },
50 { 1, 49, 91, 283, 149 },
51 { 1, 49, 134, 283, 149 },
52 { 1, 49, 177, 283, 209 },
53 { -1, 0, 0, 0, 0 }
54};
55
56/* 0x00468ac0 */
64
65static int bTitleMenuSceneInitialized = 0; /* 0x00468ad8 */
66
67/* Linker commons defined here; LINK orders them by identifier hash. */
68short nExternalViewAngle; /* 0x005a7f06 */
69struct Shape *pTitleShape; /* 0x005a7f08 */
70
71/* Function start: 0x40FA30 */
72unsigned short GetPaletteReadyUnused(void)
73{
74 return 1;
75}
76
77/* Function start: 0x40FA40 */
78void DrawTitleLogo(short distance, short y)
79{
80 ShortRect bounds;
81 short scale;
82
83 if (distance <= 10)
84 return;
85 scale = (short)(0x1000 / distance);
87 (short)(nScreenWidth >> 1), y,
88 pTitleShape, 1, 0, scale, 0,
89 &bounds);
90 DrawSpriteScaled(&stSpaceBufferViewport, (short)(bounds.left - 1), y,
91 pTitleShape, 0, 0, scale, 0);
93 (short)(nScreenWidth >> 1), y,
94 pTitleShape, 1, 0, scale, 0);
96 pTitleShape, 2, 0, scale, 0);
97}
98
99/* Function start: 0x40FB10 */
101{
102 short mouseX;
103 short mouseY;
104 short frame;
105 TitleMenuRegion *region;
106
107 frame = 0;
108 mouseX = stHostMouseState.x;
109 mouseY = stHostMouseState.y;
110 for (region = aTitleMenuRegions; region->frame != -1; region++) {
111 if (IsPointInRect(mouseX, mouseY,
112 &region->left) != 0)
113 frame = region->frame;
114 }
116}
117
118/* Function start: 0x40FB70 */
120{
121 short frame;
122 short credit;
123 short titleDistance;
124 short missionShip;
125 short menuIndex;
126 int optionCount;
127 short eventType;
128 short menuOptions[4];
129 struct Shape *menuShape;
130 struct Shape *alternateMenuShape;
131 InputEventState event;
132 int activate;
133 signed char state;
134 signed char selectedIndex;
135
136 state = 0;
139 if (bEscapePressedFlag == 0) {
145 pIntroFont =
147 nSceneResourceBudgetValue = 0x3e8000;
149 aIntroResourceDescriptors, 0, 0x3e8000);
156
157 while (state == 0) {
159 for (missionShip = 32; missionShip < 46; missionShip++) {
160 aMissionShips[missionShip].state = 0;
161 }
162 titleDistance = 200;
168 spacetrack(0x17, 2, 1);
171
172 for (frame = 0; frame < 25; frame++) {
174 if (Draw_3Space_Frame() != 0) {
178 DIBslam();
179 DIBslamReal();
181 if (CheckEscaped() != 0) {
182 state++;
183 break;
184 }
185 }
186 }
188 if (state != 0)
189 break;
190
191 frame = 0;
192 do {
195 if (CheckEscaped() != 0) {
196 state++;
197 break;
198 }
199 frame++;
200 DIBslam();
201 DIBslamReal();
202 } while (frame < 110);
203 if (state != 0)
204 break;
205
206 for (frame = 0; frame < 100; frame++) {
208 if (Draw_3Space_Frame() != 0) {
209 DrawTitleLogo(titleDistance,
210 (short)(nCurrentViewCenterPosY - 6));
212 DIBslam();
213 DIBslamReal();
215 }
216 if (titleDistance > 16)
217 titleDistance -= 4;
218 if (CheckEscaped() != 0) {
219 state++;
220 break;
221 }
222 }
224 if (state != 0)
225 break;
226
227 ScaleFixedVector(&aShipFwdVec[61], 0x9600,
228 &aShipVelocity[61]);
231 anObjPitchRot[0] = 0;
232 anObjectYawRotation[0] = 0;
235
236 credit = 0;
237 for (; credit < nIntroCreditCount; credit++) {
238 for (frame = 0; frame < 70; frame++) {
240 if (Draw_3Space_Frame() != 0) {
242 apszIntroCredits[credit]);
244 DIBslam();
245 DIBslamReal();
247 }
248 if (CheckEscaped() != 0) {
249 state++;
250 break;
251 }
252 }
253 if (state != 0)
254 break;
255
256 for (frame = 0; frame < 40; frame++) {
259 DIBslam();
260 DIBslamReal();
261 if (CheckEscaped() != 0) {
262 state++;
263 break;
264 }
265 }
266 }
267 if (state != 0)
268 break;
269
270 for (frame = 0; frame < 150; frame++) {
273 DIBslam();
274 DIBslamReal();
275 if (CheckEscaped() != 0) {
276 state++;
277 break;
278 }
279 }
280 }
281
282 state = 0;
292 free_3Space();
295 bScriptedView = 0;
298 }
299
304 }
305 menuShape = FetchDiskPacketRetrying(9, 4, 0);
306 alternateMenuShape =
307 FetchDiskPacketRetrying(0x4b, 0, 0);
308 menuOptions[0] = 0;
309 optionCount = 1;
310 if (AnySavedGames() != 0) {
311 optionCount = 2;
312 menuOptions[1] = 1;
313 }
314 for (; optionCount < 4; optionCount++)
315 menuOptions[optionCount] = -1;
316
317 for (menuIndex = 0; menuIndex < 4; menuIndex++) {
318 if (menuOptions[menuIndex] != -1) {
319 aTitleMenuRegions[menuIndex].frame = 1;
320 if (menuOptions[menuIndex] < 3) {
322 &aTitleMenuRegions[menuIndex].left,
323 aTitleMenuRegions[menuIndex].left,
324 aTitleMenuRegions[menuIndex].top,
325 menuShape, menuOptions[menuIndex]);
326 } else {
328 &aTitleMenuRegions[menuIndex].left,
329 aTitleMenuRegions[menuIndex].left,
330 aTitleMenuRegions[menuIndex].top,
331 alternateMenuShape, 0);
332 }
333 } else {
334 aTitleMenuRegions[menuIndex].frame = -1;
335 }
336 }
337
339 for (menuIndex = 0; menuIndex < 4; menuIndex++) {
340 if (menuOptions[menuIndex] != -1) {
341 if (menuOptions[menuIndex] < 3) {
343 aTitleMenuRegions[menuIndex].left,
344 aTitleMenuRegions[menuIndex].top,
345 menuShape, menuOptions[menuIndex]);
346 } else {
348 aTitleMenuRegions[menuIndex].left,
349 aTitleMenuRegions[menuIndex].top,
350 alternateMenuShape, 0);
351 }
352 }
353 }
354 DIBslam();
355 DIBslamReal();
356
360 WarpMouseTo(160, 100);
362 bInputModeState = 1;
364 while (state == 0) {
365 selectedIndex = -1;
367 eventType = PollInputEvent(&event, 0xff);
368 switch (eventType) {
369 case 3:
370 case 5:
371 activate = 0;
373 switch ((short)event.value) {
374 case 0x1c:
375 case 0x1f:
376 case 0x2e:
377 case 0x39:
378 if ((short)event.value == 0x1f)
379 selectedIndex = 0;
380 if ((short)event.value == 0x2e &&
381 menuOptions[2] != -1)
382 selectedIndex = 1;
383 if ((short)event.value == 0x32 &&
384 menuOptions[2] != -1)
385 selectedIndex = 2;
386 activate = 1;
387 break;
388 case 0x24:
390 break;
391 default:
393 break;
394 }
395 if (activate == 0)
396 break;
397 /* Fall through to the shared mouse/keyboard activation. */
398 case 2:
399 {
400 int selection;
401
402 if (selectedIndex == -1) {
403 int mouseX;
404 int mouseY;
405
406 mouseY = event.y;
407 mouseX = event.x;
408 selectedIndex = FindMenuRegionAtPoint(
409 mouseX, mouseY, aTitleMenuRegions);
410 }
411 selection = selectedIndex;
412 switch (selection) {
413 case 0:
414 case 1:
415 case 2:
416 case 3:
417 state = (signed char)(menuOptions[selection] + 1);
418 break;
419 default:
420 state = 0;
421 break;
422 }
423 break;
424 }
425 default:
426 break;
427 }
428 DIBslam();
429 DIBslamReal();
430 }
431
434 ReleasePacketHandle(menuShape);
435 ReleasePacketHandle(alternateMenuShape);
441 DIBslam();
442 DIBslamReal();
444 return state - 1;
445}
unsigned char bEscapePressedFlag
Definition mathfp.c:24
ObjectTypeData aObjectTypeData[OBJECT_TYPE_COUNT]
Definition objdata.c:86
unsigned char cBlackColour
Definition init.c:12
short anObjectRollRotationList[SPACE_OBJECT_COUNT]
Definition screen.c:16
short anObjectYawRotation[SPACE_OBJECT_COUNT]
Definition joycal.c:33
short anObjPitchRot[SPACE_OBJECT_COUNT]
Definition data.c:247
int bShowKilrathiSagaCredits
Definition winmain.c:35
short asIntroCameraSequence[]
Definition game.c:110
unsigned int bKeyEventQueueEnabled
Definition winmain.c:31
short nFrameSkipCounter
Definition main.c:23
MouseCursorState stHostMouseState
Definition data.c:243
unsigned char bInputModeState
Definition eventmgr.c:21
int bIntroSecondaryScene
Definition game.c:40
MouseCursorState stMouseCursorState
Definition strdos.c:19
FixedVector aShipVelocity[SPACE_OBJECT_COUNT]
Definition smart.c:21
int bScriptedView
Definition view.c:14
unsigned int bIntroSceneResourcesActive
Definition logic.c:87
short nScreenWidth
Definition data.c:34
int nSceneResourceBudgetValue
Definition ship.c:62
Viewport stScreenView
Definition launch.c:50
Viewport stSpaceBufferViewport
Definition timer.c:13
int nCannedSceneMode
Definition main.c:21
short nExternalViewAngle
Definition title.c:68
short nMenuInputRepeatDelay
Definition objdata.c:597
MissionShipRecord aMissionShips[MISSION_SHIP_STORAGE_COUNT]
Definition game.c:230
FixedVector aShipFwdVec[64]
Definition smart.c:17
short nCurrentViewCenterPosY
Definition eventmgr.c:26
struct Shape * pTitleShape
Definition title.c:69
struct Shape * pIntroFont
Definition eject.c:29
unsigned int value
Definition wc1base.h:140
signed char state
Definition wcdata.h:896
Viewport * viewport
Definition wc1base.h:110
struct Shape * shape
Definition wc1base.h:107
struct Shape * shapeSet
Definition wcdata.h:393
short left
Definition wcdata.h:440
short right
Definition wcdata.h:442
static int nIntroCreditCount
Definition title.c:22
static char * pszIntroOpeningText
Definition title.c:12
char szMissingSecretMissionsMessage[279]
Definition title.c:17
static TitleMenuRegion aTitleMenuRegions[5]
Definition title.c:48
static char * apszIntroCredits[20]
Definition title.c:24
static int bTitleMenuSceneInitialized
Definition title.c:65
static PacketResourceDescriptor aIntroResourceDescriptors[3]
Definition title.c:57
Umbrella header for the game core.
unsigned short GetPaletteReadyUnused(void)
Definition title.c:72
void LeaveAllocationScope(void)
Definition eventmgr.c:556
short __stdcall IsPointInRect(short x, short y, const short *rect)
Definition mathfp.c:217
void PollJoystickButtonEvents(void)
Definition input.c:76
unsigned int RenderSpaceViewFrame(void)
Definition main.c:1913
short GetTransformedShapeBounds(Viewport *viewport, short x, short y, struct Shape *shape, short frame, short angle, short scale, short flip, ShortRect *bounds)
Definition gr.c:1196
void DIBslam(void)
Definition dib.c:513
void MoveMenuPointerFromKeyboard(InputEventState *event)
Definition disk.c:551
short __stdcall PollInputEvent(InputEventState *event, short filter)
Definition eventmgr.c:336
int set_up_action_sphere(short navPoint)
Definition mission.c:519
unsigned int free_3Space(void)
Definition logic.c:1975
unsigned int Draw_3Space_Frame(void)
Definition main.c:1832
void * FetchDiskPacketRetrying(short logicalFile, short section, short flags)
Definition disk.c:126
void intro_drawbackgroundships(void)
Definition eventmgr.c:962
void CalibrateJoystickInteractive()
Definition joystick.c:13
void SceneEnterHook(void)
Definition pilot.cpp:163
int Title_Sequence(void)
Definition title.c:119
void DrawSpriteScaled(Viewport *viewport, short x, short y, struct Shape *shape, short frame, short angle, short scale, short flip)
Definition gr.c:1176
void ClearInputKeyStatePreservingModifiers(void)
Definition eventmgr.c:787
unsigned int spacetrack(int track, int mode, short enabled)
Definition music.c:411
int FindMenuRegionAtPoint(short x, short y, const TitleMenuRegion *regions)
Definition killbrd.c:274
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
void FlushInputEvents(void)
Definition eventmgr.c:381
int LoadPacketResourceList(PacketResourceDescriptor *resources, short flags, int availableBytes)
Definition logic.c:1429
void DIBslamReal(void)
Definition dib.c:519
unsigned int clear_view_buffer(void)
Definition main.c:414
unsigned int PreloadMusicTrackHook(short track)
Definition logic.c:2044
void __stdcall SetEventManagerPump(void(*pump)(void))
Definition strdos.c:126
int free_all_slots(void)
Definition mission.c:397
void initialize_scripted_view(const short *script)
Definition view.c:175
void EnterAllocationScope(void)
Definition eventmgr.c:550
unsigned int PumpWindowMessages(void)
Definition winmain.c:740
unsigned int init_3Space_objects()
void ClearDebugPauseFlags(void)
Definition pilot.cpp:229
void ResetSoundState(void)
Definition music.c:669
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
void __stdcall WarpMouseTo(short x, short y)
Definition winmain.c:501
unsigned int ReleaseMusicTrackHook(short track)
Definition logic.c:2051
void start_hazard_field(short region)
Definition winmain.c:448
void ClearViewport(Viewport *viewport, short colour)
Definition gr.c:963
void PollMenuInputDevices(void)
Definition input.c:110
short __stdcall GetShapeFrameBounds(short *bounds, short x, short y, struct Shape *shape, short frame)
Definition mathfp.c:195
void DrawTitleLogo(short distance, short y)
Definition title.c:78
unsigned int Update_3Space(void)
Definition main.c:476
void ReleasePacketHandle(void *handle)
Definition ending.c:50
void __stdcall SetMouseCursorShape(struct Shape *shape, short frame)
Definition eventmgr.c:562
void __stdcall EventManagerHook(void(*callback)(void))
Definition strdos.c:120
int FreeShapeSet(PacketResourceDescriptor *resources, unsigned short releaseFlags)
Definition logic.c:1417
short CheckEscaped(void)
Definition disk.c:442
void FreePacketAndClear(void *slot, unsigned short releaseFlags)
Definition mathutil.c:37
short AnySavedGames(void)
Definition barracks.c:175
void remove_all_hazards(void)
Definition winmain.c:141
void UpdateTitleMenuCursor(void)
Definition title.c:100
unsigned int dump_buffer_to_screen(void)
Definition main.c:383
@ OBJECT_TYPE_DEBRIS_METAL_SHEET
Definition wcdata.h:98
@ OBJECT_TYPE_DEBRIS_WING
Definition wcdata.h:99
@ OBJECT_TYPE_EXPLOSION1
Definition wcdata.h:104