Skip to content

Commit 81b94d1

Browse files
committed
Remove dependency on SDL headers in libretro builds
I'd already removed the SDL static libraries from libretro builds for portability, but kept the headers to make it easier to port the codebase to libretro. Eventually it was time to stop using the SDL headers as a crutch.
1 parent b9e54fb commit 81b94d1

File tree

16 files changed

+97
-44
lines changed

16 files changed

+97
-44
lines changed

meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ if is_libretro
112112
libretro_defines = [
113113
'-DMKXPZ_VERSION="@0@"'.format(meson.project_version()),
114114
'-DMKXPZ_RETRO',
115-
'-DSHARED_FLUID',
116115
'-D_FILE_OFFSET_BITS=64',
117116
'-DMPG123_NO_LARGENAME',
118117
'-DGL_GLES_PROTOTYPES=0',
@@ -499,7 +498,6 @@ if is_libretro
499498

500499
libretro_deps = [
501500
subproject('libretro-common').get_variable('libretro_common'),
502-
subproject('sdl2-headers').get_variable('sdl2_headers'),
503501
cmake.subproject('boost_asio', options: boost_options).dependency('boost_asio'),
504502
cmake.subproject('boost_mp11', options: boost_options).dependency('boost_mp11'),
505503
cmake.subproject('boost_describe', options: boost_options).dependency('boost_describe'),

src/audio/fluid-fun.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#include "fluid-fun.h"
22

33
#include <string.h>
4-
#include <SDL_loadso.h>
5-
#include <SDL_platform.h>
4+
#ifndef MKXPZ_RETRO
5+
# include <SDL_loadso.h>
6+
# include <SDL_platform.h>
7+
#endif // MKXPZ_RETRO
68

79
#include "debugwriter.h"
810

@@ -14,18 +16,18 @@
1416
# define FLUID_LIB "libfluidsynth.3.dylib"
1517
#elif defined(__WIN32__)
1618
# define FLUID_LIB "fluidsynth.dll"
17-
#elif !defined(SHARED_FLUID)
19+
#elif !defined(MKXPZ_RETRO) && !defined(SHARED_FLUID)
1820
# error "platform not recognized"
1921
#endif
2022

2123
struct FluidFunctions fluid;
22-
#ifndef SHARED_FLUID
24+
#if !defined(MKXPZ_RETRO) && !defined(SHARED_FLUID)
2325
static void *so;
2426
#endif
2527

2628
void initFluidFunctions()
2729
{
28-
#ifdef SHARED_FLUID
30+
#if defined(MKXPZ_RETRO) || defined(SHARED_FLUID)
2931

3032
#define FLUID_FUN(name, type) \
3133
fluid.name = fluid_##name;
@@ -55,7 +57,7 @@ FLUID_FUNCS2
5557

5658
return;
5759

58-
#ifndef SHARED_FLUID
60+
#if !defined(MKXPZ_RETRO) && !defined(SHARED_FLUID)
5961
fail:
6062
Debug() << "Failed to load " FLUID_LIB ". Midi playback is disabled.";
6163

src/audio/fluid-fun.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#ifndef FLUIDFUN_H
22
#define FLUIDFUN_H
33

4-
#ifdef SHARED_FLUID
5-
# ifdef MKXPZ_RETRO
6-
# include <fluidlite.h>
7-
# else
8-
# include <fluidsynth.h>
9-
# endif // MKXPZ_RETRO
4+
#ifdef MKXPZ_RETRO
5+
# include <fluidlite.h>
6+
#elif defined(SHARED_FLUID)
7+
# include <fluidsynth.h>
108
#else
119
# define FLUIDSYNTH_VERSION_MAJOR 3
1210
#endif
@@ -31,7 +29,7 @@ typedef fluid_settings_t* (*NEWFLUIDSETTINGSPROC)(void);
3129
typedef fluid_synth_t* (*NEWFLUIDSYNTHPROC)(fluid_settings_t* settings);
3230
typedef void (*DELETEFLUIDSETTINGSPROC)(fluid_settings_t* settings);
3331

34-
#if (defined(SHARED_FLUID) && defined(MKXPZ_RETRO)) || FLUIDSYNTH_VERSION_MAJOR == 1
32+
#if defined(MKXPZ_RETRO) || FLUIDSYNTH_VERSION_MAJOR == 1
3533
typedef int (*DELETEFLUIDSYNTHPROC)(fluid_synth_t* synth);
3634
#else
3735
typedef void (*DELETEFLUIDSYNTHPROC)(fluid_synth_t* synth);

src/display/bitmap.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,8 +1455,10 @@ void Bitmap::stretchBlt(IntRect destRect,
14551455
}
14561456
}
14571457

1458+
#ifndef MKXPZ_RETRO // TODO
14581459
if (blitTemp)
14591460
SDL_FreeSurface(blitTemp);
1461+
#endif // MKXPZ_RETRO
14601462

14611463
p->addTaintedArea(destRect);
14621464
p->onModified();
@@ -1764,13 +1766,15 @@ void Bitmap::clear()
17641766
p->onModified();
17651767
}
17661768

1769+
#ifndef MKXPZ_RETRO
17671770
static uint32_t &getPixelAt(SDL_Surface *surf, SDL_PixelFormat *form, int x, int y)
17681771
{
17691772
size_t offset = x*form->BytesPerPixel + y*surf->pitch;
17701773
uint8_t *bytes = (uint8_t*) surf->pixels + offset;
17711774

17721775
return *((uint32_t*) bytes);
17731776
}
1777+
#endif // MKXPZ_RETRO
17741778

17751779
Color Bitmap::getPixel(int x, int y) const
17761780
{
@@ -2077,6 +2081,7 @@ static std::string fixupString(const char *str)
20772081
return s;
20782082
}
20792083

2084+
#ifndef MKXPZ_RETRO
20802085
static void applyShadow(SDL_Surface *&in, const SDL_PixelFormat &fm, const SDL_Color &c)
20812086
{
20822087
SDL_Surface *out = SDL_CreateRGBSurface
@@ -2163,6 +2168,7 @@ static void applyShadow(SDL_Surface *&in, const SDL_PixelFormat &fm, const SDL_C
21632168
SDL_FreeSurface(in);
21642169
in = out;
21652170
}
2171+
#endif // MKXPZ_RETRO
21662172

21672173
#ifdef MKXPZ_RETRO
21682174
IntRect Bitmap::textRect(const char *str)

src/display/gl/gl-meta.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@
2626
#include "gl-util.h"
2727
#include "vertex.h"
2828

29-
#include <SDL_surface.h>
29+
#ifdef MKXPZ_RETRO
30+
struct SDL_Surface
31+
{
32+
int w;
33+
int h;
34+
void *pixels;
35+
};
36+
#else
37+
# include <SDL_surface.h>
38+
#endif // MKXPZ_RETRO
3039

3140
namespace GLMeta
3241
{

src/display/gl/glstate.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#include "shader.h"
2828
#include "sharedstate.h"
2929

30-
#include <SDL_rect.h>
31-
3230
static void applyBool(GLenum state, bool mode) {
3331
mode ? gl.Enable(state) : gl.Disable(state);
3432
}

src/display/sprite.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
# define M_PI 3.14159265358979323846
4242
#endif
4343

44-
#include <SDL_rect.h>
45-
4644
#include "sigslot/signal.hpp"
4745

4846
struct SpritePrivate

src/display/tilemap.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
#include <algorithm>
4848
#include <vector>
4949

50-
#include <SDL_surface.h>
51-
5250
extern const StaticRect autotileRects[];
5351

5452
typedef std::vector<SVertex> SVVector;

src/etc/etc-internal.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@
2424

2525
#include "util.h"
2626

27-
#include <SDL_rect.h>
27+
#ifdef MKXPZ_RETRO
28+
struct SDL_Rect
29+
{
30+
int x;
31+
int y;
32+
int w;
33+
int h;
34+
};
35+
#else
36+
# include <SDL_rect.h>
37+
#endif // MKXPZ_RETRO
2838

2939
struct Vec2
3040
{

src/etc/etc.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@
2727
#include "serializable.h"
2828
#include "etc-internal.h"
2929

30+
#ifdef MKXPZ_RETRO
31+
struct SDL_Color
32+
{
33+
uint8_t r;
34+
uint8_t g;
35+
uint8_t b;
36+
uint8_t a;
37+
};
38+
#else
3039
struct SDL_Color;
40+
#endif // MKXPZ_RETRO
3141

3242
enum BlendType
3343
{

0 commit comments

Comments
 (0)