MacOS Classic is no longer supported.
authorSam Lantinga <slouken@libsdl.org>
Thu, 10 Aug 2006 14:54:23 +0000
changeset 1978542c78b6fb12
parent 1977 754847f19490
child 1979 5f7db8d2d06f
MacOS Classic is no longer supported.
CWprojects.sea.bin
MPWmake.sea.bin
Makefile.in
include/SDL_config.h.default
include/SDL_config.h.in
include/SDL_config_macos.h
include/SDL_main.h
include/SDL_opengl.h
include/begin_code.h
include/close_code.h
src/audio/SDL_audio.c
src/cdrom/SDL_cdrom.c
src/cdrom/SDL_syscdrom.h
src/cdrom/macos/SDL_syscdrom.c
src/cdrom/macos/SDL_syscdrom_c.h
src/events/SDL_events.c
src/events/SDL_sysevents.h
src/file/SDL_rwops.c
src/joystick/SDL_sysjoystick.h
src/joystick/macos/SDL_sysjoystick.c
src/loadso/macos/SDL_sysloadso.c
src/main/macos/SDL.r
src/main/macos/SDL_main.c
src/main/macos/SIZE.r
src/main/macos/exports/Makefile
src/main/macos/exports/SDL.x
src/main/macos/exports/gendef.pl
src/timer/macos/FastTimes.c
src/timer/macos/FastTimes.h
src/timer/macos/SDL_MPWtimer.c
src/timer/macos/SDL_systimer.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/maccommon/SDL_lowvideo.h
src/video/maccommon/SDL_macevents.c
src/video/maccommon/SDL_macevents_c.h
src/video/maccommon/SDL_macgl.c
src/video/maccommon/SDL_macgl_c.h
src/video/maccommon/SDL_mackeys.h
src/video/maccommon/SDL_macmouse.c
src/video/maccommon/SDL_macmouse_c.h
src/video/maccommon/SDL_macwm.c
src/video/maccommon/SDL_macwm_c.h
src/video/macdsp/SDL_dspvideo.c
src/video/macdsp/SDL_dspvideo.h
src/video/macrom/SDL_romvideo.c
src/video/macrom/SDL_romvideo.h
     1.1 Binary file CWprojects.sea.bin has changed
     2.1 Binary file MPWmake.sea.bin has changed
     3.1 --- a/Makefile.in	Thu Aug 10 14:35:42 2006 +0000
     3.2 +++ b/Makefile.in	Thu Aug 10 14:54:23 2006 +0000
     3.3 @@ -38,7 +38,7 @@
     3.4  SDLMAIN_SOURCES = @SDLMAIN_SOURCES@
     3.5  SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
     3.6  
     3.7 -DIST = acinclude.m4 autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS CWprojects.sea.bin docs docs.html EpocBuildFiles.zip include INSTALL Makefile.dc Makefile.minimal Makefile.in MPWmake.sea.bin README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualCE.zip VisualC.html VisualC.zip Watcom-OS2.zip Watcom-Win32.zip WhatsNew Xcode.tar.gz
     3.8 +DIST = acinclude.m4 autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS docs docs.html EpocBuildFiles.zip include INSTALL Makefile.dc Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualCE.zip VisualC.html VisualC.zip Watcom-OS2.zip Watcom-Win32.zip WhatsNew Xcode.tar.gz
     3.9  
    3.10  LT_AGE      = @LT_AGE@
    3.11  LT_CURRENT  = @LT_CURRENT@
     4.1 --- a/include/SDL_config.h.default	Thu Aug 10 14:35:42 2006 +0000
     4.2 +++ b/include/SDL_config.h.default	Thu Aug 10 14:54:23 2006 +0000
     4.3 @@ -30,8 +30,6 @@
     4.4  #include "SDL_config_amiga.h"
     4.5  #elif defined(__DREAMCAST__)
     4.6  #include "SDL_config_dreamcast.h"
     4.7 -#elif defined(__MACOS__)
     4.8 -#include "SDL_config_macos.h"
     4.9  #elif defined(__MACOSX__)
    4.10  #include "SDL_config_macosx.h"
    4.11  #elif defined(__WIN32__)
     5.1 --- a/include/SDL_config.h.in	Thu Aug 10 14:35:42 2006 +0000
     5.2 +++ b/include/SDL_config.h.in	Thu Aug 10 14:54:23 2006 +0000
     5.3 @@ -184,7 +184,6 @@
     5.4  #undef SDL_CDROM_DUMMY
     5.5  #undef SDL_CDROM_FREEBSD
     5.6  #undef SDL_CDROM_LINUX
     5.7 -#undef SDL_CDROM_MACOS
     5.8  #undef SDL_CDROM_MACOSX
     5.9  #undef SDL_CDROM_MINT
    5.10  #undef SDL_CDROM_OPENBSD
    5.11 @@ -203,7 +202,6 @@
    5.12  #undef SDL_JOYSTICK_IOKIT
    5.13  #undef SDL_JOYSTICK_LINUX
    5.14  #undef SDL_JOYSTICK_LINUXEV
    5.15 -#undef SDL_JOYSTICK_MACOS
    5.16  #undef SDL_JOYSTICK_MINT
    5.17  #undef SDL_JOYSTICK_OS2
    5.18  #undef SDL_JOYSTICK_RISCOS
    5.19 @@ -217,7 +215,6 @@
    5.20  #undef SDL_LOADSO_DLOPEN
    5.21  #undef SDL_LOADSO_DUMMY
    5.22  #undef SDL_LOADSO_LDG
    5.23 -#undef SDL_LOADSO_MACOS
    5.24  #undef SDL_LOADSO_OS2
    5.25  #undef SDL_LOADSO_WIN32
    5.26  
    5.27 @@ -240,7 +237,6 @@
    5.28  #undef SDL_TIMER_DC
    5.29  #undef SDL_TIMER_DUMMY
    5.30  #undef SDL_TIMER_EPOC
    5.31 -#undef SDL_TIMER_MACOS
    5.32  #undef SDL_TIMER_MINT
    5.33  #undef SDL_TIMER_OS2
    5.34  #undef SDL_TIMER_RISCOS
    5.35 @@ -254,7 +250,6 @@
    5.36  #undef SDL_VIDEO_DRIVER_CYBERGRAPHICS
    5.37  #undef SDL_VIDEO_DRIVER_DC
    5.38  #undef SDL_VIDEO_DRIVER_DIRECTFB
    5.39 -#undef SDL_VIDEO_DRIVER_DRAWSPROCKET
    5.40  #undef SDL_VIDEO_DRIVER_DUMMY
    5.41  #undef SDL_VIDEO_DRIVER_EPOC
    5.42  #undef SDL_VIDEO_DRIVER_FBCON
    5.43 @@ -268,7 +263,6 @@
    5.44  #undef SDL_VIDEO_DRIVER_PS2GS
    5.45  #undef SDL_VIDEO_DRIVER_RISCOS
    5.46  #undef SDL_VIDEO_DRIVER_SVGALIB
    5.47 -#undef SDL_VIDEO_DRIVER_TOOLBOX
    5.48  #undef SDL_VIDEO_DRIVER_VGL
    5.49  #undef SDL_VIDEO_DRIVER_WIN32
    5.50  #undef SDL_VIDEO_DRIVER_WSCONS
     6.1 --- a/include/SDL_config_macos.h	Thu Aug 10 14:35:42 2006 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,112 +0,0 @@
     6.4 -/*
     6.5 -    SDL - Simple DirectMedia Layer
     6.6 -    Copyright (C) 1997-2006 Sam Lantinga
     6.7 -
     6.8 -    This library is free software; you can redistribute it and/or
     6.9 -    modify it under the terms of the GNU Lesser General Public
    6.10 -    License as published by the Free Software Foundation; either
    6.11 -    version 2.1 of the License, or (at your option) any later version.
    6.12 -
    6.13 -    This library is distributed in the hope that it will be useful,
    6.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.16 -    Lesser General Public License for more details.
    6.17 -
    6.18 -    You should have received a copy of the GNU Lesser General Public
    6.19 -    License along with this library; if not, write to the Free Software
    6.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    6.21 -
    6.22 -    Sam Lantinga
    6.23 -    slouken@libsdl.org
    6.24 -*/
    6.25 -
    6.26 -#ifndef _SDL_config_macos_h
    6.27 -#define _SDL_config_macos_h
    6.28 -
    6.29 -#include "SDL_platform.h"
    6.30 -
    6.31 -/* This is a set of defines to configure the SDL features */
    6.32 -
    6.33 -#include <MacTypes.h>
    6.34 -
    6.35 -typedef SInt8 int8_t;
    6.36 -typedef UInt8 uint8_t;
    6.37 -typedef SInt16 int16_t;
    6.38 -typedef UInt16 uint16_t;
    6.39 -typedef SInt32 int32_t;
    6.40 -typedef UInt32 uint32_t;
    6.41 -typedef SInt64 int64_t;
    6.42 -typedef UInt64 uint64_t;
    6.43 -typedef unsigned long uintptr_t;
    6.44 -
    6.45 -#define SDL_HAS_64BIT_TYPE	1
    6.46 -
    6.47 -/* Useful headers */
    6.48 -#define HAVE_STDIO_H	1
    6.49 -#define STDC_HEADERS	1
    6.50 -#define HAVE_STRING_H	1
    6.51 -#define HAVE_CTYPE_H	1
    6.52 -#define HAVE_MATH_H	1
    6.53 -#define HAVE_SIGNAL_H	1
    6.54 -
    6.55 -/* C library functions */
    6.56 -#define HAVE_MALLOC	1
    6.57 -#define HAVE_CALLOC	1
    6.58 -#define HAVE_REALLOC	1
    6.59 -#define HAVE_FREE	1
    6.60 -#define HAVE_ALLOCA	1
    6.61 -#define HAVE_ABS	1
    6.62 -#define HAVE_MEMSET	1
    6.63 -#define HAVE_MEMCPY	1
    6.64 -#define HAVE_MEMMOVE	1
    6.65 -#define HAVE_MEMCMP	1
    6.66 -#define HAVE_STRLEN	1
    6.67 -#define HAVE_STRCHR	1
    6.68 -#define HAVE_STRRCHR	1
    6.69 -#define HAVE_STRSTR	1
    6.70 -#define HAVE_ITOA	1
    6.71 -#define HAVE_STRTOL	1
    6.72 -#define HAVE_STRTOD	1
    6.73 -#define HAVE_ATOI	1
    6.74 -#define HAVE_ATOF	1
    6.75 -#define HAVE_STRCMP	1
    6.76 -#define HAVE_STRNCMP	1
    6.77 -#define HAVE_SSCANF	1
    6.78 -
    6.79 -/* Enable various audio drivers */
    6.80 -#define SDL_AUDIO_DRIVER_SNDMGR	1
    6.81 -#define SDL_AUDIO_DRIVER_DISK	1
    6.82 -#define SDL_AUDIO_DRIVER_DUMMY	1
    6.83 -
    6.84 -/* Enable various cdrom drivers */
    6.85 -#if TARGET_API_MAC_CARBON
    6.86 -#define SDL_CDROM_DUMMY		1
    6.87 -#else
    6.88 -#define SDL_CDROM_MACOS		1
    6.89 -#endif
    6.90 -
    6.91 -/* Enable various input drivers */
    6.92 -#if TARGET_API_MAC_CARBON
    6.93 -#define SDL_JOYSTICK_DUMMY	1
    6.94 -#else
    6.95 -#define SDL_JOYSTICK_MACOS	1
    6.96 -#endif
    6.97 -
    6.98 -/* Enable various shared object loading systems */
    6.99 -#define SDL_LOADSO_MACOS	1
   6.100 -
   6.101 -/* Enable various threading systems */
   6.102 -#define SDL_THREADS_DISABLED	1
   6.103 -
   6.104 -/* Enable various timer systems */
   6.105 -#define SDL_TIMER_MACOS	1
   6.106 -
   6.107 -/* Enable various video drivers */
   6.108 -#define SDL_VIDEO_DRIVER_DUMMY	1
   6.109 -#define SDL_VIDEO_DRIVER_DRAWSPROCKET	1
   6.110 -#define SDL_VIDEO_DRIVER_TOOLBOX	1
   6.111 -
   6.112 -/* Enable OpenGL support */
   6.113 -#define SDL_VIDEO_OPENGL	1
   6.114 -
   6.115 -#endif /* _SDL_config_macos_h */
     7.1 --- a/include/SDL_main.h	Thu Aug 10 14:35:42 2006 +0000
     7.2 +++ b/include/SDL_main.h	Thu Aug 10 14:54:23 2006 +0000
     7.3 @@ -29,7 +29,6 @@
     7.4  
     7.5  #if defined(__WIN32__) || \
     7.6      (defined(__MWERKS__) && !defined(__BEOS__)) || \
     7.7 -    defined(__MACOS__) || \
     7.8      defined(__SYMBIAN32__) || defined(QWS)
     7.9  
    7.10  #ifdef __cplusplus
    7.11 @@ -76,30 +75,6 @@
    7.12  #include "close_code.h"
    7.13  #endif
    7.14  
    7.15 -/* From the SDL library code -- needed for registering QuickDraw on MacOS */
    7.16 -#if defined(__MACOS__)
    7.17 -
    7.18 -#include "begin_code.h"
    7.19 -#ifdef __cplusplus
    7.20 -/* *INDENT-OFF* */
    7.21 -extern "C" {
    7.22 -/* *INDENT-ON* */
    7.23 -#endif
    7.24 -
    7.25 -/* Forward declaration so we don't need to include QuickDraw.h */
    7.26 -struct QDGlobals;
    7.27 -
    7.28 -/* This should be called from your main() function, if any */
    7.29 -extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd);
    7.30 -
    7.31 -#ifdef __cplusplus
    7.32 -/* *INDENT-OFF* */
    7.33 -}
    7.34 -/* *INDENT-ON* */
    7.35 -#endif
    7.36 -#include "close_code.h"
    7.37 -#endif
    7.38 -
    7.39  #endif /* Need to redefine main()? */
    7.40  
    7.41  #endif /* _SDL_main_h */
     8.1 --- a/include/SDL_opengl.h	Thu Aug 10 14:35:42 2006 +0000
     8.2 +++ b/include/SDL_opengl.h	Thu Aug 10 14:54:23 2006 +0000
     8.3 @@ -37,9 +37,6 @@
     8.4  #if defined(__MACOSX__)
     8.5  #include <OpenGL/gl.h>          /* Header File For The OpenGL Library */
     8.6  #include <OpenGL/glu.h>         /* Header File For The GLU Library */
     8.7 -#elif defined(__MACOS__)
     8.8 -#include <gl.h>                 /* Header File For The OpenGL Library */
     8.9 -#include <glu.h>                /* Header File For The GLU Library */
    8.10  #else
    8.11  #include <GL/gl.h>              /* Header File For The OpenGL Library */
    8.12  #include <GL/glu.h>             /* Header File For The GLU Library */
     9.1 --- a/include/begin_code.h	Thu Aug 10 14:35:42 2006 +0000
     9.2 +++ b/include/begin_code.h	Thu Aug 10 14:54:23 2006 +0000
     9.3 @@ -102,9 +102,6 @@
     9.4  #pragma nopackwarning
     9.5  #endif
     9.6  #pragma pack(push,4)
     9.7 -#elif (defined(__MWERKS__) && defined(__MACOS__))
     9.8 -#pragma options align=mac68k4byte
     9.9 -#pragma enumsalwaysint on
    9.10  #endif /* Compiler needs structure packing set */
    9.11  
    9.12  /* Set up compiler-specific options for inlining functions */
    10.1 --- a/include/close_code.h	Thu Aug 10 14:35:42 2006 +0000
    10.2 +++ b/include/close_code.h	Thu Aug 10 14:54:23 2006 +0000
    10.3 @@ -31,10 +31,5 @@
    10.4  #ifdef __BORLANDC__
    10.5  #pragma nopackwarning
    10.6  #endif
    10.7 -#if (defined(__MWERKS__) && defined(__MACOS__))
    10.8 -#pragma options align=reset
    10.9 -#pragma enumsalwaysint reset
   10.10 -#else
   10.11  #pragma pack(pop)
   10.12 -#endif
   10.13  #endif /* Compiler needs structure packing set */
    11.1 --- a/src/audio/SDL_audio.c	Thu Aug 10 14:35:42 2006 +0000
    11.2 +++ b/src/audio/SDL_audio.c	Thu Aug 10 14:54:23 2006 +0000
    11.3 @@ -532,9 +532,6 @@
    11.4          SDL_SetError("SDL_OpenAudio() passed a NULL callback");
    11.5          return (-1);
    11.6      }
    11.7 -#if defined(__MACOS__) || (defined(__RISCOS__) && SDL_THREADS_DISABLED)
    11.8 -    /* FIXME: Need to implement PPC interrupt asm for SDL_LockAudio() */
    11.9 -#else
   11.10  #if defined(__MINT__) && SDL_THREADS_DISABLED
   11.11      /* Uses interrupt driven audio, without thread */
   11.12  #else
   11.13 @@ -546,7 +543,6 @@
   11.14          return (-1);
   11.15      }
   11.16  #endif /* __MINT__ */
   11.17 -#endif /* __MACOS__ */
   11.18  
   11.19      /* Calculate the silence and size of the audio specification */
   11.20      SDL_CalculateAudioSpec(desired);
    12.1 --- a/src/cdrom/SDL_cdrom.c	Thu Aug 10 14:35:42 2006 +0000
    12.2 +++ b/src/cdrom/SDL_cdrom.c	Thu Aug 10 14:54:23 2006 +0000
    12.3 @@ -26,9 +26,7 @@
    12.4  #include "SDL_cdrom.h"
    12.5  #include "SDL_syscdrom.h"
    12.6  
    12.7 -#if !defined(__MACOS__)
    12.8  #define CLIP_FRAMES	10      /* Some CD-ROMs won't go all the way */
    12.9 -#endif
   12.10  
   12.11  static int SDL_cdinitted = 0;
   12.12  static SDL_CD *default_cdrom;
    13.1 --- a/src/cdrom/SDL_syscdrom.h	Thu Aug 10 14:35:42 2006 +0000
    13.2 +++ b/src/cdrom/SDL_syscdrom.h	Thu Aug 10 14:54:23 2006 +0000
    13.3 @@ -74,4 +74,5 @@
    13.4  
    13.5  /* Function to perform any system-specific CD-ROM related cleanup */
    13.6  extern void SDL_SYS_CDQuit(void);
    13.7 +
    13.8  /* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/src/cdrom/macos/SDL_syscdrom.c	Thu Aug 10 14:35:42 2006 +0000
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,543 +0,0 @@
    14.4 -/*
    14.5 -    SDL - Simple DirectMedia Layer
    14.6 -    Copyright (C) 1997-2006 Sam Lantinga
    14.7 -
    14.8 -    This library is free software; you can redistribute it and/or
    14.9 -    modify it under the terms of the GNU Lesser General Public
   14.10 -    License as published by the Free Software Foundation; either
   14.11 -    version 2.1 of the License, or (at your option) any later version.
   14.12 -
   14.13 -    This library is distributed in the hope that it will be useful,
   14.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14.16 -    Lesser General Public License for more details.
   14.17 -
   14.18 -    You should have received a copy of the GNU Lesser General Public
   14.19 -    License along with this library; if not, write to the Free Software
   14.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   14.21 -
   14.22 -    Sam Lantinga
   14.23 -    slouken@libsdl.org
   14.24 -*/
   14.25 -#include "SDL_config.h"
   14.26 -
   14.27 -#ifdef SDL_CDROM_MACOS
   14.28 -
   14.29 -/* MacOS functions for system-level CD-ROM audio control */
   14.30 -
   14.31 -#include <Devices.h>
   14.32 -#include <Files.h>
   14.33 -#include <LowMem.h>             /* Use entry table macros, not functions in InterfaceLib  */
   14.34 -
   14.35 -#include "SDL_cdrom.h"
   14.36 -#include "../SDL_syscdrom.h"
   14.37 -#include "SDL_syscdrom_c.h"
   14.38 -
   14.39 -/* Added by Matt Slot */
   14.40 -#if !defined(LMGetUnitTableEntryCount)
   14.41 -#define LMGetUnitTableEntryCount()   *(short *)0x01D2
   14.42 -#endif
   14.43 -
   14.44 -/* The maximum number of CD-ROM drives we'll detect */
   14.45 -#define MAX_DRIVES	26
   14.46 -
   14.47 -/* A list of available CD-ROM drives */
   14.48 -static long SDL_cdversion = 0;
   14.49 -static struct
   14.50 -{
   14.51 -    short dRefNum;
   14.52 -    short driveNum;
   14.53 -    long frames;
   14.54 -    char name[256];
   14.55 -    Boolean hasAudio;
   14.56 -} SDL_cdlist[MAX_DRIVES];
   14.57 -static StringPtr gDriverName = "\p.AppleCD";
   14.58 -
   14.59 -/* The system-dependent CD control functions */
   14.60 -static const char *SDL_SYS_CDName(int drive);
   14.61 -static int SDL_SYS_CDOpen(int drive);
   14.62 -static int SDL_SYS_CDGetTOC(SDL_CD * cdrom);
   14.63 -static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position);
   14.64 -static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length);
   14.65 -static int SDL_SYS_CDPause(SDL_CD * cdrom);
   14.66 -static int SDL_SYS_CDResume(SDL_CD * cdrom);
   14.67 -static int SDL_SYS_CDStop(SDL_CD * cdrom);
   14.68 -static int SDL_SYS_CDEject(SDL_CD * cdrom);
   14.69 -static void SDL_SYS_CDClose(SDL_CD * cdrom);
   14.70 -
   14.71 -static short
   14.72 -SDL_SYS_ShortToBCD(short value)
   14.73 -{
   14.74 -    return ((value % 10) + (value / 10) * 0x10);        /* Convert value to BCD */
   14.75 -}
   14.76 -
   14.77 -static short
   14.78 -SDL_SYS_BCDToShort(short value)
   14.79 -{
   14.80 -    return ((value % 0x10) + (value / 0x10) * 10);      /* Convert value from BCD */
   14.81 -}
   14.82 -
   14.83 -int
   14.84 -SDL_SYS_CDInit(void)
   14.85 -{
   14.86 -    SInt16 dRefNum = 0;
   14.87 -    SInt16 first, last;
   14.88 -
   14.89 -    SDL_numcds = 0;
   14.90 -
   14.91 -    /* Check that the software is available */
   14.92 -    if (Gestalt(kGestaltAudioCDSelector, &SDL_cdversion) || !SDL_cdversion)
   14.93 -        return (0);
   14.94 -
   14.95 -    /* Fill in our driver capabilities */
   14.96 -    SDL_CDcaps.Name = SDL_SYS_CDName;
   14.97 -    SDL_CDcaps.Open = SDL_SYS_CDOpen;
   14.98 -    SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
   14.99 -    SDL_CDcaps.Status = SDL_SYS_CDStatus;
  14.100 -    SDL_CDcaps.Play = SDL_SYS_CDPlay;
  14.101 -    SDL_CDcaps.Pause = SDL_SYS_CDPause;
  14.102 -    SDL_CDcaps.Resume = SDL_SYS_CDResume;
  14.103 -    SDL_CDcaps.Stop = SDL_SYS_CDStop;
  14.104 -    SDL_CDcaps.Eject = SDL_SYS_CDEject;
  14.105 -    SDL_CDcaps.Close = SDL_SYS_CDClose;
  14.106 -
  14.107 -    /* Walk the list, count each AudioCD driver, and save the refnums */
  14.108 -    first = -1;
  14.109 -    last = 0 - LMGetUnitTableEntryCount();
  14.110 -    for (dRefNum = first; dRefNum >= last; dRefNum--) {
  14.111 -        Str255 driverName;
  14.112 -        StringPtr namePtr;
  14.113 -        DCtlHandle deviceEntry;
  14.114 -
  14.115 -        deviceEntry = GetDCtlEntry(dRefNum);
  14.116 -        if (!deviceEntry)
  14.117 -            continue;
  14.118 -
  14.119 -        /* Is this an .AppleCD ? */
  14.120 -        namePtr = (*deviceEntry)->dCtlFlags & (1L << dRAMBased) ?
  14.121 -            ((StringPtr) ((DCtlPtr) deviceEntry)->dCtlDriver + 18) :
  14.122 -            ((StringPtr) (*deviceEntry)->dCtlDriver + 18);
  14.123 -        BlockMoveData(namePtr, driverName, namePtr[0] + 1);
  14.124 -        if (driverName[0] > gDriverName[0])
  14.125 -            driverName[0] = gDriverName[0];
  14.126 -        if (!EqualString(driverName, gDriverName, false, false))
  14.127 -            continue;
  14.128 -
  14.129 -        /* Record the basic info for each drive */
  14.130 -        SDL_cdlist[SDL_numcds].dRefNum = dRefNum;
  14.131 -        BlockMoveData(namePtr + 1, SDL_cdlist[SDL_numcds].name, namePtr[0]);
  14.132 -        SDL_cdlist[SDL_numcds].name[namePtr[0]] = 0;
  14.133 -        SDL_cdlist[SDL_numcds].hasAudio = false;
  14.134 -        SDL_numcds++;
  14.135 -    }
  14.136 -    return (0);
  14.137 -}
  14.138 -
  14.139 -static const char *
  14.140 -SDL_SYS_CDName(int drive)
  14.141 -{
  14.142 -    return (SDL_cdlist[drive].name);
  14.143 -}
  14.144 -
  14.145 -static int
  14.146 -get_drivenum(int drive)
  14.147 -{
  14.148 -    QHdr *driveQ = GetDrvQHdr();
  14.149 -    DrvQEl *driveElem;
  14.150 -
  14.151 -    /* Update the drive number */
  14.152 -    SDL_cdlist[drive].driveNum = 0;
  14.153 -    if (driveQ->qTail) {
  14.154 -        driveQ->qTail->qLink = 0;
  14.155 -    }
  14.156 -    for (driveElem = (DrvQEl *) driveQ->qHead; driveElem;
  14.157 -         driveElem = (DrvQEl *) driveElem->qLink) {
  14.158 -        if (driveElem->dQRefNum == SDL_cdlist[drive].dRefNum) {
  14.159 -            SDL_cdlist[drive].driveNum = driveElem->dQDrive;
  14.160 -            break;
  14.161 -        }
  14.162 -    }
  14.163 -    return (SDL_cdlist[drive].driveNum);
  14.164 -}
  14.165 -
  14.166 -static int
  14.167 -SDL_SYS_CDOpen(int drive)
  14.168 -{
  14.169 -    return (drive);
  14.170 -}
  14.171 -
  14.172 -static int
  14.173 -SDL_SYS_CDGetTOC(SDL_CD * cdrom)
  14.174 -{
  14.175 -    CDCntrlParam cdpb;
  14.176 -    CDTrackData tracks[SDL_MAX_TRACKS];
  14.177 -    long i, leadout;
  14.178 -
  14.179 -    /* Get the number of tracks on the CD by examining the TOC */
  14.180 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.181 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.182 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.183 -    cdpb.csCode = kReadTOC;
  14.184 -    cdpb.csParam.words[0] = kGetTrackRange;
  14.185 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.186 -        SDL_SetError("PBControlSync() failed");
  14.187 -        return (-1);
  14.188 -    }
  14.189 -
  14.190 -    cdrom->numtracks =
  14.191 -        SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]) -
  14.192 -        SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]) + 1;
  14.193 -    if (cdrom->numtracks > SDL_MAX_TRACKS)
  14.194 -        cdrom->numtracks = SDL_MAX_TRACKS;
  14.195 -    cdrom->status = CD_STOPPED;
  14.196 -    cdrom->cur_track = 0;       /* Apparently these are set elsewhere */
  14.197 -    cdrom->cur_frame = 0;       /* Apparently these are set elsewhere */
  14.198 -
  14.199 -
  14.200 -    /* Get the lead out area of the CD by examining the TOC */
  14.201 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.202 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.203 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.204 -    cdpb.csCode = kReadTOC;
  14.205 -    cdpb.csParam.words[0] = kGetLeadOutArea;
  14.206 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.207 -        SDL_SetError("PBControlSync() failed");
  14.208 -        return (-1);
  14.209 -    }
  14.210 -
  14.211 -    leadout = MSF_TO_FRAMES(SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]),
  14.212 -                            SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]),
  14.213 -                            SDL_SYS_BCDToShort(cdpb.csParam.bytes[2]));
  14.214 -
  14.215 -    /* Get an array of track locations by examining the TOC */
  14.216 -    SDL_memset(tracks, 0, sizeof(tracks));
  14.217 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.218 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.219 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.220 -    cdpb.csCode = kReadTOC;
  14.221 -    cdpb.csParam.words[0] = kGetTrackEntries;   /* Type of Query */
  14.222 -    *((long *) (cdpb.csParam.words + 1)) = (long) tracks;
  14.223 -    cdpb.csParam.words[3] = cdrom->numtracks * sizeof(tracks[0]);
  14.224 -    *((char *) (cdpb.csParam.words + 4)) = 1;   /* First track */
  14.225 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.226 -        SDL_SetError("PBControlSync() failed");
  14.227 -        return (-1);
  14.228 -    }
  14.229 -
  14.230 -    /* Read all the track TOC entries */
  14.231 -    SDL_cdlist[cdrom->id].hasAudio = false;
  14.232 -    for (i = 0; i < cdrom->numtracks; ++i) {
  14.233 -        cdrom->track[i].id = i + 1;
  14.234 -        if (tracks[i].entry.control & kDataTrackMask)
  14.235 -            cdrom->track[i].type = SDL_DATA_TRACK;
  14.236 -        else {
  14.237 -            cdrom->track[i].type = SDL_AUDIO_TRACK;
  14.238 -            SDL_cdlist[SDL_numcds].hasAudio = true;
  14.239 -        }
  14.240 -
  14.241 -        cdrom->track[i].offset =
  14.242 -            MSF_TO_FRAMES(SDL_SYS_BCDToShort(tracks[i].entry.min),
  14.243 -                          SDL_SYS_BCDToShort(tracks[i].entry.min),
  14.244 -                          SDL_SYS_BCDToShort(tracks[i].entry.frame));
  14.245 -        cdrom->track[i].length =
  14.246 -            MSF_TO_FRAMES(SDL_SYS_BCDToShort(tracks[i + 1].entry.min),
  14.247 -                          SDL_SYS_BCDToShort(tracks[i + 1].entry.min),
  14.248 -                          SDL_SYS_BCDToShort(tracks[i + 1].entry.frame)) -
  14.249 -            cdrom->track[i].offset;
  14.250 -    }
  14.251 -
  14.252 -    /* Apparently SDL wants a fake last entry */
  14.253 -    cdrom->track[i].offset = leadout;
  14.254 -    cdrom->track[i].length = 0;
  14.255 -
  14.256 -    return (0);
  14.257 -}
  14.258 -
  14.259 -/* Get CD-ROM status */
  14.260 -static CDstatus
  14.261 -SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
  14.262 -{
  14.263 -    CDCntrlParam cdpb;
  14.264 -    CDstatus status = CD_ERROR;
  14.265 -    Boolean spinning = false;
  14.266 -
  14.267 -    if (position)
  14.268 -        *position = 0;
  14.269 -
  14.270 -    /* Get the number of tracks on the CD by examining the TOC */
  14.271 -    if (!get_drivenum(cdrom->id)) {
  14.272 -        return (CD_TRAYEMPTY);
  14.273 -    }
  14.274 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.275 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.276 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.277 -    cdpb.csCode = kReadTOC;
  14.278 -    cdpb.csParam.words[0] = kGetTrackRange;
  14.279 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.280 -        SDL_SetError("PBControlSync() failed");
  14.281 -        return (CD_ERROR);
  14.282 -    }
  14.283 -
  14.284 -    cdrom->numtracks =
  14.285 -        SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]) -
  14.286 -        SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]) + 1;
  14.287 -    if (cdrom->numtracks > SDL_MAX_TRACKS)
  14.288 -        cdrom->numtracks = SDL_MAX_TRACKS;
  14.289 -    cdrom->cur_track = 0;       /* Apparently these are set elsewhere */
  14.290 -    cdrom->cur_frame = 0;       /* Apparently these are set elsewhere */
  14.291 -
  14.292 -
  14.293 -    if (1 || SDL_cdlist[cdrom->id].hasAudio) {
  14.294 -        /* Get the current playback status */
  14.295 -        SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.296 -        cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.297 -        cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.298 -        cdpb.csCode = kAudioStatus;
  14.299 -        if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.300 -            SDL_SetError("PBControlSync() failed");
  14.301 -            return (-1);
  14.302 -        }
  14.303 -
  14.304 -        switch (cdpb.csParam.cd.status) {
  14.305 -        case kStatusPlaying:
  14.306 -            status = CD_PLAYING;
  14.307 -            spinning = true;
  14.308 -            break;
  14.309 -        case kStatusPaused:
  14.310 -            status = CD_PAUSED;
  14.311 -            spinning = true;
  14.312 -            break;
  14.313 -        case kStatusMuted:
  14.314 -            status = CD_PLAYING;        /* What should I do here? */
  14.315 -            spinning = true;
  14.316 -            break;
  14.317 -        case kStatusDone:
  14.318 -            status = CD_STOPPED;
  14.319 -            spinning = true;
  14.320 -            break;
  14.321 -        case kStatusStopped:
  14.322 -            status = CD_STOPPED;
  14.323 -            spinning = false;
  14.324 -            break;
  14.325 -        case kStatusError:
  14.326 -        default:
  14.327 -            status = CD_ERROR;
  14.328 -            spinning = false;
  14.329 -            break;
  14.330 -        }
  14.331 -
  14.332 -        if (spinning && position)
  14.333 -            *position =
  14.334 -                MSF_TO_FRAMES(SDL_SYS_BCDToShort(cdpb.csParam.cd.minute),
  14.335 -                              SDL_SYS_BCDToShort(cdpb.csParam.cd.second),
  14.336 -                              SDL_SYS_BCDToShort(cdpb.csParam.cd.frame));
  14.337 -    } else
  14.338 -        status = CD_ERROR;      /* What should I do here? */
  14.339 -
  14.340 -    return (status);
  14.341 -}
  14.342 -
  14.343 -/* Start play */
  14.344 -static int
  14.345 -SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
  14.346 -{
  14.347 -    CDCntrlParam cdpb;
  14.348 -
  14.349 -    /* Pause the current audio playback to avoid audible artifacts */
  14.350 -    if (SDL_SYS_CDPause(cdrom) < 0) {
  14.351 -        return (-1);
  14.352 -    }
  14.353 -
  14.354 -    /* Specify the AudioCD playback mode */
  14.355 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.356 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.357 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.358 -    cdpb.csCode = kSetPlayMode;
  14.359 -    cdpb.csParam.bytes[0] = false;      /* Repeat? */
  14.360 -    cdpb.csParam.bytes[1] = kPlayModeSequential;        /* Play mode */
  14.361 -    /* Treat as soft error, NEC Drive doesnt support this call  */
  14.362 -    PBControlSync((ParmBlkPtr) & cdpb);
  14.363 -
  14.364 -#if 1
  14.365 -    /* Specify the end of audio playback */
  14.366 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.367 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.368 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.369 -    cdpb.csCode = kAudioStop;
  14.370 -    cdpb.csParam.words[0] = kBlockPosition;     /* Position Mode */
  14.371 -    *(long *) (cdpb.csParam.words + 1) = start + length - 1;    /* Search Address */
  14.372 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.373 -        SDL_SetError("PBControlSync() failed");
  14.374 -        return (-1);
  14.375 -    }
  14.376 -
  14.377 -    /* Specify the start of audio playback, and start it */
  14.378 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.379 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.380 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.381 -    cdpb.csCode = kAudioPlay;
  14.382 -    cdpb.csParam.words[0] = kBlockPosition;     /* Position Mode */
  14.383 -    *(long *) (cdpb.csParam.words + 1) = start + 1;     /* Search Address */
  14.384 -    cdpb.csParam.words[3] = false;      /* Stop address? */
  14.385 -    cdpb.csParam.words[4] = kStereoPlayMode;    /* Audio Play Mode */
  14.386 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.387 -        SDL_SetError("PBControlSync() failed");
  14.388 -        return (-1);
  14.389 -    }
  14.390 -#else
  14.391 -    /* Specify the end of audio playback */
  14.392 -    FRAMES_TO_MSF(start + length, &m, &s, &f);
  14.393 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.394 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.395 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.396 -    cdpb.csCode = kAudioStop;
  14.397 -    cdpb.csParam.words[0] = kTrackPosition;     /* Position Mode */
  14.398 -    cdpb.csParam.words[1] = 0;  /* Search Address (hiword) */
  14.399 -    cdpb.csParam.words[2] =     /* Search Address (loword) */
  14.400 -        SDL_SYS_ShortToBCD(cdrom->numtracks);
  14.401 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.402 -        SDL_SetError("PBControlSync() failed");
  14.403 -        return (-1);
  14.404 -    }
  14.405 -
  14.406 -    /* Specify the start of audio playback, and start it */
  14.407 -    FRAMES_TO_MSF(start, &m, &s, &f);
  14.408 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.409 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.410 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.411 -    cdpb.csCode = kAudioPlay;
  14.412 -    cdpb.csParam.words[0] = kTrackPosition;     /* Position Mode */
  14.413 -    cdpb.csParam.words[1] = 0;  /* Search Address (hiword) */
  14.414 -    cdpb.csParam.words[2] = SDL_SYS_ShortToBCD(1);      /* Search Address (loword) */
  14.415 -    cdpb.csParam.words[3] = false;      /* Stop address? */
  14.416 -    cdpb.csParam.words[4] = kStereoPlayMode;    /* Audio Play Mode */
  14.417 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.418 -        SDL_SetError("PBControlSync() failed");
  14.419 -        return (-1);
  14.420 -    }
  14.421 -#endif
  14.422 -
  14.423 -    return (0);
  14.424 -}
  14.425 -
  14.426 -/* Pause play */
  14.427 -static int
  14.428 -SDL_SYS_CDPause(SDL_CD * cdrom)
  14.429 -{
  14.430 -    CDCntrlParam cdpb;
  14.431 -
  14.432 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.433 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.434 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.435 -    cdpb.csCode = kAudioPause;
  14.436 -    cdpb.csParam.words[0] = 0;  /* Pause/Continue Flag (hiword) */
  14.437 -    cdpb.csParam.words[1] = 1;  /* Pause/Continue Flag (loword) */
  14.438 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.439 -        SDL_SetError("PBControlSync() failed");
  14.440 -        return (-1);
  14.441 -    }
  14.442 -    return (0);
  14.443 -}
  14.444 -
  14.445 -/* Resume play */
  14.446 -static int
  14.447 -SDL_SYS_CDResume(SDL_CD * cdrom)
  14.448 -{
  14.449 -    CDCntrlParam cdpb;
  14.450 -
  14.451 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.452 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.453 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.454 -    cdpb.csCode = kAudioPause;
  14.455 -    cdpb.csParam.words[0] = 0;  /* Pause/Continue Flag (hiword) */
  14.456 -    cdpb.csParam.words[1] = 0;  /* Pause/Continue Flag (loword) */
  14.457 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.458 -        SDL_SetError("PBControlSync() failed");
  14.459 -        return (-1);
  14.460 -    }
  14.461 -    return (0);
  14.462 -}
  14.463 -
  14.464 -/* Stop play */
  14.465 -static int
  14.466 -SDL_SYS_CDStop(SDL_CD * cdrom)
  14.467 -{
  14.468 -    CDCntrlParam cdpb;
  14.469 -
  14.470 -    SDL_memset(&cdpb, 0, sizeof(cdpb));
  14.471 -    cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  14.472 -    cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.473 -    cdpb.csCode = kAudioStop;
  14.474 -    cdpb.csParam.words[0] = 0;  /* Position Mode */
  14.475 -    cdpb.csParam.words[1] = 0;  /* Search Address (hiword) */
  14.476 -    cdpb.csParam.words[2] = 0;  /* Search Address (loword) */
  14.477 -    if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) {
  14.478 -        SDL_SetError("PBControlSync() failed");
  14.479 -        return (-1);
  14.480 -    }
  14.481 -    return (0);
  14.482 -}
  14.483 -
  14.484 -/* Eject the CD-ROM */
  14.485 -static int
  14.486 -SDL_SYS_CDEject(SDL_CD * cdrom)
  14.487 -{
  14.488 -    Boolean disk = false;
  14.489 -    QHdr *driveQ = GetDrvQHdr();
  14.490 -    DrvQEl *driveElem;
  14.491 -    HParamBlockRec hpb;
  14.492 -    ParamBlockRec cpb;
  14.493 -
  14.494 -    for (driveElem = (DrvQEl *) driveQ->qHead; driveElem; driveElem =
  14.495 -         (driveElem) ? ((DrvQEl *) driveElem->qLink) :
  14.496 -         ((DrvQEl *) driveQ->qHead)) {
  14.497 -        if (driveQ->qTail) {
  14.498 -            driveQ->qTail->qLink = 0;
  14.499 -        }
  14.500 -        if (driveElem->dQRefNum != SDL_cdlist[cdrom->id].dRefNum) {
  14.501 -            continue;
  14.502 -        }
  14.503 -
  14.504 -        /* Does drive contain mounted volume? If not, skip */
  14.505 -        SDL_memset(&hpb, 0, sizeof(hpb));
  14.506 -        hpb.volumeParam.ioVRefNum = driveElem->dQDrive;
  14.507 -        if (PBHGetVInfoSync(&hpb) != noErr) {
  14.508 -            continue;
  14.509 -        }
  14.510 -        if ((UnmountVol(0, driveElem->dQDrive) == noErr) &&
  14.511 -            (Eject(0, driveElem->dQDrive) == noErr)) {
  14.512 -            driveElem = 0;      /* Clear pointer to reset our loop */
  14.513 -            disk = true;
  14.514 -        }
  14.515 -    }
  14.516 -
  14.517 -    /* If no disk is present, just eject the tray */
  14.518 -    if (!disk) {
  14.519 -        SDL_memset(&cpb, 0, sizeof(cpb));
  14.520 -        cpb.cntrlParam.ioVRefNum = 0;   /* No Drive */
  14.521 -        cpb.cntrlParam.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  14.522 -        cpb.cntrlParam.csCode = kEjectTheDisc;
  14.523 -        if (PBControlSync((ParmBlkPtr) & cpb) != noErr) {
  14.524 -            SDL_SetError("PBControlSync() failed");
  14.525 -            return (-1);
  14.526 -        }
  14.527 -    }
  14.528 -    return (0);
  14.529 -}
  14.530 -
  14.531 -/* Close the CD-ROM handle */
  14.532 -static void
  14.533 -SDL_SYS_CDClose(SDL_CD * cdrom)
  14.534 -{
  14.535 -    return;
  14.536 -}
  14.537 -
  14.538 -void
  14.539 -SDL_SYS_CDQuit(void)
  14.540 -{
  14.541 -    while (SDL_numcds--)
  14.542 -        SDL_memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0]));
  14.543 -}
  14.544 -
  14.545 -#endif /* SDL_CDROM_MACOS */
  14.546 -/* vi: set ts=4 sw=4 expandtab: */
    15.1 --- a/src/cdrom/macos/SDL_syscdrom_c.h	Thu Aug 10 14:35:42 2006 +0000
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,146 +0,0 @@
    15.4 -/*
    15.5 -    SDL - Simple DirectMedia Layer
    15.6 -    Copyright (C) 1997-2004 Sam Lantinga
    15.7 -
    15.8 -    This library is free software; you can redistribute it and/or
    15.9 -    modify it under the terms of the GNU Library General Public
   15.10 -    License as published by the Free Software Foundation; either
   15.11 -    version 2 of the License, or (at your option) any later version.
   15.12 -
   15.13 -    This library is distributed in the hope that it will be useful,
   15.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15.16 -    Library General Public License for more details.
   15.17 -
   15.18 -    You should have received a copy of the GNU Library General Public
   15.19 -    License along with this library; if not, write to the Free
   15.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   15.21 -
   15.22 -    Sam Lantinga
   15.23 -    slouken@libsdl.org
   15.24 -*/
   15.25 -#include "SDL_config.h"
   15.26 -
   15.27 -/* This is the MacOS specific header for the SDL CD-ROM API
   15.28 -   Contributed by Matt Slot
   15.29 - */
   15.30 -
   15.31 -/* AppleCD Control calls */
   15.32 -#define kVerifyTheDisc   	  5     /* Returns noErr if there is disc inserted */
   15.33 -#define kEjectTheDisc   	  7     /* Eject disc from drive */
   15.34 -#define kUserEject    		 80     /* Enable/disable the CD-ROM eject button */
   15.35 -#define kReadTOC    		100     /* Extract various TOC information from the disc */
   15.36 -#define kReadQ   			101     /* Extract Q subcode info for the current track */
   15.37 -#define kAudioTrackSearch   103 /* Start playback from the indicated position */
   15.38 -#define kAudioPlay    		104     /* Start playback from the indicated position */
   15.39 -#define kAudioPause    		105     /* Pause/continue the playback */
   15.40 -#define kAudioStop    		106     /* Stop playback at the indicated position */
   15.41 -#define kAudioStatus    	107     /* Return audio play status */
   15.42 -#define kAudioControl    	109     /* Set the output volume for the audio channels */
   15.43 -#define kReadAudioVolume   	112     /* Get the output volume for the audio channels */
   15.44 -#define kSetTrackList   	122     /* Set the track program for the audio CD to play */
   15.45 -#define kGetTrackList   	123     /* Get the track program the audio CD is playing */
   15.46 -#define kGetTrackIndex   	124     /* Get the track index the audio CD is playing */
   15.47 -#define kSetPlayMode   		125     /* Set the audio tracks play mode */
   15.48 -#define kGetPlayMode   		126     /* Get the audio tracks play mode */
   15.49 -
   15.50 -/* AppleCD Status calls */
   15.51 -#define kGetDriveType   	 96     /* Get the type of the physical CD-ROM drive */
   15.52 -#define kWhoIsThere    		 97     /* Get a bitmap of SCSI IDs the driver controls */
   15.53 -#define kGetBlockSize    	 98     /* Get current block size of the CD-ROM drive */
   15.54 -
   15.55 -/* AppleCD other constants */
   15.56 -#define kBlockPosition    	  0     /* Position at the specified logical block number */
   15.57 -#define kAbsMSFPosition    	  1     /* Position at the specified Min/Sec/Frame (in BCD) */
   15.58 -#define kTrackPosition    	  2     /* Position at the specified track number (in BCD) */
   15.59 -#define kIndexPosition    	  3     /* Position at the nth track in program (in BCD) */
   15.60 -
   15.61 -#define kMutedPlayMode   	  0     /* Play the audio track with no output */
   15.62 -#define kStereoPlayMode   	  9     /* Play the audio track in normal stereo */
   15.63 -
   15.64 -#define kControlFieldMask  	0x0D    /* Bits 3,2,0 in the nibble */
   15.65 -#define kDataTrackMask   	0x04    /* Indicates Data Track */
   15.66 -
   15.67 -#define kGetTrackRange    	  1     /* Query TOC for track numbers */
   15.68 -#define kGetLeadOutArea    	  2     /* Query TOC for "Lead Out" end of audio data */
   15.69 -#define kGetTrackEntries   	  3     /* Query TOC for track starts and data types */
   15.70 -
   15.71 -#define kStatusPlaying		  0     /* Audio Play operation in progress */
   15.72 -#define kStatusPaused		  1     /* CD-ROM device in Hold Track ("Pause") state */
   15.73 -#define kStatusMuted		  2     /* MUTING-ON operation in progress */
   15.74 -#define kStatusDone			  3     /* Audio Play completed */
   15.75 -#define kStatusError		  4     /* Error occurred during audio play operation */
   15.76 -#define kStatusStopped		  5     /* Audio play operation not requested */
   15.77 -
   15.78 -#define kPlayModeSequential	  0     /*  Play tracks in order */
   15.79 -#define kPlayModeShuffled	  1     /* Play tracks randomly */
   15.80 -#define kPlayModeProgrammed   2 /* Use custom playlist */
   15.81 -
   15.82 -/* AppleCD Gestalt selectors */
   15.83 -#define kGestaltAudioCDSelector    'aucd'
   15.84 -#define kDriverVersion52   		0x00000520
   15.85 -#define kDriverVersion51   		0x00000510
   15.86 -#define kDriverVersion50   		0x00000500
   15.87 -
   15.88 -/* Drive type constants */
   15.89 -#define kDriveAppleCD_SC   				  1
   15.90 -#define kDriveAppleCD_SCPlus_or_150   	  2
   15.91 -#define kDriveAppleCD_300_or_300Plus   	  3
   15.92 -
   15.93 -/* Misc constants */
   15.94 -#define kFirstSCSIDevice   	 -33
   15.95 -#define kLastSCSIDevice    	 -40
   15.96 -
   15.97 -#if PRAGMA_STRUCT_ALIGN
   15.98 -#pragma options align=mac68k
   15.99 -#endif
  15.100 -
  15.101 -/* AppleCD driver parameter block */
  15.102 -typedef struct CDCntrlParam
  15.103 -{
  15.104 -    QElemPtr qLink;
  15.105 -    short qType;
  15.106 -    short ioTrap;
  15.107 -    Ptr ioCmdAddr;
  15.108 -    IOCompletionUPP ioCompletion;
  15.109 -    OSErr ioResult;
  15.110 -    StringPtr ioNamePtr;
  15.111 -    short ioVRefNum;
  15.112 -    short ioCRefNum;
  15.113 -    short csCode;
  15.114 -
  15.115 -    union
  15.116 -    {
  15.117 -        long longs[6];
  15.118 -        short words[11];
  15.119 -        unsigned char bytes[22];
  15.120 -        struct
  15.121 -        {
  15.122 -            unsigned char status;
  15.123 -            unsigned char play;
  15.124 -            unsigned char control;
  15.125 -            unsigned char minute;
  15.126 -            unsigned char second;
  15.127 -            unsigned char frame;
  15.128 -        } cd;
  15.129 -    } csParam;
  15.130 -
  15.131 -} CDCntrlParam, *CDCntrlParamPtr;
  15.132 -
  15.133 -typedef union CDTrackData
  15.134 -{
  15.135 -    long value;                 /* Treat as a longword value */
  15.136 -    struct
  15.137 -    {
  15.138 -        unsigned char reserved:4;       /* Unused by AppleCD driver  */
  15.139 -        unsigned char control:4;        /* Track flags (data track?) */
  15.140 -        unsigned char min;      /* Start of track (BCD)      */
  15.141 -        unsigned char sec;      /* Start of track (BCD)      */
  15.142 -        unsigned char frame;    /* Start of track (BCD)      */
  15.143 -    } entry;                    /* Broken into fields        */
  15.144 -} CDTrackData, *CDTrackPtr;
  15.145 -
  15.146 -#if PRAGMA_STRUCT_ALIGN
  15.147 -#pragma options align=reset
  15.148 -#endif
  15.149 -/* vi: set ts=4 sw=4 expandtab: */
    16.1 --- a/src/events/SDL_events.c	Thu Aug 10 14:35:42 2006 +0000
    16.2 +++ b/src/events/SDL_events.c	Thu Aug 10 14:54:23 2006 +0000
    16.3 @@ -157,11 +157,7 @@
    16.4  #if !SDL_THREADS_DISABLED
    16.5      SDL_EventQ.lock = SDL_CreateMutex();
    16.6      if (SDL_EventQ.lock == NULL) {
    16.7 -#ifdef __MACOS__                /* MacOS classic you can't multithread, so no lock needed */
    16.8 -        ;
    16.9 -#else
   16.10          return (-1);
   16.11 -#endif
   16.12      }
   16.13  #endif /* !SDL_THREADS_DISABLED */
   16.14      SDL_EventQ.active = 1;
    17.1 --- a/src/events/SDL_sysevents.h	Thu Aug 10 14:35:42 2006 +0000
    17.2 +++ b/src/events/SDL_sysevents.h	Thu Aug 10 14:54:23 2006 +0000
    17.3 @@ -37,11 +37,8 @@
    17.4  #define CANT_THREAD_EVENTS
    17.5  #endif
    17.6  
    17.7 -#ifdef __MACOS__                /* MacOS 7/8 don't support preemptive multi-tasking */
    17.8 -#define CANT_THREAD_EVENTS
    17.9 -#endif
   17.10 -
   17.11  #ifdef __OS2__                  /* The OS/2 event loop runs in a separate thread */
   17.12  #define MUST_THREAD_EVENTS
   17.13  #endif
   17.14 +
   17.15  /* vi: set ts=4 sw=4 expandtab: */
    18.1 --- a/src/file/SDL_rwops.c	Thu Aug 10 14:35:42 2006 +0000
    18.2 +++ b/src/file/SDL_rwops.c	Thu Aug 10 14:54:23 2006 +0000
    18.3 @@ -349,51 +349,6 @@
    18.4  
    18.5  /* Functions to create SDL_RWops structures from various data sources */
    18.6  
    18.7 -#ifdef __MACOS__
    18.8 -/*
    18.9 - * translate unix-style slash-separated filename to mac-style colon-separated
   18.10 - * name; return malloced string
   18.11 - */
   18.12 -static char *
   18.13 -unix_to_mac(const char *file)
   18.14 -{
   18.15 -    int flen = SDL_strlen(file);
   18.16 -    char *path = SDL_malloc(flen + 2);
   18.17 -    const char *src = file;
   18.18 -    char *dst = path;
   18.19 -    if (*src == '/') {
   18.20 -        /* really depends on filesystem layout, hope for the best */
   18.21 -        src++;
   18.22 -    } else {
   18.23 -        /* Check if this is a MacOS path to begin with */
   18.24 -        if (*src != ':')
   18.25 -            *dst++ = ':';       /* relative paths begin with ':' */
   18.26 -    }
   18.27 -    while (src < file + flen) {
   18.28 -        const char *end = SDL_strchr(src, '/');
   18.29 -        int len;
   18.30 -        if (!end)
   18.31 -            end = file + flen;  /* last component */
   18.32 -        len = end - src;
   18.33 -        if (len == 0 || (len == 1 && src[0] == '.')) {
   18.34 -            /* remove repeated slashes and . */
   18.35 -        } else {
   18.36 -            if (len == 2 && src[0] == '.' && src[1] == '.') {
   18.37 -                /* replace .. with the empty string */
   18.38 -            } else {
   18.39 -                SDL_memcpy(dst, src, len);
   18.40 -                dst += len;
   18.41 -            }
   18.42 -            if (end < file + flen)
   18.43 -                *dst++ = ':';
   18.44 -        }
   18.45 -        src = end + 1;
   18.46 -    }
   18.47 -    *dst++ = '\0';
   18.48 -    return path;
   18.49 -}
   18.50 -#endif /* __MACOS__ */
   18.51 -
   18.52  SDL_RWops *
   18.53  SDL_RWFromFile(const char *file, const char *mode)
   18.54  {
   18.55 @@ -421,15 +376,7 @@
   18.56  
   18.57  #elif HAVE_STDIO_H
   18.58  
   18.59 -#ifdef __MACOS__
   18.60 -    {
   18.61 -        char *mpath = unix_to_mac(file);
   18.62 -        fp = fopen(mpath, mode);
   18.63 -        SDL_free(mpath);
   18.64 -    }
   18.65 -#else
   18.66      fp = fopen(file, mode);
   18.67 -#endif
   18.68      if (fp == NULL) {
   18.69          SDL_SetError("Couldn't open %s", file);
   18.70      } else {
    19.1 --- a/src/joystick/SDL_sysjoystick.h	Thu Aug 10 14:35:42 2006 +0000
    19.2 +++ b/src/joystick/SDL_sysjoystick.h	Thu Aug 10 14:54:23 2006 +0000
    19.3 @@ -81,4 +81,5 @@
    19.4  
    19.5  /* Function to perform any system-specific joystick related cleanup */
    19.6  extern void SDL_SYS_JoystickQuit(void);
    19.7 +
    19.8  /* vi: set ts=4 sw=4 expandtab: */
    20.1 --- a/src/joystick/macos/SDL_sysjoystick.c	Thu Aug 10 14:35:42 2006 +0000
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,301 +0,0 @@
    20.4 -/*
    20.5 -    SDL - Simple DirectMedia Layer
    20.6 -    Copyright (C) 1997-2006 Sam Lantinga
    20.7 -
    20.8 -    This library is free software; you can redistribute it and/or
    20.9 -    modify it under the terms of the GNU Lesser General Public
   20.10 -    License as published by the Free Software Foundation; either
   20.11 -    version 2.1 of the License, or (at your option) any later version.
   20.12 -
   20.13 -    This library is distributed in the hope that it will be useful,
   20.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20.16 -    Lesser General Public License for more details.
   20.17 -
   20.18 -    You should have received a copy of the GNU Lesser General Public
   20.19 -    License along with this library; if not, write to the Free Software
   20.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   20.21 -
   20.22 -    Sam Lantinga
   20.23 -    slouken@libsdl.org
   20.24 -*/
   20.25 -#include "SDL_config.h"
   20.26 -
   20.27 -#ifdef SDL_JOYSTICK_MACOS
   20.28 -
   20.29 -/*  SDL stuff  --  "SDL_sysjoystick.c"
   20.30 -    MacOS joystick functions by Frederick Reitberger
   20.31 -
   20.32 -    The code that follows is meant for SDL.  Use at your own risk.
   20.33 -*/
   20.34 -
   20.35 -#include <InputSprocket.h>
   20.36 -
   20.37 -#include "SDL_joystick.h"
   20.38 -#include "../SDL_sysjoystick.h"
   20.39 -#include "../SDL_joystick_c.h"
   20.40 -
   20.41 -
   20.42 -/*  The max number of joysticks we will detect  */
   20.43 -#define     MAX_JOYSTICKS       16
   20.44 -/*  Limit ourselves to 32 elements per device  */
   20.45 -#define     kMaxReferences      32
   20.46 -
   20.47 -#define		ISpSymmetricAxisToFloat(axis)	((((float) axis) - kISpAxisMiddle) / (kISpAxisMaximum-kISpAxisMiddle))
   20.48 -#define		ISpAsymmetricAxisToFloat(axis)	(((float) axis) / (kISpAxisMaximum))
   20.49 -
   20.50 -
   20.51 -static ISpDeviceReference SYS_Joysticks[MAX_JOYSTICKS];
   20.52 -static ISpElementListReference SYS_Elements[MAX_JOYSTICKS];
   20.53 -static ISpDeviceDefinition SYS_DevDef[MAX_JOYSTICKS];
   20.54 -
   20.55 -struct joystick_hwdata
   20.56 -{
   20.57 -    char name[64];
   20.58 -/*    Uint8   id;*/
   20.59 -    ISpElementReference refs[kMaxReferences];
   20.60 -    /*  gonna need some sort of mapping info  */
   20.61 -};
   20.62 -
   20.63 -
   20.64 -/* Function to scan the system for joysticks.
   20.65 - * Joystick 0 should be the system default joystick.
   20.66 - * This function should return the number of available joysticks, or -1
   20.67 - * on an unrecoverable fatal error.
   20.68 - */
   20.69 -int
   20.70 -SDL_SYS_JoystickInit(void)
   20.71 -{
   20.72 -    static ISpDeviceClass classes[4] = {
   20.73 -        kISpDeviceClass_Joystick,
   20.74 -#if kISpDeviceClass_Gamepad
   20.75 -        kISpDeviceClass_Gamepad,
   20.76 -#endif
   20.77 -        kISpDeviceClass_Wheel,
   20.78 -        0
   20.79 -    };
   20.80 -    OSErr err;
   20.81 -    int i;
   20.82 -    UInt32 count, numJoysticks;
   20.83 -
   20.84 -    if ((Ptr) 0 == (Ptr) ISpStartup) {
   20.85 -        SDL_SetError("InputSprocket not installed");
   20.86 -        return -1;              //  InputSprocket not installed
   20.87 -    }
   20.88 -
   20.89 -    if ((Ptr) 0 == (Ptr) ISpGetVersion) {
   20.90 -        SDL_SetError("InputSprocket not version 1.1 or newer");
   20.91 -        return -1;              //  old version of ISp (not at least 1.1)
   20.92 -    }
   20.93 -
   20.94 -    ISpStartup();
   20.95 -
   20.96 -    /* Get all the joysticks */
   20.97 -    numJoysticks = 0;
   20.98 -    for (i = 0; classes[i]; ++i) {
   20.99 -        count = 0;
  20.100 -        err = ISpDevices_ExtractByClass(classes[i],
  20.101 -                                        MAX_JOYSTICKS - numJoysticks,
  20.102 -                                        &count, &SYS_Joysticks[numJoysticks]);
  20.103 -        numJoysticks += count;
  20.104 -    }
  20.105 -
  20.106 -    for (i = 0; i < numJoysticks; i++) {
  20.107 -        ISpDevice_GetDefinition(SYS_Joysticks[i],
  20.108 -                                sizeof(ISpDeviceDefinition), &SYS_DevDef[i]);
  20.109 -
  20.110 -        err = ISpElementList_New(0, NULL, &SYS_Elements[i], 0);
  20.111 -
  20.112 -        if (err) {
  20.113 -            SDL_OutOfMemory();
  20.114 -            return -1;
  20.115 -        }
  20.116 -
  20.117 -        ISpDevice_GetElementList(SYS_Joysticks[i], &SYS_Elements[i]);
  20.118 -    }
  20.119 -
  20.120 -    ISpDevices_Deactivate(numJoysticks, SYS_Joysticks);
  20.121 -
  20.122 -    return numJoysticks;
  20.123 -}
  20.124 -
  20.125 -/* Function to get the device-dependent name of a joystick */
  20.126 -const char *
  20.127 -SDL_SYS_JoystickName(int index)
  20.128 -{
  20.129 -    static char name[64];
  20.130 -    int len;
  20.131 -
  20.132 -    /*  convert pascal string to c-string  */
  20.133 -    len = SYS_DevDef[index].deviceName[0];
  20.134 -    if (len >= sizeof(name)) {
  20.135 -        len = (sizeof(name) - 1);
  20.136 -    }
  20.137 -    SDL_memcpy(name, &SYS_DevDef[index].deviceName[1], len);
  20.138 -    name[len] = '\0';
  20.139 -
  20.140 -    return name;
  20.141 -}
  20.142 -
  20.143 -/* Function to open a joystick for use.
  20.144 -   The joystick to open is specified by the index field of the joystick.
  20.145 -   This should fill the nbuttons and naxes fields of the joystick structure.
  20.146 -   It returns 0, or -1 if there is an error.
  20.147 - */
  20.148 -int
  20.149 -SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
  20.150 -{
  20.151 -    int index;
  20.152 -    UInt32 count, gotCount, count2;
  20.153 -    long numAxis, numButtons, numHats, numBalls;
  20.154 -
  20.155 -    count = kMaxReferences;
  20.156 -    count2 = 0;
  20.157 -    numAxis = numButtons = numHats = numBalls = 0;
  20.158 -
  20.159 -    index = joystick->index;
  20.160 -
  20.161 -    /* allocate memory for system specific hardware data */
  20.162 -    joystick->hwdata =
  20.163 -        (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
  20.164 -    if (joystick->hwdata == NULL) {
  20.165 -        SDL_OutOfMemory();
  20.166 -        return (-1);
  20.167 -    }
  20.168 -    SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
  20.169 -    SDL_strlcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index),
  20.170 -                SDL_arraysize(joystick->hwdata->name));
  20.171 -    joystick->name = joystick->hwdata->name;
  20.172 -
  20.173 -    ISpElementList_ExtractByKind(SYS_Elements[index],
  20.174 -                                 kISpElementKind_Axis,
  20.175 -                                 count, &gotCount, joystick->hwdata->refs);
  20.176 -
  20.177 -    numAxis = gotCount;
  20.178 -    count -= gotCount;
  20.179 -    count2 += gotCount;
  20.180 -
  20.181 -    ISpElementList_ExtractByKind(SYS_Elements[index],
  20.182 -                                 kISpElementKind_DPad,
  20.183 -                                 count,
  20.184 -                                 &gotCount,
  20.185 -                                 &(joystick->hwdata->refs[count2]));
  20.186 -
  20.187 -    numHats = gotCount;
  20.188 -    count -= gotCount;
  20.189 -    count2 += gotCount;
  20.190 -
  20.191 -    ISpElementList_ExtractByKind(SYS_Elements[index],
  20.192 -                                 kISpElementKind_Button,
  20.193 -                                 count,
  20.194 -                                 &gotCount,
  20.195 -                                 &(joystick->hwdata->refs[count2]));
  20.196 -
  20.197 -    numButtons = gotCount;
  20.198 -    count -= gotCount;
  20.199 -    count2 += gotCount;
  20.200 -
  20.201 -    joystick->naxes = numAxis;
  20.202 -    joystick->nhats = numHats;
  20.203 -    joystick->nballs = numBalls;
  20.204 -    joystick->nbuttons = numButtons;
  20.205 -
  20.206 -    ISpDevices_Activate(1, &SYS_Joysticks[index]);
  20.207 -
  20.208 -    return 0;
  20.209 -}
  20.210 -
  20.211 -/* Function to update the state of a joystick - called as a device poll.
  20.212 - * This function shouldn't update the joystick structure directly,
  20.213 - * but instead should call SDL_PrivateJoystick*() to deliver events
  20.214 - * and update joystick device state.
  20.215 - */
  20.216 -void
  20.217 -SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
  20.218 -{
  20.219 -    int i, j;
  20.220 -    ISpAxisData a;
  20.221 -    ISpDPadData b;
  20.222 -    //ISpDeltaData    c;
  20.223 -    ISpButtonData d;
  20.224 -
  20.225 -    for (i = 0, j = 0; i < joystick->naxes; i++, j++) {
  20.226 -        Sint16 value;
  20.227 -
  20.228 -        ISpElement_GetSimpleState(joystick->hwdata->refs[j], &a);
  20.229 -        value = (ISpSymmetricAxisToFloat(a) * 32767.0);
  20.230 -        if (value != joystick->axes[i]) {
  20.231 -            SDL_PrivateJoystickAxis(joystick, i, value);
  20.232 -        }
  20.233 -    }
  20.234 -
  20.235 -    for (i = 0; i < joystick->nhats; i++, j++) {
  20.236 -        Uint8 pos;
  20.237 -
  20.238 -        ISpElement_GetSimpleState(joystick->hwdata->refs[j], &b);
  20.239 -        switch (b) {
  20.240 -        case kISpPadIdle:
  20.241 -            pos = SDL_HAT_CENTERED;
  20.242 -            break;
  20.243 -        case kISpPadLeft:
  20.244 -            pos = SDL_HAT_LEFT;
  20.245 -            break;
  20.246 -        case kISpPadUpLeft:
  20.247 -            pos = SDL_HAT_LEFTUP;
  20.248 -            break;
  20.249 -        case kISpPadUp:
  20.250 -            pos = SDL_HAT_UP;
  20.251 -            break;
  20.252 -        case kISpPadUpRight:
  20.253 -            pos = SDL_HAT_RIGHTUP;
  20.254 -            break;
  20.255 -        case kISpPadRight:
  20.256 -            pos = SDL_HAT_RIGHT;
  20.257 -            break;
  20.258 -        case kISpPadDownRight:
  20.259 -            pos = SDL_HAT_RIGHTDOWN;
  20.260 -            break;
  20.261 -        case kISpPadDown:
  20.262 -            pos = SDL_HAT_DOWN;
  20.263 -            break;
  20.264 -        case kISpPadDownLeft:
  20.265 -            pos = SDL_HAT_LEFTDOWN;
  20.266 -            break;
  20.267 -        }
  20.268 -        if (pos != joystick->hats[i]) {
  20.269 -            SDL_PrivateJoystickHat(joystick, i, pos);
  20.270 -        }
  20.271 -    }
  20.272 -
  20.273 -    for (i = 0; i < joystick->nballs; i++, j++) {
  20.274 -        /*  ignore balls right now  */
  20.275 -    }
  20.276 -
  20.277 -    for (i = 0; i < joystick->nbuttons; i++, j++) {
  20.278 -        ISpElement_GetSimpleState(joystick->hwdata->refs[j], &d);
  20.279 -        if (d != joystick->buttons[i]) {
  20.280 -            SDL_PrivateJoystickButton(joystick, i, d);
  20.281 -        }
  20.282 -    }
  20.283 -}
  20.284 -
  20.285 -/* Function to close a joystick after use */
  20.286 -void
  20.287 -SDL_SYS_JoystickClose(SDL_Joystick * joystick)
  20.288 -{
  20.289 -    int index;
  20.290 -
  20.291 -    index = joystick->index;
  20.292 -
  20.293 -    ISpDevices_Deactivate(1, &SYS_Joysticks[index]);
  20.294 -}
  20.295 -
  20.296 -/* Function to perform any system-specific joystick related cleanup */
  20.297 -void
  20.298 -SDL_SYS_JoystickQuit(void)
  20.299 -{
  20.300 -    ISpShutdown();
  20.301 -}
  20.302 -
  20.303 -#endif /* SDL_JOYSTICK_MACOS */
  20.304 -/* vi: set ts=4 sw=4 expandtab: */
    21.1 --- a/src/loadso/macos/SDL_sysloadso.c	Thu Aug 10 14:35:42 2006 +0000
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,110 +0,0 @@
    21.4 -/*
    21.5 -    SDL - Simple DirectMedia Layer
    21.6 -    Copyright (C) 1997-2006 Sam Lantinga
    21.7 -
    21.8 -    This library is free software; you can redistribute it and/or
    21.9 -    modify it under the terms of the GNU Lesser General Public
   21.10 -    License as published by the Free Software Foundation; either
   21.11 -    version 2.1 of the License, or (at your option) any later version.
   21.12 -
   21.13 -    This library is distributed in the hope that it will be useful,
   21.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   21.16 -    Lesser General Public License for more details.
   21.17 -
   21.18 -    You should have received a copy of the GNU Lesser General Public
   21.19 -    License along with this library; if not, write to the Free Software
   21.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   21.21 -
   21.22 -    Sam Lantinga
   21.23 -    slouken@libsdl.org
   21.24 -*/
   21.25 -#include "SDL_config.h"
   21.26 -
   21.27 -#ifdef SDL_LOADSO_MACOS
   21.28 -
   21.29 -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
   21.30 -/* System dependent library loading routines                           */
   21.31 -
   21.32 -#include <stdio.h>
   21.33 -#include <string.h>
   21.34 -#define OLDP2C 1
   21.35 -#include <Strings.h>
   21.36 -#include <CodeFragments.h>
   21.37 -#include <Errors.h>
   21.38 -
   21.39 -#include "SDL_loadso.h"
   21.40 -
   21.41 -void *
   21.42 -SDL_LoadObject(const char *sofile)
   21.43 -{
   21.44 -    void *handle = NULL;
   21.45 -    const char *loaderror = NULL;
   21.46 -    CFragConnectionID library_id;
   21.47 -    Ptr mainAddr;
   21.48 -    Str255 errName;
   21.49 -    OSErr error;
   21.50 -    char psofile[512];
   21.51 -
   21.52 -    SDL_strlcpy(psofile, sofile, SDL_arraysize(psofile));
   21.53 -    error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch,
   21.54 -                             kLoadCFrag, &library_id, &mainAddr, errName);
   21.55 -    switch (error) {
   21.56 -    case noErr:
   21.57 -        loaderror = NULL;
   21.58 -        break;
   21.59 -    case cfragNoLibraryErr:
   21.60 -        loaderror = "Library not found";
   21.61 -        break;
   21.62 -    case cfragUnresolvedErr:
   21.63 -        loaderror = "Unabled to resolve symbols";
   21.64 -        break;
   21.65 -    case cfragNoPrivateMemErr:
   21.66 -    case cfragNoClientMemErr:
   21.67 -        loaderror = "Out of memory";
   21.68 -        break;
   21.69 -    default:
   21.70 -        loaderror = "Unknown Code Fragment Manager error";
   21.71 -        break;
   21.72 -    }
   21.73 -    if (loaderror == NULL) {
   21.74 -        handle = (void *) (library_id);
   21.75 -    } else {
   21.76 -        SDL_SetError("Failed loading %s: %s", sofile, loaderror);
   21.77 -    }
   21.78 -    return (handle);
   21.79 -}
   21.80 -
   21.81 -void *
   21.82 -SDL_LoadFunction(void *handle, const char *name)
   21.83 -{
   21.84 -    void *symbol = NULL;
   21.85 -    const char *loaderror = NULL;
   21.86 -    CFragSymbolClass class;
   21.87 -    CFragConnectionID library_id = (CFragConnectionID) handle;
   21.88 -    char pname[512];
   21.89 -
   21.90 -    SDL_strlcpy(pname, name, SDL_arraysize(pname));
   21.91 -    if (FindSymbol(library_id, C2PStr(pname),
   21.92 -                   (char **) &symbol, &class) != noErr) {
   21.93 -        loaderror = "Symbol not found";
   21.94 -    }
   21.95 -
   21.96 -    if (symbol == NULL) {
   21.97 -        SDL_SetError("Failed loading %s: %s", name, loaderror);
   21.98 -    }
   21.99 -    return (symbol);
  21.100 -}
  21.101 -
  21.102 -void
  21.103 -SDL_UnloadObject(void *handle)
  21.104 -{
  21.105 -    CFragConnectionID library_id;
  21.106 -    if (handle != NULL) {
  21.107 -        library_id = (CFragConnectionID) handle;
  21.108 -        CloseConnection(&library_id);
  21.109 -    }
  21.110 -}
  21.111 -
  21.112 -#endif /* SDL_LOADSO_MACOS */
  21.113 -/* vi: set ts=4 sw=4 expandtab: */
    22.1 --- a/src/main/macos/SDL.r	Thu Aug 10 14:35:42 2006 +0000
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,58 +0,0 @@
    22.4 -data 'DLOG' (1000) {
    22.5 -	$"0072 0040 00EA 01B3 0001 0100 0000 0000 0000 03E8 0C43 6F6D 6D61 6E64 204C 696E"                    /* .r.@..............Command Lin */
    22.6 -	$"6500 280A"                                                                                          /* e.( */
    22.7 -};
    22.8 -
    22.9 -data 'DLOG' (1001) {
   22.10 -	$"0072 0040 00DB 01AC 0001 0100 0000 0000 0000 03E9 0C45 7272 6F72 2057 696E 646F"                    /* .r.@..............Error Windo */
   22.11 -	$"7700 280A"                                                                                          /* w.( */
   22.12 -};
   22.13 -
   22.14 -data 'DLOG' (1002) {
   22.15 -	$"00B8 00BE 0147 01D8 0005 0100 0000 0000 0000 03EA 1643 6F6E 6669 726D 2044 6973"                    /* ...G.............Confirm Dis */
   22.16 -	$"706C 6179 2043 6861 6E67 6510 280A"                                                                 /* play Change.( */
   22.17 -};
   22.18 -
   22.19 -data 'DITL' (1000) {
   22.20 -	$"0005 0000 0000 0052 0113 0066 0158 0402 4F4B 0000 0000 0052 00C2 0066 0107 0406"                    /* .......R...f.X..OK.....R..f.... */
   22.21 -	$"4361 6E63 656C 0000 0000 000F 0084 001F 0155 1000 0000 0000 0054 0019 0066 007D"                    /* Cancel..........U.......T...f.} */
   22.22 -	$"050E 4F75 7470 7574 2074 6F20 6669 6C65 0000 0000 000F 0018 001F 007F 080D 436F"                    /* ..Output to file..............Co */
   22.23 -	$"6D6D 616E 6420 4C69 6E65 3A00 0000 0000 0030 0018 0040 0158 0702 0080"                              /* mmand Line:......0...@.X... */
   22.24 -};
   22.25 -
   22.26 -data 'DITL' (1001) {
   22.27 -	$"0001 0000 0000 0046 0120 005A 015A 0402 4F4B 0000 0000 0010 000A 0038 0160 0800"                    /* .......F. .Z.Z..OK........8.`.. */
   22.28 -};
   22.29 -
   22.30 -data 'DITL' (1002) {
   22.31 -	$"0002 0000 0000 006F 001E 0083 0058 0406 4361 6E63 656C 0000 0000 006E 00C0 0082"                    /* .......o....X..Cancel.....n.. */
   22.32 -	$"00FA 0402 4F4B 0000 0000 000E 000F 005F 010C 88B3 5468 6520 7365 7474 696E 6720"                    /* ...OK........._..The setting  */
   22.33 -	$"666F 7220 796F 7572 206D 6F6E 6974 6F72 2068 6173 2062 6565 6E20 6368 616E 6765"                    /* for your monitor has been change */
   22.34 -	$"642C 2061 6E64 2069 7420 6D61 7920 6E6F 7420 6265 2064 6973 706C 6179 6564 2063"                    /* d, and it may not be displayed c */
   22.35 -	$"6F72 7265 6374 6C79 2E20 546F 2063 6F6E 6669 726D 2074 6865 2064 6973 706C 6179"                    /* orrectly. To confirm the display */
   22.36 -	$"2069 7320 636F 7272 6563 742C 2063 6C69 636B 204F 4B2E 2054 6F20 7265 7475 726E"                    /*  is correct, click OK. To return */
   22.37 -	$"2074 6F20 7468 6520 6F72 6967 696E 616C 2073 6574 7469 6E67 2C20 636C 6963 6B20"                    /*  to the original setting, click  */
   22.38 -	$"4361 6E63 656C 2E00"                                                                                /* Cancel.. */
   22.39 -};
   22.40 -
   22.41 -data 'MENU' (128, preload) {
   22.42 -	$"0080 0000 0000 0000 0000 FFFF FFFB 0114 0C41 626F 7574 2053 444C 2E2E 2E00 0000"                    /* ............About SDL...... */
   22.43 -	$"0001 2D00 0000 0000"                                                                                /* ..-..... */
   22.44 -};
   22.45 -
   22.46 -data 'MENU' (129) {
   22.47 -	$"0081 0000 0000 0000 0000 FFFF FFFF 0C56 6964 656F 2044 7269 7665 7219 4472 6177"                    /* ..........Video Driver.Draw */
   22.48 -	$"5370 726F 636B 6574 2028 4675 6C6C 7363 7265 656E 2900 0000 001E 546F 6F6C 426F"                    /* Sprocket (Fullscreen).....ToolBo */
   22.49 -	$"7820 2028 4675 6C6C 7363 7265 656E 2F57 696E 646F 7765 6429 0000 0000 00"                           /* x  (Fullscreen/Windowed)..... */
   22.50 -};
   22.51 -
   22.52 -data 'CNTL' (128) {
   22.53 -	$"0000 0000 0010 0140 0000 0100 0064 0081 03F0 0000 0000 0D56 6964 656F 2044 7269"                    /* .......@.....d.......Video Dri */
   22.54 -	$"7665 723A"                                                                                          /* ver: */
   22.55 -};
   22.56 -
   22.57 -data 'TMPL' (128, "CLne") {
   22.58 -	$"0C43 6F6D 6D61 6E64 204C 696E 6550 5354 520C 5669 6465 6F20 4472 6976 6572 5053"                    /* .Command LinePSTR.Video DriverPS */
   22.59 -	$"5452 0C53 6176 6520 546F 2046 696C 6542 4F4F 4C"                                                    /* TR.Save To FileBOOL */
   22.60 -};
   22.61 -
    23.1 --- a/src/main/macos/SDL_main.c	Thu Aug 10 14:35:42 2006 +0000
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,647 +0,0 @@
    23.4 -/*
    23.5 -    SDL - Simple DirectMedia Layer
    23.6 -    Copyright (C) 1997-2006 Sam Lantinga
    23.7 -
    23.8 -    This library is free software; you can redistribute it and/or
    23.9 -    modify it under the terms of the GNU Lesser General Public
   23.10 -    License as published by the Free Software Foundation; either
   23.11 -    version 2.1 of the License, or (at your option) any later version.
   23.12 -
   23.13 -    This library is distributed in the hope that it will be useful,
   23.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   23.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   23.16 -    Lesser General Public License for more details.
   23.17 -
   23.18 -    You should have received a copy of the GNU Lesser General Public
   23.19 -    License along with this library; if not, write to the Free Software
   23.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   23.21 -
   23.22 -    Sam Lantinga
   23.23 -    slouken@libsdl.org
   23.24 -*/
   23.25 -
   23.26 -/* This file takes care of command line argument parsing, and stdio redirection
   23.27 -   in the MacOS environment. (stdio/stderr is *not* directed for Mach-O builds)
   23.28 - */
   23.29 -
   23.30 -#if defined(__APPLE__) && defined(__MACH__)
   23.31 -#include <Carbon/Carbon.h>
   23.32 -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
   23.33 -#include <Carbon.h>
   23.34 -#else
   23.35 -#include <Dialogs.h>
   23.36 -#include <Fonts.h>
   23.37 -#include <Events.h>
   23.38 -#include <Resources.h>
   23.39 -#include <Folders.h>
   23.40 -#endif
   23.41 -
   23.42 -/* Include the SDL main definition header */
   23.43 -#include "SDL.h"
   23.44 -#include "SDL_main.h"
   23.45 -#ifdef main
   23.46 -#undef main
   23.47 -#endif
   23.48 -
   23.49 -#if !(defined(__APPLE__) && defined(__MACH__))
   23.50 -/* The standard output files */
   23.51 -#define STDOUT_FILE	"stdout.txt"
   23.52 -#define STDERR_FILE	"stderr.txt"
   23.53 -#endif
   23.54 -
   23.55 -#if !defined(__MWERKS__) && !TARGET_API_MAC_CARBON
   23.56 -        /* In MPW, the qd global has been removed from the libraries */
   23.57 -QDGlobals qd;
   23.58 -#endif
   23.59 -
   23.60 -/* Structure for keeping prefs in 1 variable */
   23.61 -typedef struct
   23.62 -{
   23.63 -    Str255 command_line;
   23.64 -    Str255 video_driver_name;
   23.65 -    Boolean output_to_file;
   23.66 -} PrefsRecord;
   23.67 -
   23.68 -/* See if the command key is held down at startup */
   23.69 -static Boolean
   23.70 -CommandKeyIsDown(void)
   23.71 -{
   23.72 -    KeyMap theKeyMap;
   23.73 -
   23.74 -    GetKeys(theKeyMap);
   23.75 -
   23.76 -    if (((unsigned char *) theKeyMap)[6] & 0x80) {
   23.77 -        return (true);
   23.78 -    }
   23.79 -    return (false);
   23.80 -}
   23.81 -
   23.82 -#if !(defined(__APPLE__) && defined(__MACH__))
   23.83 -
   23.84 -/* Parse a command line buffer into arguments */
   23.85 -static int
   23.86 -ParseCommandLine(char *cmdline, char **argv)
   23.87 -{
   23.88 -    char *bufp;
   23.89 -    int argc;
   23.90 -
   23.91 -    argc = 0;
   23.92 -    for (bufp = cmdline; *bufp;) {
   23.93 -        /* Skip leading whitespace */
   23.94 -        while (SDL_isspace(*bufp)) {
   23.95 -            ++bufp;
   23.96 -        }
   23.97 -        /* Skip over argument */
   23.98 -        if (*bufp == '"') {
   23.99 -            ++bufp;
  23.100 -            if (*bufp) {
  23.101 -                if (argv) {
  23.102 -                    argv[argc] = bufp;
  23.103 -                }
  23.104 -                ++argc;
  23.105 -            }
  23.106 -            /* Skip over word */
  23.107 -            while (*bufp && (*bufp != '"')) {
  23.108 -                ++bufp;
  23.109 -            }
  23.110 -        } else {
  23.111 -            if (*bufp) {
  23.112 -                if (argv) {
  23.113 -                    argv[argc] = bufp;
  23.114 -                }
  23.115 -                ++argc;
  23.116 -            }
  23.117 -            /* Skip over word */
  23.118 -            while (*bufp && !SDL_isspace(*bufp)) {
  23.119 -                ++bufp;
  23.120 -            }
  23.121 -        }
  23.122 -        if (*bufp) {
  23.123 -            if (argv) {
  23.124 -                *bufp = '\0';
  23.125 -            }
  23.126 -            ++bufp;
  23.127 -        }
  23.128 -    }
  23.129 -    if (argv) {
  23.130 -        argv[argc] = NULL;
  23.131 -    }
  23.132 -    return (argc);
  23.133 -}
  23.134 -
  23.135 -/* Remove the output files if there was no output written */
  23.136 -static void
  23.137 -cleanup_output(void)
  23.138 -{
  23.139 -    FILE *file;
  23.140 -    int empty;
  23.141 -
  23.142 -    /* Flush the output in case anything is queued */
  23.143 -    fclose(stdout);
  23.144 -    fclose(stderr);
  23.145 -
  23.146 -    /* See if the files have any output in them */
  23.147 -    file = fopen(STDOUT_FILE, "rb");
  23.148 -    if (file) {
  23.149 -        empty = (fgetc(file) == EOF) ? 1 : 0;
  23.150 -        fclose(file);
  23.151 -        if (empty) {
  23.152 -            remove(STDOUT_FILE);
  23.153 -        }
  23.154 -    }
  23.155 -    file = fopen(STDERR_FILE, "rb");
  23.156 -    if (file) {
  23.157 -        empty = (fgetc(file) == EOF) ? 1 : 0;
  23.158 -        fclose(file);
  23.159 -        if (empty) {
  23.160 -            remove(STDERR_FILE);
  23.161 -        }
  23.162 -    }
  23.163 -}
  23.164 -
  23.165 -#endif //!(defined(__APPLE__) && defined(__MACH__))
  23.166 -
  23.167 -static int
  23.168 -getCurrentAppName(StrFileName name)
  23.169 -{
  23.170 -
  23.171 -    ProcessSerialNumber process;
  23.172 -    ProcessInfoRec process_info;
  23.173 -    FSSpec process_fsp;
  23.174 -
  23.175 -    process.highLongOfPSN = 0;
  23.176 -    process.lowLongOfPSN = kCurrentProcess;
  23.177 -    process_info.processInfoLength = sizeof(process_info);
  23.178 -    process_info.processName = NULL;
  23.179 -    process_info.processAppSpec = &process_fsp;
  23.180 -
  23.181 -    if (noErr != GetProcessInformation(&process, &process_info))
  23.182 -        return 0;
  23.183 -
  23.184 -    SDL_memcpy(name, process_fsp.name, process_fsp.name[0] + 1);
  23.185 -    return 1;
  23.186 -}
  23.187 -
  23.188 -static int
  23.189 -getPrefsFile(FSSpec * prefs_fsp, int create)
  23.190 -{
  23.191 -
  23.192 -    /* The prefs file name is the application name, possibly truncated, */
  23.193 -    /* plus " Preferences */
  23.194 -
  23.195 -#define  SUFFIX   " Preferences"
  23.196 -#define  MAX_NAME 19            /* 31 - strlen (SUFFIX) */
  23.197 -
  23.198 -    short volume_ref_number;
  23.199 -    long directory_id;
  23.200 -    StrFileName prefs_name;
  23.201 -    StrFileName app_name;
  23.202 -
  23.203 -    /* Get Preferences folder - works with Multiple Users */
  23.204 -    if (noErr !=
  23.205 -        FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder,
  23.206 -                   &volume_ref_number, &directory_id))
  23.207 -        exit(-1);
  23.208 -
  23.209 -    if (!getCurrentAppName(app_name))
  23.210 -        exit(-1);
  23.211 -
  23.212 -    /* Truncate if name is too long */
  23.213 -    if (app_name[0] > MAX_NAME)
  23.214 -        app_name[0] = MAX_NAME;
  23.215 -
  23.216 -    SDL_memcpy(prefs_name + 1, app_name + 1, app_name[0]);
  23.217 -    SDL_memcpy(prefs_name + app_name[0] + 1, SUFFIX, strlen(SUFFIX));
  23.218 -    prefs_name[0] = app_name[0] + strlen(SUFFIX);
  23.219 -
  23.220 -    /* Make the file spec for prefs file */
  23.221 -    if (noErr !=
  23.222 -        FSMakeFSSpec(volume_ref_number, directory_id, prefs_name, prefs_fsp))
  23.223 -    {
  23.224 -        if (!create)
  23.225 -            return 0;
  23.226 -        else {
  23.227 -            /* Create the prefs file */
  23.228 -            SDL_memcpy(prefs_fsp->name, prefs_name, prefs_name[0] + 1);
  23.229 -            prefs_fsp->parID = directory_id;
  23.230 -            prefs_fsp->vRefNum = volume_ref_number;
  23.231 -
  23.232 -            FSpCreateResFile(prefs_fsp, 0x3f3f3f3f, 'pref', 0); // '????' parsed as trigraph
  23.233 -
  23.234 -            if (noErr != ResError())
  23.235 -                return 0;
  23.236 -        }
  23.237 -    }
  23.238 -    return 1;
  23.239 -}
  23.240 -
  23.241 -static int
  23.242 -readPrefsResource(PrefsRecord * prefs)
  23.243 -{
  23.244 -
  23.245 -    Handle prefs_handle;
  23.246 -
  23.247 -    prefs_handle = Get1Resource('CLne', 128);
  23.248 -
  23.249 -    if (prefs_handle != NULL) {
  23.250 -        int offset = 0;
  23.251 -//              int j      = 0;
  23.252 -
  23.253 -        HLock(prefs_handle);
  23.254 -
  23.255 -        /* Get command line string */
  23.256 -        SDL_memcpy(prefs->command_line, *prefs_handle,
  23.257 -                   (*prefs_handle)[0] + 1);
  23.258 -
  23.259 -        /* Get video driver name */
  23.260 -        offset += (*prefs_handle)[0] + 1;
  23.261 -        SDL_memcpy(prefs->video_driver_name, *prefs_handle + offset,
  23.262 -                   (*prefs_handle)[offset] + 1);
  23.263 -
  23.264 -        /* Get save-to-file option (1 or 0) */
  23.265 -        offset += (*prefs_handle)[offset] + 1;
  23.266 -        prefs->output_to_file = (*prefs_handle)[offset];
  23.267 -
  23.268 -        ReleaseResource(prefs_handle);
  23.269 -
  23.270 -        return ResError() == noErr;
  23.271 -    }
  23.272 -
  23.273 -    return 0;
  23.274 -}
  23.275 -
  23.276 -static int
  23.277 -writePrefsResource(PrefsRecord * prefs, short resource_file)
  23.278 -{
  23.279 -
  23.280 -    Handle prefs_handle;
  23.281 -
  23.282 -    UseResFile(resource_file);
  23.283 -
  23.284 -    prefs_handle = Get1Resource('CLne', 128);
  23.285 -    if (prefs_handle != NULL)
  23.286 -        RemoveResource(prefs_handle);
  23.287 -
  23.288 -    prefs_handle =
  23.289 -        NewHandle(prefs->command_line[0] + prefs->video_driver_name[0] + 4);
  23.290 -    if (prefs_handle != NULL) {
  23.291 -
  23.292 -        int offset;
  23.293 -
  23.294 -        HLock(prefs_handle);
  23.295 -
  23.296 -        /* Command line text */
  23.297 -        offset = 0;
  23.298 -        SDL_memcpy(*prefs_handle, prefs->command_line,
  23.299 -                   prefs->command_line[0] + 1);
  23.300 -
  23.301 -        /* Video driver name */
  23.302 -        offset += prefs->command_line[0] + 1;
  23.303 -        SDL_memcpy(*prefs_handle + offset, prefs->video_driver_name,
  23.304 -                   prefs->video_driver_name[0] + 1);
  23.305 -
  23.306 -        /* Output-to-file option */
  23.307 -        offset += prefs->video_driver_name[0] + 1;
  23.308 -        *(*((char **) prefs_handle) + offset) = (char) prefs->output_to_file;
  23.309 -        *(*((char **) prefs_handle) + offset + 1) = 0;
  23.310 -
  23.311 -        AddResource(prefs_handle, 'CLne', 128, "\pCommand Line");
  23.312 -        WriteResource(prefs_handle);
  23.313 -        UpdateResFile(resource_file);
  23.314 -        DisposeHandle(prefs_handle);
  23.315 -
  23.316 -        return ResError() == noErr;
  23.317 -    }
  23.318 -
  23.319 -    return 0;
  23.320 -}
  23.321 -
  23.322 -static int
  23.323 -readPreferences(PrefsRecord * prefs)
  23.324 -{
  23.325 -
  23.326 -    int no_error = 1;
  23.327 -    FSSpec prefs_fsp;
  23.328 -
  23.329 -    /* Check for prefs file first */
  23.330 -    if (getPrefsFile(&prefs_fsp, 0)) {
  23.331 -
  23.332 -        short prefs_resource;
  23.333 -
  23.334 -        prefs_resource = FSpOpenResFile(&prefs_fsp, fsRdPerm);
  23.335 -        if (prefs_resource == -1)       /* this shouldn't happen, but... */
  23.336 -            return 0;
  23.337 -
  23.338 -        UseResFile(prefs_resource);
  23.339 -        no_error = readPrefsResource(prefs);
  23.340 -        CloseResFile(prefs_resource);
  23.341 -    }
  23.342 -
  23.343 -    /* Fall back to application's resource fork (reading only, so this is safe) */
  23.344 -    else {
  23.345 -
  23.346 -        no_error = readPrefsResource(prefs);
  23.347 -    }
  23.348 -
  23.349 -    return no_error;
  23.350 -}
  23.351 -
  23.352 -static int
  23.353 -writePreferences(PrefsRecord * prefs)
  23.354 -{
  23.355 -
  23.356 -    int no_error = 1;
  23.357 -    FSSpec prefs_fsp;
  23.358 -
  23.359 -    /* Get prefs file, create if it doesn't exist */
  23.360 -    if (getPrefsFile(&prefs_fsp, 1)) {
  23.361 -
  23.362 -        short prefs_resource;
  23.363 -
  23.364 -        prefs_resource = FSpOpenResFile(&prefs_fsp, fsRdWrPerm);
  23.365 -        if (prefs_resource == -1)
  23.366 -            return 0;
  23.367 -        no_error = writePrefsResource(prefs, prefs_resource);
  23.368 -        CloseResFile(prefs_resource);
  23.369 -    }
  23.370 -
  23.371 -    return no_error;
  23.372 -}
  23.373 -
  23.374 -/* This is where execution begins */
  23.375 -int
  23.376 -main(int argc, char *argv[])
  23.377 -{
  23.378 -
  23.379 -#if !(defined(__APPLE__) && defined(__MACH__))
  23.380 -#pragma unused(argc, argv)
  23.381 -#endif
  23.382 -
  23.383 -#define DEFAULT_ARGS "\p"       /* pascal string for default args */
  23.384 -#define DEFAULT_VIDEO_DRIVER "\ptoolbox"        /* pascal string for default video driver name */
  23.385 -#define DEFAULT_OUTPUT_TO_FILE 1        /* 1 == output to file, 0 == no output */
  23.386 -
  23.387 -#define VIDEO_ID_DRAWSPROCKET 1 /* these correspond to popup menu choices */
  23.388 -#define VIDEO_ID_TOOLBOX      2
  23.389 -
  23.390 -    PrefsRecord prefs =
  23.391 -        { DEFAULT_ARGS, DEFAULT_VIDEO_DRIVER, DEFAULT_OUTPUT_TO_FILE };
  23.392 -
  23.393 -#if !(defined(__APPLE__) && defined(__MACH__))
  23.394 -    int nargs;
  23.395 -    char **args;
  23.396 -    char *commandLine;
  23.397 -
  23.398 -    StrFileName appNameText;
  23.399 -#endif
  23.400 -    int videodriver = VIDEO_ID_TOOLBOX;
  23.401 -    int settingsChanged = 0;
  23.402 -
  23.403 -    long i;
  23.404 -
  23.405 -    /* Kyle's SDL command-line dialog code ... */
  23.406 -#if !TARGET_API_MAC_CARBON
  23.407 -    InitGraf(&qd.thePort);
  23.408 -    InitFonts();
  23.409 -    InitWindows();
  23.410 -    InitMenus();
  23.411 -    InitDialogs(nil);
  23.412 -#endif
  23.413 -    InitCursor();
  23.414 -    FlushEvents(everyEvent, 0);
  23.415 -#if !TARGET_API_MAC_CARBON
  23.416 -    MaxApplZone();
  23.417 -#endif
  23.418 -    MoreMasters();
  23.419 -    MoreMasters();
  23.420 -#if 0
  23.421 -    /* Intialize SDL, and put up a dialog if we fail */
  23.422 -    if (SDL_Init(0) < 0) {
  23.423 -
  23.424 -#define kErr_OK		1
  23.425 -#define kErr_Text	2
  23.426 -
  23.427 -        DialogPtr errorDialog;
  23.428 -        short dummyType;
  23.429 -        Rect dummyRect;
  23.430 -        Handle dummyHandle;
  23.431 -        short itemHit;
  23.432 -
  23.433 -        errorDialog = GetNewDialog(1001, nil, (WindowPtr) - 1);
  23.434 -        if (errorDialog == NULL)
  23.435 -            return -1;
  23.436 -        DrawDialog(errorDialog);
  23.437 -
  23.438 -        GetDialogItem(errorDialog, kErr_Text, &dummyType, &dummyHandle,
  23.439 -                      &dummyRect);
  23.440 -        SetDialogItemText(dummyHandle, "\pError Initializing SDL");
  23.441 -
  23.442 -#if TARGET_API_MAC_CARBON
  23.443 -        SetPort(GetDialogPort(errorDialog));
  23.444 -#else
  23.445 -        SetPort(errorDialog);
  23.446 -#endif
  23.447 -        do {
  23.448 -            ModalDialog(nil, &itemHit);
  23.449 -        }
  23.450 -        while (itemHit != kErr_OK);
  23.451 -
  23.452 -        DisposeDialog(errorDialog);
  23.453 -        exit(-1);
  23.454 -    }
  23.455 -    atexit(cleanup_output);
  23.456 -    atexit(SDL_Quit);
  23.457 -#endif
  23.458 -
  23.459 -/* Set up SDL's QuickDraw environment  */
  23.460 -#if !TARGET_API_MAC_CARBON
  23.461 -    SDL_InitQuickDraw(&qd);
  23.462 -#endif
  23.463 -
  23.464 -    if (readPreferences(&prefs)) {
  23.465 -
  23.466 -        if (SDL_memcmp(prefs.video_driver_name + 1, "DSp", 3) == 0)
  23.467 -            videodriver = 1;
  23.468 -        else if (SDL_memcmp(prefs.video_driver_name + 1, "toolbox", 7) == 0)
  23.469 -            videodriver = 2;
  23.470 -    }
  23.471 -
  23.472 -    if (CommandKeyIsDown()) {
  23.473 -
  23.474 -#define kCL_OK		1
  23.475 -#define kCL_Cancel	2
  23.476 -#define kCL_Text	3
  23.477 -#define kCL_File	4
  23.478 -#define kCL_Video   6
  23.479 -
  23.480 -        DialogPtr commandDialog;
  23.481 -        short dummyType;
  23.482 -        Rect dummyRect;
  23.483 -        Handle dummyHandle;
  23.484 -        short itemHit;
  23.485 -#if TARGET_API_MAC_CARBON
  23.486 -        ControlRef control;
  23.487 -#endif
  23.488 -
  23.489 -        /* Assume that they will change settings, rather than do exhaustive check */
  23.490 -        settingsChanged = 1;
  23.491 -
  23.492 -        /* Create dialog and display it */
  23.493 -        commandDialog = GetNewDialog(1000, nil, (WindowPtr) - 1);
  23.494 -#if TARGET_API_MAC_CARBON
  23.495 -        SetPort(GetDialogPort(commandDialog));
  23.496 -#else
  23.497 -        SetPort(commandDialog);
  23.498 -#endif
  23.499 -
  23.500 -        /* Setup controls */
  23.501 -#if TARGET_API_MAC_CARBON
  23.502 -        GetDialogItemAsControl(commandDialog, kCL_File, &control);
  23.503 -        SetControlValue(control, prefs.output_to_file);
  23.504 -#else
  23.505 -        GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect);   /* MJS */
  23.506 -        SetControlValue((ControlHandle) dummyHandle, prefs.output_to_file);
  23.507 -#endif
  23.508 -
  23.509 -        GetDialogItem(commandDialog, kCL_Text, &dummyType, &dummyHandle,
  23.510 -                      &dummyRect);
  23.511 -        SetDialogItemText(dummyHandle, prefs.command_line);
  23.512 -
  23.513 -#if TARGET_API_MAC_CARBON
  23.514 -        GetDialogItemAsControl(commandDialog, kCL_Video, &control);
  23.515 -        SetControlValue(control, videodriver);
  23.516 -#else
  23.517 -        GetDialogItem(commandDialog, kCL_Video, &dummyType, &dummyHandle,
  23.518 -                      &dummyRect);
  23.519 -        SetControlValue((ControlRef) dummyHandle, videodriver);
  23.520 -#endif
  23.521 -
  23.522 -        SetDialogDefaultItem(commandDialog, kCL_OK);
  23.523 -        SetDialogCancelItem(commandDialog, kCL_Cancel);
  23.524 -
  23.525 -        do {
  23.526 -
  23.527 -            ModalDialog(nil, &itemHit); /* wait for user response */
  23.528 -
  23.529 -            /* Toggle command-line output checkbox */
  23.530 -            if (itemHit == kCL_File) {
  23.531 -#if TARGET_API_MAC_CARBON
  23.532 -                GetDialogItemAsControl(commandDialog, kCL_File, &control);
  23.533 -                SetControlValue(control, !GetControlValue(control));
  23.534 -#else
  23.535 -                GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect);   /* MJS */
  23.536 -                SetControlValue((ControlHandle) dummyHandle,
  23.537 -                                !GetControlValue((ControlHandle)
  23.538 -                                                 dummyHandle));
  23.539 -#endif
  23.540 -            }
  23.541 -
  23.542 -        }
  23.543 -        while (itemHit != kCL_OK && itemHit != kCL_Cancel);
  23.544 -
  23.545 -        /* Get control values, even if they did not change */
  23.546 -        GetDialogItem(commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect);   /* MJS */
  23.547 -        GetDialogItemText(dummyHandle, prefs.command_line);
  23.548 -
  23.549 -#if TARGET_API_MAC_CARBON
  23.550 -        GetDialogItemAsControl(commandDialog, kCL_File, &control);
  23.551 -        prefs.output_to_file = GetControlValue(control);
  23.552 -#else
  23.553 -        GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect);   /* MJS */
  23.554 -        prefs.output_to_file = GetControlValue((ControlHandle) dummyHandle);
  23.555 -#endif
  23.556 -
  23.557 -#if TARGET_API_MAC_CARBON
  23.558 -        GetDialogItemAsControl(commandDialog, kCL_Video, &control);
  23.559 -        videodriver = GetControlValue(control);
  23.560 -#else
  23.561 -        GetDialogItem(commandDialog, kCL_Video, &dummyType, &dummyHandle,
  23.562 -                      &dummyRect);
  23.563 -        videodriver = GetControlValue((ControlRef) dummyHandle);
  23.564 -#endif
  23.565 -
  23.566 -        DisposeDialog(commandDialog);
  23.567 -
  23.568 -        if (itemHit == kCL_Cancel) {
  23.569 -            exit(0);
  23.570 -        }
  23.571 -    }
  23.572 -
  23.573 -    /* Set pseudo-environment variables for video driver, update prefs */
  23.574 -    switch (videodriver) {
  23.575 -    case VIDEO_ID_DRAWSPROCKET:
  23.576 -        SDL_putenv("SDL_VIDEODRIVER=DSp");
  23.577 -        SDL_memcpy(prefs.video_driver_name, "\pDSp", 4);
  23.578 -        break;
  23.579 -    case VIDEO_ID_TOOLBOX:
  23.580 -        SDL_putenv("SDL_VIDEODRIVER=toolbox");
  23.581 -        SDL_memcpy(prefs.video_driver_name, "\ptoolbox", 8);
  23.582 -        break;
  23.583 -    }
  23.584 -
  23.585 -#if !(defined(__APPLE__) && defined(__MACH__))
  23.586 -    /* Redirect standard I/O to files */
  23.587 -    if (prefs.output_to_file) {
  23.588 -        freopen(STDOUT_FILE, "w", stdout);
  23.589 -        freopen(STDERR_FILE, "w", stderr);
  23.590 -    } else {
  23.591 -        fclose(stdout);
  23.592 -        fclose(stderr);
  23.593 -    }
  23.594 -#endif
  23.595 -
  23.596 -    if (settingsChanged) {
  23.597 -        /* Save the prefs, even if they might not have changed (but probably did) */
  23.598 -        if (!writePreferences(&prefs))
  23.599 -            fprintf(stderr, "WARNING: Could not save preferences!\n");
  23.600 -    }
  23.601 -#if !(defined(__APPLE__) && defined(__MACH__))
  23.602 -    appNameText[0] = 0;
  23.603 -    getCurrentAppName(appNameText);     /* check for error here ? */
  23.604 -
  23.605 -    commandLine = (char *) malloc(appNameText[0] + prefs.command_line[0] + 2);
  23.606 -    if (commandLine == NULL) {
  23.607 -        exit(-1);
  23.608 -    }
  23.609 -
  23.610 -    /* Rather than rewrite ParseCommandLine method, let's replace  */
  23.611 -    /* any spaces in application name with underscores,            */
  23.612 -    /* so that the app name is only 1 argument                     */
  23.613 -    for (i = 1; i < 1 + appNameText[0]; i++)
  23.614 -        if (appNameText[i] == ' ')
  23.615 -            appNameText[i] = '_';
  23.616 -
  23.617 -    /* Copy app name & full command text to command-line C-string */
  23.618 -    SDL_memcpy(commandLine, appNameText + 1, appNameText[0]);
  23.619 -    commandLine[appNameText[0]] = ' ';
  23.620 -    SDL_memcpy(commandLine + appNameText[0] + 1, prefs.command_line + 1,
  23.621 -               prefs.command_line[0]);
  23.622 -    commandLine[appNameText[0] + 1 + prefs.command_line[0]] = '\0';
  23.623 -
  23.624 -    /* Parse C-string into argv and argc */
  23.625 -    nargs = ParseCommandLine(commandLine, NULL);
  23.626 -    args = (char **) malloc((nargs + 1) * (sizeof *args));
  23.627 -    if (args == NULL) {
  23.628 -        exit(-1);
  23.629 -    }
  23.630 -    ParseCommandLine(commandLine, args);
  23.631 -
  23.632 -    /* Run the main application code */
  23.633 -    SDL_main(nargs, args);
  23.634 -    free(args);
  23.635 -    free(commandLine);
  23.636 -
  23.637 -    /* Remove useless stdout.txt and stderr.txt */
  23.638 -    cleanup_output();
  23.639 -#else // defined(__APPLE__) && defined(__MACH__)
  23.640 -    SDL_main(argc, argv);
  23.641 -#endif
  23.642 -
  23.643 -    /* Exit cleanly, calling atexit() functions */
  23.644 -    exit(0);
  23.645 -
  23.646 -    /* Never reached, but keeps the compiler quiet */
  23.647 -    return (0);
  23.648 -}
  23.649 -
  23.650 -/* vi: set ts=4 sw=4 expandtab: */
    24.1 --- a/src/main/macos/SIZE.r	Thu Aug 10 14:35:42 2006 +0000
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,24 +0,0 @@
    24.4 -
    24.5 -#include "Processes.r"
    24.6 -
    24.7 -resource 'SIZE' (-1) {
    24.8 -	reserved,
    24.9 -	acceptSuspendResumeEvents,
   24.10 -	reserved,
   24.11 -	canBackground,
   24.12 -	doesActivateOnFGSwitch,
   24.13 -	backgroundAndForeground,
   24.14 -	getFrontClicks,
   24.15 -	ignoreAppDiedEvents,
   24.16 -	is32BitCompatible,
   24.17 -	isHighLevelEventAware,
   24.18 -	onlyLocalHLEvents,
   24.19 -	notStationeryAware,
   24.20 -	useTextEditServices,
   24.21 -	reserved,
   24.22 -	reserved,
   24.23 -	reserved,
   24.24 -	5242880,		// 5 megs minimum
   24.25 -	5242880			// 5 megs maximum
   24.26 -};
   24.27 -
    25.1 --- a/src/main/macos/exports/Makefile	Thu Aug 10 14:35:42 2006 +0000
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,34 +0,0 @@
    25.4 -
    25.5 -EXPORTS = SDL.x
    25.6 -HEADERS = \
    25.7 -	../../../../include/SDL.h \
    25.8 -	../../../../include/SDL_active.h \
    25.9 -	../../../../include/SDL_audio.h \
   25.10 -	../../../../include/SDL_cdrom.h \
   25.11 -	../../../../include/SDL_copying.h \
   25.12 -	../../../../include/SDL_cpuinfo.h \
   25.13 -	../../../../include/SDL_endian.h \
   25.14 -	../../../../include/SDL_error.h \
   25.15 -	../../../../include/SDL_events.h \
   25.16 -	../../../../include/SDL_joystick.h \
   25.17 -	../../../../include/SDL_keyboard.h \
   25.18 -	../../../../include/SDL_keysym.h \
   25.19 -	../../../../include/SDL_loadso.h \
   25.20 -	../../../../include/SDL_mouse.h \
   25.21 -	../../../../include/SDL_mutex.h \
   25.22 -	../../../../include/SDL_quit.h \
   25.23 -	../../../../include/SDL_rwops.h \
   25.24 -	../../../../include/SDL_syswm.h \
   25.25 -	../../../../include/SDL_thread.h \
   25.26 -	../../../../include/SDL_timer.h \
   25.27 -	../../../../include/SDL_version.h \
   25.28 -	../../../../include/SDL_video.h
   25.29 -
   25.30 -
   25.31 -all: $(EXPORTS)
   25.32 -
   25.33 -$(EXPORTS): Makefile gendef.pl $(HEADERS)
   25.34 -	perl gendef.pl $(HEADERS) >$@ || rm $@
   25.35 -
   25.36 -clean:
   25.37 -	rm -f $(EXPORTS)
    26.1 --- a/src/main/macos/exports/SDL.x	Thu Aug 10 14:35:42 2006 +0000
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,206 +0,0 @@
    26.4 -	SDL_Init
    26.5 -	SDL_InitSubSystem
    26.6 -	SDL_QuitSubSystem
    26.7 -	SDL_WasInit
    26.8 -	SDL_Quit
    26.9 -	SDL_GetAppState
   26.10 -	SDL_AudioInit
   26.11 -	SDL_AudioQuit
   26.12 -	SDL_AudioDriverName
   26.13 -	SDL_OpenAudio
   26.14 -	SDL_GetAudioStatus
   26.15 -	SDL_PauseAudio
   26.16 -	SDL_LoadWAV_RW
   26.17 -	SDL_FreeWAV
   26.18 -	SDL_BuildAudioCVT
   26.19 -	SDL_ConvertAudio
   26.20 -	SDL_MixAudio
   26.21 -	SDL_LockAudio
   26.22 -	SDL_UnlockAudio
   26.23 -	SDL_CloseAudio
   26.24 -	SDL_CDNumDrives
   26.25 -	SDL_CDName
   26.26 -	SDL_CDOpen
   26.27 -	SDL_CDStatus
   26.28 -	SDL_CDPlayTracks
   26.29 -	SDL_CDPlay
   26.30 -	SDL_CDPause
   26.31 -	SDL_CDResume
   26.32 -	SDL_CDStop
   26.33 -	SDL_CDEject
   26.34 -	SDL_CDClose
   26.35 -	SDL_HasRDTSC
   26.36 -	SDL_HasMMX
   26.37 -	SDL_HasMMXExt
   26.38 -	SDL_Has3DNow
   26.39 -	SDL_Has3DNowExt
   26.40 -	SDL_HasSSE
   26.41 -	SDL_HasSSE2
   26.42 -	SDL_HasAltiVec
   26.43 -	SDL_SetError
   26.44 -	SDL_GetError
   26.45 -	SDL_ClearError
   26.46 -	SDL_Error
   26.47 -	SDL_PumpEvents
   26.48 -	SDL_PeepEvents
   26.49 -	SDL_PollEvent
   26.50 -	SDL_WaitEvent
   26.51 -	SDL_PushEvent
   26.52 -	SDL_SetEventFilter
   26.53 -	SDL_GetEventFilter
   26.54 -	SDL_EventState
   26.55 -	SDL_NumJoysticks
   26.56 -	SDL_JoystickName
   26.57 -	SDL_JoystickOpen
   26.58 -	SDL_JoystickOpened
   26.59 -	SDL_JoystickIndex
   26.60 -	SDL_JoystickNumAxes
   26.61 -	SDL_JoystickNumBalls
   26.62 -	SDL_JoystickNumHats
   26.63 -	SDL_JoystickNumButtons
   26.64 -	SDL_JoystickUpdate
   26.65 -	SDL_JoystickEventState
   26.66 -	SDL_JoystickGetAxis
   26.67 -	SDL_JoystickGetHat
   26.68 -	SDL_JoystickGetBall
   26.69 -	SDL_JoystickGetButton
   26.70 -	SDL_JoystickClose
   26.71 -	SDL_EnableUNICODE
   26.72 -	SDL_EnableKeyRepeat
   26.73 -	SDL_GetKeyRepeat
   26.74 -	SDL_GetKeyState
   26.75 -	SDL_GetModState
   26.76 -	SDL_SetModState
   26.77 -	SDL_GetKeyName
   26.78 -	SDL_LoadObject
   26.79 -	SDL_LoadFunction
   26.80 -	SDL_UnloadObject
   26.81 -	SDL_GetMouseState
   26.82 -	SDL_GetRelativeMouseState
   26.83 -	SDL_WarpMouse
   26.84 -	SDL_CreateCursor
   26.85 -	SDL_SetCursor
   26.86 -	SDL_GetCursor
   26.87 -	SDL_FreeCursor
   26.88 -	SDL_ShowCursor
   26.89 -	SDL_CreateMutex
   26.90 -	SDL_mutexP
   26.91 -	SDL_mutexV
   26.92 -	SDL_DestroyMutex
   26.93 -	SDL_CreateSemaphore
   26.94 -	SDL_DestroySemaphore
   26.95 -	SDL_SemWait
   26.96 -	SDL_SemTryWait
   26.97 -	SDL_SemWaitTimeout
   26.98 -	SDL_SemPost
   26.99 -	SDL_SemValue
  26.100 -	SDL_CreateCond
  26.101 -	SDL_DestroyCond
  26.102 -	SDL_CondSignal
  26.103 -	SDL_CondBroadcast
  26.104 -	SDL_CondWait
  26.105 -	SDL_CondWaitTimeout
  26.106 -	SDL_RWFromFile
  26.107 -	SDL_RWFromFP
  26.108 -	SDL_RWFromMem
  26.109 -	SDL_RWFromConstMem
  26.110 -	SDL_AllocRW
  26.111 -	SDL_FreeRW
  26.112 -	SDL_ReadLE16
  26.113 -	SDL_ReadBE16
  26.114 -	SDL_ReadLE32
  26.115 -	SDL_ReadBE32
  26.116 -	SDL_ReadLE64
  26.117 -	SDL_ReadBE64
  26.118 -	SDL_WriteLE16
  26.119 -	SDL_WriteBE16
  26.120 -	SDL_WriteLE32
  26.121 -	SDL_WriteBE32
  26.122 -	SDL_WriteLE64
  26.123 -	SDL_WriteBE64
  26.124 -	SDL_GetWMInfo
  26.125 -	SDL_CreateThread
  26.126 -	SDL_CreateThread
  26.127 -	SDL_ThreadID
  26.128 -	SDL_GetThreadID
  26.129 -	SDL_WaitThread
  26.130 -	SDL_KillThread
  26.131 -	SDL_GetTicks
  26.132 -	SDL_Delay
  26.133 -	SDL_SetTimer
  26.134 -	SDL_AddTimer
  26.135 -	SDL_RemoveTimer
  26.136 -	SDL_Linked_Version
  26.137 -	SDL_VideoInit
  26.138 -	SDL_VideoQuit
  26.139 -	SDL_VideoDriverName
  26.140 -	SDL_GetVideoSurface
  26.141 -	SDL_GetVideoInfo
  26.142 -	SDL_VideoModeOK
  26.143 -	SDL_ListModes
  26.144 -	SDL_SetVideoMode
  26.145 -	SDL_UpdateRects
  26.146 -	SDL_UpdateRect
  26.147 -	SDL_Flip
  26.148 -	SDL_SetGamma
  26.149 -	SDL_SetGammaRamp
  26.150 -	SDL_GetGammaRamp
  26.151 -	SDL_SetColors
  26.152 -	SDL_SetPalette
  26.153 -	SDL_MapRGB
  26.154 -	SDL_MapRGBA
  26.155 -	SDL_GetRGB
  26.156 -	SDL_GetRGBA
  26.157 -	SDL_CreateRGBSurface
  26.158 -	SDL_CreateRGBSurfaceFrom
  26.159 -	SDL_FreeSurface
  26.160 -	SDL_LockSurface
  26.161 -	SDL_UnlockSurface
  26.162 -	SDL_LoadBMP_RW
  26.163 -	SDL_SaveBMP_RW
  26.164 -	SDL_SetColorKey
  26.165 -	SDL_SetAlpha
  26.166 -	SDL_SetClipRect
  26.167 -	SDL_GetClipRect
  26.168 -	SDL_ConvertSurface
  26.169 -	SDL_UpperBlit
  26.170 -	SDL_LowerBlit
  26.171 -	SDL_FillRect
  26.172 -	SDL_DisplayFormat
  26.173 -	SDL_DisplayFormatAlpha
  26.174 -	SDL_CreateYUVOverlay
  26.175 -	SDL_LockYUVOverlay
  26.176 -	SDL_UnlockYUVOverlay
  26.177 -	SDL_DisplayYUVOverlay
  26.178 -	SDL_FreeYUVOverlay
  26.179 -	SDL_GL_LoadLibrary
  26.180 -	SDL_GL_GetProcAddress
  26.181 -	SDL_GL_SetAttribute
  26.182 -	SDL_GL_GetAttribute
  26.183 -	SDL_GL_SwapBuffers
  26.184 -	SDL_WM_SetCaption
  26.185 -	SDL_WM_GetCaption
  26.186 -	SDL_WM_SetIcon
  26.187 -	SDL_WM_IconifyWindow
  26.188 -	SDL_WM_ToggleFullScreen
  26.189 -	SDL_WM_GrabInput
  26.190 -	SDL_SoftStretch
  26.191 -	SDL_putenv
  26.192 -	SDL_getenv
  26.193 -	SDL_qsort
  26.194 -	SDL_revcpy
  26.195 -	SDL_strlcpy
  26.196 -	SDL_strlcat
  26.197 -	SDL_strdup
  26.198 -	SDL_strrev
  26.199 -	SDL_strupr
  26.200 -	SDL_strlwr
  26.201 -	SDL_ltoa
  26.202 -	SDL_ultoa
  26.203 -	SDL_strcasecmp
  26.204 -	SDL_strncasecmp
  26.205 -	SDL_snprintf
  26.206 -	SDL_vsnprintf
  26.207 -	SDL_iconv
  26.208 -	SDL_iconv_string
  26.209 -	SDL_InitQuickDraw
    27.1 --- a/src/main/macos/exports/gendef.pl	Thu Aug 10 14:35:42 2006 +0000
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,43 +0,0 @@
    27.4 -#!/usr/bin/perl
    27.5 -#
    27.6 -# Program to take a set of header files and generate DLL export definitions
    27.7 -
    27.8 -# Special exports to ignore for this platform
    27.9 -
   27.10 -while ( ($file = shift(@ARGV)) ) {
   27.11 -	if ( ! defined(open(FILE, $file)) ) {
   27.12 -		warn "Couldn't open $file: $!\n";
   27.13 -		next;
   27.14 -	}
   27.15 -	$printed_header = 0;
   27.16 -	$file =~ s,.*/,,;
   27.17 -	while (<FILE>) {
   27.18 -		if ( / DECLSPEC.* SDLCALL ([^\s\(]+)/ ) {
   27.19 -			if ( not $exclude{$1} ) {
   27.20 -				print "\t$1\n";
   27.21 -			}
   27.22 -		}
   27.23 -	}
   27.24 -	close(FILE);
   27.25 -}
   27.26 -
   27.27 -# Special exports to include for this platform
   27.28 -print "\tSDL_putenv\n";
   27.29 -print "\tSDL_getenv\n";
   27.30 -print "\tSDL_qsort\n";
   27.31 -print "\tSDL_revcpy\n";
   27.32 -print "\tSDL_strlcpy\n";
   27.33 -print "\tSDL_strlcat\n";
   27.34 -print "\tSDL_strdup\n";
   27.35 -print "\tSDL_strrev\n";
   27.36 -print "\tSDL_strupr\n";
   27.37 -print "\tSDL_strlwr\n";
   27.38 -print "\tSDL_ltoa\n";
   27.39 -print "\tSDL_ultoa\n";
   27.40 -print "\tSDL_strcasecmp\n";
   27.41 -print "\tSDL_strncasecmp\n";
   27.42 -print "\tSDL_snprintf\n";
   27.43 -print "\tSDL_vsnprintf\n";
   27.44 -print "\tSDL_iconv\n";
   27.45 -print "\tSDL_iconv_string\n";
   27.46 -print "\tSDL_InitQuickDraw\n";
    28.1 --- a/src/timer/macos/FastTimes.c	Thu Aug 10 14:35:42 2006 +0000
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,348 +0,0 @@
    28.4 -/* File "FastTimes.c" - Original code by Matt Slot <fprefect@ambrosiasw.com>  */
    28.5 -/* Created 4/24/99    - This file is hereby placed in the public domain       */
    28.6 -/* Updated 5/21/99    - Calibrate to VIA, add TBR support, renamed functions  */
    28.7 -/* Updated 10/4/99    - Use AbsoluteToNanoseconds() in case Absolute = double */
    28.8 -/* Updated 2/15/00    - Check for native Time Manager, no need to calibrate   */
    28.9 -/* Updated 2/19/00    - Fixed default value for gScale under native Time Mgr  */
   28.10 -/* Updated 3/21/00    - Fixed ns conversion, create 2 different scale factors */
   28.11 -/* Updated 5/03/00    - Added copyright and placed into PD. No code changes   */
   28.12 -/* Updated 8/01/00    - Made "Carbon-compatible" by replacing LMGetTicks()    */
   28.13 -
   28.14 -/* This file is Copyright (C) Matt Slot, 1999-2000. It is hereby placed into 
   28.15 -   the public domain. The author makes no warranty as to fitness or stability */
   28.16 -
   28.17 -#include <Gestalt.h>
   28.18 -#include <LowMem.h>
   28.19 -#include <CodeFragments.h>
   28.20 -#include <DriverServices.h>
   28.21 -#include <Timer.h>
   28.22 -
   28.23 -#include "FastTimes.h"
   28.24 -
   28.25 -#ifdef TARGET_CPU_PPC
   28.26 -#undef GENERATINGPOWERPC        /* stop whining */
   28.27 -#define GENERATINGPOWERPC TARGET_CPU_PPC
   28.28 -#endif
   28.29 -
   28.30 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
   28.31 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
   28.32 -/*
   28.33 -	On 680x0 machines, we just use Microseconds().
   28.34 -	
   28.35 -	On PowerPC machines, we try several methods:
   28.36 -	  * DriverServicesLib is available on all PCI PowerMacs, and perhaps
   28.37 -	    some NuBus PowerMacs. If it is, we use UpTime() : Overhead = 2.1 sec.
   28.38 -	  * The PowerPC 601 has a built-in "real time clock" RTC, and we fall
   28.39 -	    back to that, accessing it directly from asm. Overhead = 1.3 sec.
   28.40 -	  * Later PowerPCs have an accurate "time base register" TBR, and we 
   28.41 -	    fall back to that, access it from PowerPC asm. Overhead = 1.3 sec.
   28.42 -	  * We can also try Microseconds() which is emulated : Overhead = 36 sec.
   28.43 -
   28.44 -	On PowerPC machines, we avoid the following:
   28.45 -	  * OpenTransport is available on all PCI and some NuBus PowerMacs, but it
   28.46 -	    uses UpTime() if available and falls back to Microseconds() otherwise.
   28.47 -	  * InputSprocket is available on many PowerMacs, but again it uses
   28.48 -	    UpTime() if available and falls back to Microseconds() otherwise.
   28.49 -
   28.50 -	Another PowerPC note: certain configurations, especially 3rd party upgrade
   28.51 -	cards, may return inaccurate timings for the CPU or memory bus -- causing
   28.52 -	skew in various system routines (up to 20% drift!). The VIA chip is very
   28.53 -	accurate, and it's the basis for the Time Manager and Microseconds().
   28.54 -	Unfortunately, it's also very slow because the MacOS has to (a) switch to
   28.55 -	68K and (b) poll for a VIA event.
   28.56 -	
   28.57 -	We compensate for the drift by calibrating a floating point scale factor
   28.58 -	between our fast method and the accurate timer at startup, then convert
   28.59 -	each sample quickly on the fly. I'd rather not have the initialization 
   28.60 -	overhead -- but it's simply necessary for accurate timing. You can drop
   28.61 -	it down to 30 ticks if you prefer, but that's as low as I'd recommend.
   28.62 -
   28.63 -	Under MacOS 9, "new world" Macs (iMacs, B+W G3s and G+W G4s) have a native
   28.64 -	Time Manager implementation: UpTime(), Microseconds(), and TickCount() are
   28.65 -	all based on the same underlying counter. This makes it silly to calibrate
   28.66 -	UpTime() against TickCount(). We now check for this feature using Gestalt(),
   28.67 -	and skip the whole calibration step if possible.
   28.68 -
   28.69 -*/
   28.70 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
   28.71 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
   28.72 -
   28.73 -#define RTCToNano(w)	((double) (w).hi * 1000000000.0 + (double) (w).lo)
   28.74 -#define WideTo64bit(w)	(*(UInt64 *) &(w))
   28.75 -
   28.76 -/* LMGetTicks() is not in Carbon and TickCount() has a fair bit of overhead,
   28.77 -   so for speed we always read lowmem directly. This is a Mac OS X no-no, but 
   28.78 -   it always work on those systems that don't have a native Time Manager (ie,
   28.79 -   anything before MacOS 9) -- regardless whether we are in Carbon or not! */
   28.80 -#define MyLMGetTicks()	(*(volatile UInt32 *) 0x16A)
   28.81 -
   28.82 -#if GENERATINGPOWERPC
   28.83 -
   28.84 -static asm UnsignedWide PollRTC(void);
   28.85 -static asm UnsignedWide PollTBR(void);
   28.86 -static Ptr FindFunctionInSharedLib(StringPtr libName, StringPtr funcName);
   28.87 -
   28.88 -static Boolean gInited = false;
   28.89 -static Boolean gNative = false;
   28.90 -static Boolean gUseRTC = false;
   28.91 -static Boolean gUseTBR = false;
   28.92 -static double gScaleUSec = 1.0 / 1000.0;        /* 1 / ( nsec / usec) */
   28.93 -static double gScaleMSec = 1.0 / 1000000.0;     /* 1 / ( nsec / msec) */
   28.94 -
   28.95 -/* Functions loaded from DriverServicesLib */
   28.96 -typedef AbsoluteTime(*UpTimeProcPtr) (void);
   28.97 -typedef Nanoseconds(*A2NSProcPtr) (AbsoluteTime);
   28.98 -static UpTimeProcPtr gUpTime = NULL;
   28.99 -static A2NSProcPtr gA2NS = NULL;
  28.100 -
  28.101 -#endif /* GENERATINGPOWERPC */
  28.102 -
  28.103 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.104 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.105 -
  28.106 -void
  28.107 -FastInitialize()
  28.108 -{
  28.109 -    SInt32 result;
  28.110 -
  28.111 -    if (!gInited) {
  28.112 -
  28.113 -#if GENERATINGPOWERPC
  28.114 -
  28.115 -        /* Initialize the feature flags */
  28.116 -        gNative = gUseRTC = gUseTBR = false;
  28.117 -
  28.118 -        /* We use CFM to find and load needed symbols from shared libraries, so
  28.119 -           the application doesn't have to weak-link them, for convenience.   */
  28.120 -        gUpTime =
  28.121 -            (UpTimeProcPtr) FindFunctionInSharedLib("\pDriverServicesLib",
  28.122 -                                                    "\pUpTime");
  28.123 -        if (gUpTime)
  28.124 -            gA2NS = (A2NSProcPtr)
  28.125 -                FindFunctionInSharedLib("\pDriverServicesLib",
  28.126 -                                        "\pAbsoluteToNanoseconds");
  28.127 -        if (!gA2NS)
  28.128 -            gUpTime = nil;      /* Pedantic but necessary */
  28.129 -
  28.130 -        if (gUpTime) {
  28.131 -            /* If we loaded UpTime(), then we need to know if the system has
  28.132 -               a native implementation of the Time Manager. If so, then it's
  28.133 -               pointless to calculate a scale factor against the missing VIA */
  28.134 -
  28.135 -            /* gestaltNativeTimeMgr = 4 in some future version of the headers */
  28.136 -            if (!Gestalt(gestaltTimeMgrVersion, &result) &&
  28.137 -                (result > gestaltExtendedTimeMgr))
  28.138 -                gNative = true;
  28.139 -        } else {
  28.140 -            /* If no DriverServicesLib, use Gestalt() to get the processor type. 
  28.141 -               Only NuBus PowerMacs with old System Software won't have DSL, so
  28.142 -               we know it should either be a 601 or 603. */
  28.143 -
  28.144 -            /* Use the processor gestalt to determine which register to use */
  28.145 -            if (!Gestalt(gestaltNativeCPUtype, &result)) {
  28.146 -                if (result == gestaltCPU601)
  28.147 -                    gUseRTC = true;
  28.148 -                else if (result > gestaltCPU601)
  28.149 -                    gUseTBR = true;
  28.150 -            }
  28.151 -        }
  28.152 -
  28.153 -        /* Now calculate a scale factor to keep us accurate. */
  28.154 -        if ((gUpTime && !gNative) || gUseRTC || gUseTBR) {
  28.155 -            UInt64 tick, usec1, usec2;
  28.156 -            UnsignedWide wide;
  28.157 -
  28.158 -            /* Wait for the beginning of the very next tick */
  28.159 -            for (tick = MyLMGetTicks() + 1; tick > MyLMGetTicks(););
  28.160 -
  28.161 -            /* Poll the selected timer and prepare it (since we have time) */
  28.162 -            wide = (gUpTime) ? (*gA2NS) ((*gUpTime) ()) :
  28.163 -                ((gUseRTC) ? PollRTC() : PollTBR());
  28.164 -            usec1 = (gUseRTC) ? RTCToNano(wide) : WideTo64bit(wide);
  28.165 -
  28.166 -            /* Wait for the exact 60th tick to roll over */
  28.167 -            while (tick + 60 > MyLMGetTicks());
  28.168 -
  28.169 -            /* Poll the selected timer again and prepare it  */
  28.170 -            wide = (gUpTime) ? (*gA2NS) ((*gUpTime) ()) :
  28.171 -                ((gUseRTC) ? PollRTC() : PollTBR());
  28.172 -            usec2 = (gUseRTC) ? RTCToNano(wide) : WideTo64bit(wide);
  28.173 -
  28.174 -            /* Calculate a scale value that will give microseconds per second.
  28.175 -               Remember, there are actually 60.15 ticks in a second, not 60.  */
  28.176 -            gScaleUSec = (60.0 * 1000000.0) / ((usec2 - usec1) * 60.15);
  28.177 -            gScaleMSec = gScaleUSec / 1000.0;
  28.178 -        }
  28.179 -#endif /* GENERATINGPOWERPC */
  28.180 -
  28.181 -        /* We've initialized our globals */
  28.182 -        gInited = true;
  28.183 -    }
  28.184 -}
  28.185 -
  28.186 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.187 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.188 -
  28.189 -UInt64
  28.190 -FastMicroseconds()
  28.191 -{
  28.192 -    UnsignedWide wide;
  28.193 -    UInt64 usec;
  28.194 -
  28.195 -#if GENERATINGPOWERPC
  28.196 -    /* Initialize globals the first time we are called */
  28.197 -    if (!gInited)
  28.198 -        FastInitialize();
  28.199 -
  28.200 -    if (gNative) {
  28.201 -        /* Use DriverServices if it's available -- it's fast and compatible */
  28.202 -        wide = (*gA2NS) ((*gUpTime) ());
  28.203 -        usec = (double) WideTo64bit(wide) * gScaleUSec + 0.5;
  28.204 -    } else if (gUpTime) {
  28.205 -        /* Use DriverServices if it's available -- it's fast and compatible */
  28.206 -        wide = (*gA2NS) ((*gUpTime) ());
  28.207 -        usec = (double) WideTo64bit(wide) * gScaleUSec + 0.5;
  28.208 -    } else if (gUseTBR) {
  28.209 -        /* On a recent PowerPC, we poll the TBR directly */
  28.210 -        wide = PollTBR();
  28.211 -        usec = (double) WideTo64bit(wide) * gScaleUSec + 0.5;
  28.212 -    } else if (gUseRTC) {
  28.213 -        /* On a 601, we can poll the RTC instead */
  28.214 -        wide = PollRTC();
  28.215 -        usec = (double) RTCToNano(wide) * gScaleUSec + 0.5;
  28.216 -    } else
  28.217 -#endif /* GENERATINGPOWERPC */
  28.218 -    {
  28.219 -        /* If all else fails, suffer the mixed mode overhead */
  28.220 -        Microseconds(&wide);
  28.221 -        usec = WideTo64bit(wide);
  28.222 -    }
  28.223 -
  28.224 -    return (usec);
  28.225 -}
  28.226 -
  28.227 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.228 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.229 -
  28.230 -UInt64
  28.231 -FastMilliseconds()
  28.232 -{
  28.233 -    UnsignedWide wide;
  28.234 -    UInt64 msec;
  28.235 -
  28.236 -#if GENERATINGPOWERPC
  28.237 -    /* Initialize globals the first time we are called */
  28.238 -    if (!gInited)
  28.239 -        FastInitialize();
  28.240 -
  28.241 -    if (gNative) {
  28.242 -        /* Use DriverServices if it's available -- it's fast and compatible */
  28.243 -        wide = (*gA2NS) ((*gUpTime) ());
  28.244 -        msec = (double) WideTo64bit(wide) * gScaleMSec + 0.5;
  28.245 -    } else if (gUpTime) {
  28.246 -        /* Use DriverServices if it's available -- it's fast and compatible */
  28.247 -        wide = (*gA2NS) ((*gUpTime) ());
  28.248 -        msec = (double) WideTo64bit(wide) * gScaleMSec + 0.5;
  28.249 -    } else if (gUseTBR) {
  28.250 -        /* On a recent PowerPC, we poll the TBR directly */
  28.251 -        wide = PollTBR();
  28.252 -        msec = (double) WideTo64bit(wide) * gScaleMSec + 0.5;
  28.253 -    } else if (gUseRTC) {
  28.254 -        /* On a 601, we can poll the RTC instead */
  28.255 -        wide = PollRTC();
  28.256 -        msec = (double) RTCToNano(wide) * gScaleMSec + 0.5;
  28.257 -    } else
  28.258 -#endif /* GENERATINGPOWERPC */
  28.259 -    {
  28.260 -        /* If all else fails, suffer the mixed mode overhead */
  28.261 -        Microseconds(&wide);
  28.262 -        msec = ((double) WideTo64bit(wide) + 500.0) / 1000.0;
  28.263 -    }
  28.264 -
  28.265 -    return (msec);
  28.266 -}
  28.267 -
  28.268 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.269 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.270 -
  28.271 -StringPtr
  28.272 -FastMethod()
  28.273 -{
  28.274 -    StringPtr method = "\p<Unknown>";
  28.275 -
  28.276 -#if GENERATINGPOWERPC
  28.277 -    /* Initialize globals the first time we are called */
  28.278 -    if (!gInited)
  28.279 -        FastInitialize();
  28.280 -
  28.281 -    if (gNative) {
  28.282 -        /* The Time Manager and UpTime() are entirely native on this machine */
  28.283 -        method = "\pNative UpTime()";
  28.284 -    } else if (gUpTime) {
  28.285 -        /* Use DriverServices if it's available -- it's fast and compatible */
  28.286 -        method = "\pUpTime()";
  28.287 -    } else if (gUseTBR) {
  28.288 -        /* On a recent PowerPC, we poll the TBR directly */
  28.289 -        method = "\pPowerPC TBR";
  28.290 -    } else if (gUseRTC) {
  28.291 -        /* On a 601, we can poll the RTC instead */
  28.292 -        method = "\pPowerPC RTC";
  28.293 -    } else
  28.294 -#endif /* GENERATINGPOWERPC */
  28.295 -    {
  28.296 -        /* If all else fails, suffer the mixed mode overhead */
  28.297 -        method = "\pMicroseconds()";
  28.298 -    }
  28.299 -
  28.300 -    return (method);
  28.301 -}
  28.302 -
  28.303 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.304 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.305 -#pragma mark -
  28.306 -
  28.307 -#if GENERATINGPOWERPC
  28.308 -asm static UnsignedWide
  28.309 -PollRTC_()
  28.310 -{
  28.311 -    entry PollRTC               /* Avoid CodeWarrior glue */
  28.312 -      machine 601 @ AGAIN:mfrtcu r4     /* RTCU = SPR 4 */
  28.313 -      mfrtcl r5                 /* RTCL = SPR 5 */
  28.314 -  mfrtcu r6 cmpw r4, r6 bne @ AGAIN stw r4, 0(r3) stw r5, 4(r3) blr}
  28.315 -
  28.316 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.317 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.318 -
  28.319 -asm static UnsignedWide
  28.320 -PollTBR_()
  28.321 -{
  28.322 -    entry PollTBR               /* Avoid CodeWarrior glue */
  28.323 -      machine 604 @ AGAIN:mftbu r4      /* TBRU = SPR 268 */
  28.324 -      mftb r5                   /* TBRL = SPR 269 */
  28.325 -  mftbu r6 cmpw r4, r6 bne @ AGAIN stw r4, 0(r3) stw r5, 4(r3) blr}
  28.326 -
  28.327 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.328 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  28.329 -
  28.330 -static Ptr
  28.331 -FindFunctionInSharedLib(StringPtr libName, StringPtr funcName)
  28.332 -{
  28.333 -    OSErr error = noErr;
  28.334 -    Str255 errorStr;
  28.335 -    Ptr func = NULL;
  28.336 -    Ptr entry = NULL;
  28.337 -    CFragSymbolClass symClass;
  28.338 -    CFragConnectionID connID;
  28.339 -
  28.340 -    /* Find CFM containers for the current archecture -- CFM-PPC or CFM-68K */
  28.341 -    if ( /* error = */ GetSharedLibrary(libName, kCompiledCFragArch,
  28.342 -                                        kLoadCFrag, &connID, &entry,
  28.343 -                                        errorStr))
  28.344 -        return (NULL);
  28.345 -    if ( /* error = */ FindSymbol(connID, funcName, &func, &symClass))
  28.346 -        return (NULL);
  28.347 -
  28.348 -    return (func);
  28.349 -}
  28.350 -#endif /* GENERATINGPOWERPC */
  28.351 -/* vi: set ts=4 sw=4 expandtab: */
    29.1 --- a/src/timer/macos/FastTimes.h	Thu Aug 10 14:35:42 2006 +0000
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,28 +0,0 @@
    29.4 -/* File "FastTimes.h" - Original code by Matt Slot <fprefect@ambrosiasw.com>  */
    29.5 -#include "SDL_config.h"
    29.6 -/* Created 4/24/99    - This file is hereby placed in the public domain       */
    29.7 -/* Updated 5/21/99    - Calibrate to VIA, add TBR support, renamed functions  */
    29.8 -/* Updated 10/4/99    - Use AbsoluteToNanoseconds() in case Absolute = double */
    29.9 -/* Updated 2/15/00    - Check for native Time Manager, no need to calibrate   */
   29.10 -/* Updated 3/21/00    - Fixed ns conversion, create 2 different scale factors */
   29.11 -/* Updated 5/03/00    - Added copyright and placed into PD. No code changes   */
   29.12 -
   29.13 -/* This file is Copyright (C) Matt Slot, 1999-2000. It is hereby placed into 
   29.14 -   the public domain. The author makes no warranty as to fitness or stability */
   29.15 -
   29.16 -#ifndef __FAST_TIMES_HEADER__
   29.17 -#define __FAST_TIMES_HEADER__
   29.18 -
   29.19 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
   29.20 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
   29.21 -
   29.22 -extern void FastInitialize(void);
   29.23 -extern UInt64 FastMicroseconds(void);
   29.24 -extern UInt64 FastMilliseconds(void);
   29.25 -extern StringPtr FastMethod(void);
   29.26 -
   29.27 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
   29.28 -/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
   29.29 -
   29.30 -#endif /* __FAST_TIMES_HEADER__ */
   29.31 -/* vi: set ts=4 sw=4 expandtab: */
    30.1 --- a/src/timer/macos/SDL_MPWtimer.c	Thu Aug 10 14:35:42 2006 +0000
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,161 +0,0 @@
    30.4 -/*
    30.5 -    SDL - Simple DirectMedia Layer
    30.6 -    Copyright (C) 1997-2006 Sam Lantinga
    30.7 -
    30.8 -    This library is free software; you can redistribute it and/or
    30.9 -    modify it under the terms of the GNU Lesser General Public
   30.10 -    License as published by the Free Software Foundation; either
   30.11 -    version 2.1 of the License, or (at your option) any later version.
   30.12 -
   30.13 -    This library is distributed in the hope that it will be useful,
   30.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   30.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   30.16 -    Lesser General Public License for more details.
   30.17 -
   30.18 -    You should have received a copy of the GNU Lesser General Public
   30.19 -    License along with this library; if not, write to the Free Software
   30.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   30.21 -
   30.22 -    Sam Lantinga
   30.23 -    slouken@libsdl.org
   30.24 -*/
   30.25 -#include "SDL_config.h"
   30.26 -
   30.27 -#ifdef SDL_TIMER_MACOS
   30.28 -
   30.29 -#include <Types.h>
   30.30 -#include <Timer.h>
   30.31 -#include <OSUtils.h>
   30.32 -#include <Gestalt.h>
   30.33 -#include <Processes.h>
   30.34 -
   30.35 -#include <LowMem.h>
   30.36 -
   30.37 -#include "SDL_timer.h"
   30.38 -#include "../SDL_timer_c.h"
   30.39 -
   30.40 -#define MS_PER_TICK	(1000/60)       /* MacOS tick = 1/60 second */
   30.41 -
   30.42 -/* Note: This is only a step above the original 1/60s implementation.
   30.43 - *       For a good implementation, see FastTimes.[ch], by Matt Slot.
   30.44 - */
   30.45 -#define USE_MICROSECONDS
   30.46 -#define WideTo64bit(w)	(*(UInt64 *) &(w))
   30.47 -
   30.48 -UInt64 start;
   30.49 -
   30.50 -void
   30.51 -SDL_StartTicks(void)
   30.52 -{
   30.53 -#ifdef USE_MICROSECONDS
   30.54 -    UnsignedWide now;
   30.55 -
   30.56 -    Microseconds(&now);
   30.57 -    start = WideTo64bit(now);
   30.58 -#else
   30.59 -    /* FIXME: Should we implement a wrapping algorithm, like Win32? */
   30.60 -#endif
   30.61 -}
   30.62 -
   30.63 -Uint32
   30.64 -SDL_GetTicks(void)
   30.65 -{
   30.66 -#ifdef USE_MICROSECONDS
   30.67 -    UnsignedWide now;
   30.68 -
   30.69 -    Microseconds(&now);
   30.70 -    return (Uint32) ((WideTo64bit(now) - start) / 1000);
   30.71 -#else
   30.72 -    return (LMGetTicks() * MS_PER_TICK);
   30.73 -#endif
   30.74 -}
   30.75 -
   30.76 -void
   30.77 -SDL_Delay(Uint32 ms)
   30.78 -{
   30.79 -#ifdef USE_MICROSECONDS
   30.80 -    Uint32 end_ms;
   30.81 -
   30.82 -    end_ms = SDL_GetTicks() + ms;
   30.83 -    do {
   30.84 -        /* FIXME: Yield CPU? */ ;
   30.85 -    }
   30.86 -    while (SDL_GetTicks() < end_ms);
   30.87 -#else
   30.88 -    UInt32 unused;              /* MJS */
   30.89 -    Delay(ms / MS_PER_TICK, &unused);
   30.90 -#endif
   30.91 -}
   30.92 -
   30.93 -
   30.94 -/* Data to handle a single periodic alarm */
   30.95 -typedef struct _ExtendedTimerRec
   30.96 -{
   30.97 -    TMTask tmTask;
   30.98 -    ProcessSerialNumber taskPSN;
   30.99 -} ExtendedTimerRec, *ExtendedTimerPtr;
  30.100 -
  30.101 -static ExtendedTimerRec gExtendedTimerRec;
  30.102 -
  30.103 -
  30.104 -int
  30.105 -SDL_SYS_TimerInit(void)
  30.106 -{
  30.107 -    /* We don't need a setup? */
  30.108 -    return (0);
  30.109 -}
  30.110 -
  30.111 -void
  30.112 -SDL_SYS_TimerQuit(void)
  30.113 -{
  30.114 -    /* We don't need a cleanup? */
  30.115 -    return;
  30.116 -}
  30.117 -
  30.118 -/* Our Stub routine to set up and then call the real routine. */
  30.119 -pascal void
  30.120 -TimerCallbackProc(TMTaskPtr tmTaskPtr)
  30.121 -{
  30.122 -    Uint32 ms;
  30.123 -
  30.124 -    WakeUpProcess(&((ExtendedTimerPtr) tmTaskPtr)->taskPSN);
  30.125 -
  30.126 -    ms = SDL_alarm_callback(SDL_alarm_interval);
  30.127 -    if (ms) {
  30.128 -        SDL_alarm_interval = ROUND_RESOLUTION(ms);
  30.129 -        PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval);
  30.130 -    } else {
  30.131 -        SDL_alarm_interval = 0;
  30.132 -    }
  30.133 -}
  30.134 -
  30.135 -int
  30.136 -SDL_SYS_StartTimer(void)
  30.137 -{
  30.138 -    /*
  30.139 -     * Configure the global structure that stores the timing information.
  30.140 -     */
  30.141 -    gExtendedTimerRec.tmTask.qLink = NULL;
  30.142 -    gExtendedTimerRec.tmTask.qType = 0;
  30.143 -    gExtendedTimerRec.tmTask.tmAddr = NewTimerUPP(TimerCallbackProc);
  30.144 -    gExtendedTimerRec.tmTask.tmCount = 0;
  30.145 -    gExtendedTimerRec.tmTask.tmWakeUp = 0;
  30.146 -    gExtendedTimerRec.tmTask.tmReserved = 0;
  30.147 -    GetCurrentProcess(&gExtendedTimerRec.taskPSN);
  30.148 -
  30.149 -    /* Install the task record */
  30.150 -    InsXTime((QElemPtr) & gExtendedTimerRec.tmTask);
  30.151 -
  30.152 -    /* Go! */
  30.153 -    PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval);
  30.154 -    return (0);
  30.155 -}
  30.156 -
  30.157 -void
  30.158 -SDL_SYS_StopTimer(void)
  30.159 -{
  30.160 -    RmvTime((QElemPtr) & gExtendedTimerRec.tmTask);
  30.161 -}
  30.162 -
  30.163 -#endif /* SDL_TIMER_MACOS */
  30.164 -/* vi: set ts=4 sw=4 expandtab: */
    31.1 --- a/src/timer/macos/SDL_systimer.c	Thu Aug 10 14:35:42 2006 +0000
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,195 +0,0 @@
    31.4 -/*
    31.5 -    SDL - Simple DirectMedia Layer
    31.6 -    Copyright (C) 1997-2006 Sam Lantinga
    31.7 -
    31.8 -    This library is free software; you can redistribute it and/or
    31.9 -    modify it under the terms of the GNU Lesser General Public
   31.10 -    License as published by the Free Software Foundation; either
   31.11 -    version 2.1 of the License, or (at your option) any later version.
   31.12 -
   31.13 -    This library is distributed in the hope that it will be useful,
   31.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   31.16 -    Lesser General Public License for more details.
   31.17 -
   31.18 -    You should have received a copy of the GNU Lesser General Public
   31.19 -    License along with this library; if not, write to the Free Software
   31.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   31.21 -
   31.22 -    Sam Lantinga
   31.23 -    slouken@libsdl.org
   31.24 -*/
   31.25 -#include "SDL_config.h"
   31.26 -
   31.27 -#ifdef SDL_TIMER_MACOS
   31.28 -
   31.29 -#include <Types.h>
   31.30 -#include <Timer.h>
   31.31 -#include <OSUtils.h>
   31.32 -#include <Gestalt.h>
   31.33 -#include <Processes.h>
   31.34 -
   31.35 -#include <LowMem.h>
   31.36 -
   31.37 -#include "SDL_timer.h"
   31.38 -#include "../SDL_timer_c.h"
   31.39 -
   31.40 -#include "FastTimes.h"
   31.41 -
   31.42 -#if TARGET_API_MAC_CARBON
   31.43 -#define NewTimerProc NewTimerUPP
   31.44 -#endif
   31.45 -
   31.46 -#define MS_PER_TICK	(1000.0/60.0)   /* MacOS tick = 1/60 second */
   31.47 -
   31.48 -
   31.49 -#define kTwoPower32     (4294967296.0)  /* 2^32 */
   31.50 -
   31.51 -static double start_tick;
   31.52 -static int is_fast_inited = 0;
   31.53 -
   31.54 -void
   31.55 -SDL_StartTicks(void)
   31.56 -{
   31.57 -    if (!is_fast_inited)        // important to check or FastTime may hang machine!
   31.58 -        SDL_SYS_TimerInit();
   31.59 -
   31.60 -    start_tick = FastMicroseconds();
   31.61 -}
   31.62 -
   31.63 -Uint32
   31.64 -SDL_GetTicks(void)
   31.65 -{
   31.66 -
   31.67 -    if (!is_fast_inited)
   31.68 -        SDL_SYS_TimerInit();
   31.69 -
   31.70 -    return FastMilliseconds();
   31.71 -}
   31.72 -
   31.73 -void
   31.74 -SDL_Delay(Uint32 ms)
   31.75 -{
   31.76 -    Uint32 stop, now;
   31.77 -
   31.78 -    stop = SDL_GetTicks() + ms;
   31.79 -    do {
   31.80 -#if TARGET_API_MAC_CARBON
   31.81 -        MPYield();
   31.82 -#else
   31.83 -        SystemTask();
   31.84 -#endif
   31.85 -
   31.86 -        now = SDL_GetTicks();
   31.87 -
   31.88 -    }
   31.89 -    while (stop > now);
   31.90 -}
   31.91 -
   31.92 -/*
   31.93 -void SDL_StartTicks(void)
   31.94 -{
   31.95 -	// FIXME: Should we implement a wrapping algorithm, like Win32? 
   31.96 -}
   31.97 -
   31.98 -Uint32 SDL_GetTicks(void)
   31.99 -{
  31.100 -	UnsignedWide ms;
  31.101 -	
  31.102 -	Microseconds (&ms);
  31.103 -	
  31.104 -	return ( ms.lo / 1000 );
  31.105 -}
  31.106 -
  31.107 -void SDL_Delay(Uint32 ms)
  31.108 -{
  31.109 -	
  31.110 -	UnsignedWide microsecs;
  31.111 -	UInt32       stop;
  31.112 -	
  31.113 -	Microseconds (&microsecs);
  31.114 -	
  31.115 -	stop = microsecs.lo + (ms * 1000);
  31.116 -	
  31.117 -	while ( stop > microsecs.lo ) {
  31.118 -	
  31.119 -	   SystemTask ();
  31.120 -	   
  31.121 -	   Microseconds (&microsecs);
  31.122 -	}
  31.123 -
  31.124 -}*/
  31.125 -
  31.126 -/* Data to handle a single periodic alarm */
  31.127 -typedef struct _ExtendedTimerRec
  31.128 -{
  31.129 -    TMTask tmTask;
  31.130 -    ProcessSerialNumber taskPSN;
  31.131 -} ExtendedTimerRec, *ExtendedTimerPtr;
  31.132 -
  31.133 -static ExtendedTimerRec gExtendedTimerRec;
  31.134 -
  31.135 -
  31.136 -int
  31.137 -SDL_SYS_TimerInit(void)
  31.138 -{
  31.139 -    FastInitialize();
  31.140 -    is_fast_inited = 1;
  31.141 -
  31.142 -    return (0);
  31.143 -}
  31.144 -
  31.145 -void
  31.146 -SDL_SYS_TimerQuit(void)
  31.147 -{
  31.148 -    /* We don't need a cleanup? */
  31.149 -    return;
  31.150 -}
  31.151 -
  31.152 -/* Our Stub routine to set up and then call the real routine. */
  31.153 -pascal void
  31.154 -TimerCallbackProc(TMTaskPtr tmTaskPtr)
  31.155 -{
  31.156 -    Uint32 ms;
  31.157 -
  31.158 -    WakeUpProcess(&((ExtendedTimerPtr) tmTaskPtr)->taskPSN);
  31.159 -
  31.160 -    ms = SDL_alarm_callback(SDL_alarm_interval);
  31.161 -    if (ms) {
  31.162 -        SDL_alarm_interval = ROUND_RESOLUTION(ms);
  31.163 -        PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval);
  31.164 -    } else {
  31.165 -        SDL_alarm_interval = 0;
  31.166 -    }
  31.167 -}
  31.168 -
  31.169 -int
  31.170 -SDL_SYS_StartTimer(void)
  31.171 -{
  31.172 -    /*
  31.173 -     * Configure the global structure that stores the timing information.
  31.174 -     */
  31.175 -    gExtendedTimerRec.tmTask.qLink = NULL;
  31.176 -    gExtendedTimerRec.tmTask.qType = 0;
  31.177 -    gExtendedTimerRec.tmTask.tmAddr = NewTimerProc(TimerCallbackProc);
  31.178 -    gExtendedTimerRec.tmTask.tmCount = 0;
  31.179 -    gExtendedTimerRec.tmTask.tmWakeUp = 0;
  31.180 -    gExtendedTimerRec.tmTask.tmReserved = 0;
  31.181 -    GetCurrentProcess(&gExtendedTimerRec.taskPSN);
  31.182 -
  31.183 -    /* Install the task record */
  31.184 -    InsXTime((QElemPtr) & gExtendedTimerRec.tmTask);
  31.185 -
  31.186 -    /* Go! */
  31.187 -    PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval);
  31.188 -    return (0);
  31.189 -}
  31.190 -
  31.191 -void
  31.192 -SDL_SYS_StopTimer(void)
  31.193 -{
  31.194 -    RmvTime((QElemPtr) & gExtendedTimerRec.tmTask);
  31.195 -}
  31.196 -
  31.197 -#endif /* SDL_TIMER_MACOS */
  31.198 -/* vi: set ts=4 sw=4 expandtab: */
    32.1 --- a/src/video/SDL_sysvideo.h	Thu Aug 10 14:35:42 2006 +0000
    32.2 +++ b/src/video/SDL_sysvideo.h	Thu Aug 10 14:54:23 2006 +0000
    32.3 @@ -336,12 +336,6 @@
    32.4  #if SDL_VIDEO_DRIVER_BWINDOW
    32.5  extern VideoBootStrap BWINDOW_bootstrap;
    32.6  #endif
    32.7 -#if SDL_VIDEO_DRIVER_TOOLBOX
    32.8 -extern VideoBootStrap TOOLBOX_bootstrap;
    32.9 -#endif
   32.10 -#if SDL_VIDEO_DRIVER_DRAWSPROCKET
   32.11 -extern VideoBootStrap DSp_bootstrap;
   32.12 -#endif
   32.13  #if SDL_VIDEO_DRIVER_CYBERGRAPHICS
   32.14  extern VideoBootStrap CGX_bootstrap;
   32.15  #endif
    33.1 --- a/src/video/SDL_video.c	Thu Aug 10 14:35:42 2006 +0000
    33.2 +++ b/src/video/SDL_video.c	Thu Aug 10 14:54:23 2006 +0000
    33.3 @@ -85,12 +85,6 @@
    33.4  #if SDL_VIDEO_DRIVER_BWINDOW
    33.5      &BWINDOW_bootstrap,
    33.6  #endif
    33.7 -#if SDL_VIDEO_DRIVER_TOOLBOX
    33.8 -    &TOOLBOX_bootstrap,
    33.9 -#endif
   33.10 -#if SDL_VIDEO_DRIVER_DRAWSPROCKET
   33.11 -    &DSp_bootstrap,
   33.12 -#endif
   33.13  #if SDL_VIDEO_DRIVER_CYBERGRAPHICS
   33.14      &CGX_bootstrap,
   33.15  #endif
    34.1 --- a/src/video/maccommon/SDL_lowvideo.h	Thu Aug 10 14:35:42 2006 +0000
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,104 +0,0 @@
    34.4 -/*
    34.5 -    SDL - Simple DirectMedia Layer
    34.6 -    Copyright (C) 1997-2006 Sam Lantinga
    34.7 -
    34.8 -    This library is free software; you can redistribute it and/or
    34.9 -    modify it under the terms of the GNU Lesser General Public
   34.10 -    License as published by the Free Software Foundation; either
   34.11 -    version 2.1 of the License, or (at your option) any later version.
   34.12 -
   34.13 -    This library is distributed in the hope that it will be useful,
   34.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   34.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   34.16 -    Lesser General Public License for more details.
   34.17 -
   34.18 -    You should have received a copy of the GNU Lesser General Public
   34.19 -    License along with this library; if not, write to the Free Software
   34.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   34.21 -
   34.22 -    Sam Lantinga
   34.23 -    slouken@libsdl.org
   34.24 -*/
   34.25 -#include "SDL_config.h"
   34.26 -
   34.27 -#ifndef _SDL_lowvideo_h
   34.28 -#define _SDL_lowvideo_h
   34.29 -
   34.30 -#if defined(__APPLE__) && defined(__MACH__)
   34.31 -#include <Carbon/Carbon.h>
   34.32 -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
   34.33 -#include <Carbon.h>
   34.34 -#else
   34.35 -#include <Quickdraw.h>
   34.36 -#include <Palettes.h>
   34.37 -#include <Menus.h>
   34.38 -#include <DrawSprocket.h>
   34.39 -#endif
   34.40 -
   34.41 -#if SDL_VIDEO_OPENGL
   34.42 -typedef struct __AGLContextRec *AGLContext;
   34.43 -#endif
   34.44 -
   34.45 -#include "SDL_video.h"
   34.46 -#include "../SDL_sysvideo.h"
   34.47 -
   34.48 -/* Hidden "this" pointer for the video functions */
   34.49 -#define _THIS	SDL_VideoDevice *this
   34.50 -
   34.51 -#if !TARGET_API_MAC_CARBON      /* not available in OS X (or more accurately, Carbon) */
   34.52 -/* Global QuickDraw data */
   34.53 -extern QDGlobals *theQD;
   34.54 -#endif
   34.55 -
   34.56 -/* Private display data */
   34.57 -struct SDL_PrivateVideoData
   34.58 -{
   34.59 -    GDevice **SDL_Display;
   34.60 -    WindowRef SDL_Window;
   34.61 -    SDL_Rect **SDL_modelist;
   34.62 -    CTabHandle SDL_CTab;
   34.63 -    PaletteHandle SDL_CPal;
   34.64 -
   34.65 -#if TARGET_API_MAC_CARBON
   34.66 -    /* For entering and leaving fullscreen mode */
   34.67 -    Ptr fullscreen_ctx;
   34.68 -#endif
   34.69 -
   34.70 -    /* The current window document style */
   34.71 -    int current_style;
   34.72 -
   34.73 -    /* Information about the last cursor position */
   34.74 -    Point last_where;
   34.75 -
   34.76 -    /* Information about the last keys down */
   34.77 -    EventModifiers last_mods;
   34.78 -    KeyMap last_keys;
   34.79 -
   34.80 -    /* A handle to the Apple Menu */
   34.81 -    MenuRef apple_menu;
   34.82 -
   34.83 -    /* Information used by DrawSprocket driver */
   34.84 -    struct DSpInfo *dspinfo;
   34.85 -
   34.86 -#if SDL_VIDEO_OPENGL
   34.87 -    AGLContext appleGLContext;
   34.88 -
   34.89 -    void *libraryHandle;
   34.90 -#endif
   34.91 -};
   34.92 -/* Old variable names */
   34.93 -#define SDL_Display		(this->hidden->SDL_Display)
   34.94 -#define SDL_Window		(this->hidden->SDL_Window)
   34.95 -#define SDL_modelist		(this->hidden->SDL_modelist)
   34.96 -#define SDL_CTab		(this->hidden->SDL_CTab)
   34.97 -#define SDL_CPal		(this->hidden->SDL_CPal)
   34.98 -#define fullscreen_ctx		(this->hidden->fullscreen_ctx)
   34.99 -#define current_style		(this->hidden->current_style)
  34.100 -#define last_where		(this->hidden->last_where)
  34.101 -#define last_mods		(this->hidden->last_mods)
  34.102 -#define last_keys		(this->hidden->last_keys)
  34.103 -#define apple_menu		(this->hidden->apple_menu)
  34.104 -#define glContext		(this->hidden->appleGLContext)
  34.105 -
  34.106 -#endif /* _SDL_lowvideo_h */
  34.107 -/* vi: set ts=4 sw=4 expandtab: */
    35.1 --- a/src/video/maccommon/SDL_macevents.c	Thu Aug 10 14:35:42 2006 +0000
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,778 +0,0 @@
    35.4 -/*
    35.5 -    SDL - Simple DirectMedia Layer
    35.6 -    Copyright (C) 1997-2006 Sam Lantinga
    35.7 -
    35.8 -    This library is free software; you can redistribute it and/or
    35.9 -    modify it under the terms of the GNU Lesser General Public
   35.10 -    License as published by the Free Software Foundation; either
   35.11 -    version 2.1 of the License, or (at your option) any later version.
   35.12 -
   35.13 -    This library is distributed in the hope that it will be useful,
   35.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   35.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   35.16 -    Lesser General Public License for more details.
   35.17 -
   35.18 -    You should have received a copy of the GNU Lesser General Public
   35.19 -    License along with this library; if not, write to the Free Software
   35.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   35.21 -
   35.22 -    Sam Lantinga
   35.23 -    slouken@libsdl.org
   35.24 -*/
   35.25 -#include "SDL_config.h"
   35.26 -
   35.27 -#include <stdio.h>
   35.28 -
   35.29 -#if defined(__APPLE__) && defined(__MACH__)
   35.30 -#include <Carbon/Carbon.h>
   35.31 -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
   35.32 -#include <Carbon.h>
   35.33 -#else
   35.34 -#include <Script.h>
   35.35 -#include <LowMem.h>
   35.36 -#include <Devices.h>
   35.37 -#include <DiskInit.h>
   35.38 -#include <ToolUtils.h>
   35.39 -#endif
   35.40 -
   35.41 -#include "SDL_events.h"
   35.42 -#include "SDL_video.h"
   35.43 -#include "SDL_syswm.h"
   35.44 -#include "../../events/SDL_events_c.h"
   35.45 -#include "../../events/SDL_sysevents.h"
   35.46 -#include "../SDL_cursor_c.h"
   35.47 -#include "SDL_macevents_c.h"
   35.48 -#include "SDL_mackeys.h"
   35.49 -#include "SDL_macmouse_c.h"
   35.50 -
   35.51 -/* Define this to be able to collapse SDL windows.
   35.52 -#define USE_APPEARANCE_MANAGER
   35.53 - */
   35.54 -
   35.55 -/* Macintosh resource constants */
   35.56 -#define mApple	128             /* Apple menu resource */
   35.57 -#define iAbout	1               /* About menu item */
   35.58 -
   35.59 -/* Functions to handle the About menu */
   35.60 -static void Mac_DoAppleMenu(_THIS, long item);
   35.61 -
   35.62 -/* The translation table from a macintosh key scancode to a SDL keysym */
   35.63 -static SDLKey MAC_keymap[256];
   35.64 -static SDL_keysym *TranslateKey(int scancode, int modifiers,
   35.65 -                                SDL_keysym * keysym, int pressed);
   35.66 -
   35.67 -/* Handle activation and deactivation  -- returns whether an event was posted */
   35.68 -static int
   35.69 -Mac_HandleActivate(int activate)
   35.70 -{
   35.71 -    if (activate) {
   35.72 -        /* Show the current SDL application cursor */
   35.73 -        SDL_SetCursor(NULL);
   35.74 -
   35.75 -        /* put our mask back case it changed during context switch */
   35.76 -        SetEventMask(everyEvent & ~autoKeyMask);
   35.77 -    } else {
   35.78 -#if TARGET_API_MAC_CARBON
   35.79 -        {
   35.80 -            Cursor cursor;
   35.81 -            SetCursor(GetQDGlobalsArrow(&cursor));
   35.82 -        }
   35.83 -#else
   35.84 -        SetCursor(&theQD->arrow);
   35.85 -#endif
   35.86 -        if (!Mac_cursor_showing) {
   35.87 -            ShowCursor();
   35.88 -            Mac_cursor_showing = 1;
   35.89 -        }
   35.90 -    }
   35.91 -    return (SDL_PrivateAppActive(activate, SDL_APPINPUTFOCUS));
   35.92 -}
   35.93 -
   35.94 -static void
   35.95 -myGlobalToLocal(_THIS, Point * pt)
   35.96 -{
   35.97 -    if (SDL_VideoSurface && !(SDL_VideoSurface->flags & SDL_FULLSCREEN)) {
   35.98 -        GrafPtr saveport;
   35.99 -        GetPort(&saveport);
  35.100 -#if TARGET_API_MAC_CARBON
  35.101 -        SetPort(GetWindowPort(SDL_Window));
  35.102 -#else
  35.103 -        SetPort(SDL_Window);
  35.104 -#endif
  35.105 -        GlobalToLocal(pt);
  35.106 -        SetPort(saveport);
  35.107 -    }
  35.108 -}
  35.109 -
  35.110 -/* The main MacOS event handler */
  35.111 -static int
  35.112 -Mac_HandleEvents(_THIS, int wait4it)
  35.113 -{
  35.114 -    static int mouse_button = 1;
  35.115 -    int i;
  35.116 -    EventRecord event;
  35.117 -
  35.118 -#if TARGET_API_MAC_CARBON
  35.119 -    /* There's no GetOSEvent() in the Carbon API. *sigh* */
  35.120 -#define cooperative_multitasking 1
  35.121 -#else
  35.122 -    int cooperative_multitasking;
  35.123 -    /* If we're running fullscreen, we can hog the MacOS events,
  35.124 -       otherwise we had better play nicely with the other apps.
  35.125 -     */
  35.126 -    if (this->screen && (this->screen->flags & SDL_FULLSCREEN)) {
  35.127 -        cooperative_multitasking = 0;
  35.128 -    } else {
  35.129 -        cooperative_multitasking = 1;
  35.130 -    }
  35.131 -#endif
  35.132 -
  35.133 -    /* If we call WaitNextEvent(), MacOS will check other processes
  35.134 -     * and allow them to run, and perform other high-level processing.
  35.135 -     */
  35.136 -    if (cooperative_multitasking || wait4it) {
  35.137 -        UInt32 wait_time;
  35.138 -
  35.139 -        /* Are we polling or not? */
  35.140 -        if (wait4it) {
  35.141 -            wait_time = 2147483647;
  35.142 -        } else {
  35.143 -            wait_time = 0;
  35.144 -        }
  35.145 -        WaitNextEvent(everyEvent, &event, wait_time, nil);
  35.146 -    } else {
  35.147 -#if ! TARGET_API_MAC_CARBON
  35.148 -        GetOSEvent(everyEvent, &event);
  35.149 -#endif
  35.150 -    }
  35.151 -
  35.152 -#if TARGET_API_MAC_CARBON
  35.153 -    /* for some reason, event.where isn't set ? */
  35.154 -    GetGlobalMouse(&event.where);
  35.155 -#endif
  35.156 -
  35.157 -    /* Check for mouse motion */
  35.158 -    if ((event.where.h != last_where.h) || (event.where.v != last_where.v)) {
  35.159 -        Point pt;
  35.160 -        pt = last_where = event.where;
  35.161 -        myGlobalToLocal(this, &pt);
  35.162 -        SDL_PrivateMouseMotion(0, 0, pt.h, pt.v);
  35.163 -    }
  35.164 -
  35.165 -    /* Check the current state of the keyboard */
  35.166 -    if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
  35.167 -        KeyMap keys;
  35.168 -
  35.169 -        /* Check for special non-event keys */
  35.170 -        if (event.modifiers != last_mods) {
  35.171 -            static struct
  35.172 -            {
  35.173 -                EventModifiers mask;
  35.174 -                SDLKey key;
  35.175 -            } mods[] = {
  35.176 -                {
  35.177 -                alphaLock, SDLK_CAPSLOCK},
  35.178 -#if 0                           /* These are handled below in the GetKeys() code */
  35.179 -                {
  35.180 -                cmdKey, SDLK_LMETA}, {
  35.181 -                shiftKey, SDLK_LSHIFT}, {
  35.182 -                rightShiftKey, SDLK_RSHIFT}, {
  35.183 -                optionKey, SDLK_LALT}, {
  35.184 -                rightOptionKey, SDLK_RALT}, {
  35.185 -                controlKey, SDLK_LCTRL}, {
  35.186 -                rightControlKey, SDLK_RCTRL},
  35.187 -#endif /* 0 */
  35.188 -                {
  35.189 -                0, 0}
  35.190 -            };
  35.191 -            SDL_keysym keysym;
  35.192 -            Uint8 mode;
  35.193 -            EventModifiers mod, mask;
  35.194 -
  35.195 -
  35.196 -            /* Set up the keyboard event */
  35.197 -            keysym.scancode = 0;
  35.198 -            keysym.sym = SDLK_UNKNOWN;
  35.199 -            keysym.mod = KMOD_NONE;
  35.200 -            keysym.unicode = 0;
  35.201 -
  35.202 -            /* See what has changed, and generate events */
  35.203 -            mod = event.modifiers;
  35.204 -            for (i = 0; mods[i].mask; ++i) {
  35.205 -                mask = mods[i].mask;
  35.206 -                if ((mod & mask) != (last_mods & mask)) {
  35.207 -                    keysym.sym = mods[i].key;
  35.208 -                    if ((mod & mask) || (mods[i].key == SDLK_CAPSLOCK)) {
  35.209 -                        mode = SDL_PRESSED;
  35.210 -                    } else {
  35.211 -                        mode = SDL_RELEASED;
  35.212 -                    }
  35.213 -                    SDL_PrivateKeyboard(mode, &keysym);
  35.214 -                }
  35.215 -            }
  35.216 -
  35.217 -            /* Save state for next time */
  35.218 -            last_mods = mod;
  35.219 -        }
  35.220 -
  35.221 -        /* Check for normal event keys, but we have to scan the
  35.222 -           actual keyboard state because on Mac OS X a keydown event
  35.223 -           is immediately followed by a keyup event.
  35.224 -         */
  35.225 -        GetKeys(keys);
  35.226 -        if ((keys[0] != last_keys[0]) || (keys[1] != last_keys[1]) ||
  35.227 -            (keys[2] != last_keys[2]) || (keys[3] != last_keys[3])) {
  35.228 -            SDL_keysym keysym;
  35.229 -            int old_bit, new_bit;
  35.230 -
  35.231 -#ifdef DEBUG_KEYBOARD
  35.232 -            fprintf(sterr, "New keys: 0x%x 0x%x 0x%x 0x%x\n",
  35.233 -                    new_keys[0], new_keys[1], new_keys[2], new_keys[3]);
  35.234 -#endif
  35.235 -            for (i = 0; i < 128; ++i) {
  35.236 -                old_bit = (((Uint8 *) last_keys)[i / 8] >> (i % 8)) & 0x01;
  35.237 -                new_bit = (((Uint8 *) keys)[i / 8] >> (i % 8)) & 0x01;
  35.238 -                if (old_bit != new_bit) {
  35.239 -                    /* Post the keyboard event */
  35.240 -#ifdef DEBUG_KEYBOARD
  35.241 -                    fprintf(stderr, "Scancode: 0x%2.2X\n", i);
  35.242 -#endif
  35.243 -                    SDL_PrivateKeyboard(new_bit,
  35.244 -                                        TranslateKey(i,
  35.245 -                                                     event.
  35.246 -                                                     modifiers,
  35.247 -                                                     &keysym, new_bit));
  35.248 -                }
  35.249 -            }
  35.250 -
  35.251 -            /* Save state for next time */
  35.252 -            last_keys[0] = keys[0];
  35.253 -            last_keys[1] = keys[1];
  35.254 -            last_keys[2] = keys[2];
  35.255 -            last_keys[3] = keys[3];
  35.256 -        }
  35.257 -    }
  35.258 -
  35.259 -    /* Handle normal events */
  35.260 -    switch (event.what) {
  35.261 -    case mouseDown:
  35.262 -        {
  35.263 -            WindowRef win;
  35.264 -            short area;
  35.265 -
  35.266 -            area = FindWindow(event.where, &win);
  35.267 -            /* Support switching between the SIOUX console
  35.268 -               and SDL_Window by clicking in the window.
  35.269 -             */
  35.270 -            if (win && (win != FrontWindow())) {
  35.271 -                SelectWindow(win);
  35.272 -            }
  35.273 -            switch (area) {
  35.274 -            case inMenuBar:    /* Only the apple menu exists */
  35.275 -                Mac_DoAppleMenu(this, MenuSelect(event.where));
  35.276 -                HiliteMenu(0);
  35.277 -                break;
  35.278 -            case inDrag:
  35.279 -#if TARGET_API_MAC_CARBON
  35.280 -                DragWindow(win, event.where, NULL);
  35.281 -#else
  35.282 -                DragWindow(win, event.where, &theQD->screenBits.bounds);
  35.283 -#endif
  35.284 -                break;
  35.285 -            case inGoAway:
  35.286 -                if (TrackGoAway(win, event.where)) {
  35.287 -                    SDL_PrivateQuit();
  35.288 -                }
  35.289 -                break;
  35.290 -            case inContent:
  35.291 -                myGlobalToLocal(this, &event.where);
  35.292 -                /* Treat command-click as right mouse button */
  35.293 -                if (event.modifiers & optionKey) {
  35.294 -                    mouse_button = 2;
  35.295 -                } else if (event.modifiers & cmdKey) {
  35.296 -                    mouse_button = 3;
  35.297 -                } else {
  35.298 -                    mouse_button = 1;
  35.299 -                }
  35.300 -                SDL_PrivateMouseButton(SDL_PRESSED,
  35.301 -                                       mouse_button, event.where.h,
  35.302 -                                       event.where.v);
  35.303 -                break;
  35.304 -            case inGrow:
  35.305 -                {
  35.306 -                    int newSize;
  35.307 -
  35.308 -                    /* Don't allow resize if video mode isn't resizable */
  35.309 -                    if (!SDL_PublicSurface ||
  35.310 -                        !(SDL_PublicSurface->flags & SDL_RESIZABLE)) {
  35.311 -                        break;
  35.312 -                    }
  35.313 -#if TARGET_API_MAC_CARBON
  35.314 -                    newSize = GrowWindow(win, event.where, NULL);
  35.315 -#else
  35.316 -                    newSize =
  35.317 -                        GrowWindow(win, event.where,
  35.318 -                                   &theQD->screenBits.bounds);
  35.319 -#endif
  35.320 -                    if (newSize) {
  35.321 -#if !TARGET_API_MAC_CARBON
  35.322 -                        EraseRect(&theQD->screenBits.bounds);
  35.323 -#endif
  35.324 -                        SizeWindow(win, LoWord(newSize), HiWord(newSize), 1);
  35.325 -                        SDL_PrivateResize(LoWord(newSize), HiWord(newSize));
  35.326 -                    }
  35.327 -                }
  35.328 -                break;
  35.329 -            case inZoomIn:
  35.330 -            case inZoomOut:
  35.331 -                if (TrackBox(win, event.where, area)) {
  35.332 -                    Rect rect;
  35.333 -#if !TARGET_API_MAC_CARBON
  35.334 -                    EraseRect(&theQD->screenBits.bounds);
  35.335 -#endif
  35.336 -                    ZoomWindow(win, area, 0);
  35.337 -                    if (area == inZoomIn) {
  35.338 -                        GetWindowUserState(SDL_Window, &rect);
  35.339 -                    } else {
  35.340 -                        GetWindowStandardState(SDL_Window, &rect);
  35.341 -                    }
  35.342 -                    SDL_PrivateResize(rect.right - rect.left,
  35.343 -                                      rect.bottom - rect.top);
  35.344 -                }
  35.345 -                break;
  35.346 -#if TARGET_API_MAC_CARBON
  35.347 -            case inCollapseBox:
  35.348 -                if (TrackBox(win, event.where, area)) {
  35.349 -                    if (IsWindowCollapsable(win)) {
  35.350 -                        CollapseWindow(win, !IsWindowCollapsed(win));
  35.351 -                        /* There should be something done like in inGrow case, but... */
  35.352 -                    }
  35.353 -                }
  35.354 -                break;
  35.355 -#endif /* TARGET_API_MAC_CARBON */
  35.356 -            case inSysWindow:
  35.357 -#if TARGET_API_MAC_CARBON
  35.358 -                /* Never happens in Carbon? */
  35.359 -#else
  35.360 -                SystemClick(&event, win);
  35.361 -#endif
  35.362 -                break;
  35.363 -            default:
  35.364 -                break;
  35.365 -            }
  35.366 -        }
  35.367 -        break;
  35.368 -    case mouseUp:
  35.369 -        {
  35.370 -            myGlobalToLocal(this, &event.where);
  35.371 -            /* Release the mouse button we simulated in the last press.
  35.372 -               The drawback of this methos is we cannot press more than
  35.373 -               one button. However, this doesn't matter, since there is
  35.374 -               only a single logical mouse button, even if you have a
  35.375 -               multi-button mouse, this doesn't matter at all.
  35.376 -             */
  35.377 -            SDL_PrivateMouseButton(SDL_RELEASED,
  35.378 -                                   mouse_button, event.where.h,
  35.379 -                                   event.where.v);
  35.380 -        }
  35.381 -        break;
  35.382 -#if 0                           /* Handled above the switch statement */
  35.383 -    case keyDown:
  35.384 -        {
  35.385 -            SDL_keysym keysym;
  35.386 -
  35.387 -            SDL_PrivateKeyboard(SDL_PRESSED,
  35.388 -                                TranslateKey((event.
  35.389 -                                              message & keyCodeMask) >> 8
  35.390 -                                             event.modifiers, &keysym, 1));
  35.391 -        }
  35.392 -        break;
  35.393 -    case keyUp:
  35.394 -        {
  35.395 -            SDL_keysym keysym;
  35.396 -
  35.397 -            SDL_PrivateKeyboard(SDL_RELEASED,
  35.398 -                                TranslateKey((event.
  35.399 -                                              message & keyCodeMask) >> 8
  35.400 -                                             event.modifiers, &keysym, 0));
  35.401 -        }
  35.402 -        break;
  35.403 -#endif
  35.404 -    case updateEvt:
  35.405 -        {
  35.406 -            BeginUpdate(SDL_Window);
  35.407 -#if SDL_VIDEO_OPENGL
  35.408 -            if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL)
  35.409 -                SDL_GL_SwapBuffers();
  35.410 -            else
  35.411 -#endif
  35.412 -            if ((SDL_VideoSurface->flags & SDL_HWSURFACE) == SDL_SWSURFACE) {
  35.413 -                SDL_UpdateRect(SDL_VideoSurface, 0, 0, 0, 0);
  35.414 -            }
  35.415 -            EndUpdate(SDL_Window);
  35.416 -        }
  35.417 -        /* If this was an update event for the SIOUX console, we return 0
  35.418 -           in order to stop an endless series of updates being triggered.
  35.419 -         */
  35.420 -        if ((WindowRef) event.message != SDL_Window) {
  35.421 -            return 0;
  35.422 -        }
  35.423 -        break;
  35.424 -    case activateEvt:
  35.425 -        {
  35.426 -            Mac_HandleActivate(!!(event.modifiers & activeFlag));
  35.427 -        }
  35.428 -        break;
  35.429 -    case diskEvt:
  35.430 -        {
  35.431 -#if TARGET_API_MAC_CARBON
  35.432 -            /* What are we supposed to do? */ ;
  35.433 -#else
  35.434 -            if (((event.message >> 16) & 0xFFFF) != noErr) {
  35.435 -                Point spot;
  35.436 -                SetPt(&spot, 0x0070, 0x0050);
  35.437 -                DIBadMount(spot, event.message);
  35.438 -            }
  35.439 -#endif
  35.440 -        }
  35.441 -        break;
  35.442 -    case osEvt:
  35.443 -        {
  35.444 -            switch ((event.message >> 24) & 0xFF) {
  35.445 -#if 0                           /* Handled above the switch statement */
  35.446 -            case mouseMovedMessage:
  35.447 -                {
  35.448 -                    myGlobalToLocal(this, &event.where);
  35.449 -                    SDL_PrivateMouseMotion(0, 0,
  35.450 -                                           event.where.h, event.where.v);
  35.451 -                }
  35.452 -                break;
  35.453 -#endif /* 0 */
  35.454 -            case suspendResumeMessage:
  35.455 -                {
  35.456 -                    Mac_HandleActivate(!!(event.message & resumeFlag));
  35.457 -                }
  35.458 -                break;
  35.459 -            }
  35.460 -        }
  35.461 -        break;
  35.462 -    default:
  35.463 -        {
  35.464 -            ;
  35.465 -        }
  35.466 -        break;
  35.467 -    }
  35.468 -    return (event.what != nullEvent);
  35.469 -}
  35.470 -
  35.471 -
  35.472 -void
  35.473 -Mac_PumpEvents(_THIS)
  35.474 -{
  35.475 -    /* Process pending MacOS events */
  35.476 -    while (Mac_HandleEvents(this, 0)) {
  35.477 -        /* Loop and check again */ ;
  35.478 -    }
  35.479 -}
  35.480 -
  35.481 -void
  35.482 -Mac_InitOSKeymap(_THIS)
  35.483 -{
  35.484 -    const void *KCHRPtr;
  35.485 -    UInt32 state;
  35.486 -    UInt32 value;
  35.487 -    int i;
  35.488 -    int world = SDLK_WORLD_0;
  35.489 -
  35.490 -    /* Map the MAC keysyms */
  35.491 -    for (i = 0; i < SDL_arraysize(MAC_keymap); ++i)
  35.492 -        MAC_keymap[i] = SDLK_UNKNOWN;
  35.493 -
  35.494 -    /* Defined MAC_* constants */
  35.495 -    MAC_keymap[MK_ESCAPE] = SDLK_ESCAPE;
  35.496 -    MAC_keymap[MK_F1] = SDLK_F1;
  35.497 -    MAC_keymap[MK_F2] = SDLK_F2;
  35.498 -    MAC_keymap[MK_F3] = SDLK_F3;
  35.499 -    MAC_keymap[MK_F4] = SDLK_F4;
  35.500 -    MAC_keymap[MK_F5] = SDLK_F5;
  35.501 -    MAC_keymap[MK_F6] = SDLK_F6;
  35.502 -    MAC_keymap[MK_F7] = SDLK_F7;
  35.503 -    MAC_keymap[MK_F8] = SDLK_F8;
  35.504 -    MAC_keymap[MK_F9] = SDLK_F9;
  35.505 -    MAC_keymap[MK_F10] = SDLK_F10;
  35.506 -    MAC_keymap[MK_F11] = SDLK_F11;
  35.507 -    MAC_keymap[MK_F12] = SDLK_F12;
  35.508 -    MAC_keymap[MK_PRINT] = SDLK_PRINT;
  35.509 -    MAC_keymap[MK_SCROLLOCK] = SDLK_SCROLLOCK;
  35.510 -    MAC_keymap[MK_PAUSE] = SDLK_PAUSE;
  35.511 -    MAC_keymap[MK_POWER] = SDLK_POWER;
  35.512 -    MAC_keymap[MK_BACKQUOTE] = SDLK_BACKQUOTE;
  35.513 -    MAC_keymap[MK_1] = SDLK_1;
  35.514 -    MAC_keymap[MK_2] = SDLK_2;
  35.515 -    MAC_keymap[MK_3] = SDLK_3;
  35.516 -    MAC_keymap[MK_4] = SDLK_4;
  35.517 -    MAC_keymap[MK_5] = SDLK_5;
  35.518 -    MAC_keymap[MK_6] = SDLK_6;
  35.519 -    MAC_keymap[MK_7] = SDLK_7;
  35.520 -    MAC_keymap[MK_8] = SDLK_8;
  35.521 -    MAC_keymap[MK_9] = SDLK_9;
  35.522 -    MAC_keymap[MK_0] = SDLK_0;
  35.523 -    MAC_keymap[MK_MINUS] = SDLK_MINUS;
  35.524 -    MAC_keymap[MK_EQUALS] = SDLK_EQUALS;
  35.525 -    MAC_keymap[MK_BACKSPACE] = SDLK_BACKSPACE;
  35.526 -    MAC_keymap[MK_INSERT] = SDLK_INSERT;
  35.527 -    MAC_keymap[MK_HOME] = SDLK_HOME;
  35.528 -    MAC_keymap[MK_PAGEUP] = SDLK_PAGEUP;
  35.529 -    MAC_keymap[MK_NUMLOCK] = SDLK_NUMLOCK;
  35.530 -    MAC_keymap[MK_KP_EQUALS] = SDLK_KP_EQUALS;
  35.531 -    MAC_keymap[MK_KP_DIVIDE] = SDLK_KP_DIVIDE;
  35.532 -    MAC_keymap[MK_KP_MULTIPLY] = SDLK_KP_MULTIPLY;
  35.533 -    MAC_keymap[MK_TAB] = SDLK_TAB;
  35.534 -    MAC_keymap[MK_q] = SDLK_q;
  35.535 -    MAC_keymap[MK_w] = SDLK_w;
  35.536 -    MAC_keymap[MK_e] = SDLK_e;
  35.537 -    MAC_keymap[MK_r] = SDLK_r;
  35.538 -    MAC_keymap[MK_t] = SDLK_t;
  35.539 -    MAC_keymap[MK_y] = SDLK_y;
  35.540 -    MAC_keymap[MK_u] = SDLK_u;
  35.541 -    MAC_keymap[MK_i] = SDLK_i;
  35.542 -    MAC_keymap[MK_o] = SDLK_o;
  35.543 -    MAC_keymap[MK_p] = SDLK_p;
  35.544 -    MAC_keymap[MK_LEFTBRACKET] = SDLK_LEFTBRACKET;
  35.545 -    MAC_keymap[MK_RIGHTBRACKET] = SDLK_RIGHTBRACKET;
  35.546 -    MAC_keymap[MK_BACKSLASH] = SDLK_BACKSLASH;
  35.547 -    MAC_keymap[MK_DELETE] = SDLK_DELETE;
  35.548 -    MAC_keymap[MK_END] = SDLK_END;
  35.549 -    MAC_keymap[MK_PAGEDOWN] = SDLK_PAGEDOWN;
  35.550 -    MAC_keymap[MK_KP7] = SDLK_KP7;
  35.551 -    MAC_keymap[MK_KP8] = SDLK_KP8;
  35.552 -    MAC_keymap[MK_KP9] = SDLK_KP9;
  35.553 -    MAC_keymap[MK_KP_MINUS] = SDLK_KP_MINUS;
  35.554 -    MAC_keymap[MK_CAPSLOCK] = SDLK_CAPSLOCK;
  35.555 -    MAC_keymap[MK_a] = SDLK_a;
  35.556 -    MAC_keymap[MK_s] = SDLK_s;
  35.557 -    MAC_keymap[MK_d] = SDLK_d;
  35.558 -    MAC_keymap[MK_f] = SDLK_f;
  35.559 -    MAC_keymap[MK_g] = SDLK_g;
  35.560 -    MAC_keymap[MK_h] = SDLK_h;
  35.561 -    MAC_keymap[MK_j] = SDLK_j;
  35.562 -    MAC_keymap[MK_k] = SDLK_k;
  35.563 -    MAC_keymap[MK_l] = SDLK_l;
  35.564 -    MAC_keymap[MK_SEMICOLON] = SDLK_SEMICOLON;
  35.565 -    MAC_keymap[MK_QUOTE] = SDLK_QUOTE;
  35.566 -    MAC_keymap[MK_RETURN] = SDLK_RETURN;
  35.567 -    MAC_keymap[MK_KP4] = SDLK_KP4;
  35.568 -    MAC_keymap[MK_KP5] = SDLK_KP5;
  35.569 -    MAC_keymap[MK_KP6] = SDLK_KP6;
  35.570 -    MAC_keymap[MK_KP_PLUS] = SDLK_KP_PLUS;
  35.571 -    MAC_keymap[MK_LSHIFT] = SDLK_LSHIFT;
  35.572 -    MAC_keymap[MK_z] = SDLK_z;
  35.573 -    MAC_keymap[MK_x] = SDLK_x;
  35.574 -    MAC_keymap[MK_c] = SDLK_c;
  35.575 -    MAC_keymap[MK_v] = SDLK_v;
  35.576 -    MAC_keymap[MK_b] = SDLK_b;
  35.577 -    MAC_keymap[MK_n] = SDLK_n;
  35.578 -    MAC_keymap[MK_m] = SDLK_m;
  35.579 -    MAC_keymap[MK_COMMA] = SDLK_COMMA;
  35.580 -    MAC_keymap[MK_PERIOD] = SDLK_PERIOD;
  35.581 -    MAC_keymap[MK_SLASH] = SDLK_SLASH;
  35.582 -#if 0                           /* These are the same as the left versions - use left by default */
  35.583 -    MAC_keymap[MK_RSHIFT] = SDLK_RSHIFT;
  35.584 -#endif
  35.585 -    MAC_keymap[MK_UP] = SDLK_UP;
  35.586 -    MAC_keymap[MK_KP1] = SDLK_KP1;
  35.587 -    MAC_keymap[MK_KP2] = SDLK_KP2;
  35.588 -    MAC_keymap[MK_KP3] = SDLK_KP3;
  35.589 -    MAC_keymap[MK_KP_ENTER] = SDLK_KP_ENTER;
  35.590 -    MAC_keymap[MK_LCTRL] = SDLK_LCTRL;
  35.591 -    MAC_keymap[MK_LALT] = SDLK_LALT;
  35.592 -    MAC_keymap[MK_LMETA] = SDLK_LMETA;
  35.593 -    MAC_keymap[MK_SPACE] = SDLK_SPACE;
  35.594 -#if 0                           /* These are the same as the left versions - use left by default */
  35.595 -    MAC_keymap[MK_RMETA] = SDLK_RMETA;
  35.596 -    MAC_keymap[MK_RALT] = SDLK_RALT;
  35.597 -    MAC_keymap[MK_RCTRL] = SDLK_RCTRL;
  35.598 -#endif
  35.599 -    MAC_keymap[MK_LEFT] = SDLK_LEFT;
  35.600 -    MAC_keymap[MK_DOWN] = SDLK_DOWN;
  35.601 -    MAC_keymap[MK_RIGHT] = SDLK_RIGHT;
  35.602 -    MAC_keymap[MK_KP0] = SDLK_KP0;
  35.603 -    MAC_keymap[MK_KP_PERIOD] = SDLK_KP_PERIOD;
  35.604 -
  35.605 -#if defined(__APPLE__) && defined(__MACH__)
  35.606 -    /* Wierd, these keys are on my iBook under Mac OS X
  35.607 -       Note that the left arrow keysym is the same as left ctrl!?
  35.608 -     */
  35.609 -    MAC_keymap[MK_IBOOK_ENTER] = SDLK_KP_ENTER;
  35.610 -    MAC_keymap[MK_IBOOK_RIGHT] = SDLK_RIGHT;
  35.611 -    MAC_keymap[MK_IBOOK_DOWN] = SDLK_DOWN;
  35.612 -    MAC_keymap[MK_IBOOK_UP] = SDLK_UP;
  35.613 -    MAC_keymap[MK_IBOOK_LEFT] = SDLK_LEFT;
  35.614 -#endif /* Mac OS X */
  35.615 -
  35.616 -    /* Up there we setup a static scancode->keysym map. However, it will not
  35.617 -     * work very well on international keyboard. Hence we now query MacOS
  35.618 -     * for its own keymap to adjust our own mapping table. However, this is
  35.619 -     * bascially only useful for ascii char keys. This is also the reason
  35.620 -     * why we keep the static table, too.
  35.621 -     */
  35.622 -
  35.623 -    /* Get a pointer to the systems cached KCHR */
  35.624 -    KCHRPtr = (void *) GetScriptManagerVariable(smKCHRCache);
  35.625 -    if (KCHRPtr) {
  35.626 -        /* Loop over all 127 possible scan codes */
  35.627 -        for (i = 0; i < 0x7F; i++) {
  35.628 -            /* We pretend a clean start to begin with (i.e. no dead keys active */
  35.629 -            state = 0;
  35.630 -
  35.631 -            /* Now translate the key code to a key value */
  35.632 -            value = KeyTranslate(KCHRPtr, i, &state) & 0xff;
  35.633 -
  35.634 -            /* If the state become 0, it was a dead key. We need to translate again,
  35.635 -               passing in the new state, to get the actual key value */
  35.636 -            if (state != 0)
  35.637 -                value = KeyTranslate(KCHRPtr, i, &state) & 0xff;
  35.638 -
  35.639 -            /* Now we should have an ascii value, or 0. Try to figure out to which SDL symbol it maps */
  35.640 -            if (value >= 128)   /* Some non-ASCII char, map it to SDLK_WORLD_* */
  35.641 -                MAC_keymap[i] = world++;
  35.642 -            else if (value >= 32)       /* non-control ASCII char */
  35.643 -                MAC_keymap[i] = value;
  35.644 -        }
  35.645 -    }
  35.646 -
  35.647 -    /* The keypad codes are re-setup here, because the loop above cannot
  35.648 -     * distinguish between a key on the keypad and a regular key. We maybe
  35.649 -     * could get around this problem in another fashion: NSEvent's flags
  35.650 -     * include a "NSNumericPadKeyMask" bit; we could check that and modify
  35.651 -     * the symbol we return on the fly. However, this flag seems to exhibit
  35.652 -     * some weird behaviour related to the num lock key
  35.653 -     */
  35.654 -    MAC_keymap[MK_KP0] = SDLK_KP0;
  35.655 -    MAC_keymap[MK_KP1] = SDLK_KP1;
  35.656 -    MAC_keymap[MK_KP2] = SDLK_KP2;
  35.657 -    MAC_keymap[MK_KP3] = SDLK_KP3;
  35.658 -    MAC_keymap[MK_KP4] = SDLK_KP4;
  35.659 -    MAC_keymap[MK_KP5] = SDLK_KP5;
  35.660 -    MAC_keymap[MK_KP6] = SDLK_KP6;
  35.661 -    MAC_keymap[MK_KP7] = SDLK_KP7;
  35.662 -    MAC_keymap[MK_KP8] = SDLK_KP8;
  35.663 -    MAC_keymap[MK_KP9] = SDLK_KP9;
  35.664 -    MAC_keymap[MK_KP_MINUS] = SDLK_KP_MINUS;
  35.665 -    MAC_keymap[MK_KP_PLUS] = SDLK_KP_PLUS;
  35.666 -    MAC_keymap[MK_KP_PERIOD] = SDLK_KP_PERIOD;
  35.667 -    MAC_keymap[MK_KP_EQUALS] = SDLK_KP_EQUALS;
  35.668 -    MAC_keymap[MK_KP_DIVIDE] = SDLK_KP_DIVIDE;
  35.669 -    MAC_keymap[MK_KP_MULTIPLY] = SDLK_KP_MULTIPLY;
  35.670 -    MAC_keymap[MK_KP_ENTER] = SDLK_KP_ENTER;
  35.671 -}
  35.672 -
  35.673 -static SDL_keysym *
  35.674 -TranslateKey(int scancode, int modifiers, SDL_keysym * keysym, int pressed)
  35.675 -{
  35.676 -    /* Set the keysym information */
  35.677 -    keysym->scancode = scancode;
  35.678 -    keysym->sym = MAC_keymap[keysym->scancode];
  35.679 -    keysym->mod = KMOD_NONE;
  35.680 -    keysym->unicode = 0;
  35.681 -    if (pressed && SDL_TranslateUNICODE) {
  35.682 -        static unsigned long state = 0;
  35.683 -        static Ptr keymap = nil;
  35.684 -        Ptr new_keymap;
  35.685 -
  35.686 -        /* Get the current keyboard map resource */
  35.687 -        new_keymap = (Ptr) GetScriptManagerVariable(smKCHRCache);
  35.688 -        if (new_keymap != keymap) {
  35.689 -            keymap = new_keymap;
  35.690 -            state = 0;
  35.691 -        }
  35.692 -        keysym->unicode = KeyTranslate(keymap,
  35.693 -                                       keysym->scancode | modifiers,
  35.694 -                                       &state) & 0xFFFF;
  35.695 -    }
  35.696 -    return (keysym);
  35.697 -}
  35.698 -
  35.699 -void
  35.700 -Mac_InitEvents(_THIS)
  35.701 -{
  35.702 -    /* Create apple menu bar */
  35.703 -    apple_menu = GetMenu(mApple);
  35.704 -    if (apple_menu != nil) {
  35.705 -        AppendResMenu(apple_menu, 'DRVR');
  35.706 -        InsertMenu(apple_menu, 0);
  35.707 -    }
  35.708 -    DrawMenuBar();
  35.709 -
  35.710 -    /* Get rid of spurious events at startup */
  35.711 -    FlushEvents(everyEvent, 0);
  35.712 -
  35.713 -    /* Allow every event but keyrepeat */
  35.714 -    SetEventMask(everyEvent & ~autoKeyMask);
  35.715 -}
  35.716 -
  35.717 -void
  35.718 -Mac_QuitEvents(_THIS)
  35.719 -{
  35.720 -    ClearMenuBar();
  35.721 -    if (apple_menu != nil) {
  35.722 -        ReleaseResource((char **) apple_menu);
  35.723 -    }
  35.724 -
  35.725 -    /* Clean up pending events */
  35.726 -    FlushEvents(everyEvent, 0);
  35.727 -}
  35.728 -
  35.729 -static void
  35.730 -Mac_DoAppleMenu(_THIS, long choice)
  35.731 -{
  35.732 -#if !TARGET_API_MAC_CARBON      /* No Apple menu in OS X */
  35.733 -    short menu, item;
  35.734 -
  35.735 -    item = (choice & 0xFFFF);
  35.736 -    choice >>= 16;
  35.737 -    menu = (choice & 0xFFFF);
  35.738 -
  35.739 -    switch (menu) {
  35.740 -    case mApple:
  35.741 -        {
  35.742 -            switch (item) {
  35.743 -            case iAbout:
  35.744 -                {
  35.745 -                    /* Run the about box */ ;
  35.746 -                }
  35.747 -                break;
  35.748 -            default:
  35.749 -                {
  35.750 -                    Str255 name;
  35.751 -
  35.752 -                    GetMenuItemText(apple_menu, item, name);
  35.753 -                    OpenDeskAcc(name);
  35.754 -                }
  35.755 -                break;
  35.756 -            }
  35.757 -        }
  35.758 -        break;
  35.759 -    default:
  35.760 -        {
  35.761 -            /* Ignore other menus */ ;
  35.762 -        }
  35.763 -    }
  35.764 -#endif /* !TARGET_API_MAC_CARBON */
  35.765 -}
  35.766 -
  35.767 -#if !TARGET_API_MAC_CARBON
  35.768 -/* Since we don't initialize QuickDraw, we need to get a pointer to qd */
  35.769 -QDGlobals *theQD = NULL;
  35.770 -#endif
  35.771 -
  35.772 -/* Exported to the macmain code */
  35.773 -void
  35.774 -SDL_InitQuickDraw(struct QDGlobals *the_qd)
  35.775 -{
  35.776 -#if !TARGET_API_MAC_CARBON
  35.777 -    theQD = the_qd;
  35.778 -#endif
  35.779 -}
  35.780 -
  35.781 -/* vi: set ts=4 sw=4 expandtab: */
    36.1 --- a/src/video/maccommon/SDL_macevents_c.h	Thu Aug 10 14:35:42 2006 +0000
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,33 +0,0 @@
    36.4 -/*
    36.5 -    SDL - Simple DirectMedia Layer
    36.6 -    Copyright (C) 1997-2006 Sam Lantinga
    36.7 -
    36.8 -    This library is free software; you can redistribute it and/or
    36.9 -    modify it under the terms of the GNU Lesser General Public
   36.10 -    License as published by the Free Software Foundation; either
   36.11 -    version 2.1 of the License, or (at your option) any later version.
   36.12 -
   36.13 -    This library is distributed in the hope that it will be useful,
   36.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   36.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   36.16 -    Lesser General Public License for more details.
   36.17 -
   36.18 -    You should have received a copy of the GNU Lesser General Public
   36.19 -    License along with this library; if not, write to the Free Software
   36.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   36.21 -
   36.22 -    Sam Lantinga
   36.23 -    slouken@libsdl.org
   36.24 -*/
   36.25 -#include "SDL_config.h"
   36.26 -
   36.27 -#include "../macrom/SDL_romvideo.h"
   36.28 -
   36.29 -/* Functions exported by SDL_macevents.c for the video subsystem
   36.30 -*/
   36.31 -extern void Mac_InitEvents(_THIS);
   36.32 -extern void Mac_QuitEvents(_THIS);
   36.33 -
   36.34 -extern void Mac_InitOSKeymap(_THIS);
   36.35 -extern void Mac_PumpEvents(_THIS);
   36.36 -/* vi: set ts=4 sw=4 expandtab: */
    37.1 --- a/src/video/maccommon/SDL_macgl.c	Thu Aug 10 14:35:42 2006 +0000
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,203 +0,0 @@
    37.4 -/*
    37.5 -    SDL - Simple DirectMedia Layer
    37.6 -    Copyright (C) 1997-2006 Sam Lantinga
    37.7 -
    37.8 -    This library is free software; you can redistribute it and/or
    37.9 -    modify it under the terms of the GNU Lesser General Public
   37.10 -    License as published by the Free Software Foundation; either
   37.11 -    version 2.1 of the License, or (at your option) any later version.
   37.12 -
   37.13 -    This library is distributed in the hope that it will be useful,
   37.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   37.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   37.16 -    Lesser General Public License for more details.
   37.17 -
   37.18 -    You should have received a copy of the GNU Lesser General Public
   37.19 -    License along with this library; if not, write to the Free Software
   37.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   37.21 -
   37.22 -    Sam Lantinga
   37.23 -    slouken@libsdl.org
   37.24 -*/
   37.25 -#include "SDL_config.h"
   37.26 -
   37.27 -/* AGL implementation of SDL OpenGL support */
   37.28 -
   37.29 -#include "SDL_lowvideo.h"
   37.30 -#include "SDL_macgl_c.h"
   37.31 -#include "SDL_loadso.h"
   37.32 -
   37.33 -
   37.34 -/* krat: adding OpenGL support */
   37.35 -int
   37.36 -Mac_GL_Init(_THIS)
   37.37 -{
   37.38 -#if SDL_VIDEO_OPENGL
   37.39 -    AGLPixelFormat format;
   37.40 -    int i = 0;
   37.41 -    GLint attributes[26];       /* 26 is max possible in this setup */
   37.42 -    GLboolean noerr;
   37.43 -
   37.44 -    /* load the gl driver from a default path */
   37.45 -    if (!this->gl_config.driver_loaded) {
   37.46 -        /* no driver has been loaded, use default (ourselves) */
   37.47 -        if (Mac_GL_LoadLibrary(this, NULL) < 0) {
   37.48 -            return (-1);
   37.49 -        }
   37.50 -    }
   37.51 -
   37.52 -    attributes[i++] = AGL_RGBA;
   37.53 -    if (this->gl_config.red_size != 0 &&
   37.54 -        this->gl_config.blue_size != 0 && this->gl_config.green_size != 0) {
   37.55 -        attributes[i++] = AGL_RED_SIZE;
   37.56 -        attributes[i++] = this->gl_config.red_size;
   37.57 -        attributes[i++] = AGL_GREEN_SIZE;
   37.58 -        attributes[i++] = this->gl_config.green_size;
   37.59 -        attributes[i++] = AGL_BLUE_SIZE;
   37.60 -        attributes[i++] = this->gl_config.blue_size;
   37.61 -        attributes[i++] = AGL_ALPHA_SIZE;
   37.62 -        attributes[i++] = this->gl_config.alpha_size;
   37.63 -    }
   37.64 -    if (this->gl_config.double_buffer) {
   37.65 -        attributes[i++] = AGL_DOUBLEBUFFER;
   37.66 -    }
   37.67 -    if (this->gl_config.depth_size != 0) {
   37.68 -        attributes[i++] = AGL_DEPTH_SIZE;
   37.69 -        attributes[i++] = this->gl_config.depth_size;
   37.70 -    }
   37.71 -    if (this->gl_config.stencil_size != 0) {
   37.72 -        attributes[i++] = AGL_STENCIL_SIZE;
   37.73 -        attributes[i++] = this->gl_config.stencil_size;
   37.74 -    }
   37.75 -    if (this->gl_config.accum_red_size != 0 &&
   37.76 -        this->gl_config.accum_blue_size != 0 &&
   37.77 -        this->gl_config.accum_green_size != 0) {
   37.78 -
   37.79 -        attributes[i++] = AGL_ACCUM_RED_SIZE;
   37.80 -        attributes[i++] = this->gl_config.accum_red_size;
   37.81 -        attributes[i++] = AGL_ACCUM_GREEN_SIZE;
   37.82 -        attributes[i++] = this->gl_config.accum_green_size;
   37.83 -        attributes[i++] = AGL_ACCUM_BLUE_SIZE;
   37.84 -        attributes[i++] = this->gl_config.accum_blue_size;
   37.85 -        attributes[i++] = AGL_ACCUM_ALPHA_SIZE;
   37.86 -        attributes[i++] = this->gl_config.accum_alpha_size;
   37.87 -    }
   37.88 -    if (this->gl_config.stereo) {
   37.89 -        attributes[i++] = AGL_STEREO;
   37.90 -    }
   37.91 -#if defined(AGL_SAMPLE_BUFFERS_ARB) && defined(AGL_SAMPLES_ARB)
   37.92 -    if (this->gl_config.multisamplebuffers != 0) {
   37.93 -        attributes[i++] = AGL_SAMPLE_BUFFERS_ARB;
   37.94 -        attributes[i++] = this->gl_config.multisamplebuffers;
   37.95 -    }
   37.96 -    if (this->gl_config.multisamplesamples != 0) {
   37.97 -        attributes[i++] = AGL_SAMPLES_ARB;
   37.98 -        attributes[i++] = this->gl_config.multisamplesamples;
   37.99 -    }
  37.100 -#endif
  37.101 -    if (this->gl_config.accelerated > 0) {
  37.102 -        attributes[i++] = AGL_ACCELERATED;
  37.103 -        attributes[i++] = AGL_NO_RECOVERY;
  37.104 -    }
  37.105 -
  37.106 -    attributes[i++] = AGL_ALL_RENDERERS;
  37.107 -    attributes[i] = AGL_NONE;
  37.108 -
  37.109 -    format = aglChoosePixelFormat(NULL, 0, attributes);
  37.110 -    if (format == NULL) {
  37.111 -        SDL_SetError("Couldn't match OpenGL desired format");
  37.112 -        return (-1);
  37.113 -    }
  37.114 -
  37.115 -    glContext = aglCreateContext(format, NULL);
  37.116 -    if (glContext == NULL) {
  37.117 -        SDL_SetError("Couldn't create OpenGL context");
  37.118 -        return (-1);
  37.119 -    }
  37.120 -    aglDestroyPixelFormat(format);
  37.121 -
  37.122 -#if  TARGET_API_MAC_CARBON
  37.123 -    noerr = aglSetDrawable(glContext, GetWindowPort(SDL_Window));
  37.124 -#else
  37.125 -    noerr = aglSetDrawable(glContext, (AGLDrawable) SDL_Window);
  37.126 -#endif
  37.127 -
  37.128 -    if (!noerr) {
  37.129 -        SDL_SetError("Unable to bind GL context to window");
  37.130 -        return (-1);
  37.131 -    }
  37.132 -    return (0);
  37.133 -#else
  37.134 -    SDL_SetError("OpenGL support not configured");
  37.135 -    return (-1);
  37.136 -#endif
  37.137 -}
  37.138 -
  37.139 -void
  37.140 -Mac_GL_Quit(_THIS)
  37.141 -{
  37.142 -#if SDL_VIDEO_OPENGL
  37.143 -    if (glContext != NULL) {
  37.144 -        aglSetCurrentContext(NULL);
  37.145 -        aglSetDrawable(glContext, NULL);
  37.146 -        aglDestroyContext(glContext);
  37.147 -        glContext = NULL;
  37.148 -    }
  37.149 -#endif
  37.150 -}
  37.151 -
  37.152 -#if SDL_VIDEO_OPENGL
  37.153 -
  37.154 -/* Make the current context active */
  37.155 -int
  37.156 -Mac_GL_MakeCurrent(_THIS)
  37.157 -{
  37.158 -    int retval;
  37.159 -
  37.160 -    retval = 0;
  37.161 -    if (!aglSetCurrentContext(glContext)) {
  37.162 -        SDL_SetError("Unable to make GL context current");
  37.163 -        retval = -1;
  37.164 -    }
  37.165 -    return (retval);
  37.166 -}
  37.167 -
  37.168 -void
  37.169 -Mac_GL_SwapBuffers(_THIS)
  37.170 -{
  37.171 -    aglSwapBuffers(glContext);
  37.172 -}
  37.173 -
  37.174 -int
  37.175 -Mac_GL_LoadLibrary(_THIS, const char *location)
  37.176 -{
  37.177 -    if (location == NULL)
  37.178 -#if __MACH__
  37.179 -        location = "/System/Library/Frameworks/OpenGL.framework/OpenGL";
  37.180 -#else
  37.181 -        location = "OpenGLLibrary";
  37.182 -#endif
  37.183 -
  37.184 -    this->hidden->libraryHandle = SDL_LoadObject(location);
  37.185 -
  37.186 -    this->gl_config.driver_loaded = 1;
  37.187 -    return (this->hidden->libraryHandle != NULL) ? 0 : -1;
  37.188 -}
  37.189 -
  37.190 -void
  37.191 -Mac_GL_UnloadLibrary(_THIS)
  37.192 -{
  37.193 -    SDL_UnloadObject(this->hidden->libraryHandle);
  37.194 -
  37.195 -    this->hidden->libraryHandle = NULL;
  37.196 -    this->gl_config.driver_loaded = 0;
  37.197 -}
  37.198 -
  37.199 -void *
  37.200 -Mac_GL_GetProcAddress(_THIS, const char *proc)
  37.201 -{
  37.202 -    return SDL_LoadFunction(this->hidden->libraryHandle, proc);
  37.203 -}
  37.204 -
  37.205 -#endif /* SDL_VIDEO_OPENGL */
  37.206 -/* vi: set ts=4 sw=4 expandtab: */
    38.1 --- a/src/video/maccommon/SDL_macgl_c.h	Thu Aug 10 14:35:42 2006 +0000
    38.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.3 @@ -1,47 +0,0 @@
    38.4 -/*
    38.5 -    SDL - Simple DirectMedia Layer
    38.6 -    Copyright (C) 1997-2006 Sam Lantinga
    38.7 -
    38.8 -    This library is free software; you can redistribute it and/or
    38.9 -    modify it under the terms of the GNU Lesser General Public
   38.10 -    License as published by the Free Software Foundation; either
   38.11 -    version 2.1 of the License, or (at your option) any later version.
   38.12 -
   38.13 -    This library is distributed in the hope that it will be useful,
   38.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   38.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   38.16 -    Lesser General Public License for more details.
   38.17 -
   38.18 -    You should have received a copy of the GNU Lesser General Public
   38.19 -    License along with this library; if not, write to the Free Software
   38.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   38.21 -
   38.22 -    Sam Lantinga
   38.23 -    slouken@libsdl.org
   38.24 -*/
   38.25 -
   38.26 -/* AGL implementation of SDL OpenGL support */
   38.27 -
   38.28 -#include "SDL_config.h"
   38.29 -
   38.30 -#if SDL_VIDEO_OPENGL
   38.31 -#include "SDL_opengl.h"
   38.32 -#if __MACOSX__
   38.33 -#include <AGL/agl.h>            /* AGL.framework */
   38.34 -#else
   38.35 -#include <agl.h>
   38.36 -#endif
   38.37 -#endif /* SDL_VIDEO_OPENGL */
   38.38 -
   38.39 -/* OpenGL functions */
   38.40 -extern int Mac_GL_Init(_THIS);
   38.41 -extern void Mac_GL_Quit(_THIS);
   38.42 -#if SDL_VIDEO_OPENGL
   38.43 -extern int Mac_GL_MakeCurrent(_THIS);
   38.44 -extern int Mac_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
   38.45 -extern void Mac_GL_SwapBuffers(_THIS);
   38.46 -extern int Mac_GL_LoadLibrary(_THIS, const char *location);
   38.47 -extern void Mac_GL_UnloadLibrary(_THIS);
   38.48 -extern void *Mac_GL_GetProcAddress(_THIS, const char *proc);
   38.49 -#endif
   38.50 -/* vi: set ts=4 sw=4 expandtab: */
    39.1 --- a/src/video/maccommon/SDL_mackeys.h	Thu Aug 10 14:35:42 2006 +0000
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,141 +0,0 @@
    39.4 -/*
    39.5 -    SDL - Simple DirectMedia Layer
    39.6 -    Copyright (C) 1997-2006 Sam Lantinga
    39.7 -
    39.8 -    This library is free software; you can redistribute it and/or
    39.9 -    modify it under the terms of the GNU Lesser General Public
   39.10 -    License as published by the Free Software Foundation; either
   39.11 -    version 2.1 of the License, or (at your option) any later version.
   39.12 -
   39.13 -    This library is distributed in the hope that it will be useful,
   39.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   39.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   39.16 -    Lesser General Public License for more details.
   39.17 -
   39.18 -    You should have received a copy of the GNU Lesser General Public
   39.19 -    License along with this library; if not, write to the Free Software
   39.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   39.21 -
   39.22 -    Sam Lantinga
   39.23 -    slouken@libsdl.org
   39.24 -*/
   39.25 -
   39.26 -/* These are the Macintosh key scancode constants -- from Inside Macintosh */
   39.27 -
   39.28 -#define MK_ESCAPE		0x35
   39.29 -#define MK_F1			0x7A
   39.30 -#define MK_F2			0x78
   39.31 -#define MK_F3			0x63
   39.32 -#define MK_F4			0x76
   39.33 -#define MK_F5			0x60
   39.34 -#define MK_F6			0x61
   39.35 -#define MK_F7			0x62
   39.36 -#define MK_F8			0x64
   39.37 -#define MK_F9			0x65
   39.38 -#define MK_F10			0x6D
   39.39 -#define MK_F11			0x67
   39.40 -#define MK_F12			0x6F
   39.41 -#define MK_PRINT		0x69
   39.42 -#define MK_SCROLLOCK		0x6B
   39.43 -#define MK_PAUSE		0x71
   39.44 -#define MK_POWER		0x7F
   39.45 -#define MK_BACKQUOTE		0x32
   39.46 -#define MK_1			0x12
   39.47 -#define MK_2			0x13
   39.48 -#define MK_3			0x14
   39.49 -#define MK_4			0x15
   39.50 -#define MK_5			0x17
   39.51 -#define MK_6			0x16
   39.52 -#define MK_7			0x1A
   39.53 -#define MK_8			0x1C
   39.54 -#define MK_9			0x19
   39.55 -#define MK_0			0x1D
   39.56 -#define MK_MINUS		0x1B
   39.57 -#define MK_EQUALS		0x18
   39.58 -#define MK_BACKSPACE		0x33
   39.59 -#define MK_INSERT		0x72
   39.60 -#define MK_HOME			0x73
   39.61 -#define MK_PAGEUP		0x74
   39.62 -#define MK_NUMLOCK		0x47
   39.63 -#define MK_KP_EQUALS		0x51
   39.64 -#define MK_KP_DIVIDE		0x4B
   39.65 -#define MK_KP_MULTIPLY		0x43
   39.66 -#define MK_TAB			0x30
   39.67 -#define MK_q			0x0C
   39.68 -#define MK_w			0x0D
   39.69 -#define MK_e			0x0E
   39.70 -#define MK_r			0x0F
   39.71 -#define MK_t			0x11
   39.72 -#define MK_y			0x10
   39.73 -#define MK_u			0x20
   39.74 -#define MK_i			0x22
   39.75 -#define MK_o			0x1F
   39.76 -#define MK_p			0x23
   39.77 -#define MK_LEFTBRACKET		0x21
   39.78 -#define MK_RIGHTBRACKET		0x1E
   39.79 -#define MK_BACKSLASH		0x2A
   39.80 -#define MK_DELETE		0x75
   39.81 -#define MK_END			0x77
   39.82 -#define MK_PAGEDOWN		0x79
   39.83 -#define MK_KP7			0x59
   39.84 -#define MK_KP8			0x5B
   39.85 -#define MK_KP9			0x5C
   39.86 -#define MK_KP_MINUS		0x4E
   39.87 -#define MK_CAPSLOCK		0x39
   39.88 -#define MK_a			0x00
   39.89 -#define MK_s			0x01
   39.90 -#define MK_d			0x02
   39.91 -#define MK_f			0x03
   39.92 -#define MK_g			0x05
   39.93 -#define MK_h			0x04
   39.94 -#define MK_j			0x26
   39.95 -#define MK_k			0x28
   39.96 -#define MK_l			0x25
   39.97 -#define MK_SEMICOLON		0x29
   39.98 -#define MK_QUOTE		0x27
   39.99 -#define MK_RETURN		0x24
  39.100 -#define MK_KP4			0x56
  39.101 -#define MK_KP5			0x57
  39.102 -#define MK_KP6			0x58
  39.103 -#define MK_KP_PLUS		0x45
  39.104 -#define MK_LSHIFT		0x38
  39.105 -#define MK_z			0x06
  39.106 -#define MK_x			0x07
  39.107 -#define MK_c			0x08
  39.108 -#define MK_v			0x09
  39.109 -#define MK_b			0x0B
  39.110 -#define MK_n			0x2D
  39.111 -#define MK_m			0x2E
  39.112 -#define MK_COMMA		0x2B
  39.113 -#define MK_PERIOD		0x2F
  39.114 -#define MK_SLASH		0x2C
  39.115 -#if 0                           /* These are the same as the left versions - use left by default */
  39.116 -#define MK_RSHIFT		0x38
  39.117 -#endif
  39.118 -#define MK_UP			0x7E
  39.119 -#define MK_KP1			0x53
  39.120 -#define MK_KP2			0x54
  39.121 -#define MK_KP3			0x55
  39.122 -#define MK_KP_ENTER		0x4C
  39.123 -#define MK_LCTRL		0x3B
  39.124 -#define MK_LALT			0x3A
  39.125 -#define MK_LMETA		0x37
  39.126 -#define MK_SPACE		0x31
  39.127 -#if 0                           /* These are the same as the left versions - use left by default */
  39.128 -#define MK_RMETA		0x37
  39.129 -#define MK_RALT			0x3A
  39.130 -#define MK_RCTRL		0x3B
  39.131 -#endif
  39.132 -#define MK_LEFT			0x7B
  39.133 -#define MK_DOWN			0x7D
  39.134 -#define MK_RIGHT		0x7C
  39.135 -#define MK_KP0			0x52
  39.136 -#define MK_KP_PERIOD		0x41
  39.137 -
  39.138 -/* Wierd, these keys are on my iBook under Mac OS X */
  39.139 -#define MK_IBOOK_ENTER		0x34
  39.140 -#define MK_IBOOK_LEFT		0x3B
  39.141 -#define MK_IBOOK_RIGHT		0x3C
  39.142 -#define MK_IBOOK_DOWN		0x3D
  39.143 -#define MK_IBOOK_UP		0x3E
  39.144 -/* vi: set ts=4 sw=4 expandtab: */
    40.1 --- a/src/video/maccommon/SDL_macmouse.c	Thu Aug 10 14:35:42 2006 +0000
    40.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.3 @@ -1,136 +0,0 @@
    40.4 -/*
    40.5 -    SDL - Simple DirectMedia Layer
    40.6 -    Copyright (C) 1997-2006 Sam Lantinga
    40.7 -
    40.8 -    This library is free software; you can redistribute it and/or
    40.9 -    modify it under the terms of the GNU Lesser General Public
   40.10 -    License as published by the Free Software Foundation; either
   40.11 -    version 2.1 of the License, or (at your option) any later version.
   40.12 -
   40.13 -    This library is distributed in the hope that it will be useful,
   40.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   40.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   40.16 -    Lesser General Public License for more details.
   40.17 -
   40.18 -    You should have received a copy of the GNU Lesser General Public
   40.19 -    License along with this library; if not, write to the Free Software
   40.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   40.21 -
   40.22 -    Sam Lantinga
   40.23 -    slouken@libsdl.org
   40.24 -*/
   40.25 -#include "SDL_config.h"
   40.26 -
   40.27 -#if defined(__APPLE__) && defined(__MACH__)
   40.28 -#include <Carbon/Carbon.h>
   40.29 -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
   40.30 -#include <Carbon.h>
   40.31 -#else
   40.32 -#include <Quickdraw.h>
   40.33 -#endif
   40.34 -
   40.35 -/* Routines that are not supported by the Carbon API... */
   40.36 -#if !TARGET_API_MAC_CARBON
   40.37 -#include <CursorDevices.h>
   40.38 -#endif
   40.39 -
   40.40 -#include "SDL_mouse.h"
   40.41 -#include "SDL_macmouse_c.h"
   40.42 -
   40.43 -
   40.44 -/* The implementation dependent data for the window manager cursor */
   40.45 -struct WMcursor
   40.46 -{
   40.47 -    Cursor curs;
   40.48 -};
   40.49 -
   40.50 -
   40.51 -void
   40.52 -Mac_FreeWMCursor(_THIS, WMcursor * cursor)
   40.53 -{
   40.54 -    SDL_free(cursor);
   40.55 -}
   40.56 -
   40.57 -WMcursor *
   40.58 -Mac_CreateWMCursor(_THIS,
   40.59 -                   Uint8 * data, Uint8 * mask, int w, int h, int hot_x,
   40.60 -                   int hot_y)
   40.61 -{
   40.62 -    WMcursor *cursor;
   40.63 -    int row, bytes;
   40.64 -
   40.65 -    /* Allocate the cursor memory */
   40.66 -    cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor));
   40.67 -    if (cursor == NULL) {
   40.68 -        SDL_OutOfMemory();
   40.69 -        return (NULL);
   40.70 -    }
   40.71 -    SDL_memset(cursor, 0, sizeof(*cursor));
   40.72 -
   40.73 -    if (w > 16)
   40.74 -        w = 16;
   40.75 -
   40.76 -    if (h > 16)
   40.77 -        h = 16;
   40.78 -
   40.79 -    bytes = (w + 7) / 8;
   40.80 -
   40.81 -    for (row = 0; row < h; ++row) {
   40.82 -        SDL_memcpy(&cursor->curs.data[row], data, bytes);
   40.83 -        data += bytes;
   40.84 -    }
   40.85 -    for (row = 0; row < h; ++row) {
   40.86 -        SDL_memcpy(&cursor->curs.mask[row], mask, bytes);
   40.87 -        mask += bytes;
   40.88 -    }
   40.89 -    cursor->curs.hotSpot.h = hot_x;
   40.90 -    cursor->curs.hotSpot.v = hot_y;
   40.91 -
   40.92 -    /* That was easy. :) */
   40.93 -    return (cursor);
   40.94 -}
   40.95 -
   40.96 -int Mac_cursor_showing = 1;
   40.97 -
   40.98 -int
   40.99 -Mac_ShowWMCursor(_THIS, WMcursor * cursor)
  40.100 -{
  40.101 -    if (cursor == NULL) {
  40.102 -        if (Mac_cursor_showing) {
  40.103 -            HideCursor();
  40.104 -            Mac_cursor_showing = 0;
  40.105 -        }
  40.106 -    } else {
  40.107 -        SetCursor(&cursor->curs);
  40.108 -        if (!Mac_cursor_showing) {
  40.109 -            ShowCursor();
  40.110 -            Mac_cursor_showing = 1;
  40.111 -        }
  40.112 -    }
  40.113 -    return (1);
  40.114 -}
  40.115 -
  40.116 -void
  40.117 -Mac_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
  40.118 -{
  40.119 -#if !TARGET_API_MAC_CARBON
  40.120 -    CursorDevice *cursordevice;
  40.121 -
  40.122 -    cursordevice = nil;
  40.123 -    CursorDeviceNextDevice(&cursordevice);
  40.124 -    if (cursordevice != nil) {
  40.125 -        WindowPtr saveport;
  40.126 -        Point where;
  40.127 -
  40.128 -        GetPort(&saveport);
  40.129 -        SetPort(SDL_Window);
  40.130 -        where.h = x;
  40.131 -        where.v = y;
  40.132 -        LocalToGlobal(&where);
  40.133 -        SetPort(saveport);
  40.134 -        CursorDeviceMoveTo(cursordevice, where.h, where.v);
  40.135 -    }
  40.136 -#endif /* !TARGET_API_MAC_CARBON */
  40.137 -}
  40.138 -
  40.139 -/* vi: set ts=4 sw=4 expandtab: */
    41.1 --- a/src/video/maccommon/SDL_macmouse_c.h	Thu Aug 10 14:35:42 2006 +0000
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,36 +0,0 @@
    41.4 -/*
    41.5 -    SDL - Simple DirectMedia Layer
    41.6 -    Copyright (C) 1997-2006 Sam Lantinga
    41.7 -
    41.8 -    This library is free software; you can redistribute it and/or
    41.9 -    modify it under the terms of the GNU Lesser General Public
   41.10 -    License as published by the Free Software Foundation; either
   41.11 -    version 2.1 of the License, or (at your option) any later version.
   41.12 -
   41.13 -    This library is distributed in the hope that it will be useful,
   41.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   41.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   41.16 -    Lesser General Public License for more details.
   41.17 -
   41.18 -    You should have received a copy of the GNU Lesser General Public
   41.19 -    License along with this library; if not, write to the Free Software
   41.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   41.21 -
   41.22 -    Sam Lantinga
   41.23 -    slouken@libsdl.org
   41.24 -*/
   41.25 -#include "SDL_config.h"
   41.26 -
   41.27 -#include "../macrom/SDL_romvideo.h"
   41.28 -
   41.29 -/* Functions to be exported */
   41.30 -extern void Mac_FreeWMCursor(_THIS, WMcursor * cursor);
   41.31 -extern WMcursor *Mac_CreateWMCursor(_THIS,
   41.32 -                                    Uint8 * data, Uint8 * mask, int w, int h,
   41.33 -                                    int hot_x, int hot_y);
   41.34 -extern int Mac_ShowWMCursor(_THIS, WMcursor * cursor);
   41.35 -extern void Mac_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
   41.36 -
   41.37 -/* Data to be exported */
   41.38 -extern int Mac_cursor_showing;
   41.39 -/* vi: set ts=4 sw=4 expandtab: */
    42.1 --- a/src/video/maccommon/SDL_macwm.c	Thu Aug 10 14:35:42 2006 +0000
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,47 +0,0 @@
    42.4 -/*
    42.5 -    SDL - Simple DirectMedia Layer
    42.6 -    Copyright (C) 1997-2006 Sam Lantinga
    42.7 -
    42.8 -    This library is free software; you can redistribute it and/or
    42.9 -    modify it under the terms of the GNU Lesser General Public
   42.10 -    License as published by the Free Software Foundation; either
   42.11 -    version 2.1 of the License, or (at your option) any later version.
   42.12 -
   42.13 -    This library is distributed in the hope that it will be useful,
   42.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   42.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   42.16 -    Lesser General Public License for more details.
   42.17 -
   42.18 -    You should have received a copy of the GNU Lesser General Public
   42.19 -    License along with this library; if not, write to the Free Software
   42.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   42.21 -
   42.22 -    Sam Lantinga
   42.23 -    slouken@libsdl.org
   42.24 -*/
   42.25 -#include "SDL_config.h"
   42.26 -
   42.27 -#if defined(__APPLE__) && defined(__MACH__)
   42.28 -#include <Carbon/Carbon.h>
   42.29 -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
   42.30 -#include <Carbon.h>
   42.31 -#else
   42.32 -#include <Windows.h>
   42.33 -#include <Strings.h>
   42.34 -#endif
   42.35 -
   42.36 -#include "SDL_stdinc.h"
   42.37 -#include "SDL_macwm_c.h"
   42.38 -
   42.39 -void
   42.40 -Mac_SetCaption(_THIS, const char *title, const char *icon)
   42.41 -{
   42.42 -    /* Don't convert C to P string in place, because it may be read-only */
   42.43 -    Str255 ptitle;              /* MJS */
   42.44 -    ptitle[0] = strlen(title);
   42.45 -    SDL_memcpy(ptitle + 1, title, ptitle[0]);   /* MJS */
   42.46 -    if (SDL_Window)
   42.47 -        SetWTitle(SDL_Window, ptitle);  /* MJS */
   42.48 -}
   42.49 -
   42.50 -/* vi: set ts=4 sw=4 expandtab: */
    43.1 --- a/src/video/maccommon/SDL_macwm_c.h	Thu Aug 10 14:35:42 2006 +0000
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,28 +0,0 @@
    43.4 -/*
    43.5 -    SDL - Simple DirectMedia Layer
    43.6 -    Copyright (C) 1997-2006 Sam Lantinga
    43.7 -
    43.8 -    This library is free software; you can redistribute it and/or
    43.9 -    modify it under the terms of the GNU Lesser General Public
   43.10 -    License as published by the Free Software Foundation; either
   43.11 -    version 2.1 of the License, or (at your option) any later version.
   43.12 -
   43.13 -    This library is distributed in the hope that it will be useful,
   43.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   43.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   43.16 -    Lesser General Public License for more details.
   43.17 -
   43.18 -    You should have received a copy of the GNU Lesser General Public
   43.19 -    License along with this library; if not, write to the Free Software
   43.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   43.21 -
   43.22 -    Sam Lantinga
   43.23 -    slouken@libsdl.org
   43.24 -*/
   43.25 -#include "SDL_config.h"
   43.26 -
   43.27 -#include "../macrom/SDL_romvideo.h"
   43.28 -
   43.29 -/* Functions to be exported */
   43.30 -extern void Mac_SetCaption(_THIS, const char *title, const char *icon);
   43.31 -/* vi: set ts=4 sw=4 expandtab: */
    44.1 --- a/src/video/macdsp/SDL_dspvideo.c	Thu Aug 10 14:35:42 2006 +0000
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,1480 +0,0 @@
    44.4 -/*
    44.5 -    SDL - Simple DirectMedia Layer
    44.6 -    Copyright (C) 1997-2006 Sam Lantinga
    44.7 -
    44.8 -    This library is free software; you can redistribute it and/or
    44.9 -    modify it under the terms of the GNU Lesser General Public
   44.10 -    License as published by the Free Software Foundation; either
   44.11 -    version 2.1 of the License, or (at your option) any later version.
   44.12 -
   44.13 -    This library is distributed in the hope that it will be useful,
   44.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   44.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   44.16 -    Lesser General Public License for more details.
   44.17 -
   44.18 -    You should have received a copy of the GNU Lesser General Public
   44.19 -    License along with this library; if not, write to the Free Software
   44.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   44.21 -
   44.22 -    Sam Lantinga
   44.23 -    slouken@libsdl.org
   44.24 -*/
   44.25 -#include "SDL_config.h"
   44.26 -
   44.27 -/*
   44.28 - Written by Darrell Walisser <dwaliss1@purdue.edu>
   44.29 -
   44.30 - Implementation notes ----------------------------------------------------------------------
   44.31 -
   44.32 - A bit on GWorlds in VRAM from technote 1182:
   44.33 -
   44.34 - There are two important things to note about GWorld's allocated in
   44.35 - VRAM. First, the base address retrieved through GetPixBaseAddr or
   44.36 - read directly from the PixMap structure can become invalid anytime
   44.37 - memory is allocated in VRAM. This can occur either by explicit
   44.38 - allocations, such as calls to NewGWorld, or by implicit ones, such as
   44.39 - those associated with the internal texture allocation of OpenGL. The
   44.40 - stored pixel images themselves will still be valid but may have been
   44.41 - moved in VRAM, thus rendering any stored base addresses invalid.
   44.42 - You should never store an image's base address for longer than is
   44.43 - necessary and especially never across calls to NewGWorld or
   44.44 - texture-creation routines. 
   44.45 -
   44.46 - Secondly, an offscreen pixel image allocated in VRAM can be
   44.47 - purged at system task time by the display driver. This means any
   44.48 - time your application yields time such by calling WaitNextEvent or
   44.49 - SystemTask you can lose your VRAM GWorld contents. While this
   44.50 - happens infrequently, usually associated with display resolution or
   44.51 - pixel depth changes you must code for this eventuality. This purge
   44.52 - can occur whether or not the GWorld is locked or not. A return value
   44.53 - of false from LockPixels, a NULL return value from GetPixBaseAddr
   44.54 - or NULL in the baseAddr field of the PixMap mean that the pixel
   44.55 - image has been purged. To reallocate it you can either call
   44.56 - UpdateGWorld or Dispose your current GWorld through
   44.57 - DisposeGWorld and reallocate it via NewGWorld. Either way you must
   44.58 - then rebuild the pixel image. 
   44.59 -
   44.60 -------------------------------------------------------------------------------------
   44.61 -
   44.62 -  Currently, I don't account for (1). In my testing, NewGWorld never invalidated
   44.63 -  other existing GWorlds in VRAM. However, I do have protection for (2).
   44.64 -  Namely, I am using GetOSEvent() instead of WaitNextEvent() so that there are no
   44.65 -  context switches (the app hogs the CPU). Eventually a book-keeping system should
   44.66 -  be coded to take care of (1) and (2).
   44.67 -  
   44.68 -------------------------------------------------------------------------------------
   44.69 -
   44.70 -  System requirements (* denotes optional):
   44.71 -  
   44.72 -  1. DrawSprocket 1.7.3
   44.73 -  2. *MacOS 9 or later (but *not* Mac OS X) for hardware accelerated blit / fill
   44.74 -  3. *May also require certain graphics hardware for (2). I trust that all Apple OEM
   44.75 -     hardware will work. Third party accelerators may work if they have QuickDraw
   44.76 -     acceleration in the drivers and the drivers have been updated for OS 9. The current
   44.77 -     Voodoo 3 drivers (1.0b12) do not work.
   44.78 -  
   44.79 -  Coding suggestions:
   44.80 -  
   44.81 -  1. Use SDL_UpdateRects !
   44.82 -  
   44.83 -    If no QuickDraw acceleration is present, double-buffered surfaces will use a back buffer
   44.84 -    in System memory. I recommend you use SDL_UpdateRects with double-buffered surfaces
   44.85 -    for best performance on these cards, since the overhead is nearly zero for VRAM back buffer.
   44.86 -    
   44.87 -  2. Load most-resident surfaces first.
   44.88 -  
   44.89 -    If you fill up VRAM or AGP memory, there is no contingency for purging to make room for the next one.
   44.90 -    Therefore, you should load the surfaces you plan to use the most frequently first.
   44.91 -    Sooner or later, I will code LRU replacement to help this.
   44.92 -  
   44.93 -  TODO:
   44.94 -  Some kind of posterized mode for resolutions < 640x480.
   44.95 -  Window support / fullscreen toggle.
   44.96 -  Figure out how much VRAM is available. Put in video->info->video_mem.
   44.97 -  Track VRAM usage.
   44.98 -  
   44.99 -  BUGS:
  44.100 -  I can't create a hardware surface the same size as the screen?! How to fix?
  44.101 -  
  44.102 -  
  44.103 -
  44.104 -   COMPILE OPTIONS:
  44.105 -   
  44.106 -   DSP_TRY_CC_AND_AA - Define if you want to try HWA color-key and alpha blitters
  44.107 -                       HW color-key blitting gives substantial improvements,
  44.108 -                       but hw alpha is neck-and-neck with SDL's soft bitter.
  44.109 -
  44.110 -   DSP_NO_SYNC_VBL   - Define for HWA double-buffered surfaces: don't sync
  44.111 -                       pseudo-flip to monitor redraw.
  44.112 -
  44.113 -   DSP_NO_SYNC_OPENGL - Define for OpenGL surfaces: don't sync buffer swap. Synching buffer
  44.114 -                        swap may result in reduced performance, but can eliminate some
  44.115 -                        tearing artifacts.
  44.116 -   CHANGELOG:
  44.117 -   09/17/00 Lots of little tweaks. Build modelist in reverse order so largest contexts
  44.118 -            list first. Compared various methods with ROM methods and fixed rez switch
  44.119 -            crashing bug in GL Tron. (Woohoo!)
  44.120 -*/
  44.121 -
  44.122 -#define DSP_TRY_CC_AND_AA
  44.123 -
  44.124 -/* #define DSP_NO_SYNC_VBL */
  44.125 -
  44.126 -#define DSP_NO_SYNC_OPENGL
  44.127 -
  44.128 -
  44.129 -#if defined(__APPLE__) && defined(__MACH__)
  44.130 -#include <Carbon/Carbon.h>
  44.131 -#include <DrawSprocket/DrawSprocket.h>
  44.132 -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
  44.133 -#include <Carbon.h>
  44.134 -#include <DrawSprocket.h>
  44.135 -#else
  44.136 -#include <LowMem.h>
  44.137 -#include <Gestalt.h>
  44.138 -#include <Devices.h>
  44.139 -#include <DiskInit.h>
  44.140 -#include <QDOffscreen.h>
  44.141 -#include <DrawSprocket.h>
  44.142 -#endif
  44.143 -
  44.144 -#include "SDL_video.h"
  44.145 -#include "SDL_syswm.h"
  44.146 -#include "../SDL_sysvideo.h"
  44.147 -#include "../SDL_blit.h"
  44.148 -#include "../SDL_pixels_c.h"
  44.149 -#include "SDL_dspvideo.h"
  44.150 -#include "../maccommon/SDL_macgl_c.h"
  44.151 -#include "../maccommon/SDL_macwm_c.h"
  44.152 -#include "../maccommon/SDL_macmouse_c.h"
  44.153 -#include "../maccommon/SDL_macevents_c.h"
  44.154 -
  44.155 -/* Initialization/Query functions */
  44.156 -static int DSp_VideoInit(_THIS, SDL_PixelFormat * vformat);
  44.157 -static SDL_Rect **DSp_ListModes(_THIS, SDL_PixelFormat * format,
  44.158 -                                Uint32 flags);
  44.159 -static SDL_Surface *DSp_SetVideoMode(_THIS, SDL_Surface * current, int width,
  44.160 -                                     int height, int bpp, Uint32 flags);
  44.161 -static int DSp_SetColors(_THIS, int firstcolor, int ncolors,
  44.162 -                         SDL_Color * colors);
  44.163 -static int DSp_CreatePalette(_THIS);
  44.164 -static int DSp_DestroyPalette(_THIS);
  44.165 -static void DSp_VideoQuit(_THIS);
  44.166 -
  44.167 -static int DSp_GetMainDevice(_THIS, GDHandle * device);
  44.168 -static void DSp_IsHWAvailable(_THIS, SDL_PixelFormat * vformat);
  44.169 -static void DSp_DSpUpdate(_THIS, int numrects, SDL_Rect * sdl_rects);
  44.170 -static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * sdl_rects);
  44.171 -
  44.172 -/* Hardware surface functions */
  44.173 -static int DSp_SetHWAlpha(_THIS, SDL_Surface * surface, UInt8 alpha);
  44.174 -static int DSp_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key);
  44.175 -static int DSp_NewHWSurface(_THIS, CGrafPtr * port, int depth, int width,
  44.176 -                            int height);
  44.177 -static int DSp_AllocHWSurface(_THIS, SDL_Surface * surface);
  44.178 -static int DSp_LockHWSurface(_THIS, SDL_Surface * surface);
  44.179 -static void DSp_UnlockHWSurface(_THIS, SDL_Surface * surface);
  44.180 -static void DSp_FreeHWSurface(_THIS, SDL_Surface * surface);
  44.181 -static int DSp_FlipHWSurface(_THIS, SDL_Surface * surface);
  44.182 -static int DSp_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dest);
  44.183 -static int DSp_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
  44.184 -                           SDL_Surface * dst, SDL_Rect * dstrect);
  44.185 -static int DSp_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect,
  44.186 -                          Uint32 color);
  44.187 -
  44.188 -#if SDL_VIDEO_OPENGL
  44.189 -static void DSp_GL_SwapBuffers(_THIS);
  44.190 -#endif
  44.191 -
  44.192 -#if ! TARGET_API_MAC_CARBON
  44.193 -
  44.194 -#define GetPortPixRowBytes(x)  ( (*(x->portPixMap))->rowBytes )
  44.195 -#define GetGDevPixMap(x) ((**(x)).gdPMap)
  44.196 -#define GetPortPixMap(x) ((*(x)).portPixMap)
  44.197 -
  44.198 -#define GetPixDepth(y)    ((**(y)).pixelSize)
  44.199 -   //#define GetPixRowBytes(y) ((**(y)).rowBytes)
  44.200 -   //#define GetPixBaseAddr(y) ((**(y)).baseAddr)
  44.201 -#define GetPixCTab(y)     ((**(y)).pmTable)
  44.202 -#define GetPortBitMapForCopyBits(x) (&(((GrafPtr)(x))->portBits))
  44.203 -
  44.204 -#else
  44.205 -#define GetPortPixRowBytes(x) (GetPixRowBytes(GetPortPixMap(x)) )
  44.206 -#define GetGDevPixMap(x) ((**(x)).gdPMap)
  44.207 -
  44.208 -#endif
  44.209 -
  44.210 -typedef struct private_hwdata
  44.211 -{
  44.212 -
  44.213 -    GWorldPtr offscreen;        // offscreen gworld in VRAM or AGP
  44.214 -
  44.215 -#ifdef DSP_TRY_CC_AND_AA
  44.216 -    GWorldPtr mask;             // transparent mask
  44.217 -    RGBColor alpha;             // alpha color
  44.218 -    RGBColor trans;             // transparent color
  44.219 -#endif
  44.220 -
  44.221 -} private_hwdata;
  44.222 -
  44.223 -typedef private_hwdata private_swdata;  /* have same fields */
  44.224 -
  44.225 -/* Macintosh toolbox driver bootstrap functions */
  44.226 -
  44.227 -static int
  44.228 -DSp_Available(void)
  44.229 -{
  44.230 -    /* Check for DrawSprocket */
  44.231 -#if ! TARGET_API_MAC_OSX
  44.232 -    /* This check is only meaningful if you weak-link DrawSprocketLib */
  44.233 -    return ((Ptr) DSpStartup != (Ptr) kUnresolvedCFragSymbolAddress);
  44.234 -#else
  44.235 -    return 1;                   // DrawSprocket.framework doesn't have it all, but it's there
  44.236 -#endif
  44.237 -}
  44.238 -
  44.239 -static void
  44.240 -DSp_DeleteDevice(SDL_VideoDevice * device)
  44.241 -{
  44.242 -    /* -dw- taking no chances with null pointers */
  44.243 -    if (device) {
  44.244 -
  44.245 -        if (device->hidden) {
  44.246 -
  44.247 -            if (device->hidden->dspinfo)
  44.248 -                SDL_free(device->hidden->dspinfo);
  44.249 -
  44.250 -            SDL_free(device->hidden);
  44.251 -        }
  44.252 -        SDL_free(device);
  44.253 -    }
  44.254 -}
  44.255 -
  44.256 -static SDL_VideoDevice *
  44.257 -DSp_CreateDevice(int devindex)
  44.258 -{
  44.259 -    SDL_VideoDevice *device;
  44.260 -
  44.261 -    /* Initialize all variables that we clean on shutdown */
  44.262 -    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
  44.263 -    if (device) {
  44.264 -        SDL_memset(device, 0, sizeof(*device));
  44.265 -        device->hidden = (struct SDL_PrivateVideoData *)
  44.266 -            SDL_malloc((sizeof *device->hidden));
  44.267 -        if (device->hidden)
  44.268 -            SDL_memset(device->hidden, 0, sizeof(*(device->hidden)));
  44.269 -    }
  44.270 -    if ((device == NULL) || (device->hidden == NULL)) {
  44.271 -        SDL_OutOfMemory();
  44.272 -
  44.273 -        if (device) {
  44.274 -
  44.275 -            if (device->hidden)
  44.276 -                SDL_free(device->hidden);
  44.277 -
  44.278 -            SDL_free(device);
  44.279 -        }
  44.280 -
  44.281 -        return (NULL);
  44.282 -    }
  44.283 -
  44.284 -    /* Allocate DrawSprocket information */
  44.285 -    device->hidden->dspinfo = (struct DSpInfo *) SDL_malloc((sizeof *device->
  44.286 -                                                             hidden->
  44.287 -                                                             dspinfo));
  44.288 -    if (device->hidden->dspinfo == NULL) {
  44.289 -        SDL_OutOfMemory();
  44.290 -        SDL_free(device->hidden);
  44.291 -        SDL_free(device);
  44.292 -        return (0);
  44.293 -    }
  44.294 -    SDL_memset(device->hidden->dspinfo, 0, (sizeof *device->hidden->dspinfo));
  44.295 -
  44.296 -    /* Set the function pointers */
  44.297 -    device->VideoInit = DSp_VideoInit;
  44.298 -    device->ListModes = DSp_ListModes;
  44.299 -    device->SetVideoMode = DSp_SetVideoMode;
  44.300 -    device->SetColors = DSp_SetColors;
  44.301 -    device->UpdateRects = NULL;
  44.302 -    device->VideoQuit = DSp_VideoQuit;
  44.303 -    device->AllocHWSurface = DSp_AllocHWSurface;
  44.304 -    device->CheckHWBlit = NULL;
  44.305 -    device->FillHWRect = NULL;
  44.306 -    device->SetHWColorKey = NULL;
  44.307 -    device->SetHWAlpha = NULL;
  44.308 -    device->LockHWSurface = DSp_LockHWSurface;
  44.309 -    device->UnlockHWSurface = DSp_UnlockHWSurface;
  44.310 -    device->FlipHWSurface = DSp_FlipHWSurface;
  44.311 -    device->FreeHWSurface = DSp_FreeHWSurface;
  44.312 -#if SDL_VIDEO_OPENGL
  44.313 -    device->GL_MakeCurrent = Mac_GL_MakeCurrent;
  44.314 -    device->GL_SwapBuffers = DSp_GL_SwapBuffers;
  44.315 -    device->GL_LoadLibrary = Mac_GL_LoadLibrary;
  44.316 -    device->GL_GetProcAddress = Mac_GL_GetProcAddress;
  44.317 -#endif
  44.318 -    device->SetCaption = NULL;
  44.319 -    device->SetIcon = NULL;
  44.320 -    device->IconifyWindow = NULL;
  44.321 -    device->GrabInput = NULL;
  44.322 -    device->GetWMInfo = NULL;
  44.323 -    device->FreeWMCursor = Mac_FreeWMCursor;
  44.324 -    device->CreateWMCursor = Mac_CreateWMCursor;
  44.325 -    device->ShowWMCursor = Mac_ShowWMCursor;
  44.326 -    device->WarpWMCursor = Mac_WarpWMCursor;
  44.327 -    device->InitOSKeymap = Mac_InitOSKeymap;
  44.328 -    device->PumpEvents = Mac_PumpEvents;
  44.329 -
  44.330 -    device->GrabInput = NULL;
  44.331 -    device->CheckMouseMode = NULL;
  44.332 -
  44.333 -    device->free = DSp_DeleteDevice;
  44.334 -
  44.335 -    return device;
  44.336 -}
  44.337 -
  44.338 -VideoBootStrap DSp_bootstrap = {
  44.339 -    "DSp", "MacOS DrawSprocket",
  44.340 -    DSp_Available, DSp_CreateDevice
  44.341 -};
  44.342 -
  44.343 -/* Use DSp/Display Manager to build mode list for given screen */
  44.344 -static SDL_Rect **
  44.345 -DSp_BuildModeList(const GDHandle gDevice, int *displayWidth,
  44.346 -                  int *displayHeight)
  44.347 -{
  44.348 -    DSpContextAttributes attributes;
  44.349 -    DSpContextReference context;
  44.350 -    DisplayIDType displayID;
  44.351 -    SDL_Rect temp_list[16];
  44.352 -    SDL_Rect **mode_list;
  44.353 -    int width, height, i, j;
  44.354 -
  44.355 -#if TARGET_API_MAC_OSX
  44.356 -
  44.357 -    displayID = 0;
  44.358 -
  44.359 -#else
  44.360 -    /* Ask Display Manager for integer id of screen device */
  44.361 -    if (DMGetDisplayIDByGDevice(gDevice, &displayID, SDL_TRUE) != noErr) {
  44.362 -        return NULL;
  44.363 -    }
  44.364 -#endif
  44.365 -    /* Get the first possible DSp context on this device */
  44.366 -    if (DSpGetFirstContext(displayID, &context) != noErr) {
  44.367 -        return NULL;
  44.368 -    }
  44.369 -
  44.370 -    if (DSpContext_GetAttributes(context, &attributes) != noErr)
  44.371 -        return NULL;
  44.372 -
  44.373 -    *displayWidth = attributes.displayWidth;
  44.374 -    *displayHeight = attributes.displayHeight;
  44.375 -
  44.376 -    for (i = 0; i < SDL_arraysize(temp_list); i++) {
  44.377 -        width = attributes.displayWidth;
  44.378 -        height = attributes.displayHeight;
  44.379 -
  44.380 -        temp_list[i].x = 0 | attributes.displayBestDepth;
  44.381 -        temp_list[i].y = 0;
  44.382 -        temp_list[i].w = width;
  44.383 -        temp_list[i].h = height;
  44.384 -
  44.385 -        /* DSp will report many different contexts with the same width and height. */
  44.386 -        /* They will differ in bit depth and refresh rate. */
  44.387 -        /* We will ignore them until we reach one with a different width/height */
  44.388 -        /* When there are no more contexts to look at, we will quit building the list */
  44.389 -        while (width == attributes.displayWidth
  44.390 -               && height == attributes.displayHeight) {
  44.391 -
  44.392 -            OSStatus err = DSpGetNextContext(context, &context);
  44.393 -            if (err != noErr)
  44.394 -                if (err == kDSpContextNotFoundErr)
  44.395 -                    goto done;
  44.396 -                else
  44.397 -                    return NULL;
  44.398 -
  44.399 -            if (DSpContext_GetAttributes(context, &attributes) != noErr)
  44.400 -                return NULL;
  44.401 -
  44.402 -            temp_list[i].x |= attributes.displayBestDepth;
  44.403 -        }
  44.404 -    }
  44.405 -  done:
  44.406 -    i++;                        /* i was not incremented before kicking out of the loop */
  44.407 -
  44.408 -    mode_list = (SDL_Rect **) SDL_malloc(sizeof(SDL_Rect *) * (i + 1));
  44.409 -    if (mode_list) {
  44.410 -
  44.411 -        /* -dw- new stuff: build in reverse order so largest sizes list first */
  44.412 -        for (j = i - 1; j >= 0; j--) {
  44.413 -            mode_list[j] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
  44.414 -            if (mode_list[j])
  44.415 -                SDL_memcpy(mode_list[j], &(temp_list[j]), sizeof(SDL_Rect));
  44.416 -            else {
  44.417 -                SDL_OutOfMemory();
  44.418 -                return NULL;
  44.419 -            }
  44.420 -        }
  44.421 -        mode_list[i] = NULL;    /* append null to the end */
  44.422 -    } else {
  44.423 -        SDL_OutOfMemory();
  44.424 -        return NULL;
  44.425 -    }
  44.426 -
  44.427 -    return mode_list;
  44.428 -}
  44.429 -
  44.430 -static void
  44.431 -DSp_IsHWAvailable(_THIS, SDL_PixelFormat * vformat)
  44.432 -{
  44.433 -    /* 
  44.434 -       VRAM GWorlds are only available on OS 9 or later.
  44.435 -       Even with OS 9, some display drivers won't support it, 
  44.436 -       so we create a test GWorld and check for errors. 
  44.437 -     */
  44.438 -
  44.439 -    long versionSystem;
  44.440 -
  44.441 -    dsp_vram_available = SDL_FALSE;
  44.442 -    dsp_agp_available = SDL_FALSE;
  44.443 -
  44.444 -    Gestalt('sysv', &versionSystem);
  44.445 -    if (0x00000860 < (versionSystem & 0x0000FFFF)) {
  44.446 -
  44.447 -        GWorldPtr offscreen;
  44.448 -        OSStatus err;
  44.449 -        Rect bounds;
  44.450 -
  44.451 -        SetRect(&bounds, 0, 0, 320, 240);
  44.452 -
  44.453 -#if useDistantHdwrMem && useLocalHdwrMem
  44.454 -        err =
  44.455 -            NewGWorld(&offscreen, vformat->BitsPerPixel, &bounds, NULL,
  44.456 -                      SDL_Display, useDistantHdwrMem | noNewDevice);
  44.457 -        if (err == noErr) {
  44.458 -            dsp_vram_available = SDL_TRUE;
  44.459 -            DisposeGWorld(offscreen);
  44.460 -        }
  44.461 -
  44.462 -        err =
  44.463 -            NewGWorld(&offscreen, vformat->BitsPerPixel, &bounds, NULL,
  44.464 -                      SDL_Display, useLocalHdwrMem | noNewDevice);
  44.465 -        if (err == noErr) {
  44.466 -            DisposeGWorld(offscreen);
  44.467 -            dsp_agp_available = SDL_TRUE;
  44.468 -        }
  44.469 -#endif
  44.470 -    }
  44.471 -}
  44.472 -
  44.473 -static int
  44.474 -DSp_GetMainDevice(_THIS, GDHandle * device)
  44.475 -{
  44.476 -
  44.477 -#if TARGET_API_MAC_OSX
  44.478 -    /* DSpUserSelectContext not available on OS X */
  44.479 -    *device = GetMainDevice();
  44.480 -    return 0;
  44.481 -#else
  44.482 -
  44.483 -    DSpContextAttributes attrib;
  44.484 -    DSpContextReference context;
  44.485 -    DisplayIDType display_id;
  44.486 -    GDHandle main_device;
  44.487 -    GDHandle device_list;
  44.488 -
  44.489 -    device_list = GetDeviceList();
  44.490 -    main_device = GetMainDevice();
  44.491 -
  44.492 -    /* Quick check to avoid slower method when only one display exists */
  44.493 -    if ((**device_list).gdNextGD == NULL) {
  44.494 -        *device = main_device;
  44.495 -        return 0;
  44.496 -    }
  44.497 -
  44.498 -    SDL_memset(&attrib, 0, sizeof(DSpContextAttributes));
  44.499 -
  44.500 -    /* These attributes are hopefully supported on all devices... */
  44.501 -    attrib.displayWidth = 640;
  44.502 -    attrib.displayHeight = 480;
  44.503 -    attrib.displayBestDepth = 8;
  44.504 -    attrib.backBufferBestDepth = 8;
  44.505 -    attrib.displayDepthMask = kDSpDepthMask_All;
  44.506 -    attrib.backBufferDepthMask = kDSpDepthMask_All;
  44.507 -    attrib.colorNeeds = kDSpColorNeeds_Require;
  44.508 -    attrib.pageCount = 1;
  44.509 -
  44.510 -    if (noErr != DMGetDisplayIDByGDevice(main_device, &display_id, SDL_FALSE)) {
  44.511 -        SDL_SetError
  44.512 -            ("Display Manager couldn't associate GDevice with a Display ID");
  44.513 -        return (-1);
  44.514 -    }
  44.515 -
  44.516 -    /* Put up dialog on main display to select which display to use */
  44.517 -    if (noErr != DSpUserSelectContext(&attrib, display_id, NULL, &context)) {
  44.518 -        SDL_SetError("DrawSprocket couldn't create a context");
  44.519 -        return (-1);
  44.520 -    }
  44.521 -
  44.522 -    if (noErr != DSpContext_GetDisplayID(context, &display_id)) {
  44.523 -        SDL_SetError("DrawSprocket couldn't get display ID");
  44.524 -        return (-1);
  44.525 -    }
  44.526 -
  44.527 -    if (noErr != DMGetGDeviceByDisplayID(display_id, &main_device, SDL_FALSE)) {
  44.528 -        SDL_SetError
  44.529 -            ("Display Manager couldn't associate Display ID with GDevice");
  44.530 -        return (-1);
  44.531 -    }
  44.532 -
  44.533 -    *device = main_device;
  44.534 -    return (0);
  44.535 -#endif
  44.536 -}
  44.537 -
  44.538 -static int
  44.539 -DSp_VideoInit(_THIS, SDL_PixelFormat * vformat)
  44.540 -{
  44.541 -    NumVersion dsp_version = { 0x01, 0x00, 0x00, 0x00 };
  44.542 -
  44.543 -#if UNIVERSAL_INTERFACES_VERSION > 0x0320
  44.544 -    dsp_version = DSpGetVersion();
  44.545 -#endif
  44.546 -
  44.547 -    if ((dsp_version.majorRev == 1 && dsp_version.minorAndBugRev < 0x73) ||
  44.548 -        (dsp_version.majorRev < 1)) {
  44.549 -
  44.550 -        /* StandardAlert (kAlertStopAlert, "\pError!", 
  44.551 -           "\pI need DrawSprocket 1.7.3 or later!\n"
  44.552 -           "You can find a newer version at http://www.apple.com/swupdates.",
  44.553 -           NULL, NULL);
  44.554 -         */
  44.555 -        SDL_SetError("DrawSprocket version is too old. Need 1.7.3 or later.");
  44.556 -        return (-1);
  44.557 -    }
  44.558 -
  44.559 -    if (DSpStartup() != noErr) {
  44.560 -        SDL_SetError("DrawSprocket couldn't startup");
  44.561 -        return (-1);
  44.562 -    }
  44.563 -
  44.564 -    /* Start DSpintosh events */
  44.565 -    Mac_InitEvents(this);
  44.566 -
  44.567 -    /* Get a handle to the main monitor, or choose one on multiple monitor setups */
  44.568 -    if (DSp_GetMainDevice(this, &SDL_Display) < 0)
  44.569 -        return (-1);
  44.570 -
  44.571 -    /* Determine pixel format */
  44.572 -    vformat->BitsPerPixel = GetPixDepth((**SDL_Display).gdPMap);
  44.573 -    dsp_old_depth = vformat->BitsPerPixel;
  44.574 -
  44.575 -    switch (vformat->BitsPerPixel) {
  44.576 -    case 16:
  44.577 -        vformat->Rmask = 0x00007c00;
  44.578 -        vformat->Gmask = 0x000003e0;
  44.579 -        vformat->Bmask = 0x0000001f;
  44.580 -        break;
  44.581 -    default:
  44.582 -        break;
  44.583 -    }
  44.584 -
  44.585 -    if (DSp_CreatePalette(this) < 0) {
  44.586 -        SDL_SetError("Could not create palette");
  44.587 -        return (-1);
  44.588 -    }
  44.589 -
  44.590 -    /* Get a list of available fullscreen modes */
  44.591 -    SDL_modelist = DSp_BuildModeList(SDL_Display,
  44.592 -                                     &this->info.current_w,
  44.593 -                                     &this->info.current_h);
  44.594 -    if (SDL_modelist == NULL) {
  44.595 -        SDL_SetError("DrawSprocket could not build a mode list");
  44.596 -        return (-1);
  44.597 -    }
  44.598 -
  44.599 -    /* Check for VRAM and AGP GWorlds for HW Blitting */
  44.600 -    DSp_IsHWAvailable(this, vformat);
  44.601 -
  44.602 -    this->info.wm_available = 0;
  44.603 -
  44.604 -    if (dsp_vram_available || dsp_agp_available) {
  44.605 -
  44.606 -        this->info.hw_available = SDL_TRUE;
  44.607 -
  44.608 -        this->CheckHWBlit = DSp_CheckHWBlit;
  44.609 -        this->info.blit_hw = SDL_TRUE;
  44.610 -
  44.611 -        this->FillHWRect = DSp_FillHWRect;
  44.612 -        this->info.blit_fill = SDL_TRUE;
  44.613 -
  44.614 -#ifdef DSP_TRY_CC_AND_AA
  44.615 -        this->SetHWColorKey = DSp_SetHWColorKey;
  44.616 -        this->info.blit_hw_CC = SDL_TRUE;
  44.617 -
  44.618 -        this->SetHWAlpha = DSp_SetHWAlpha;
  44.619 -        this->info.blit_hw_A = SDL_TRUE;
  44.620 -#endif
  44.621 -
  44.622 -    }
  44.623 -
  44.624 -    return (0);
  44.625 -}
  44.626 -
  44.627 -static SDL_Rect **
  44.628 -DSp_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
  44.629 -{
  44.630 -    static SDL_Rect *dsp_modes[16];
  44.631 -    int i = 0, j = 0;
  44.632 -
  44.633 -    if (format->BitsPerPixel == 0)
  44.634 -        return ((SDL_Rect **) NULL);
  44.635 -
  44.636 -    while (SDL_modelist[i] != NULL) {
  44.637 -
  44.638 -        if (SDL_modelist[i]->x & format->BitsPerPixel) {
  44.639 -            dsp_modes[j] = SDL_modelist[i];
  44.640 -            j++;
  44.641 -        }
  44.642 -        i++;
  44.643 -    }
  44.644 -
  44.645 -    dsp_modes[j] = NULL;
  44.646 -
  44.647 -    return dsp_modes;
  44.648 -}
  44.649 -
  44.650 -/* Various screen update functions available */
  44.651 -static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
  44.652 -
  44.653 -#if ! TARGET_API_MAC_OSX
  44.654 -
  44.655 -static volatile unsigned int retrace_count = 0; /* -dw- need volatile because it updates asychronously */
  44.656 -
  44.657 -Boolean
  44.658 -DSp_VBLProc(DSpContextReference context, void *ref_con)
  44.659 -{
  44.660 -    retrace_count++;
  44.661 -
  44.662 -    return 1;                   /* Darrell, is this right? */
  44.663 -}
  44.664 -
  44.665 -static void
  44.666 -DSp_SetHWError(OSStatus err, int is_agp)
  44.667 -{
  44.668 -    char message[1024];
  44.669 -    const char *fmt, *mem;
  44.670 -
  44.671 -    if (is_agp) {
  44.672 -        mem = "AGP Memory";
  44.673 -    } else {
  44.674 -        mem = "VRAM";
  44.675 -    }
  44.676 -    switch (err) {
  44.677 -    case memFullErr:
  44.678 -        fmt = "Hardware surface possible but not enough %s available";
  44.679 -        break;
  44.680 -    case cDepthErr:
  44.681 -        fmt = "Hardware surface possible but invalid color depth";
  44.682 -        break;
  44.683 -    default:
  44.684 -        fmt = "Hardware surface could not be allocated in %s - unknown error";
  44.685 -        break;
  44.686 -    }
  44.687 -    SDL_snprintf(message, SDL_arraysize(message), fmt, mem);
  44.688 -    SDL_SetError(message);
  44.689 -}
  44.690 -#endif // TARGET_API_MAC_OSX
  44.691 -
  44.692 -/* put up a dialog to verify display change */
  44.693 -static int
  44.694 -DSp_ConfirmSwitch()
  44.695 -{
  44.696 -
  44.697 -    /* resource id's for dialog */
  44.698 -    const int rDialog = 1002;
  44.699 -    const int bCancel = 1;
  44.700 -    const int bOK = 2;
  44.701 -
  44.702 -    DialogPtr dialog;
  44.703 -    OSStatus err;
  44.704 -    SInt32 response;
  44.705 -    DialogItemIndex item = 0;
  44.706 -    GrafPtr savePort;
  44.707 -
  44.708 -    GetPort(&savePort);
  44.709 -
  44.710 -    dialog = GetNewDialog(rDialog, NULL, (WindowPtr) - 1);
  44.711 -    if (dialog == NULL)
  44.712 -        return (0);
  44.713 -
  44.714 -#if TARGET_API_MAC_CARBON
  44.715 -    SetPort(GetDialogPort(dialog));
  44.716 -#else
  44.717 -    SetPort((WindowPtr) dialog);
  44.718 -#endif
  44.719 -
  44.720 -    SetDialogDefaultItem(dialog, bCancel);
  44.721 -    SetDialogCancelItem(dialog, bCancel);
  44.722 -
  44.723 -    SetEventMask(everyEvent);
  44.724 -    FlushEvents(everyEvent, 0);
  44.725 -
  44.726 -    /* On MacOS 8.5 or later, we can make the dialog go away after 15 seconds */
  44.727 -    /* This is good since it's possible user can't even see the dialog! */
  44.728 -    /* Requires linking to DialogsLib */
  44.729 -    err = Gestalt(gestaltSystemVersion, &response);
  44.730 -    if (err == noErr && response >= 0x00000850) {
  44.731 -        SetDialogTimeout(dialog, bCancel, 15);
  44.732 -    }
  44.733 -
  44.734 -    do {
  44.735 -
  44.736 -        ModalDialog(NULL, &item);
  44.737 -
  44.738 -    }
  44.739 -    while (item != bCancel && item != bOK && err != noErr);
  44.740 -
  44.741 -
  44.742 -    DisposeDialog(dialog);
  44.743 -    SetPort(savePort);
  44.744 -
  44.745 -    SetEventMask(everyEvent - autoKeyMask);
  44.746 -    FlushEvents(everyEvent, 0);
  44.747 -
  44.748 -    return (item - 1);
  44.749 -}
  44.750 -
  44.751 -static void
  44.752 -DSp_UnsetVideoMode(_THIS, SDL_Surface * current)
  44.753 -{
  44.754 -
  44.755 -
  44.756 -    if (current->flags & SDL_INTERNALOPENGL) {
  44.757 -        Mac_GL_Quit(this);
  44.758 -    }
  44.759 -
  44.760 -    if (dsp_context != NULL) {
  44.761 -
  44.762 -        GWorldPtr front;
  44.763 -        DSpContext_GetFrontBuffer(dsp_context, &front);
  44.764 -
  44.765 -        if (front != dsp_back_buffer)
  44.766 -            DisposeGWorld(dsp_back_buffer);
  44.767 -
  44.768 -        if (current->hwdata)
  44.769 -            SDL_free(current->hwdata);
  44.770 -
  44.771 -        DSpContext_SetState(dsp_context, kDSpContextState_Inactive);
  44.772 -        DSpContext_Release(dsp_context);
  44.773 -
  44.774 -        dsp_context = NULL;
  44.775 -    }
  44.776 -
  44.777 -    if (SDL_Window != NULL) {
  44.778 -        DisposeWindow(SDL_Window);
  44.779 -        SDL_Window = NULL;
  44.780 -    }
  44.781 -
  44.782 -    current->pixels = NULL;
  44.783 -    current->flags = 0;
  44.784 -}
  44.785 -
  44.786 -static SDL_Surface *
  44.787 -DSp_SetVideoMode(_THIS,
  44.788 -                 SDL_Surface * current, int width, int height, int bpp,
  44.789 -                 Uint32 flags)
  44.790 -{
  44.791 -
  44.792 -#if !TARGET_API_MAC_OSX
  44.793 -    DisplayIDType display_id;
  44.794 -    Fixed freq;
  44.795 -#endif
  44.796 -    DSpContextAttributes attrib;
  44.797 -    OSStatus err;
  44.798 -    UInt32 rmask = 0, gmask = 0, bmask = 0;
  44.799 -
  44.800 -    int page_count;
  44.801 -    int double_buf;
  44.802 -    int hw_surface;
  44.803 -    int use_dsp_back_buffer;
  44.804 -
  44.805 -    DSp_UnsetVideoMode(this, current);
  44.806 -
  44.807 -    if (bpp != dsp_old_depth)
  44.808 -        DSp_DestroyPalette(this);
  44.809 -
  44.810 -    double_buf = (flags & SDL_DOUBLEBUF) != 0;
  44.811 -    hw_surface = (flags & SDL_HWSURFACE) != 0;
  44.812 -    use_dsp_back_buffer = !dsp_vram_available || !hw_surface;
  44.813 -
  44.814 -    current->flags |= SDL_FULLSCREEN;
  44.815 -
  44.816 -  rebuild:
  44.817 -
  44.818 -    if (double_buf && use_dsp_back_buffer) {
  44.819 -        page_count = 2;
  44.820 -    } else {
  44.821 -        page_count = 1;
  44.822 -    }
  44.823 -
  44.824 -    SDL_memset(&attrib, 0, sizeof(DSpContextAttributes));
  44.825 -    attrib.displayWidth = width;
  44.826 -    attrib.displayHeight = height;
  44.827 -    attrib.displayBestDepth = bpp;
  44.828 -    attrib.backBufferBestDepth = bpp;
  44.829 -    attrib.displayDepthMask = kDSpDepthMask_All;
  44.830 -    attrib.backBufferDepthMask = kDSpDepthMask_All;
  44.831 -    attrib.colorNeeds = kDSpColorNeeds_Require;
  44.832 -    attrib.colorTable = 0;
  44.833 -    attrib.pageCount = page_count;
  44.834 -#if TARGET_API_MAC_OSX || UNIVERSAL_INTERFACES_VERSION == 0x0320
  44.835 -
  44.836 -    if (DSpFindBestContext(&attrib, &dsp_context) != noErr) {
  44.837 -        SDL_SetError("DrawSprocket couldn't find a context");
  44.838 -        return NULL;
  44.839 -    }
  44.840 -#else
  44.841 -    if (noErr != DMGetDisplayIDByGDevice(SDL_Display, &display_id, SDL_FALSE)) {
  44.842 -        SDL_SetError
  44.843 -            ("Display Manager couldn't associate GDevice with display_id");
  44.844 -        return NULL;
  44.845 -    }
  44.846 -    if (DSpFindBestContextOnDisplayID(&attrib, &dsp_context, display_id) !=
  44.847 -        noErr) {
  44.848 -        SDL_SetError
  44.849 -            ("DrawSprocket couldn't find a suitable context on given display");
  44.850 -        return NULL;
  44.851 -    }
  44.852 -#endif
  44.853 -    if (DSpContext_Reserve(dsp_context, &attrib) != noErr) {
  44.854 -        SDL_SetError
  44.855 -            ("DrawSprocket couldn't get the needed resources to build the display");
  44.856 -        return NULL;
  44.857 -    }
  44.858 -
  44.859 -    if ((err =
  44.860 -         DSpContext_SetState(dsp_context, kDSpContextState_Active)) != noErr)
  44.861 -    {
  44.862 -
  44.863 -        if (err == kDSpConfirmSwitchWarning) {
  44.864 -
  44.865 -            if (!DSp_ConfirmSwitch()) {
  44.866 -
  44.867 -                DSpContext_Release(dsp_context);
  44.868 -                dsp_context = NULL;
  44.869 -                SDL_SetError("User cancelled display switch");
  44.870 -                return NULL;
  44.871 -            } else
  44.872 -                /* Have to reactivate context. Why? */
  44.873 -                DSpContext_SetState(dsp_context, kDSpContextState_Active);
  44.874 -
  44.875 -        } else {
  44.876 -            SDL_SetError("DrawSprocket couldn't activate the context");
  44.877 -            return NULL;
  44.878 -        }
  44.879 -    }
  44.880 -
  44.881 -
  44.882 -    if (bpp != dsp_old_depth) {
  44.883 -
  44.884 -        DSp_CreatePalette(this);
  44.885 -
  44.886 -        /* update format if display depth changed */
  44.887 -        if (bpp == 16) {
  44.888 -
  44.889 -            rmask = 0x00007c00;
  44.890 -            gmask = 0x000003e0;
  44.891 -            bmask = 0x0000001f;
  44.892 -        }
  44.893 -        if (!SDL_ReallocFormat(current, bpp, rmask, gmask, bmask, 0)) {
  44.894 -
  44.895 -            SDL_SetError("Could not reallocate video format.");
  44.896 -            return (NULL);
  44.897 -        }
  44.898 -    }
  44.899 -
  44.900 -    if (!double_buf) {
  44.901 -
  44.902 -        /* single-buffer context */
  44.903 -        DSpContext_GetFrontBuffer(dsp_context, &dsp_back_buffer);
  44.904 -
  44.905 -        current->hwdata =
  44.906 -            (private_hwdata *) SDL_malloc(sizeof(private_hwdata));
  44.907 -        if (current->hwdata == NULL) {
  44.908 -            SDL_OutOfMemory();
  44.909 -            return NULL;
  44.910 -        }
  44.911 -        current->hwdata->offscreen = dsp_back_buffer;
  44.912 -        current->flags |= SDL_HWSURFACE;
  44.913 -        this->UpdateRects = DSp_DirectUpdate;
  44.914 -    } else if (use_dsp_back_buffer) {
  44.915 -
  44.916 -        DSpContext_GetBackBuffer(dsp_context, kDSpBufferKind_Normal,
  44.917 -                                 &dsp_back_buffer);
  44.918 -
  44.919 -        current->flags |= SDL_DOUBLEBUF | SDL_SWSURFACE;        /* only front buffer is in VRAM */
  44.920 -        this->UpdateRects = DSp_DSpUpdate;
  44.921 -    } else if (DSp_NewHWSurface
  44.922 -               (this, &dsp_back_buffer, bpp, width - 1, height - 1) == 0) {
  44.923 -
  44.924 -        current->hwdata =
  44.925 -            (private_hwdata *) SDL_malloc(sizeof(private_hwdata));
  44.926 -        if (current->hwdata == NULL) {
  44.927 -            SDL_OutOfMemory();
  44.928 -            return NULL;
  44.929 -        }
  44.930 -
  44.931 -        SDL_memset(current->hwdata, 0, sizeof(private_hwdata));
  44.932 -        current->hwdata->offscreen = dsp_back_buffer;
  44.933 -        current->flags |= SDL_DOUBLEBUF | SDL_HWSURFACE;
  44.934 -        this->UpdateRects = DSp_DirectUpdate;   /* hardware doesn't do update rects, must be page-flipped */
  44.935 -    } else {
  44.936 -
  44.937 -        DSpContext_Release(dsp_context);
  44.938 -        use_dsp_back_buffer = SDL_TRUE;
  44.939 -        goto rebuild;
  44.940 -    }
  44.941 -
  44.942 -    current->pitch = GetPortPixRowBytes(dsp_back_buffer) & 0x3FFF;
  44.943 -    current->pixels = GetPixBaseAddr(GetPortPixMap(dsp_back_buffer));
  44.944 -
  44.945 -    current->w = width;
  44.946 -    current->h = height;
  44.947 -
  44.948 -#if ! TARGET_API_MAC_OSX
  44.949 -
  44.950 -    if (use_dsp_back_buffer) {
  44.951 -
  44.952 -        DSpContext_GetMonitorFrequency(dsp_context, &freq);
  44.953 -        DSpContext_SetMaxFrameRate(dsp_context, freq >> 16);
  44.954 -    }
  44.955 -
  44.956 -
  44.957 -    if ((current->flags & SDL_HWSURFACE)
  44.958 -        || (current->flags & SDL_INTERNALOPENGL))
  44.959 -        DSpContext_SetVBLProc(dsp_context, DSp_VBLProc, NULL);
  44.960 -#endif
  44.961 -
  44.962 -    if (bpp == 8)
  44.963 -        current->flags |= SDL_HWPALETTE;
  44.964 -
  44.965 -    if (flags & SDL_INTERNALOPENGL) {
  44.966 -
  44.967 -        Rect rect;
  44.968 -        RGBColor rgb = { 0.0, 0.0, 0.0 };
  44.969 -        GrafPtr save_port;
  44.970 -
  44.971 -        SetRect(&rect, 0, 0, width, height);
  44.972 -        SDL_Window =
  44.973 -            NewCWindow(nil, &((**SDL_Display).gdRect), "\p", SDL_TRUE,
  44.974 -                       plainDBox, (WindowPtr) - 1, SDL_FALSE, 0);
  44.975 -
  44.976 -        if (SDL_Window == NULL) {
  44.977 -
  44.978 -            SDL_SetError
  44.979 -                ("DSp_SetVideoMode : OpenGL window could not be created.");
  44.980 -            return NULL;
  44.981 -        }
  44.982 -
  44.983 -        /* Set window color to black to avoid white flash */
  44.984 -        GetPort(&save_port);
  44.985 -#if TARGET_API_MAC_CARBON
  44.986 -        SetPort(GetWindowPort(SDL_Window));
  44.987 -#else
  44.988 -        SetPort(SDL_Window);
  44.989 -#endif
  44.990 -        RGBForeColor(&rgb);
  44.991 -        PaintRect(&rect);
  44.992 -        SetPort(save_port);
  44.993 -
  44.994 -        SetPortWindowPort(SDL_Window);
  44.995 -        SelectWindow(SDL_Window);
  44.996 -
  44.997 -        if (Mac_GL_Init(this) < 0) {
  44.998 -
  44.999 -            SDL_SetError
 44.1000 -                ("DSp_SetVideoMode : could not create OpenGL context.");
 44.1001 -            return NULL;
 44.1002 -        }
 44.1003 -
 44.1004 -        current->flags |= SDL_INTERNALOPENGL;
 44.1005 -    }
 44.1006 -
 44.1007 -    return current;
 44.1008 -}
 44.1009 -
 44.1010 -#ifdef DSP_TRY_CC_AND_AA
 44.1011 -
 44.1012 -static int
 44.1013 -DSp_MakeHWMask(_THIS, SDL_Surface * surface)
 44.1014 -{
 44.1015 -    GDHandle save_device;
 44.1016 -    CGrafPtr save_port;
 44.1017 -    GWorldPtr temp;
 44.1018 -    RGBColor black = { 0, 0, 0 };
 44.1019 -    RGBColor white = { 0xFFFF, 0xFFFF, 0xFFFF };
 44.1020 -    Rect rect;
 44.1021 -
 44.1022 -    Uint32 depth = GetPixDepth(GetGDevPixMap(SDL_Display));
 44.1023 -
 44.1024 -    SetRect(&rect, 0, 0, surface->w, surface->h);
 44.1025 -
 44.1026 -    if (noErr !=
 44.1027 -        NewGWorld(&(surface->hwdata->mask), depth, &rect, 0, SDL_Display,
 44.1028 -                  0) < 0) {
 44.1029 -
 44.1030 -        SDL_OutOfMemory();
 44.1031 -        return (-1);
 44.1032 -    }
 44.1033 -
 44.1034 -    if (noErr != NewGWorld(&temp, depth, &rect, 0, SDL_Display, 0)) {
 44.1035 -
 44.1036 -        SDL_OutOfMemory();
 44.1037 -        return (-1);
 44.1038 -    }
 44.1039 -
 44.1040 -
 44.1041 -    GetGWorld(&save_port, &save_device);
 44.1042 -    SetGWorld(surface->hwdata->mask, SDL_Display);
 44.1043 -
 44.1044 -    RGBForeColor(&white);
 44.1045 -    PaintRect(&rect);
 44.1046 -
 44.1047 -    RGBBackColor(&(surface->hwdata->trans));
 44.1048 -
 44.1049 -    CopyBits(GetPortBitMapForCopyBits(surface->hwdata->offscreen),
 44.1050 -             GetPortBitMapForCopyBits(surface->hwdata->mask),
 44.1051 -             &rect, &rect, transparent, NULL);
 44.1052 -
 44.1053 -    SetGWorld(surface->hwdata->mask, SDL_Display);
 44.1054 -    SetGWorld(save_port, save_device);
 44.1055 -    return (0);
 44.1056 -}
 44.1057 -
 44.1058 -static int
 44.1059 -DSp_SetHWAlpha(_THIS, SDL_Surface * surface, UInt8 alpha)
 44.1060 -{
 44.1061 -    surface->hwdata->alpha.red = (alpha / 255.0) * 65535;
 44.1062 -    surface->hwdata->alpha.blue = (alpha / 255.0) * 65535;
 44.1063 -    surface->hwdata->alpha.green = (alpha / 255.0) * 65535;
 44.1064 -
 44.1065 -    surface->flags |= SDL_SRCALPHA;
 44.1066 -
 44.1067 -    if (surface->flags & SDL_SRCCOLORKEY) {
 44.1068 -        return (DSp_MakeHWMask(this, surface));
 44.1069 -    }
 44.1070 -    return (0);
 44.1071 -}
 44.1072 -
 44.1073 -static int
 44.1074 -DSp_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key)
 44.1075 -{
 44.1076 -    CGrafPtr save_port;
 44.1077 -    GDHandle save_device;
 44.1078 -
 44.1079 -    GetGWorld(&save_port, &save_device);
 44.1080 -    SetGWorld(surface->hwdata->offscreen, NULL);
 44.1081 -
 44.1082 -    Index2Color(key, &(surface->hwdata->trans));
 44.1083 -    surface->flags |= SDL_SRCCOLORKEY;
 44.1084 -
 44.1085 -    SetGWorld(save_port, save_device);
 44.1086 -
 44.1087 -    if (surface->flags & SDL_SRCALPHA) {
 44.1088 -        return (DSp_MakeHWMask(this, surface));
 44.1089 -    }
 44.1090 -    return (0);
 44.1091 -}
 44.1092 -
 44.1093 -#endif /* DSP_TRY_CC_AND_AA */
 44.1094 -
 44.1095 -static int
 44.1096 -DSp_NewHWSurface(_THIS, CGrafPtr * port, int depth, int width, int height)
 44.1097 -{
 44.1098 -
 44.1099 -    OSStatus err;
 44.1100 -    Rect bounds;
 44.1101 -
 44.1102 -    SetRect(&bounds, 0, 0, width, height);
 44.1103 -
 44.1104 -#if useDistantHdwrMem && useLocalHdwrMem
 44.1105 -    if (dsp_vram_available) {
 44.1106 -        /* try VRAM */
 44.1107 -        err =
 44.1108 -            NewGWorld(port, depth, &bounds, 0, SDL_Display,
 44.1109 -                      useDistantHdwrMem | noNewDevice);
 44.1110 -        if (err != noErr)
 44.1111 -            DSp_SetHWError(err, SDL_FALSE);
 44.1112 -        else
 44.1113 -            return (0);
 44.1114 -    }
 44.1115 -
 44.1116 -    if (dsp_agp_available) {
 44.1117 -        /* try AGP */
 44.1118 -        err =
 44.1119 -            NewGWorld(port, depth, &bounds, 0, SDL_Display,
 44.1120 -                      useLocalHdwrMem | noNewDevice);
 44.1121 -
 44.1122 -        if (err != noErr)
 44.1123 -            DSp_SetHWError(err, SDL_TRUE);
 44.1124 -        else
 44.1125 -            return (0);
 44.1126 -    }
 44.1127 -#endif
 44.1128 -
 44.1129 -    return (-1);
 44.1130 -}
 44.1131 -
 44.1132 -static int
 44.1133 -DSp_AllocHWSurface(_THIS, SDL_Surface * surface)
 44.1134 -{
 44.1135 -    GWorldPtr temp;
 44.1136 -
 44.1137 -    if (DSp_NewHWSurface
 44.1138 -        (this, &temp, surface->format->BitsPerPixel, surface->w,
 44.1139 -         surface->h) < 0)
 44.1140 -        return (-1);
 44.1141 -
 44.1142 -    surface->hwdata = (private_hwdata *) SDL_malloc(sizeof(private_hwdata));
 44.1143 -    if (surface->hwdata == NULL) {
 44.1144 -        SDL_OutOfMemory();
 44.1145 -        return -1;
 44.1146 -    }
 44.1147 -
 44.1148 -    SDL_memset(surface->hwdata, 0, sizeof(private_hwdata));
 44.1149 -    surface->hwdata->offscreen = temp;
 44.1150 -    surface->pitch = GetPixRowBytes(GetPortPixMap(temp)) & 0x3FFF;
 44.1151 -    surface->pixels = GetPixBaseAddr(GetPortPixMap(temp));
 44.1152 -    surface->flags |= SDL_HWSURFACE;
 44.1153 -#ifdef DSP_TRY_CC_AND_AA
 44.1154 -    surface->flags |= SDL_HWACCEL;
 44.1155 -#endif
 44.1156 -    return 0;
 44.1157 -}
 44.1158 -
 44.1159 -static void
 44.1160 -DSp_FreeHWSurface(_THIS, SDL_Surface * surface)
 44.1161 -{
 44.1162 -    if (surface->hwdata->offscreen != NULL)
 44.1163 -        DisposeGWorld(surface->hwdata->offscreen);
 44.1164 -    SDL_free(surface->hwdata);
 44.1165 -
 44.1166 -    surface->pixels = NULL;
 44.1167 -}
 44.1168 -
 44.1169 -static int
 44.1170 -DSp_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dest)
 44.1171 -{
 44.1172 -    int accelerated;
 44.1173 -
 44.1174 -    /* Set initial acceleration on */
 44.1175 -    src->flags |= SDL_HWACCEL;
 44.1176 -
 44.1177 -    /* Set the surface attributes */
 44.1178 -    if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
 44.1179 -        if (!this->info.blit_hw_A) {
 44.1180 -            src->flags &= ~SDL_HWACCEL;
 44.1181 -        }
 44.1182 -    }
 44.1183 -    if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
 44.1184 -        if (!this->info.blit_hw_CC) {
 44.1185 -            src->flags &= ~SDL_HWACCEL;
 44.1186 -        }
 44.1187 -    }
 44.1188 -
 44.1189 -    /* Check to see if final surface blit is accelerated */
 44.1190 -    accelerated = !!(src->flags & SDL_HWACCEL);
 44.1191 -    if (accelerated) {
 44.1192 -        src->map->hw_blit = DSp_HWAccelBlit;
 44.1193 -    }
 44.1194 -    return (accelerated);
 44.1195 -}
 44.1196 -
 44.1197 -static int
 44.1198 -DSp_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
 44.1199 -                SDL_Surface * dst, SDL_Rect * dstrect)
 44.1200 -{
 44.1201 -    CGrafPtr save_port;
 44.1202 -    GDHandle save_device;
 44.1203 -    Rect src_rect, dst_rect;
 44.1204 -    RGBColor black = { 0, 0, 0 };
 44.1205 -    RGBColor white = { 0xFFFF, 0xFFFF, 0xFFFF };
 44.1206 -
 44.1207 -#ifdef DSP_TRY_CC_AND_AA
 44.1208 -    UInt32 mode;
 44.1209 -#endif
 44.1210 -
 44.1211 -    SetRect(&src_rect, srcrect->x, srcrect->y, srcrect->x + srcrect->w,
 44.1212 -            srcrect->y + srcrect->h);
 44.1213 -    SetRect(&dst_rect, dstrect->x, dstrect->y, dstrect->x + dstrect->w,
 44.1214 -            dstrect->y + dstrect->h);
 44.1215 -
 44.1216 -    GetGWorld(&save_port, &save_device);
 44.1217 -    SetGWorld(dst->hwdata->offscreen, NULL);
 44.1218 -
 44.1219 -    RGBForeColor(&black);
 44.1220 -    RGBBackColor(&white);
 44.1221 -
 44.1222 -#ifdef DSP_TRY_CC_AND_AA
 44.1223 -
 44.1224 -    if ((src->flags & SDL_SRCCOLORKEY) && (src->flags & SDL_SRCALPHA)) {
 44.1225 -
 44.1226 -        OpColor(&(src->hwdata->alpha));
 44.1227 -
 44.1228 -        CopyDeepMask(GetPortBitMapForCopyBits(src->hwdata->offscreen),
 44.1229 -                     GetPortBitMapForCopyBits(src->hwdata->mask),
 44.1230 -                     GetPortBitMapForCopyBits(dst->hwdata->offscreen),
 44.1231 -                     &src_rect, &src_rect, &dst_rect, blend, NULL);
 44.1232 -    } else {
 44.1233 -
 44.1234 -        if (src->flags & SDL_SRCCOLORKEY) {
 44.1235 -            RGBBackColor(&(src->hwdata->trans));
 44.1236 -            mode = transparent;
 44.1237 -        } else if (src->flags & SDL_SRCALPHA) {
 44.1238 -
 44.1239 -            OpColor(&(src->hwdata->alpha));
 44.1240 -            mode = blend;
 44.1241 -        } else {
 44.1242 -
 44.1243 -            mode = srcCopy;
 44.1244 -        }
 44.1245 -
 44.1246 -        CopyBits(GetPortBitMapForCopyBits(src->hwdata->offscreen),
 44.1247 -                 GetPortBitMapForCopyBits(dst->hwdata->offscreen),
 44.1248 -                 &src_rect, &dst_rect, mode, NULL);
 44.1249 -    }
 44.1250 -#else
 44.1251 -
 44.1252 -    CopyBits(&(((GrafPtr) (src->hwdata->offscreen))->portBits),
 44.1253 -             &(((GrafPtr) (dst->hwdata->offscreen))->portBits),
 44.1254 -             &src_rect, &dst_rect, srcCopy, NULL);
 44.1255 -
 44.1256 -#endif /* DSP_TRY_CC_AND_AA */
 44.1257 -
 44.1258 -    SetGWorld(save_port, save_device);
 44.1259 -
 44.1260 -    return (0);
 44.1261 -}
 44.1262 -
 44.1263 -static int
 44.1264 -DSp_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
 44.1265 -{
 44.1266 -    CGrafPtr save_port;
 44.1267 -    GDHandle save_device;
 44.1268 -    Rect fill_rect;
 44.1269 -    RGBColor rgb;
 44.1270 -
 44.1271 -    SetRect(&fill_rect, rect->x, rect->y, rect->x + rect->w,
 44.1272 -            rect->y + rect->h);
 44.1273 -
 44.1274 -    GetGWorld(&save_port, &save_device);
 44.1275 -    SetGWorld(dst->hwdata->offscreen, NULL);
 44.1276 -
 44.1277 -    Index2Color(color, &rgb);
 44.1278 -
 44.1279 -    RGBForeColor(&rgb);
 44.1280 -    PaintRect(&fill_rect);
 44.1281 -
 44.1282 -    SetGWorld(save_port, save_device);
 44.1283 -
 44.1284 -    return (0);
 44.1285 -}
 44.1286 -
 44.1287 -static int
 44.1288 -DSp_FlipHWSurface(_THIS, SDL_Surface * surface)
 44.1289 -{
 44.1290 -    if ((surface->flags & SDL_HWSURFACE)) {
 44.1291 -        CGrafPtr dsp_front_buffer, save_port;
 44.1292 -        Rect rect;
 44.1293 -
 44.1294 -#if ! TARGET_API_MAC_OSX
 44.1295 -        unsigned int old_count;
 44.1296 -#endif
 44.1297 -
 44.1298 -        /* pseudo page flipping for VRAM back buffer */
 44.1299 -        DSpContext_GetFrontBuffer(dsp_context, &dsp_front_buffer);
 44.1300 -        SetRect(&rect, 0, 0, surface->w - 1, surface->h - 1);
 44.1301 -
 44.1302 -        GetPort((GrafPtr *) & save_port);
 44.1303 -        SetPort((GrafPtr) dsp_front_buffer);
 44.1304 -
 44.1305 -        /* wait for retrace */
 44.1306 -        /* I have tried doing the swap in interrupt routine (VBL Proc) to do */
 44.1307 -        /* it asynchronously, but apparently CopyBits isn't interrupt safe  */
 44.1308 -
 44.1309 -#if ! TARGET_API_MAC_OSX
 44.1310 -#ifndef DSP_NO_SYNC_VBL
 44.1311 -        old_count = retrace_count;
 44.1312 -        while (old_count == retrace_count);
 44.1313 -#endif
 44.1314 -#endif
 44.1315 -
 44.1316 -        CopyBits(GetPortBitMapForCopyBits(dsp_back_buffer),
 44.1317 -                 GetPortBitMapForCopyBits(dsp_front_buffer),
 44.1318 -                 &rect, &rect, srcCopy, NULL);
 44.1319 -
 44.1320 -        SetPort((GrafPtr) save_port);
 44.1321 -
 44.1322 -    } else {
 44.1323 -        /* not really page flipping at all: DSp just blits the dirty rectangles from DSp_UpdateRects */
 44.1324 -        Boolean busy_flag;
 44.1325 -        DSpContext_SwapBuffers(dsp_context, NULL, &busy_flag);  /* this  waits for VBL */
 44.1326 -        DSpContext_GetBackBuffer(dsp_context, kDSpBufferKind_Normal,
 44.1327 -                                 &dsp_back_buffer);
 44.1328 -        surface->pixels = GetPixBaseAddr(GetPortPixMap(dsp_back_buffer));
 44.1329 -    }
 44.1330 -    return (0);
 44.1331 -}
 44.1332 -
 44.1333 -static int
 44.1334 -DSp_LockHWSurface(_THIS, SDL_Surface * surface)
 44.1335 -{
 44.1336 -    if (LockPixels(GetGWorldPixMap(surface->hwdata->offscreen)))
 44.1337 -        return 0;
 44.1338 -    else
 44.1339 -        return -1;
 44.1340 -}
 44.1341 -
 44.1342 -static void
 44.1343 -DSp_UnlockHWSurface(_THIS, SDL_Surface * surface)
 44.1344 -{
 44.1345 -    UnlockPixels(GetGWorldPixMap(surface->hwdata->offscreen));
 44.1346 -}
 44.1347 -
 44.1348 -static void
 44.1349 -DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * sdl_rects)
 44.1350 -{
 44.1351 -    return;
 44.1352 -}
 44.1353 -
 44.1354 -static void
 44.1355 -DSp_DSpUpdate(_THIS, int numrects, SDL_Rect * sdl_rects)
 44.1356 -{
 44.1357 -#if ! TARGET_API_MAC_OSX        /* Unsupported DSp in here */
 44.1358 -    int i;
 44.1359 -    Rect rect;
 44.1360 -
 44.1361 -    for (i = 0; i < numrects; i++) {
 44.1362 -
 44.1363 -        rect.top = sdl_rects[i].y;
 44.1364 -        rect.left = sdl_rects[i].x;
 44.1365 -        rect.bottom = sdl_rects[i].h + sdl_rects[i].y;
 44.1366 -        rect.right = sdl_rects[i].w + sdl_rects[i].x;
 44.1367 -
 44.1368 -        DSpContext_InvalBackBufferRect(dsp_context, &rect);
 44.1369 -    }
 44.1370 -#endif
 44.1371 -}
 44.1372 -
 44.1373 -static int
 44.1374 -DSp_CreatePalette(_THIS)
 44.1375 -{
 44.1376 -
 44.1377 -
 44.1378 -    /* Create our palette */
 44.1379 -    SDL_CTab = (CTabHandle) NewHandle(sizeof(ColorSpec) * 256 + 8);
 44.1380 -    if (SDL_CTab == nil) {
 44.1381 -        SDL_OutOfMemory();
 44.1382 -        return (-1);
 44.1383 -    }
 44.1384 -    (**SDL_CTab).ctSeed = GetCTSeed();
 44.1385 -    (**SDL_CTab).ctFlags = 0;
 44.1386 -    (**SDL_CTab).ctSize = 255;
 44.1387 -    CTabChanged(SDL_CTab);
 44.1388 -    SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit + pmTolerant, 0);
 44.1389 -
 44.1390 -    return 0;
 44.1391 -}
 44.1392 -
 44.1393 -static int
 44.1394 -DSp_DestroyPalette(_THIS)
 44.1395 -{
 44.1396 -
 44.1397 -    /* Free palette and restore original one */
 44.1398 -    if (SDL_CTab != nil) {
 44.1399 -        DisposeHandle((Handle) SDL_CTab);
 44.1400 -        SDL_CTab = nil;
 44.1401 -    }
 44.1402 -    if (SDL_CPal != nil) {
 44.1403 -        DisposePalette(SDL_CPal);
 44.1404 -        SDL_CPal = nil;
 44.1405 -    }
 44.1406 -    RestoreDeviceClut(SDL_Display);
 44.1407 -
 44.1408 -    return (0);
 44.1409 -}
 44.1410 -
 44.1411 -static int
 44.1412 -DSp_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
 44.1413 -{
 44.1414 -    CTabHandle cTab;
 44.1415 -
 44.1416 -    int i;
 44.1417 -
 44.1418 -    cTab = SDL_CTab;
 44.1419 -
 44.1420 -    /* Verify the range of colors */
 44.1421 -    if ((firstcolor + ncolors) > ((**cTab).ctSize + 1)) {
 44.1422 -        return (0);
 44.1423 -    }
 44.1424 -
 44.1425 -    /* Set the screen palette and update the display */
 44.1426 -    for (i = 0; i < ncolors; i++) {
 44.1427 -        int j = firstcolor + i;
 44.1428 -        (**cTab).ctTable[j].value = j;
 44.1429 -        (**cTab).ctTable[j].rgb.red = colors[i].r << 8 | colors[i].r;
 44.1430 -        (**cTab).ctTable[j].rgb.green = colors[i].g << 8 | colors[i].g;
 44.1431 -        (**cTab).ctTable[j].rgb.blue = colors[i].b << 8 | colors[i].b;
 44.1432 -    }
 44.1433 -
 44.1434 -    SetGDevice(SDL_Display);
 44.1435 -    SetEntries(0, (**cTab).ctSize, (ColorSpec *) & (**cTab).ctTable);
 44.1436 -
 44.1437 -    return (1);
 44.1438 -}
 44.1439 -
 44.1440 -void
 44.1441 -DSp_VideoQuit(_THIS)
 44.1442 -{
 44.1443 -    int i;
 44.1444 -
 44.1445 -    /* Free current video mode */
 44.1446 -    DSp_UnsetVideoMode(this, this->screen);
 44.1447 -
 44.1448 -    /* Free Palette and restore original */
 44.1449 -    DSp_DestroyPalette(this);
 44.1450 -
 44.1451 -    /* Free list of video modes */
 44.1452 -    if (SDL_modelist != NULL) {
 44.1453 -        for (i = 0; SDL_modelist[i]; i++) {
 44.1454 -            SDL_free(SDL_modelist[i]);
 44.1455 -        }
 44.1456 -        SDL_free(SDL_modelist);
 44.1457 -        SDL_modelist = NULL;
 44.1458 -    }
 44.1459 -
 44.1460 -    /* Unload DrawSprocket */
 44.1461 -    DSpShutdown();
 44.1462 -}
 44.1463 -
 44.1464 -#if SDL_VIDEO_OPENGL
 44.1465 -
 44.1466 -/* swap buffers with v-sync */
 44.1467 -static void
 44.1468 -DSp_GL_SwapBuffers(_THIS)
 44.1469 -{
 44.1470 -
 44.1471 -#ifndef DSP_NO_SYNC_OPENGL
 44.1472 -
 44.1473 -    unsigned int old_count;
 44.1474 -
 44.1475 -    old_count = retrace_count;
 44.1476 -    while (old_count == retrace_count);
 44.1477 -#endif
 44.1478 -
 44.1479 -    aglSwapBuffers(glContext);
 44.1480 -}
 44.1481 -
 44.1482 -#endif
 44.1483 -/* vi: set ts=4 sw=4 expandtab: */
    45.1 --- a/src/video/macdsp/SDL_dspvideo.h	Thu Aug 10 14:35:42 2006 +0000
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,56 +0,0 @@
    45.4 -/*
    45.5 -    SDL - Simple DirectMedia Layer
    45.6 -    Copyright (C) 1997-2006 Sam Lantinga
    45.7 -
    45.8 -    This library is free software; you can redistribute it and/or
    45.9 -    modify it under the terms of the GNU Lesser General Public
   45.10 -    License as published by the Free Software Foundation; either
   45.11 -    version 2.1 of the License, or (at your option) any later version.
   45.12 -
   45.13 -    This library is distributed in the hope that it will be useful,
   45.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   45.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   45.16 -    Lesser General Public License for more details.
   45.17 -
   45.18 -    You should have received a copy of the GNU Lesser General Public
   45.19 -    License along with this library; if not, write to the Free Software
   45.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   45.21 -
   45.22 -    Sam Lantinga
   45.23 -    slouken@libsdl.org
   45.24 -*/
   45.25 -#include "SDL_config.h"
   45.26 -
   45.27 -#ifndef _SDL_dspvideo_h
   45.28 -#define _SDL_dspvideo_h
   45.29 -
   45.30 -#if TARGET_API_MAC_OSX
   45.31 -#  include <DrawSprocket/DrawSprocket.h>        /* Drawsprocket.framework */
   45.32 -#else
   45.33 -#include <DrawSprocket.h>
   45.34 -#endif
   45.35 -
   45.36 -#include "../maccommon/SDL_lowvideo.h"
   45.37 -
   45.38 -/* DrawSprocket specific information */
   45.39 -struct DSpInfo
   45.40 -{
   45.41 -    DSpContextReference dsp_context;
   45.42 -    CGrafPtr dsp_back_buffer;
   45.43 -    int dsp_old_depth;
   45.44 -
   45.45 -    /* Flags for hw acceleration */
   45.46 -    int dsp_vram_available;
   45.47 -    int dsp_agp_available;
   45.48 -
   45.49 -
   45.50 -};
   45.51 -/* Old variable names */
   45.52 -#define dsp_context (this->hidden->dspinfo->dsp_context)
   45.53 -#define dsp_back_buffer (this->hidden->dspinfo->dsp_back_buffer)
   45.54 -#define dsp_old_depth   (this->hidden->dspinfo->dsp_old_depth)
   45.55 -#define dsp_vram_available (this->hidden->dspinfo->dsp_vram_available)
   45.56 -#define dsp_agp_available (this->hidden->dspinfo->dsp_agp_available)
   45.57 -
   45.58 -#endif /* _SDL_dspvideo_h */
   45.59 -/* vi: set ts=4 sw=4 expandtab: */
    46.1 --- a/src/video/macrom/SDL_romvideo.c	Thu Aug 10 14:35:42 2006 +0000
    46.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.3 @@ -1,762 +0,0 @@
    46.4 -/*
    46.5 -    SDL - Simple DirectMedia Layer
    46.6 -    Copyright (C) 1997-2006 Sam Lantinga
    46.7 -
    46.8 -    This library is free software; you can redistribute it and/or
    46.9 -    modify it under the terms of the GNU Lesser General Public
   46.10 -    License as published by the Free Software Foundation; either
   46.11 -    version 2.1 of the License, or (at your option) any later version.
   46.12 -
   46.13 -    This library is distributed in the hope that it will be useful,
   46.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   46.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   46.16 -    Lesser General Public License for more details.
   46.17 -
   46.18 -    You should have received a copy of the GNU Lesser General Public
   46.19 -    License along with this library; if not, write to the Free Software
   46.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   46.21 -
   46.22 -    Sam Lantinga
   46.23 -    slouken@libsdl.org
   46.24 -*/
   46.25 -#include "SDL_config.h"
   46.26 -
   46.27 -#if defined(__APPLE__) && defined(__MACH__)
   46.28 -#include <Carbon/Carbon.h>
   46.29 -#if USE_QUICKTIME
   46.30 -#include <QuickTime/Movies.h>
   46.31 -#endif
   46.32 -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
   46.33 -#include <Carbon.h>
   46.34 -/* The fullscreen code requires the QuickTime framework, and the window
   46.35 -   is still at the back on Mac OS X, which is where this code is needed.
   46.36 - */
   46.37 -#if USE_QUICKTIME
   46.38 -#include <Movies.h>
   46.39 -#endif
   46.40 -#else
   46.41 -#include <Quickdraw.h>
   46.42 -#include <LowMem.h>
   46.43 -#include <Gestalt.h>
   46.44 -#include <Devices.h>
   46.45 -#include <DiskInit.h>
   46.46 -#include <QDOffscreen.h>
   46.47 -#endif
   46.48 -
   46.49 -#include "SDL_video.h"
   46.50 -#include "SDL_syswm.h"
   46.51 -#include "../SDL_sysvideo.h"
   46.52 -#include "SDL_romvideo.h"
   46.53 -#include "../maccommon/SDL_macgl_c.h"
   46.54 -#include "../maccommon/SDL_macwm_c.h"
   46.55 -#include "../maccommon/SDL_macmouse_c.h"
   46.56 -#include "../maccommon/SDL_macevents_c.h"
   46.57 -
   46.58 -/* Initialization/Query functions */
   46.59 -static int ROM_VideoInit(_THIS, SDL_PixelFormat * vformat);
   46.60 -static SDL_Rect **ROM_ListModes(_THIS, SDL_PixelFormat * format,
   46.61 -                                Uint32 flags);
   46.62 -static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface * current, int width,
   46.63 -                                     int height, int bpp, Uint32 flags);
   46.64 -static int ROM_SetColors(_THIS, int firstcolor, int ncolors,
   46.65 -                         SDL_Color * colors);
   46.66 -static void ROM_VideoQuit(_THIS);
   46.67 -
   46.68 -/* Hardware surface functions */
   46.69 -static int ROM_AllocHWSurface(_THIS, SDL_Surface * surface);
   46.70 -static int ROM_LockHWSurface(_THIS, SDL_Surface * surface);
   46.71 -static void ROM_UnlockHWSurface(_THIS, SDL_Surface * surface);
   46.72 -static void ROM_FreeHWSurface(_THIS, SDL_Surface * surface);
   46.73 -
   46.74 -#if !TARGET_API_MAC_CARBON      /* This seems not to be available? -sts Aug 2000 */
   46.75 -/* Saved state for the menu bar */
   46.76 -static RgnHandle gSaveGrayRgn = nil;
   46.77 -static short gSaveMenuBar = 0;
   46.78 -static Boolean gSaveCSVis = true;
   46.79 -
   46.80 -#if powerc
   46.81 -/* Mixed mode glue to activate the 68K emulator and twiddle a register */
   46.82 -#define ONEWORDSTUB(p1) \
   46.83 -		{ 0x41FA, 0x0010, 0x209F, (p1), 0x41FA, \
   46.84 -		  0x0008, 0x2F10, 0x4E75, 0x0000, 0x0000, 0x0000 }
   46.85 -
   46.86 -#define TWOWORDSTUB(p1,p2) \
   46.87 -		{ 0x41FA, 0x0012, 0x209F, (p1), (p2), 0x41FA, \
   46.88 -		  0x0008, 0x2F10, 0x4E75, 0x0000, 0x0000, 0x0000 }
   46.89 -
   46.90 -#define THREEWORDSTUB(p1,p2,p3) \
   46.91 -		{ 0x41FA, 0x0014, 0x209F, (p1), (p2), (p3), 0x41FA, \
   46.92 -		  0x0008, 0x2F10, 0x4E75, 0x0000, 0x0000, 0x0000 }
   46.93 -
   46.94 -/* ControlStrip inline glue for PowerPC */
   46.95 -static pascal Boolean
   46.96 -SBIsControlStripVisible(void)
   46.97 -{
   46.98 -    static short procData[] = TWOWORDSTUB(0x7000, 0xAAF2);
   46.99 -    ProcInfoType procInfo = kD0DispatchedPascalStackBased
  46.100 -        | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  46.101 -        | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode);
  46.102 -
  46.103 -    return ((Boolean)
  46.104 -            CallUniversalProc((UniversalProcPtr) procData, procInfo, 0x00));
  46.105 -}
  46.106 -
  46.107 -static pascal void
  46.108 -SBShowHideControlStrip(Boolean showIt)
  46.109 -{
  46.110 -    static short procData[] = THREEWORDSTUB(0x303C, 0x0101, 0xAAF2);
  46.111 -    ProcInfoType procInfo = kD0DispatchedPascalStackBased
  46.112 -        | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  46.113 -        | DISPATCHED_STACK_ROUTINE_PARAMETER(1,
  46.114 -                                             SIZE_CODE(sizeof(Boolean)));
  46.115 -
  46.116 -    CallUniversalProc((UniversalProcPtr) procData, procInfo, 0x01, showIt);
  46.117 -}
  46.118 -#endif /* powerc */
  46.119 -#endif /* !TARGET_API_MAC_CARBON */
  46.120 -
  46.121 -/* Macintosh toolbox driver bootstrap functions */
  46.122 -
  46.123 -static int
  46.124 -ROM_Available(void)
  46.125 -{
  46.126 -    return (1);
  46.127 -}
  46.128 -
  46.129 -static void
  46.130 -ROM_DeleteDevice(SDL_VideoDevice * device)
  46.131 -{
  46.132 -    SDL_free(device->hidden);
  46.133 -    SDL_free(device);
  46.134 -}
  46.135 -
  46.136 -static SDL_VideoDevice *
  46.137 -ROM_CreateDevice(int devindex)
  46.138 -{
  46.139 -    SDL_VideoDevice *device;
  46.140 -
  46.141 -    /* Initialize all variables that we clean on shutdown */
  46.142 -    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
  46.143 -    if (device) {
  46.144 -        SDL_memset(device, 0, (sizeof *device));
  46.145 -        device->hidden = (struct SDL_PrivateVideoData *)
  46.146 -            SDL_malloc((sizeof *device->hidden));
  46.147 -    }
  46.148 -    if ((device == NULL) || (device->hidden == NULL)) {
  46.149 -        SDL_OutOfMemory();
  46.150 -        if (device) {
  46.151 -            SDL_free(device);
  46.152 -        }
  46.153 -        return (0);
  46.154 -    }
  46.155 -    SDL_memset(device->hidden, 0, (sizeof *device->hidden));
  46.156 -
  46.157 -    /* Set the function pointers */
  46.158 -    device->VideoInit = ROM_VideoInit;
  46.159 -    device->ListModes = ROM_ListModes;
  46.160 -    device->SetVideoMode = ROM_SetVideoMode;
  46.161 -    device->SetColors = ROM_SetColors;
  46.162 -    device->UpdateRects = NULL;
  46.163 -    device->VideoQuit = ROM_VideoQuit;
  46.164 -    device->AllocHWSurface = ROM_AllocHWSurface;
  46.165 -    device->CheckHWBlit = NULL;
  46.166 -    device->FillHWRect = NULL;
  46.167 -    device->SetHWColorKey = NULL;
  46.168 -    device->SetHWAlpha = NULL;
  46.169 -    device->LockHWSurface = ROM_LockHWSurface;
  46.170 -    device->UnlockHWSurface = ROM_UnlockHWSurface;
  46.171 -    device->FlipHWSurface = NULL;
  46.172 -    device->FreeHWSurface = ROM_FreeHWSurface;
  46.173 -#if SDL_VIDEO_OPENGL
  46.174 -    device->GL_MakeCurrent = Mac_GL_MakeCurrent;
  46.175 -    device->GL_SwapBuffers = Mac_GL_SwapBuffers;
  46.176 -    device->GL_LoadLibrary = Mac_GL_LoadLibrary;
  46.177 -    device->GL_GetProcAddress = Mac_GL_GetProcAddress;
  46.178 -#endif // Have OpenGL
  46.179 -    device->SetCaption = Mac_SetCaption;
  46.180 -    device->SetIcon = NULL;
  46.181 -    device->IconifyWindow = NULL;
  46.182 -    device->GrabInput = NULL;
  46.183 -    device->GetWMInfo = NULL;
  46.184 -    device->FreeWMCursor = Mac_FreeWMCursor;
  46.185 -    device->CreateWMCursor = Mac_CreateWMCursor;
  46.186 -    device->ShowWMCursor = Mac_ShowWMCursor;
  46.187 -    device->WarpWMCursor = Mac_WarpWMCursor;
  46.188 -    device->InitOSKeymap = Mac_InitOSKeymap;
  46.189 -    device->PumpEvents = Mac_PumpEvents;
  46.190 -
  46.191 -    device->free = ROM_DeleteDevice;
  46.192 -
  46.193 -    return device;
  46.194 -}
  46.195 -
  46.196 -VideoBootStrap TOOLBOX_bootstrap = {
  46.197 -    "toolbox", "MacOS ROM Toolbox",
  46.198 -    ROM_Available, ROM_CreateDevice
  46.199 -};
  46.200 -
  46.201 -
  46.202 -static int
  46.203 -ROM_VideoInit(_THIS, SDL_PixelFormat * vformat)
  46.204 -{
  46.205 -    long info;
  46.206 -
  46.207 -    /* Check out some things about the system */
  46.208 -    Gestalt(gestaltQuickdrawVersion, &info);
  46.209 -    if (info == gestaltOriginalQD) {
  46.210 -        SDL_SetError("Color Quickdraw not available");
  46.211 -        return (-1);
  46.212 -    }
  46.213 -
  46.214 -    /* Start ROMintosh events */
  46.215 -    Mac_InitEvents(this);
  46.216 -
  46.217 -    /* Get a handle to the main monitor */
  46.218 -    SDL_Display = GetMainDevice();
  46.219 -
  46.220 -    /* Determine the current screen size */
  46.221 -    this->info.current_w = (**SDL_Display).gdRect.right;
  46.222 -    this->info.current_h = (**SDL_Display).gdRect.bottom;
  46.223 -
  46.224 -    /* Determine pixel format */
  46.225 -    vformat->BitsPerPixel = (**(**SDL_Display).gdPMap).pixelSize;
  46.226 -    switch (vformat->BitsPerPixel) {
  46.227 -    case 16:                   /* 5-5-5 RGB */
  46.228 -        vformat->Rmask = 0x00007c00;
  46.229 -        vformat->Gmask = 0x000003e0;
  46.230 -        vformat->Bmask = 0x0000001f;
  46.231 -        break;
  46.232 -    default:
  46.233 -        break;
  46.234 -    }
  46.235 -
  46.236 -    /* Create our palette */
  46.237 -    SDL_CTab = (CTabHandle) NewHandle(sizeof(ColorSpec) * 256 + 8);
  46.238 -    if (SDL_CTab == nil) {
  46.239 -        SDL_OutOfMemory();
  46.240 -        return (-1);
  46.241 -    }
  46.242 -    (**SDL_CTab).ctSeed = GetCTSeed();
  46.243 -    (**SDL_CTab).ctFlags = 0;
  46.244 -    (**SDL_CTab).ctSize = 255;
  46.245 -    CTabChanged(SDL_CTab);
  46.246 -    SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit + pmTolerant, 0);
  46.247 -
  46.248 -    /* Get a list of available fullscreen modes */
  46.249 -    SDL_modelist = (SDL_Rect **) SDL_malloc((1 + 1) * sizeof(SDL_Rect *));
  46.250 -    if (SDL_modelist) {
  46.251 -        SDL_modelist[0] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
  46.252 -        if (SDL_modelist[0]) {
  46.253 -            SDL_modelist[0]->x = 0;
  46.254 -            SDL_modelist[0]->y = 0;
  46.255 -            SDL_modelist[0]->w = (**SDL_Display).gdRect.right;
  46.256 -            SDL_modelist[0]->h = (**SDL_Display).gdRect.bottom;
  46.257 -        }
  46.258 -        SDL_modelist[1] = NULL;
  46.259 -    }
  46.260 -
  46.261 -    /* Fill in some window manager capabilities */
  46.262 -    this->info.wm_available = 1;
  46.263 -
  46.264 -    /* We're done! */
  46.265 -    return (0);
  46.266 -}
  46.267 -
  46.268 -static SDL_Rect **
  46.269 -ROM_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
  46.270 -{
  46.271 -    if (this->screen->format->BitsPerPixel == format->BitsPerPixel) {
  46.272 -        if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) {
  46.273 -            return (SDL_modelist);
  46.274 -        } else {
  46.275 -            return ((SDL_Rect **) - 1);
  46.276 -        }
  46.277 -    } else {
  46.278 -        return ((SDL_Rect **) 0);
  46.279 -    }
  46.280 -}
  46.281 -
  46.282 -static void
  46.283 -ROM_HideMenuBar(_THIS)
  46.284 -{
  46.285 -#if !TARGET_API_MAC_CARBON      /* This seems not to be available? -sts Aug 2000 */
  46.286 -    RgnHandle drawRgn = nil;
  46.287 -    RgnHandle tempRgn = nil;
  46.288 -    RgnHandle grayRgn = nil;
  46.289 -    WindowPtr window = nil;
  46.290 -    GDHandle gd = nil;
  46.291 -    GrafPtr savePort;
  46.292 -    long response;
  46.293 -    short height;
  46.294 -    EventRecord theEvent;
  46.295 -
  46.296 -    height = GetMBarHeight();
  46.297 -
  46.298 -    if (height > 0) {
  46.299 -        tempRgn = NewRgn();
  46.300 -        drawRgn = NewRgn();
  46.301 -        gSaveGrayRgn = NewRgn();
  46.302 -        if (!tempRgn || !drawRgn || !gSaveGrayRgn) {
  46.303 -            goto CLEANUP;
  46.304 -        }
  46.305 -        grayRgn = GetGrayRgn(); /* No need to check for this */
  46.306 -
  46.307 -        GetPort(&savePort);
  46.308 -
  46.309 -        /* Hide the control strip if it's present, and record its 
  46.310 -           previous position into the dirty region for redrawing. 
  46.311 -           This isn't necessary, but may help catch stray bits. */
  46.312 -        CopyRgn(grayRgn, tempRgn);
  46.313 -        if (!Gestalt(gestaltControlStripAttr, &response) &&
  46.314 -            (response & (1L << gestaltControlStripExists))) {
  46.315 -            gSaveCSVis = SBIsControlStripVisible();
  46.316 -            if (gSaveCSVis)
  46.317 -                SBShowHideControlStrip(false);
  46.318 -        }
  46.319 -        DiffRgn(grayRgn, tempRgn, drawRgn);
  46.320 -
  46.321 -        /* Save the gray region once the control strip is hidden */
  46.322 -        CopyRgn(grayRgn, gSaveGrayRgn);
  46.323 -
  46.324 -        /* Change the menu height in lowmem */
  46.325 -        gSaveMenuBar = height;
  46.326 -        LMSetMBarHeight(0);
  46.327 -
  46.328 -        /* Walk the monitor rectangles, and combine any pieces that
  46.329 -           aren't in GrayRgn: menubar, round corners, fake floaters. */
  46.330 -        for (gd = GetDeviceList(); gd; gd = GetNextDevice(gd)) {
  46.331 -            if (!TestDeviceAttribute(gd, screenDevice))
  46.332 -                continue;
  46.333 -            if (!TestDeviceAttribute(gd, screenActive))
  46.334 -                continue;
  46.335 -
  46.336 -            RectRgn(tempRgn, &(*gd)->gdRect);   /* Get the whole screen */
  46.337 -            DiffRgn(tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */
  46.338 -            UnionRgn(tempRgn, drawRgn, drawRgn);        /* Combine all the bits */
  46.339 -        }
  46.340 -
  46.341 -        /* Add the bits into the GrayRgn */
  46.342 -        UnionRgn(drawRgn, grayRgn, grayRgn);
  46.343 -
  46.344 -        /* Modify the vis regions of exposed windows */
  46.345 -        window = (FrontWindow())? FrontWindow() : (WindowPtr) - 1L;
  46.346 -        PaintBehind(window, drawRgn);
  46.347 -        CalcVisBehind(window, drawRgn);
  46.348 -
  46.349 -        SetPort(savePort);
  46.350 -
  46.351 -        /* Yield time so that floaters can catch up */
  46.352 -        EventAvail(0, &theEvent);
  46.353 -        EventAvail(0, &theEvent);
  46.354 -        EventAvail(0, &theEvent);
  46.355 -        EventAvail(0, &theEvent);
  46.356 -    }
  46.357 -
  46.358 -  CLEANUP:
  46.359 -
  46.360 -    if (tempRgn)
  46.361 -        DisposeRgn(tempRgn);
  46.362 -    if (drawRgn)
  46.363 -        DisposeRgn(drawRgn);
  46.364 -#endif /* !TARGET_API_MAC_CARBON */
  46.365 -}
  46.366 -
  46.367 -static void
  46.368 -ROM_ShowMenuBar(_THIS)
  46.369 -{
  46.370 -#if !TARGET_API_MAC_CARBON      /* This seems not to be available? -sts Aug 2000 */
  46.371 -    RgnHandle drawRgn = nil;
  46.372 -    RgnHandle menuRgn = nil;
  46.373 -    RgnHandle tempRgn = nil;
  46.374 -    RgnHandle grayRgn = nil;
  46.375 -    WindowPtr window = nil;
  46.376 -    GrafPtr wMgrPort;
  46.377 -    GrafPtr savePort;
  46.378 -    Rect menuRect;
  46.379 -    long response;
  46.380 -    short height;
  46.381 -    EventRecord theEvent;
  46.382 -    RGBColor saveRGB;
  46.383 -    RGBColor blackRGB = { 0, 0, 0 };
  46.384 -
  46.385 -    height = GetMBarHeight();
  46.386 -
  46.387 -    if ((height <= 0) && (gSaveMenuBar > 0)) {
  46.388 -        drawRgn = NewRgn();
  46.389 -        menuRgn = NewRgn();
  46.390 -        tempRgn = NewRgn();
  46.391 -        if (!tempRgn || !drawRgn || !gSaveGrayRgn) {
  46.392 -            goto CLEANUP;
  46.393 -        }
  46.394 -        grayRgn = GetGrayRgn(); /* No need to check for this */
  46.395 -
  46.396 -        GetPort(&savePort);
  46.397 -        GetWMgrPort(&wMgrPort);
  46.398 -
  46.399 -        /* Set the height properly */
  46.400 -        LMSetMBarHeight(gSaveMenuBar);
  46.401 -
  46.402 -        /* Restore the old GrayRgn: rounded corners, etc, but not
  46.403 -           the menubar -- subtract that out first! */
  46.404 -        if (gSaveGrayRgn) {
  46.405 -            menuRect = (*GetMainDevice())->gdRect;
  46.406 -            menuRect.bottom = menuRect.top + gSaveMenuBar;
  46.407 -            RectRgn(menuRgn, &menuRect);
  46.408 -
  46.409 -            DiffRgn(grayRgn, gSaveGrayRgn, drawRgn);    /* What do we inval? */
  46.410 -            DiffRgn(drawRgn, menuRgn, drawRgn); /* Clip out the menu */
  46.411 -
  46.412 -            /* Now redraw the corners and other bits black */
  46.413 -            SetPort(wMgrPort);
  46.414 -            GetClip(tempRgn);
  46.415 -            SetClip(drawRgn);
  46.416 -            GetForeColor(&saveRGB);
  46.417 -            RGBForeColor(&blackRGB);
  46.418 -            PaintRgn(drawRgn);
  46.419 -            RGBForeColor(&saveRGB);
  46.420 -            SetClip(tempRgn);
  46.421 -            SetPort(savePort);
  46.422 -
  46.423 -            UnionRgn(drawRgn, menuRgn, drawRgn);        /* Put back the menu */
  46.424 -
  46.425 -            /* Now actually restore the GrayRgn */
  46.426 -            CopyRgn(gSaveGrayRgn, grayRgn);
  46.427 -            DisposeRgn(gSaveGrayRgn);
  46.428 -            gSaveGrayRgn = nil;
  46.429 -        }
  46.430 -
  46.431 -        /* Modify the vis regions of exposed windows and draw menubar */
  46.432 -        window = (FrontWindow())? FrontWindow() : (WindowPtr) - 1L;
  46.433 -        PaintBehind(window, drawRgn);
  46.434 -        CalcVisBehind(window, drawRgn);
  46.435 -        DrawMenuBar();
  46.436 -
  46.437 -        SetPort(savePort);
  46.438 -        gSaveMenuBar = 0;
  46.439 -
  46.440 -        /* Now show the control strip if it's present */
  46.441 -        if (!Gestalt(gestaltControlStripAttr, &response) &&
  46.442 -            (response & (1L << gestaltControlStripExists))) {
  46.443 -            if (gSaveCSVis && !SBIsControlStripVisible())
  46.444 -                SBShowHideControlStrip(true);
  46.445 -            gSaveCSVis = true;
  46.446 -        }
  46.447 -
  46.448 -        /* Yield time so that floaters can catch up */
  46.449 -        EventAvail(0, &theEvent);
  46.450 -        EventAvail(0, &theEvent);
  46.451 -        EventAvail(0, &theEvent);
  46.452 -        EventAvail(0, &theEvent);
  46.453 -    }
  46.454 -
  46.455 -  CLEANUP:
  46.456 -
  46.457 -    if (drawRgn)
  46.458 -        DisposeRgn(drawRgn);
  46.459 -    if (menuRgn)
  46.460 -        DisposeRgn(menuRgn);
  46.461 -    if (tempRgn)
  46.462 -        DisposeRgn(tempRgn);
  46.463 -#endif /* !TARGET_API_MAC_CARBON */
  46.464 -}
  46.465 -
  46.466 -/* Various screen update functions available */
  46.467 -static void ROM_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
  46.468 -static void ROM_WindowUpdate(_THIS, int numrects, SDL_Rect * rects);
  46.469 -
  46.470 -static void
  46.471 -ROM_UnsetVideoMode(_THIS, SDL_Surface * current)
  46.472 -{
  46.473 -    /* Free the current window, if any */
  46.474 -    if (SDL_Window != nil) {
  46.475 -        GWorldPtr memworld;
  46.476 -
  46.477 -        /* Handle OpenGL support */
  46.478 -        Mac_GL_Quit(this);
  46.479 -
  46.480 -        memworld = (GWorldPtr) GetWRefCon(SDL_Window);
  46.481 -        if (memworld != nil) {
  46.482 -            UnlockPixels(GetGWorldPixMap(memworld));
  46.483 -            DisposeGWorld(memworld);
  46.484 -        }
  46.485 -        if ((current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) {
  46.486 -#if USE_QUICKTIME
  46.487 -            EndFullScreen(fullscreen_ctx, nil);
  46.488 -            SDL_Window = nil;
  46.489 -#else
  46.490 -            ROM_ShowMenuBar(this);
  46.491 -#endif
  46.492 -        }
  46.493 -    }
  46.494 -    current->pixels = NULL;
  46.495 -    current->flags &= ~(SDL_HWSURFACE | SDL_FULLSCREEN);
  46.496 -}
  46.497 -
  46.498 -static SDL_Surface *
  46.499 -ROM_SetVideoMode(_THIS, SDL_Surface * current,
  46.500 -                 int width, int height, int bpp, Uint32 flags)
  46.501 -{
  46.502 -    Rect wrect, orect;
  46.503 -#if TARGET_API_MAC_CARBON
  46.504 -    Rect tmprect;
  46.505 -#endif
  46.506 -
  46.507 -    /* Free any previous video mode */
  46.508 -    ROM_UnsetVideoMode(this, current);
  46.509 -
  46.510 -    /* Create the ROM window and SDL video surface */
  46.511 -    current->flags = 0;         /* Clear flags */
  46.512 -    current->w = width;
  46.513 -    current->h = height;
  46.514 -    SetRect(&wrect, 0, 0, width, height);
  46.515 -    if (SDL_Window) {
  46.516 -        /* If we recreate the window, don't move it around */
  46.517 -#if TARGET_API_MAC_CARBON
  46.518 -        orect = *GetWindowPortBounds(SDL_Window, &tmprect);
  46.519 -#else
  46.520 -        orect = SDL_Window->portRect;
  46.521 -#endif
  46.522 -        OffsetRect(&wrect, orect.left, orect.top);
  46.523 -    } else {
  46.524 -        /* Center the window the first time we show it */
  46.525 -        OffsetRect(&wrect,
  46.526 -                   (SDL_modelist[0]->w - width) / 2,
  46.527 -                   (SDL_modelist[0]->h - height) / 2);
  46.528 -    }
  46.529 -
  46.530 -#if defined(__MACOSX__) && !USE_QUICKTIME
  46.531 -    /* Hum.. fullscreen mode is broken */
  46.532 -    flags &= ~SDL_FULLSCREEN;
  46.533 -#endif
  46.534 -    if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) {
  46.535 -        /* Create the fullscreen window and use screen bits */
  46.536 -        current->flags |= SDL_HWSURFACE | SDL_FULLSCREEN;
  46.537 -        if (SDL_Window) {
  46.538 -            DisposeWindow(SDL_Window);
  46.539 -        }
  46.540 -#if USE_QUICKTIME
  46.541 -        BeginFullScreen(&fullscreen_ctx, nil, 0, 0, &SDL_Window, nil, 0);
  46.542 -#else
  46.543 -        SDL_Window = NewCWindow(nil, &wrect, "\p", true, plainDBox,
  46.544 -                                (WindowPtr) - 1, false, 0);
  46.545 -        ROM_HideMenuBar(this);
  46.546 -#endif
  46.547 -        current->pitch = (**(**SDL_Display).gdPMap).rowBytes & 0x3FFF;
  46.548 -        current->pixels = (**(**SDL_Display).gdPMap).baseAddr;
  46.549 -        this->UpdateRects = ROM_DirectUpdate;
  46.550 -    } else {
  46.551 -        GWorldPtr memworld;
  46.552 -        PixMapHandle pixmap;
  46.553 -        int style;
  46.554 -
  46.555 -        style = noGrowDocProc;
  46.556 -        if (flags & SDL_NOFRAME) {
  46.557 -            style = plainDBox;
  46.558 -            current->flags |= SDL_NOFRAME;
  46.559 -        } else if (flags & SDL_RESIZABLE) {
  46.560 -            style = zoomDocProc;
  46.561 -            current->flags |= SDL_RESIZABLE;
  46.562 -        }
  46.563 -        if (SDL_Window && (style == current_style)) {
  46.564 -            /* Resize existing window, if necessary */
  46.565 -            if (((orect.right - orect.left) != width) ||
  46.566 -                ((orect.bottom - orect.top) != height)) {
  46.567 -                SizeWindow(SDL_Window, width, height, false);
  46.568 -            }
  46.569 -        } else {
  46.570 -            /* Recreate the window in the new style */
  46.571 -            if (SDL_Window) {
  46.572 -                DisposeWindow(SDL_Window);
  46.573 -            }
  46.574 -            SDL_Window = NewCWindow(nil, &wrect, "\p", true,
  46.575 -                                    style, (WindowPtr) - 1, true, 0);
  46.576 -
  46.577 -            /* Set the window title, if any */
  46.578 -            {
  46.579 -                char *title;
  46.580 -                SDL_WM_GetCaption(&title, NULL);
  46.581 -                if (title) {
  46.582 -                    Mac_SetCaption(this, title, NULL);
  46.583 -                }
  46.584 -            }
  46.585 -        }
  46.586 -        current_style = style;
  46.587 -        SetPalette(SDL_Window, SDL_CPal, false);
  46.588 -        ActivatePalette(SDL_Window);
  46.589 -        if (NewGWorld(&memworld, 0,
  46.590 -#if TARGET_API_MAC_CARBON
  46.591 -                      GetWindowPortBounds(SDL_Window, &tmprect),
  46.592 -#else
  46.593 -                      &SDL_Window->portRect,
  46.594 -#endif
  46.595 -                      SDL_CTab, nil, 0) != noErr) {
  46.596 -            SDL_SetError("NewGWorld() failed");
  46.597 -            return (NULL);
  46.598 -        }
  46.599 -        SetWRefCon(SDL_Window, (long) memworld);
  46.600 -        pixmap = GetGWorldPixMap(memworld);
  46.601 -        LockPixels(pixmap);
  46.602 -        current->pitch = (**pixmap).rowBytes & 0x3FFF;
  46.603 -        current->pixels = GetPixBaseAddr(pixmap);
  46.604 -        this->UpdateRects = ROM_WindowUpdate;
  46.605 -    }
  46.606 -    SetPortWindowPort(SDL_Window);
  46.607 -    SelectWindow(SDL_Window);
  46.608 -
  46.609 -    /* Handle OpenGL support */
  46.610 -    if (flags & SDL_INTERNALOPENGL) {
  46.611 -        if (Mac_GL_Init(this) == 0) {
  46.612 -            current->flags |= SDL_INTERNALOPENGL;
  46.613 -        } else {
  46.614 -            current = NULL;
  46.615 -        }
  46.616 -    }
  46.617 -
  46.618 -    if ((flags & SDL_HWPALETTE) && (flags & SDL_FULLSCREEN))
  46.619 -        current->flags |= SDL_HWPALETTE;
  46.620 -
  46.621 -    /* We're live! */
  46.622 -    return (current);
  46.623 -}
  46.624 -
  46.625 -/* We don't actually allow hardware surfaces other than the main one */
  46.626 -static int
  46.627 -ROM_AllocHWSurface(_THIS, SDL_Surface * surface)
  46.628 -{
  46.629 -    return (-1);
  46.630 -}
  46.631 -static void
  46.632 -ROM_FreeHWSurface(_THIS, SDL_Surface * surface)
  46.633 -{
  46.634 -    return;
  46.635 -}
  46.636 -static int
  46.637 -ROM_LockHWSurface(_THIS, SDL_Surface * surface)
  46.638 -{
  46.639 -    return (0);
  46.640 -}
  46.641 -static void
  46.642 -ROM_UnlockHWSurface(_THIS, SDL_Surface * surface)
  46.643 -{
  46.644 -    return;
  46.645 -}
  46.646 -
  46.647 -static void
  46.648 -ROM_DirectUpdate(_THIS, int numrects, SDL_Rect * rects)
  46.649 -{
  46.650 -    /* The application is already updating the visible video memory */
  46.651 -    return;
  46.652 -}
  46.653 -
  46.654 -static void
  46.655 -ROM_WindowUpdate(_THIS, int numrects, SDL_Rect * rects)
  46.656 -{
  46.657 -    GWorldPtr memworld;
  46.658 -    GrafPtr saveport;
  46.659 -    CGrafPtr thePort;
  46.660 -    const BitMap *memBits;
  46.661 -    const BitMap *winBits;
  46.662 -    int i;
  46.663 -    Rect update;
  46.664 -
  46.665 -    /* Copy from the offscreen GWorld to the window port */
  46.666 -    GetPort(&saveport);
  46.667 -    SetPortWindowPort(SDL_Window);
  46.668 -    thePort = GetWindowPort(SDL_Window);
  46.669 -    memworld = (GWorldPtr) GetWRefCon(SDL_Window);
  46.670 -#if TARGET_API_MAC_CARBON && ACCESSOR_CALLS_ARE_FUNCTIONS
  46.671 -    memBits = GetPortBitMapForCopyBits((CGrafPtr) memworld);
  46.672 -#else
  46.673 -    memBits = &((GrafPtr) memworld)->portBits;
  46.674 -#endif
  46.675 -#if TARGET_API_MAC_CARBON && ACCESSOR_CALLS_ARE_FUNCTIONS
  46.676 -    winBits = GetPortBitMapForCopyBits(thePort);
  46.677 -#else
  46.678 -    winBits = &SDL_Window->portBits;
  46.679 -#endif
  46.680 -    for (i = 0; i < numrects; ++i) {
  46.681 -        update.left = rects[i].x;
  46.682 -        update.right = rects[i].x + rects[i].w;
  46.683 -        update.top = rects[i].y;
  46.684 -        update.bottom = rects[i].y + rects[i].h;
  46.685 -        CopyBits(memBits, winBits, &update, &update, srcCopy, nil);
  46.686 -    }
  46.687 -#if TARGET_API_MAC_CARBON
  46.688 -    if (QDIsPortBuffered(thePort)) {
  46.689 -        QDFlushPortBuffer(thePort, NULL);
  46.690 -    }
  46.691 -#endif
  46.692 -    SetPort(saveport);
  46.693 -}
  46.694 -
  46.695 -static int
  46.696 -ROM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  46.697 -{
  46.698 -    CTabHandle cTab;
  46.699 -    int i;
  46.700 -
  46.701 -    /* Get the colortable from the either the display or window */
  46.702 -    if ((this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) {
  46.703 -        cTab = (**(**SDL_Display).gdPMap).pmTable;
  46.704 -    } else {
  46.705 -        cTab = SDL_CTab;
  46.706 -    }
  46.707 -
  46.708 -    /* Verify the range of colors */
  46.709 -    if ((firstcolor + ncolors) > ((**cTab).ctSize + 1)) {
  46.710 -        return (0);
  46.711 -    }
  46.712 -
  46.713 -    /* Set the screen palette and update the display */
  46.714 -    for (i = 0; i < ncolors; ++i) {
  46.715 -        int j = firstcolor + i;
  46.716 -        (**cTab).ctTable[j].value = j;
  46.717 -        (**cTab).ctTable[j].rgb.red = colors[i].r << 8 | colors[i].r;
  46.718 -        (**cTab).ctTable[j].rgb.green = colors[i].g << 8 | colors[i].g;
  46.719 -        (**cTab).ctTable[j].rgb.blue = colors[i].b << 8 | colors[i].b;
  46.720 -    }
  46.721 -//      if ( (this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) 
  46.722 -    {
  46.723 -        GDevice **odisplay;
  46.724 -        odisplay = GetGDevice();
  46.725 -        SetGDevice(SDL_Display);
  46.726 -        SetEntries(0, (**cTab).ctSize, (ColorSpec *) & (**cTab).ctTable);
  46.727 -        SetGDevice(odisplay);
  46.728 -    }
  46.729 -    return (1);
  46.730 -}
  46.731 -
  46.732 -void
  46.733 -ROM_VideoQuit(_THIS)
  46.734 -{
  46.735 -    int i;
  46.736 -
  46.737 -    /* Free current video mode */
  46.738 -    ROM_UnsetVideoMode(this, this->screen);
  46.739 -    if (SDL_Window) {
  46.740 -        DisposeWindow(SDL_Window);
  46.741 -        SDL_Window = nil;
  46.742 -    }
  46.743 -
  46.744 -    /* Free palette and restore original one */
  46.745 -    if (SDL_CTab != nil) {
  46.746 -        DisposeHandle((Handle) SDL_CTab);
  46.747 -        SDL_CTab = nil;
  46.748 -    }
  46.749 -    if (SDL_CPal != nil) {
  46.750 -        DisposePalette(SDL_CPal);
  46.751 -        SDL_CPal = nil;
  46.752 -    }
  46.753 -    RestoreDeviceClut(GetMainDevice());
  46.754 -
  46.755 -    /* Free list of video modes */
  46.756 -    if (SDL_modelist != NULL) {
  46.757 -        for (i = 0; SDL_modelist[i]; ++i) {
  46.758 -            SDL_free(SDL_modelist[i]);
  46.759 -        }
  46.760 -        SDL_free(SDL_modelist);
  46.761 -        SDL_modelist = NULL;
  46.762 -    }
  46.763 -}
  46.764 -
  46.765 -/* vi: set ts=4 sw=4 expandtab: */
    47.1 --- a/src/video/macrom/SDL_romvideo.h	Thu Aug 10 14:35:42 2006 +0000
    47.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.3 @@ -1,30 +0,0 @@
    47.4 -/*
    47.5 -    SDL - Simple DirectMedia Layer
    47.6 -    Copyright (C) 1997-2006 Sam Lantinga
    47.7 -
    47.8 -    This library is free software; you can redistribute it and/or
    47.9 -    modify it under the terms of the GNU Lesser General Public
   47.10 -    License as published by the Free Software Foundation; either
   47.11 -    version 2.1 of the License, or (at your option) any later version.
   47.12 -
   47.13 -    This library is distributed in the hope that it will be useful,
   47.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   47.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   47.16 -    Lesser General Public License for more details.
   47.17 -
   47.18 -    You should have received a copy of the GNU Lesser General Public
   47.19 -    License along with this library; if not, write to the Free Software
   47.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   47.21 -
   47.22 -    Sam Lantinga
   47.23 -    slouken@libsdl.org
   47.24 -*/
   47.25 -#include "SDL_config.h"
   47.26 -
   47.27 -#ifndef _SDL_romvideo_h
   47.28 -#define _SDL_romvideo_h
   47.29 -
   47.30 -#include "../maccommon/SDL_lowvideo.h"
   47.31 -
   47.32 -#endif /* _SDL_romvideo_h */
   47.33 -/* vi: set ts=4 sw=4 expandtab: */