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
|
|
|
|
|
2018-06-26 18:02:03 +02:00
|
|
|
#define WM_AUTORENDERER WM_USER+111
|
2018-08-14 15:43:48 +02:00
|
|
|
#define WM_WINEFULLSCREEN WM_USER+112
|
2018-10-15 00:01:31 +02:00
|
|
|
#define WM_D3D9DEVICELOST WM_USER+113
|
2018-06-26 18:02:03 +02:00
|
|
|
|
2018-09-30 01:02:48 +02:00
|
|
|
extern BOOL ShowDriverWarning;
|
2018-10-27 16:44:09 +02:00
|
|
|
extern RECT WindowRect;
|
2018-06-22 04:27:34 +02:00
|
|
|
|
2018-10-15 00:57:05 +02:00
|
|
|
BOOL detect_cutscene();
|
2018-10-31 11:48:41 +01:00
|
|
|
void LimitGameTicks();
|
2018-10-25 07:03:01 +02:00
|
|
|
DWORD WINAPI render_main(void);
|
2018-10-15 00:57:05 +02:00
|
|
|
DWORD WINAPI render_soft_main(void);
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
struct IDirectDrawImpl;
|
|
|
|
struct IDirectDrawImplVtbl;
|
2010-11-13 10:49:46 +02:00
|
|
|
struct IDirectDrawSurfaceImpl;
|
2010-10-17 00:41:14 +03:00
|
|
|
|
2010-10-24 01:02:08 +03:00
|
|
|
extern struct IDirectDrawImpl *ddraw;
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
typedef struct IDirectDrawImpl
|
2010-10-17 00:41:14 +03:00
|
|
|
{
|
2010-10-23 17:04:01 +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;
|
2011-07-09 17:39:01 +03:00
|
|
|
BOOL boxing;
|
2010-11-13 10:49:46 +02:00
|
|
|
BOOL windowed_init;
|
2010-11-12 19:50:00 +02:00
|
|
|
DEVMODE mode;
|
2010-11-13 10:49:46 +02:00
|
|
|
struct IDirectDrawSurfaceImpl *primary;
|
2010-11-21 17:11:47 +02:00
|
|
|
char title[128];
|
2010-11-23 17:36:12 +02:00
|
|
|
HMODULE real_dll;
|
2010-11-06 08:28:11 +02:00
|
|
|
|
2010-11-06 21:42:37 +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*);
|
2010-11-15 22:25:12 +02:00
|
|
|
CRITICAL_SECTION cs;
|
2010-11-06 21:42:37 +02:00
|
|
|
|
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;
|
|
|
|
int width;
|
|
|
|
int height;
|
2010-11-07 09:59:44 +02:00
|
|
|
int bpp;
|
2010-11-06 21:30:48 +02:00
|
|
|
|
2010-11-16 18:07:59 +02:00
|
|
|
HDC hDC;
|
|
|
|
int *tex;
|
|
|
|
|
2010-11-06 08:28:11 +02:00
|
|
|
HANDLE thread;
|
|
|
|
BOOL run;
|
|
|
|
HANDLE ev;
|
2011-06-29 22:47:29 +03:00
|
|
|
HANDLE sem;
|
2010-11-12 19:50:00 +02:00
|
|
|
DEVMODE mode;
|
2018-03-15 20:49:27 +01:00
|
|
|
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;
|
2010-11-12 19:50:00 +02:00
|
|
|
} render;
|
2010-10-17 00:41:14 +03:00
|
|
|
|
2010-10-17 10:53:01 +03:00
|
|
|
HWND hWnd;
|
2018-05-06 10:52:06 +02:00
|
|
|
LRESULT (CALLBACK *WndProc)(HWND, UINT, WPARAM, LPARAM);
|
2010-11-07 15:54:47 +02:00
|
|
|
struct { float x; float y; } cursor;
|
2010-10-24 01:02:08 +03:00
|
|
|
BOOL locked;
|
2018-03-11 21:23:22 +01:00
|
|
|
BOOL adjmouse;
|
2010-11-15 20:37:02 +02:00
|
|
|
BOOL devmode;
|
2010-11-17 22:12:19 +02:00
|
|
|
BOOL vsync;
|
2011-03-24 19:41:36 +02:00
|
|
|
BOOL vhack;
|
2012-12-11 00:25:21 +01:00
|
|
|
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-12 15:11:22 +01:00
|
|
|
char screenshotKey;
|
2017-11-20 05:11:39 +01:00
|
|
|
BOOL fullscreen;
|
2018-03-14 14:02:04 +01:00
|
|
|
BOOL maintas;
|
2018-03-19 00:32:13 +01:00
|
|
|
BOOL fakecursorpos;
|
2018-03-19 02:27:55 +01:00
|
|
|
BOOL noactivateapp;
|
2018-10-26 05:27:10 +02:00
|
|
|
BOOL hidemouse;
|
2018-05-12 12:28:07 +02:00
|
|
|
char shader[MAX_PATH];
|
2018-08-09 11:19:36 +02:00
|
|
|
BOOL wine;
|
2018-10-07 13:42:32 +02:00
|
|
|
LONG minimized;
|
2018-10-31 11:48:41 +01:00
|
|
|
DWORD ticklength;
|
2017-11-12 14:57:27 +01:00
|
|
|
|
2010-10-23 17:04:01 +03: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 *);
|
2010-10-23 00:15:11 +03:00
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
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);
|
|
|
|
HRESULT(__stdcall *SetDisplayMode)(IDirectDrawImpl *, DWORD, DWORD,DWORD);
|
|
|
|
HRESULT(__stdcall *WaitForVerticalBlank)(IDirectDrawImpl *, DWORD, HANDLE);
|
|
|
|
};
|
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
|