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

DirectDraw back end: frame buffer, palette and screen updates. More...

#include "wc1.h"
#include <sys/stat.h>

Go to the source code of this file.

Functions

int DIBcascade (int mode, int *reportedResult)
void ThrottleFrameAndDrawFps (HDC dc)
void ReportSpaceFlightMaxFps (float adjustment)
void SetSpaceFlightFrameTiming (void)
void SetCinematicFrameTiming (void)
void DIBerror (const char *tag, int hr)
void DIBpositionWindow (void)
void DIBreInstall (void)
void DIBinstall (HWND window)
void DIBunInstall (void)
void DIBmakeDIB (void)
void DIBdestroyDIB (void)
void DIBslam (void)
void DIBslamReal (void)
void DIBupdate (int left, int top, int right, int bottom)
unsigned char * GetDIBPixelBuffer (void)
void DIBpixelBufferHook (void)
HWND GetDIBWindowHandle (void)
unsigned int GetDIBWidth (void)
unsigned int GetDIBHeight (void)
void CachePaletteEntryFromWords (short index, short *rgb)
void DIBramPalette (void)
void DIBsetPalette (short index, short *rgb)
void GetPaletteEntryAsWords (short i, short *rgb)
void DIBwholePaletteFromTriplets (unsigned char *palette)
void DIBwholePaletteFromWords (short *palette)
void DIBwaitForVerticalBlank (void)
char * DirectDrawResultToText (int result)

Variables

static LPDIRECTDRAW2 pDirectDraw2 = 0
static LPDIRECTDRAWSURFACE pPrimarySurface = 0
static LPDIRECTDRAWSURFACE pSecondarySurface = 0
static LPDIRECTDRAWPALETTE pDirectDrawPalette = 0
static int nDIBCascadeLevel = -1
int nFrameIntervalMs = 62
static int nFrameDeadlineMs = 0
static int DAT_0046b1c0 = 0
static int nPreviousFrameTimeMs = 0
static int bSpaceFlightFrameTiming = 0
static float fSpaceFlightFrameRate = 20.0f
static float fCinematicFrameRate = 16.0f
static int DAT_0046b1d4 = 0
const GUID CLSID_DirectDraw
const GUID CLSID_DirectDrawClipper
const GUID IID_IDirectDraw
const GUID guidDirectDraw2
const GUID IID_IDirectDrawSurface
const GUID IID_IDirectDrawSurface2
const GUID IID_IDirectDrawPalette
const GUID IID_IDirectDrawClipper
static unsigned int nDIBFrameHeight
static unsigned int nDIBFrameWidth
static unsigned char * pDIBImage
static unsigned char szFrameRateLabel [32]
static unsigned int DAT_00476640
static unsigned int DAT_00476644
static unsigned char abDIBPixelBackup [0xfa00]
static int DAT_00486058
static int nUnusedDIBData
static int nDIBSlamTotal
static int nUnusedDIBValue
static unsigned char abUnusedDIBArea [12]
static char szDIBFailureString [0x98]
static HWND hDIBParentWindow
static unsigned char abDIBPaletteQuads [1024]
static float fSampledFps
static int nUnusedDIBLevel
static int bPendingDIBSlam
static unsigned char abUnusedDIBRect [8]
static char szSpaceFlightFpsCapMessage [0x80]
signed char cCurrentNavPtIdx
short asObjectFlipArray [SPACE_OBJECT_COUNT]
short nEyeRollTargetValue
FixedVector vPreviousStarFieldMotion
short nCurrentHazardFieldTotal
signed char acPreviousAttackers [16]
signed char acViableTargetList [16]
short asActionCounts [10]
short nEyeYawGoalValue
short asObjScreenScalesArray [SPACE_OBJECT_COUNT]
short asObjAfterburnerVelocities [SPACE_OBJECT_COUNT]
CampaignState stCampaignState
signed char aShipWeaponsTable [10][0x47]

Detailed Description

