Wing Commander
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
main.c File Reference

WINGLEADER's main module: process services, flight control and the HUD. More...

#include <dos.h>
#include "wc1.h"
#include <malloc.h>

Go to the source code of this file.

Functions

void DosInterruptHandlerHook (void)
short __stdcall PollInputEvent (InputEventState *event, short filter)
short __stdcall IsInputEventQueued (short type)
short LogMemoryUsage (void)
void exit_squadron (const char *msg)
unsigned int ShowMemoryStatusDebug (void)
unsigned int GetJoystickButtonEdge (unsigned int a, short b)
int main (short argc, char **argv)
unsigned int GetScreenUpdateFlag (void)
unsigned int initialize_view_buffer (void)
unsigned int dump_buffer_to_screen (void)
unsigned int clear_view_buffer (void)
unsigned int InitializeConversationViewport (void)
unsigned int ResetScreenClipToFullHeight (void)
unsigned int InitializeConversationText (void)
unsigned int RefreshMemoryStatusOverlay (void)
unsigned int Update_3Space (void)
unsigned int TriggerPlayerHitPaletteFlash (void)
unsigned int FadeFlightPaletteEntry (short *entry)
unsigned int UpdateSpacePaletteFade (void)
unsigned int house_keep (void)
void init_player_input (void)
void get_player_input (void)
int process_player_input (void)
unsigned int fire_players_lasers (void)
unsigned int players_flight_dynamics (void)
unsigned int player_input (void)
unsigned int SelectNextExternalViewObject (void)
void rotate_about_i (short angle, FixedVector *j, FixedVector *k)
void rotate_about_j (short angle, FixedVector *i, FixedVector *k)
short MinShort (short a, short b)
short __stdcall DosStrlen (const char *s)
short ShowModalTextPanel (short fontIndex, const char *format,...)
void FatalErrorAndExit (const char *format,...)
void SetHudMessageText (char *text, unsigned short colour, unsigned short duration)
void ShowHudTextLine (char *s, unsigned short b)
unsigned int SelectPreviousExternalViewObject (void)
unsigned int HandleFleetOverviewInput (void)
short MeasureMessageWidth (const char *text)
void WaitForKeyAcknowledge (int mode)
void ShowModalMessage (const char *format,...)
void ReportOutOfMemoryAndExit (const char *resource)
void ShowOnScreenMessage (int flags, short duration, const char *format,...)
void ShowGamePausedBanner (short showBanner)
void ShowVersionBanner (void)
void SetMessageDisplaySpeed (void)
void ReportFramesSkipped (short adjustment)
int HandleSpaceFlightControls (void)
unsigned int Draw_3Space_Frame (void)
void GetArcadeBonus (void)
void FigureArcadeTime (void)
void DrawArcadeScorePanel (short x, short y)
void UpdateArcadeScoreDisplay (void)
unsigned int RenderSpaceViewFrame (void)
unsigned int RefreshCockpitStatus (void)
short GetShipDistanceToNavPoint (short ship, MissionNavPoint *navPoint)
short FindNearestNavPoint (short ship)
unsigned int ReleaseStaleNavTarget (void)
int RunSpaceFlight (short entryNavPoint)
void flag_objective (short objective, unsigned char flags)
int calculate_damage_level (void)
void UpdateTrainSimMenuCursor (void)
void ResetMouseCursorFrame (void)
void UpdateRoomMenuCursor (void)
void __stdcall FadeViewportPaletteToColour (Viewport *viewport, unsigned short colour, short enabled)

Variables

