Wing Commander
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
install.c
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup shell
4 * @brief Installation-file loading, start-up arguments and disk-prompt setup.
5 *
6 * Address range 42c410-42c7ff. Which unit owned the leading empty shutdown
7 * hook is provisional.
8 */
9#include "wc1.h"
10
11/* Linker commons defined here; LINK orders them by identifier hash. */
13int aiSoundEffectSourceActiveArray[0x40]; /* 0x005a66f0 */
14unsigned char abAudioPlaybackSlots[0xf8]; /* 0x005a67f0 */
15int nPassingShipAudioCooldown; /* 0x005a68e8 */
16int nAllocateViewportCallsValue; /* 0x005a68ec */
17void *pLastPacketAllocation; /* 0x005a68f0 */
18FireworkState aFireworksList[30]; /* 0x005a6900 */
19struct Shape *pFireworkShape; /* 0x005a6a68 */
21
22/* Function start: 0x42C410 */
24{
25}
26
27/* Function start: 0x42C420 */
29{
30 short textWidth;
31 short textHeight;
32
34 if (stScreenView.pixels == 0)
43 textWidth =
45 "Press any key when ready") +
46 10);
47 textHeight =
48 (short)((FontHeight(stDiskPromptTextContext.font) + 1) * 3);
50 (short)(100 - textHeight / 2);
52 (short)(160 - textWidth / 2);
54 (short)(stDiskPromptBounds.top + textHeight);
56 (short)(stDiskPromptBounds.left + textWidth);
59 (signed char)cViewportClearColour);
61 return 0;
62}
63
64/* Function start: 0x42C510 */
65unsigned short RewriteDiskFileGraphicsExtensions(short videoMode)
66{
67 DiskFileRecord *record;
68 char *extensionPosition;
69 char extension;
70
71 record = pDiskFileRecords;
72 switch (videoMode) {
73 case 0:
74 extension = 'v';
75 break;
76 case 1:
77 extension = 'e';
78 break;
79 case 3:
80 extension = 't';
81 break;
82 }
83
84 while (record->name[0] != '\0') {
85 extensionPosition = strchr(record->name, '.');
86 if (extensionPosition++ != 0 &&
87 toupper((int)*extensionPosition) == 'V')
88 *extensionPosition = extension;
89 record++;
90 }
91 return 0;
92}
93
94/* Function start: 0x42C580 */
95short LoadWingCmdrCfgFile(short argc, char **argv)
96{
97 FILE *file;
98 char *destination;
99 short argumentCount;
100 short argumentIndex;
101
102 argumentIndex = 1;
103 argumentCount = 0;
104 destination = szTxtWorkspaceBuffer;
105 file = fopen("WINGCMDR.CFG", "rt");
106 while (file != 0) {
107 if ((short)fscanf(file, "%s", destination) == -1) {
108 fclose(file);
109 break;
110 }
111 pCurrentStartupArgumentsPtr[argumentCount++] =
112 destination;
113 destination = strchr(destination, 0) + 1;
114 }
115
116 while (argc-- != 0) {
117 strcpy(destination, argv[argumentIndex]);
118 pCurrentStartupArgumentsPtr[argumentCount++] = destination;
119 argumentIndex++;
120 destination = strchr(destination, 0) + 1;
121 }
122 return (short)(argumentCount - 1);
123}
124
125/* Function start: 0x42C660 */
126unsigned short LoadInstallDat(void)
127{
128 DiskFileRecord *records;
129 DiskFileRecord *record;
130 DiskFileRecord *entry;
131 unsigned int size;
132 short file;
133 short maximumId;
134
135 maximumId = 0;
136 SystemDebugPrintf("Loading INSTALL.DAT\n");
137 file = OpenDataFileOrDie("install.dat");
138 if (file == -1) {
139 SystemDebugPrintf("Unable to open INSTALL.DAT\n");
141 "[SYSTEM]: Exiting Prematurely (LoadInstallData)\n");
144 exit(0);
145 }
146 size = (unsigned int)filelength(file);
147 records = (DiskFileRecord *)AllocateTaggedMemory(size, 0);
148 if (records == 0) {
149 SystemDebugPrintf("Unable to load INSTALL.DAT\n");
151 "[SYSTEM]: Exiting Prematurely (LoadInstallData)\n");
154 exit(0);
155 }
156 ReadDataFileAtOffset(file, 0, size, records);
157 CloseDataFile(file);
158
159 for (record = records; record->name[0] != 0; record++) {
160 if (maximumId < record->logicalFile &&
161 record->logicalFile != 0xff)
162 maximumId = record->logicalFile;
163 }
164 maximumId++;
165
168 memset(pDiskFileRecords, 0,
169 (maximumId + 1) * sizeof(DiskFileRecord));
170 if (pDiskFileRecords == 0) {
171 SystemDebugPrintf("Unable to copy INSTALL.DAT\n");
173 "[SYSTEM]: Exiting Prematurely (LoadInstallData)\n");
176 exit(0);
177 }
178
179 entry = pDiskFileRecords;
180 while (maximumId > 0) {
181 entry->name[0] = ' ';
182 entry++;
183 maximumId--;
184 }
185
186 for (record = records; record->name[0] != 0; record++) {
187 if (record->logicalFile != 0xff)
188 pDiskFileRecords[record->logicalFile] = *record;
189 }
190 ReleasePacketHandle(records);
192 return 0;
193}
TextContext stDefaultTxtContext
Definition targ.c:14
void * pLastPacketAllocation
Definition install.c:17
unsigned char cBlackColour
Definition init.c:12
char szTxtWorkspaceBuffer[256]
Definition screens.c:164
unsigned char cViewportClearColour
Definition init.c:13
short nDiskPromptBorderColour
Definition disk.c:28
ScreenAllocation * pScreenAllocPtr
Definition install.c:12
int bGraphicsActive
Definition init.c:39
int nPassingShipAudioCooldown
Definition install.c:15
int nAllocateViewportCallsValue
Definition install.c:16
struct Shape * pFireworkShape
Definition install.c:19
Viewport stScreenView
Definition launch.c:50
int aiSoundEffectSourceActiveArray[0x40]
Definition install.c:13
Viewport stDiskPromptViewport
Definition disk.c:42
char * pCurrentStartupArgumentsPtr[30]
Definition main.c:96
FireworkState aFireworksList[30]
Definition install.c:18
DiskFileRecord * pDiskFileRecords
Definition disk.c:36
ConstellationStar aConstellationStarsTable[10]
Definition install.c:20
TextContext stDiskPromptTextContext
Definition disk.c:44
ShortRect stDiskPromptBounds
Definition disk.c:45
unsigned char abAudioPlaybackSlots[0xf8]
Definition install.c:14
unsigned char logicalFile
Definition wcdata.h:493
char name[13]
Definition wcdata.h:490
short top
Definition wcdata.h:441
short left
Definition wcdata.h:440
short right
Definition wcdata.h:442
short bottom
Definition wcdata.h:443
unsigned char * font
Definition wc1base.h:239
char * text
Definition wc1base.h:242
Viewport * viewport
Definition wc1base.h:236
unsigned char alignment
Definition wc1base.h:244
unsigned char * pixels
Definition wc1base.h:74
Umbrella header for the game core.
void SystemDebugPrintf(const char *fmt,...)
Definition pilot.cpp:182
void * AllocateTaggedMemory(int size, unsigned short flags)
Definition ending.c:31
unsigned short InitializeDiskPromptTextContext(void)
Definition install.c:28
char PumpMessagesDuringWait(void)
Definition pilot.cpp:188
unsigned int InitializeTextContextFromFont(TextContext *context, short fontIndex, unsigned char colour, signed char background)
Definition disk.c:192
unsigned int InitializeGameTextContexts(void)
Definition init.c:209
short __stdcall MeasureTextPixelWidthClamped(const char *text)
Definition geom.c:18
int __stdcall ReadDataFileAtOffset(unsigned short fd, int offset, unsigned int length, void *data)
Definition mono.c:61
void FxDriverShutdownHook(void)
Definition install.c:23
void __stdcall CloseDataFile(unsigned short fd)
Definition mono.c:23
short LoadWingCmdrCfgFile(short argc, char **argv)
Definition install.c:95
short __stdcall OpenDataFileOrDie(const char *path)
Definition winsys.c:297
void ClearDebugPauseFlags(void)
Definition pilot.cpp:229
unsigned short RewriteDiskFileGraphicsExtensions(short videoMode)
Definition install.c:65
unsigned short __stdcall FontHeight(const void *p)
Definition mathfp.c:178
void ReleasePacketHandle(void *handle)
Definition ending.c:50
unsigned short LoadInstallDat(void)
Definition install.c:126