diff --git a/Makefile b/Makefile index 4ac73f332..24754e222 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ srcdir ?= . -DEFINES := -D_GLIBCXX_USE_CXX11_ABI=1 +DEFINES := -DSDL_SUPPORT -D_GLIBCXX_USE_CXX11_ABI=1 LDFLAGS := -pthread INCLUDES := LIBS := diff --git a/src/common/MediaFactory.hxx b/src/common/MediaFactory.hxx index f43f9fcdd..4d205b59b 100644 --- a/src/common/MediaFactory.hxx +++ b/src/common/MediaFactory.hxx @@ -19,7 +19,9 @@ #define MEDIA_FACTORY_HXX #include "bspf.hxx" -#include "SDL_lib.hxx" +#if defined(SDL_SUPPORT) + #include "SDL_lib.hxx" +#endif #include "OSystem.hxx" #include "Settings.hxx" @@ -54,16 +56,20 @@ #if defined(__LIB_RETRO__) #include "EventHandlerLIBRETRO.hxx" #include "FrameBufferLIBRETRO.hxx" -#else +#elif defined(SDL_SUPPORT) #include "EventHandlerSDL2.hxx" #include "FrameBufferSDL2.hxx" +#else + #error Unsupported backend! #endif #if defined(SOUND_SUPPORT) #if defined(__LIB_RETRO__) #include "SoundLIBRETRO.hxx" - #else + #elif defined(SDL_SUPPORT) #include "SoundSDL2.hxx" + #else + #include "SoundNull.hxx" #endif #else #include "SoundNull.hxx" @@ -140,19 +146,23 @@ class MediaFactory { #if defined(__LIB_RETRO__) return make_unique(osystem); - #else + #elif defined(SDL_SUPPORT) return make_unique(osystem); + #else + #error Unsupported platform for FrameBuffer! #endif } static unique_ptr createAudio(OSystem& osystem, AudioSettings& audioSettings) { - #ifdef SOUND_SUPPORT + #if defined(SOUND_SUPPORT) #if defined(__LIB_RETRO__) return make_unique(osystem, audioSettings); - #elif defined(SOUND_SUPPORT) + #elif defined(SOUND_SUPPORT) && defined(SDL_SUPPORT) return make_unique(osystem, audioSettings); - #endif + #else + return make_unique(osystem); + #endif #else return make_unique(osystem); #endif @@ -161,25 +171,28 @@ class MediaFactory static unique_ptr createEventHandler(OSystem& osystem) { #if defined(__LIB_RETRO__) - return make_unique(osystem); - #else - return make_unique(osystem); - #endif + return make_unique(osystem); + #elif defined(SDL_SUPPORT) + return make_unique(osystem); + #else + #error Unsupported platform for EventHandler! + #endif } static void cleanUp() { + #if defined(SDL_SUPPORT) SDL_Quit(); + #endif } static string backendName() { - ostringstream buf; - SDL_version ver; - SDL_GetVersion(&ver); - buf << "SDL " << int(ver.major) << "." << int(ver.minor) << "." << int(ver.patch); - - return buf.str(); + #if defined(SDL_SUPPORT) + return SDLVersion(); + #else + return "Custom backend"; + #endif } private: diff --git a/src/common/SDL_lib.hxx b/src/common/SDL_lib.hxx index fb93d753c..8b459e04c 100644 --- a/src/common/SDL_lib.hxx +++ b/src/common/SDL_lib.hxx @@ -18,6 +18,8 @@ #ifndef SDL_LIB_HXX #define SDL_LIB_HXX +#include "bspf.hxx" + /* * We can't control the quality of code from outside projects, so for now * just disable warnings for it. @@ -43,4 +45,13 @@ #undef pixel #undef bool -#endif +static inline string SDLVersion() +{ + ostringstream buf; + SDL_version ver; + SDL_GetVersion(&ver); + buf << "SDL " << int(ver.major) << "." << int(ver.minor) << "." << int(ver.patch); + return buf.str(); +} + +#endif // SDL_LIB_HXX diff --git a/src/common/StellaKeys.hxx b/src/common/StellaKeys.hxx index 92967dcca..c6fe1ac8d 100644 --- a/src/common/StellaKeys.hxx +++ b/src/common/StellaKeys.hxx @@ -18,7 +18,9 @@ #ifndef STELLA_KEYS_HXX #define STELLA_KEYS_HXX -#include "SDL_lib.hxx" +#ifdef SDL_SUPPORT + #include "SDL_lib.hxx" +#endif /** This class implements a thin wrapper around the SDL keysym enumerations, @@ -439,7 +441,11 @@ namespace StellaKeyName { inline const char* const forKey(StellaKey key) { + #ifdef SDL_SUPPORT return SDL_GetScancodeName(SDL_Scancode(key)); + #else + return ""; + #endif } }; diff --git a/src/macos/stella.xcodeproj/project.pbxproj b/src/macos/stella.xcodeproj/project.pbxproj index fcf9a48f7..a101dd45d 100644 --- a/src/macos/stella.xcodeproj/project.pbxproj +++ b/src/macos/stella.xcodeproj/project.pbxproj @@ -3026,6 +3026,7 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( + SDL_SUPPORT, CHEATCODE_SUPPORT, DEBUGGER_SUPPORT, JOYSTICK_SUPPORT, @@ -3080,6 +3081,7 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_OPTIMIZATION_LEVEL = 3; GCC_PREPROCESSOR_DEFINITIONS = ( + SDL_SUPPORT, CHEATCODE_SUPPORT, DEBUGGER_SUPPORT, JOYSTICK_SUPPORT, diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index ea417eb48..88f983912 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -157,7 +157,7 @@ Disabled ..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories) - BSPF_WINDOWS;WIN32;DEBUG_BUILD;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) + BSPF_WINDOWS;WIN32;DEBUG_BUILD;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDLL @@ -193,7 +193,7 @@ Disabled ..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories) - BSPF_WINDOWS;WIN32;DEBUG_BUILD;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) + BSPF_WINDOWS;WIN32;DEBUG_BUILD;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDLL @@ -226,7 +226,7 @@ true false ..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories) - BSPF_WINDOWS;WIN32;NDEBUG;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) + BSPF_WINDOWS;WIN32;NDEBUG;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) MultiThreadedDLL false @@ -260,7 +260,7 @@ true false ..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories) - BSPF_WINDOWS;WIN32;NDEBUG;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) + BSPF_WINDOWS;WIN32;NDEBUG;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) MultiThreadedDLL false @@ -298,7 +298,7 @@ AnySuitable true ..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories) - BSPF_WINDOWS;WIN32;NDEBUG;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) + BSPF_WINDOWS;WIN32;NDEBUG;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) MultiThreadedDLL false @@ -335,7 +335,7 @@ Default true ..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories) - BSPF_WINDOWS;WIN32;NDEBUG;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) + BSPF_WINDOWS;WIN32;NDEBUG;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions) MultiThreadedDLL false @@ -1399,4 +1399,4 @@ - \ No newline at end of file +