unsigned int _ovrbuffer = 0x1370
int nCannedSceneMode = 0
int nArcadeState = 0
short nFrameSkipCounter = 1
short nFrameSkip = 1
int nSfxVolumeSetting = 0x14
int nMusicVolumeSetting = 0x14
int bViewportDirty = 0
static int anVolumeLevels [11]
int nOriginDevUnlock = 0
int bPlayerCollisionsEnabled = 1
int bPlayerVulnerable = 1
int bPlayerCollisionResponse = 1
int bViewBufferEnabled = 0
int bCockpitlessView = 0
static int nShowMemoryStatus = 0
short nStartNavPointOverride = -1
short nArcadeBonusCountdown = 0
volatile int bMouseCursorVisible = 0
unsigned char bInputPollingGuard = 0
static InputDeviceSample stLastPolledFlightInput = {0}
static int bMouseAfterburnerControl = 0
static short asMouseYawThresholds [6]
static short asMousePitchThresholds [6]
static unsigned int dwLastSecondaryButtonPress = 0
static unsigned char bFlightRollLatch = 0
static volatile unsigned char bAfterburnerButtonLatched = 0
static short nMouseYawInput = 0
static short nMousePitchInput = 0
static int nFlightFrameTicks
static int nHudDelta
static LARGE_INTEGER liFlightAfterInputCounter
static LARGE_INTEGER liFlightFrameEndCounter
static int nFlightPresentDelta
static LARGE_INTEGER liFrameStart
static LARGE_INTEGER liSimulationDone
static int nSimulationDelta
static LARGE_INTEGER liFlightAfterCockpitCounter
static int nInputTicks
static LARGE_INTEGER liRenderDoneCounter
static int nDrawDelta
int nDmgDispState
int nDamageDisplayPhase
struct Shape * pLaunchDoorShape
unsigned int nCurrentFrameTimerIdValue
unsigned char abPaletteTripletsArray [256][3]
InputDeviceSample stPreviousFlightInput
short bMouseButtonEventQueuedFlag
short bCurrentKeyboardEvtQueued
short bMouseMoveEvtQueued
char * pCurrentStartupArgumentsPtr [30]
short bJoystickEventQueued
short nMainArcadeStartupParameterValue
Viewport stCurrentTrainSimTitleDisplayViewport

Detailed Description

WINGLEADER's main module: process services, flight control and the HUD.

Address range 4272f0-42a8ef. The initialized state and the complete literal order identify this group; its trailing cursor and palette helpers are provisional.

Definition in file main.c.

Function Documentation

◆ calculate_damage_level()

◆ clear_view_buffer()

◆ DosInterruptHandlerHook()

void DosInterruptHandlerHook ( void )

Definition at line 1097 of file eventmgr.c.

References DosInterruptHandlerHook().

Referenced by DosInterruptHandlerHook(), and main().

◆ DosStrlen()

short __stdcall DosStrlen ( const char * s)

Definition at line 61 of file strdos.c.

◆ Draw_3Space_Frame()

◆ DrawArcadeScorePanel()

void DrawArcadeScorePanel ( short x,
short y )

◆ dump_buffer_to_screen()

◆ exit_squadron()

◆ FadeFlightPaletteEntry()

unsigned int FadeFlightPaletteEntry ( short * entry)

Definition at line 496 of file main.c.

References FadeFlightPaletteEntry().

Referenced by FadeFlightPaletteEntry(), house_keep(), and init_3Space_objects().

◆ FadeViewportPaletteToColour()

◆ FatalErrorAndExit()

void FatalErrorAndExit ( const char * format,
... )

Definition at line 237 of file cockpt.c.

◆ FigureArcadeTime()

void FigureArcadeTime ( void )

◆ FindNearestNavPoint()

◆ fire_players_lasers()

◆ flag_objective()

void flag_objective ( short objective,
unsigned char flags )

Definition at line 1048 of file cockpt.c.

◆ get_player_input()

◆ GetArcadeBonus()

◆ GetJoystickButtonEdge()

unsigned int GetJoystickButtonEdge ( unsigned int a,
short b )

Definition at line 162 of file main.c.

References GetJoystickButtonEdge(), JoystickEdgeHook(), and void().

Referenced by GetJoystickButtonEdge(), init_3Space_objects(), and main().

◆ GetScreenUpdateFlag()