DirectDraw back end: frame buffer, palette and screen updates.

Address range 431f00-43390f. The named DirectDraw routines are followed by DirectDrawResultToText and its compiler-generated switch tables. ThrottleFrameAndDrawFps belongs here: it uses this unit's statics szFrameRateLabel and fSampledFps, and its 1000.0 constant follows the unit's DirectDraw GUIDs in .rdata.

Definition in file dib.c.

Function Documentation

◆ CachePaletteEntryFromWords()

void CachePaletteEntryFromWords ( short index,
short * rgb )

◆ DIBcascade()

int DIBcascade ( int mode,
int * reportedResult )

◆ DIBdestroyDIB()

◆ DIBerror()

◆ DIBinstall()

◆ DIBmakeDIB()

◆ DIBpixelBufferHook()

void DIBpixelBufferHook ( void )

Definition at line 735 of file dib.c.

References DIBpixelBufferHook().

Referenced by DIBpixelBufferHook().

◆ DIBpositionWindow()

◆ DIBramPalette()

void DIBramPalette ( void )

◆ DIBreInstall()

◆ DIBsetPalette()

void DIBsetPalette ( short index,
short * rgb )

◆ DIBslam()

void DIBslam ( void )

Definition at line 513 of file dib.c.

References bPendingDIBSlam, and DIBslam().

Referenced by AnimateScrambleWalk(), AnimateTrainSimTitle(), AppendFormattedText(), BarracksScreen(), BlitViewportScanlineRuns(), ClearViewport(), CloseLook(), death_sequence(), DeBriefing(), DebriefingEstablishingShot(), DIBreInstall(), DIBslam(), Dismissed(), DisplayTrainSimHighScoreTable(), DrawDebriefingLongShot(), DrawFormattedText(), DrawFuneralLongShot(), DrawMedalChest(), DrawMedalLongShot(), DrawMedals(), DrawNavLocationReadout(), DrawScrambleFrame(), DrawTextAt(), DrawViewportEllipse(), DrawViewportEllipseShadow(), ejection_sequence(), EstablishingShot(), FadeViewportPaletteToColour(), FillViewportEllipse(), fizzle_fade(), FormatTextBufferFromStart(), funeral_player(), InflightComputer(), initialize_cockpit(), landing(), LaunchPlayerShip(), LongTalk(), MedalEstablish(), Office(), PanToScreen(), PinMedal(), PlaySceneAnimation(), PlayScrambleHangarScene(), PlaySfxWaveFileByNumber(), print_subtitle(), PromptForTextInput(), PumpWindowMessages(), ReadTextInput(), RecRoom(), ReleaseModalTextPanel(), RestoreSpriteBackground(), ReturnToBriefingLongShot(), RunSpaceFlight(), RunTrainSim(), SelectTrainSimMission(), shaded_triangle(), shadow_draw(), ShowCampaignVictorySequence(), ShowCarrierLaunchSequence(), ShowChalkBoard(), ShowGameOverScreen(), ShowGetReadyScreen(), ShowMeanwhileTransition(), ShowModalTextPanel(), ShowTheEndScreen(), ShowTigerClawEscapeScene(), ShowTrainSimHighScores(), ShowTrainSimTextMessage(), ShowVictoryScreen(), snow_viewport(), stranded_sequence(), Title_Sequence(), triangle(), UpdateTrainSimHighScores(), ValidateViewportBounds(), ViewMedals(), and visit_the_cinema().

◆ DIBslamReal()

void DIBslamReal ( void )

Definition at line 519 of file dib.c.

References bPendingDIBSlam, CaptureMouseCursorBackground(), DIBerror(), DIBslamReal(), DrawMouseCursor(), hDIBParentWindow, nDIBCascadeLevel, nDIBFrameHeight, nDIBFrameWidth, nDIBSlamTotal, pDIBImage, pDirectDraw2, Viewport::pixels, pPrimarySurface, pSecondarySurface, RestoreMouseCursorBackground(), ServiceSoundSystem(), stMouseCursorState, ThrottleFrameAndDrawFps(), UpdateStreamerStoppedFlag(), and MouseCursorState::viewport.

