coastline 0.0.4
Loading...
Searching...
No Matches
app.h
Go to the documentation of this file.
1#pragma once
2
8
9#include <cstddef>
10
11#include <windows.h>
12
13#include "common/fatalerror.h"
14#include "common/screen.h"
15#include "common/session.h"
16
23extern int g_dwAppExitCode;
24
31extern char g_szInstallDirectory[];
32
40
44
48
51extern int g_nRallyMainCmdShow;
52
59extern size_t g_dwTotalPhysicalMemory;
60
68
75extern HWND g_hMainWindow;
76
83
92
99extern int g_dwActivateState;
100
107extern int g_dwActivateMinimized;
108
109#ifdef __cplusplus
110extern "C" {
111#endif
112
114enum {
120};
121
128extern int g_dwGameState;
129
136extern int (*g_apfnGameStateHandlers[])(void);
137
144extern int g_dwGameModeFrameCounter;
145
152extern int g_dwGameModeContinue;
153
163
172
181
191
200
208
219
220#if TGR_RENDERER == TGR_RENDERER_GLIDE
228void ShowGlideSplashImage(const char *pszPath, int nChecksum);
229#endif /* TGR_RENDERER == TGR_RENDERER_GLIDE */
230
231#ifdef __cplusplus
232}
233#endif
234
236
243
244#ifdef __cplusplus
245extern "C" {
246#endif
247
259LRESULT CALLBACK MainWindowProc(HWND hWnd, UINT nMessage, WPARAM wParam, LPARAM lParam);
260
269
280
292
301
312
321
330
341
352
363
374
385
396
407
418
430
441
451
461
487 LPCSTR pszClassName,
488 LPCSTR pszWindowName,
489 DWORD dwStyle,
490 int x,
491 int y,
492 int nWidth,
493 int nHeight,
494 HWND hParent,
495 HMENU hMenu,
496 HINSTANCE hInstance,
497 LPVOID pParam,
498 GUID *pDriverGuid,
499 int nUnused,
500 HWND *phWnd,
501 DirectDrawRenderer **ppRenderer);
502
509
517
526
536void GetDXVersion(unsigned *pdwVersion, unsigned *pdwPlatform);
537
546
554
562
571
580
587void RunMessageLoop(void);
588
595#ifdef __cplusplus
596}
597#endif
bool FocusExistingBossRallyInstance(void)
Bring an instance of the game that is already running to the front.
LRESULT HandleWindowClose(HWND hWnd)
Handle WM_CLOSE.
int DestroyMainWindow(void)
Destroy the main window and its renderer.
LRESULT DetachRenderDeviceFromWindow(HWND hWnd, LPARAM lParam)
Clear the renderer that is releasing its objects from the user data of its window.
int(* g_apfnGameStateHandlers[])(void)
The routine that runs a frame of each state of the game.
bool CreateMainWindow(void)
Create the main window.
int g_nRallyMainCmdShow
The initial window display mode passed to RallyMain().
WPARAM g_dwAppActive
The first parameter of the last WM_ACTIVATE.
char g_szInstallDirectory[]
Directory the game is installed in, read from the registry, with a trailing separator.
LRESULT HandleWindowMove(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_MOVE.
int g_dwActivateMinimized
Whether the main window is minimised.
LRESULT HandleWindowSetCursor(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_SETCURSOR.
LRESULT HandleWindowEnterMenuLoop(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_ENTERMENULOOP.
LRESULT HandleWindowActivate(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_ACTIVATE.
LRESULT HandleWindowSysCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_SYSCOMMAND.
HINSTANCE g_hAppInstance
The module of the game, set by InitializeApplication().
int g_dwGameModeFrameCounter
The frames the mode of the game has run.
void UpdateAppActiveStateFromActivate(WPARAM wParam)
Set whether the application is active from the state of WM_ACTIVATE.
LRESULT HandleWindowGetMinMaxInfo(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_GETMINMAXINFO.
HINSTANCE g_hRallyMainPrevInstance
The previous application instance passed to RallyMain().
void GetDXVersion(unsigned *pdwVersion, unsigned *pdwPlatform)
Query the installed DirectX version by creating its objects in turn.
void ShowGlideSplashImage(const char *pszPath, int nChecksum)
Show an image of the Glide library over the whole screen.
LRESULT HandleWindowCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_COMMAND.
HRESULT CreateRenderWindow(DWORD dwExStyle, LPCSTR pszClassName, LPCSTR pszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hParent, HMENU hMenu, HINSTANCE hInstance, LPVOID pParam, GUID *pDriverGuid, int nUnused, HWND *phWnd, DirectDrawRenderer **ppRenderer)
Create a window and the renderer that draws into it, and show the window.
int GameState_InitResources(void)
Open the pod of the game files, load the first sound set and the names of the controls of the game co...
HINSTANCE g_hRallyMainInstance
Arguments of WinMain() as the launcher passed them to RallyMain().
void ShutdownMainWindow(void)
Destroy the main window.
int GameState_ShowLoadingScreenAndInitGame(void)
Set the display mode of the configuration, show the loading screen, set up the game,...
LRESULT HandleWindowDestroy(HWND hWnd)
Handle WM_DESTROY.
HACCEL g_hAccelTable
The keyboard accelerators of the main window.
LRESULT HandleWindowActivateApp(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_ACTIVATEAPP.
LRESULT HandleWindowExitMenuLoop(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_EXITMENULOOP.
LRESULT HandleWindowPosChanging(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_WINDOWPOSCHANGING.
@ GAME_STATE_INIT_RESOURCES
Definition app.h:115
@ GAME_STATE_RUN_FRONT_END
Definition app.h:119
@ GAME_STATE_ENTER_GAME_MODE
Definition app.h:116
@ GAME_STATE_RUN_GAME_MODE
Definition app.h:117
@ GAME_STATE_LOAD_GAME
Definition app.h:118
HWND g_hMainWindow
The main window.
int g_dwGameModeContinue
What GameState_RunGameMode() returns, 1 at the start.
int g_dwAppExitCode
Exit code RallyMain() returns to the launcher.
int GameState_RunFrontEnd(void)
Run a frame of the front end.
bool InitializeApplication(void)
Start the application: refuse DirectX before version 6 and a second instance, then create the main wi...
LPSTR g_pszRallyMainCmdLine
The command line passed to RallyMain().
LRESULT HandleDisplayChange(HWND hWnd)
Handle WM_DISPLAYCHANGE.
LRESULT AttachRenderDeviceToWindow(HWND hWnd, LPARAM lParam)
Store the renderer that has created its objects in the user data of its window.
LRESULT HandleWindowSize(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_SIZE.
int GameState_EnterGameMode(void)
Go on to run the mode of the game.
void ReadInstallDirectoryFromRegistry(void)
Read the install directory from the registry into g_szInstallDirectory.
void SetGameStateFrontEnd(void)
Go back to the front end after a game, setting it up again.
LRESULT HandleWindowNcPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_NCPAINT.
bool OpenBossRallyPodAndInit(void)
Open BossRally.pod, and set up the renderer, the damage bitmaps of the paint, DirectInput,...
int DispatchGameStateFrame(void)
Run a frame of the current state of the game.
void RefreshTotalPhysicalMemory(void)
Read the amount of physical memory the machine has.
LRESULT CALLBACK MainWindowProc(HWND hWnd, UINT nMessage, WPARAM wParam, LPARAM lParam)
Handle the messages of the main window.
HCURSOR g_hArrowCursor
The arrow cursor of the main window.
int g_dwGameState
The state of the game, an index into g_apfnGameStateHandlers.
size_t g_dwTotalPhysicalMemory
The amount of physical memory of the machine, in bytes.
void RunMessageLoop(void)
Run the message loop until the game quits.
int GameState_RunGameMode(void)
Run a frame of the mode of the game.
DirectDrawRenderer * g_pMainRenderWindow
The renderer of the main window.
LRESULT HandleWindowEraseBackground(HWND hWnd, WPARAM wParam, LPARAM lParam)
Handle WM_ERASEBKGND.
int g_dwActivateState
How the main window is activated, WA_INACTIVE, WA_ACTIVE, or WA_CLICKACTIVE.
The DirectDraw and Direct3D objects of a window.
Definition renderer.h:652
The size of the frame, and the routines of the screen the main loop calls.
The state of the session of the Boss Rally release the race shares with the front end.
typedef CALLBACK
typedef DWORD
typedef HACCEL
typedef HCURSOR
typedef HINSTANCE
typedef HMENU
typedef HRESULT
typedef HWND
typedef LPARAM
typedef LPCSTR
typedef LPSTR
typedef LPVOID
typedef LRESULT
typedef UINT
typedef WPARAM