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

Win32 shell (window creation, message loop, exit paths and the guarded debug allocator) and the asteroid and mine hazard fields. More...

#include <stdio.h>
#include "winmain.h"
#include <crtdbg.h>
#include <assert.h>
#include <dos.h>

Go to the source code of this file.

Functions

void SaveGamePalette (void)
void RestoreGamePalette (void)
short easy2see (short obj)
void make_shard (short asteroid, FixedVector direction)
void remove_hazard (signed char hazard)
void remove_all_hazards (void)
short difficulty (void)
short asteroid_velocity (void)
void skew_randomly (short obj, short allowReverse)
void align (short *value, short quantum)
void init_hazard (short obj, FixedVector position, short moving)
short near_field (const HazardField *field, const FixedVector *point)
short within_field (const HazardField *field, const FixedVector *point)
short try_far_spot (FixedVector *spot, short *moving)
short rear_sphere (void)
short ok_hazard_spot (short obj)
short make_hazard (void)
void extra_hazard (short obj)
void approach (short obj)
void manage_hazard (short obj, short slot)
void match_ship_to_eye (void)
void update_hazards (void)
void start_hazard_field (short region)
void add_hazard_field (enum ObjectType type, FixedVector center, short radius, short density)
void check_hazards (void)
void __stdcall WarpMouseTo (short x, short y)
void CheckLauncherAndConfig (void)
int WINAPI WinMain (HINSTANCE instance, HINSTANCE previous, LPSTR commandLine, int showCommand)
void ShutdownGameWindow (void)
void ShowNoticeMessageBox (const char *text)
unsigned int AbortToDesktop (void)
int CreateMainWindow (HINSTANCE instance, HINSTANCE previous, int showCommand)
unsigned int PumpWindowMessages (void)
unsigned int GetF1KeyLatch (void)
LRESULT CALLBACK MainWindowProc (HWND window, UINT message, WPARAM wParam, LPARAM lParam)
int __stdcall GetJoystickPosition (int *x, int *y, unsigned int *buttons, short joystick, unsigned short fallback)
short GetJoystickButtons (void)
void GetJoystickDevCaps (short joystick, unsigned short *xMin, unsigned short *xMax, unsigned short *yMin, unsigned short *yMax)
HINSTANCE GetApplicationInstance (void)
HWND GetMainWindowHandle (void)
HDC GetMainWindowDeviceContext (void)
void * AllocateGuardedMemory (unsigned int size)
void ReportHeapGuardCorruption (void *memory, int count, int overrun)
void CheckAllGuardedAllocations (void)
void FreeGuardedAllocation (void *memory)

Variables

short nHazardReferenceSpeed = 0
short nActiveHazards = 0
static signed char acHazardTravelTimeByView [8]
static signed char acHazardPitchRange [8]
int bIxAudioEnabled = 1
unsigned int bKeyEventQueueEnabled = 0
unsigned int nGuardedAllocationTotalBytes = 0
unsigned int nGuardedAllocationBytes = 0
unsigned int nGuardedAllocationPeakBytes = 0
int bShowKilrathiSagaCredits = 0
int bShowFrameRate = 0
int bDirectDrawModeCascadeEnabled = 1
int DAT_00465078 = 1
int bCockpitEnabled = 1
volatile int bMainWindowMinimized = 0
int DAT_00465084 = 0
char szMainWindowClassName [] = "Wing Commander"
char szMainWindowTitle [] = "Wing Commander"
int bWindowMessagePumpActive = 0
volatile unsigned int bF1KeyLatch = 0
struct GuardedAllocation * pGuardedAllocationHead = 0
HDC hMainWindowDC
HCURSOR hPrevPointer
unsigned int nSessionEndTime
int bMainWindowAlive
HINSTANCE hCurrentAppInstance
unsigned int nSessionStartTime
short awPaletteRgbWordsList [0x300]

Detailed Description

Win32 shell (window creation, message loop, exit paths and the guarded debug allocator) and the asteroid and mine hazard fields.

Address range 401000-402e7f; its string literals occupy 465048-465354.

Definition in file winmain.c.

Function Documentation

◆ AbortToDesktop()

◆ add_hazard_field()

void add_hazard_field ( enum ObjectType type,
FixedVector center,
short radius,
short density )

◆ align()

void align ( short * value,
short quantum )

Definition at line 190 of file winmain.c.

References align().

Referenced by align(), and init_hazard().

◆ AllocateGuardedMemory()

◆ approach()

void approach ( short obj)

◆ asteroid_velocity()

short asteroid_velocity ( void )

Definition at line 160 of file winmain.c.

References asteroid_velocity(), MinShort(), and RandomBelowOrEqual().

