From ba55947ee6ab36efc04598953a78a11173103bcf Mon Sep 17 00:00:00 2001
From: GoldenTails <milestailsprower101n2@gmail.com>
Date: Mon, 10 Oct 2022 00:30:23 -0500
Subject: [PATCH] Make dummy compile again, if SDL is explicitly set to 0

---
 src/Makefile               |  4 ++--
 src/Makefile.d/detect.mk   |  1 -
 src/Makefile.d/nix.mk      |  2 +-
 src/Makefile.d/platform.mk |  4 +++-
 src/Makefile.d/win32.mk    |  4 +++-
 src/doomtype.h             |  2 --
 src/dummy/Sourcefile       |  5 +++++
 src/dummy/i_sound.c        | 11 ++++-------
 src/dummy/i_system.c       | 21 +++++++++++++++++----
 9 files changed, 35 insertions(+), 19 deletions(-)
 create mode 100644 src/dummy/Sourcefile

diff --git a/src/Makefile b/src/Makefile
index c1aa35742..9cab3e487 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -31,8 +31,8 @@
 # MINGW=1, MINGW64=1 - Windows (MinGW toolchain)
 # UNIX=1 - Generic Unix like system
 # FREEBSD=1
-# SDL=1 - Use SDL backend. SDL is the only backend though
-#         and thus, always enabled.
+# SDL=1 - Use SDL backend. SDL is the only implemented backend though.
+#         If disabled, a dummy backend will be used.
 #
 # A list of supported GCC versions can be found in
 # Makefile.d/detect.mk -- search 'gcc_versions'.
diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk
index f458b044c..aca498721 100644
--- a/src/Makefile.d/detect.mk
+++ b/src/Makefile.d/detect.mk
@@ -17,7 +17,6 @@ all_systems:=\
 	UNIX\
 	LINUX\
 	FREEBSD\
-	SDL\
 
 # check for user specified system
 ifeq (,$(filter $(all_systems),$(.VARIABLES)))
diff --git a/src/Makefile.d/nix.mk b/src/Makefile.d/nix.mk
index 6642a6bcc..767b64c12 100644
--- a/src/Makefile.d/nix.mk
+++ b/src/Makefile.d/nix.mk
@@ -18,7 +18,7 @@ opts+=-I/usr/X11R6/include
 libs+=-L/usr/X11R6/lib
 endif
 
-SDL=1
+SDL?=1
 
 # In common usage.
 ifdef LINUX
diff --git a/src/Makefile.d/platform.mk b/src/Makefile.d/platform.mk
index fad4be191..c5ac71a20 100644
--- a/src/Makefile.d/platform.mk
+++ b/src/Makefile.d/platform.mk
@@ -64,6 +64,8 @@ ifdef UNIX
 include Makefile.d/nix.mk
 endif
 
-ifdef SDL
+ifeq ($(SDL), 1)
 include Makefile.d/sdl.mk
+else
+include Makefile.d/dummy.mk
 endif
diff --git a/src/Makefile.d/win32.mk b/src/Makefile.d/win32.mk
index 768133c15..25d3ea9f4 100644
--- a/src/Makefile.d/win32.mk
+++ b/src/Makefile.d/win32.mk
@@ -19,7 +19,7 @@ libs+=-ladvapi32 -lkernel32 -lmsvcrt -luser32
 
 nasm_format:=win32
 
-SDL=1
+SDL?=1
 
 ifndef NOHW
 opts+=-DUSE_WGL_SWAP
@@ -76,6 +76,7 @@ else
 lib:=../libs/SDL2_mixer/$(mingw)
 endif
 
+ifdef SDL2
 mixer_opts:=-I$(lib)/include/SDL2
 mixer_libs:=-L$(lib)/lib
 
@@ -85,6 +86,7 @@ SDL_opts:=-I$(lib)/include/SDL2\
 SDL_libs:=-L$(lib)/lib $(mixer_libs)\
 	-lmingw32 -lSDL2main -lSDL2 -mwindows
 $(eval $(call _set,SDL))
+endif
 
 lib:=../libs/zlib
 ZLIB_opts:=-I$(lib)
diff --git a/src/doomtype.h b/src/doomtype.h
index 5ddd9ae44..b8f602c64 100644
--- a/src/doomtype.h
+++ b/src/doomtype.h
@@ -392,8 +392,6 @@ unset_bit_array (bitarray_t * const array, const int value)
 	array[value >> 3] &= ~(1<<(value & 7));
 }
 
-#ifdef HAVE_SDL
 typedef UINT64 precise_t;
-#endif
 
 #endif //__DOOMTYPE__
diff --git a/src/dummy/Sourcefile b/src/dummy/Sourcefile
new file mode 100644
index 000000000..2f5dd1a59
--- /dev/null
+++ b/src/dummy/Sourcefile
@@ -0,0 +1,5 @@
+i_net.c
+i_system.c
+i_main.c
+i_video.c
+i_sound.c
diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c
index f09158e01..ba0fc6423 100644
--- a/src/dummy/i_sound.c
+++ b/src/dummy/i_sound.c
@@ -139,29 +139,24 @@ boolean I_LoadSong(char *data, size_t len)
 
 void I_UnloadSong(void)
 {
-	(void)handle;
 }
 
 boolean I_PlaySong(boolean looping)
 {
-	(void)handle;
 	(void)looping;
 	return false;
 }
 
 void I_StopSong(void)
 {
-	(void)handle;
 }
 
 void I_PauseSong(void)
 {
-	(void)handle;
 }
 
 void I_ResumeSong(void)
 {
-	(void)handle;
 }
 
 void I_SetMusicVolume(UINT8 volume)
@@ -188,18 +183,20 @@ void I_StopFadingSong(void)
 {
 }
 
-boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void));
+boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void))
 {
 	(void)target_volume;
 	(void)source_volume;
 	(void)ms;
+	(void)callback;
 	return false;
 }
 
-boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void));
+boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void))
 {
 	(void)target_volume;
 	(void)ms;
+	(void)callback;
 	return false;
 }
 
diff --git a/src/dummy/i_system.c b/src/dummy/i_system.c
index 4a657ed19..a1d757204 100644
--- a/src/dummy/i_system.c
+++ b/src/dummy/i_system.c
@@ -1,6 +1,9 @@
 #include "../doomdef.h"
+#include "../doomtype.h"
 #include "../i_system.h"
 
+FILE *logstream = NULL;
+
 UINT8 graphics_started = 0;
 
 UINT8 keyboard_started = 0;
@@ -16,8 +19,14 @@ tic_t I_GetTime(void)
 	return 0;
 }
 
-int I_GetTimeMicros(void)
+precise_t I_GetPreciseTime(void)
+{
+	return 0;
+}
+
+int I_PreciseToMicros(precise_t d)
 {
+	(void)d;
 	return 0;
 }
 
@@ -96,8 +105,6 @@ void I_StartupMouse(void){}
 
 void I_StartupMouse2(void){}
 
-void I_StartupKeyboard(void){}
-
 INT32 I_GetKey(void)
 {
 	return 0;
@@ -176,12 +183,18 @@ INT32 I_ClipboardCopy(const char *data, size_t size)
 	return -1;
 }
 
-char *I_ClipboardPaste(void)
+const char *I_ClipboardPaste(void)
 {
 	return NULL;
 }
 
 void I_RegisterSysCommands(void) {}
 
+void I_GetCursorPosition(INT32 *x, INT32 *y)
+{
+	(void)x;
+	(void)y;
+}
+
 #include "../sdl/dosstr.c"
 
-- 
GitLab