Skip to content

Commit

Permalink
removed PLATFORM_SDL (#69)
Browse files Browse the repository at this point in the history
PLATFORM_SDL was hardcoded and the rest of the old DX8 code was removed long time ago.
  • Loading branch information
Mia75owo authored Dec 12, 2023
1 parent 0bc68c3 commit 780878c
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 73 deletions.
1 change: 0 additions & 1 deletion Hurrican/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ IF(FBO)
)
ENDIF(FBO)

add_definitions(-DPLATFORM_SDL)
add_definitions(-DENABLE_CONSOLE_COMMANDS) # make optional?

OPTION(DISABLE_EXCEPTIONS "Disable exception handling to reduce binary size" OFF)
Expand Down
12 changes: 0 additions & 12 deletions Hurrican/src/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,27 +822,15 @@ int ConsoleClass::GetIntFromBuffer(int index) {

inline bool ConsoleClass::CONSOLE_COMMAND(const char* command) {
#if defined(ENABLE_CONSOLE_COMMANDS)

# if defined(PLATFORM_SDL)
return strcmp(Buffer, command) == 0;
# else
return strcmp(_strlwr_s(Buffer), command) == 0;
# endif

#else
return false;
#endif
}

inline bool ConsoleClass::CONSOLE_COMMAND_ARG(const char* command, int len) {
#if defined(ENABLE_CONSOLE_COMMANDS)

# if defined(PLATFORM_SDL)
return strncmp(Buffer, command, len) == 0;
# else
return strncmp(_strlwr_s(Buffer), command, len) == 0;
# endif

#else
return false;
#endif
Expand Down
2 changes: 0 additions & 2 deletions Hurrican/src/DX8Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#include "Globals.hpp"
#include "Logdatei.hpp"
#include "Timer.hpp"
#if defined(PLATFORM_SDL)
#include "SDLPort/texture.hpp"
#endif // PLATFORM_SDL
#include "DX8Font.hpp"
#include "DX8Graphics.hpp"
#include "Gameplay.hpp"
Expand Down
11 changes: 2 additions & 9 deletions Hurrican/src/DX8Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ bool DirectGraphicsClass::SetDeviceInfo() {

bool DirectGraphicsClass::TakeScreenshot(const char Filename[100], int screenx, int screeny) {

#if defined(PLATFORM_SDL) && SDL_VERSION_ATLEAST(2, 0, 0)
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_Surface *image = SDL_CreateRGBSurface(SDL_SWSURFACE, screenx, screeny, 24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0);
glReadPixels(0, 0, screenx, screeny, GL_RGB, GL_UNSIGNED_BYTE, image->pixels);
FlipSurface(image);
Expand Down Expand Up @@ -664,7 +664,6 @@ void DirectGraphicsClass::DisplayBuffer() {
ShowBackBuffer();
}

#if defined(PLATFORM_SDL)
bool DirectGraphicsClass::ExtensionSupported(const char *ext) {
if (strstr(glextensions, ext) != nullptr) {
Protokoll << ext << " is supported" << std::endl;
Expand All @@ -674,11 +673,9 @@ bool DirectGraphicsClass::ExtensionSupported(const char *ext) {
Protokoll << ext << " is not supported" << std::endl;
return false;
}
#endif

// DKS - Supports new TexturesystemClass and is now used for both GL and DirectX
#if 0
#if defined(PLATFORM_SDL)
void DirectGraphicsClass::SetTexture( int32_t index )
{
if (index >= 0)
Expand Down Expand Up @@ -715,7 +712,6 @@ void DirectGraphicsClass::SetTexture( int32_t index )
#endif
}
}
#endif
#endif // 0
void DirectGraphicsClass::SetTexture(int idx) {
if (idx >= 0) {
Expand Down Expand Up @@ -832,7 +828,6 @@ void DirectGraphicsClass::ShowBackBuffer() {
#endif
}

#if defined(PLATFORM_SDL)
void DirectGraphicsClass::SetupFramebuffers() {
/* Read the current window size */
#if SDL_VERSION_ATLEAST(2, 0, 0)
Expand Down Expand Up @@ -1001,7 +996,7 @@ void DirectGraphicsClass::DrawCircle(uint16_t x, uint16_t y, uint16_t radius) {
// Takes a SDL surface and flips it vertically
// --------------------------------------------------------------------------------------

#if defined(PLATFORM_SDL) && SDL_VERSION_ATLEAST(2, 0, 0)
#if SDL_VERSION_ATLEAST(2, 0, 0)
void DirectGraphicsClass::FlipSurface(SDL_Surface* surface) {
SDL_LockSurface(surface);

Expand All @@ -1025,5 +1020,3 @@ void DirectGraphicsClass::FlipSurface(SDL_Surface* surface) {
SDL_UnlockSurface(surface);
}
#endif

#endif /* PLATFORM_SDL */
25 changes: 8 additions & 17 deletions Hurrican/src/DX8Graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,13 @@
// Include Dateien
// --------------------------------------------------------------------------------------

#if defined(PLATFORM_SDL)
# include "SDL_port.hpp"
# if defined(USE_GL2) || defined(USE_GL3)
# include "cshader.hpp"
# if defined(USE_FBO)
# include "cfbo.hpp"
# endif /* USE_FBO */
# endif /* USE_GL2 || USE_GL3 */
#else
# include <D3dx8math.h>
# include <d3d8.h>
# include <d3dx8.h>
# include <d3dx8tex.h>
#endif
#include "SDL_port.hpp"
#if defined(USE_GL2) || defined(USE_GL3)
# include "cshader.hpp"
# if defined(USE_FBO)
# include "cfbo.hpp"
# endif /* USE_FBO */
#endif /* USE_GL2 || USE_GL3 */

// --------------------------------------------------------------------------------------
// Defines
Expand Down Expand Up @@ -133,7 +126,6 @@ class DirectGraphicsClass {
void DisplayBuffer(); // Render den Buffer auf den Backbuffer
// DKS - SetTexture is now used for both GL and DirectX, and uses new TexturesystemClass:
void SetTexture(int idx);
#if defined(PLATFORM_SDL)
bool ExtensionSupported(const char *ext);
void SetupFramebuffers();
void ClearBackBuffer();
Expand All @@ -143,7 +135,6 @@ class DirectGraphicsClass {
void DrawTouchOverlay();
void DrawCircle(uint16_t x, uint16_t y, uint16_t radius);
#endif
#endif
#endif

inline BlendModeEnum GetBlendMode() const { return BlendMode; }
Expand All @@ -154,7 +145,7 @@ class DirectGraphicsClass {
inline SDL_Rect GetWindowView() const {return WindowView); }
#endif

#if defined(PLATFORM_SDL) && SDL_VERSION_ATLEAST(2, 0, 0)
#if SDL_VERSION_ATLEAST(2, 0, 0)
void FlipSurface(SDL_Surface* surface);
#endif
};
Expand Down
16 changes: 6 additions & 10 deletions Hurrican/src/DX8Input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ constexpr int MAX_MOUSEBUTTONS = 4;
constexpr int DINPUT_BUFFERSIZE = 32;
constexpr int MAX_KEYS = 256;

#if defined(PLATFORM_SDL)
# if SDL_VERSION_ATLEAST(2, 0, 0)
# define KeyDown(Taste) (TastaturPuffer[SDL_GetScancodeFromKey(Taste)] > 0)
# define KeyCode(Taste) (SDL_GetKeyFromScancode(static_cast<SDL_Scancode >(i)))
# else
# define KeyDown(Taste) (TastaturPuffer[Taste] > 0)
# define KeyCode(Taste) (Taste)
# endif
#if SDL_VERSION_ATLEAST(2, 0, 0)
# define KeyDown(Taste) (TastaturPuffer[SDL_GetScancodeFromKey(Taste)] > 0)
# define KeyCode(Taste) (SDL_GetKeyFromScancode(static_cast<SDL_Scancode >(i)))
#else
# define KeyDown(Taste) (TastaturPuffer[Taste] > 0)
# define KeyCode(Taste) (Taste)
#endif

// ForceFeedback Effekte
Expand Down Expand Up @@ -138,9 +136,7 @@ class DirectInputClass {
// --------------------------------------------------------------------------------------

extern DirectInputClass DirectInput;
#if defined(PLATFORM_SDL)
extern const Uint8 *TastaturPuffer;
#endif
extern bool UseForceFeedback; // ForceFeedback Fähigkeit nutzen ?

#endif
5 changes: 2 additions & 3 deletions Hurrican/src/DX8Joystick.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ constexpr int MAX_JOYSTICKBUTTONS = 128;
// --------------------------------------------------------------------------------------
// Include Dateien
// --------------------------------------------------------------------------------------
#if defined(PLATFORM_SDL)
# include "SDL_port.hpp"
#endif

#include "SDL_port.hpp"

#include <bitset>
#include <string>
Expand Down
2 changes: 0 additions & 2 deletions Hurrican/src/DX8Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ bool DirectGraphicsSprite::LoadImage(const char *Filename, int xs, int ys, int x
#if defined(USE_PVRTC) || defined(USE_ETC1)
char compresstex[256];
#endif
#if defined(PLATFORM_SDL)
()hresult;

SDL_Rect dims;
#endif

// zuerst eine evtl benutzte Textur freigeben
delete_texture( itsTexture );
Expand Down
7 changes: 1 addition & 6 deletions Hurrican/src/DX8Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@
// abstracts away the details like the alpha textures needed by ETC1 compression.
// It also unifies the interface that was once different between DX8 and SDL.

#if defined(PLATFORM_SDL)
#include "SDLPort/SDL_port.hpp"
#endif
#include "SDLPort/texture.hpp"

#include "DX8Texture.hpp"

#if defined(PLATFORM_SDL)
#include "SDLPort/texture.hpp"
#endif

#include "Gameplay.hpp"
#include "Main.hpp"

Expand Down
4 changes: 0 additions & 4 deletions Hurrican/src/GegnerClass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
// Include Dateien
// --------------------------------------------------------------------------------------

#if defined(PLATFORM_SDL)
#include "SDL_port.hpp"
#else
#include <d3dx8.h>
#endif
#include "DX8Sprite.hpp"

#include <list>
Expand Down
6 changes: 2 additions & 4 deletions Hurrican/src/Main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ struct sCommandLineParams {
char Params[256];
char *DataPath;
char *SavePath;
#if defined(PLATFORM_SDL)
uint16_t TexFactor;
uint16_t TexSizeMin;
bool AllowNPotTextureSizes;
#endif
bool ShowFPS;
bool VSync;
uint8_t ScreenDepth;
Expand Down Expand Up @@ -111,15 +109,15 @@ void ShowFPS();
// We will Swap values only for Big_Endian, Little_Endian should be unchanged
// --------------------------------------------------------------------------------------
static inline uint32_t FixEndian(uint32_t x) {
#if defined(PLATFORM_SDL) && (SDL_BYTEORDER == SDL_BIG_ENDIAN)
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
return SDL_Swap32(x);
#else
return x;
#endif
}

static inline int32_t FixEndian(int32_t x) {
#if defined(PLATFORM_SDL) && (SDL_BYTEORDER == SDL_BIG_ENDIAN)
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
uint32_t val = SDL_Swap32(*reinterpret_cast<uint32_t *>(&x));
return *reinterpret_cast<int32_t *>(&val);
#else
Expand Down
2 changes: 1 addition & 1 deletion Hurrican/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TARGET := linux_GL1
endif


DEFINES := -DPLATFORM_SDL -DENABLE_CONSOLE_COMMANDS -DUSE_MODPLUG
DEFINES := -DENABLE_CONSOLE_COMMANDS -DUSE_MODPLUG

#####################################
####### *** OPTIONAL DEFINES: *** #
Expand Down
3 changes: 1 addition & 2 deletions Hurrican/src/Mathematics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
#define _MATHEMATICS_HPP_
#include <stdint.h>
#include <cmath>
#ifdef PLATFORM_SDL

#include "SDLPort/SDL_port.hpp"
#endif

// --------------------------------------------------------------------------------------
// Defines
Expand Down
1 change: 1 addition & 0 deletions Hurrican/src/SDLPort/texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define _TEXTURE_H_

#include <string>
#include "DX8Texture.hpp"
#include "SDL_port.hpp"

struct image_t {
Expand Down

0 comments on commit 780878c

Please sign in to comment.