Referenced by asteroid_velocity(), and init_hazard().

◆ check_hazards()

◆ CheckAllGuardedAllocations()

◆ CheckLauncherAndConfig()

◆ CreateMainWindow()

int CreateMainWindow ( HINSTANCE instance,
HINSTANCE previous,
int showCommand )

◆ difficulty()

short difficulty ( void )

Definition at line 154 of file winmain.c.

References difficulty(), and nHazardReferenceSpeed.

Referenced by close_behind(), difficulty(), init_hazard(), and skill_check().

◆ easy2see()

◆ extra_hazard()

void extra_hazard ( short obj)

Definition at line 375 of file winmain.c.

References aeObjectClass, extra_hazard(), OBJECT_CLASS_DUST, and OBJECT_CLASS_NULL.

Referenced by extra_hazard(), and update_star_field().

◆ FreeGuardedAllocation()

◆ GetApplicationInstance()

HINSTANCE GetApplicationInstance ( void )

Definition at line 1032 of file winmain.c.

References GetApplicationInstance(), and hCurrentAppInstance.

Referenced by GetApplicationInstance().

◆ GetF1KeyLatch()

unsigned int GetF1KeyLatch ( void )

Definition at line 817 of file winmain.c.

References bF1KeyLatch, and GetF1KeyLatch().

Referenced by GetF1KeyLatch(), and HandleSpaceFlightControls().

◆ GetJoystickButtons()

short GetJoystickButtons ( void )

Definition at line 1005 of file winmain.c.

References aJoystickInfos, and GetJoystickButtons().

Referenced by GetJoystickButtons(), and ReadJoystickButtons().

◆ GetJoystickDevCaps()

void GetJoystickDevCaps ( short joystick,
unsigned short * xMin,
unsigned short * xMax,
unsigned short * yMin,
unsigned short * yMax )

Definition at line 1012 of file winmain.c.

References GetJoystickDevCaps(), and SystemDebugPrintf().

Referenced by GetJoystickDevCaps(), and LoadJoystickCalibrationFile().

◆ GetJoystickPosition()

int __stdcall GetJoystickPosition ( int * x,
int * y,
unsigned int * buttons,
short joystick,
unsigned short fallback )

Definition at line 969 of file winmain.c.

References aJoystickInfos, and GetJoystickPosition().

Referenced by GetJoystickPosition(), SampleBothJoysticks(), and SampleJoystickDevice().

◆ GetMainWindowDeviceContext()

HDC GetMainWindowDeviceContext ( void )

Definition at line 1048 of file winmain.c.

References GetMainWindowDeviceContext(), and hMainWindowDC.

Referenced by GetMainWindowDeviceContext().

◆ GetMainWindowHandle()

HWND GetMainWindowHandle ( void )

Definition at line 1040 of file winmain.c.

References GetMainWindowHandle(), and hMainWindow.

Referenced by GetMainWindowHandle().

◆ init_hazard()

◆ MainWindowProc()

◆ make_hazard()

short make_hazard ( void )

◆ make_shard()

◆ manage_hazard()

◆ match_ship_to_eye()

◆ near_field()

short near_field ( const HazardField * field,
const FixedVector * point )

Definition at line 280 of file winmain.c.

References HazardField::center, HazardField::innerRadius, IsPointWithinRange(), and near_field().

Referenced by check_hazards(), and near_field().

◆ ok_hazard_spot()

short ok_hazard_spot ( short obj)

◆ PumpWindowMessages()

◆ rear_sphere()

short rear_sphere ( void )

Definition at line 342 of file winmain.c.

References find_ratio(), nHazardReferenceSpeed, and rear_sphere().

Referenced by ok_hazard_spot(), and rear_sphere().

◆ remove_all_hazards()

◆ remove_hazard()

void remove_hazard ( signed char hazard)

◆ ReportHeapGuardCorruption()

void ReportHeapGuardCorruption ( void * memory,
int count,
int overrun )

◆ RestoreGamePalette()

◆ SaveGamePalette()

void SaveGamePalette ( void )

◆ ShowNoticeMessageBox()

void ShowNoticeMessageBox ( const char * text)

Definition at line 657 of file winmain.c.

References DIBpositionWindow(), and ShowNoticeMessageBox().

Referenced by ShowNoticeMessageBox(), and Streamer_open().

◆ ShutdownGameWindow()

◆ skew_randomly()

void skew_randomly ( short obj,
short allowReverse )

◆ start_hazard_field()

void start_hazard_field ( short region)

◆ try_far_spot()

◆ update_hazards()

◆ WarpMouseTo()

◆ WinMain()

◆ within_field()

short within_field ( const HazardField * field,
const FixedVector * point )

Variable Documentation

◆ acHazardPitchRange