Referenced by AnimateScrambleWalk(), AnimateTrainSimTitle(), BarracksScreen(), CalibrateJoystickInteractive(), ClearViewport(), CloseLook(), death_sequence(), DeBriefing(), DebriefingEstablishingShot(), DIBreInstall(), DIBslamReal(), Dismissed(), DisplayTrainSimHighScoreTable(), DrawDebriefingLongShot(), DrawFuneralLongShot(), DrawMedalChest(), DrawMedalLongShot(), DrawMedals(), DrawNavLocationReadout(), DrawScrambleFrame(), ejection_sequence(), EstablishingShot(), FadeViewportPaletteToColour(), funeral_player(), InflightComputer(), initialize_cockpit(), landing(), LaunchPlayerShip(), LongTalk(), MedalEstablish(), Office(), PanToScreen(), PinMedal(), PlaySceneAnimation(), PlayScrambleHangarScene(), PlaySfxWaveFileByNumber(), PromptForTextInput(), PumpWindowMessages(), ReadTextInput(), RecRoom(), ReleaseModalTextPanel(), ReturnToBriefingLongShot(), RunSpaceFlight(), RunTrainSim(), SelectTrainSimMission(), ShowCampaignVictorySequence(), ShowCarrierLaunchSequence(), ShowChalkBoard(), ShowGameOverScreen(), ShowGetReadyScreen(), ShowMeanwhileTransition(), ShowModalTextPanel(), ShowTheEndScreen(), ShowTigerClawEscapeScene(), ShowTrainSimHighScores(), ShowTrainSimTextMessage(), ShowVictoryScreen(), stranded_sequence(), Title_Sequence(), UpdateTrainSimHighScores(), ViewMedals(), and visit_the_cinema().

◆ DIBunInstall()

◆ DIBupdate()

void DIBupdate ( int left,
int top,
int right,
int bottom )

◆ DIBwaitForVerticalBlank()

void DIBwaitForVerticalBlank ( void )

◆ DIBwholePaletteFromTriplets()

void DIBwholePaletteFromTriplets ( unsigned char * palette)

◆ DIBwholePaletteFromWords()

void DIBwholePaletteFromWords ( short * palette)

◆ DirectDrawResultToText()

char * DirectDrawResultToText ( int result)

Definition at line 924 of file dib.c.

References DirectDrawResultToText().

Referenced by DIBerror(), DirectDrawResultToText(), and PlaySfxWaveFileByNumber().

◆ GetDIBHeight()

unsigned int GetDIBHeight ( void )

Definition at line 754 of file dib.c.

References GetDIBHeight(), and nDIBFrameHeight.

Referenced by GetDIBHeight().

◆ GetDIBPixelBuffer()

unsigned char * GetDIBPixelBuffer ( void )

◆ GetDIBWidth()

unsigned int GetDIBWidth ( void )

Definition at line 747 of file dib.c.

References GetDIBWidth(), and nDIBFrameWidth.

Referenced by GetDIBWidth().

◆ GetDIBWindowHandle()

HWND GetDIBWindowHandle ( void )

Definition at line 740 of file dib.c.

References GetDIBWindowHandle(), and hDIBParentWindow.

Referenced by GetDIBWindowHandle(), and PlaySfxWaveFileByNumber().

◆ GetPaletteEntryAsWords()

void GetPaletteEntryAsWords ( short i,
short * rgb )

◆ ReportSpaceFlightMaxFps()

◆ SetCinematicFrameTiming()

◆ SetSpaceFlightFrameTiming()

◆ ThrottleFrameAndDrawFps()

Variable Documentation

◆ abDIBPaletteQuads

◆ abDIBPixelBackup

unsigned char abDIBPixelBackup[0xfa00]
static

