Skip to content

Commit

Permalink
Strip some now unused parts of miniwin and windows api
Browse files Browse the repository at this point in the history
  • Loading branch information
AJenbo committed Sep 24, 2019
1 parent 46a11a8 commit 88813c4
Show file tree
Hide file tree
Showing 29 changed files with 186 additions and 764 deletions.
13 changes: 0 additions & 13 deletions 3rdParty/Storm/Source/storm.h
Expand Up @@ -3,21 +3,10 @@
#ifndef __BLIZZARD_STORM_HEADER
#define __BLIZZARD_STORM_HEADER

#ifndef DEVILUTION_STUB
#include <windows.h>
#include <winuser.h>
#include <winsock.h>
#include <ddraw.h>
#include <limits>

#else

#include "miniwin/pushdecl.inc"
#include <limits>
namespace dvl {

#endif

// Note to self: Linker error => forgot a return value in cpp

// Storm API definition
Expand Down Expand Up @@ -1354,9 +1343,7 @@ BOOL __stdcall SFileEnableDirectAccess(BOOL enable);
}
#endif

#ifdef DEVILUTION_STUB
}
#include "miniwin/popdecl.inc"
#endif

#endif
2 changes: 0 additions & 2 deletions CMakeLists.txt
Expand Up @@ -186,7 +186,6 @@ add_executable(devilutionx MACOSX_BUNDLE
SourceX/miniwin/rand.cpp
SourceX/miniwin/thread.cpp
SourceX/miniwin/dsound.cpp
SourceX/miniwin/ddraw.cpp
SourceX/sound.cpp
SourceX/storm/storm.cpp
SourceX/storm/storm_net.cpp
Expand Down Expand Up @@ -231,7 +230,6 @@ target_link_libraries(devilutionx PRIVATE

target_compile_definitions(devilution PRIVATE DEVILUTION_ENGINE)
target_compile_definitions(devilution PUBLIC
DEVILUTION_STUB
"$<$<BOOL:${DEBUG}>:_DEBUG>"
# Skip fades and other fluff
"$<$<BOOL:${FASTER}>:FASTER>")
Expand Down
4 changes: 0 additions & 4 deletions DiabloUI/diabloui.h
Expand Up @@ -2,10 +2,8 @@
#ifndef __DIABLOUI_H__
#define __DIABLOUI_H__

#ifdef DEVILUTION_STUB
#include "miniwin/pushdecl.inc"
namespace dvl {
#endif

//#if defined(__GNUC__) || defined(__cplusplus)
//extern "C" {
Expand Down Expand Up @@ -65,9 +63,7 @@ BOOL __stdcall UiBetaDisclaimer(int a1);
//}
//#endif

#ifdef DEVILUTION_STUB
}
#include "miniwin/popdecl.inc"
#endif

#endif /* __DIABLOUI_H__ */
2 changes: 0 additions & 2 deletions Source/appfat.cpp
Expand Up @@ -528,10 +528,8 @@ void center_window(HWND hDlg)
GetWindowRect(hDlg, &Rect);
w = Rect.right - Rect.left;
h = Rect.bottom - Rect.top;
hdc = GetDC(hDlg);
screenW = GetDeviceCaps(hdc, HORZRES);
screenH = GetDeviceCaps(hdc, VERTRES);
ReleaseDC(hDlg, hdc);

if (!SetWindowPos(hDlg, HWND_TOP, (screenW - w) / 2, (screenH - h) / 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE)) {
app_fatal("center_window: %s", TraceLastError());
Expand Down
6 changes: 3 additions & 3 deletions Source/capture.cpp
Expand Up @@ -12,7 +12,7 @@ void CaptureScreen()
hObject = CaptureFile(FileName);
if (hObject != INVALID_HANDLE_VALUE) {
DrawAndBlit();
lpDDPalette->GetEntries(0, 0, 256, palette);
PaletteGetEntries(256, palette);
RedPalette(palette);

lock_buf(2);
Expand All @@ -30,7 +30,7 @@ void CaptureScreen()
DeleteFile(FileName);

Sleep(300);
lpDDPalette->SetEntries(0, 0, 256, palette);
PaletteGetEntries(256, palette);
}
}

Expand Down Expand Up @@ -154,7 +154,7 @@ void RedPalette(PALETTEENTRY *pal)
red[i].peFlags = 0;
}

lpDDPalette->SetEntries(0, 0, 256, red);
PaletteGetEntries(256, red);
}

DEVILUTION_END_NAMESPACE
4 changes: 0 additions & 4 deletions Source/diablo.cpp
Expand Up @@ -293,7 +293,6 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi

if (ghMainWnd) {
Sleep(300);
DestroyWindow(ghMainWnd);
}
}

Expand All @@ -314,9 +313,6 @@ void diablo_parse_flags(char *args)
if (_strnicmp("dd_emulate", args, strlen("dd_emulate")) == 0) {
gbEmulate = 1;
args += strlen("dd_emulate");
} else if (_strnicmp("dd_backbuf", args, strlen("dd_backbuf")) == 0) {
gbBackBuf = 1;
args += strlen("dd_backbuf");
} else if (_strnicmp("ds_noduplicates", args, strlen("ds_noduplicates")) == 0) {
gbDupSounds = FALSE;
args += strlen("ds_noduplicates");
Expand Down
3 changes: 0 additions & 3 deletions Source/diablo.h
Expand Up @@ -171,10 +171,7 @@ extern BOOL FriendlyMode;
extern char *spszMsgTbl[4];
extern char *spszMsgHotKeyTbl[4];

#ifdef DEVILUTION_STUB
#include "miniwin/popdecl.inc"
#endif

DEVILUTION_END_NAMESPACE

#endif /* __DIABLO_H__ */
6 changes: 6 additions & 0 deletions Source/dx.h
Expand Up @@ -23,6 +23,12 @@ void dx_cleanup();
void dx_reinit();
void j_dx_reinit();

HRESULT CreatePalette();
HRESULT BltFast(DWORD dwX, DWORD dwY, LPRECT lpSrcRect);
HRESULT RenderPresent();
void PaletteGetEntries(DWORD dwNumEntries, LPPALETTEENTRY lpEntries);
void PaletteSetEntries(DWORD dwCount, LPPALETTEENTRY lpEntries);

/* data */

#endif /* __DX_H__ */
18 changes: 5 additions & 13 deletions Source/palette.cpp
Expand Up @@ -27,10 +27,7 @@ void palette_init()
LoadGamma();
memcpy(system_palette, orig_palette, sizeof(orig_palette));
LoadSysPal();
error_code = lpDDInterface->CreatePalette(DDPCAPS_ALLOW256 | DDPCAPS_8BIT, system_palette, &lpDDPalette, NULL);
if (error_code)
ERR_DLG(IDD_DIALOG8, error_code);
error_code = lpDDSPrimary->SetPalette(lpDDPalette);
error_code = CreatePalette();
if (error_code)
ERR_DLG(IDD_DIALOG8, error_code);
}
Expand Down Expand Up @@ -64,8 +61,6 @@ void LoadSysPal()
system_palette[i].peFlags = PC_NOCOLLAPSE | PC_RESERVED;

if (!fullscreen) {
hDC = GetDC(NULL);

gdwPalEntries = GetDeviceCaps(hDC, NUMRESERVED) / 2;
GetSystemPaletteEntries(hDC, 0, gdwPalEntries, system_palette);
for (i = 0; i < gdwPalEntries; i++)
Expand All @@ -77,8 +72,6 @@ void LoadSysPal()
for (i = iStartIndex; i < 256; i++)
system_palette[i].peFlags = 0;
}

ReleaseDC(NULL, hDC);
}
}

Expand Down Expand Up @@ -136,7 +129,7 @@ void palette_update()
int nentries;
int max_entries;

