# HG changeset patch # User Ryan C. Gordon # Date 1126160174 0 # Node ID 609c060fd2a2e75447ad4bd406f52cc723198a07 # Parent a0d3514c04b2b48222d3eac237d8de98431c3027 The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails: To: SDL Developers From: =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= Date: Mon, 30 May 2005 23:29:04 +0200 Subject: [SDL] Mac OS X Video Drivers [patch] I've updated/added the Carbon and X11 video drivers to the Mac OS X port of SDL 1.2 (the CVS version), and made the Cocoa driver and runtime *optional*. The default is still Cocoa, and the "Quartz" driver. But you can now also use "toolbox" for Carbon, and "x11" for running with Apple's (or other) X11 server: export SDL_VIDEODRIVER=x11 export SDL_VIDEO_GL_DRIVER=/usr/X11R6/lib/libGL.dylib It also checks if the frameworks are available, by a: #include or #import (this should make it configure on plain Darwin as well?) Here are the new configure targets: --enable-video-cocoa use Cocoa/Quartz video driver default=yes --enable-video-carbon use Carbon/QuickDraw video driver default=yes --enable-video-x11 use X11 video driver default=no ./configure --enable-video-cocoa --enable-video-carbon --enable-video-x11 \ --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib The Carbon version is just an updated version of the old SDL driver for Mac OS 9, and could probably be improved... (but it does work, including the Carbon version of SDLmain) If you disable cocoa, you can run with -framework Carbon only, and the C version of SDL_main.c. And if you disable carbon too, you can still use the X11 version which doesn't require SDLmain. I updated the DrawSprocket version, but did not include it. (no blitters or VRAM GWorlds etc. available on OS X anyway) Besides for Mac OS 9, I don't think there's any use for it ? And note that any performance on Mac OS X equals OpenGL anyway... You can get "fair" software SDL results on captured CG displays, but for decent frame rates you need to be using GL for rendering. Finally, here is the patch itself: http://www.algonet.se/~afb/SDL-12CVS-macvideo.patch --anders PS. It says "video", but as usual it applies to mouse/keyboard too. ------ To: A list for developers using the SDL library From: =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= Date: Sun, 4 Sep 2005 10:02:15 +0200 Subject: [SDL] Updated Mac patch Updated the previous Mac patch to disable Carbon by default. Also "fixed" the SDL.spec again, so that it builds on Darwin. http://www.algonet.se/~afb/SDL-1.2.9-mac.patch Also applied fine to SDL12 CVS, when I tried it. diff -r a0d3514c04b2 -r 609c060fd2a2 SDL.spec.in --- a/SDL.spec.in Thu Aug 25 20:31:58 2005 +0000 +++ b/SDL.spec.in Thu Sep 08 06:16:14 2005 +0000 @@ -1,18 +1,16 @@ -%define name @PACKAGE@ -%define version @VERSION@ -%define release 1 - Summary: Simple DirectMedia Layer -Name: %{name} -Version: %{version} -Release: %{release} -Source0: %{name}-%{version}.tar.gz +Name: @PACKAGE@ +Version: @VERSION@ +Release: 1 +Source: http://www.libsdl.org/release/%{name}-%{version}.tar.gz URL: http://www.libsdl.org/ -Copyright: LGPL +License: LGPL Group: System Environment/Libraries -BuildRoot: /var/tmp/%{name}-buildroot +BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot Prefix: %{_prefix} +%ifos linux Provides: libSDL-1.1.so.0 +%endif %description This is the Simple DirectMedia Layer, a generic API that provides low @@ -22,7 +20,7 @@ %package devel Summary: Libraries, includes and more to develop SDL applications. Group: Development/Libraries -Requires: %{name} +Requires: %{name} = %{version} %description devel This is the Simple DirectMedia Layer, a generic API that provides low @@ -34,40 +32,62 @@ %prep -rm -rf ${RPM_BUILD_ROOT} - %setup -q %build +%ifos linux CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix} --disable-video-svga --disable-video-ggi --disable-video-aalib --disable-debug --enable-dlopen --enable-esd-shared --enable-arts-shared +%else +%configure --disable-debug --enable-dlopen +%endif make %install rm -rf $RPM_BUILD_ROOT +%ifos linux make install prefix=$RPM_BUILD_ROOT/%{prefix} ln -s libSDL-1.2.so.0 $RPM_BUILD_ROOT/%{prefix}/lib/libSDL-1.1.so.0 +%else +%makeinstall +%endif %clean rm -rf $RPM_BUILD_ROOT +%ifnos darwin +%define __defattr %defattr(-,root,root) +%define __soext so +%else +%define __defattr %defattr(-,root,wheel) +%define __soext dylib +%endif + %files -%defattr(-,root,root) +%{__defattr} %doc README-SDL.txt COPYING CREDITS BUGS -%{prefix}/lib/lib*.so.* +%ifnos darwin +%{_libdir}/lib*.%{__soext}.* +%else +%{_libdir}/lib*.*.%{__soext} +%endif %files devel %defattr(-,root,root) %doc README README-SDL.txt COPYING CREDITS BUGS WhatsNew docs.html %doc docs/index.html docs/html -%{prefix}/bin/*-config -%{prefix}/lib/lib*.a -%{prefix}/lib/lib*.la -%{prefix}/lib/lib*.so -%{prefix}/include/SDL/ -%{prefix}/man/man3/* -%{prefix}/share/aclocal/* +%{_bindir}/*-config +%{_libdir}/lib*.a +%{_libdir}/lib*.la +%{_libdir}/lib*.%{__soext} +%dir %{_includedir}/SDL +%{_includedir}/SDL/*.h +%{_mandir}/man3/* +%{_datadir}/aclocal/* %changelog +* Mon Jan 03 2004 Anders Bjorklund +- Added support for Darwin, updated spec file + * Wed Jan 19 2000 Sam Lantinga - Re-integrated spec file into SDL distribution - 'name' and 'version' come from configure diff -r a0d3514c04b2 -r 609c060fd2a2 configure.in --- a/configure.in Thu Aug 25 20:31:58 2005 +0000 +++ b/configure.in Thu Sep 08 06:16:14 2005 +0000 @@ -742,6 +742,28 @@ fi } + +dnl Check for X11 on Mac OS X / Darwin +CheckMacX11() +{ + AC_ARG_ENABLE(video-x11, +[ --enable-video-x11 use X11 video driver [default=no]], + , enable_video_x11=no) + if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then + AC_PATH_X + AC_PATH_XTRA + if test x$have_x = xyes; then + CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11 -DXTHREADS -I$srcdir/include -I$srcdir/src/video" + if test x$ac_cv_func_shmat != xyes; then + CFLAGS="$CFLAGS -DNO_SHARED_MEMORY" + fi + SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS -lX11 -lXext" + VIDEO_SUBDIRS="$VIDEO_SUBDIRS x11" + VIDEO_DRIVERS="$VIDEO_DRIVERS x11/libvideo_x11.la" + fi + fi +} + dnl Find the X11 DGA 2.0 include and library directories CheckDGA() { @@ -1128,7 +1150,9 @@ CFLAGS="$CFLAGS -DHAVE_OPENGL" case "$target" in *-*-darwin*) - SYSTEM_LIBS="$SYSTEM_LIBS -framework OpenGL -framework AGL" + SYSTEM_LIBS="$SYSTEM_LIBS -framework OpenGL" + # The following is probably not available in Darwin: + SYSTEM_LIBS="$SYSTEM_LIBS -framework AGL" esac fi } @@ -1635,15 +1659,34 @@ dnl Set up the Mac toolbox video driver for Mac OS 7-9 CheckTOOLBOX() { + CFLAGS="$CFLAGS -DENABLE_TOOLBOX -DENABLE_DRAWSPROCKET" VIDEO_SUBDIRS="$VIDEO_SUBDIRS maccommon" VIDEO_DRIVERS="$VIDEO_DRIVERS maccommon/libvideo_maccommon.la" VIDEO_SUBDIRS="$VIDEO_SUBDIRS macrom" VIDEO_DRIVERS="$VIDEO_DRIVERS macrom/libvideo_macrom.la" + VIDEO_SUBDIRS="$VIDEO_SUBDIRS macdsp" + VIDEO_DRIVERS="$VIDEO_DRIVERS macdsp/libvideo_macdsp.la" } -dnl Set up the Mac toolbox video driver for Mac OS X +dnl Set up the Carbon/QuickDraw video driver for Mac OS X (but not Darwin) CheckCARBON() { + AC_ARG_ENABLE(video-carbon, +[ --enable-video-carbon use Carbon/QuickDraw video driver [default=no]], + , enable_video_carbon=no) + if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then + AC_MSG_CHECKING(for Carbon framework) + have_carbon=no + if test x$have_carbon != xyes; then + AC_TRY_COMPILE([ + #include + ],[ + ],[ + have_carbon=yes + ]) + fi + AC_MSG_RESULT($have_carbon) + if test x$have_carbon = xyes; then # "MACOSX" is not an official definition, but it's commonly # accepted as a way to differentiate between what runs on X # and what runs on older Macs - while in theory "Carbon" defns @@ -1656,11 +1699,35 @@ VIDEO_DRIVERS="$VIDEO_DRIVERS maccommon/libvideo_maccommon.la" VIDEO_SUBDIRS="$VIDEO_SUBDIRS macrom" VIDEO_DRIVERS="$VIDEO_DRIVERS macrom/libvideo_macrom.la" + #VIDEO_SUBDIRS="$VIDEO_SUBDIRS macdsp" + #VIDEO_DRIVERS="$VIDEO_DRIVERS macdsp/libvideo_macdsp.la" + fi + fi } -dnl Set up the Mac toolbox video driver for Mac OS X -CheckQUARTZ() +dnl Set up the Cocoa/Quartz video driver for Mac OS X (but not Darwin) +CheckCOCOA() { + AC_ARG_ENABLE(video-cocoa, +[ --enable-video-cocoa use Cocoa/Quartz video driver [default=yes]], + , enable_video_cocoa=yes) + if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then + old_CFLAGS="$CFLAGS" + dnl work around that we don't have Objective-C support in autoconf + CFLAGS="$CFLAGS -x objective-c" + AC_MSG_CHECKING(for Cocoa framework) + have_cocoa=no + if test x$have_cocoa != xyes; then + AC_TRY_COMPILE([ + #import + ],[ + ],[ + have_cocoa=yes + ]) + fi + AC_MSG_RESULT($have_cocoa) + CFLAGS="$old_CFLAGS" + if test x$have_cocoa = xyes; then # "MACOSX" is not an official definition, but it's commonly # accepted as a way to differentiate between what runs on X # and what runs on older Macs - while in theory "Carbon" defns @@ -1672,6 +1739,8 @@ -DENABLE_QUARTZ -DMACOSX -DTARGET_API_${mac_autoconf_target_workaround}_CARBON=1 -I\$(top_srcdir)/src/video/quartz" VIDEO_SUBDIRS="$VIDEO_SUBDIRS quartz" VIDEO_DRIVERS="$VIDEO_DRIVERS quartz/libvideo_quartz.la" + fi + fi } dnl Check for the dlfcn.h interface for dynamically loading objects @@ -2581,13 +2650,15 @@ SDL_LIBS="-lSDLmain $SDL_LIBS" ;; *-*-darwin* ) - # Strictly speaking, we want "Mac OS X", not "Darwin", which is + # This could be either full "Mac OS X", or plain "Darwin" which is # just the OS X kernel sans upper layers like Carbon and Cocoa. - # But config.guess comes back with "darwin", so go with the flow. + # Next line is broken, and a few files below require Mac OS X (full) ARCH=macosx CheckDummyVideo CheckDiskAudio - CheckQUARTZ + CheckCOCOA + CheckCARBON + CheckMacX11 CheckMacGL CheckPTHREAD CheckSIGACTION @@ -2625,8 +2696,16 @@ fi # The MacOS X platform requires special setup. SDL_LIBS="-lSDLmain $SDL_LIBS" - # The Cocoa backend still needs Carbon, and the YUV code QuickTime - SYSTEM_LIBS="$SYSTEM_LIBS -framework Cocoa -framework Carbon -framework QuickTime" + if test x$enable_video_cocoa = xyes; then + SYSTEM_LIBS="$SYSTEM_LIBS -framework Cocoa" + fi + if test x$enable_video_carbon = xyes -o x$enable_video_cocoa = xyes; then + # The Cocoa backend still needs Carbon, and the YUV code QuickTime + SYSTEM_LIBS="$SYSTEM_LIBS -framework Carbon -framework QuickTime" + fi + #if test x$enable_video_carbon = xyes; then + # SYSTEM_LIBS="$SYSTEM_LIBS -framework DrawSprocket" + #fi ;; *-*-mint*) ARCH=mint @@ -2746,6 +2825,8 @@ AM_CONDITIONAL(USE_DIRECTX, test x$use_directx = xyes) AM_CONDITIONAL(USE_CLONE, test x$use_clone = xyes) AM_CONDITIONAL(HAVE_NASM, test x$use_nasm = xyes) +AM_CONDITIONAL(USE_COCOA, test x$enable_video_cocoa = xyes) +AM_CONDITIONAL(USE_CARBON, test x$enable_video_carbon = xyes) # Set conditional variables for shared and static library selection. # These are not used in any Makefile.am but in sdl-config.in. @@ -2773,7 +2854,13 @@ SHARED_SYSTEM_LIBS="$SYSTEM_LIBS" ;; macosx) - SHARED_SYSTEM_LIBS="-framework Cocoa" + SHARED_SYSTEM_LIBS="" + if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then + SHARED_SYSTEM_LIBS="$SHARED_SYSTEM_LIBS -framework Cocoa" + fi + if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then + SHARED_SYSTEM_LIBS="$SHARED_SYSTEM_LIBS -framework Carbon" + fi if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then SHARED_SYSTEM_LIBS="$SHARED_SYSTEM_LIBS -framework OpenGL" fi @@ -2874,6 +2961,7 @@ include/Makefile src/Makefile src/main/Makefile +src/main/macos/Makefile src/main/macosx/Makefile src/main/macosx/Info.plist src/audio/Makefile diff -r a0d3514c04b2 -r 609c060fd2a2 include/SDL_syswm.h --- a/include/SDL_syswm.h Thu Aug 25 20:31:58 2005 +0000 +++ b/include/SDL_syswm.h Thu Sep 08 06:16:14 2005 +0000 @@ -48,14 +48,26 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo; #else +#if defined(__APPLE__) && defined(__MACH__) +// conflicts with Quickdraw.h +#define Cursor X11Cursor +#endif + /* This is the structure for custom window manager events */ -#if (defined(unix) || defined(__unix__) || defined(_AIX) || defined(__OpenBSD__) || defined(__NetBSD__)) && \ +#if (defined(unix) || defined(__unix__) || defined(_AIX) || \ + defined(__OpenBSD__) || defined(__NetBSD__) || \ + (defined(__APPLE__) && defined(__MACH__))) && \ (!defined(DISABLE_X11) && !defined(__CYGWIN32__) && !defined(ENABLE_NANOX) && \ - !defined(__QNXNTO__)) + !defined(__QNXNTO__)) /* AIX is unix, of course, but the native compiler CSet doesn't define unix */ #include #include +#if defined(__APPLE__) && defined(__MACH__) +// matches the re-define above +#undef Cursor +#endif + /* These are the various supported subsystems under UNIX */ typedef enum { SDL_SYSWM_X11 diff -r a0d3514c04b2 -r 609c060fd2a2 src/audio/macrom/SDL_romaudio.c --- a/src/audio/macrom/SDL_romaudio.c Thu Aug 25 20:31:58 2005 +0000 +++ b/src/audio/macrom/SDL_romaudio.c Thu Sep 08 06:16:14 2005 +0000 @@ -25,7 +25,9 @@ "@(#) $Id$"; #endif -#if TARGET_API_MAC_CARBON +#if defined(__APPLE__) && defined(__MACH__) +# include +#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) # include #else # include /* SoundManager interface */ @@ -36,6 +38,12 @@ #include #include +#if !defined(NewSndCallBackUPP) && (UNIVERSAL_INTERFACES_VERSION < 0x0335) +#if !defined(NewSndCallBackProc) /* avoid circular redefinition... */ +#define NewSndCallBackUPP NewSndCallBackProc +#endif +#endif + #include "SDL_endian.h" #include "SDL_audio.h" #include "SDL_audio_c.h" @@ -229,7 +237,7 @@ /* initialize bufferCmd header */ memset (&header, 0, sizeof(header)); - callback = NewSndCallBackUPP (callBackProc); + callback = (SndCallBackUPP) NewSndCallBackUPP (callBackProc); sample_bits = spec->size / spec->samples / spec->channels * 8; #ifdef DEBUG_AUDIO diff -r a0d3514c04b2 -r 609c060fd2a2 src/joystick/macos/SDL_sysjoystick.c --- a/src/joystick/macos/SDL_sysjoystick.c Thu Aug 25 20:31:58 2005 +0000 +++ b/src/joystick/macos/SDL_sysjoystick.c Thu Sep 08 06:16:14 2005 +0000 @@ -72,7 +72,9 @@ { static ISpDeviceClass classes[4] = { kISpDeviceClass_Joystick, + #if kISpDeviceClass_Gamepad kISpDeviceClass_Gamepad, + #endif kISpDeviceClass_Wheel, 0 }; diff -r a0d3514c04b2 -r 609c060fd2a2 src/main/Makefile.am --- a/src/main/Makefile.am Thu Aug 25 20:31:58 2005 +0000 +++ b/src/main/Makefile.am Thu Sep 08 06:16:14 2005 +0000 @@ -19,8 +19,14 @@ MAINLIB_ARCH_SRCS = win32/SDL_win32_main.c else if TARGET_MACOSX +if USE_COCOA MAINLIB_ARCH_SRCS = macosx/SDLMain.m macosx/SDLMain.h else +if USE_CARBON +MAINLIB_ARCH_SRCS = macos/SDL_main.c +endif # USE_CARBON +endif # USE_COCOA +else if TARGET_QTOPIA MAINLIB_ARCH_SRCS = qtopia/SDL_qtopia_main.cc else diff -r a0d3514c04b2 -r 609c060fd2a2 src/main/macos/SDL_main.c --- a/src/main/macos/SDL_main.c Thu Aug 25 20:31:58 2005 +0000 +++ b/src/main/macos/SDL_main.c Thu Sep 08 06:16:14 2005 +0000 @@ -26,14 +26,16 @@ #endif /* This file takes care of command line argument parsing, and stdio redirection - in the MacOS environment. + in the MacOS environment. (stdio/stderr is *not* directed for Mach-O builds) */ #include #include #include #include -#if TARGET_API_MAC_CARBON +#if defined(__APPLE__) && defined(__MACH__) +#include +#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) #include #else #include @@ -50,9 +52,11 @@ #undef main #endif +#if !(defined(__APPLE__) && defined(__MACH__)) /* The standard output files */ #define STDOUT_FILE "stdout.txt" #define STDERR_FILE "stderr.txt" +#endif #if !defined(__MWERKS__) && !TARGET_API_MAC_CARBON /* In MPW, the qd global has been removed from the libraries */ @@ -79,6 +83,8 @@ return(false); } +#if !(defined(__APPLE__) && defined(__MACH__)) + /* Parse a command line buffer into arguments */ static int ParseCommandLine(char *cmdline, char **argv) { @@ -158,6 +164,8 @@ } } +#endif //!(defined(__APPLE__) && defined(__MACH__)) + static int getCurrentAppName (StrFileName name) { ProcessSerialNumber process; @@ -207,7 +215,7 @@ prefs_name[0] = app_name[0] + strlen (SUFFIX); /* Make the file spec for prefs file */ - if ( noErr != FSMakeFSSpec (volume_ref_number, directory_id, prefs_name, prefs_fsp) ) + if ( noErr != FSMakeFSSpec (volume_ref_number, directory_id, prefs_name, prefs_fsp) ) { if ( !create ) return 0; else { @@ -216,12 +224,12 @@ prefs_fsp->parID = directory_id; prefs_fsp->vRefNum = volume_ref_number; - FSpCreateResFile (prefs_fsp, '????', 'pref', 0); + FSpCreateResFile (prefs_fsp, 0x3f3f3f3f, 'pref', 0); // '????' parsed as trigraph if ( noErr != ResError () ) return 0; } - + } return 1; } @@ -233,7 +241,7 @@ if (prefs_handle != NULL) { int offset = 0; - int j = 0; +// int j = 0; HLock(prefs_handle); @@ -349,7 +357,9 @@ int main(int argc, char *argv[]) { +#if !(defined(__APPLE__) && defined(__MACH__)) #pragma unused(argc, argv) +#endif #define DEFAULT_ARGS "\p" /* pascal string for default args */ #define DEFAULT_VIDEO_DRIVER "\ptoolbox" /* pascal string for default video driver name */ @@ -360,11 +370,13 @@ PrefsRecord prefs = { DEFAULT_ARGS, DEFAULT_VIDEO_DRIVER, DEFAULT_OUTPUT_TO_FILE }; +#if !(defined(__APPLE__) && defined(__MACH__)) int nargs; char **args; char *commandLine; StrFileName appNameText; +#endif int videodriver = VIDEO_ID_TOOLBOX; int settingsChanged = 0; @@ -399,12 +411,18 @@ short itemHit; errorDialog = GetNewDialog (1001, nil, (WindowPtr)-1); + if (errorDialog == NULL) + return -1; DrawDialog (errorDialog); GetDialogItem (errorDialog, kErr_Text, &dummyType, &dummyHandle, &dummyRect); SetDialogItemText (dummyHandle, "\pError Initializing SDL"); +#if TARGET_API_MAC_CARBON + SetPort (GetDialogPort(errorDialog)); +#else SetPort (errorDialog); +#endif do { ModalDialog (nil, &itemHit); } while (itemHit != kErr_OK); @@ -442,23 +460,40 @@ Rect dummyRect; Handle dummyHandle; short itemHit; - + #if TARGET_API_MAC_CARBON + ControlRef control; + #endif + /* Assume that they will change settings, rather than do exhaustive check */ settingsChanged = 1; /* Create dialog and display it */ - commandDialog = GetNewDialog (1000, nil, (DialogPtr)-1); + commandDialog = GetNewDialog (1000, nil, (WindowPtr)-1); + #if TARGET_API_MAC_CARBON + SetPort ( GetDialogPort(commandDialog) ); + #else SetPort (commandDialog); - + #endif + /* Setup controls */ + #if TARGET_API_MAC_CARBON + GetDialogItemAsControl(commandDialog, kCL_File, &control); + SetControlValue (control, prefs.output_to_file); + #else GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */ SetControlValue ((ControlHandle)dummyHandle, prefs.output_to_file ); + #endif GetDialogItem (commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect); SetDialogItemText (dummyHandle, prefs.command_line); + #if TARGET_API_MAC_CARBON + GetDialogItemAsControl(commandDialog, kCL_Video, &control); + SetControlValue (control, videodriver); + #else GetDialogItem (commandDialog, kCL_Video, &dummyType, &dummyHandle, &dummyRect); SetControlValue ((ControlRef)dummyHandle, videodriver); + #endif SetDialogDefaultItem (commandDialog, kCL_OK); SetDialogCancelItem (commandDialog, kCL_Cancel); @@ -469,8 +504,13 @@ /* Toggle command-line output checkbox */ if ( itemHit == kCL_File ) { + #if TARGET_API_MAC_CARBON + GetDialogItemAsControl(commandDialog, kCL_File, &control); + SetControlValue (control, !GetControlValue(control)); + #else GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */ SetControlValue((ControlHandle)dummyHandle, !GetControlValue((ControlHandle)dummyHandle) ); + #endif } } while (itemHit != kCL_OK && itemHit != kCL_Cancel); @@ -479,11 +519,21 @@ GetDialogItem (commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect); /* MJS */ GetDialogItemText (dummyHandle, prefs.command_line); + #if TARGET_API_MAC_CARBON + GetDialogItemAsControl(commandDialog, kCL_File, &control); + prefs.output_to_file = GetControlValue(control); + #else GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */ prefs.output_to_file = GetControlValue ((ControlHandle)dummyHandle); + #endif + #if TARGET_API_MAC_CARBON + GetDialogItemAsControl(commandDialog, kCL_Video, &control); + videodriver = GetControlValue(control); + #else GetDialogItem (commandDialog, kCL_Video, &dummyType, &dummyHandle, &dummyRect); videodriver = GetControlValue ((ControlRef)dummyHandle); + #endif DisposeDialog (commandDialog); @@ -504,6 +554,7 @@ break; } +#if !(defined(__APPLE__) && defined(__MACH__)) /* Redirect standard I/O to files */ if ( prefs.output_to_file ) { freopen (STDOUT_FILE, "w", stdout); @@ -512,6 +563,7 @@ fclose (stdout); fclose (stderr); } +#endif if (settingsChanged) { /* Save the prefs, even if they might not have changed (but probably did) */ @@ -519,6 +571,8 @@ fprintf (stderr, "WARNING: Could not save preferences!\n"); } +#if !(defined(__APPLE__) && defined(__MACH__)) + appNameText[0] = 0; getCurrentAppName (appNameText); /* check for error here ? */ commandLine = (char*) malloc (appNameText[0] + prefs.command_line[0] + 2); @@ -553,6 +607,9 @@ /* Remove useless stdout.txt and stderr.txt */ cleanup_output (); +#else // defined(__APPLE__) && defined(__MACH__) + SDL_main(argc, argv); +#endif /* Exit cleanly, calling atexit() functions */ exit (0); diff -r a0d3514c04b2 -r 609c060fd2a2 src/video/SDL_video.c --- a/src/video/SDL_video.c Thu Aug 25 20:31:58 2005 +0000 +++ b/src/video/SDL_video.c Thu Sep 08 06:16:14 2005 +0000 @@ -45,6 +45,9 @@ /* Available video drivers */ static VideoBootStrap *bootstrap[] = { +#ifdef ENABLE_QUARTZ + &QZ_bootstrap, +#endif #ifdef ENABLE_X11 &X11_bootstrap, #endif @@ -93,9 +96,6 @@ #ifdef ENABLE_DRAWSPROCKET &DSp_bootstrap, #endif -#ifdef ENABLE_QUARTZ - &QZ_bootstrap, -#endif #ifdef ENABLE_CYBERGRAPHICS &CGX_bootstrap, #endif diff -r a0d3514c04b2 -r 609c060fd2a2 src/video/maccommon/SDL_lowvideo.h --- a/src/video/maccommon/SDL_lowvideo.h Thu Aug 25 20:31:58 2005 +0000 +++ b/src/video/maccommon/SDL_lowvideo.h Thu Sep 08 06:16:14 2005 +0000 @@ -28,7 +28,9 @@ #ifndef _SDL_lowvideo_h #define _SDL_lowvideo_h -#if TARGET_API_MAC_CARBON +#if defined(__APPLE__) && defined(__MACH__) +#include +#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) #include #else #include diff -r a0d3514c04b2 -r 609c060fd2a2 src/video/maccommon/SDL_macevents.c --- a/src/video/maccommon/SDL_macevents.c Thu Aug 25 20:31:58 2005 +0000 +++ b/src/video/maccommon/SDL_macevents.c Thu Sep 08 06:16:14 2005 +0000 @@ -27,7 +27,9 @@ #include -#if TARGET_API_MAC_CARBON +#if defined(__APPLE__) && defined(__MACH__) +#include +#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) #include #else #include @@ -734,10 +736,12 @@ #if !TARGET_API_MAC_CARBON /* Since we don't initialize QuickDraw, we need to get a pointer to qd */ QDGlobals *theQD = NULL; +#endif /* Exported to the macmain code */ void SDL_InitQuickDraw(struct QDGlobals *the_qd) { +#if !TARGET_API_MAC_CARBON theQD = the_qd; +#endif } -#endif diff -r a0d3514c04b2 -r 609c060fd2a2 src/video/maccommon/SDL_macmouse.c --- a/src/video/maccommon/SDL_macmouse.c Thu Aug 25 20:31:58 2005 +0000 +++ b/src/video/maccommon/SDL_macmouse.c Thu Sep 08 06:16:14 2005 +0000 @@ -27,7 +27,9 @@ #include #include -#if TARGET_API_MAC_CARBON +#if defined(__APPLE__) && defined(__MACH__) +#include +#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) #include #else #include diff -r a0d3514c04b2 -r 609c060fd2a2 src/video/maccommon/SDL_macwm.c --- a/src/video/maccommon/SDL_macwm.c Thu Aug 25 20:31:58 2005 +0000 +++ b/src/video/maccommon/SDL_macwm.c Thu Sep 08 06:16:14 2005 +0000 @@ -28,7 +28,9 @@ #include #include -#if TARGET_API_MAC_CARBON +#if defined(__APPLE__) && defined(__MACH__) +#include +#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) #include #else #include diff -r a0d3514c04b2 -r 609c060fd2a2 src/video/macdsp/Makefile.am --- a/src/video/macdsp/Makefile.am Thu Aug 25 20:31:58 2005 +0000 +++ b/src/video/macdsp/Makefile.am Thu Sep 08 06:16:14 2005 +0000 @@ -1,8 +1,8 @@ ## Makefile.am for SDL using the Mac DrawSprocket video driver -noinst_LTLIBRARIES = libvideo_dsp.la -libvideo_dsp_la_SOURCES = $(DSP_SRCS) +noinst_LTLIBRARIES = libvideo_macdsp.la +libvideo_macdsp_la_SOURCES = $(DSP_SRCS) # The SDL Mac DrawSprocket driver sources DSP_SRCS = \ diff -r a0d3514c04b2 -r 609c060fd2a2 src/video/macdsp/SDL_dspvideo.c --- a/src/video/macdsp/SDL_dspvideo.c Thu Aug 25 20:31:58 2005 +0000 +++ b/src/video/macdsp/SDL_dspvideo.c Thu Sep 08 06:16:14 2005 +0000 @@ -66,7 +66,7 @@ System requirements (* denotes optional): 1. DrawSprocket 1.7.3 - 2. *MacOS 9 or later for hardware accelerated blit / fill + 2. *MacOS 9 or later (but *not* Mac OS X) for hardware accelerated blit / fill 3. *May also require certain graphics hardware for (2). I trust that all Apple OEM hardware will work. Third party accelerators may work if they have QuickDraw acceleration in the drivers and the drivers have been updated for OS 9. The current @@ -130,14 +130,19 @@ #include #include -#if TARGET_API_MAC_CARBON +#if defined(__APPLE__) && defined(__MACH__) +#include +#include +#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) #include +#include #else #include #include #include #include #include +#include #endif #include "SDL_video.h" @@ -145,6 +150,7 @@ #include "SDL_error.h" #include "SDL_syswm.h" #include "SDL_sysvideo.h" +#include "SDL_pixels_c.h" #include "SDL_dspvideo.h" #include "SDL_macgl_c.h" #include "SDL_macwm_c.h" @@ -221,8 +227,12 @@ static int DSp_Available(void) { /* Check for DrawSprocket */ +#if ! TARGET_API_MAC_OSX /* This check is only meaningful if you weak-link DrawSprocketLib */ return ((Ptr)DSpStartup != (Ptr)kUnresolvedCFragSymbolAddress); +#else + return 1; // DrawSprocket.framework doesn't have it all, but it's there +#endif } static void DSp_DeleteDevice(SDL_VideoDevice *device) @@ -430,6 +440,7 @@ SetRect (&bounds, 0, 0, 320, 240); +#if useDistantHdwrMem && useLocalHdwrMem err = NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL, SDL_Display, useDistantHdwrMem | noNewDevice); if (err == noErr) { dsp_vram_available = SDL_TRUE; @@ -441,6 +452,7 @@ DisposeGWorld (offscreen); dsp_agp_available = SDL_TRUE; } +#endif } } @@ -508,8 +520,9 @@ static int DSp_VideoInit(_THIS, SDL_PixelFormat *vformat) { + NumVersion dsp_version; - NumVersion dsp_version = DSpGetVersion (); + dsp_version = DSpGetVersion (); if ( (dsp_version.majorRev == 1 && dsp_version.minorAndBugRev < 0x73) || (dsp_version.majorRev < 1) ) { @@ -615,16 +628,16 @@ /* Various screen update functions available */ static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); +#if ! TARGET_API_MAC_OSX + static volatile unsigned int retrace_count = 0; /* -dw- need volatile because it updates asychronously */ -#if ! TARGET_API_MAC_OSX Boolean DSp_VBLProc ( DSpContextReference context, void *ref_con ) { retrace_count++; return 1; /* Darrell, is this right? */ } -#endif static void DSp_SetHWError (OSStatus err, int is_agp) { @@ -650,6 +663,7 @@ sprintf(message, fmt, mem); SDL_SetError(message); } +#endif // TARGET_API_MAC_OSX /* put up a dialog to verify display change */ static int DSp_ConfirmSwitch () { @@ -671,7 +685,11 @@ if (dialog == NULL) return (0); - SetPort (dialog); +#if TARGET_API_CARBON + SetPort (GetDialogPort(dialog)); +#else + SetPort ((WindowPtr) dialog); +#endif SetDialogDefaultItem (dialog, bCancel); SetDialogCancelItem (dialog, bCancel); @@ -693,7 +711,8 @@ } while ( item != bCancel && item != bOK && err != noErr); - DisposeWindow (dialog); + + DisposeDialog (dialog); SetPort (savePort); SetEventMask(everyEvent - autoKeyMask); @@ -740,9 +759,11 @@ SDL_Surface *current, int width, int height, int bpp, Uint32 flags) { - DisplayIDType display_id; +#if !TARGET_API_MAC_OSX + DisplayIDType display_id; + Fixed freq; +#endif DSpContextAttributes attrib; - Fixed freq; OSStatus err; UInt32 rmask = 0, gmask = 0, bmask = 0; @@ -924,7 +945,11 @@ /* Set window color to black to avoid white flash*/ GetPort (&save_port); +#if TARGET_API_MAC_CARBON + SetPort (GetWindowPort(SDL_Window)); +#else SetPort (SDL_Window); +#endif RGBForeColor (&rgb); PaintRect (&rect); SetPort (save_port); @@ -1031,6 +1056,7 @@ SetRect (&bounds, 0, 0, width, height); + #if useDistantHdwrMem && useLocalHdwrMem if (dsp_vram_available) { /* try VRAM */ err = NewGWorld (port, depth, &bounds, 0 , SDL_Display, useDistantHdwrMem | noNewDevice ); @@ -1049,6 +1075,7 @@ else return (0); } +#endif return (-1); } @@ -1210,8 +1237,10 @@ CGrafPtr dsp_front_buffer, save_port; Rect rect; + #if ! TARGET_API_MAC_OSX unsigned int old_count; - + #endif + /* pseudo page flipping for VRAM back buffer*/ DSpContext_GetFrontBuffer (dsp_context, &dsp_front_buffer); SetRect (&rect, 0, 0, surface->w-1, surface->h-1); diff -r a0d3514c04b2 -r 609c060fd2a2 src/video/macrom/SDL_romvideo.c --- a/src/video/macrom/SDL_romvideo.c Thu Aug 25 20:31:58 2005 +0000 +++ b/src/video/macrom/SDL_romvideo.c Thu Sep 08 06:16:14 2005 +0000 @@ -28,13 +28,18 @@ #include #include -#if TARGET_API_MAC_CARBON +#if defined(__APPLE__) && defined(__MACH__) +#include +#if USE_QUICKTIME +#include +#endif +#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) #include /* The fullscreen code requires the QuickTime framework, and the window is still at the back on MacOS X, which is where this code is needed. */ #if USE_QUICKTIME -#include +#include #endif #else #include