◆ GetShipDistanceToNavPoint()

◆ HandleFleetOverviewInput()

◆ HandleSpaceFlightControls()

int HandleSpaceFlightControls ( void )

Definition at line 1362 of file main.c.

References accelerate(), acPlayerComponentDamageList, acShipTargetTable, aeShipObjectiveList, anShipSpeed, anVolumeLevels, any_enemy(), aShipWeaponsTable, auto_pilot_sequence(), bCockpitlessView, bCurrentKey, bEscapePressedFlag, bMissileCameraEnabled, bMouseCursorVisible, Viewport::bottom, bPtrMovedByKeyboardState, bVideoImagesSuppressed, CalibrateJoystickInteractive(), Chosen_communicate_option(), ClearDebugPauseFlags(), CloseCommChoiceMenu(), cPreviousKey, cPrimaryTextColour, cRedColour, cScreenViewMode, cViewObject, drop_player_mine(), EndCommMenu(), fire_missile(), fire_players_lasers(), FlushInputEvents(), force_view(), get_mode(), GetControlKeyState(), GetF1KeyLatch(), GetKeyboardModifiers(), GetScreenUpdateFlag(), HandleFleetOverviewInput(), HandleSpaceFlightControls(), init_player_input(), initialize_cockpit(), initialize_view_buffer(), InvalidateVduMode(), Viewport::left, malf_sound(), message_showing(), nArcadeState, nCameraViewMode, nCommMenuChoiceCount, nCurrentViewCenterPosY, new_view(), nExternalViewShip, nFlightSoundEffectsEnabled, nMusicVolumeSetting, nScreenHeight, nScreenWidth, nSelectedReleaseWeaponIndex, nSfxVolumeSetting, nTargetLockMode, nTrainSimActive, nYourWingman, OBJECT_TYPE_SPACE_MINE, OBJECTIVE_HOLD_FORMATION, player_input(), players_flight_dynamics(), PlaySfxWaveFileByNumber(), RandomInRange(), ReportFramesSkipped(), request(), ResetSoundStateForFlight(), ResetSoundStateForScene(), Viewport::right, SelectCockpitVduMode(), SelectNextExternalViewObject(), SetFrameTimerPeriodDirect(), SetHudMessageText(), SetMessageDisplaySpeed(), SetMousePosition(), SetMusicStreamVolume(), SetSoundEffectsVolume(), SetViewportRect(), ShowGamePausedBanner(), ShowOnScreenMessage(), ShowVersionBanner(), stSpaceBufferViewport, Viewport::top, and your_afterburner().

Referenced by HandleSpaceFlightControls(), init_3Space_objects(), and RunSpaceFlight().

◆ house_keep()

◆ init_player_input()

◆ initialize_view_buffer()

◆ InitializeConversationText()

◆ InitializeConversationViewport()

◆ IsInputEventQueued()

short __stdcall IsInputEventQueued ( short type)

Definition at line 371 of file eventmgr.c.

◆ LogMemoryUsage()

◆ main()

◆ MeasureMessageWidth()

short MeasureMessageWidth ( const char * text)

◆ MinShort()

short MinShort ( short a,
short b )

Definition at line 20 of file mathutil.c.

◆ player_input()

◆ players_flight_dynamics()

◆ PollInputEvent()

short __stdcall PollInputEvent ( InputEventState * event,
short filter )

Definition at line 336 of file eventmgr.c.

◆ process_player_input()

◆ RefreshCockpitStatus()

◆ RefreshMemoryStatusOverlay()

◆ ReleaseStaleNavTarget()

unsigned int ReleaseStaleNavTarget ( void )

◆ RenderSpaceViewFrame()

◆ ReportFramesSkipped()

void ReportFramesSkipped ( short adjustment)

◆ ReportOutOfMemoryAndExit()

◆ ResetMouseCursorFrame()

◆ ResetScreenClipToFullHeight()

◆ rotate_about_i()

