Commit 1d1a4b19 authored by Ryan C. Gordon's avatar Ryan C. Gordon

The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:


To: SDL Developers <sdl@libsdl.org>
From: =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb@algonet.se>
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 <Carbon/Carbon.h> or #import <Cocoa/Cocoa.h>
(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 <sdl@libsdl.org>
From: =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb@algonet.se>
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.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401136
parent c705e88b
%define name @PACKAGE@
%define version @VERSION@
%define release 1
Summary: Simple DirectMedia Layer Summary: Simple DirectMedia Layer
Name: %{name} Name: @PACKAGE@
Version: %{version} Version: @VERSION@
Release: %{release} Release: 1
Source0: %{name}-%{version}.tar.gz Source: http://www.libsdl.org/release/%{name}-%{version}.tar.gz
URL: http://www.libsdl.org/ URL: http://www.libsdl.org/
Copyright: LGPL License: LGPL
Group: System Environment/Libraries Group: System Environment/Libraries
BuildRoot: /var/tmp/%{name}-buildroot BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
Prefix: %{_prefix} Prefix: %{_prefix}
%ifos linux
Provides: libSDL-1.1.so.0 Provides: libSDL-1.1.so.0
%endif
%description %description
This is the Simple DirectMedia Layer, a generic API that provides low This is the Simple DirectMedia Layer, a generic API that provides low
...@@ -22,7 +20,7 @@ multiple platforms. ...@@ -22,7 +20,7 @@ multiple platforms.
%package devel %package devel
Summary: Libraries, includes and more to develop SDL applications. Summary: Libraries, includes and more to develop SDL applications.
Group: Development/Libraries Group: Development/Libraries
Requires: %{name} Requires: %{name} = %{version}
%description devel %description devel
This is the Simple DirectMedia Layer, a generic API that provides low This is the Simple DirectMedia Layer, a generic API that provides low
...@@ -34,40 +32,62 @@ to develop SDL applications. ...@@ -34,40 +32,62 @@ to develop SDL applications.
%prep %prep
rm -rf ${RPM_BUILD_ROOT}
%setup -q %setup -q
%build %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 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 make
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
%ifos linux
make install prefix=$RPM_BUILD_ROOT/%{prefix} make install prefix=$RPM_BUILD_ROOT/%{prefix}
ln -s libSDL-1.2.so.0 $RPM_BUILD_ROOT/%{prefix}/lib/libSDL-1.1.so.0 ln -s libSDL-1.2.so.0 $RPM_BUILD_ROOT/%{prefix}/lib/libSDL-1.1.so.0
%else
%makeinstall
%endif
%clean %clean
rm -rf $RPM_BUILD_ROOT 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 %files
%defattr(-,root,root) %{__defattr}
%doc README-SDL.txt COPYING CREDITS BUGS %doc README-SDL.txt COPYING CREDITS BUGS
%{prefix}/lib/lib*.so.* %ifnos darwin
%{_libdir}/lib*.%{__soext}.*
%else
%{_libdir}/lib*.*.%{__soext}
%endif
%files devel %files devel
%defattr(-,root,root) %defattr(-,root,root)
%doc README README-SDL.txt COPYING CREDITS BUGS WhatsNew docs.html %doc README README-SDL.txt COPYING CREDITS BUGS WhatsNew docs.html
%doc docs/index.html docs/html %doc docs/index.html docs/html
%{prefix}/bin/*-config %{_bindir}/*-config
%{prefix}/lib/lib*.a %{_libdir}/lib*.a
%{prefix}/lib/lib*.la %{_libdir}/lib*.la
%{prefix}/lib/lib*.so %{_libdir}/lib*.%{__soext}
%{prefix}/include/SDL/ %dir %{_includedir}/SDL
%{prefix}/man/man3/* %{_includedir}/SDL/*.h
%{prefix}/share/aclocal/* %{_mandir}/man3/*
%{_datadir}/aclocal/*
%changelog %changelog
* Mon Jan 03 2004 Anders Bjorklund <afb@algonet.se>
- Added support for Darwin, updated spec file
* Wed Jan 19 2000 Sam Lantinga <slouken@libsdl.org> * Wed Jan 19 2000 Sam Lantinga <slouken@libsdl.org>
- Re-integrated spec file into SDL distribution - Re-integrated spec file into SDL distribution
- 'name' and 'version' come from configure - 'name' and 'version' come from configure
......
...@@ -742,6 +742,28 @@ CheckX11() ...@@ -742,6 +742,28 @@ CheckX11()
fi 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 dnl Find the X11 DGA 2.0 include and library directories
CheckDGA() CheckDGA()
{ {
...@@ -1128,7 +1150,9 @@ CheckMacGL() ...@@ -1128,7 +1150,9 @@ CheckMacGL()
CFLAGS="$CFLAGS -DHAVE_OPENGL" CFLAGS="$CFLAGS -DHAVE_OPENGL"
case "$target" in case "$target" in
*-*-darwin*) *-*-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 esac
fi fi
} }
...@@ -1635,15 +1659,34 @@ CheckPicoGUI() ...@@ -1635,15 +1659,34 @@ CheckPicoGUI()
dnl Set up the Mac toolbox video driver for Mac OS 7-9 dnl Set up the Mac toolbox video driver for Mac OS 7-9
CheckTOOLBOX() CheckTOOLBOX()
{ {
CFLAGS="$CFLAGS -DENABLE_TOOLBOX -DENABLE_DRAWSPROCKET"
VIDEO_SUBDIRS="$VIDEO_SUBDIRS maccommon" VIDEO_SUBDIRS="$VIDEO_SUBDIRS maccommon"
VIDEO_DRIVERS="$VIDEO_DRIVERS maccommon/libvideo_maccommon.la" VIDEO_DRIVERS="$VIDEO_DRIVERS maccommon/libvideo_maccommon.la"
VIDEO_SUBDIRS="$VIDEO_SUBDIRS macrom" VIDEO_SUBDIRS="$VIDEO_SUBDIRS macrom"
VIDEO_DRIVERS="$VIDEO_DRIVERS macrom/libvideo_macrom.la" 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() 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 <Carbon/Carbon.h>
],[
],[
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 # "MACOSX" is not an official definition, but it's commonly
# accepted as a way to differentiate between what runs on X # accepted as a way to differentiate between what runs on X
# and what runs on older Macs - while in theory "Carbon" defns # and what runs on older Macs - while in theory "Carbon" defns
...@@ -1656,11 +1699,35 @@ CheckCARBON() ...@@ -1656,11 +1699,35 @@ CheckCARBON()
VIDEO_DRIVERS="$VIDEO_DRIVERS maccommon/libvideo_maccommon.la" VIDEO_DRIVERS="$VIDEO_DRIVERS maccommon/libvideo_maccommon.la"
VIDEO_SUBDIRS="$VIDEO_SUBDIRS macrom" VIDEO_SUBDIRS="$VIDEO_SUBDIRS macrom"
VIDEO_DRIVERS="$VIDEO_DRIVERS macrom/libvideo_macrom.la" 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 dnl Set up the Cocoa/Quartz video driver for Mac OS X (but not Darwin)
CheckQUARTZ() 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 <Cocoa/Cocoa.h>
],[
],[
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 # "MACOSX" is not an official definition, but it's commonly
# accepted as a way to differentiate between what runs on X # accepted as a way to differentiate between what runs on X
# and what runs on older Macs - while in theory "Carbon" defns # and what runs on older Macs - while in theory "Carbon" defns
...@@ -1672,6 +1739,8 @@ CheckQUARTZ() ...@@ -1672,6 +1739,8 @@ CheckQUARTZ()
-DENABLE_QUARTZ -DMACOSX -DTARGET_API_${mac_autoconf_target_workaround}_CARBON=1 -I\$(top_srcdir)/src/video/quartz" -DENABLE_QUARTZ -DMACOSX -DTARGET_API_${mac_autoconf_target_workaround}_CARBON=1 -I\$(top_srcdir)/src/video/quartz"
VIDEO_SUBDIRS="$VIDEO_SUBDIRS quartz" VIDEO_SUBDIRS="$VIDEO_SUBDIRS quartz"
VIDEO_DRIVERS="$VIDEO_DRIVERS quartz/libvideo_quartz.la" VIDEO_DRIVERS="$VIDEO_DRIVERS quartz/libvideo_quartz.la"
fi
fi
} }
dnl Check for the dlfcn.h interface for dynamically loading objects dnl Check for the dlfcn.h interface for dynamically loading objects
...@@ -2581,13 +2650,15 @@ case "$target" in ...@@ -2581,13 +2650,15 @@ case "$target" in
SDL_LIBS="-lSDLmain $SDL_LIBS" SDL_LIBS="-lSDLmain $SDL_LIBS"
;; ;;
*-*-darwin* ) *-*-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. # 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 ARCH=macosx
CheckDummyVideo CheckDummyVideo
CheckDiskAudio CheckDiskAudio
CheckQUARTZ CheckCOCOA
CheckCARBON
CheckMacX11
CheckMacGL CheckMacGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION CheckSIGACTION
...@@ -2625,8 +2696,16 @@ case "$target" in ...@@ -2625,8 +2696,16 @@ case "$target" in
fi fi
# The MacOS X platform requires special setup. # The MacOS X platform requires special setup.
SDL_LIBS="-lSDLmain $SDL_LIBS" SDL_LIBS="-lSDLmain $SDL_LIBS"
# The Cocoa backend still needs Carbon, and the YUV code QuickTime if test x$enable_video_cocoa = xyes; then
SYSTEM_LIBS="$SYSTEM_LIBS -framework Cocoa -framework Carbon -framework QuickTime" 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*) *-*-mint*)
ARCH=mint ARCH=mint
...@@ -2746,6 +2825,8 @@ AM_CONDITIONAL(TARGET_MINT, test $ARCH = mint) ...@@ -2746,6 +2825,8 @@ AM_CONDITIONAL(TARGET_MINT, test $ARCH = mint)
AM_CONDITIONAL(USE_DIRECTX, test x$use_directx = xyes) AM_CONDITIONAL(USE_DIRECTX, test x$use_directx = xyes)
AM_CONDITIONAL(USE_CLONE, test x$use_clone = xyes) AM_CONDITIONAL(USE_CLONE, test x$use_clone = xyes)
AM_CONDITIONAL(HAVE_NASM, test x$use_nasm = 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. # Set conditional variables for shared and static library selection.
# These are not used in any Makefile.am but in sdl-config.in. # These are not used in any Makefile.am but in sdl-config.in.
...@@ -2773,7 +2854,13 @@ case "$ARCH" in ...@@ -2773,7 +2854,13 @@ case "$ARCH" in
SHARED_SYSTEM_LIBS="$SYSTEM_LIBS" SHARED_SYSTEM_LIBS="$SYSTEM_LIBS"
;; ;;
macosx) 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 if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
SHARED_SYSTEM_LIBS="$SHARED_SYSTEM_LIBS -framework OpenGL" SHARED_SYSTEM_LIBS="$SHARED_SYSTEM_LIBS -framework OpenGL"
fi fi
...@@ -2874,6 +2961,7 @@ docs/man3/Makefile ...@@ -2874,6 +2961,7 @@ docs/man3/Makefile
include/Makefile include/Makefile
src/Makefile src/Makefile
src/main/Makefile src/main/Makefile
src/main/macos/Makefile
src/main/macosx/Makefile src/main/macosx/Makefile
src/main/macosx/Info.plist src/main/macosx/Info.plist
src/audio/Makefile src/audio/Makefile
......
...@@ -48,14 +48,26 @@ struct SDL_SysWMinfo; ...@@ -48,14 +48,26 @@ struct SDL_SysWMinfo;
typedef struct SDL_SysWMinfo SDL_SysWMinfo; typedef struct SDL_SysWMinfo SDL_SysWMinfo;
#else #else
#if defined(__APPLE__) && defined(__MACH__)
// conflicts with Quickdraw.h
#define Cursor X11Cursor
#endif
/* This is the structure for custom window manager events */ /* 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(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 */ /* AIX is unix, of course, but the native compiler CSet doesn't define unix */
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#if defined(__APPLE__) && defined(__MACH__)
// matches the re-define above
#undef Cursor
#endif
/* These are the various supported subsystems under UNIX */ /* These are the various supported subsystems under UNIX */
typedef enum { typedef enum {
SDL_SYSWM_X11 SDL_SYSWM_X11
......
...@@ -25,7 +25,9 @@ static char rcsid = ...@@ -25,7 +25,9 @@ static char rcsid =
"@(#) $Id$"; "@(#) $Id$";
#endif #endif
#if TARGET_API_MAC_CARBON #if defined(__APPLE__) && defined(__MACH__)
# include <Carbon/Carbon.h>
#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
# include <Carbon.h> # include <Carbon.h>
#else #else
# include <Sound.h> /* SoundManager interface */ # include <Sound.h> /* SoundManager interface */
...@@ -36,6 +38,12 @@ static char rcsid = ...@@ -36,6 +38,12 @@ static char rcsid =
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if !defined(NewSndCallBackUPP) && (UNIVERSAL_INTERFACES_VERSION < 0x0335)
#if !defined(NewSndCallBackProc) /* avoid circular redefinition... */
#define NewSndCallBackUPP NewSndCallBackProc
#endif
#endif
#include "SDL_endian.h" #include "SDL_endian.h"
#include "SDL_audio.h" #include "SDL_audio.h"
#include "SDL_audio_c.h" #include "SDL_audio_c.h"
...@@ -229,7 +237,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) { ...@@ -229,7 +237,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) {
/* initialize bufferCmd header */ /* initialize bufferCmd header */
memset (&header, 0, sizeof(header)); memset (&header, 0, sizeof(header));
callback = NewSndCallBackUPP (callBackProc); callback = (SndCallBackUPP) NewSndCallBackUPP (callBackProc);
sample_bits = spec->size / spec->samples / spec->channels * 8; sample_bits = spec->size / spec->samples / spec->channels * 8;
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
......
...@@ -72,7 +72,9 @@ int SDL_SYS_JoystickInit(void) ...@@ -72,7 +72,9 @@ int SDL_SYS_JoystickInit(void)
{ {
static ISpDeviceClass classes[4] = { static ISpDeviceClass classes[4] = {
kISpDeviceClass_Joystick, kISpDeviceClass_Joystick,
#if kISpDeviceClass_Gamepad
kISpDeviceClass_Gamepad, kISpDeviceClass_Gamepad,
#endif
kISpDeviceClass_Wheel, kISpDeviceClass_Wheel,
0 0
}; };
......
...@@ -19,8 +19,14 @@ if TARGET_WIN32 ...@@ -19,8 +19,14 @@ if TARGET_WIN32
MAINLIB_ARCH_SRCS = win32/SDL_win32_main.c MAINLIB_ARCH_SRCS = win32/SDL_win32_main.c
else else
if TARGET_MACOSX if TARGET_MACOSX
if USE_COCOA
MAINLIB_ARCH_SRCS = macosx/SDLMain.m macosx/SDLMain.h MAINLIB_ARCH_SRCS = macosx/SDLMain.m macosx/SDLMain.h
else else
if USE_CARBON
MAINLIB_ARCH_SRCS = macos/SDL_main.c
endif # USE_CARBON
endif # USE_COCOA
else
if TARGET_QTOPIA if TARGET_QTOPIA
MAINLIB_ARCH_SRCS = qtopia/SDL_qtopia_main.cc MAINLIB_ARCH_SRCS = qtopia/SDL_qtopia_main.cc
else else
......
...@@ -26,14 +26,16 @@ static char rcsid = ...@@ -26,14 +26,16 @@ static char rcsid =
#endif #endif
/* This file takes care of command line argument parsing, and stdio redirection /* 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 <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#if TARGET_API_MAC_CARBON #if defined(__APPLE__) && defined(__MACH__)
#include <Carbon/Carbon.h>
#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
#include <Carbon.h> #include <Carbon.h>
#else #else
#include <Dialogs.h> #include <Dialogs.h>
...@@ -50,9 +52,11 @@ static char rcsid = ...@@ -50,9 +52,11 @@ static char rcsid =
#undef main #undef main
#endif #endif
#if !(defined(__APPLE__) && defined(__MACH__))
/* The standard output files */ /* The standard output files */
#define STDOUT_FILE "stdout.txt" #define STDOUT_FILE "stdout.txt"
#define STDERR_FILE "stderr.txt" #define STDERR_FILE "stderr.txt"
#endif
#if !defined(__MWERKS__) && !TARGET_API_MAC_CARBON #if !defined(__MWERKS__) && !TARGET_API_MAC_CARBON
/* In MPW, the qd global has been removed from the libraries */ /* In MPW, the qd global has been removed from the libraries */
...@@ -79,6 +83,8 @@ static Boolean CommandKeyIsDown(void) ...@@ -79,6 +83,8 @@ static Boolean CommandKeyIsDown(void)
return(false); return(false);
} }
#if !(defined(__APPLE__) && defined(__MACH__))
/* Parse a command line buffer into arguments */ /* Parse a command line buffer into arguments */
static int ParseCommandLine(char *cmdline, char **argv) static int ParseCommandLine(char *cmdline, char **argv)
{ {
...@@ -158,6 +164,8 @@ static void cleanup_output(void) ...@@ -158,6 +164,8 @@ static void cleanup_output(void)
} }
} }
#endif //!(defined(__APPLE__) && defined(__MACH__))
static int getCurrentAppName (StrFileName name) { static int getCurrentAppName (StrFileName name) {
ProcessSerialNumber process; ProcessSerialNumber process;
...@@ -207,7 +215,7 @@ static int getPrefsFile (FSSpec *prefs_fsp, int create) { ...@@ -207,7 +215,7 @@ static int getPrefsFile (FSSpec *prefs_fsp, int create) {
prefs_name[0] = app_name[0] + strlen (SUFFIX); prefs_name[0] = app_name[0] + strlen (SUFFIX);
/* Make the file spec for prefs file */ /* 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 ) if ( !create )
return 0; return 0;
else { else {
...@@ -216,12 +224,12 @@ static int getPrefsFile (FSSpec *prefs_fsp, int create) { ...@@ -216,12 +224,12 @@ static int getPrefsFile (FSSpec *prefs_fsp, int create) {
prefs_fsp->parID = directory_id; prefs_fsp->parID = directory_id;
prefs_fsp->vRefNum = volume_ref_number; prefs_fsp->vRefNum = volume_ref_number;
FSpCreateResFile (prefs_fsp, '????', 'pref', 0); FSpCreateResFile (prefs_fsp, 0x3f3f3f3f, 'pref', 0); // '????' parsed as trigraph
if ( noErr != ResError () ) if ( noErr != ResError () )
return 0; return 0;
} }
}
return 1; return 1;
} }
...@@ -233,7 +241,7 @@ static int readPrefsResource (PrefsRecord *prefs) { ...@@ -233,7 +241,7 @@ static int readPrefsResource (PrefsRecord *prefs) {
if (prefs_handle != NULL) { if (prefs_handle != NULL) {
int offset = 0; int offset = 0;
int j = 0; // int j = 0;
HLock(prefs_handle); HLock(prefs_handle);
...@@ -349,7 +357,9 @@ static int writePreferences (PrefsRecord *prefs) { ...@@ -349,7 +357,9 @@ static int writePreferences (PrefsRecord *prefs) {
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#if !(defined(__APPLE__) && defined(__MACH__))
#pragma unused(argc, argv) #pragma unused(argc, argv)
#endif
#define DEFAULT_ARGS "\p" /* pascal string for default args */ #define DEFAULT_ARGS "\p" /* pascal string for default args */
#define DEFAULT_VIDEO_DRIVER "\ptoolbox" /* pascal string for default video driver name */ #define DEFAULT_VIDEO_DRIVER "\ptoolbox" /* pascal string for default video driver name */
...@@ -360,11 +370,13 @@ int main(int argc, char *argv[]) ...@@ -360,11 +370,13 @@ int main(int argc, char *argv[])
PrefsRecord prefs = { DEFAULT_ARGS, DEFAULT_VIDEO_DRIVER, DEFAULT_OUTPUT_TO_FILE }; PrefsRecord prefs = { DEFAULT_ARGS, DEFAULT_VIDEO_DRIVER, DEFAULT_OUTPUT_TO_FILE };
#if !(defined(__APPLE__) && defined(__MACH__))
int nargs; int nargs;
char **args; char **args;
char *commandLine; char *commandLine;
StrFileName appNameText; StrFileName appNameText;
#endif
int videodriver = VIDEO_ID_TOOLBOX; int videodriver = VIDEO_ID_TOOLBOX;
int settingsChanged = 0; int settingsChanged = 0;
...@@ -399,12 +411,18 @@ int main(int argc, char *argv[]) ...@@ -399,12 +411,18 @@ int main(int argc, char *argv[])
short itemHit; short itemHit;
errorDialog = GetNewDialog (1001, nil, (WindowPtr)-1); errorDialog = GetNewDialog (1001, nil, (WindowPtr)-1);
if (errorDialog == NULL)
return -1;
DrawDialog (errorDialog); DrawDialog (errorDialog);
GetDialogItem (errorDialog, kErr_Text, &dummyType, &dummyHandle, &dummyRect); GetDialogItem (errorDialog, kErr_Text, &dummyType, &dummyHandle, &dummyRect);
SetDialogItemText (dummyHandle, "\pError Initializing SDL"); SetDialogItemText (dummyHandle, "\pError Initializing SDL");
#if TARGET_API_MAC_CARBON
SetPort (GetDialogPort(errorDialog));
#else
SetPort (errorDialog); SetPort (errorDialog);
#endif
do { do {
ModalDialog (nil, &itemHit); ModalDialog (nil, &itemHit);
} while (itemHit != kErr_OK); } while (itemHit != kErr_OK);
...@@ -442,23 +460,40 @@ int main(int argc, char *argv[]) ...@@ -442,23 +460,40 @@ int main(int argc, char *argv[])
Rect dummyRect; Rect dummyRect;
Handle dummyHandle; Handle dummyHandle;
short itemHit; short itemHit;
#if TARGET_API_MAC_CARBON
ControlRef control;
#endif
/* Assume that they will change settings, rather than do exhaustive check */ /* Assume that they will change settings, rather than do exhaustive check */
settingsChanged = 1; settingsChanged = 1;
/* Create dialog and display it */ /* 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); SetPort (commandDialog);
#endif
/* Setup controls */ /* 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 */ GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */
SetControlValue ((ControlHandle)dummyHandle, prefs.output_to_file ); SetControlValue ((ControlHandle)dummyHandle, prefs.output_to_file );
#endif
GetDialogItem (commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect); GetDialogItem (commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect);
SetDialogItemText (dummyHandle, prefs.command_line); 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); GetDialogItem (commandDialog, kCL_Video, &dummyType, &dummyHandle, &dummyRect);
SetControlValue ((ControlRef)dummyHandle, videodriver); SetControlValue ((ControlRef)dummyHandle, videodriver);
#endif
SetDialogDefaultItem (commandDialog, kCL_OK); SetDialogDefaultItem (commandDialog, kCL_OK);
SetDialogCancelItem (commandDialog, kCL_Cancel); SetDialogCancelItem (commandDialog, kCL_Cancel);
...@@ -469,8 +504,13 @@ int main(int argc, char *argv[]) ...@@ -469,8 +504,13 @@ int main(int argc, char *argv[])
/* Toggle command-line output checkbox */ /* Toggle command-line output checkbox */
if ( itemHit == kCL_File ) { 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 */ GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */
SetControlValue((ControlHandle)dummyHandle, !GetControlValue((ControlHandle)dummyHandle) ); SetControlValue((ControlHandle)dummyHandle, !GetControlValue((ControlHandle)dummyHandle) );
#endif
} }
} while (itemHit != kCL_OK && itemHit != kCL_Cancel); } while (itemHit != kCL_OK && itemHit != kCL_Cancel);
...@@ -479,11 +519,21 @@ int main(int argc, char *argv[]) ...@@ -479,11 +519,21 @@ int main(int argc, char *argv[])
GetDialogItem (commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect); /* MJS */ GetDialogItem (commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect); /* MJS */
GetDialogItemText (dummyHandle, prefs.command_line); 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 */ GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */
prefs.output_to_file = GetControlValue ((ControlHandle)dummyHandle); 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); GetDialogItem (commandDialog, kCL_Video, &dummyType, &dummyHandle, &dummyRect);
videodriver = GetControlValue ((ControlRef)dummyHandle); videodriver = GetControlValue ((ControlRef)dummyHandle);
#endif
DisposeDialog (commandDialog); DisposeDialog (commandDialog);
...@@ -504,6 +554,7 @@ int main(int argc, char *argv[]) ...@@ -504,6 +554,7 @@ int main(int argc, char *argv[])
break; break;
} }
#if !(defined(__APPLE__) && defined(__MACH__))
/* Redirect standard I/O to files */ /* Redirect standard I/O to files */
if ( prefs.output_to_file ) { if ( prefs.output_to_file ) {
freopen (STDOUT_FILE, "w", stdout); freopen (STDOUT_FILE, "w", stdout);
...@@ -512,6 +563,7 @@ int main(int argc, char *argv[]) ...@@ -512,6 +563,7 @@ int main(int argc, char *argv[])
fclose (stdout); fclose (stdout);
fclose (stderr); fclose (stderr);
} }
#endif
if (settingsChanged) { if (settingsChanged) {
/* Save the prefs, even if they might not have changed (but probably did) */ /* Save the prefs, even if they might not have changed (but probably did) */
...@@ -519,6 +571,8 @@ int main(int argc, char *argv[]) ...@@ -519,6 +571,8 @@ int main(int argc, char *argv[])
fprintf (stderr, "WARNING: Could not save preferences!\n"); fprintf (stderr, "WARNING: Could not save preferences!\n");
} }
#if !(defined(__APPLE__) && defined(__MACH__))
appNameText[0] = 0;
getCurrentAppName (appNameText); /* check for error here ? */ getCurrentAppName (appNameText); /* check for error here ? */
commandLine = (char*) malloc (appNameText[0] + prefs.command_line[0] + 2); commandLine = (char*) malloc (appNameText[0] + prefs.command_line[0] + 2);
...@@ -553,6 +607,9 @@ int main(int argc, char *argv[]) ...@@ -553,6 +607,9 @@ int main(int argc, char *argv[])
/* Remove useless stdout.txt and stderr.txt */ /* Remove useless stdout.txt and stderr.txt */
cleanup_output (); cleanup_output ();
#else // defined(__APPLE__) && defined(__MACH__)
SDL_main(argc, argv);
#endif
/* Exit cleanly, calling atexit() functions */ /* Exit cleanly, calling atexit() functions */
exit (0); exit (0);
......
...@@ -45,6 +45,9 @@ static char rcsid = ...@@ -45,6 +45,9 @@ static char rcsid =
/* Available video drivers */ /* Available video drivers */
static VideoBootStrap *bootstrap[] = { static VideoBootStrap *bootstrap[] = {
#ifdef ENABLE_QUARTZ
&QZ_bootstrap,
#endif
#ifdef ENABLE_X11 #ifdef ENABLE_X11
&X11_bootstrap, &X11_bootstrap,
#endif #endif
...@@ -93,9 +96,6 @@ static VideoBootStrap *bootstrap[] = { ...@@ -93,9 +96,6 @@ static VideoBootStrap *bootstrap[] = {
#ifdef ENABLE_DRAWSPROCKET #ifdef ENABLE_DRAWSPROCKET
&DSp_bootstrap, &DSp_bootstrap,
#endif #endif
#ifdef ENABLE_QUARTZ
&QZ_bootstrap,
#endif
#ifdef ENABLE_CYBERGRAPHICS #ifdef ENABLE_CYBERGRAPHICS
&CGX_bootstrap, &CGX_bootstrap,
#endif #endif
......
...@@ -28,7 +28,9 @@ static char rcsid = ...@@ -28,7 +28,9 @@ static char rcsid =
#ifndef _SDL_lowvideo_h #ifndef _SDL_lowvideo_h
#define _SDL_lowvideo_h #define _SDL_lowvideo_h
#if TARGET_API_MAC_CARBON #if defined(__APPLE__) && defined(__MACH__)
#include <Carbon/Carbon.h>
#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
#include <Carbon.h> #include <Carbon.h>
#else #else
#include <Quickdraw.h> #include <Quickdraw.h>
......
...@@ -27,7 +27,9 @@ static char rcsid = ...@@ -27,7 +27,9 @@ static char rcsid =
#include <stdio.h> #include <stdio.h>
#if TARGET_API_MAC_CARBON #if defined(__APPLE__) && defined(__MACH__)
#include <Carbon/Carbon.h>
#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
#include <Carbon.h> #include <Carbon.h>
#else #else
#include <Script.h> #include <Script.h>
...@@ -734,10 +736,12 @@ static void Mac_DoAppleMenu(_THIS, long choice) ...@@ -734,10 +736,12 @@ static void Mac_DoAppleMenu(_THIS, long choice)
#if !TARGET_API_MAC_CARBON #if !TARGET_API_MAC_CARBON
/* Since we don't initialize QuickDraw, we need to get a pointer to qd */ /* Since we don't initialize QuickDraw, we need to get a pointer to qd */
QDGlobals *theQD = NULL; QDGlobals *theQD = NULL;
#endif
/* Exported to the macmain code */ /* Exported to the macmain code */
void SDL_InitQuickDraw(struct QDGlobals *the_qd) void SDL_InitQuickDraw(struct QDGlobals *the_qd)
{ {
#if !TARGET_API_MAC_CARBON
theQD = the_qd; theQD = the_qd;
}
#endif #endif
}
...@@ -27,7 +27,9 @@ static char rcsid = ...@@ -27,7 +27,9 @@ static char rcsid =
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if TARGET_API_MAC_CARBON #if defined(__APPLE__) && defined(__MACH__)
#include <Carbon/Carbon.h>
#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
#include <Carbon.h> #include <Carbon.h>
#else #else
#include <Quickdraw.h> #include <Quickdraw.h>
......
...@@ -28,7 +28,9 @@ static char rcsid = ...@@ -28,7 +28,9 @@ static char rcsid =
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if TARGET_API_MAC_CARBON #if defined(__APPLE__) && defined(__MACH__)
#include <Carbon/Carbon.h>
#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
#include <Carbon.h> #include <Carbon.h>
#else #else
#include <Windows.h> #include <Windows.h>
......
## Makefile.am for SDL using the Mac DrawSprocket video driver ## Makefile.am for SDL using the Mac DrawSprocket video driver
noinst_LTLIBRARIES = libvideo_dsp.la noinst_LTLIBRARIES = libvideo_macdsp.la
libvideo_dsp_la_SOURCES = $(DSP_SRCS) libvideo_macdsp_la_SOURCES = $(DSP_SRCS)
# The SDL Mac DrawSprocket driver sources # The SDL Mac DrawSprocket driver sources
DSP_SRCS = \ DSP_SRCS = \
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
System requirements (* denotes optional): System requirements (* denotes optional):
1. DrawSprocket 1.7.3 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 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 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 acceleration in the drivers and the drivers have been updated for OS 9. The current
...@@ -130,14 +130,19 @@ static char rcsid = ...@@ -130,14 +130,19 @@ static char rcsid =
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#if TARGET_API_MAC_CARBON #if defined(__APPLE__) && defined(__MACH__)
#include <Carbon/Carbon.h>
#include <DrawSprocket/DrawSprocket.h>
#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
#include <Carbon.h> #include <Carbon.h>
#include <DrawSprocket.h>
#else #else
#include <LowMem.h> #include <LowMem.h>
#include <Gestalt.h> #include <Gestalt.h>
#include <Devices.h> #include <Devices.h>
#include <DiskInit.h> #include <DiskInit.h>
#include <QDOffscreen.h> #include <QDOffscreen.h>
#include <DrawSprocket.h>
#endif #endif
#include "SDL_video.h" #include "SDL_video.h"
...@@ -145,6 +150,7 @@ static char rcsid = ...@@ -145,6 +150,7 @@ static char rcsid =
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_syswm.h" #include "SDL_syswm.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#include "SDL_pixels_c.h"
#include "SDL_dspvideo.h" #include "SDL_dspvideo.h"
#include "SDL_macgl_c.h" #include "SDL_macgl_c.h"
#include "SDL_macwm_c.h" #include "SDL_macwm_c.h"
...@@ -221,8 +227,12 @@ typedef private_hwdata private_swdata ; /* have same fields */ ...@@ -221,8 +227,12 @@ typedef private_hwdata private_swdata ; /* have same fields */
static int DSp_Available(void) static int DSp_Available(void)
{ {
/* Check for DrawSprocket */ /* Check for DrawSprocket */
#if ! TARGET_API_MAC_OSX
/* This check is only meaningful if you weak-link DrawSprocketLib */ /* This check is only meaningful if you weak-link DrawSprocketLib */
return ((Ptr)DSpStartup != (Ptr)kUnresolvedCFragSymbolAddress); 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) static void DSp_DeleteDevice(SDL_VideoDevice *device)
...@@ -430,6 +440,7 @@ static void DSp_IsHWAvailable (_THIS, SDL_PixelFormat *vformat) ...@@ -430,6 +440,7 @@ static void DSp_IsHWAvailable (_THIS, SDL_PixelFormat *vformat)
SetRect (&bounds, 0, 0, 320, 240); SetRect (&bounds, 0, 0, 320, 240);
#if useDistantHdwrMem && useLocalHdwrMem
err = NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL, SDL_Display, useDistantHdwrMem | noNewDevice); err = NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL, SDL_Display, useDistantHdwrMem | noNewDevice);
if (err == noErr) { if (err == noErr) {
dsp_vram_available = SDL_TRUE; dsp_vram_available = SDL_TRUE;
...@@ -441,6 +452,7 @@ static void DSp_IsHWAvailable (_THIS, SDL_PixelFormat *vformat) ...@@ -441,6 +452,7 @@ static void DSp_IsHWAvailable (_THIS, SDL_PixelFormat *vformat)
DisposeGWorld (offscreen); DisposeGWorld (offscreen);
dsp_agp_available = SDL_TRUE; dsp_agp_available = SDL_TRUE;
} }
#endif
} }
} }
...@@ -508,8 +520,9 @@ static int DSp_GetMainDevice (_THIS, GDHandle *device) ...@@ -508,8 +520,9 @@ static int DSp_GetMainDevice (_THIS, GDHandle *device)
static int DSp_VideoInit(_THIS, SDL_PixelFormat *vformat) 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) || if ( (dsp_version.majorRev == 1 && dsp_version.minorAndBugRev < 0x73) ||
(dsp_version.majorRev < 1) ) { (dsp_version.majorRev < 1) ) {
...@@ -615,16 +628,16 @@ static SDL_Rect **DSp_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) ...@@ -615,16 +628,16 @@ static SDL_Rect **DSp_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
/* Various screen update functions available */ /* Various screen update functions available */
static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); 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 */ 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 ) Boolean DSp_VBLProc ( DSpContextReference context, void *ref_con )
{ {
retrace_count++; retrace_count++;
return 1; /* Darrell, is this right? */ return 1; /* Darrell, is this right? */
} }
#endif
static void DSp_SetHWError (OSStatus err, int is_agp) static void DSp_SetHWError (OSStatus err, int is_agp)
{ {
...@@ -650,6 +663,7 @@ static void DSp_SetHWError (OSStatus err, int is_agp) ...@@ -650,6 +663,7 @@ static void DSp_SetHWError (OSStatus err, int is_agp)
sprintf(message, fmt, mem); sprintf(message, fmt, mem);
SDL_SetError(message); SDL_SetError(message);
} }
#endif // TARGET_API_MAC_OSX
/* put up a dialog to verify display change */ /* put up a dialog to verify display change */
static int DSp_ConfirmSwitch () { static int DSp_ConfirmSwitch () {
...@@ -671,7 +685,11 @@ static int DSp_ConfirmSwitch () { ...@@ -671,7 +685,11 @@ static int DSp_ConfirmSwitch () {
if (dialog == NULL) if (dialog == NULL)
return (0); return (0);
SetPort (dialog); #if TARGET_API_CARBON
SetPort (GetDialogPort(dialog));
#else
SetPort ((WindowPtr) dialog);
#endif
SetDialogDefaultItem (dialog, bCancel); SetDialogDefaultItem (dialog, bCancel);
SetDialogCancelItem (dialog, bCancel); SetDialogCancelItem (dialog, bCancel);
...@@ -693,7 +711,8 @@ static int DSp_ConfirmSwitch () { ...@@ -693,7 +711,8 @@ static int DSp_ConfirmSwitch () {
} while ( item != bCancel && item != bOK && err != noErr); } while ( item != bCancel && item != bOK && err != noErr);
DisposeWindow (dialog);
DisposeDialog (dialog);
SetPort (savePort); SetPort (savePort);
SetEventMask(everyEvent - autoKeyMask); SetEventMask(everyEvent - autoKeyMask);
...@@ -740,9 +759,11 @@ static SDL_Surface *DSp_SetVideoMode(_THIS, ...@@ -740,9 +759,11 @@ static SDL_Surface *DSp_SetVideoMode(_THIS,
SDL_Surface *current, int width, int height, int bpp, Uint32 flags) SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
{ {
DisplayIDType display_id; #if !TARGET_API_MAC_OSX
DSpContextAttributes attrib; DisplayIDType display_id;
Fixed freq; Fixed freq;
#endif
DSpContextAttributes attrib;
OSStatus err; OSStatus err;
UInt32 rmask = 0, gmask = 0, bmask = 0; UInt32 rmask = 0, gmask = 0, bmask = 0;
...@@ -924,7 +945,11 @@ rebuild: ...@@ -924,7 +945,11 @@ rebuild:
/* Set window color to black to avoid white flash*/ /* Set window color to black to avoid white flash*/
GetPort (&save_port); GetPort (&save_port);
#if TARGET_API_MAC_CARBON
SetPort (GetWindowPort(SDL_Window));
#else
SetPort (SDL_Window); SetPort (SDL_Window);
#endif
RGBForeColor (&rgb); RGBForeColor (&rgb);
PaintRect (&rect); PaintRect (&rect);
SetPort (save_port); SetPort (save_port);
...@@ -1031,6 +1056,7 @@ static int DSp_NewHWSurface(_THIS, CGrafPtr *port, int depth, int width, int hei ...@@ -1031,6 +1056,7 @@ static int DSp_NewHWSurface(_THIS, CGrafPtr *port, int depth, int width, int hei
SetRect (&bounds, 0, 0, width, height); SetRect (&bounds, 0, 0, width, height);
#if useDistantHdwrMem && useLocalHdwrMem
if (dsp_vram_available) { if (dsp_vram_available) {
/* try VRAM */ /* try VRAM */
err = NewGWorld (port, depth, &bounds, 0 , SDL_Display, useDistantHdwrMem | noNewDevice ); err = NewGWorld (port, depth, &bounds, 0 , SDL_Display, useDistantHdwrMem | noNewDevice );
...@@ -1049,6 +1075,7 @@ static int DSp_NewHWSurface(_THIS, CGrafPtr *port, int depth, int width, int hei ...@@ -1049,6 +1075,7 @@ static int DSp_NewHWSurface(_THIS, CGrafPtr *port, int depth, int width, int hei
else else
return (0); return (0);
} }
#endif
return (-1); return (-1);
} }
...@@ -1210,8 +1237,10 @@ static int DSp_FlipHWSurface(_THIS, SDL_Surface *surface) ...@@ -1210,8 +1237,10 @@ static int DSp_FlipHWSurface(_THIS, SDL_Surface *surface)
CGrafPtr dsp_front_buffer, save_port; CGrafPtr dsp_front_buffer, save_port;
Rect rect; Rect rect;
#if ! TARGET_API_MAC_OSX
unsigned int old_count; unsigned int old_count;
#endif
/* pseudo page flipping for VRAM back buffer*/ /* pseudo page flipping for VRAM back buffer*/
DSpContext_GetFrontBuffer (dsp_context, &dsp_front_buffer); DSpContext_GetFrontBuffer (dsp_context, &dsp_front_buffer);
SetRect (&rect, 0, 0, surface->w-1, surface->h-1); SetRect (&rect, 0, 0, surface->w-1, surface->h-1);
......
...@@ -28,13 +28,18 @@ static char rcsid = ...@@ -28,13 +28,18 @@ static char rcsid =
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#if TARGET_API_MAC_CARBON #if defined(__APPLE__) && defined(__MACH__)
#include <Carbon/Carbon.h>
#if USE_QUICKTIME
#include <QuickTime/Movies.h>
#endif
#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
#include <Carbon.h> #include <Carbon.h>
/* The fullscreen code requires the QuickTime framework, and the window /* 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. is still at the back on MacOS X, which is where this code is needed.
*/ */
#if USE_QUICKTIME #if USE_QUICKTIME
#include <QuickTime/Movies.h> #include <Movies.h>
#endif #endif
#else #else
#include <LowMem.h> #include <LowMem.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment