diff --git a/Makefile b/Makefile index 3406068..6ce2b4c 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,16 @@ -include config.mk -TARGET = ddraw.dll -LDFLAGS = -Wl,--enable-stdcall-fixup -s -static -shared -CFLAGS = -Iinc -O2 -march=i486 -Wall -std=c99 -LIBS = -lgdi32 -lwinmm -ldbghelp -lole32 +TARGET ?= ddraw.dll + +LDFLAGS ?= -Wl,--enable-stdcall-fixup -s -static -shared +CFLAGS ?= -Iinc -O2 -Wall -std=c99 +LIBS = -lgdi32 -lwinmm -ldbghelp -lole32 -lMsimg32 COMMIT := $(shell git describe --match=NeVeRmAtCh --always --dirty || echo UNKNOWN) BRANCH := $(shell git rev-parse --abbrev-ref HEAD || echo UNKNOWN) -CMDTEST := $(shell echo \"\") -ifeq ($(CMDTEST),\"\") +ECHOTEST := $(shell echo \"\") +ifeq ($(ECHOTEST),\"\") # Windows HASH := \# ECOMMIT := $(shell echo $(HASH)define GIT_COMMIT "$(COMMIT)" > inc/git.h) @@ -20,13 +21,17 @@ else EBRANCH := $(shell echo "#define GIT_BRANCH" \"$(BRANCH)\" >> inc/git.h) endif -CC = i686-w64-mingw32-gcc -WINDRES ?= i686-w64-mingw32-windres - ifdef DEBUG CFLAGS += -D _DEBUG -D _DEBUG_X endif +ifdef _WIN32_WINNT + CFLAGS += -march=i486 -D _WIN32_WINNT=$(_WIN32_WINNT) +endif + +CC = i686-w64-mingw32-gcc +WINDRES ?= i686-w64-mingw32-windres + SRCS := $(wildcard src/*.c) $(wildcard src/*/*.c) res.rc OBJS := $(addsuffix .o, $(basename $(SRCS))) diff --git a/build.cmd b/build.cmd index 34bb56c..0348c73 100644 --- a/build.cmd +++ b/build.cmd @@ -10,6 +10,6 @@ set GIT6=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\ set PATH=C:\w64devkit\bin;%GIT1%;%GIT2%;%GIT3%;%GIT4%;%GIT5%;%GIT6%;%PATH% make clean -make +make _WIN32_WINNT=0x0500 pause diff --git a/build_debug.cmd b/build_debug.cmd index 755ec1f..154ceb2 100644 --- a/build_debug.cmd +++ b/build_debug.cmd @@ -10,6 +10,6 @@ set GIT6=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\ set PATH=C:\w64devkit\bin;%GIT1%;%GIT2%;%GIT3%;%GIT4%;%GIT5%;%GIT6%;%PATH% make clean -make DEBUG=1 +make DEBUG=1 _WIN32_WINNT=0x0500 pause diff --git a/inc/dd.h b/inc/dd.h index 36f1ca6..b9382b1 100644 --- a/inc/dd.h +++ b/inc/dd.h @@ -64,6 +64,18 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute #define CREATE_WAITABLE_TIMER_MANUAL_RESET 0x00000001 #endif +#ifndef GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT +#define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 0x00000002 +#endif + +#ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS +#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004 +#endif + +#if (_WIN32_WINNT < _WIN32_WINNT_WIN2K) +#define GdiTransparentBlt TransparentBlt +#endif + typedef struct SPEEDLIMITER { DWORD tick_length; diff --git a/inc/versionhelpers.h b/inc/versionhelpers.h index 8a59f74..bf622e6 100644 --- a/inc/versionhelpers.h +++ b/inc/versionhelpers.h @@ -28,6 +28,11 @@ #define _WIN32_WINNT_WIN11 0x0A00 #endif +#if (_WIN32_WINNT < _WIN32_WINNT_WIN2K) +#define RtlVerifyVersionInfo(a,b,c) 1 +#define VerifyVersionInfoW(a,b,c) 0 +#define VerSetConditionMask(a,b,c) 0 +#endif void verhelp_init(); BOOL verhelp_verify_version(PRTL_OSVERSIONINFOEXW versionInfo, ULONG typeMask, ULONGLONG conditionMask); diff --git a/src/debug.c b/src/debug.c index cff87d3..8d4ba5b 100644 --- a/src/debug.c +++ b/src/debug.c @@ -73,7 +73,7 @@ LONG WINAPI dbg_exception_handler(EXCEPTION_POINTERS* exception) HMODULE mod = NULL; char filename[MAX_PATH] = { 0 }; -#if defined(_MSC_VER) /* comment this out just to keep the mingw build win2000 compatible */ +#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP) if (GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, exception->ExceptionRecord->ExceptionAddress,