if (lpDDPalette) {
if (1) {
nentries = 0;
max_entries = 256;
if (!fullscreen) {
Expand Down Expand Up @@ -194,23 +187,22 @@ void SetFadeLevel(DWORD fadeval)
int i;
RECT SrcRect;

if (lpDDInterface) {
if (1) {
for (i = 0; i < 255; i++) {
system_palette[i].peRed = (fadeval * logical_palette[i].peRed) >> 8;
system_palette[i].peGreen = (fadeval * logical_palette[i].peGreen) >> 8;
system_palette[i].peBlue = (fadeval * logical_palette[i].peBlue) >> 8;
}
Sleep(3);
lpDDInterface->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL);
palette_update();

// Workaround for flickering mouse in caves https://github.com/diasurgical/devilutionX/issues/7
SrcRect.left = 64;
SrcRect.top = 160;
SrcRect.right = BUFFER_WIDTH;
SrcRect.bottom = BUFFER_HEIGHT; // menu isn't offset so make sure we copy all of it
lpDDSPrimary->BltFast(0, 0, lpDDSBackBuf, &SrcRect, DDBLTFAST_WAIT);
lpDDSPrimary->Unlock(NULL);
BltFast(0, 0, &SrcRect);
RenderPresent();
}
}

Expand Down
12 changes: 4 additions & 8 deletions Source/scrollrt.cpp
Expand Up @@ -13,7 +13,6 @@ DWORD level_cel_block;
DWORD sgdwCursXOld;
DWORD sgdwCursYOld;
char arch_draw_type;
DDSURFACEDESC DDS_desc;
int cel_transparency_active;
int level_piece_id;
DWORD sgdwCursWdt;
Expand Down Expand Up @@ -2294,7 +2293,7 @@ void DrawMain(int dwHgt, BOOL draw_desc, BOOL draw_hp, BOOL draw_mana, BOOL draw

ysize = dwHgt;

if (!gbActive || lpDDSPrimary == NULL) {
if (!gbActive) {
return;
}

Expand Down Expand Up @@ -2358,10 +2357,7 @@ void DrawFPS()
if (framerate > 99)
framerate = 99;
wsprintf(String, "%2d", framerate);
if (!lpDDSPrimary->GetDC(&hdc)) {
TextOut(hdc, 0, 400, String, strlen(String));
lpDDSPrimary->ReleaseDC(hdc);
}
TextOut(hdc, 0, 400, String, strlen(String));
}
}
#endif
Expand All @@ -2376,15 +2372,15 @@ void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt)
/// ASSERT: assert(! (dwX & 3));
/// ASSERT: assert(! (dwWdt & 3));

if (lpDDSBackBuf != NULL) {
if (1) {
SrcRect.left = dwX + SCREEN_X;
SrcRect.top = dwY + SCREEN_Y;
SrcRect.right = SrcRect.left + dwWdt - 1;
SrcRect.bottom = SrcRect.top + dwHgt - 1;
/// ASSERT: assert(! gpBuffer);
dwTicks = GetTickCount();
while (1) {
hDDVal = lpDDSPrimary->BltFast(dwX, dwY, lpDDSBackBuf, &SrcRect, DDBLTFAST_WAIT);
hDDVal = BltFast(dwX, dwY, &SrcRect);
if (hDDVal == DD_OK) {
break;
}
Expand Down
1 change: 0 additions & 1 deletion Source/scrollrt.h
Expand Up @@ -7,7 +7,6 @@ extern int PitchTbl[1024];
extern BYTE *gpBufEnd;
extern DWORD level_cel_block;
extern char arch_draw_type;
extern DDSURFACEDESC DDS_desc;
extern int cel_transparency_active;
extern int level_piece_id;
extern void (*DrawPlrProc)(int, int, int, int, int, BYTE *, int, int, int, int);
Expand Down
2 changes: 0 additions & 2 deletions SourceS/miniwin.h
Expand Up @@ -39,7 +39,5 @@ unsigned int _rotr(unsigned int value, int shift);
#include "storm_full.h"

#define MAX_PATH DVL_MAX_PATH
#ifdef DEVILUTION_ENGINE
#include "miniwin/misc_macro.h"
#include "miniwin/com_macro.h"
#endif
38 changes: 3 additions & 35 deletions SourceS/miniwin/com.h
Expand Up @@ -2,25 +2,6 @@

namespace dvl {

#define DEVILUTION_MINIWIN_COM

#ifndef DEVILUTION_ENGINE
#pragma push_macro("DECLARE_INTERFACE_")
#pragma push_macro("STDMETHOD")
#pragma push_macro("STDMETHOD_")
#pragma push_macro("THIS_")
#pragma push_macro("THIS")
#pragma push_macro("PURE")
#pragma push_macro("REFIID")
#undef DECLARE_INTERFACE_
#undef STDMETHOD
#undef STDMETHOD_
#undef THIS_
#undef THIS
#undef PURE
#undef REFIID
#endif

//
// COM
//
Expand All @@ -32,9 +13,6 @@ namespace dvl {
#define STDMETHOD(name) STDMETHOD_(HRESULT, name)
#define STDMETHOD_(type, name) virtual WINAPI type name

typedef void *DVL_REFIID;
#define REFIID DVL_REFIID

struct IUnknown {
// clang-format off
STDMETHOD_(ULONG, Release)(THIS) PURE;
Expand All @@ -46,22 +24,12 @@ template<class T, class U, class V> constexpr HRESULT DVL_MAKE_HRESULT(T&& sev,
return (((uint32_t)(sev) << 31) | ((uint32_t)(fac) << 16) | ((uint32_t)(code)));
}

typedef struct IDirectDrawPalette *LPDIRECTDRAWPALETTE;
typedef struct IDirectDrawSurface *LPDIRECTDRAWSURFACE;
typedef struct IDirectDraw *LPDIRECTDRAW;

#include "miniwin/com/ddraw.inc"
#include "miniwin/com/dsound.inc"

#ifndef DEVILUTION_ENGINE
#pragma pop_macro("DECLARE_INTERFACE_")
#pragma pop_macro("STDMETHOD")
#pragma pop_macro("STDMETHOD_")
#pragma pop_macro("THIS_")
#pragma pop_macro("THIS")
#pragma pop_macro("PURE")
#pragma pop_macro("REFIID")
#endif

#undef DEVILUTION_MINIWIN_COM

constexpr HRESULT DVL_E_FAIL = 0x80004005L;
constexpr HRESULT DVL_S_OK = 0;

Expand Down

0 comments on commit 88813c4

Please sign in to comment.