signed char acHazardPitchRange[8]
static
Initial value:
= {
-10, 4, -8, 8, -12, 8, -8, 8
}

Definition at line 26 of file winmain.c.

Referenced by try_far_spot().

◆ acHazardTravelTimeByView

signed char acHazardTravelTimeByView[8]
static
Initial value:
= {
56, 52, 75, 73, 0, 0, 0, 0
}

Definition at line 22 of file winmain.c.

Referenced by init_hazard().

◆ awPaletteRgbWordsList

short awPaletteRgbWordsList[0x300]

◆ bCockpitEnabled

int bCockpitEnabled = 1

Definition at line 41 of file winmain.c.

Referenced by CheckLauncherAndConfig(), and RunSpaceFlight().

◆ bDirectDrawModeCascadeEnabled

int bDirectDrawModeCascadeEnabled = 1

Definition at line 37 of file winmain.c.

Referenced by CheckLauncherAndConfig(), DIBinstall(), DIBreInstall(), and main().

◆ bF1KeyLatch

volatile unsigned int bF1KeyLatch = 0

Definition at line 49 of file winmain.c.

Referenced by GetF1KeyLatch(), and MainWindowProc().

◆ bIxAudioEnabled

◆ bKeyEventQueueEnabled

unsigned int bKeyEventQueueEnabled = 0

◆ bMainWindowAlive

int bMainWindowAlive

Definition at line 55 of file winmain.c.

Referenced by CreateMainWindow(), MainWindowProc(), and PumpWindowMessages().

◆ bMainWindowMinimized

volatile int bMainWindowMinimized = 0

Definition at line 42 of file winmain.c.

Referenced by PumpWindowMessages(), and WinMain().

◆ bShowFrameRate

int bShowFrameRate = 0

Definition at line 36 of file winmain.c.

Referenced by CheckLauncherAndConfig(), main(), and ThrottleFrameAndDrawFps().

◆ bShowKilrathiSagaCredits

int bShowKilrathiSagaCredits = 0

Definition at line 35 of file winmain.c.

Referenced by CheckLauncherAndConfig(), and Title_Sequence().

◆ bWindowMessagePumpActive

int bWindowMessagePumpActive = 0

Definition at line 48 of file winmain.c.

Referenced by PumpWindowMessages().

◆ DAT_00465078

int DAT_00465078 = 1

Definition at line 40 of file winmain.c.

◆ DAT_00465084

int DAT_00465084 = 0

Definition at line 43 of file winmain.c.

◆ hCurrentAppInstance

HINSTANCE hCurrentAppInstance

Definition at line 56 of file winmain.c.

Referenced by CreateMainWindow(), and GetApplicationInstance().

◆ hMainWindowDC

HDC hMainWindowDC

Definition at line 52 of file winmain.c.

Referenced by CreateMainWindow(), and GetMainWindowDeviceContext().

◆ hPrevPointer

HCURSOR hPrevPointer

Definition at line 53 of file winmain.c.

Referenced by CreateMainWindow().

◆ nActiveHazards

short nActiveHazards = 0

Definition at line 19 of file winmain.c.

Referenced by init_hazard(), and remove_hazard().

◆ nGuardedAllocationBytes

unsigned int nGuardedAllocationBytes = 0

◆ nGuardedAllocationPeakBytes

unsigned int nGuardedAllocationPeakBytes = 0

Definition at line 34 of file winmain.c.

Referenced by AbortToDesktop(), AllocateGuardedMemory(), and MainWindowProc().

◆ nGuardedAllocationTotalBytes

unsigned int nGuardedAllocationTotalBytes = 0

Definition at line 32 of file winmain.c.

Referenced by AbortToDesktop(), AllocateGuardedMemory(), and MainWindowProc().

◆ nHazardReferenceSpeed

short nHazardReferenceSpeed = 0

Definition at line 18 of file winmain.c.

Referenced by difficulty(), match_ship_to_eye(), rear_sphere(), and update_hazards().

◆ nSessionEndTime

unsigned int nSessionEndTime

Definition at line 54 of file winmain.c.

Referenced by ShutdownGameWindow(), and WinMain().

◆ nSessionStartTime

unsigned int nSessionStartTime

Definition at line 57 of file winmain.c.

Referenced by WinMain().

◆ pGuardedAllocationHead

struct GuardedAllocation* pGuardedAllocationHead = 0

◆ szMainWindowClassName

char szMainWindowClassName[] = "Wing Commander"

Definition at line 45 of file winmain.c.

Referenced by CreateMainWindow().

◆ szMainWindowTitle

char szMainWindowTitle[] = "Wing Commander"

Definition at line 46 of file winmain.c.

Referenced by CreateMainWindow().