void rotate_about_i ( short angle,
FixedVector * j,
FixedVector * k )

Definition at line 508 of file geom.c.

◆ rotate_about_j()

void rotate_about_j ( short angle,
FixedVector * i,
FixedVector * k )

Definition at line 528 of file geom.c.

◆ RunSpaceFlight()

int RunSpaceFlight ( short entryNavPoint)

Definition at line 1994 of file main.c.

References aMissionShips, bCockpitEnabled, bCockpitlessView, bInputModeState, bMouseAfterburnerControl, bMouseCursorVisible, Viewport::bottom, bPtrMovedByKeyboardState, ClearDebugPauseFlags(), copy_frame(), cScreenViewMode, DIBslam(), DIBslamReal(), find_objective(), flag_objective(), FlushInputEvents(), free_inflight_music(), get_player_input(), GetScreenUpdateFlag(), HandleSpaceFlightControls(), init_inflight_music(), initialize_cockpit(), initialize_view_buffer(), Viewport::left, liFlightAfterCockpitCounter, liFlightAfterInputCounter, liFlightFrameEndCounter, liFrameStart, liRenderDoneCounter, liSimulationDone, nArcadeState, MissionShipRecord::navPoint, nCurrentViewCenterPosY, nDrawDelta, new_view(), nFlightFrameTicks, nFlightPresentDelta, nFrameSkipCounter, nHudDelta, nInputTicks, nScreenHeight, nScreenWidth, nSimulationDelta, nTrainSimActive, nUnusedFlightProfileTicksA, nUnusedFlightProfileTicksB, nUnusedFlightProfileTicksC, MissionHeaderDisk::playerMissionShip, QueueInputEvent(), ReadPerformanceCounter(), RenderSpaceViewFrame(), ResetCockpitPaletteEntries(), Viewport::right, RunSpaceFlight(), set_up_action_sphere(), SetCinematicFrameTiming(), SetEventManagerPump(), SetMouseCursorShape(), SetMousePosition(), SetSpaceFlightFrameTiming(), SetViewportRect(), MouseCursorState::shape, stCurrentMissionHeader, stMouseCursorState, stSpaceBufferViewport, Viewport::top, Update_3Space(), update_cockpit(), MouseCursorState::viewport, and WarpMouseTo().

Referenced by GameFlow(), init_3Space_objects(), main(), RunSpaceFlight(), and RunTrainSim().

◆ SelectNextExternalViewObject()

unsigned int SelectNextExternalViewObject ( void )

◆ SelectPreviousExternalViewObject()

unsigned int SelectPreviousExternalViewObject ( void )

◆ SetHudMessageText()

void SetHudMessageText ( char * text,
unsigned short colour,
unsigned short duration )

Definition at line 2218 of file cockpt.c.

◆ SetMessageDisplaySpeed()

void SetMessageDisplaySpeed ( void )

◆ ShowGamePausedBanner()

void ShowGamePausedBanner ( short showBanner)

◆ ShowHudTextLine()

void ShowHudTextLine ( char * s,
unsigned short b )

Definition at line 1875 of file cockpt.c.

◆ ShowMemoryStatusDebug()

◆ ShowModalMessage()

◆ ShowModalTextPanel()

short ShowModalTextPanel ( short fontIndex,
const char * format,
... )

Definition at line 123 of file barracks.c.

◆ ShowOnScreenMessage()

◆ ShowVersionBanner()

void ShowVersionBanner ( void )

◆ TriggerPlayerHitPaletteFlash()

unsigned int TriggerPlayerHitPaletteFlash ( void )

◆ Update_3Space()

◆ UpdateArcadeScoreDisplay()

◆ UpdateRoomMenuCursor()

◆ UpdateSpacePaletteFade()

◆ UpdateTrainSimMenuCursor()

◆ WaitForKeyAcknowledge()

Variable Documentation

◆ _ovrbuffer

unsigned int _ovrbuffer = 0x1370

Definition at line 20 of file main.c.

