refactoring
This commit is contained in:
parent
95afd87656
commit
baaa87b18f
62 changed files with 7231 additions and 6636 deletions
71
inc/IDirectDraw.h
Normal file
71
inc/IDirectDraw.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
#ifndef IDIRECTDRAW_H
|
||||
#define IDIRECTDRAW_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
|
||||
|
||||
DEFINE_GUID(IID_IDirectDraw4, 0x9c59509a, 0x39bd, 0x11d1, 0x8c, 0x4a, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5);
|
||||
DEFINE_GUID(IID_IDirectDraw7, 0x15e65ec0, 0x3b9c, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b);
|
||||
|
||||
extern struct IDirectDrawImplVtbl g_dd_vtbl1;
|
||||
extern struct IDirectDrawImplVtbl g_dd_vtblx;
|
||||
|
||||
struct IDirectDrawImpl;
|
||||
struct IDirectDrawImplVtbl;
|
||||
|
||||
typedef struct IDirectDrawImpl
|
||||
{
|
||||
struct IDirectDrawImplVtbl* lpVtbl;
|
||||
|
||||
ULONG ref;
|
||||
|
||||
} 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);
|
||||
union
|
||||
{
|
||||
LPVOID d;
|
||||
HRESULT(__stdcall* SetDisplayMode)(IDirectDrawImpl*, DWORD, DWORD, DWORD);
|
||||
HRESULT(__stdcall* SetDisplayModeX)(IDirectDrawImpl*, DWORD, DWORD, DWORD, DWORD, DWORD);
|
||||
};
|
||||
HRESULT(__stdcall* WaitForVerticalBlank)(IDirectDrawImpl*, DWORD, HANDLE);
|
||||
// v2
|
||||
HRESULT(__stdcall* GetAvailableVidMem)(IDirectDrawImpl*, void*, LPDWORD, LPDWORD);
|
||||
// v4
|
||||
HRESULT(__stdcall* GetSurfaceFromDC)(IDirectDrawImpl*, HDC, void*);
|
||||
HRESULT(__stdcall* RestoreAllSurfaces)(IDirectDrawImpl*);
|
||||
HRESULT(__stdcall* TestCooperativeLevel)(IDirectDrawImpl*);
|
||||
HRESULT(__stdcall* GetDeviceIdentifier)(IDirectDrawImpl*, void*, DWORD);
|
||||
// v7
|
||||
HRESULT(__stdcall* StartModeTest)(IDirectDrawImpl*, LPSIZE, DWORD, DWORD);
|
||||
HRESULT(__stdcall* EvaluateMode)(IDirectDrawImpl*, DWORD, DWORD*);
|
||||
};
|
||||
|
||||
#endif
|
40
inc/IDirectDrawClipper.h
Normal file
40
inc/IDirectDrawClipper.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef IDIRECTDRAWCLIPPER_H
|
||||
#define IDIRECTDRAWCLIPPER_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
|
||||
|
||||
struct IDirectDrawClipperImpl;
|
||||
struct IDirectDrawClipperImplVtbl;
|
||||
|
||||
typedef struct IDirectDrawClipperImpl
|
||||
{
|
||||
struct IDirectDrawClipperImplVtbl *lpVtbl;
|
||||
|
||||
ULONG ref;
|
||||
|
||||
} IDirectDrawClipperImpl;
|
||||
|
||||
typedef struct IDirectDrawClipperImplVtbl IDirectDrawClipperImplVtbl;
|
||||
|
||||
struct IDirectDrawClipperImplVtbl
|
||||
{
|
||||
/* IUnknown */
|
||||
HRESULT (__stdcall *QueryInterface)(IDirectDrawClipperImpl *, REFIID, void **);
|
||||
ULONG (__stdcall *AddRef)(IDirectDrawClipperImpl *);
|
||||
ULONG (__stdcall *Release)(IDirectDrawClipperImpl *);
|
||||
|
||||
/* IDirectDrawClipper */
|
||||
HRESULT (__stdcall *GetClipList)(IDirectDrawClipperImpl *, LPRECT, LPRGNDATA, LPDWORD);
|
||||
HRESULT (__stdcall *GetHWnd)(IDirectDrawClipperImpl *, HWND FAR *);
|
||||
HRESULT (__stdcall *Initialize)(IDirectDrawClipperImpl *, LPDIRECTDRAW, DWORD);
|
||||
HRESULT (__stdcall *IsClipListChanged)(IDirectDrawClipperImpl *, BOOL FAR *);
|
||||
HRESULT (__stdcall *SetClipList)(IDirectDrawClipperImpl *, LPRGNDATA,DWORD);
|
||||
HRESULT (__stdcall *SetHWnd)(IDirectDrawClipperImpl *, DWORD, HWND );
|
||||
};
|
||||
|
||||
extern struct IDirectDrawClipperImplVtbl g_ddc_vtbl;
|
||||
|
||||
#endif
|
42
inc/IDirectDrawPalette.h
Normal file
42
inc/IDirectDrawPalette.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
#ifndef IDIRECTDRAWPALETTE_H
|
||||
#define IDIRECTDRAWPALETTE_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
|
||||
|
||||
struct IDirectDrawPaletteImpl;
|
||||
struct IDirectDrawPaletteImplVtbl;
|
||||
|
||||
typedef struct IDirectDrawPaletteImpl
|
||||
{
|
||||
struct IDirectDrawPaletteImplVtbl* lpVtbl;
|
||||
|
||||
ULONG ref;
|
||||
|
||||
int data_bgr[256];
|
||||
RGBQUAD* data_rgb;
|
||||
|
||||
} IDirectDrawPaletteImpl;
|
||||
|
||||
typedef struct IDirectDrawPaletteImplVtbl IDirectDrawPaletteImplVtbl;
|
||||
|
||||
struct IDirectDrawPaletteImplVtbl
|
||||
{
|
||||
/* IUnknown */
|
||||
HRESULT(__stdcall* QueryInterface)(IDirectDrawPaletteImpl*, REFIID, void**);
|
||||
ULONG(__stdcall* AddRef)(IDirectDrawPaletteImpl*);
|
||||
ULONG(__stdcall* Release)(IDirectDrawPaletteImpl*);
|
||||
|
||||
/* IDirectDrawPalette */
|
||||
HRESULT(__stdcall* GetCaps)(IDirectDrawPaletteImpl*, LPDWORD);
|
||||
HRESULT(__stdcall* GetEntries)(IDirectDrawPaletteImpl*, DWORD, DWORD, DWORD, LPPALETTEENTRY);
|
||||
HRESULT(__stdcall* Initialize)(IDirectDrawPaletteImpl*, LPDIRECTDRAW, DWORD, LPPALETTEENTRY);
|
||||
HRESULT(__stdcall* SetEntries)(IDirectDrawPaletteImpl*, DWORD, DWORD, DWORD, LPPALETTEENTRY);
|
||||
|
||||
};
|
||||
|
||||
extern struct IDirectDrawPaletteImplVtbl g_ddp_vtbl;
|
||||
|
||||
#endif
|
|
@ -1,38 +1,20 @@
|
|||
/*
|
||||
* 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 SURFACE_H
|
||||
#define SURFACE_H
|
||||
#ifndef IDIRECTDRAWSURFACE_H
|
||||
#define IDIRECTDRAWSURFACE_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "IDirectDrawPalette.h"
|
||||
#include "ddraw.h"
|
||||
#include "palette.h"
|
||||
|
||||
HRESULT __stdcall ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC DDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *DDSurface, IUnknown FAR * unkOuter);
|
||||
|
||||
struct IDirectDrawSurfaceImpl;
|
||||
struct IDirectDrawSurfaceImplVtbl;
|
||||
|
||||
extern struct IDirectDrawSurfaceImpl *ddraw_primary;
|
||||
|
||||
typedef struct IDirectDrawSurfaceImpl
|
||||
{
|
||||
struct IDirectDrawSurfaceImplVtbl *lpVtbl;
|
||||
|
||||
ULONG Ref;
|
||||
ULONG ref;
|
||||
|
||||
DWORD width;
|
||||
DWORD height;
|
||||
|
@ -43,18 +25,20 @@ typedef struct IDirectDrawSurfaceImpl
|
|||
IDirectDrawPaletteImpl *palette;
|
||||
|
||||
void *surface;
|
||||
DWORD lPitch;
|
||||
DWORD lXPitch;
|
||||
DWORD l_pitch;
|
||||
DWORD lx_pitch;
|
||||
|
||||
PBITMAPINFO bmi;
|
||||
HBITMAP bitmap;
|
||||
HDC hDC;
|
||||
DDCOLORKEY colorKey;
|
||||
DWORD lastFlipTick;
|
||||
DWORD lastBltTick;
|
||||
HDC hdc;
|
||||
DDCOLORKEY color_key;
|
||||
DWORD last_flip_tick;
|
||||
DWORD last_blt_tick;
|
||||
|
||||
} IDirectDrawSurfaceImpl;
|
||||
|
||||
typedef struct IDirectDrawSurfaceImplVtbl IDirectDrawSurfaceImplVtbl;
|
||||
|
||||
struct IDirectDrawSurfaceImplVtbl
|
||||
{
|
||||
/* IUnknown */
|
||||
|
@ -96,7 +80,8 @@ struct IDirectDrawSurfaceImplVtbl
|
|||
HRESULT (__stdcall *UpdateOverlay)(IDirectDrawSurfaceImpl*, LPRECT, LPDIRECTDRAWSURFACE,LPRECT,DWORD, LPDDOVERLAYFX);
|
||||
HRESULT (__stdcall *UpdateOverlayDisplay)(IDirectDrawSurfaceImpl*, DWORD);
|
||||
HRESULT (__stdcall *UpdateOverlayZOrder)(IDirectDrawSurfaceImpl*, DWORD, LPDIRECTDRAWSURFACE);
|
||||
} IDirectDrawSurfaceImplVtbl;
|
||||
};
|
||||
|
||||
extern struct IDirectDrawSurfaceImplVtbl g_dds_vtbl;
|
||||
|
||||
#endif
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* 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 CLIPPER_H
|
||||
#define CLIPPER_H
|
||||
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
#include "main.h"
|
||||
|
||||
HRESULT __stdcall ddraw_CreateClipper(IDirectDrawImpl *This, DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter );
|
||||
|
||||
struct IDirectDrawClipperImpl;
|
||||
struct IDirectDrawClipperImplVtbl;
|
||||
|
||||
typedef struct IDirectDrawClipperImpl
|
||||
{
|
||||
struct IDirectDrawClipperImplVtbl *lpVtbl;
|
||||
|
||||
ULONG Ref;
|
||||
|
||||
} IDirectDrawClipperImpl;
|
||||
|
||||
struct IDirectDrawClipperImplVtbl
|
||||
{
|
||||
/* IUnknown */
|
||||
HRESULT (__stdcall *QueryInterface)(IDirectDrawClipperImpl *, REFIID, void **);
|
||||
ULONG (__stdcall *AddRef)(IDirectDrawClipperImpl *);
|
||||
ULONG (__stdcall *Release)(IDirectDrawClipperImpl *);
|
||||
|
||||
/* IDirectDrawClipper */
|
||||
HRESULT (__stdcall *GetClipList)(IDirectDrawClipperImpl *, LPRECT, LPRGNDATA, LPDWORD);
|
||||
HRESULT (__stdcall *GetHWnd)(IDirectDrawClipperImpl *, HWND FAR *);
|
||||
HRESULT (__stdcall *Initialize)(IDirectDrawClipperImpl *, LPDIRECTDRAW, DWORD);
|
||||
HRESULT (__stdcall *IsClipListChanged)(IDirectDrawClipperImpl *, BOOL FAR *);
|
||||
HRESULT (__stdcall *SetClipList)(IDirectDrawClipperImpl *, LPRGNDATA,DWORD);
|
||||
HRESULT (__stdcall *SetHWnd)(IDirectDrawClipperImpl *, DWORD, HWND );
|
||||
} IDirectDrawClipperImplVtbl;
|
||||
|
||||
#endif
|
23
inc/config.h
Normal file
23
inc/config.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
typedef struct cnc_ddraw_config
|
||||
{
|
||||
RECT window_rect;
|
||||
int window_state;
|
||||
char ini_path[MAX_PATH];
|
||||
char process_file_name[96];
|
||||
int save_settings;
|
||||
|
||||
} cnc_ddraw_config;
|
||||
|
||||
extern cnc_ddraw_config g_config;
|
||||
|
||||
void cfg_load();
|
||||
void cfg_save();
|
||||
|
||||
#endif
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef D3D9SHADER_H
|
||||
#define D3D9SHADER_H
|
||||
|
||||
#if 0
|
||||
//
|
||||
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
|
||||
|
@ -42,7 +45,7 @@ float4 main(float2 texCoords : TEXCOORD) : COLOR
|
|||
*/
|
||||
#endif
|
||||
|
||||
const BYTE PalettePixelShaderSrc[] =
|
||||
const BYTE D3D9_PALETTE_SHADER[] =
|
||||
{
|
||||
0, 2, 255, 255, 254, 255,
|
||||
44, 0, 67, 84, 65, 66,
|
||||
|
@ -99,3 +102,5 @@ const BYTE PalettePixelShaderSrc[] =
|
|||
0, 8, 15, 128, 0, 0,
|
||||
228, 128, 255, 255, 0, 0
|
||||
};
|
||||
|
||||
#endif
|
118
inc/dd.h
Normal file
118
inc/dd.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
#ifndef DD_H
|
||||
#define DD_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
|
||||
|
||||
ULONG dd_AddRef();
|
||||
ULONG dd_Release();
|
||||
HRESULT dd_EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback);
|
||||
HRESULT dd_WaitForVerticalBlank(DWORD dwFlags, HANDLE h);
|
||||
HRESULT dd_SetDisplayMode(DWORD width, DWORD height, DWORD bpp);
|
||||
HRESULT dd_SetCooperativeLevel(HWND hwnd, DWORD dwFlags);
|
||||
HRESULT dd_RestoreDisplayMode();
|
||||
HRESULT dd_GetCaps(LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDEmulCaps);
|
||||
HRESULT dd_GetAvailableVidMem(void* lpDDCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree);
|
||||
HRESULT dd_GetVerticalBlankStatus(LPBOOL lpbIsInVB);
|
||||
|
||||
typedef struct speed_limiter
|
||||
{
|
||||
DWORD tick_length;
|
||||
LONGLONG tick_length_ns;
|
||||
HANDLE htimer;
|
||||
LARGE_INTEGER due_time;
|
||||
BOOL use_blt_or_flip;
|
||||
} speed_limiter;
|
||||
|
||||
struct IDirectDrawSurfaceImpl;
|
||||
|
||||
extern struct cnc_ddraw *g_ddraw;
|
||||
|
||||
typedef struct cnc_ddraw
|
||||
{
|
||||
ULONG ref;
|
||||
|
||||
DWORD width;
|
||||
DWORD height;
|
||||
DWORD bpp;
|
||||
BOOL windowed;
|
||||
BOOL border;
|
||||
BOOL boxing;
|
||||
DEVMODE mode;
|
||||
struct IDirectDrawSurfaceImpl *primary;
|
||||
char title[128];
|
||||
HMODULE real_dll;
|
||||
|
||||
/* real export from system32\ddraw.dll */
|
||||
HRESULT (WINAPI *DirectDrawCreate)(GUID FAR*, LPDIRECTDRAW FAR*, IUnknown FAR*);
|
||||
CRITICAL_SECTION cs;
|
||||
|
||||
struct
|
||||
{
|
||||
int maxfps;
|
||||
BOOL forcefps;
|
||||
int width;
|
||||
int height;
|
||||
int bpp;
|
||||
|
||||
HDC hdc;
|
||||
int *tex;
|
||||
|
||||
HANDLE thread;
|
||||
BOOL run;
|
||||
HANDLE sem;
|
||||
DEVMODE mode;
|
||||
struct { int width; int height; int x; int y; } viewport;
|
||||
|
||||
LONG palette_updated;
|
||||
LONG surface_updated;
|
||||
|
||||
float scale_w;
|
||||
float scale_h;
|
||||
float unscale_w;
|
||||
float unscale_h;
|
||||
} render;
|
||||
|
||||
HWND hwnd;
|
||||
LRESULT (CALLBACK *wndproc)(HWND, UINT, WPARAM, LPARAM);
|
||||
struct { float x; float y; } cursor;
|
||||
BOOL locked;
|
||||
BOOL adjmouse;
|
||||
BOOL devmode;
|
||||
BOOL vsync;
|
||||
BOOL vhack;
|
||||
BOOL isredalert;
|
||||
BOOL iscnc1;
|
||||
LONG incutscene;
|
||||
DWORD (WINAPI *renderer)(void);
|
||||
BOOL fullscreen;
|
||||
BOOL maintas;
|
||||
BOOL noactivateapp;
|
||||
BOOL handlemouse;
|
||||
char shader[MAX_PATH];
|
||||
BOOL wine;
|
||||
BOOL altenter;
|
||||
BOOL hidecursor;
|
||||
BOOL accurate_timers;
|
||||
BOOL resizable;
|
||||
BOOL sierrahack;
|
||||
BOOL nonexclusive;
|
||||
BOOL bnet_active;
|
||||
BOOL bnet_was_fullscreen;
|
||||
BOOL bnet_was_upscaled;
|
||||
RECT bnet_win_rect;
|
||||
POINT bnet_pos;
|
||||
int mouse_y_adjust;
|
||||
void* last_freed_palette; // Dungeon Keeper hack
|
||||
BOOL child_window_exists;
|
||||
DWORD last_set_window_pos_tick; // WINE hack
|
||||
BOOL show_driver_warning;
|
||||
speed_limiter ticks_limiter;
|
||||
speed_limiter flip_limiter;
|
||||
speed_limiter fps_limiter;
|
||||
|
||||
} cnc_ddraw;
|
||||
|
||||
#endif
|
11
inc/ddclipper.h
Normal file
11
inc/ddclipper.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef DDCLIPPER_H
|
||||
#define DDCLIPPER_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
|
||||
|
||||
HRESULT dd_CreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR* lplpDDClipper, IUnknown FAR* pUnkOuter);
|
||||
|
||||
#endif
|
14
inc/ddpalette.h
Normal file
14
inc/ddpalette.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef DDPALETTE_H
|
||||
#define DDPALETTE_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
#include "IDirectDrawPalette.h"
|
||||
#include "dd.h"
|
||||
|
||||
HRESULT ddp_GetEntries(IDirectDrawPaletteImpl* This, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries);
|
||||
HRESULT ddp_SetEntries(IDirectDrawPaletteImpl* This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries);
|
||||
HRESULT dd_CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR* lpDDPalette, IUnknown FAR* unkOuter);
|
||||
|
||||
#endif
|
|
@ -422,7 +422,7 @@ typedef DDBLTBATCH FAR * LPDDBLTBATCH;
|
|||
/*
|
||||
* callbacks
|
||||
*/
|
||||
typedef DWORD (FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper, HWND hWnd, DWORD code, LPVOID lpContext );
|
||||
typedef DWORD (FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper, HWND hwnd, DWORD code, LPVOID lpContext );
|
||||
#ifdef STREAMING
|
||||
typedef DWORD (FAR PASCAL *LPSURFACESTREAMINGCALLBACK)(DWORD);
|
||||
#endif
|
||||
|
|
32
inc/ddsurface.h
Normal file
32
inc/ddsurface.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#ifndef DDSURFACE_H
|
||||
#define DDSURFACE_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
#include "IDirectDrawSurface.h"
|
||||
|
||||
// enables redraw via blt/unlock if there wasn't any flip for X ms
|
||||
#define FLIP_REDRAW_TIMEOUT 1000 / 10
|
||||
|
||||
HRESULT dds_AddAttachedSurface(IDirectDrawSurfaceImpl* This, LPDIRECTDRAWSURFACE lpDDSurface);
|
||||
HRESULT dds_Blt(IDirectDrawSurfaceImpl* This, LPRECT lpDestRect, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
|
||||
HRESULT dds_BltFast(IDirectDrawSurfaceImpl* This, DWORD dst_x, DWORD dst_y, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DWORD flags);
|
||||
HRESULT dds_DeleteAttachedSurface(IDirectDrawSurfaceImpl* This, DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSurface);
|
||||
HRESULT dds_GetSurfaceDesc(IDirectDrawSurfaceImpl* This, LPDDSURFACEDESC lpDDSurfaceDesc);
|
||||
HRESULT dds_EnumAttachedSurfaces(IDirectDrawSurfaceImpl* This, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback);
|
||||
HRESULT dds_Flip(IDirectDrawSurfaceImpl* This, LPDIRECTDRAWSURFACE surface, DWORD flags);
|
||||
HRESULT dds_GetAttachedSurface(IDirectDrawSurfaceImpl* This, LPDDSCAPS lpDdsCaps, LPDIRECTDRAWSURFACE FAR* surface);
|
||||
HRESULT dds_GetCaps(IDirectDrawSurfaceImpl* This, LPDDSCAPS lpDDSCaps);
|
||||
HRESULT dds_GetColorKey(IDirectDrawSurfaceImpl* This, DWORD flags, LPDDCOLORKEY colorKey);
|
||||
HRESULT dds_GetDC(IDirectDrawSurfaceImpl* This, HDC FAR* a);
|
||||
HRESULT dds_GetPalette(IDirectDrawSurfaceImpl* This, LPDIRECTDRAWPALETTE FAR* lplpDDPalette);
|
||||
HRESULT dds_GetPixelFormat(IDirectDrawSurfaceImpl* This, LPDDPIXELFORMAT ddpfPixelFormat);
|
||||
HRESULT dds_Lock(IDirectDrawSurfaceImpl* This, LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent);
|
||||
HRESULT dds_SetColorKey(IDirectDrawSurfaceImpl* This, DWORD flags, LPDDCOLORKEY colorKey);
|
||||
HRESULT dds_SetPalette(IDirectDrawSurfaceImpl* This, LPDIRECTDRAWPALETTE lpDDPalette);
|
||||
HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPVOID lpRect);
|
||||
HRESULT dd_CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR* lpDDSurface, IUnknown FAR* unkOuter);
|
||||
|
||||
|
||||
#endif
|
57
inc/debug.h
57
inc/debug.h
|
@ -1,17 +1,25 @@
|
|||
#pragma once
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void CounterStart();
|
||||
double CounterStop();
|
||||
void DebugPrint(const char *format, ...);
|
||||
void DrawFrameInfoStart();
|
||||
void DrawFrameInfoEnd();
|
||||
int dprintf(const char *fmt, ...);
|
||||
|
||||
extern double DebugFrameTime;
|
||||
extern DWORD DebugFrameCount;
|
||||
void dbg_counter_start();
|
||||
double dbg_counter_stop();
|
||||
void dbg_debug_string(const char *format, ...);
|
||||
void dbg_draw_frame_info_start();
|
||||
void dbg_draw_frame_info_end();
|
||||
int dbg_printf(const char *fmt, ...);
|
||||
void dbg_init();
|
||||
void dbg_dump_dds_blt_flags(DWORD flags);
|
||||
void dbg_dump_dds_caps(DWORD caps);
|
||||
void dbg_dump_dds_flags(DWORD flags);
|
||||
void dbg_dump_dds_blt_fast_flags(DWORD flags);
|
||||
void dbg_dump_dds_lock_flags(DWORD flags);
|
||||
|
||||
extern double g_dbg_frame_time;
|
||||
extern DWORD g_dbg_frame_count;
|
||||
|
||||
//#define _DEBUG 1
|
||||
|
||||
|
@ -21,14 +29,35 @@ extern DWORD DebugFrameCount;
|
|||
//log everything (slow)
|
||||
//#define _DEBUG_X 1
|
||||
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#ifdef _DEBUG_S
|
||||
#define printf(format, ...) DebugPrint("xDBG " format, ##__VA_ARGS__)
|
||||
|
||||
#define dprintf(format, ...) dbg_debug_string("xDBG " format, ##__VA_ARGS__)
|
||||
|
||||
#ifdef _DEBUG_X
|
||||
#define dprintfex(format, ...) dbg_debug_string("xDBG " format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define printf(format, ...) dprintf(format, ##__VA_ARGS__)
|
||||
#define dprintfex(format, ...)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define dprintf(format, ...) dbg_printf(format, ##__VA_ARGS__)
|
||||
|
||||
#ifdef _DEBUG_X
|
||||
#define dprintfex(format, ...) dbg_printf(format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define dprintfex(format, ...)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define printf(format, ...)
|
||||
#endif
|
||||
#define dprintf(format, ...)
|
||||
#define dprintfex(format, ...)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
7
inc/directinput.h
Normal file
7
inc/directinput.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef DINPUTINPUT_H
|
||||
#define DINPUTINPUT_H
|
||||
|
||||
void dinput_hook();
|
||||
void dinput_unhook();
|
||||
|
||||
#endif
|
16
inc/dllmain.h
Normal file
16
inc/dllmain.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef DLLMAIN_H
|
||||
#define DLLMAIN_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
extern BOOL GameHandlesClose;
|
||||
extern HMODULE g_ddraw_module;
|
||||
|
||||
typedef enum PROCESS_DPI_AWARENESS {
|
||||
PROCESS_DPI_UNAWARE = 0,
|
||||
PROCESS_SYSTEM_DPI_AWARE = 1,
|
||||
PROCESS_PER_MONITOR_DPI_AWARE = 2
|
||||
} PROCESS_DPI_AWARENESS;
|
||||
|
||||
#endif
|
16
inc/hook.h
16
inc/hook.h
|
@ -1,8 +1,10 @@
|
|||
#ifndef HOOK_H
|
||||
#define HOOK_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
typedef BOOL (WINAPI* GETCURSORPOSPROC)(LPPOINT);
|
||||
typedef BOOL(WINAPI* CLIPCURSORPROC)(const RECT*);
|
||||
typedef int (WINAPI* SHOWCURSORPROC)(BOOL);
|
||||
|
@ -55,13 +57,13 @@ extern LOADLIBRARYWPROC real_LoadLibraryW;
|
|||
extern LOADLIBRARYEXAPROC real_LoadLibraryExA;
|
||||
extern LOADLIBRARYEXWPROC real_LoadLibraryExW;
|
||||
|
||||
extern int HookingMethod;
|
||||
extern BOOL Hook_Active;
|
||||
extern int g_hook_method;
|
||||
extern BOOL g_hook_active;
|
||||
|
||||
void Hook_Init();
|
||||
void Hook_Exit();
|
||||
void Hook_PatchIAT(HMODULE hMod, char *moduleName, char *functionName, PROC newFunction);
|
||||
void Hook_Create(char *moduleName, char *functionName, PROC newFunction, PROC *function);
|
||||
void Hook_Revert(char *moduleName, char *functionName, PROC newFunction, PROC *function);
|
||||
void hook_init();
|
||||
void hook_exit();
|
||||
void hook_patch_iat(HMODULE hMod, char *moduleName, char *functionName, PROC newFunction);
|
||||
void hook_create(char *moduleName, char *functionName, PROC newFunction, PROC *function);
|
||||
void hook_revert(char *moduleName, char *functionName, PROC newFunction, PROC *function);
|
||||
|
||||
#endif
|
||||
|
|
190
inc/main.h
190
inc/main.h
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
* 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"
|
||||
#include "debug.h"
|
||||
|
||||
#define CUTSCENE_WIDTH 640
|
||||
#define CUTSCENE_HEIGHT 400
|
||||
|
||||
#define WM_AUTORENDERER WM_USER+111
|
||||
#define WM_WINEFULLSCREEN WM_USER+112
|
||||
#define WM_D3D9DEVICELOST WM_USER+113
|
||||
|
||||
#define IDT_TIMER_LEAVE_BNET 541287654
|
||||
|
||||
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);
|
||||
|
||||
extern BOOL ShowDriverWarning;
|
||||
extern RECT WindowRect;
|
||||
extern int WindowState;
|
||||
extern BOOL ChildWindowExists;
|
||||
extern HMODULE DDrawModule;
|
||||
|
||||
BOOL detect_cutscene();
|
||||
void LimitGameTicks();
|
||||
void ToggleFullscreen();
|
||||
void SetWindowRect(int x, int y, int width, int height, UINT flags);
|
||||
DWORD WINAPI render_main(void);
|
||||
DWORD WINAPI render_soft_main(void);
|
||||
BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam);
|
||||
|
||||
struct IDirectDrawImpl;
|
||||
struct IDirectDrawImplVtbl;
|
||||
struct IDirectDrawSurfaceImpl;
|
||||
|
||||
extern struct IDirectDrawImpl *ddraw;
|
||||
|
||||
typedef struct SpeedLimiter
|
||||
{
|
||||
DWORD ticklength;
|
||||
LONGLONG tickLengthNs;
|
||||
HANDLE hTimer;
|
||||
LARGE_INTEGER dueTime;
|
||||
BOOL useBltOrFlip;
|
||||
} SpeedLimiter;
|
||||
|
||||
typedef struct IDirectDrawImpl
|
||||
{
|
||||
struct IDirectDrawImplVtbl *lpVtbl;
|
||||
|
||||
ULONG Ref;
|
||||
|
||||
DWORD width;
|
||||
DWORD height;
|
||||
DWORD bpp;
|
||||
BOOL windowed;
|
||||
BOOL border;
|
||||
BOOL boxing;
|
||||
DEVMODE mode;
|
||||
struct IDirectDrawSurfaceImpl *primary;
|
||||
char title[128];
|
||||
HMODULE real_dll;
|
||||
|
||||
/* real export from system32\ddraw.dll */
|
||||
HRESULT (WINAPI *DirectDrawCreate)(GUID FAR*, LPDIRECTDRAW FAR*, IUnknown FAR*);
|
||||
CRITICAL_SECTION cs;
|
||||
|
||||
struct
|
||||
{
|
||||
int maxfps;
|
||||
BOOL forcefps;
|
||||
int width;
|
||||
int height;
|
||||
int bpp;
|
||||
|
||||
HDC hDC;
|
||||
int *tex;
|
||||
|
||||
HANDLE thread;
|
||||
BOOL run;
|
||||
HANDLE sem;
|
||||
DEVMODE mode;
|
||||
struct { int width; int height; int x; int y; } viewport;
|
||||
|
||||
LONG paletteUpdated;
|
||||
LONG surfaceUpdated;
|
||||
|
||||
float scaleW;
|
||||
float scaleH;
|
||||
float unScaleW;
|
||||
float unScaleH;
|
||||
} render;
|
||||
|
||||
HWND hWnd;
|
||||
LRESULT (CALLBACK *WndProc)(HWND, UINT, WPARAM, LPARAM);
|
||||
struct { float x; float y; } cursor;
|
||||
BOOL locked;
|
||||
BOOL adjmouse;
|
||||
BOOL devmode;
|
||||
BOOL vsync;
|
||||
BOOL vhack;
|
||||
BOOL isredalert;
|
||||
BOOL iscnc1;
|
||||
LONG incutscene;
|
||||
DWORD (WINAPI *renderer)(void);
|
||||
BOOL fullscreen;
|
||||
BOOL maintas;
|
||||
BOOL noactivateapp;
|
||||
BOOL handlemouse;
|
||||
char shader[MAX_PATH];
|
||||
BOOL wine;
|
||||
BOOL altenter;
|
||||
BOOL hidecursor;
|
||||
BOOL accurateTimers;
|
||||
BOOL resizable;
|
||||
BOOL tm2hack;
|
||||
BOOL sierrahack;
|
||||
BOOL nonexclusive;
|
||||
BOOL bnetActive;
|
||||
BOOL bnetWasFullscreen;
|
||||
BOOL bnetWasUpscaled;
|
||||
RECT bnetWinRect;
|
||||
POINT bnetPos;
|
||||
SpeedLimiter ticksLimiter;
|
||||
SpeedLimiter flipLimiter;
|
||||
SpeedLimiter fpsLimiter;
|
||||
|
||||
} 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);
|
||||
union
|
||||
{
|
||||
HRESULT(__stdcall *SetDisplayMode1)(IDirectDrawImpl *, DWORD, DWORD, DWORD);
|
||||
HRESULT(__stdcall *SetDisplayMode2)(IDirectDrawImpl *, DWORD, DWORD, DWORD, DWORD, DWORD);
|
||||
};
|
||||
|
||||
HRESULT(__stdcall *WaitForVerticalBlank)(IDirectDrawImpl *, DWORD, HANDLE);
|
||||
HRESULT(__stdcall *GetAvailableVidMem)(IDirectDrawImpl *, LPDDSCAPS, LPDWORD, LPDWORD);
|
||||
};
|
||||
|
||||
typedef enum PROCESS_DPI_AWARENESS {
|
||||
PROCESS_DPI_UNAWARE = 0,
|
||||
PROCESS_SYSTEM_DPI_AWARE = 1,
|
||||
PROCESS_PER_MONITOR_DPI_AWARE = 2
|
||||
} PROCESS_DPI_AWARENESS;
|
||||
|
||||
#endif
|
29
inc/mouse.h
29
inc/mouse.h
|
@ -1,37 +1,8 @@
|
|||
#ifndef MOUSE_H
|
||||
#define MOUSE_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
void mouse_lock();
|
||||
void mouse_unlock();
|
||||
|
||||
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint);
|
||||
BOOL WINAPI fake_ClipCursor(const RECT *lpRect);
|
||||
int WINAPI fake_ShowCursor(BOOL bShow);
|
||||
HCURSOR WINAPI fake_SetCursor(HCURSOR hCursor);
|
||||
BOOL WINAPI fake_GetWindowRect(HWND hWnd, LPRECT lpRect);
|
||||
BOOL WINAPI fake_GetClientRect(HWND hWnd, LPRECT lpRect);
|
||||
BOOL WINAPI fake_ClientToScreen(HWND hWnd, LPPOINT lpPoint);
|
||||
BOOL WINAPI fake_ScreenToClient(HWND hWnd, LPPOINT lpPoint);
|
||||
BOOL WINAPI fake_SetCursorPos(int X, int Y);
|
||||
HWND WINAPI fake_WindowFromPoint(POINT Point);
|
||||
BOOL WINAPI fake_GetClipCursor(LPRECT lpRect);
|
||||
BOOL WINAPI fake_GetCursorInfo(PCURSORINFO pci);
|
||||
int WINAPI fake_GetSystemMetrics(int nIndex);
|
||||
BOOL WINAPI fake_SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
|
||||
BOOL WINAPI fake_MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, BOOL bRepaint);
|
||||
LRESULT WINAPI fake_SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
LONG WINAPI fake_SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong);
|
||||
BOOL WINAPI fake_EnableWindow(HWND hWnd, BOOL bEnable);
|
||||
BOOL WINAPI fake_DestroyWindow(HWND hWnd);
|
||||
int WINAPI fake_GetDeviceCaps(HDC hdc, int index);
|
||||
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName);
|
||||
HMODULE WINAPI fake_LoadLibraryW(LPCWSTR lpLibFileName);
|
||||
HMODULE WINAPI fake_LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
|
||||
HMODULE WINAPI fake_LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
|
||||
HWND WINAPI fake_CreateWindowExA(
|
||||
DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y,
|
||||
int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#ifndef OPENGL_UTILS_H
|
||||
#define OPENGL_UTILS_H
|
||||
#include "glcorearb.h"
|
||||
|
||||
// wgl
|
||||
|
@ -32,11 +33,11 @@ extern PFNGLVERTEX2FPROC glVertex2f;
|
|||
// <--- compat profile only
|
||||
|
||||
|
||||
BOOL OpenGL_LoadDll();
|
||||
void OpenGL_Init();
|
||||
BOOL OpenGL_ExtExists(char *ext, HDC hdc);
|
||||
GLuint OpenGL_BuildProgram(const GLchar *vertSource, const GLchar *fragSource);
|
||||
GLuint OpenGL_BuildProgramFromFile(const char *filePath);
|
||||
BOOL oglu_load_dll();
|
||||
void oglu_init();
|
||||
BOOL oglu_ext_exists(char *ext, HDC hdc);
|
||||
GLuint oglu_build_program(const GLchar *vertSource, const GLchar *fragSource);
|
||||
GLuint oglu_build_program_from_file(const char *filePath);
|
||||
|
||||
extern PFNGLVIEWPORTPROC glViewport;
|
||||
extern PFNGLBINDTEXTUREPROC glBindTexture;
|
||||
|
@ -52,7 +53,6 @@ extern PFNGLGETTEXIMAGEPROC glGetTexImage;
|
|||
extern PFNGLPIXELSTOREIPROC glPixelStorei;
|
||||
extern PFNGLENABLEPROC glEnable;
|
||||
extern PFNGLCLEARPROC glClear;
|
||||
|
||||
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||
extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
||||
extern PFNGLUSEPROGRAMPROC glUseProgram;
|
||||
|
@ -84,13 +84,11 @@ extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
|||
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
||||
extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
|
||||
extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform;
|
||||
|
||||
extern PFNGLCREATESHADERPROC glCreateShader;
|
||||
extern PFNGLDELETESHADERPROC glDeleteShader;
|
||||
extern PFNGLSHADERSOURCEPROC glShaderSource;
|
||||
extern PFNGLCOMPILESHADERPROC glCompileShader;
|
||||
extern PFNGLGETSHADERIVPROC glGetShaderiv;
|
||||
|
||||
extern PFNGLGENBUFFERSPROC glGenBuffers;
|
||||
extern PFNGLBINDBUFFERPROC glBindBuffer;
|
||||
extern PFNGLBUFFERDATAPROC glBufferData;
|
||||
|
@ -102,21 +100,18 @@ extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
|||
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
||||
|
||||
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
|
||||
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
|
||||
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||
extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||
|
||||
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
||||
|
||||
extern HMODULE OpenGL_hModule;
|
||||
extern HMODULE g_oglu_hmodule;
|
||||
extern BOOL g_oglu_got_version2;
|
||||
extern BOOL g_oglu_got_version3;
|
||||
extern char g_oglu_version[];
|
||||
|
||||
extern BOOL OpenGL_GotVersion2;
|
||||
extern BOOL OpenGL_GotVersion3;
|
||||
|
||||
extern char OpenGL_Version[];
|
||||
#endif
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef OPENGLSHADER_H
|
||||
#define OPENGLSHADER_H
|
||||
|
||||
// old
|
||||
|
||||
const char PassthroughVertShader110Src[] =
|
||||
const char PASSTHROUGH_VERT_SHADER_110[] =
|
||||
"#version 110\n"
|
||||
"varying vec2 TEX0; \n"
|
||||
"\n"
|
||||
|
@ -10,7 +13,7 @@ const char PassthroughVertShader110Src[] =
|
|||
" TEX0 = gl_MultiTexCoord0.xy; \n"
|
||||
"}\n";
|
||||
|
||||
const char PaletteFragShader110Src[] =
|
||||
const char PALETTE_FRAG_SHADER_110[] =
|
||||
"#version 110\n"
|
||||
"uniform sampler2D SurfaceTex; \n"
|
||||
"uniform sampler2D PaletteTex; \n"
|
||||
|
@ -23,7 +26,7 @@ const char PaletteFragShader110Src[] =
|
|||
"}\n";
|
||||
|
||||
|
||||
const char PassthroughFragShader110Src[] =
|
||||
const char PASSTHROUGH_FRAG_SHADER_110[] =
|
||||
"#version 110\n"
|
||||
"uniform sampler2D SurfaceTex; \n"
|
||||
"varying vec2 TEX0; \n"
|
||||
|
@ -36,7 +39,7 @@ const char PassthroughFragShader110Src[] =
|
|||
|
||||
// new
|
||||
|
||||
const char PassthroughVertShaderSrc[] =
|
||||
const char PASSTHROUGH_VERT_SHADER[] =
|
||||
"#version 130\n"
|
||||
"in vec4 VertexCoord;\n"
|
||||
"in vec4 COLOR;\n"
|
||||
|
@ -53,7 +56,7 @@ const char PassthroughVertShaderSrc[] =
|
|||
"}\n";
|
||||
|
||||
|
||||
const char PaletteFragShaderSrc[] =
|
||||
const char PALETTE_FRAG_SHADER[] =
|
||||
"#version 130\n"
|
||||
"out vec4 FragColor;\n"
|
||||
"uniform sampler2D SurfaceTex;\n"
|
||||
|
@ -67,7 +70,7 @@ const char PaletteFragShaderSrc[] =
|
|||
"}\n";
|
||||
|
||||
|
||||
const char PassthroughFragShaderSrc[] =
|
||||
const char PASSTHROUGH_FRAG_SHADER[] =
|
||||
"#version 130\n"
|
||||
"out vec4 FragColor;\n"
|
||||
"uniform sampler2D SurfaceTex;\n"
|
||||
|
@ -78,3 +81,5 @@ const char PassthroughFragShaderSrc[] =
|
|||
" vec4 texel = texture(SurfaceTex, TEX0.xy);\n"
|
||||
" FragColor = texel;\n"
|
||||
"}\n";
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* 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 PALETTE_H
|
||||
#define PALETTE_H
|
||||
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
#include "main.h"
|
||||
|
||||
struct IDirectDrawPaletteImpl;
|
||||
struct IDirectDrawPaletteImplVtbl;
|
||||
|
||||
typedef struct IDirectDrawPaletteImpl
|
||||
{
|
||||
struct IDirectDrawPaletteImplVtbl *lpVtbl;
|
||||
|
||||
ULONG Ref;
|
||||
|
||||
int data_bgr[256];
|
||||
RGBQUAD *data_rgb;
|
||||
|
||||
} IDirectDrawPaletteImpl;
|
||||
|
||||
struct IDirectDrawPaletteImplVtbl
|
||||
{
|
||||
/* IUnknown */
|
||||
HRESULT (__stdcall *QueryInterface)(IDirectDrawPaletteImpl*, REFIID, void**);
|
||||
ULONG (__stdcall *AddRef)(IDirectDrawPaletteImpl*);
|
||||
ULONG (__stdcall *Release)(IDirectDrawPaletteImpl*);
|
||||
|
||||
/* IDirectDrawPalette */
|
||||
HRESULT (__stdcall *GetCaps)(IDirectDrawPaletteImpl*, LPDWORD);
|
||||
HRESULT (__stdcall *GetEntries)(IDirectDrawPaletteImpl*, DWORD, DWORD, DWORD, LPPALETTEENTRY);
|
||||
HRESULT (__stdcall *Initialize)(IDirectDrawPaletteImpl*, LPDIRECTDRAW, DWORD, LPPALETTEENTRY);
|
||||
HRESULT (__stdcall *SetEntries)(IDirectDrawPaletteImpl*, DWORD, DWORD, DWORD, LPPALETTEENTRY);
|
||||
|
||||
} IDirectDrawPaletteImplVtbl;
|
||||
|
||||
HRESULT __stdcall ddraw_CreatePalette(IDirectDrawImpl *This, DWORD dwFlags, LPPALETTEENTRY DDColorArray, LPDIRECTDRAWPALETTE FAR * DDPalette, IUnknown FAR * unkOuter);
|
||||
extern IDirectDrawPaletteImpl *LastFreedPalette;
|
||||
|
||||
#endif
|
|
@ -1,11 +1,35 @@
|
|||
#pragma once
|
||||
#ifndef RENDER_D3D9_H
|
||||
#define RENDER_D3D9_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <d3d9.h>
|
||||
|
||||
#define D3D9_TEXTURE_COUNT 2
|
||||
|
||||
typedef struct CUSTOMVERTEX { float x, y, z, rhw, u, v; } CUSTOMVERTEX;
|
||||
|
||||
DWORD WINAPI render_d3d9_main(void);
|
||||
BOOL Direct3D9_Create();
|
||||
BOOL Direct3D9_Reset();
|
||||
BOOL Direct3D9_Release();
|
||||
BOOL Direct3D9_OnDeviceLost();
|
||||
typedef struct d3d9_renderer
|
||||
{
|
||||
HMODULE hmodule;
|
||||
D3DPRESENT_PARAMETERS params;
|
||||
LPDIRECT3D9 instance;
|
||||
LPDIRECT3DDEVICE9 device;
|
||||
LPDIRECT3DVERTEXBUFFER9 vertex_buf;
|
||||
IDirect3DTexture9* surface_tex[D3D9_TEXTURE_COUNT];
|
||||
IDirect3DTexture9* palette_tex[D3D9_TEXTURE_COUNT];
|
||||
IDirect3DPixelShader9* pixel_shader;
|
||||
float scale_w;
|
||||
float scale_h;
|
||||
int bits_per_pixel;
|
||||
} d3d9_renderer;
|
||||
|
||||
extern HMODULE Direct3D9_hModule;
|
||||
BOOL d3d9_is_available();
|
||||
DWORD WINAPI d3d9_render_main(void);
|
||||
BOOL d3d9_create();
|
||||
BOOL d3d9_reset();
|
||||
BOOL d3d9_release();
|
||||
BOOL d3d9_on_device_lost();
|
||||
|
||||
|
||||
#endif
|
||||
|
|
10
inc/render_gdi.h
Normal file
10
inc/render_gdi.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef RENDER_GDI_H
|
||||
#define RENDER_GDI_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
DWORD WINAPI gdi_render_main(void);
|
||||
|
||||
#endif
|
40
inc/render_ogl.h
Normal file
40
inc/render_ogl.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef RENDER_OGL_H
|
||||
#define RENDER_OGL_H
|
||||
|
||||
#include <windows.h>
|
||||
#include "opengl_utils.h"
|
||||
|
||||
#define TEXTURE_COUNT 4
|
||||
|
||||
typedef struct ogl_renderer
|
||||
{
|
||||
HGLRC context;
|
||||
GLuint main_program;
|
||||
GLuint scale_program;
|
||||
BOOL got_error;
|
||||
int surface_tex_width;
|
||||
int surface_tex_height;
|
||||
int* surface_tex;
|
||||
GLenum surface_format;
|
||||
GLenum surface_type;
|
||||
GLuint surface_tex_ids[TEXTURE_COUNT];
|
||||
GLuint palette_tex_ids[TEXTURE_COUNT];
|
||||
float scale_w;
|
||||
float scale_h;
|
||||
GLint main_tex_coord_attr_loc;
|
||||
GLint main_vertex_coord_attr_loc;
|
||||
GLuint main_vbos[3];
|
||||
GLuint main_vao;
|
||||
GLint frame_count_uni_loc;
|
||||
GLuint frame_buffer_id;
|
||||
GLuint frame_buffer_tex_id;
|
||||
GLuint scale_vbos[3];
|
||||
GLuint scale_vao;
|
||||
BOOL use_opengl;
|
||||
BOOL adjust_alignment;
|
||||
BOOL filter_bilinear;
|
||||
} ogl_renderer;
|
||||
|
||||
DWORD WINAPI ogl_render_main(void);
|
||||
|
||||
#endif
|
10
inc/screenshot.h
Normal file
10
inc/screenshot.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef SCREENSHOT_H
|
||||
#define SCREENSHOT_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "ddsurface.h"
|
||||
|
||||
BOOL ss_take_screenshot(struct IDirectDrawSurfaceImpl* src);
|
||||
|
||||
#endif
|
20
inc/utils.h
Normal file
20
inc/utils.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#define CUTSCENE_WIDTH 640
|
||||
#define CUTSCENE_HEIGHT 400
|
||||
|
||||
|
||||
void util_limit_game_ticks();
|
||||
void util_update_bnet_pos(int newX, int newY);
|
||||
BOOL util_get_lowest_resolution(float ratio, SIZE* outRes, DWORD minWidth, DWORD minHeight, DWORD maxWidth, DWORD maxHeight);
|
||||
void util_toggle_fullscreen();
|
||||
BOOL util_unadjust_window_rect(LPRECT prc, DWORD dwStyle, BOOL fMenu, DWORD dwExStyle);
|
||||
void util_set_window_rect(int x, int y, int width, int height, UINT flags);
|
||||
BOOL CALLBACK util_enum_child_proc(HWND hwnd, LPARAM lParam);
|
||||
BOOL util_detect_cutscene();
|
||||
|
||||
#endif
|
36
inc/winapi_hooks.h
Normal file
36
inc/winapi_hooks.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef WINAPI_HOOKS_H
|
||||
#define WINAPI_HOOKS_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint);
|
||||
BOOL WINAPI fake_ClipCursor(const RECT *lpRect);
|
||||
int WINAPI fake_ShowCursor(BOOL bShow);
|
||||
HCURSOR WINAPI fake_SetCursor(HCURSOR hCursor);
|
||||
BOOL WINAPI fake_GetWindowRect(HWND hWnd, LPRECT lpRect);
|
||||
BOOL WINAPI fake_GetClientRect(HWND hWnd, LPRECT lpRect);
|
||||
BOOL WINAPI fake_ClientToScreen(HWND hWnd, LPPOINT lpPoint);
|
||||
BOOL WINAPI fake_ScreenToClient(HWND hWnd, LPPOINT lpPoint);
|
||||
BOOL WINAPI fake_SetCursorPos(int X, int Y);
|
||||
HWND WINAPI fake_WindowFromPoint(POINT Point);
|
||||
BOOL WINAPI fake_GetClipCursor(LPRECT lpRect);
|
||||
BOOL WINAPI fake_GetCursorInfo(PCURSORINFO pci);
|
||||
int WINAPI fake_GetSystemMetrics(int nIndex);
|
||||
BOOL WINAPI fake_SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
|
||||
BOOL WINAPI fake_MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, BOOL bRepaint);
|
||||
LRESULT WINAPI fake_SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
LONG WINAPI fake_SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong);
|
||||
BOOL WINAPI fake_EnableWindow(HWND hWnd, BOOL bEnable);
|
||||
BOOL WINAPI fake_DestroyWindow(HWND hWnd);
|
||||
int WINAPI fake_GetDeviceCaps(HDC hdc, int index);
|
||||
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName);
|
||||
HMODULE WINAPI fake_LoadLibraryW(LPCWSTR lpLibFileName);
|
||||
HMODULE WINAPI fake_LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
|
||||
HMODULE WINAPI fake_LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
|
||||
HWND WINAPI fake_CreateWindowExA(
|
||||
DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y,
|
||||
int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
|
||||
|
||||
#endif
|
12
inc/wndproc.h
Normal file
12
inc/wndproc.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef WNDPROC_H
|
||||
#define WNDPROC_H
|
||||
|
||||
#define WM_AUTORENDERER WM_USER+111
|
||||
#define WM_WINEFULLSCREEN WM_USER+112
|
||||
#define WM_D3D9DEVICELOST WM_USER+113
|
||||
|
||||
#define IDT_TIMER_LEAVE_BNET 541287654
|
||||
|
||||
LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue