Skip to content

Commit

Permalink
dosbox_sdl2_20140712.diff by NY00123, without Android code
Browse files Browse the repository at this point in the history
This patch was obtained from:
http://www.vogons.org/viewtopic.php?f=32&t=34770&start=20#p367377

Android-only files and #ifdef __ANDROID__ code have both been
removed. This should minimize conflicts when updating to latest
SVN code or merging with em-dosbox.
  • Loading branch information
dreamlayers committed Jan 8, 2015
1 parent 2308491 commit bd974e8
Show file tree
Hide file tree
Showing 15 changed files with 1,251 additions and 109 deletions.
37 changes: 23 additions & 14 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
dnl
AC_DEFUN([AM_PATH_SDL],
[dnl
dnl Get the cflags and libraries from the sdl-config script
dnl Get the cflags and libraries from the sdl-config (or sdl2-config) script
dnl
AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
sdl_prefix="$withval", sdl_prefix="")
Expand All @@ -12,21 +12,30 @@ AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL
AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
, enable_sdltest=yes)
if test x$with_sdl2 = xyes ; then
SDL_CONFIG_EXE=sdl2-config
else
SDL_CONFIG_EXE=sdl-config
fi
if test x$sdl_exec_prefix != x ; then
sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
if test x${SDL_CONFIG+set} != xset ; then
SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
SDL_CONFIG=$sdl_exec_prefix/bin/$SDL_CONFIG_EXE
fi
fi
if test x$sdl_prefix != x ; then
sdl_args="$sdl_args --prefix=$sdl_prefix"
if test x${SDL_CONFIG+set} != xset ; then
SDL_CONFIG=$sdl_prefix/bin/sdl-config
SDL_CONFIG=$sdl_prefix/bin/$SDL_CONFIG_EXE
fi
fi
AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
min_sdl_version=ifelse([$1], ,0.11.0,$1)
AC_PATH_PROG(SDL_CONFIG, $SDL_CONFIG_EXE, no)
if test x$with_sdl2 = xyes ; then
min_sdl_version=2.0.0
else
min_sdl_version=1.2.0
fi
AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
no_sdl=""
if test "$SDL_CONFIG" = "no" ; then
Expand All @@ -48,7 +57,7 @@ AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run
LIBS="$LIBS $SDL_LIBS"
dnl
dnl Now check if the installed SDL is sufficiently new. (Also sanity
dnl checks the results of sdl-config to some extent
dnl checks the results of sdl-config, or sdl2-config, to some extent
dnl
rm -f conf.sdltest
AC_TRY_RUN([
Expand Down Expand Up @@ -98,11 +107,11 @@ int main (int argc, char *argv[])
}
else
{
printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
printf("\n*** '$SDL_CONFIG_EXE --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
printf("*** of SDL required is %d.%d.%d. If $SDL_CONFIG_EXE is correct, then it is\n", major, minor, micro);
printf("*** best to upgrade to the required version.\n");
printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
printf("*** to point to the correct copy of sdl-config, and remove the file\n");
printf("*** If $SDL_CONFIG_EXE was wrong, set the environment variable SDL_CONFIG\n");
printf("*** to point to the correct copy of $SDL_CONFIG_EXE, and remove the file\n");
printf("*** config.cache before re-running configure\n");
return 1;
}
Expand All @@ -119,10 +128,10 @@ int main (int argc, char *argv[])
else
AC_MSG_RESULT(no)
if test "$SDL_CONFIG" = "no" ; then
echo "*** The sdl-config script installed by SDL could not be found"
echo "*** The $SDL_CONFIG_EXE script installed by SDL could not be found"
echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the SDL_CONFIG environment variable to the"
echo "*** full path to sdl-config."
echo "*** full path to $SDL_CONFIG_EXE."
else
if test -f conf.sdltest ; then
:
Expand All @@ -146,14 +155,14 @@ int main (int argc, char *argv[])
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means SDL was incorrectly installed"
echo "*** or that you have moved SDL since it was installed. In the latter case, you"
echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
echo "*** may want to edit the $SDL_CONFIG_EXE script: $SDL_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
SDL_CFLAGS=""
SDL_LIBS=""
ifelse([$3], , :, [$3])
AC_MSG_ERROR([*** SDL version $min_sdl_version not found!])
fi
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS)
Expand Down
33 changes: 20 additions & 13 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,28 @@ if test x$host = xi386-pc-os2-emx ; then
fi

dnl Check for SDL
SDL_VERSION=1.2.0
AM_PATH_SDL($SDL_VERSION,
AC_ARG_WITH(sdl2, [ --with-sdl2 Build using SDL 2.0 instead of SDL 1.2],
with_sdl2=yes, )
AM_PATH_SDL(:,
:,
AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
:
)
LIBS="$LIBS $SDL_LIBS"
CPPFLAGS="$CPPFLAGS $SDL_CFLAGS"

dnl Check if SDL is 1.2.x (1.3 not supported)
AC_MSG_CHECKING([SDL version only being 1.2.X])
dnl Check if SDL is 1.2.x, 2.0.y
AC_MSG_CHECKING([SDL version only being 1.2.x or 2.0.x])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include "SDL.h"
void blah(){
#if SDL_MINOR_VERSION != 2
#error "Only SDL 1.2 supported"
#if !((SDL_MAJOR_VERSION == 1) && (SDL_MINOR_VERSION == 2)) && !((SDL_MAJOR_VERSION == 2) && (SDL_MINOR_VERSION == 0))
#error "Only SDL 1.2 and 2.0 supported"
#endif
;
}
])],AC_MSG_RESULT([yes]),[
AC_MSG_RESULT([no])
AC_MSG_ERROR([Only libSDL 1.2.X supported])])
AC_MSG_ERROR([Only libSDL 1.2.x or 2.0.x supported])])

dnl Checks for header files.

Expand Down Expand Up @@ -370,23 +371,29 @@ AH_TEMPLATE(C_MODEM,[Define to 1 to enable internal modem support, requires SDL_
AH_TEMPLATE(C_IPX,[Define to 1 to enable IPX over Internet networking, requires SDL_net])
AC_CHECK_HEADER(SDL_net.h,have_sdl_net_h=yes,)

if test x$with_sdl2 = "xyes" ; then
LIBSDL_HEADER="SDL2"
else
LIBSDL_HEADER="SDL"
fi

if test x$host = xi386-pc-os2-emx ; then
AC_MSG_CHECKING(for SDLNet_Init in SDL_net);
AC_MSG_CHECKING(for SDLNet_Init in ${LIBSDL_HEADER}_net);
LIBS_BACKUP=$LIBS;
LIBS="$LIBS -lSDL_Net";
LIBS="$LIBS -l${LIBSDL_HEADER}_Net";
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <SDL_Net.h>]],[[
SDLNet_Init ();
]])], [AC_MSG_RESULT(yes); have_sdl_net_lib=yes], AC_MSG_RESULT(no))
LIBS=$LIBS_BACKUP
else
AC_CHECK_LIB(SDL_net, SDLNet_Init, have_sdl_net_lib=yes, , )
AC_CHECK_LIB(${LIBSDL_HEADER}_net, SDLNet_Init, have_sdl_net_lib=yes, , )
fi
if test x$have_sdl_net_lib = xyes -a x$have_sdl_net_h = xyes ; then
LIBS="$LIBS -lSDL_net"
LIBS="$LIBS -l${LIBSDL_HEADER}_net"
AC_DEFINE(C_MODEM,1)
AC_DEFINE(C_IPX,1)
else
AC_MSG_WARN([Can't find SDL_net, internal modem and ipx disabled])
AC_MSG_WARN([Can't find ${LIBSDL_HEADER}_net, internal modem and ipx disabled])
fi

AH_TEMPLATE(C_X11_XKB,[define to 1 if you have XKBlib.h and X11 lib])
Expand Down
11 changes: 9 additions & 2 deletions src/dos/cdrom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
// SDL CDROM
// ******************************************************

#include "SDL_version.h"

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Expand All @@ -30,6 +32,9 @@
#include "support.h"
#include "cdrom.h"

// On all platforms, if SDL 2.0 is used then we don't support physical CD-ROMs.
#if !SDL_VERSION_ATLEAST(2,0,0)

CDROM_Interface_SDL::CDROM_Interface_SDL(void) {
driveID = 0;
oldLeadOut = 0;
Expand Down Expand Up @@ -143,6 +148,8 @@ bool CDROM_Interface_SDL::LoadUnloadMedia(bool unload) {
return success;
}

#endif /* !SDL_VERSION_ATLEAST(2,0,0) */

int CDROM_GetMountType(char* path, int forceCD) {
// 0 - physical CDROM
// 1 - Iso file
Expand All @@ -157,6 +164,7 @@ int CDROM_GetMountType(char* path, int forceCD) {
upcase(buffer);
#endif

#if !SDL_VERSION_ATLEAST(2,0,0)
int num = SDL_CDNumDrives();
// If cd drive is forced then check if its in range and return 0
if ((forceCD>=0) && (forceCD<num)) {
Expand All @@ -169,6 +177,7 @@ int CDROM_GetMountType(char* path, int forceCD) {
cdName = SDL_CDName(i);
if (strcmp(buffer,cdName)==0) return 0;
};
#endif

// Detect ISO
struct stat file_stat;
Expand Down Expand Up @@ -214,5 +223,3 @@ bool CDROM_Interface_Fake :: GetMediaTrayStatus(bool& mediaPresent, bool& mediaC
trayOpen = false;
return true;
}


8 changes: 8 additions & 0 deletions src/dos/cdrom.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
#define RAW_SECTOR_SIZE 2352
#define COOKED_SECTOR_SIZE 2048

#if !SDL_VERSION_ATLEAST(2,0,0)
enum { CDROM_USE_SDL, CDROM_USE_ASPI, CDROM_USE_IOCTL_DIO, CDROM_USE_IOCTL_DX, CDROM_USE_IOCTL_MCI };
#endif

typedef struct SMSF {
unsigned char min;
Expand Down Expand Up @@ -84,6 +86,7 @@ class CDROM_Interface
virtual void InitNewMedia (void) {};
};

#if !SDL_VERSION_ATLEAST(2,0,0)
class CDROM_Interface_SDL : public CDROM_Interface
{
public:
Expand Down Expand Up @@ -112,6 +115,7 @@ class CDROM_Interface_SDL : public CDROM_Interface
int driveID;
Uint32 oldLeadOut;
};
#endif // !SDL_VERSION_ATLEAST(2,0,0)

class CDROM_Interface_Fake : public CDROM_Interface
{
Expand Down Expand Up @@ -237,6 +241,8 @@ typedef std::vector<Track>::iterator track_it;
Bit8u subUnit;
};

#if !SDL_VERSION_ATLEAST(2,0,0)

#if defined (WIN32) /* Win 32 */

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
Expand Down Expand Up @@ -394,4 +400,6 @@ class CDROM_Interface_Ioctl : public CDROM_Interface_SDL

#endif /* LINUX */

#endif /* !SDL_VERSION_ATLEAST(2,0,0) */

#endif /* __CDROM_INTERFACE__ */
5 changes: 5 additions & 0 deletions src/dos/cdrom_aspi_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/


#include "SDL_version.h"
// On all platforms, if SDL 2.0 is used then we don't support physical CD-ROMs.
#if !SDL_VERSION_ATLEAST(2,0,0)

#if defined (WIN32)

#include <ctype.h>
Expand Down Expand Up @@ -762,3 +766,4 @@ bool CDROM_Interface_Aspi::ReadSectors(PhysPt buffer, bool raw, unsigned long se
};

#endif
#endif // SDL_VERSION_ATLEAST(2,0,0)
18 changes: 18 additions & 0 deletions src/dos/cdrom_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ using namespace std;
#define MAX_LINE_LENGTH 512
#define MAX_FILENAME_LENGTH 256

// With no CD-ROM support on SDL 2.0, we need these. ***Taken off SDL_cdrom.h***
#ifndef CD_FPS
#define CD_FPS 75
#endif
#ifndef MSF_TO_FRAMES
#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F))
#endif
#ifndef FRAMES_TO_MSF
#define FRAMES_TO_MSF(f, M,S,F) { \
int value = f; \
*(F) = value%CD_FPS; \
value /= CD_FPS; \
*(S) = value%60; \
value /= 60; \
*(M) = value; \
}
#endif

CDROM_Interface_Image::BinaryFile::BinaryFile(const char *filename, bool &error)
{
file = new ifstream(filename, ios::in | ios::binary);
Expand Down
5 changes: 5 additions & 0 deletions src/dos/cdrom_ioctl_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/


#include "SDL_version.h"
// On all platforms, if SDL 2.0 is used then we don't support physical CD-ROMs.
#if !SDL_VERSION_ATLEAST(2,0,0)

#include <string.h>
#include "cdrom.h"
#include "support.h"
Expand Down Expand Up @@ -95,3 +99,4 @@ bool CDROM_Interface_Ioctl::SetDevice(char* path, int forceCD)
}

#endif
#endif // SDL_VERSION_ATLEAST(2,0,0)
5 changes: 5 additions & 0 deletions src/dos/cdrom_ioctl_os2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/


#include "SDL_version.h"
// On all platforms, if SDL 2.0 is used then we don't support physical CD-ROMs.
#if !SDL_VERSION_ATLEAST(2,0,0)

#include <string.h>
#include "dosbox.h"
#include "cdrom.h"
Expand Down Expand Up @@ -150,3 +154,4 @@ bool CDROM_Interface_Ioctl::SetDevice(char* path, int forceCD) {
}

#endif
#endif // SDL_VERSION_ATLEAST(2,0,0)
5 changes: 5 additions & 0 deletions src/dos/cdrom_ioctl_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/


#include "SDL_version.h"
// On all platforms, if SDL 2.0 is used then we don't support physical CD-ROMs.
#if !SDL_VERSION_ATLEAST(2,0,0)

#if defined (WIN32)

// *****************************************************************
Expand Down Expand Up @@ -621,3 +625,4 @@ void CDROM_Interface_Ioctl::Close(void) {
}

#endif
#endif // SDL_VERSION_ATLEAST(2,0,0)
Loading

0 comments on commit bd974e8

Please sign in to comment.