From d16545266686816370ac331864fa6286b144fd5f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 26 Apr 2001 16:50:19 +0000 Subject: [PATCH] Changes since SDL 1.2.0 release --- acinclude.m4 | 3 +- configure.in | 67 ++++++- docs.html | 3 + include/SDL_audio.h | 2 +- include/SDL_byteorder.h | 3 +- include/SDL_version.h | 2 +- ltconfig | 66 +++++-- ltmain.sh | 18 ++ sdl.m4 | 5 + src/SDL_error.c | 6 + src/SDL_fatal.c | 27 ++- src/audio/SDL_audiomem.c | 3 +- src/audio/SDL_mixer.c | 2 +- src/audio/dma/SDL_dmaaudio.c | 3 + src/audio/dsp/SDL_dspaudio.c | 3 + src/cdrom/openbsd/SDL_syscdrom.c | 10 +- src/timer/SDL_timer.c | 286 ++++++++++++++++++++++++++++ src/timer/linux/SDL_systimer.c | 7 + src/video/Makefile.am | 2 +- src/video/SDL_RLEaccel.c | 19 +- src/video/SDL_blit_A.c | 269 ++++++++++++++++++++------ src/video/SDL_cursor.c | 4 +- src/video/SDL_memops.h | 17 ++ src/video/SDL_sysvideo.h | 3 + src/video/SDL_video.c | 3 + src/video/bwindow/SDL_BView.h | 4 + src/video/bwindow/SDL_BWin.h | 10 + src/video/bwindow/SDL_sysevents.cc | 7 +- src/video/dummy/Makefile.am | 15 ++ src/video/dummy/SDL_nullevents.c | 48 +++++ src/video/dummy/SDL_nullevents_c.h | 37 ++++ src/video/dummy/SDL_nullmouse.c | 40 ++++ src/video/dummy/SDL_nullmouse_c.h | 30 +++ src/video/dummy/SDL_nullvideo.c | 245 ++++++++++++++++++++++++ src/video/dummy/SDL_nullvideo.h | 46 +++++ src/video/svga/SDL_svgavideo.c | 4 + src/video/wincommon/SDL_sysevents.c | 4 +- src/video/windx5/SDL_dx5video.c | 2 + strip_fPIC.sh | 2 +- test/acinclude.m4 | 5 + 40 files changed, 1226 insertions(+), 106 deletions(-) create mode 100644 src/timer/SDL_timer.c create mode 100644 src/video/dummy/Makefile.am create mode 100644 src/video/dummy/SDL_nullevents.c create mode 100644 src/video/dummy/SDL_nullevents_c.h create mode 100644 src/video/dummy/SDL_nullmouse.c create mode 100644 src/video/dummy/SDL_nullmouse_c.h create mode 100644 src/video/dummy/SDL_nullvideo.c create mode 100644 src/video/dummy/SDL_nullvideo.h diff --git a/acinclude.m4 b/acinclude.m4 index 0670b2db9..d3233b992 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -434,7 +434,8 @@ ac_prog=ld if test "$ac_cv_prog_gcc" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by GCC]) - ac_prog=`($CC -print-prog-name=ld | tr -d '\r') 2>&5` + DELCR='tr -d \015' + ac_prog=`($CC -print-prog-name=ld | $DELCR) 2>&5` case "$ac_prog" in # Accept absolute paths. changequote(,)dnl diff --git a/configure.in b/configure.in index 850b927f0..c3d6fd4b8 100644 --- a/configure.in +++ b/configure.in @@ -14,9 +14,9 @@ dnl Set various version strings - taken gratefully from the GTk sources # SDL_MAJOR_VERSION=1 SDL_MINOR_VERSION=2 -SDL_MICRO_VERSION=0 -SDL_INTERFACE_AGE=0 -SDL_BINARY_AGE=0 +SDL_MICRO_VERSION=1 +SDL_INTERFACE_AGE=1 +SDL_BINARY_AGE=1 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION AC_SUBST(SDL_MAJOR_VERSION) @@ -251,6 +251,9 @@ CheckOSS() #ifdef __bsdi__ #include #endif + #ifdef __OpenBSD__ + #include + #endif #ifdef __USLC__ #include #endif @@ -680,6 +683,19 @@ CheckAAlib() fi } +dnl rcg04172001 Set up the Null video driver. +CheckDummyVideo() +{ + AC_ARG_ENABLE(video-dummy, +[ --enable-video-dummy use dummy video driver [default=no]], + , enable_video_dummy=no) + if test x$enable_video_dummy = xyes; then + CFLAGS="$CFLAGS -DENABLE_DUMMYVIDEO" + VIDEO_SUBDIRS="$VIDEO_SUBDIRS dummy" + VIDEO_DRIVERS="$VIDEO_DRIVERS dummy/libvideo_null.la" + fi +} + dnl Check to see if OpenGL support is desired AC_ARG_ENABLE(video-opengl, [ --enable-video-opengl include OpenGL context creation [default=yes]], @@ -1012,6 +1028,7 @@ CheckKSTAT() case "$target" in *-*-linux*) ARCH=linux + CheckDummyVideo CheckNASM CheckOSS CheckALSA @@ -1076,6 +1093,7 @@ case "$target" in ;; *-*-bsdi*) ARCH=bsdi + CheckDummyVideo CheckNASM CheckOSS CheckNAS @@ -1116,6 +1134,7 @@ case "$target" in ;; *-*-freebsd*) ARCH=freebsd + CheckDummyVideo CheckNASM CheckOSS CheckARTSC @@ -1167,6 +1186,7 @@ case "$target" in ;; *-*-netbsd*) ARCH=netbsd + CheckDummyVideo CheckNASM CheckOSS CheckARTSC @@ -1199,7 +1219,11 @@ case "$target" in COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h) COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c) COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h) - COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c) + if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then + COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c) + else + COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c) + fi COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h) COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c) COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h) @@ -1213,6 +1237,8 @@ case "$target" in ;; *-*-openbsd*) ARCH=openbsd + CFLAGS="$CFLAGS -Dunix" + CheckDummyVideo CheckNASM CheckOSS CheckARTSC @@ -1261,6 +1287,7 @@ case "$target" in ;; *-*-sysv5*) ARCH=sysv5 + CheckDummyVideo CheckNASM CheckOSS CheckARTSC @@ -1306,6 +1333,8 @@ case "$target" in ;; *-*-solaris*) ARCH=solaris + CFLAGS="$CFLAGS -D__ELF__" # Fix for nasm on Solaris x86 + CheckDummyVideo CheckNASM CheckARTSC CheckESD @@ -1350,6 +1379,7 @@ case "$target" in ;; *-*-irix*) ARCH=irix + CheckDummyVideo CheckNAS CheckX11 CheckAAlib @@ -1407,6 +1437,7 @@ case "$target" in ;; *-*-hpux*) ARCH=hpux + CheckDummyVideo CheckNAS CheckX11 CheckGGI @@ -1449,6 +1480,7 @@ case "$target" in ;; *-*-aix*) ARCH=aix + CheckDummyVideo CheckNAS CheckX11 CheckGGI @@ -1490,6 +1522,7 @@ case "$target" in ;; *-*-osf*) ARCH=osf + CheckDummyVideo CheckNAS CheckX11 CheckGGI @@ -1532,6 +1565,7 @@ case "$target" in ;; *-*-qnx*) ARCH=qnx + CheckDummyVideo CheckNAS CheckPHOTON CheckX11 @@ -1581,8 +1615,11 @@ case "$target" in ac_default_prefix=/usr/local/cross-tools/i386-mingw32msvc else # Look for the location of the tools and install there - ac_default_prefix=$BUILD_PREFIX + if [ "$BUILD_PREFIX" != "" ]; then + ac_default_prefix=$BUILD_PREFIX + fi fi + CheckDummyVideo CheckWIN32 CheckDIRECTX CheckNASM @@ -1623,11 +1660,22 @@ case "$target" in fi # The Win32 platform requires special setup SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main" - SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows" + case "$target" in + *-*-cygwin*) + CFLAGS="$CFLAGS -I/usr/include/mingw -DWIN32 -Uunix" + SDL_CFLAGS="$SDL_CFLAGS -I/usr/include/mingw -DWIN32 -Uunix" + LIBS="$LIBS -mno-cygwin" + SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows -mno-cygwin" + ;; + *-*-mingw32*) + SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows" + ;; + esac ;; *-*-beos*) ARCH=beos ac_default_prefix=/boot/develop/tools/gnupro + CheckDummyVideo CheckNASM CheckBWINDOW CheckBeGL @@ -1672,6 +1720,7 @@ case "$target" in # use it at present, but Apple is working on a X-to-9 compiler # for which this case would be handy. ARCH=macos + CheckDummyVideo CheckTOOLBOX CheckMacGL # Set up files for the main() stub @@ -1714,6 +1763,7 @@ case "$target" in # just the OS X kernel sans upper layers like Carbon. But # config.guess comes back with "darwin", so go with the flow. ARCH=macos + CheckDummyVideo CheckCARBON CheckMacGL CheckPTHREAD @@ -1790,6 +1840,10 @@ if test $ARCH = solaris; then SDL_RLD_FLAGS="-R\${exec_prefix}/lib" fi +if test $ARCH = openbsd; then + SDL_RLD_FLAGS="-Wl,-R\${exec_prefix}/lib -Wl,-R\${X11BASE}/lib" +fi + dnl Output the video drivers we use if test x$enable_video = xtrue; then if test "$VIDEO_SUBDIRS" = ""; then @@ -1873,6 +1927,7 @@ src/video/windib/Makefile src/video/windx5/Makefile src/video/bwindow/Makefile src/video/photon/Makefile +src/video/dummy/Makefile src/events/Makefile src/joystick/Makefile src/joystick/beos/Makefile diff --git a/docs.html b/docs.html index 5ba0a187d..c8d2520dd 100644 --- a/docs.html +++ b/docs.html @@ -16,6 +16,9 @@