◆ abPaletteTripletsArray

unsigned char abPaletteTripletsArray[256][3]

Definition at line 91 of file main.c.

Referenced by FadeViewportPaletteToColour().

◆ anVolumeLevels

int anVolumeLevels[11]
static
Initial value:
= {
0, 40000, 50000, 55000, 60000, 61000,
61500, 62000, 63000, 63500, 64000
}

Definition at line 30 of file main.c.

Referenced by HandleSpaceFlightControls(), main(), and process_player_input().

◆ asMousePitchThresholds

short asMousePitchThresholds[6]
static
Initial value:
= {
5, 18, 27, 35, 38, 1040
}

Definition at line 58 of file main.c.

Referenced by player_input().

◆ asMouseYawThresholds

short asMouseYawThresholds[6]
static
Initial value:
= {
10, 37, 52, 57, 62, 1070
}

Definition at line 54 of file main.c.

Referenced by player_input().

◆ bAfterburnerButtonLatched

volatile unsigned char bAfterburnerButtonLatched = 0
static

Definition at line 64 of file main.c.

Referenced by player_input().

◆ bCockpitlessView

◆ bCurrentKeyboardEvtQueued

short bCurrentKeyboardEvtQueued

Definition at line 94 of file main.c.

Referenced by player_input().

◆ bFlightRollLatch

unsigned char bFlightRollLatch = 0
static

Definition at line 63 of file main.c.

Referenced by player_input().

◆ bInputPollingGuard

unsigned char bInputPollingGuard = 0

Definition at line 44 of file main.c.

Referenced by get_player_input(), PollJoystickButtonEvents(), and PollMenuInputDevices().

◆ bJoystickEventQueued

short bJoystickEventQueued

Definition at line 97 of file main.c.

Referenced by player_input().

◆ bMouseAfterburnerControl

int bMouseAfterburnerControl = 0
static

Definition at line 47 of file main.c.

Referenced by player_input(), and RunSpaceFlight().

◆ bMouseButtonEventQueuedFlag

short bMouseButtonEventQueuedFlag

Definition at line 93 of file main.c.

Referenced by player_input().

◆ bMouseCursorVisible

◆ bMouseMoveEvtQueued

short bMouseMoveEvtQueued

Definition at line 95 of file main.c.

Referenced by player_input().

◆ bPlayerCollisionResponse

int bPlayerCollisionResponse = 1

Definition at line 37 of file main.c.

Referenced by CheckLauncherAndConfig(), main(), object_collision(), and visit_the_cinema().

◆ bPlayerCollisionsEnabled

int bPlayerCollisionsEnabled = 1

Definition at line 35 of file main.c.

Referenced by house_keep_objects().

◆ bPlayerVulnerable

int bPlayerVulnerable = 1

◆ bViewBufferEnabled

int bViewBufferEnabled = 0

Definition at line 38 of file main.c.

Referenced by free_3Space(), initialize_cockpit(), and initialize_view_buffer().

◆ bViewportDirty

int bViewportDirty = 0

Definition at line 27 of file main.c.

Referenced by ShowTigerClawEscapeScene(), unwarp(), UpdateSpacePaletteFade(), and warp().

◆ dwLastSecondaryButtonPress

unsigned int dwLastSecondaryButtonPress = 0
static

Definition at line 61 of file main.c.

Referenced by player_input().

◆ liFlightAfterCockpitCounter

LARGE_INTEGER liFlightAfterCockpitCounter
static

Definition at line 81 of file main.c.

Referenced by RunSpaceFlight().

◆ liFlightAfterInputCounter

LARGE_INTEGER liFlightAfterInputCounter
static

Definition at line 75 of file main.c.

Referenced by RunSpaceFlight().

◆ liFlightFrameEndCounter

LARGE_INTEGER liFlightFrameEndCounter
static

Definition at line 76 of file main.c.

Referenced by RunSpaceFlight().

◆ liFrameStart

