1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-20 16:09:12 +01:00
cnc-ddraw/inc/main.h

191 lines
5.9 KiB
C
Raw Normal View History

2010-10-17 00:41:14 +03:00
/*
* Copyright (c) 2010 Toni Spets <toni.spets@iki.fi>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef MAIN_H
#define MAIN_H
#include <windows.h>
#include "ddraw.h"
2017-11-26 08:49:30 +01:00
#include "debug.h"
2010-10-17 00:41:14 +03:00
2018-03-23 03:21:16 +01:00
#define CUTSCENE_WIDTH 640
#define CUTSCENE_HEIGHT 400
#define WM_AUTORENDERER WM_USER+111
#define WM_WINEFULLSCREEN WM_USER+112
2018-10-15 00:01:31 +02:00
#define WM_D3D9DEVICELOST WM_USER+113
#define IDT_TIMER_LEAVE_BNET 541287654
2018-11-18 13:11:05 +01:00
DEFINE_GUID(IID_IMediaStream, 0xb502d1bd, 0x9a57, 0x11d0, 0x8f, 0xde, 0x00, 0xc0, 0x4f, 0xd9, 0x18, 0x9d);
DEFINE_GUID(IID_IAMMediaStream, 0xbebe595d, 0x9a6f, 0x11d0, 0x8f, 0xde, 0x00, 0xc0, 0x4f, 0xd9, 0x18, 0x9d);
2018-09-30 01:02:48 +02:00
extern BOOL ShowDriverWarning;
2018-10-27 16:44:09 +02:00
extern RECT WindowRect;
extern int WindowState;
extern BOOL ChildWindowExists;
2020-09-19 11:23:06 +02:00
extern HMODULE DDrawModule;
2018-06-22 04:27:34 +02:00
2018-10-15 00:57:05 +02:00
BOOL detect_cutscene();
void LimitGameTicks();
void ToggleFullscreen();
2019-08-14 17:53:36 +02:00
void SetWindowRect(int x, int y, int width, int height, UINT flags);
DWORD WINAPI render_main(void);
2018-10-15 00:57:05 +02:00
DWORD WINAPI render_soft_main(void);
2018-11-15 09:45:24 +01:00
BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam);
2018-10-15 00:57:05 +02:00
struct IDirectDrawImpl;
struct IDirectDrawImplVtbl;
2010-11-13 10:49:46 +02:00
struct IDirectDrawSurfaceImpl;
2010-10-17 00:41:14 +03:00
extern struct IDirectDrawImpl *ddraw;
typedef struct SpeedLimiter
{
DWORD ticklength;
LONGLONG tickLengthNs;
HANDLE hTimer;
LARGE_INTEGER dueTime;
BOOL useBltOrFlip;
} SpeedLimiter;
typedef struct IDirectDrawImpl
2010-10-17 00:41:14 +03:00
{
struct IDirectDrawImplVtbl *lpVtbl;
2010-10-17 00:41:14 +03:00
ULONG Ref;
DWORD width;
DWORD height;
DWORD bpp;
2010-10-27 20:13:32 +03:00
BOOL windowed;
2011-07-09 15:20:57 +03:00
BOOL border;
BOOL boxing;
2010-11-12 19:50:00 +02:00
DEVMODE mode;
2010-11-13 10:49:46 +02:00
struct IDirectDrawSurfaceImpl *primary;
char title[128];
HMODULE real_dll;
2010-11-06 08:28:11 +02:00
/* real export from system32\ddraw.dll */
2018-05-06 10:52:06 +02:00
HRESULT (WINAPI *DirectDrawCreate)(GUID FAR*, LPDIRECTDRAW FAR*, IUnknown FAR*);
CRITICAL_SECTION cs;
2010-11-12 19:50:00 +02:00
struct
2010-11-06 08:28:11 +02:00
{
2010-11-06 21:30:48 +02:00
int maxfps;
2020-01-23 08:58:22 +01:00
BOOL forcefps;
2010-11-06 21:30:48 +02:00
int width;
int height;
int bpp;
2010-11-06 21:30:48 +02:00
HDC hDC;
int *tex;
2010-11-06 08:28:11 +02:00
HANDLE thread;
BOOL run;
HANDLE sem;
2010-11-12 19:50:00 +02:00
DEVMODE mode;
struct { int width; int height; int x; int y; } viewport;
2010-11-06 08:28:11 +02:00
2018-07-04 23:27:12 +02:00
LONG paletteUpdated;
LONG surfaceUpdated;
2018-11-16 02:59:42 +01:00
float scaleW;
float scaleH;
float unScaleW;
float unScaleH;
2010-11-12 19:50:00 +02:00
} render;
2010-10-17 00:41:14 +03:00
HWND hWnd;
2018-05-06 10:52:06 +02:00
LRESULT (CALLBACK *WndProc)(HWND, UINT, WPARAM, LPARAM);
struct { float x; float y; } cursor;
BOOL locked;
2018-03-11 21:23:22 +01:00
BOOL adjmouse;
BOOL devmode;
BOOL vsync;
2011-03-24 19:41:36 +02:00
BOOL vhack;
BOOL isredalert;
2018-03-23 03:21:16 +01:00
BOOL iscnc1;
2018-08-23 00:57:31 +02:00
LONG incutscene;
2018-05-06 10:52:06 +02:00
DWORD (WINAPI *renderer)(void);
2017-11-20 05:11:39 +01:00
BOOL fullscreen;
2018-03-14 14:02:04 +01:00
BOOL maintas;
2018-03-19 02:27:55 +01:00
BOOL noactivateapp;
BOOL handlemouse;
char shader[MAX_PATH];
BOOL wine;
BOOL altenter;
BOOL hidecursor;
2018-11-30 05:18:44 +01:00
BOOL accurateTimers;
2019-08-13 15:46:05 +02:00
BOOL resizable;
2020-09-27 13:38:41 +02:00
BOOL tm2hack;
BOOL sierrahack;
BOOL nonexclusive;
BOOL bnetActive;
2019-08-08 07:13:53 +02:00
BOOL bnetWasFullscreen;
2019-08-19 17:02:36 +02:00
BOOL bnetWasUpscaled;
2019-08-14 17:53:36 +02:00
RECT bnetWinRect;
POINT bnetPos;
SpeedLimiter ticksLimiter;
SpeedLimiter flipLimiter;
SpeedLimiter fpsLimiter;
2017-11-12 14:57:27 +01:00
} IDirectDrawImpl;
typedef struct IDirectDrawImplVtbl IDirectDrawImplVtbl;
struct IDirectDrawImplVtbl
{
HRESULT(__stdcall *QueryInterface) (IDirectDrawImpl *, const IID* const riid, LPVOID * ppvObj);
ULONG(__stdcall *AddRef) (IDirectDrawImpl *);
ULONG(__stdcall *Release) (IDirectDrawImpl *);
HRESULT(__stdcall *Compact)(IDirectDrawImpl *);
HRESULT(__stdcall *CreateClipper)(IDirectDrawImpl *, DWORD, LPDIRECTDRAWCLIPPER *, IUnknown *);
HRESULT(__stdcall *CreatePalette)(IDirectDrawImpl *, DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE *, IUnknown *);
HRESULT(__stdcall *CreateSurface)(IDirectDrawImpl *, LPDDSURFACEDESC, LPDIRECTDRAWSURFACE *, IUnknown *);
HRESULT(__stdcall *DuplicateSurface)( IDirectDrawImpl *, LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE *);
HRESULT(__stdcall *EnumDisplayModes)( IDirectDrawImpl *, DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK);
HRESULT(__stdcall *EnumSurfaces)(IDirectDrawImpl *, DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK);
HRESULT(__stdcall *FlipToGDISurface)(IDirectDrawImpl *);
HRESULT(__stdcall *GetCaps)(IDirectDrawImpl *, LPDDCAPS, LPDDCAPS);
HRESULT(__stdcall *GetDisplayMode)(IDirectDrawImpl *, LPDDSURFACEDESC);
HRESULT(__stdcall *GetFourCCCodes)(IDirectDrawImpl *, LPDWORD, LPDWORD);
HRESULT(__stdcall *GetGDISurface)(IDirectDrawImpl *, LPDIRECTDRAWSURFACE *);
HRESULT(__stdcall *GetMonitorFrequency)(IDirectDrawImpl *, LPDWORD);
HRESULT(__stdcall *GetScanLine)(IDirectDrawImpl *, LPDWORD);
HRESULT(__stdcall *GetVerticalBlankStatus)(IDirectDrawImpl *, LPBOOL);
HRESULT(__stdcall *Initialize)(IDirectDrawImpl *, GUID *);
HRESULT(__stdcall *RestoreDisplayMode)(IDirectDrawImpl *);
HRESULT(__stdcall *SetCooperativeLevel)(IDirectDrawImpl *, HWND, DWORD);
2018-11-02 02:21:16 +01:00
union
{
HRESULT(__stdcall *SetDisplayMode1)(IDirectDrawImpl *, DWORD, DWORD, DWORD);
HRESULT(__stdcall *SetDisplayMode2)(IDirectDrawImpl *, DWORD, DWORD, DWORD, DWORD, DWORD);
};
HRESULT(__stdcall *WaitForVerticalBlank)(IDirectDrawImpl *, DWORD, HANDLE);
2019-08-30 05:37:29 +02:00
HRESULT(__stdcall *GetAvailableVidMem)(IDirectDrawImpl *, LPDDSCAPS, LPDWORD, LPDWORD);
};
2010-10-17 00:41:14 +03:00
2018-03-10 10:19:54 +01:00
typedef enum PROCESS_DPI_AWARENESS {
PROCESS_DPI_UNAWARE = 0,
PROCESS_SYSTEM_DPI_AWARE = 1,
PROCESS_PER_MONITOR_DPI_AWARE = 2
} PROCESS_DPI_AWARENESS;
2010-10-17 00:41:14 +03:00
#endif