Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
message.c
Go to the documentation of this file.
1/*
2 * Flight input setup, fatal errors and on-screen messages.
3 *
4 * Retail object 0x4379F0-0x43801F (link order; see docs/ORDER.md).
5 */
6#include "game.h"
7
8static const char *g_pszFatalErrorMessage =
9 "Sorry, an error has occurred.\n"
10 "Please note the following information: %s.\n"
11 "Check your configuration. If this problem persists, please\n"
12 "call Origin Systems' service line. We are sorry for the inconvenience."; /* 0x0049ac98 */
13int g_bPauseInputActive = 0; /* 0x0049ac9c */
14
15/* Function start: 0x4379F0 */
27
28/* Function start: 0x437A44 */
29void ReportFatalErrorCode(const char *errorCode)
30{
31 FILE *errorFile;
32
33 errorFile = 0;
34 errorFile = fopen("err.$$$", "w+");
35 LogMemoryStateToFile(errorFile);
36 if (errorFile != 0)
37 fclose(errorFile);
39 g_pszFatalErrorMessage, errorCode);
41}
42
43/* Function start: 0x437AB4 */
44void exit_squadron(const char *msg, ...)
45{
46 if (msg != 0)
51}
52
53/* Function start: 0x437AEC */
55{
56 TextContext *previousContext;
57 char value[60];
58 TextContext savedTextContext;
59
60 previousContext = g_29_pCurrentTextContext;
61 savedTextContext = g_3_stDefaultStringContext;
64 (unsigned char)g_bPrimaryViewBufferColour,
67 /* Called without a prototype: the int return is pushed unextended. */
68 DrawFormattedText("%X%YCurrent NMem %d.", 70, 160,
69 ((int (*)(void))GetOriginalFreeMemory)());
70 sprintf(value, "%ld", GetLargestFreeMemoryBlockByType(0));
71 DrawFormattedText("%X%YLargest Block FMem %s.", 70, 176, value);
72 sprintf(value, "%ld", GetAvailableMainMemory());
73 DrawFormattedText("%X%YCurrent FMem %s.", 70, 168, value);
74 sprintf(value, "%ld", g_dwInitialSpareMemory);
75 DrawFormattedText("%X%YOriginal FMem %s.", 0, 0, value);
76 sprintf(value, "%ld", GetAvailableFarMemory());
77 DrawFormattedText("%X%YCurrent EMS %s.", 70, 184, value);
78 g_3_stDefaultStringContext = savedTextContext;
79 g_29_pCurrentTextContext = previousContext;
80}
81
82/* Function start: 0x437C2E */
83void ShowModalMessage(const char *format, ...)
84{
85 va_list argList;
86 char text[52];
87
88 va_start(argList, format);
89 vsprintf(text, format, argList);
90 va_end(argList);
91 if (ShowModalTextPanel(1, text) != 0) {
94 return;
95 }
96 printf(text);
98}
99
100/* Function start: 0x437C96 */
101void ReportOutOfMemoryAndExit(const char *resource)
102{
103 ShowModalMessage("ERROR: Out of memory for %s", resource);
105}
106
107/* Function start: 0x437CBF */
123
124/* Function start: 0x437D68 */
131
132/* Function start: 0x437D92 */
149
150/* Function start: 0x437DFA */
151void ShowOnScreenMessage(short duration, const char *format, ...)
152{
153 char text[52];
154 short modalShown;
155 va_list argList;
156
157 va_start(argList, format);
158 vsprintf(text, format, argList);
159 va_end(argList);
160 modalShown = 0;
161 if (duration == 9999)
162 modalShown = (short)ShowModalTextPanel(1, text);
163 if (modalShown == 0) {
164 if (duration == 0)
165 duration = MeasureMessageWidth(text);
169 g_cRedColour, duration);
170 }
171 if (g_bPauseInputActive != 0) {
175 }
176 if (duration == 9999) {
177 while (WaitForInputKey() == 0)
179 }
180 if (modalShown != 0)
182 else if (duration == 9999)
184}
185
186/* Function start: 0x437F2F */
187void ShowGamePausedBanner(short showBanner)
188{
189 if (showBanner != 0) {
190 ShowOnScreenMessage(9999, "GAME PAUSED");
191 } else {
192 while (WaitForInputKey() == 0)
194 }
195}
196
197/* Function start: 0x437F77 */
199{
200 ShowOnScreenMessage(9999, "WING COMMANDER VER. %s",
202}
203
204/* Function start: 0x437F9A */
206{
208 (unsigned char)(((signed char)g_cMessageSpeed + 1) % 5);
209 ShowOnScreenMessage(0, "MESSAGES SPEED IS NOW %d.",
210 (signed char)g_cMessageSpeed + 1);
211}
212
213short MinShort(short a, short b);
214short MaxShort(short a, short b);
215
216/* Function start: 0x437FD3 */
217void ReportFramesSkipped(short adjustment)
218{
220 MaxShort((short)(g_nFrameSkip + adjustment), 1), 5);
221 ShowOnScreenMessage(0, "%d FRAMES SKIPPED.",
222 g_nFrameSkip - 1);
223}
224
225/* Linker commons defined here. LINK lays a unit's commons out by the
226 * identifiers' hash keys, so these spellings follow the original addresses. */
228char g_6_szDefaultTextBufferText[0xc8]; /* 0x005d2b80 */
229unsigned char *g_18_pCockpitIndicatorShape; /* 0x005d2c48 */
230unsigned char *g_pConstellationSprite; /* 0x005d2c4c */
232unsigned char *g_pPilotHandAnimationShapePtr; /* 0x005d2c64 */
235short g_9_aasCockpitHitPaletteFades[6][3]; /* 0x005d2cb0 */
236unsigned char *g_4_pCockpitPanelShape; /* 0x005d2cd4 */
241short g_1_asSpacePaletteFade[3]; /* 0x005d2d60 */
void ShowGamePausedBanner(short showBanner)
Definition message.c:187
int ConfigureInputPump(int slot, void(*pump)(void))
Definition eventmgr.c:2112
void SetInputViewport(Viewport *viewport)
Definition eventmgr.c:2093
short MaxShort(short a, short b)
Definition disk.c:36
short LogMemoryUsage(void)
Definition main.c:24
unsigned int GetAvailableMainMemory(void)
Definition memfree.c:13
void InitializeTextContextFromFont(TextContext *context, short fontIndex, unsigned char colour, signed char background)
Definition disk.c:254
void LogMemoryStateToFile(FILE *file)
Definition gameflow.c:132
short AllocateViewport(Viewport *viewport, short clearColour, short flags)
Definition vpalloc.c:32
void ShutdownGameWindow(void)
Definition winmain.c:172
void InitializeSpaceFlightInput(void)
Definition message.c:16
void free_viewport(Viewport *viewport)
Definition vpfree.c:10
void SetTextContext(TextContext *context)
Definition eventmgr.c:179
void ResetScreenClipToFullHeight(void)
Definition message.c:125
void ReportPacketLoadError(void *packet, char *fileName, short retry, short section, const char *sourceTag)
Definition disk.c:54
void get_player_input(void)
Definition main.c:389
unsigned int GetLargestFreeMemoryBlockByType(short memoryType)
Definition memapi.c:139
void ReportFatalErrorCode(const char *errorCode)
Definition message.c:29
void FlushInputEvents(void)
Definition eventmgr.c:1014
short MinShort(short a, short b)
Definition disk.c:27
void ShowModalMessage(const char *format,...)
Definition message.c:83
short WaitForInputKey(void)
Definition disk.c:319
void ReportFramesSkipped(short adjustment)
Definition message.c:217
void ShowOnScreenMessage(short duration, const char *format,...)
Definition message.c:151
short GetOriginalFreeMemory(void)
Definition eventmgr.c:1914
void ClearHudMessageDisplay(short closeCommMenu)
Definition cockpt.c:2171
void ShowMemoryStatusDebug(void)
Definition message.c:54
void ServiceSoundSystem(void)
Definition sound.c:389
void ClearDebugPauseFlags(void)
Definition console.cpp:82
void InitializeConversationViewport(void)
Definition message.c:108
char * DosStrcpy(char *dst, const char *src)
Definition eventmgr.c:465
void ReportOutOfMemoryAndExit(const char *resource)
Definition message.c:101
short MeasureMessageWidth(const char *text)
Definition main.c:895
void ClearViewport(Viewport *viewport, short colour)
Definition gr.c:1027
void SetMessageDisplaySpeed(void)
Definition message.c:205
void SetHudMessageText(char *text, unsigned short colour, unsigned short duration)
Definition cockpt.c:2742
void ClearInputPump(void)
Definition eventmgr.c:2100
void InitializeConversationText(void)
Definition message.c:133
void ShowNoticeMessageBox(const char *text)
Definition winmain.c:194
void AcknowledgeModalMessage(void)
Definition main.c:902
void ShowVersionBanner(void)
Definition message.c:198
void FlushPendingInputPresses(void)
Definition disk.c:305
void exit_squadron(const char *msg,...)
Definition message.c:44
void ReleaseModalTextPanel(void)
Definition optmenu.c:208
void FatalErrorAndExit(const char *format,...)
Definition cockpt.c:121
void InitializeInputDriverHook(void)
Definition eventmgr.c:2138
unsigned int GetAvailableFarMemory(void)
Definition eventmgr.c:1509
void DrawFormattedText(const char *format,...)
Definition textfmt.c:103
short ShowModalTextPanel(short fontIndex, const char *format,...)
Definition optmenu.c:163
Shared Win32 declarations, types and library interfaces.
unsigned char * g_4_pCockpitPanelShape
Definition message.c:236
short g_nFrameSkip
Definition main.c:1940
unsigned char * g_18_pCockpitIndicatorShape
Definition message.c:229
short g_3_nFlightControlCommandValue
Definition joystick.c:76
unsigned char * g_pConstellationSprite
Definition message.c:230
unsigned int g_dwInitialSpareMemory
Definition startup.c:590
short g_9_aasCockpitHitPaletteFades[6][3]
Definition message.c:235
Viewport g_stPilotHandViewportRecord
Definition message.c:233
unsigned char * g_pPilotHandAnimationShapePtr
Definition message.c:232
TextContext * g_29_pCurrentTextContext
Definition eventmgr.c:2563
char g_6_szDefaultTextBufferText[0xc8]
Definition message.c:228
Viewport g_6_stConversationTextViewport
Definition message.c:227
unsigned char g_26_bMouseCursorEnabled
Definition eventmgr.c:2506
char g_szNotEnoughMemoryMessage[]
Definition startup.c:566
unsigned char g_cSecondaryViewBufferColour
Definition startup.c:544
char g_szOnScreenMessageBuffer[52]
Definition comm.c:583
unsigned char g_88_nEventRepeatDelayState
Definition eventmgr.c:2500
unsigned char g_cRedColour
Definition startup.c:548
Viewport g_27_stViewScratchInfo
Definition cockpt.c:3841
short g_1_asSpacePaletteFade[3]
Definition message.c:241
unsigned char g_bPrimaryViewBufferColour
Definition startup.c:545
Viewport g_2_stModalSourceWindow
Definition message.c:231
signed char g_cMessageSpeed
Definition comm.c:12
Viewport g_101_stScrViewInfo
Definition cockpt.c:3831
TextContext g_1_stRightVduTextContextBlock
Definition message.c:237
int g_bPauseInputActive
Definition message.c:13
Viewport g_stSecondaryViewBufferBlock
Definition message.c:234
char * g_pszGameVersion
Definition version.c:10
char g_szCannedSceneTapeFile[9]
Definition taperec.c:11
TextContext g_16_stCockpitTextSettingsRecord
Definition message.c:238
short g_18_nInterfaceEventMode
Definition eventmgr.c:2570
TextContext g_3_stDefaultStringContext
Definition message.c:239
TextContext g_2_stConversationTextCtx
Definition message.c:240
static const char * g_pszFatalErrorMessage
Definition message.c:8
char * text
Definition game.h:290
signed char alignment
Definition game.h:292
Viewport * viewport
Definition game.h:284
unsigned char * pixels
Definition game.h:150
short right
Definition game.h:154
short bottom
Definition game.h:155
short left
Definition game.h:152
short top
Definition game.h:153