Definition at line 78 of file dib.c.

Referenced by DIBdestroyDIB(), DIBinstall(), and DIBmakeDIB().

◆ abUnusedDIBArea

unsigned char abUnusedDIBArea[12]
static

Definition at line 83 of file dib.c.

◆ abUnusedDIBRect

unsigned char abUnusedDIBRect[8]
static

Definition at line 92 of file dib.c.

◆ acPreviousAttackers

signed char acPreviousAttackers[16]

Definition at line 101 of file dib.c.

Referenced by house_keep_objects(), object_collision(), set_objects_data(), and Set_up_ship_info().

◆ acViableTargetList

◆ asActionCounts

short asActionCounts[10]

◆ aShipWeaponsTable

◆ asObjAfterburnerVelocities

short asObjAfterburnerVelocities[SPACE_OBJECT_COUNT]

Definition at line 106 of file dib.c.

Referenced by apply_force_to_object(), rotational_acceleration(), and set_objects_data().

◆ asObjectFlipArray

◆ asObjScreenScalesArray

◆ bPendingDIBSlam

int bPendingDIBSlam
static

Definition at line 91 of file dib.c.

Referenced by DIBinstall(), DIBslam(), and DIBslamReal().

◆ bSpaceFlightFrameTiming

int bSpaceFlightFrameTiming = 0
static

◆ cCurrentNavPtIdx

◆ CLSID_DirectDraw

const GUID CLSID_DirectDraw
Initial value:
= {
0xd7b70ee0, 0x4340, 0x11cf,
{ 0xb0, 0x63, 0x00, 0x20, 0xaf, 0xc2, 0xcd, 0x35 }
}

Definition at line 33 of file dib.c.

◆ CLSID_DirectDrawClipper

const GUID CLSID_DirectDrawClipper
Initial value:
= {
0x593817a0, 0x7db3, 0x11cf,
{ 0xa2, 0xde, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56 }
}

Definition at line 37 of file dib.c.

◆ DAT_0046b1c0

int DAT_0046b1c0 = 0
static

Definition at line 23 of file dib.c.

◆ DAT_0046b1d4

int DAT_0046b1d4 = 0
static

Definition at line 29 of file dib.c.

◆ DAT_00476640

unsigned int DAT_00476640
static

Definition at line 76 of file dib.c.

Referenced by DIBdestroyDIB(), and DIBmakeDIB().

◆ DAT_00476644

unsigned int DAT_00476644
static

Definition at line 77 of file dib.c.

Referenced by DIBdestroyDIB(), and DIBmakeDIB().

◆ DAT_00486058

int DAT_00486058
static

Definition at line 79 of file dib.c.

Referenced by DIBmakeDIB().

◆ fCinematicFrameRate

float fCinematicFrameRate = 16.0f
static

Definition at line 27 of file dib.c.

Referenced by SetCinematicFrameTiming().

◆ fSampledFps

float fSampledFps
static

Definition at line 89 of file dib.c.

Referenced by ThrottleFrameAndDrawFps().

◆ fSpaceFlightFrameRate

float fSpaceFlightFrameRate = 20.0f
static

Definition at line 26 of file dib.c.

Referenced by ReportSpaceFlightMaxFps(), and SetSpaceFlightFrameTiming().

◆ guidDirectDraw2

const GUID guidDirectDraw2
Initial value:
= {
0xb3a6f3e0, 0x2b43, 0x11cf,
{ 0xa2, 0xde, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56 }
}

Definition at line 45 of file dib.c.

Referenced by DIBinstall().

◆ hDIBParentWindow

HWND hDIBParentWindow
static

◆ IID_IDirectDraw

const GUID IID_IDirectDraw
Initial value:
= {
0x6c14db80, 0xa733, 0x11ce,
{ 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60 }
}

Definition at line 41 of file dib.c.

◆ IID_IDirectDrawClipper

