From a0dad416bb7cd7987bbea2c1ede69d12d1595b90 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Sat, 16 Feb 2002 02:08:31 +0000 Subject: [PATCH] allow older sdl versions --- arch/sdl/digi.c | 13 +++++++++++-- arch/sdl/event.c | 9 +++++++-- arch/sdl/gr.c | 18 ++++++++++++++---- configure.ac | 2 +- include/error.h | 12 ++++++++++-- include/oldsdl.h | 29 +++++++++++++++++++++++++++++ main/gamecntl.c | 8 ++++++++ main/inferno.c | 18 +++++++++++++++--- 8 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 include/oldsdl.h diff --git a/arch/sdl/digi.c b/arch/sdl/digi.c index cbd10114..c536ff43 100644 --- a/arch/sdl/digi.c +++ b/arch/sdl/digi.c @@ -1,12 +1,15 @@ /* * $Source: /cvs/cvsroot/d2x/arch/sdl/digi.c,v $ - * $Revision: 1.2 $ + * $Revision: 1.3 $ * $Author: bradleyb $ - * $Date: 2001-11-14 10:42:15 $ + * $Date: 2002-02-16 02:08:30 $ * * SDL digital audio support * * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/11/14 10:42:15 bradleyb + * implemented digi_set_volume + * * Revision 1.1 2001/10/25 08:25:34 bradleyb * Finished moving stuff to arch/blah. I know, it's ugly, but It'll be easier to sync with d1x. * @@ -29,6 +32,10 @@ #include #include +#ifndef SDL_VERSION_ATLEAST +#include "oldsdl.h" +#endif + #include "pstypes.h" #include "error.h" #include "mono.h" @@ -252,9 +259,11 @@ static void audio_mixcallback(void *userdata, Uint8 *stream, int len) /* Initialise audio devices. */ int digi_init() { +#if SDL_VERSION_ATLEAST(1,1,0) if (SDL_InitSubSystem(SDL_INIT_AUDIO)<0){ Error("SDL audio initialisation failed: %s.",SDL_GetError()); } +#endif //added on 980905 by adb to init sound kill system memset(SampleHandles, 255, sizeof(SampleHandles)); //end edit by adb diff --git a/arch/sdl/event.c b/arch/sdl/event.c index 244634d5..3cec4626 100644 --- a/arch/sdl/event.c +++ b/arch/sdl/event.c @@ -1,12 +1,15 @@ /* * $Source: /cvs/cvsroot/d2x/arch/sdl/event.c,v $ - * $Revision: 1.4 $ + * $Revision: 1.5 $ * $Author: bradleyb $ - * $Date: 2001-12-03 02:43:02 $ + * $Date: 2002-02-16 02:08:30 $ * * SDL Event related stuff * * $Log: not supported by cvs2svn $ + * Revision 1.4 2001/12/03 02:43:02 bradleyb + * lots of makefile fixes, and sdl joystick stuff + * * Revision 1.3 2001/11/14 10:43:10 bradleyb * remove cruft, fix formatting, begin joystick stuff * @@ -33,8 +36,10 @@ extern void key_handler(SDL_KeyboardEvent *event); extern void mouse_button_handler(SDL_MouseButtonEvent *mbe); extern void mouse_motion_handler(SDL_MouseMotionEvent *mme); +#ifdef SDL_JOYSTICK extern void joy_button_handler(SDL_JoyButtonEvent *jbe); extern void joy_axis_handler(SDL_JoyAxisEvent *jae); +#endif static int initialised=0; diff --git a/arch/sdl/gr.c b/arch/sdl/gr.c index 17e8bc73..e8bea16f 100644 --- a/arch/sdl/gr.c +++ b/arch/sdl/gr.c @@ -1,12 +1,15 @@ /* * $Source: /cvs/cvsroot/d2x/arch/sdl/gr.c,v $ - * $Revision: 1.3 $ + * $Revision: 1.4 $ * $Author: bradleyb $ - * $Date: 2002-02-14 11:29:31 $ + * $Date: 2002-02-16 02:08:31 $ * * SDL video functions. * * $Log: not supported by cvs2svn $ + * Revision 1.3 2002/02/14 11:29:31 bradleyb + * allow gr_init lowres + * * Revision 1.2 2001/10/31 07:41:54 bradleyb * Sync with d1x * @@ -31,6 +34,10 @@ #include #include #include + +#ifndef SDL_VERSION_ATLEAST +#include "oldsdl.h" +#endif #include "gr.h" #include "grdef.h" #include "palette.h" @@ -169,8 +176,11 @@ int gr_check_fullscreen(void){ int gr_toggle_fullscreen(void){ sdl_video_flags^=SDL_FULLSCREEN; -// grd_curscreen->sc_mode=0;//hack to get it to reset screen mode - SDL_WM_ToggleFullScreen(screen); +#if (SDL_COMPILEDVERSION < SDL_VERSIONNUM(1,0,5)) + grd_curscreen->sc_mode=0;//hack to get it to reset screen mode +#else + SDL_WM_ToggleFullScreen(screen); +#endif return (sdl_video_flags & SDL_FULLSCREEN)?1:0; } diff --git a/configure.ac b/configure.ac index 991346f4..d6e0a2d7 100644 --- a/configure.ac +++ b/configure.ac @@ -146,7 +146,7 @@ else CFLAGS="-pipe $CFLAGS" dnl Check for SDL - AM_PATH_SDL(1.1.7, + AM_PATH_SDL(1.0.1, :, AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix) ) diff --git a/include/error.h b/include/error.h index ee9dab78..be2c50bc 100644 --- a/include/error.h +++ b/include/error.h @@ -12,13 +12,16 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* * $Source: /cvs/cvsroot/d2x/include/error.h,v $ - * $Revision: 1.4 $ + * $Revision: 1.5 $ * $Author: bradleyb $ - * $Date: 2002-01-18 07:00:59 $ + * $Date: 2002-02-16 02:08:31 $ * * Header for error handling/printing/exiting code * * $Log: not supported by cvs2svn $ + * Revision 1.4 2002/01/18 07:00:59 bradleyb + * don't die on int3, unless -debug given + * * Revision 1.3 2001/11/14 10:51:04 bradleyb * kludge to ungrab mouse when we hit an int3 * @@ -110,13 +113,18 @@ void Int3(); #else #ifdef SDL_INPUT #include +#ifndef SDL_VERSION_ATLEAST +#include "oldsdl.h" +#endif #endif #include "args.h" static inline void _Int3() { if (FindArg("-debug")) { #ifdef SDL_INPUT +#if SDL_VERSION_ATLEAST(1,0,2) SDL_WM_GrabInput(SDL_GRAB_OFF); +#endif #endif asm("int $3"); } diff --git a/include/oldsdl.h b/include/oldsdl.h new file mode 100644 index 00000000..a4f22484 --- /dev/null +++ b/include/oldsdl.h @@ -0,0 +1,29 @@ +/* + * $Source: /cvs/cvsroot/d2x/include/oldsdl.h,v $ + * $Revision: 1.1 $ + * $Author: bradleyb $ + * $Date: 2002-02-16 02:08:31 $ + * + * Version-checking macros for SDL + * + */ + +#ifndef _OLDSDL_H +#define _OLDSDL_H + +/* This macro turns the version numbers into a numeric value: + (1,2,3) -> (1203) + This assumes that there will never be more than 100 patchlevels +*/ +#define SDL_VERSIONNUM(X, Y, Z) \ + (X)*1000 + (Y)*100 + (Z) + +/* This is the version number macro for the current SDL version */ +#define SDL_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +/* This macro will evaluate to true if compiled with SDL at least X.Y.Z */ +#define SDL_VERSION_ATLEAST(X, Y, Z) \ + (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +#endif diff --git a/main/gamecntl.c b/main/gamecntl.c index 973fefa6..3b4b887a 100644 --- a/main/gamecntl.c +++ b/main/gamecntl.c @@ -123,6 +123,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #endif +#ifndef SDL_VERSION_ATLEAST +#include "oldsdl.h" +#endif + extern void full_palette_save(void); extern void object_goto_prev_viewer(void); @@ -499,9 +503,11 @@ int do_game_pause() gr_update(); #ifdef SDL_INPUT +#if SDL_VERSION_ATLEAST(1,0,2) /* give control back to the WM */ if (FindArg("-grabmouse")) SDL_WM_GrabInput(SDL_GRAB_OFF); +#endif #endif while (Game_paused) @@ -564,9 +570,11 @@ int do_game_pause() } #ifdef SDL_INPUT +#if SDL_VERSION_ATLEAST(1,0,2) /* keep the mouse from wandering in SDL */ if (FindArg("-grabmouse")) SDL_WM_GrabInput(SDL_GRAB_ON); +#endif #endif if (VR_screen_flags & VRF_COMPATIBLE_MENUS) { diff --git a/main/inferno.c b/main/inferno.c index b24a1f8f..8d754aa9 100644 --- a/main/inferno.c +++ b/main/inferno.c @@ -13,13 +13,16 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. /* * $Source: /cvs/cvsroot/d2x/main/inferno.c,v $ - * $Revision: 1.26 $ + * $Revision: 1.27 $ * $Author: bradleyb $ - * $Date: 2002-02-15 12:24:53 $ + * $Date: 2002-02-16 02:08:31 $ * * FIXME: put description here * * $Log: not supported by cvs2svn $ + * Revision 1.26 2002/02/15 12:24:53 bradleyb + * automap resolution now selectable + * * Revision 1.25 2002/02/14 11:29:31 bradleyb * allow gr_init lowres * @@ -178,6 +181,10 @@ extern int Current_display_mode; //$$ there's got to be a better way than #include #endif +#ifndef SDL_VERSION_ATLEAST +#include "oldsdl.h" +#endif + #include "vers_id.h" void mem_init(void); @@ -302,8 +309,10 @@ void print_commandline_help() // printf( " -dynamicsockets %s\n","FIXME: Undocumented"); // printf( " -forcegfx %s\n","FIXME: Undocumented"); #ifdef SDL_INPUT +#if SDL_VERSION_ATLEAST(1,0,2) printf( " -grabmouse %s\n","Keeps the mouse from wandering out of the window"); #endif +#endif // printf( " -hw_3dacc %s\n","FIXME: Undocumented"); #ifndef RELEASE printf( " -invulnerability %s\n","Make yourself invulnerable"); @@ -1062,18 +1071,21 @@ int main(int argc,char **argv) #endif #ifdef SDL_INPUT +#if SDL_VERSION_ATLEAST(1,0,2) /* keep the mouse from wandering in SDL */ if (FindArg("-grabmouse")) SDL_WM_GrabInput(SDL_GRAB_ON); - +#endif #endif game(); #ifdef SDL_INPUT +#if SDL_VERSION_ATLEAST(1,0,2) /* give control back to the WM */ if (FindArg("-grabmouse")) SDL_WM_GrabInput(SDL_GRAB_OFF); +#endif #endif if ( Function_mode == FMODE_MENU ) -- 2.39.2