MxDirectDraw functions and structures (#33)

* MxDirectDraw functions and structures

* fix indents, and globals

* fix build, add mxdirectdraw build configuration

* add new files to cmake

* MxDirectDraw: Add code from my PR #19 on main repo

Merging in the missing functions from my pull request for MxDirectDraw on the main repo. Credit to @foxtacles for the GetPrimaryBitDepth function. All match 100% on reccmp except ErrorToString, but the problem there is with the jump table at the end.

Co-authored-by: Christian Semmler <mail@csemmler.com>

* improve match

* improve accuracy

* improve accuracy

* move _countof, impove up to 96.90%

* Update LEGO1/mxdirectdraw.h

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>

* Update LEGO1/mxdirectdraw.cpp

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>

* Update LEGO1/mxdirectdraw.cpp

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>

* Update LEGO1/mxdirectdraw.cpp

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>

* Update LEGO1/mxdirectdraw.cpp

* Update LEGO1/mxdirectdraw.cpp

---------

Co-authored-by: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Co-authored-by: disinvite <disinvite@users.noreply.github.com>
Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Roman Masanin 2023-08-03 19:09:22 +02:00 committed by GitHub
parent ac89815663
commit db2b98c248
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 1334 additions and 10 deletions

1
.gitignore vendored
View file

@ -1,6 +1,7 @@
Debug/ Debug/
Release/ Release/
*.ncb *.ncb
/.vs
ISLE.EXE ISLE.EXE
LEGO1.DLL LEGO1.DLL
build/ build/

View file

@ -4,6 +4,10 @@
#define DECOMP_STATIC_ASSERT(V) namespace { typedef int foo[(V)?1:-1]; } #define DECOMP_STATIC_ASSERT(V) namespace { typedef int foo[(V)?1:-1]; }
#define DECOMP_SIZE_ASSERT(T, S) DECOMP_STATIC_ASSERT(sizeof(T) == S) #define DECOMP_SIZE_ASSERT(T, S) DECOMP_STATIC_ASSERT(sizeof(T) == S)
#ifndef _countof
#define _countof(arr) sizeof(arr) / sizeof(arr[0])
#endif
typedef unsigned char undefined; typedef unsigned char undefined;
typedef unsigned short undefined2; typedef unsigned short undefined2;
typedef unsigned int undefined4; typedef unsigned int undefined4;

0
LEGO1/mxdirect3d.cpp Normal file
View file

0
LEGO1/mxdirect3d.h Normal file
View file

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,130 @@
#ifndef MXDIRECTDRAW_H #ifndef MXDIRECTDRAW_H
#define MXDIRECTDRAW_H #define MXDIRECTDRAW_H
#include <ddraw.h>
#include <Windows.h>
extern BOOL g_is_PALETTEINDEXED8;
//size 0x880
class MxDirectDraw class MxDirectDraw
{ {
public:
typedef void (*ErrorHandler)(const char*, HRESULT, void*);
//size 0x0c
struct Mode
{
int width;
int height;
int bitsPerPixel;
int operator==(const Mode& rMode) const
{
return ((width == rMode.width) &&
(height == rMode.height) &&
(bitsPerPixel == rMode.bitsPerPixel));
}
};
//size 0x17c
struct DeviceModesInfo
{
GUID* p_guid;
Mode* m_mode_ARRAY;
int count;
DDCAPS m_ddcaps;
void* a_178;
~DeviceModesInfo();
};
private:
BOOL m_bOnlySoftRender;
BOOL m_bFlipSurfaces;
IDirectDraw* m_pDirectDraw;
IDirectDrawSurface* m_pFrontBuffer;
IDirectDrawSurface* m_pBackBuffer;
IDirectDrawSurface* m_pZBuffer;
IDirectDrawSurface* m_pText1Surface;
IDirectDrawSurface* m_pText2Surface;
IDirectDrawClipper* m_pClipper;
IDirectDrawPalette* m_pPalette;
PALETTEENTRY m_paletteEntries[256];
PALETTEENTRY m_originalPaletteEntries[256];
SIZE m_text1SizeOnSurface;
SIZE m_text2SizeOnSurface;
HWND m_hWndMain;
HFONT m_hFont;
BOOL m_bIgnoreWM_SIZE;
BOOL m_bPrimaryPalettized;
BOOL m_bFullScreen;
void* a_850;
BOOL m_bOnlySystemMemory;
BOOL m_bIsOnPrimaryDevice;
ErrorHandler m_pErrorHandler;
ErrorHandler m_pFatalErrorHandler;
void* m_pErrorHandlerArg;
void* m_pFatalErrorHandlerArg;
int m_pauseCount;
DeviceModesInfo* m_pCurrentDeviceModesList;
Mode m_currentMode;
public: public:
__declspec(dllexport) int FlipToGDISurface(); __declspec(dllexport) int FlipToGDISurface();
__declspec(dllexport) static int GetPrimaryBitDepth(); __declspec(dllexport) static int GetPrimaryBitDepth();
__declspec(dllexport) int Pause(int); __declspec(dllexport) int Pause(int);
MxDirectDraw();
virtual ~MxDirectDraw();
virtual BOOL Create(
HWND hWnd,
BOOL fullscreen_1,
BOOL surface_fullscreen,
BOOL onlySystemMemory,
int width,
int height,
int bpp,
const PALETTEENTRY* pPaletteEntries,
int paletteEntryCount);
virtual void Destroy();
virtual void DestroyButNotDirectDraw();
virtual const char* ErrorToString(HRESULT error);
private:
BOOL CacheOriginalPaletteEntries();
HRESULT CreateDDSurface(
LPDDSURFACEDESC a2,
LPDIRECTDRAWSURFACE* a3,
IUnknown* a4);
BOOL CreateTextSurfaces();
BOOL CreateZBuffer(DWORD memorytype, DWORD depth);
BOOL DDCreateSurfaces();
BOOL DDInit(BOOL fullscreen);
BOOL DDSetMode(int width, int height, int bpp);
void Error(const char* message, int error);
BOOL GetDDSurfaceDesc(LPDDSURFACEDESC lpDDSurfDesc, LPDIRECTDRAWSURFACE lpDDSurf);
BOOL IsSupportedMode(int width, int height, int bpp);
BOOL RecreateDirectDraw(GUID** a2);
BOOL RestoreOriginalPaletteEntries();
BOOL RestorePaletteEntries();
BOOL RestoreSurfaces();
BOOL SetPaletteEntries(
const PALETTEENTRY* pPaletteEntries,
int paletteEntryCount,
BOOL fullscreen);
BOOL TextToTextSurface(
const char* text,
IDirectDrawSurface* pSurface,
SIZE& textSizeOnSurface);
BOOL TextToTextSurface1(const char* text);
BOOL TextToTextSurface2(const char* lpString);
void FUN_1009E020();
void FUN_1009D920();
}; };
#endif // MXDIRECTDRAW_H #endif // MXDIRECTDRAW_H