Major changes since SDL 1.0.0:

    +
  • 1.2.1: Added support for building under Cygwin on Windows +
  • 1.2.1: Added a dummy video driver for benchmarking (thanks Ryan!) +
  • 1.2.1: Fixed fullscreen cursor offset bug on BeOS
  • 1.2.0: Added initial support for HP-UX (thanks Stephanie)
  • 1.2.0: Added initial support for BSDI (thanks Kurt)
  • 1.2.0: Fixed blitting 32-bit ARGB images to SDL_OPENGLBLIT screens diff --git a/include/SDL_audio.h b/include/SDL_audio.h index 1bdaf048c..45ce987a2 100644 --- a/include/SDL_audio.h +++ b/include/SDL_audio.h @@ -234,7 +234,7 @@ extern DECLSPEC int SDL_ConvertAudio(SDL_AudioCVT *cvt); * This is provided for convenience -- you can mix your own audio data. */ #define SDL_MIX_MAXVOLUME 128 -extern DECLSPEC void SDL_MixAudio(Uint8 *dst, Uint8 *src, Uint32 len, int volume); +extern DECLSPEC void SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume); /* * The lock manipulated by these functions protects the callback function. diff --git a/include/SDL_byteorder.h b/include/SDL_byteorder.h index fb6e48bf7..f70f60997 100644 --- a/include/SDL_byteorder.h +++ b/include/SDL_byteorder.h @@ -42,7 +42,8 @@ static char rcsid = #if defined(__i386__) || defined(WIN32) || \ (defined(__alpha__) || defined(__alpha)) || \ defined(__arm__) || \ - (defined(__mips__) && defined(__MIPSEL__)) + (defined(__mips__) && defined(__MIPSEL__)) || \ + defined(__LITTLE_ENDIAN__) #define SDL_BYTEORDER SDL_LIL_ENDIAN #else #define SDL_BYTEORDER SDL_BIG_ENDIAN diff --git a/include/SDL_version.h b/include/SDL_version.h index ce3ddcf14..26ff413a0 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -42,7 +42,7 @@ extern "C" { */ #define SDL_MAJOR_VERSION 1 #define SDL_MINOR_VERSION 2 -#define SDL_PATCHLEVEL 0 +#define SDL_PATCHLEVEL 1 typedef struct { Uint8 major; diff --git a/ltconfig b/ltconfig index 3d69db82e..65a07d6f8 100755 --- a/ltconfig +++ b/ltconfig @@ -1105,6 +1105,9 @@ cygwin* | mingw*) with_gnu_ld=no fi ;; +openbsd*) + with_gnu_ld=no + ;; esac @@ -1155,6 +1158,12 @@ EOF ;; cygwin* | mingw*) + # Special flag that tells Cygwin to use the native MSVC runtime + case "$host_os" in + cygwin*) + cygwin_use_msvcrt=true + ;; + esac # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' @@ -1165,13 +1174,40 @@ EOF # then regenerate the def file from the symbol export list, so that # the compiled dll only exports the symbol export list. # Be careful not to strip the DATA tag left by newer dlltools. - export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + if [ "$cygwin_use_msvcrt" = "true" ]; then + export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -U__CYGWIN__ -U__CYGWIN32__ -c $soname-ltdll.c)~ + $DLLTOOL --exclude-symbols _DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def $objdir/$soname-ltdll.$objext $libobjs $convenience~ + sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $objdir/$soname-def > $export_symbols' + else + export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ $DLLTOOL --exclude-symbols _DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def $objdir/$soname-ltdll.$objext $libobjs $convenience~ sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $objdir/$soname-def > $export_symbols' + fi # If DATA tags from a recent dlltool are present, honour them! - archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~ + if [ "$cygwin_use_msvcrt" = "true" ]; then + archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~ + _lt_hint=1; + cat $export_symbols | while read symbol; do + set dummy \$symbol; + case \$# in + 2) echo " \$2 @ \$_lt_hint ; " >> $objdir/$soname-def;; + *) echo " \$2 @ \$_lt_hint \$3 ; " >> $objdir/$soname-def;; + esac; + _lt_hint=`expr 1 + \$_lt_hint`; + done~ + test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -U__CYGWIN__ -U__CYGWIN32__ -c $soname-ltdll.c)~ + $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,_DllMain@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts -L/usr/lib/mingw -mno-cygwin~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols _DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,_DllMain@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts -L/usr/lib/mingw -mno-cygwin~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols _DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,_DllMain@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts -L/usr/lib/mingw -mno-cygwin~ + : strip_is_broken_with_dlls_on_win95B - strip $lib' + else + archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~ _lt_hint=1; cat $export_symbols | while read symbol; do set dummy \$symbol; @@ -1189,8 +1225,8 @@ EOF $DLLTOOL --as=$AS --dllname $soname --exclude-symbols _DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,_DllMain@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ : strip_is_broken_with_dlls_on_win95B - strip $lib' - - old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a' + fi + old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a' ;; netbsd*) @@ -1403,10 +1439,21 @@ else ;; openbsd*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' - hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + if [ "`/usr/bin/file /usr/lib/libc.so.* | grep ELF`" != "" ]; then + export_dynamic_flag_spec='${wl}-E' + fi + ;; + esac ;; os2*) @@ -1883,7 +1930,7 @@ cygwin* | mingw*) # See where the system libraries really are - /usr/lib won't cut it libuser32=`$CC --print-file-name=libuser32.a` win32libs=`expr $libuser32 : '\(.*\)/.*'` - sys_lib_search_path_spec="$sys_lib_search_path $win32libs" + sys_lib_search_path_spec="$sys_lib_search_path_spec $win32libs" fi lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= @@ -2030,13 +2077,10 @@ netbsd*) openbsd*) version_type=sunos - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - need_version=no - fi library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH + deplibs_check_method='pass_all' ;; os2*) diff --git a/ltmain.sh b/ltmain.sh index e573215b7..0e7a37acf 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -1079,7 +1079,18 @@ compiler." # These systems don't actually have c library (as such) continue ;; + *-*-openbsd*) + # Do not include libc due to us having libc/libc_r. + continue + ;; esac + elif test "$arg" = "-lc_r"; then + case "$host" in + *-*-openbsd*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac elif test "$arg" = "-lm"; then case "$host" in *-*-cygwin* | *-*-beos*) @@ -1091,6 +1102,10 @@ compiler." deplibs="$deplibs $arg" ;; + -?thread) + deplibs="$deplibs $arg" + ;; + -module) module=yes continue @@ -1799,6 +1814,9 @@ compiler." # rhapsody is a little odd... deplibs="$deplibs -framework System" ;; + *-*-openbsd*) + # do not include libc due to us having libc/libc_r. + ;; *) # Add libc to deplibs on all other systems. deplibs="$deplibs -lc" diff --git a/sdl.m4 b/sdl.m4 index 38d8b0f02..36fb04afb 100644 --- a/sdl.m4 +++ b/sdl.m4 @@ -140,6 +140,11 @@ int main (int argc, char *argv[]) AC_TRY_LINK([ #include #include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef main +#define main K_and_R_C_main ], [ return 0; ], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding SDL or finding the wrong" diff --git a/src/SDL_error.c b/src/SDL_error.c index 6b14071ab..908a05792 100644 --- a/src/SDL_error.c +++ b/src/SDL_error.c @@ -47,6 +47,10 @@ static SDL_error SDL_global_error; #define SDL_GetErrBuf() (&SDL_global_error) #endif /* DISABLE_THREADS */ +#ifdef __CYGWIN__ +#define DISABLE_STDIO +#endif + #define SDL_ERRBUFIZE 1024 /* Private functions */ @@ -120,6 +124,7 @@ void SDL_SetError (const char *fmt, ...) } va_end(ap); +#ifndef DISABLE_STDIO /* If we are in debug mode, print out an error message */ #ifdef DEBUG_ERROR fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError()); @@ -128,6 +133,7 @@ void SDL_SetError (const char *fmt, ...) fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError()); } #endif +#endif /* !DISABLE_STDIO */ } /* Print out an integer value to a UNICODE buffer */ diff --git a/src/SDL_fatal.c b/src/SDL_fatal.c index e1b180bcb..59a9dd6d4 100644 --- a/src/SDL_fatal.c +++ b/src/SDL_fatal.c @@ -51,46 +51,59 @@ void SDL_UninstallParachute(void) #include "SDL.h" #include "SDL_fatal.h" +#ifdef __CYGWIN__ +#define DISABLE_STDIO +#endif + /* This installs some signal handlers for the more common fatal signals, so that if the programmer is lazy, the app doesn't die so horribly if the program crashes. */ +static void print_msg(const char *text) +{ +#ifndef DISABLE_STDIO + fprintf(stderr, "%s", text); +#endif +} + static void SDL_Parachute(int sig) { signal(sig, SIG_DFL); - fprintf(stderr, "Fatal signal: "); + print_msg("Fatal signal: "); switch (sig) { case SIGSEGV: - fprintf(stderr, "Segmentation Fault"); + print_msg("Segmentation Fault"); break; #ifdef SIGBUS #if SIGBUS != SIGSEGV case SIGBUS: - fprintf(stderr, "Bus Error"); + print_msg("Bus Error"); break; #endif #endif /* SIGBUS */ #ifdef SIGFPE case SIGFPE: - fprintf(stderr, "Floating Point Exception"); + print_msg("Floating Point Exception"); break; #endif /* SIGFPE */ #ifdef SIGQUIT case SIGQUIT: - fprintf(stderr, "Keyboard Quit"); + print_msg("Keyboard Quit"); break; #endif /* SIGQUIT */ #ifdef SIGPIPE case SIGPIPE: - fprintf(stderr, "Broken Pipe"); + print_msg("Broken Pipe"); break; #endif /* SIGPIPE */ default: +#ifndef DISABLE_STDIO fprintf(stderr, "# %d", sig); +#endif break; } - fprintf(stderr, " (SDL Parachute Deployed)\n"); + print_msg(" (SDL Parachute Deployed)\n"); SDL_Quit(); exit(-sig); } diff --git a/src/audio/SDL_audiomem.c b/src/audio/SDL_audiomem.c index 5e696f911..4ca71694f 100644 --- a/src/audio/SDL_audiomem.c +++ b/src/audio/SDL_audiomem.c @@ -29,13 +29,12 @@ static char rcsid = (necessary because SDL audio emulates threads with fork() */ +#include #ifdef FORK_HACK #include #include #include #include -#else -#include #endif #include "SDL_audiomem.h" diff --git a/src/audio/SDL_mixer.c b/src/audio/SDL_mixer.c index 7f740dcd0..27f938427 100644 --- a/src/audio/SDL_mixer.c +++ b/src/audio/SDL_mixer.c @@ -96,7 +96,7 @@ static const Uint8 mix8[] = #define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME) #define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128) -void SDL_MixAudio (Uint8 *dst, Uint8 *src, Uint32 len, int volume) +void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume) { Uint16 format; diff --git a/src/audio/dma/SDL_dmaaudio.c b/src/audio/dma/SDL_dmaaudio.c index 9e1a83f57..d235de798 100644 --- a/src/audio/dma/SDL_dmaaudio.c +++ b/src/audio/dma/SDL_dmaaudio.c @@ -48,6 +48,9 @@ static char rcsid = #ifdef __FreeBSD__ #include #endif +#ifdef __OpenBSD__ +#include +#endif #ifdef __USLC__ #include #endif diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index 83b0b9bdb..5b7a39608 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -46,6 +46,9 @@ static char rcsid = #ifdef __FreeBSD__ #include #endif +#ifdef __OpenBSD__ +#include +#endif #ifdef __USLC__ #include #endif diff --git a/src/cdrom/openbsd/SDL_syscdrom.c b/src/cdrom/openbsd/SDL_syscdrom.c index 7920d0c3e..fca6f88da 100644 --- a/src/cdrom/openbsd/SDL_syscdrom.c +++ b/src/cdrom/openbsd/SDL_syscdrom.c @@ -36,6 +36,7 @@ static char rcsid = #include #include #include +#include #include #include "SDL_error.h" @@ -64,7 +65,8 @@ static void SDL_SYS_CDClose(SDL_CD *cdrom); /* Some ioctl() errno values which occur when the tray is empty */ #define ERRNO_TRAYEMPTY(errno) \ - ((errno == EIO) || (errno == ENOENT) || (errno == EINVAL)) + ((errno == EIO) || (errno == ENOENT) || (errno == EINVAL) || \ + (errno == ENODEV)) /* Check a drive to see if it is a CD-ROM */ static int CheckDrive(char *drive, struct stat *stbuf) @@ -96,6 +98,8 @@ static int CheckDrive(char *drive, struct stat *stbuf) } close(cdfd); } + else if (ERRNO_TRAYEMPTY(errno)) + is_cd = 1; } return(is_cd); } @@ -137,7 +141,11 @@ static void AddDrive(char *drive, struct stat *stbuf) int SDL_SYS_CDInit(void) { static char *checklist[] = { +#ifdef __OpenBSD__ + "?0 cd?a", "cdrom", NULL +#else "?0 cd?c", "?0 acd?c", "cdrom", NULL +#endif }; char *SDLcdrom; int i, j, exists; diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c new file mode 100644 index 000000000..978804d90 --- /dev/null +++ b/src/timer/SDL_timer.c @@ -0,0 +1,286 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id$"; +#endif + +#include +#include /* For the definition of NULL */ + +#include "SDL_error.h" +#include "SDL_timer.h" +#include "SDL_timer_c.h" +#include "SDL_mutex.h" +#include "SDL_systimer.h" + +/* #define DEBUG_TIMERS */ + +int SDL_timer_started = 0; +int SDL_timer_running = 0; + +/* Data to handle a single periodic alarm */ +Uint32 SDL_alarm_interval = 0; +SDL_TimerCallback SDL_alarm_callback; + +static SDL_bool list_changed = SDL_FALSE; + +/* Data used for a thread-based timer */ +static int SDL_timer_threaded = 0; + +struct _SDL_TimerID { + Uint32 interval; + SDL_NewTimerCallback cb; + void *param; + Uint32 last_alarm; + struct _SDL_TimerID *next; +}; + +static SDL_TimerID SDL_timers = NULL; +static Uint32 num_timers = 0; +static SDL_mutex *SDL_timer_mutex; + +/* Set whether or not the timer should use a thread. + This should not be called while the timer subsystem is running. +*/ +int SDL_SetTimerThreaded(int value) +{ + int retval; + + if ( SDL_timer_started ) { + SDL_SetError("Timer already initialized"); + retval = -1; + } else { + retval = 0; + SDL_timer_threaded = value; + } + return retval; +} + +int SDL_TimerInit(void) +{ + int retval; + + SDL_timer_running = 0; + SDL_SetTimer(0, NULL); + retval = 0; + if ( ! SDL_timer_threaded ) { + retval = SDL_SYS_TimerInit(); + } + if ( SDL_timer_threaded ) { + SDL_timer_mutex = SDL_CreateMutex(); + } + SDL_timer_started = 1; + return(retval); +} + +void SDL_TimerQuit(void) +{ + SDL_SetTimer(0, NULL); + if ( SDL_timer_threaded < 2 ) { + SDL_SYS_TimerQuit(); + } + if ( SDL_timer_threaded ) { + SDL_DestroyMutex(SDL_timer_mutex); + } + SDL_timer_started = 0; + SDL_timer_threaded = 0; +} + +void SDL_ThreadedTimerCheck(void) +{ + Uint32 now, ms; + SDL_TimerID t, prev, next; + int removed; + + now = SDL_GetTicks(); + + SDL_mutexP(SDL_timer_mutex); + for ( prev = NULL, t = SDL_timers; t; t = next ) { + removed = 0; + ms = t->interval - SDL_TIMESLICE; + next = t->next; + if ( (t->last_alarm < now) && ((now - t->last_alarm) > ms) ) { + if ( (now - t->last_alarm) < t->interval ) { + t->last_alarm += t->interval; + } else { + t->last_alarm = now; + } + list_changed = SDL_FALSE; +#ifdef DEBUG_TIMERS + printf("Executing timer %p (thread = %d)\n", + t, SDL_ThreadID()); +#endif + SDL_mutexV(SDL_timer_mutex); + ms = t->cb(t->interval, t->param); + SDL_mutexP(SDL_timer_mutex); + if ( list_changed ) { + /* Abort, list of timers has been modified */ + break; + } + if ( ms != t->interval ) { + if ( ms ) { + t->interval = ROUND_RESOLUTION(ms); + } else { /* Remove the timer from the linked list */ +#ifdef DEBUG_TIMERS + printf("SDL: Removing timer %p\n", t); +#endif + if ( prev ) { + prev->next = next; + } else { + SDL_timers = next; + } + free(t); + -- num_timers; + removed = 1; + } + } + } + /* Don't update prev if the timer has disappeared */ + if ( ! removed ) { + prev = t; + } + } + SDL_mutexV(SDL_timer_mutex); +} + +SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param) +{ + SDL_TimerID t; + if ( ! SDL_timer_mutex ) { + if ( SDL_timer_started ) { + SDL_SetError("This platform doesn't support multiple timers"); + } else { + SDL_SetError("You must call SDL_Init(SDL_INIT_TIMER) first"); + } + return NULL; + } + if ( ! SDL_timer_threaded ) { + SDL_SetError("Multiple timers require threaded events!"); + return NULL; + } + SDL_mutexP(SDL_timer_mutex); + t = (SDL_TimerID) malloc(sizeof(struct _SDL_TimerID)); + if ( t ) { + t->interval = ROUND_RESOLUTION(interval); + t->cb = callback; + t->param = param; + t->last_alarm = SDL_GetTicks(); + t->next = SDL_timers; + SDL_timers = t; + ++ num_timers; + list_changed = SDL_TRUE; + SDL_timer_running = 1; + } +#ifdef DEBUG_TIMERS + printf("SDL_AddTimer(%d) = %08x num_timers = %d\n", interval, (Uint32)t, num_timers); +#endif + SDL_mutexV(SDL_timer_mutex); + return t; +} + +SDL_bool SDL_RemoveTimer(SDL_TimerID id) +{ + SDL_TimerID t, prev = NULL; + SDL_bool removed; + + removed = SDL_FALSE; + SDL_mutexP(SDL_timer_mutex); + /* Look for id in the linked list of timers */ + for (t = SDL_timers; t; prev=t, t = t->next ) { + if ( t == id ) { + if(prev) { + prev->next = t->next; + } else { + SDL_timers = t->next; + } + free(t); + -- num_timers; + removed = SDL_TRUE; + list_changed = SDL_TRUE; + break; + } + } +#ifdef DEBUG_TIMERS + printf("SDL_RemoveTimer(%08x) = %d num_timers = %d thread = %d\n", (Uint32)id, removed, num_timers, SDL_ThreadID()); +#endif + SDL_mutexV(SDL_timer_mutex); + return removed; +} + +static void SDL_RemoveAllTimers(SDL_TimerID t) +{ + SDL_TimerID freeme; + + /* Changed to non-recursive implementation. + The recursive implementation is elegant, but subject to + stack overflow if there are lots and lots of timers. + */ + while ( t ) { + freeme = t; + t = t->next; + free(freeme); + } +} + +/* Old style callback functions are wrapped through this */ +static Uint32 callback_wrapper(Uint32 ms, void *param) +{ + SDL_TimerCallback func = (SDL_TimerCallback) param; + return (*func)(ms); +} + +int SDL_SetTimer(Uint32 ms, SDL_TimerCallback callback) +{ + int retval; + +#ifdef DEBUG_TIMERS + printf("SDL_SetTimer(%d)\n", ms); +#endif + retval = 0; + if ( SDL_timer_running ) { /* Stop any currently running timer */ + SDL_timer_running = 0; + if ( SDL_timer_threaded ) { + SDL_mutexP(SDL_timer_mutex); + SDL_RemoveAllTimers(SDL_timers); + SDL_timers = NULL; + SDL_mutexV(SDL_timer_mutex); + } else { + SDL_SYS_StopTimer(); + } + } + if ( ms ) { + if ( SDL_timer_threaded ) { + retval = (SDL_AddTimer(ms, callback_wrapper, + (void *)callback) != NULL); + } else { + SDL_timer_running = 1; + SDL_alarm_interval = ms; + SDL_alarm_callback = callback; + retval = SDL_SYS_StartTimer(); + } + } + return retval; +} diff --git a/src/timer/linux/SDL_systimer.c b/src/timer/linux/SDL_systimer.c index b32d53b7d..a57cc1219 100644 --- a/src/timer/linux/SDL_systimer.c +++ b/src/timer/linux/SDL_systimer.c @@ -36,6 +36,10 @@ static char rcsid = #include "SDL_timer.h" #include "SDL_timer_c.h" +#if _POSIX_THREAD_SYSCALL_SOFT +#include +#endif + #if defined(DISABLE_THREADS) || defined(FORK_HACK) #define USE_ITIMER #endif @@ -96,6 +100,9 @@ void SDL_Delay (Uint32 ms) do { errno = 0; +#if _POSIX_THREAD_SYSCALL_SOFT + pthread_yield_np(); +#endif #ifdef USE_NANOSLEEP tv.tv_sec = elapsed.tv_sec; tv.tv_nsec = elapsed.tv_nsec; diff --git a/src/video/Makefile.am b/src/video/Makefile.am index 819898037..0197c3d88 100644 --- a/src/video/Makefile.am +++ b/src/video/Makefile.am @@ -5,7 +5,7 @@ noinst_LTLIBRARIES = libvideo.la # Define which subdirectories need to be built SUBDIRS = @VIDEO_SUBDIRS@ -DIST_SUBDIRS = x11 dga fbcon svga ggi aalib \ +DIST_SUBDIRS = dummy x11 dga fbcon svga ggi aalib \ wincommon windib windx5 \ maccommon macdsp macrom bwindow photon cybergfx diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index ca1e1ae73..462fcc2f9 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -109,12 +109,21 @@ static char rcsid = #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif +#define PIXEL_COPY(to, from, len, bpp) \ +do { \ + if(bpp == 4) { \ + SDL_memcpy4(to, from, (unsigned)(len)); \ + } else { \ + SDL_memcpy(to, from, (unsigned)(len) * (bpp)); \ + } \ +} while(0) + /* * Various colorkey blit methods, for opaque and per-surface alpha */ #define OPAQUE_BLIT(to, from, length, bpp, alpha) \ - SDL_memcpy(to, from, (unsigned)(length * bpp)) + PIXEL_COPY(to, from, length, bpp) /* * For 32bpp pixels on the form 0x00rrggbb: @@ -657,9 +666,9 @@ static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *dst, if(crun > right - cofs) \ crun = right - cofs; \ if(crun > 0) \ - SDL_memcpy(dstbuf + cofs * sizeof(Ptype), \ + PIXEL_COPY(dstbuf + cofs * sizeof(Ptype), \ srcbuf + (cofs - ofs) * sizeof(Ptype), \ - (unsigned)crun * sizeof(Ptype)); \ + (unsigned)crun, sizeof(Ptype)); \ srcbuf += run * sizeof(Ptype); \ ofs += run; \ } else if(!ofs) \ @@ -816,8 +825,8 @@ int SDL_RLEAlphaBlit(SDL_Surface *src, SDL_Rect *srcrect, run = ((Ctype *)srcbuf)[1]; \ srcbuf += 2 * sizeof(Ctype); \ if(run) { \ - SDL_memcpy(dstbuf + ofs * sizeof(Ptype), srcbuf, \ - run * sizeof(Ptype)); \ + PIXEL_COPY(dstbuf + ofs * sizeof(Ptype), srcbuf, \ + run, sizeof(Ptype)); \ srcbuf += run * sizeof(Ptype); \ ofs += run; \ } else if(!ofs) \ diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index eec519c3d..8acbc6a0e 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -195,8 +195,8 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info) } } -/* fast RGB888->(A)RGB888 blending with surface alpha */ -static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info) +/* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ +static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info) { int width = info->d_width; int height = info->d_height; @@ -204,32 +204,58 @@ static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info) int srcskip = info->s_skip >> 2; Uint32 *dstp = (Uint32 *)info->d_pixels; int dstskip = info->d_skip >> 2; - SDL_PixelFormat *srcfmt = info->src; - unsigned alpha = srcfmt->alpha; while(height--) { DUFFS_LOOP4({ - Uint32 s; - Uint32 d; - Uint32 s1; - Uint32 d1; - s = *srcp; - d = *dstp; - s1 = s & 0xff00ff; - d1 = d & 0xff00ff; - d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; - s &= 0xff00; - d &= 0xff00; - d = (d + ((s - d) * alpha >> 8)) & 0xff00; - *dstp = d1 | d | 0xff000000; - ++srcp; - ++dstp; + Uint32 s = *srcp++; + Uint32 d = *dstp; + *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) + + (s & d & 0x00010101)) | 0xff000000; }, width); srcp += srcskip; dstp += dstskip; } } +/* fast RGB888->(A)RGB888 blending with surface alpha */ +static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info) +{ + unsigned alpha = info->src->alpha; + if(alpha == 128) { + BlitRGBtoRGBSurfaceAlpha128(info); + } else { + int width = info->d_width; + int height = info->d_height; + Uint32 *srcp = (Uint32 *)info->s_pixels; + int srcskip = info->s_skip >> 2; + Uint32 *dstp = (Uint32 *)info->d_pixels; + int dstskip = info->d_skip >> 2; + + while(height--) { + DUFFS_LOOP4({ + Uint32 s; + Uint32 d; + Uint32 s1; + Uint32 d1; + s = *srcp; + d = *dstp; + s1 = s & 0xff00ff; + d1 = d & 0xff00ff; + d1 = (d1 + ((s1 - d1) * alpha >> 8)) + & 0xff00ff; + s &= 0xff00; + d &= 0xff00; + d = (d + ((s - d) * alpha >> 8)) & 0xff00; + *dstp = d1 | d | 0xff000000; + ++srcp; + ++dstp; + }, width); + srcp += srcskip; + dstp += dstskip; + } + } +} + /* fast ARGB888->(A)RGB888 blending with pixel alpha */ static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info) { @@ -277,8 +303,18 @@ static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info) } } -/* fast RGB565->RGB565 blending with surface alpha */ -static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info) +/* 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel */ + +/* blend a single 16 bit pixel at 50% */ +#define BLEND16_50(d, s, mask) \ + ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff))) + +/* blend two 16 bit pixels at 50% */ +#define BLEND2x16_50(d, s, mask) \ + (((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \ + + (s & d & (~(mask | mask << 16)))) + +static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) { int width = info->d_width; int height = info->d_height; @@ -286,56 +322,163 @@ static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info) int srcskip = info->s_skip >> 1; Uint16 *dstp = (Uint16 *)info->d_pixels; int dstskip = info->d_skip >> 1; - unsigned alpha = info->src->alpha >> 3; /* downscale alpha to 5 bits */ while(height--) { - DUFFS_LOOP4({ - Uint32 s = *srcp++; - Uint32 d = *dstp; - /* - * shift out the middle component (green) to the high 16 - * bits, and process all three RGB components at the same - * time. - */ - s = (s | s << 16) & 0x07e0f81f; - d = (d | d << 16) & 0x07e0f81f; - d += (s - d) * alpha >> 5; - d &= 0x07e0f81f; - *dstp++ = d | d >> 16; - }, width); - srcp += srcskip; - dstp += dstskip; + if(((unsigned long)srcp ^ (unsigned long)dstp) & 2) { + /* + * Source and destination not aligned, pipeline it. + * This is mostly a win for big blits but no loss for + * small ones + */ + Uint32 prev_sw; + int w = width; + + /* handle odd destination */ + if((unsigned long)dstp & 2) { + Uint16 d = *dstp, s = *srcp; + *dstp = BLEND16_50(d, s, mask); + dstp++; + srcp++; + w--; + } + srcp++; /* srcp is now 32-bit aligned */ + + /* bootstrap pipeline with first halfword */ + prev_sw = ((Uint32 *)srcp)[-1]; + + while(w > 1) { + Uint32 sw, dw, s; + sw = *(Uint32 *)srcp; + dw = *(Uint32 *)dstp; + if(SDL_BYTEORDER == SDL_BIG_ENDIAN) + s = (prev_sw << 16) + (sw >> 16); + else + s = (prev_sw >> 16) + (sw << 16); + prev_sw = sw; + *(Uint32 *)dstp = BLEND2x16_50(dw, s, mask); + dstp += 2; + srcp += 2; + w -= 2; + } + + /* final pixel if any */ + if(w) { + Uint16 d = *dstp, s; + if(SDL_BYTEORDER == SDL_BIG_ENDIAN) + s = prev_sw; + else + s = prev_sw >> 16; + *dstp = BLEND16_50(d, s, mask); + srcp++; + dstp++; + } + srcp += srcskip - 1; + dstp += dstskip; + } else { + /* source and destination are aligned */ + int w = width; + + /* first odd pixel? */ + if((unsigned long)srcp & 2) { + Uint16 d = *dstp, s = *srcp; + *dstp = BLEND16_50(d, s, mask); + srcp++; + dstp++; + w--; + } + /* srcp and dstp are now 32-bit aligned */ + + while(w > 1) { + Uint32 sw = *(Uint32 *)srcp; + Uint32 dw = *(Uint32 *)dstp; + *(Uint32 *)dstp = BLEND2x16_50(dw, sw, mask); + srcp += 2; + dstp += 2; + w -= 2; + } + + /* last odd pixel? */ + if(w) { + Uint16 d = *dstp, s = *srcp; + *dstp = BLEND16_50(d, s, mask); + srcp++; + dstp++; + } + srcp += srcskip; + dstp += dstskip; + } + } +} + +/* fast RGB565->RGB565 blending with surface alpha */ +static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info) +{ + unsigned alpha = info->src->alpha; + if(alpha == 128) { + Blit16to16SurfaceAlpha128(info, 0xf7de); + } else { + int width = info->d_width; + int height = info->d_height; + Uint16 *srcp = (Uint16 *)info->s_pixels; + int srcskip = info->s_skip >> 1; + Uint16 *dstp = (Uint16 *)info->d_pixels; + int dstskip = info->d_skip >> 1; + alpha >>= 3; /* downscale alpha to 5 bits */ + + while(height--) { + DUFFS_LOOP4({ + Uint32 s = *srcp++; + Uint32 d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x07e0f81f; + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp++ = d | d >> 16; + }, width); + srcp += srcskip; + dstp += dstskip; + } } } /* fast RGB555->RGB555 blending with surface alpha */ static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info) { - int width = info->d_width; - int height = info->d_height; - Uint16 *srcp = (Uint16 *)info->s_pixels; - int srcskip = info->s_skip >> 1; - Uint16 *dstp = (Uint16 *)info->d_pixels; - int dstskip = info->d_skip >> 1; - unsigned alpha = info->src->alpha >> 3; /* downscale alpha to 5 bits */ - - while(height--) { - DUFFS_LOOP4({ - Uint32 s = *srcp++; - Uint32 d = *dstp; - /* - * shift out the middle component (green) to the high 16 - * bits, and process all three RGB components at the same - * time. - */ - s = (s | s << 16) & 0x03e07c1f; - d = (d | d << 16) & 0x03e07c1f; - d += (s - d) * alpha >> 5; - d &= 0x03e07c1f; - *dstp++ = d | d >> 16; - }, width); - srcp += srcskip; - dstp += dstskip; + unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ + if(alpha == 128) { + Blit16to16SurfaceAlpha128(info, 0xfbde); + } else { + int width = info->d_width; + int height = info->d_height; + Uint16 *srcp = (Uint16 *)info->s_pixels; + int srcskip = info->s_skip >> 1; + Uint16 *dstp = (Uint16 *)info->d_pixels; + int dstskip = info->d_skip >> 1; + alpha >>= 3; /* downscale alpha to 5 bits */ + + while(height--) { + DUFFS_LOOP4({ + Uint32 s = *srcp++; + Uint32 d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x03e07c1f; + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp++ = d | d >> 16; + }, width); + srcp += srcskip; + dstp += dstskip; + } } } diff --git a/src/video/SDL_cursor.c b/src/video/SDL_cursor.c index 9690967b4..d72f029c9 100644 --- a/src/video/SDL_cursor.c +++ b/src/video/SDL_cursor.c @@ -723,7 +723,9 @@ void SDL_EraseCursor(SDL_Surface *screen) SDL_Rect area; SDL_MouseRect(&area); - video->UpdateRects(this, 1, &area); + if ( video->UpdateRects ) { + video->UpdateRects(this, 1, &area); + } } } diff --git a/src/video/SDL_memops.h b/src/video/SDL_memops.h index 1eb5788d0..e129df4e3 100644 --- a/src/video/SDL_memops.h +++ b/src/video/SDL_memops.h @@ -53,6 +53,17 @@ do { \ : "memory" ); \ } while(0) +#define SDL_memcpy4(dst, src, len) \ +do { \ + int ecx, edi, esi; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; movsl" \ + : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ + : "0" ((unsigned)(len)), "1" (dst), "2" (src) \ + : "memory" ); \ +} while(0) + #define SDL_revcpy(dst, src, len) \ do { \ int u0, u1, u2; \ @@ -104,9 +115,15 @@ do { \ #ifndef SDL_memcpy #define SDL_memcpy(dst, src, len) memcpy(dst, src, len) #endif + +#ifndef SDL_memcpy4 +#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len) << 2) +#endif + #ifndef SDL_revcpy #define SDL_revcpy(dst, src, len) memmove(dst, src, len) #endif + #ifndef SDL_memset4 #define SDL_memset4(dst, val, len) \ do { \ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index be38496ee..ab621c01a 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -355,6 +355,9 @@ extern VideoBootStrap DIRECTX_bootstrap; #ifdef ENABLE_BWINDOW extern VideoBootStrap BWINDOW_bootstrap; #endif +#ifdef ENABLE_DUMMYVIDEO +extern VideoBootStrap DUMMY_bootstrap; +#endif /* MacOS X gets the proper defines from configure */ #if defined(macintosh) && !defined(MACOSX) #define ENABLE_TOOLBOX diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index c2c8f6ce2..610295924 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -83,6 +83,9 @@ static VideoBootStrap *bootstrap[] = { #endif #ifdef ENABLE_CYBERGRAPHICS &CGX_bootstrap, +#endif +#ifdef ENABLE_DUMMYVIDEO + &DUMMY_bootstrap, #endif NULL }; diff --git a/src/video/bwindow/SDL_BView.h b/src/video/bwindow/SDL_BView.h index fbd53703f..ab88cb1bc 100644 --- a/src/video/bwindow/SDL_BView.h +++ b/src/video/bwindow/SDL_BView.h @@ -50,6 +50,10 @@ class SDL_BView : public BView xoff = x; yoff = y; } + virtual void GetXYOffset(int &x, int &y) { + x = xoff; + y = yoff; + } /* The view changed size. If it means we're in fullscreen, we * draw a nice black box in the entire view to get black borders. */ diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h index 52170f18d..91f2f0bf9 100644 --- a/src/video/bwindow/SDL_BWin.h +++ b/src/video/bwindow/SDL_BWin.h @@ -156,6 +156,16 @@ class SDL_BWin : public BDirectWindow #endif SDL_View->SetXYOffset(x, y); } + virtual void GetXYOffset(int &x, int &y) { +#ifdef HAVE_OPENGL + if ( the_view == SDL_GLView ) { + x = 0; + y = 0; + return; + } +#endif + SDL_View->GetXYOffset(x, y); + } virtual bool BeginDraw(void) { return(Lock()); } diff --git a/src/video/bwindow/SDL_sysevents.cc b/src/video/bwindow/SDL_sysevents.cc index 436cb2bd1..ea2c6a91f 100644 --- a/src/video/bwindow/SDL_sysevents.cc +++ b/src/video/bwindow/SDL_sysevents.cc @@ -262,7 +262,12 @@ void BE_PumpEvents(_THIS) /* Check for mouse motion */ if ( point != last_point ) { - SDL_PrivateMouseMotion(0, 0, (int)point.x, (int)point.y); + int x, y; + + SDL_Win->GetXYOffset(x, y); + x = (int)point.x - x; + y = (int)point.y - y; + SDL_PrivateMouseMotion(0, 0, x, y); } last_point = point; diff --git a/src/video/dummy/Makefile.am b/src/video/dummy/Makefile.am new file mode 100644 index 000000000..b9138cc50 --- /dev/null +++ b/src/video/dummy/Makefile.am @@ -0,0 +1,15 @@ + +## Makefile.am for SDL using the null video driver + +noinst_LTLIBRARIES = libvideo_null.la +libvideo_null_la_SOURCES = $(NULL_SRCS) + +# The SDL null video driver sources +NULL_SRCS = \ + SDL_nullvideo.h \ + SDL_nullevents.c \ + SDL_nullevents_c.h \ + SDL_nullmouse.c \ + SDL_nullmouse_c.h \ + SDL_nullvideo.c + diff --git a/src/video/dummy/SDL_nullevents.c b/src/video/dummy/SDL_nullevents.c new file mode 100644 index 000000000..b3885b2bc --- /dev/null +++ b/src/video/dummy/SDL_nullevents.c @@ -0,0 +1,48 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id$"; +#endif + +/* Being a null driver, there's no event stream. We just define stubs for + most of the API. */ + +#include "SDL.h" +#include "SDL_sysevents.h" +#include "SDL_events_c.h" +#include "SDL_nullvideo.h" +#include "SDL_nullevents_c.h" + +void DUMMY_PumpEvents(_THIS) +{ + /* do nothing. */ +} + +void DUMMY_InitOSKeymap(_THIS) +{ + /* do nothing. */ +} + +/* end of SDL_nullevents.c ... */ + diff --git a/src/video/dummy/SDL_nullevents_c.h b/src/video/dummy/SDL_nullevents_c.h new file mode 100644 index 000000000..706466e41 --- /dev/null +++ b/src/video/dummy/SDL_nullevents_c.h @@ -0,0 +1,37 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id$"; +#endif + +#include "SDL_nullvideo.h" + +/* Variables and functions exported by SDL_sysevents.c to other parts + of the native video subsystem (SDL_sysvideo.c) +*/ +extern void DUMMY_InitOSKeymap(_THIS); +extern void DUMMY_PumpEvents(_THIS); + +/* end of SDL_nullevents_c.h ... */ + diff --git a/src/video/dummy/SDL_nullmouse.c b/src/video/dummy/SDL_nullmouse.c new file mode 100644 index 000000000..2c8778cd9 --- /dev/null +++ b/src/video/dummy/SDL_nullmouse.c @@ -0,0 +1,40 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id$"; +#endif + +#include + +#include "SDL_error.h" +#include "SDL_mouse.h" +#include "SDL_events_c.h" + +#include "SDL_nullmouse_c.h" + + +/* The implementation dependent data for the window manager cursor */ +struct WMcursor { + int unused; +}; diff --git a/src/video/dummy/SDL_nullmouse_c.h b/src/video/dummy/SDL_nullmouse_c.h new file mode 100644 index 000000000..f464c1179 --- /dev/null +++ b/src/video/dummy/SDL_nullmouse_c.h @@ -0,0 +1,30 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id$"; +#endif + +#include "SDL_nullvideo.h" + +/* Functions to be exported */ diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c new file mode 100644 index 000000000..3aab2dbae --- /dev/null +++ b/src/video/dummy/SDL_nullvideo.c @@ -0,0 +1,245 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id$"; +#endif + +/* Dummy SDL video driver implementation; this is just enough to make an + * SDL-based application THINK it's got a working video driver, for + * applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it, + * and also for use as a collection of stubs when porting SDL to a new + * platform for which you haven't yet written a valid video driver. + * + * This is also a great way to determine bottlenecks: if you think that SDL + * is a performance problem for a given platform, enable this driver, and + * then see if your application runs faster without video overhead. + * + * Initial work by Ryan C. Gordon (icculus@linuxgames.com). A good portion + * of this was cut-and-pasted from Stephane Peter's work in the AAlib + * SDL video driver. Renamed to "DUMMY" by Sam Lantinga. + */ + +#include +#include + +#include "SDL.h" +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "SDL_sysvideo.h" +#include "SDL_pixels_c.h" +#include "SDL_events_c.h" + +#include "SDL_nullvideo.h" +#include "SDL_nullevents_c.h" +#include "SDL_nullmouse_c.h" + +/* Initialization/Query functions */ +static int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat); +static SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); +static SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); +static int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); +static void DUMMY_VideoQuit(_THIS); + +/* Hardware surface functions */ +static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface); +static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface); +static int DUMMY_FlipHWSurface(_THIS, SDL_Surface *surface); +static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface); +static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface); + +/* etc. */ +static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects); + +/* DUMMY driver bootstrap functions */ + +static int DUMMY_Available(void) +{ + return 1; /* Always available ! */ +} + +static void DUMMY_DeleteDevice(SDL_VideoDevice *device) +{ + free(device->hidden); + free(device); +} + +static SDL_VideoDevice *DUMMY_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + if ( device ) { + memset(device, 0, (sizeof *device)); + device->hidden = (struct SDL_PrivateVideoData *) + malloc((sizeof *device->hidden)); + } + if ( (device == NULL) || (device->hidden == NULL) ) { + SDL_OutOfMemory(); + if ( device ) { + free(device); + } + return(0); + } + memset(device->hidden, 0, (sizeof *device->hidden)); + + /* Set the function pointers */ + device->VideoInit = DUMMY_VideoInit; + device->ListModes = DUMMY_ListModes; + device->SetVideoMode = DUMMY_SetVideoMode; + device->CreateYUVOverlay = NULL; + device->SetColors = DUMMY_SetColors; + device->UpdateRects = DUMMY_UpdateRects; + device->VideoQuit = DUMMY_VideoQuit; + device->AllocHWSurface = DUMMY_AllocHWSurface; + device->CheckHWBlit = NULL; + device->FillHWRect = NULL; + device->SetHWColorKey = NULL; + device->SetHWAlpha = NULL; + device->LockHWSurface = DUMMY_LockHWSurface; + device->UnlockHWSurface = DUMMY_UnlockHWSurface; + device->FlipHWSurface = NULL; + device->FreeHWSurface = DUMMY_FreeHWSurface; + device->SetCaption = NULL; + device->SetIcon = NULL; + device->IconifyWindow = NULL; + device->GrabInput = NULL; + device->GetWMInfo = NULL; + device->InitOSKeymap = DUMMY_InitOSKeymap; + device->PumpEvents = DUMMY_PumpEvents; + + device->free = DUMMY_DeleteDevice; + + return device; +} + +VideoBootStrap DUMMY_bootstrap = { + "dummy", "SDL dummy video driver", + DUMMY_Available, DUMMY_CreateDevice +}; + + +int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat) +{ + fprintf(stderr, "WARNING: You are using the SDL dummy video driver!\n"); + + /* Determine the screen depth (use default 8-bit depth) */ + /* we change this during the SDL_SetVideoMode implementation... */ + vformat->BitsPerPixel = 8; + vformat->BytesPerPixel = 1; + + /* We're done! */ + return(0); +} + +SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) +{ + return (SDL_Rect **) -1; +} + +SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, + int width, int height, int bpp, Uint32 flags) +{ + if ( this->hidden->buffer ) { + free( this->hidden->buffer ); + } + + this->hidden->buffer = malloc(width * height * (bpp / 8)); + if ( ! this->hidden->buffer ) { + SDL_SetError("Couldn't allocate buffer for requested mode"); + return(NULL); + } + +/* printf("Setting mode %dx%d\n", width, height); */ + + memset(this->hidden->buffer, 0, width * height * (bpp / 8)); + + /* Allocate the new pixel format for the screen */ + if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) { + free(this->hidden->buffer); + this->hidden->buffer = NULL; + SDL_SetError("Couldn't allocate new pixel format for requested mode"); + return(NULL); + } + + /* Set up the new mode framebuffer */ + current->flags = flags & SDL_FULLSCREEN; + this->hidden->w = current->w = width; + this->hidden->h = current->h = height; + current->pitch = current->w * (bpp / 8); + current->pixels = this->hidden->buffer; + + /* We're done */ + return(current); +} + +/* We don't actually allow hardware surfaces other than the main one */ +static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface) +{ + return(-1); +} +static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +/* We need to wait for vertical retrace on page flipped displays */ +static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface) +{ + return(0); +} + +static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +static int DUMMY_FlipHWSurface(_THIS, SDL_Surface *surface) +{ + return(0); +} + +static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects) +{ + /* do nothing. */ +} + +int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) +{ + /* do nothing of note. */ + return(1); +} + +/* Note: If we are terminated, this could be called in the middle of + another SDL video routine -- notably UpdateRects. +*/ +void DUMMY_VideoQuit(_THIS) +{ + if (this->screen->pixels != NULL) + { + free(this->screen->pixels); + this->screen->pixels = NULL; + } +} diff --git a/src/video/dummy/SDL_nullvideo.h b/src/video/dummy/SDL_nullvideo.h new file mode 100644 index 000000000..cde507c2d --- /dev/null +++ b/src/video/dummy/SDL_nullvideo.h @@ -0,0 +1,46 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id$"; +#endif + +#ifndef _SDL_nullvideo_h +#define _SDL_nullvideo_h + +#include "SDL_mouse.h" +#include "SDL_sysvideo.h" +#include "SDL_mutex.h" + +/* Hidden "this" pointer for the video functions */ +#define _THIS SDL_VideoDevice *this + + +/* Private display data */ + +struct SDL_PrivateVideoData { + int w, h; + void *buffer; +}; + +#endif /* _SDL_nullvideo_h */ diff --git a/src/video/svga/SDL_svgavideo.c b/src/video/svga/SDL_svgavideo.c index 6c973af3c..ed2953a50 100644 --- a/src/video/svga/SDL_svgavideo.c +++ b/src/video/svga/SDL_svgavideo.c @@ -370,6 +370,10 @@ SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface *current, /* Set up the new mode framebuffer */ current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE); + if ( bpp == 8 ) { + /* FIXME: What about DirectColor? */ + current->flags |= SDL_HWPALETTE; + } current->w = width; current->h = height; current->pitch = modeinfo->linewidth; diff --git a/src/video/wincommon/SDL_sysevents.c b/src/video/wincommon/SDL_sysevents.c index b18a122ee..0db07e03a 100644 --- a/src/video/wincommon/SDL_sysevents.c +++ b/src/video/wincommon/SDL_sysevents.c @@ -134,10 +134,10 @@ static void WIN_GetKeyboardState(void) if ( keyboard[VK_RMENU] & 0x80) { state |= KMOD_RALT; } - if ( keyboard[VK_NUMLOCK] & 0x80) { + if ( keyboard[VK_NUMLOCK] & 0x01) { state |= KMOD_NUM; } - if ( keyboard[VK_CAPITAL] & 0x80) { + if ( keyboard[VK_CAPITAL] & 0x01) { state |= KMOD_CAPS; } } diff --git a/src/video/windx5/SDL_dx5video.c b/src/video/windx5/SDL_dx5video.c index d3428d6dd..87a6f3ba9 100644 --- a/src/video/windx5/SDL_dx5video.c +++ b/src/video/windx5/SDL_dx5video.c @@ -1684,6 +1684,7 @@ static int DX5_AllocHWSurface(_THIS, SDL_Surface *surface) return(DX5_AllocDDSurface(this, surface, NULL, SDL_HWSURFACE)); } +#ifdef DDRAW_DEBUG void PrintSurface(char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags) { DDSURFACEDESC ddsd; @@ -1717,6 +1718,7 @@ void PrintSurface(char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags) ddsd.ddpfPixelFormat.dwBBitMask); #endif } +#endif /* DDRAW_DEBUG */ static int DX5_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) diff --git a/strip_fPIC.sh b/strip_fPIC.sh index 6edacd2d5..edd577646 100755 --- a/strip_fPIC.sh +++ b/strip_fPIC.sh @@ -3,7 +3,7 @@ # libtool assumes that the compiler can handle the -fPIC flag # This isn't always true (for example, nasm can't handle it) command="" -while [ $1 ]; do +while [ $# -gt 0 ]; do if [ "$1" != "-fPIC" ]; then if [ "$1" != "-DPIC" ]; then command="$command $1" diff --git a/test/acinclude.m4 b/test/acinclude.m4 index 38d8b0f02..36fb04afb 100644 --- a/test/acinclude.m4 +++ b/test/acinclude.m4 @@ -140,6 +140,11 @@ int main (int argc, char *argv[]) AC_TRY_LINK([ #include #include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef main +#define main K_and_R_C_main ], [ return 0; ], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding SDL or finding the wrong"