const GUID IID_IDirectDrawClipper
Initial value:
= {
0x6c14db85, 0xa733, 0x11ce,
{ 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60 }
}

Definition at line 61 of file dib.c.

◆ IID_IDirectDrawPalette

const GUID IID_IDirectDrawPalette
Initial value:
= {
0x6c14db84, 0xa733, 0x11ce,
{ 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60 }
}

Definition at line 57 of file dib.c.

◆ IID_IDirectDrawSurface

const GUID IID_IDirectDrawSurface
Initial value:
= {
0x6c14db81, 0xa733, 0x11ce,
{ 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60 }
}

Definition at line 49 of file dib.c.

◆ IID_IDirectDrawSurface2

const GUID IID_IDirectDrawSurface2
Initial value:
= {
0x57805885, 0x6eec, 0x11cf,
{ 0x94, 0x41, 0xa8, 0x23, 0x03, 0xc1, 0x0e, 0x27 }
}

Definition at line 53 of file dib.c.

◆ nCurrentHazardFieldTotal

short nCurrentHazardFieldTotal

Definition at line 100 of file dib.c.

Referenced by add_hazard_field(), check_hazards(), house_keep(), and set_up_action_sphere().

◆ nDIBCascadeLevel

int nDIBCascadeLevel = -1
static

◆ nDIBFrameHeight

unsigned int nDIBFrameHeight
static

Definition at line 72 of file dib.c.

Referenced by DIBdestroyDIB(), DIBmakeDIB(), DIBslamReal(), and GetDIBHeight().

◆ nDIBFrameWidth

unsigned int nDIBFrameWidth
static

Definition at line 73 of file dib.c.

Referenced by DIBdestroyDIB(), DIBmakeDIB(), DIBslamReal(), DIBupdate(), and GetDIBWidth().

◆ nDIBSlamTotal

int nDIBSlamTotal
static

Definition at line 81 of file dib.c.

Referenced by DIBinstall(), and DIBslamReal().

◆ nEyeRollTargetValue

short nEyeRollTargetValue

◆ nEyeYawGoalValue

short nEyeYawGoalValue

Definition at line 104 of file dib.c.

Referenced by new_view(), parse_view_script(), rotate_eye_to_goal(), and update_scripted_view().

◆ nFrameDeadlineMs

int nFrameDeadlineMs = 0
static

◆ nFrameIntervalMs

int nFrameIntervalMs = 62

◆ nPreviousFrameTimeMs

int nPreviousFrameTimeMs = 0
static

Definition at line 24 of file dib.c.

Referenced by ThrottleFrameAndDrawFps().

◆ nUnusedDIBData

int nUnusedDIBData
static

Definition at line 80 of file dib.c.

◆ nUnusedDIBLevel

int nUnusedDIBLevel
static

Definition at line 90 of file dib.c.

◆ nUnusedDIBValue

int nUnusedDIBValue
static

Definition at line 82 of file dib.c.

◆ pDIBImage

unsigned char* pDIBImage
static

◆ pDirectDraw2

◆ pDirectDrawPalette

LPDIRECTDRAWPALETTE pDirectDrawPalette = 0
static

◆ pPrimarySurface

◆ pSecondarySurface

LPDIRECTDRAWSURFACE pSecondarySurface = 0
static

◆ stCampaignState

◆ szDIBFailureString

char szDIBFailureString[0x98]
static

Definition at line 85 of file dib.c.

Referenced by DIBerror().

◆ szFrameRateLabel

unsigned char szFrameRateLabel[32]
static

Definition at line 75 of file dib.c.

Referenced by ThrottleFrameAndDrawFps().

◆ szSpaceFlightFpsCapMessage

char szSpaceFlightFpsCapMessage[0x80]
static

Definition at line 93 of file dib.c.

Referenced by ReportSpaceFlightMaxFps().

◆ vPreviousStarFieldMotion

FixedVector vPreviousStarFieldMotion

Definition at line 99 of file dib.c.

Referenced by update_star_field().