LARGE_INTEGER liFrameStart
static

Definition at line 78 of file main.c.

Referenced by RunSpaceFlight().

◆ liRenderDoneCounter

LARGE_INTEGER liRenderDoneCounter
static

Definition at line 83 of file main.c.

Referenced by RunSpaceFlight().

◆ liSimulationDone

LARGE_INTEGER liSimulationDone
static

Definition at line 79 of file main.c.

Referenced by RunSpaceFlight().

◆ nArcadeBonusCountdown

short nArcadeBonusCountdown = 0

◆ nArcadeState

◆ nCannedSceneMode

◆ nCurrentFrameTimerIdValue

unsigned int nCurrentFrameTimerIdValue

Definition at line 90 of file main.c.

Referenced by SetMultimediaTimerCallback().

◆ nDamageDisplayPhase

int nDamageDisplayPhase

Definition at line 88 of file main.c.

Referenced by UpdateDamageDisplay().

◆ nDmgDispState

int nDmgDispState

Definition at line 87 of file main.c.

Referenced by show_damage_disp().

◆ nDrawDelta

int nDrawDelta
static

Definition at line 84 of file main.c.

Referenced by RunSpaceFlight().

◆ nFlightFrameTicks

int nFlightFrameTicks
static

Definition at line 73 of file main.c.

Referenced by RunSpaceFlight().

◆ nFlightPresentDelta

int nFlightPresentDelta
static

Definition at line 77 of file main.c.

Referenced by RunSpaceFlight().

◆ nFrameSkip

◆ nFrameSkipCounter

◆ nHudDelta

int nHudDelta
static

Definition at line 74 of file main.c.

Referenced by RunSpaceFlight().

◆ nInputTicks

int nInputTicks
static

Definition at line 82 of file main.c.

Referenced by RunSpaceFlight().

◆ nMainArcadeStartupParameterValue

short nMainArcadeStartupParameterValue

Definition at line 98 of file main.c.

Referenced by main().

◆ nMousePitchInput

short nMousePitchInput = 0
static

Definition at line 68 of file main.c.

Referenced by player_input().

◆ nMouseYawInput

short nMouseYawInput = 0
static

Definition at line 66 of file main.c.

Referenced by player_input().

◆ nMusicVolumeSetting

int nMusicVolumeSetting = 0x14

◆ nOriginDevUnlock

int nOriginDevUnlock = 0

◆ nSfxVolumeSetting

int nSfxVolumeSetting = 0x14

◆ nShowMemoryStatus

int nShowMemoryStatus = 0
static

Definition at line 40 of file main.c.

Referenced by main(), and ShowMemoryStatusDebug().

◆ nSimulationDelta

int nSimulationDelta
static

Definition at line 80 of file main.c.

Referenced by RunSpaceFlight().

◆ nStartNavPointOverride

short nStartNavPointOverride = -1

Definition at line 41 of file main.c.

Referenced by main(), and prepare_mission().

◆ pCurrentStartupArgumentsPtr

char* pCurrentStartupArgumentsPtr[30]

Definition at line 96 of file main.c.

Referenced by LoadWingCmdrCfgFile(), and main().

◆ pLaunchDoorShape

struct Shape* pLaunchDoorShape

Definition at line 89 of file main.c.

Referenced by DrawLaunchDoorFrame(), and LaunchPlayerShip().

◆ stCurrentTrainSimTitleDisplayViewport

Viewport stCurrentTrainSimTitleDisplayViewport

Definition at line 99 of file main.c.

Referenced by AnimateTrainSimTitle(), SelectTrainSimMission(), and ShowTrainSimHighScores().

◆ stLastPolledFlightInput

InputDeviceSample stLastPolledFlightInput = {0}
static

Definition at line 45 of file main.c.

Referenced by get_player_input(), and player_input().

◆ stPreviousFlightInput

InputDeviceSample stPreviousFlightInput

Definition at line 92 of file main.c.

Referenced by player_input().