src/video/macdsp/SDL_dspvideo.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/video/macdsp/SDL_dspvideo.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/macdsp/SDL_dspvideo.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -150,40 +150,40 @@
     1.4  #include "../maccommon/SDL_macevents_c.h"
     1.5  
     1.6  /* Initialization/Query functions */
     1.7 -static int DSp_VideoInit (_THIS, SDL_PixelFormat * vformat);
     1.8 -static SDL_Rect **DSp_ListModes (_THIS, SDL_PixelFormat * format,
     1.9 -                                 Uint32 flags);
    1.10 -static SDL_Surface *DSp_SetVideoMode (_THIS, SDL_Surface * current, int width,
    1.11 -                                      int height, int bpp, Uint32 flags);
    1.12 -static int DSp_SetColors (_THIS, int firstcolor, int ncolors,
    1.13 -                          SDL_Color * colors);
    1.14 -static int DSp_CreatePalette (_THIS);
    1.15 -static int DSp_DestroyPalette (_THIS);
    1.16 -static void DSp_VideoQuit (_THIS);
    1.17 +static int DSp_VideoInit(_THIS, SDL_PixelFormat * vformat);
    1.18 +static SDL_Rect **DSp_ListModes(_THIS, SDL_PixelFormat * format,
    1.19 +                                Uint32 flags);
    1.20 +static SDL_Surface *DSp_SetVideoMode(_THIS, SDL_Surface * current, int width,
    1.21 +                                     int height, int bpp, Uint32 flags);
    1.22 +static int DSp_SetColors(_THIS, int firstcolor, int ncolors,
    1.23 +                         SDL_Color * colors);
    1.24 +static int DSp_CreatePalette(_THIS);
    1.25 +static int DSp_DestroyPalette(_THIS);
    1.26 +static void DSp_VideoQuit(_THIS);
    1.27  
    1.28 -static int DSp_GetMainDevice (_THIS, GDHandle * device);
    1.29 -static void DSp_IsHWAvailable (_THIS, SDL_PixelFormat * vformat);
    1.30 -static void DSp_DSpUpdate (_THIS, int numrects, SDL_Rect * sdl_rects);
    1.31 -static void DSp_DirectUpdate (_THIS, int numrects, SDL_Rect * sdl_rects);
    1.32 +static int DSp_GetMainDevice(_THIS, GDHandle * device);
    1.33 +static void DSp_IsHWAvailable(_THIS, SDL_PixelFormat * vformat);
    1.34 +static void DSp_DSpUpdate(_THIS, int numrects, SDL_Rect * sdl_rects);
    1.35 +static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * sdl_rects);
    1.36  
    1.37  /* Hardware surface functions */
    1.38 -static int DSp_SetHWAlpha (_THIS, SDL_Surface * surface, UInt8 alpha);
    1.39 -static int DSp_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key);
    1.40 -static int DSp_NewHWSurface (_THIS, CGrafPtr * port, int depth, int width,
    1.41 -                             int height);
    1.42 -static int DSp_AllocHWSurface (_THIS, SDL_Surface * surface);
    1.43 -static int DSp_LockHWSurface (_THIS, SDL_Surface * surface);
    1.44 -static void DSp_UnlockHWSurface (_THIS, SDL_Surface * surface);
    1.45 -static void DSp_FreeHWSurface (_THIS, SDL_Surface * surface);
    1.46 -static int DSp_FlipHWSurface (_THIS, SDL_Surface * surface);
    1.47 -static int DSp_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dest);
    1.48 -static int DSp_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect,
    1.49 -                            SDL_Surface * dst, SDL_Rect * dstrect);
    1.50 -static int DSp_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect,
    1.51 -                           Uint32 color);
    1.52 +static int DSp_SetHWAlpha(_THIS, SDL_Surface * surface, UInt8 alpha);
    1.53 +static int DSp_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key);
    1.54 +static int DSp_NewHWSurface(_THIS, CGrafPtr * port, int depth, int width,
    1.55 +                            int height);
    1.56 +static int DSp_AllocHWSurface(_THIS, SDL_Surface * surface);
    1.57 +static int DSp_LockHWSurface(_THIS, SDL_Surface * surface);
    1.58 +static void DSp_UnlockHWSurface(_THIS, SDL_Surface * surface);
    1.59 +static void DSp_FreeHWSurface(_THIS, SDL_Surface * surface);
    1.60 +static int DSp_FlipHWSurface(_THIS, SDL_Surface * surface);
    1.61 +static int DSp_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dest);
    1.62 +static int DSp_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
    1.63 +                           SDL_Surface * dst, SDL_Rect * dstrect);
    1.64 +static int DSp_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect,
    1.65 +                          Uint32 color);
    1.66  
    1.67  #if SDL_VIDEO_OPENGL
    1.68 -static void DSp_GL_SwapBuffers (_THIS);
    1.69 +static void DSp_GL_SwapBuffers(_THIS);
    1.70  #endif
    1.71  
    1.72  #if ! TARGET_API_MAC_CARBON
    1.73 @@ -222,7 +222,7 @@
    1.74  /* Macintosh toolbox driver bootstrap functions */
    1.75  
    1.76  static int
    1.77 -DSp_Available (void)
    1.78 +DSp_Available(void)
    1.79  {
    1.80      /* Check for DrawSprocket */
    1.81  #if ! TARGET_API_MAC_OSX
    1.82 @@ -234,7 +234,7 @@
    1.83  }
    1.84  
    1.85  static void
    1.86 -DSp_DeleteDevice (SDL_VideoDevice * device)
    1.87 +DSp_DeleteDevice(SDL_VideoDevice * device)
    1.88  {
    1.89      /* -dw- taking no chances with null pointers */
    1.90      if (device) {
    1.91 @@ -242,54 +242,53 @@
    1.92          if (device->hidden) {
    1.93  
    1.94              if (device->hidden->dspinfo)
    1.95 -                SDL_free (device->hidden->dspinfo);
    1.96 +                SDL_free(device->hidden->dspinfo);
    1.97  
    1.98 -            SDL_free (device->hidden);
    1.99 +            SDL_free(device->hidden);
   1.100          }
   1.101 -        SDL_free (device);
   1.102 +        SDL_free(device);
   1.103      }
   1.104  }
   1.105  
   1.106  static SDL_VideoDevice *
   1.107 -DSp_CreateDevice (int devindex)
   1.108 +DSp_CreateDevice(int devindex)
   1.109  {
   1.110      SDL_VideoDevice *device;
   1.111  
   1.112      /* Initialize all variables that we clean on shutdown */
   1.113 -    device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice));
   1.114 +    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
   1.115      if (device) {
   1.116 -        SDL_memset (device, 0, sizeof (*device));
   1.117 +        SDL_memset(device, 0, sizeof(*device));
   1.118          device->hidden = (struct SDL_PrivateVideoData *)
   1.119 -            SDL_malloc ((sizeof *device->hidden));
   1.120 +            SDL_malloc((sizeof *device->hidden));
   1.121          if (device->hidden)
   1.122 -            SDL_memset (device->hidden, 0, sizeof (*(device->hidden)));
   1.123 +            SDL_memset(device->hidden, 0, sizeof(*(device->hidden)));
   1.124      }
   1.125      if ((device == NULL) || (device->hidden == NULL)) {
   1.126 -        SDL_OutOfMemory ();
   1.127 +        SDL_OutOfMemory();
   1.128  
   1.129          if (device) {
   1.130  
   1.131              if (device->hidden)
   1.132 -                SDL_free (device->hidden);
   1.133 +                SDL_free(device->hidden);
   1.134  
   1.135 -            SDL_free (device);
   1.136 +            SDL_free(device);
   1.137          }
   1.138  
   1.139          return (NULL);
   1.140      }
   1.141  
   1.142      /* Allocate DrawSprocket information */
   1.143 -    device->hidden->dspinfo = (struct DSpInfo *) SDL_malloc ((sizeof *device->
   1.144 -                                                              hidden->
   1.145 -                                                              dspinfo));
   1.146 +    device->hidden->dspinfo = (struct DSpInfo *) SDL_malloc((sizeof *device->
   1.147 +                                                             hidden->
   1.148 +                                                             dspinfo));
   1.149      if (device->hidden->dspinfo == NULL) {
   1.150 -        SDL_OutOfMemory ();
   1.151 -        SDL_free (device->hidden);
   1.152 -        SDL_free (device);
   1.153 +        SDL_OutOfMemory();
   1.154 +        SDL_free(device->hidden);
   1.155 +        SDL_free(device);
   1.156          return (0);
   1.157      }
   1.158 -    SDL_memset (device->hidden->dspinfo, 0,
   1.159 -                (sizeof *device->hidden->dspinfo));
   1.160 +    SDL_memset(device->hidden->dspinfo, 0, (sizeof *device->hidden->dspinfo));
   1.161  
   1.162      /* Set the function pointers */
   1.163      device->VideoInit = DSp_VideoInit;
   1.164 @@ -340,8 +339,8 @@
   1.165  
   1.166  /* Use DSp/Display Manager to build mode list for given screen */
   1.167  static SDL_Rect **
   1.168 -DSp_BuildModeList (const GDHandle gDevice, int *displayWidth,
   1.169 -                   int *displayHeight)
   1.170 +DSp_BuildModeList(const GDHandle gDevice, int *displayWidth,
   1.171 +                  int *displayHeight)
   1.172  {
   1.173      DSpContextAttributes attributes;
   1.174      DSpContextReference context;
   1.175 @@ -356,22 +355,22 @@
   1.176  
   1.177  #else
   1.178      /* Ask Display Manager for integer id of screen device */
   1.179 -    if (DMGetDisplayIDByGDevice (gDevice, &displayID, SDL_TRUE) != noErr) {
   1.180 +    if (DMGetDisplayIDByGDevice(gDevice, &displayID, SDL_TRUE) != noErr) {
   1.181          return NULL;
   1.182      }
   1.183  #endif
   1.184      /* Get the first possible DSp context on this device */
   1.185 -    if (DSpGetFirstContext (displayID, &context) != noErr) {
   1.186 +    if (DSpGetFirstContext(displayID, &context) != noErr) {
   1.187          return NULL;
   1.188      }
   1.189  
   1.190 -    if (DSpContext_GetAttributes (context, &attributes) != noErr)
   1.191 +    if (DSpContext_GetAttributes(context, &attributes) != noErr)
   1.192          return NULL;
   1.193  
   1.194      *displayWidth = attributes.displayWidth;
   1.195      *displayHeight = attributes.displayHeight;
   1.196  
   1.197 -    for (i = 0; i < SDL_arraysize (temp_list); i++) {
   1.198 +    for (i = 0; i < SDL_arraysize(temp_list); i++) {
   1.199          width = attributes.displayWidth;
   1.200          height = attributes.displayHeight;
   1.201  
   1.202 @@ -387,14 +386,14 @@
   1.203          while (width == attributes.displayWidth
   1.204                 && height == attributes.displayHeight) {
   1.205  
   1.206 -            OSStatus err = DSpGetNextContext (context, &context);
   1.207 +            OSStatus err = DSpGetNextContext(context, &context);
   1.208              if (err != noErr)
   1.209                  if (err == kDSpContextNotFoundErr)
   1.210                      goto done;
   1.211                  else
   1.212                      return NULL;
   1.213  
   1.214 -            if (DSpContext_GetAttributes (context, &attributes) != noErr)
   1.215 +            if (DSpContext_GetAttributes(context, &attributes) != noErr)
   1.216                  return NULL;
   1.217  
   1.218              temp_list[i].x |= attributes.displayBestDepth;
   1.219 @@ -403,22 +402,22 @@
   1.220    done:
   1.221      i++;                        /* i was not incremented before kicking out of the loop */
   1.222  
   1.223 -    mode_list = (SDL_Rect **) SDL_malloc (sizeof (SDL_Rect *) * (i + 1));
   1.224 +    mode_list = (SDL_Rect **) SDL_malloc(sizeof(SDL_Rect *) * (i + 1));
   1.225      if (mode_list) {
   1.226  
   1.227          /* -dw- new stuff: build in reverse order so largest sizes list first */
   1.228          for (j = i - 1; j >= 0; j--) {
   1.229 -            mode_list[j] = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect));
   1.230 +            mode_list[j] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
   1.231              if (mode_list[j])
   1.232 -                SDL_memcpy (mode_list[j], &(temp_list[j]), sizeof (SDL_Rect));
   1.233 +                SDL_memcpy(mode_list[j], &(temp_list[j]), sizeof(SDL_Rect));
   1.234              else {
   1.235 -                SDL_OutOfMemory ();
   1.236 +                SDL_OutOfMemory();
   1.237                  return NULL;
   1.238              }
   1.239          }
   1.240          mode_list[i] = NULL;    /* append null to the end */
   1.241      } else {
   1.242 -        SDL_OutOfMemory ();
   1.243 +        SDL_OutOfMemory();
   1.244          return NULL;
   1.245      }
   1.246  
   1.247 @@ -426,7 +425,7 @@
   1.248  }
   1.249  
   1.250  static void
   1.251 -DSp_IsHWAvailable (_THIS, SDL_PixelFormat * vformat)
   1.252 +DSp_IsHWAvailable(_THIS, SDL_PixelFormat * vformat)
   1.253  {
   1.254      /* 
   1.255         VRAM GWorlds are only available on OS 9 or later.
   1.256 @@ -439,29 +438,29 @@
   1.257      dsp_vram_available = SDL_FALSE;
   1.258      dsp_agp_available = SDL_FALSE;
   1.259  
   1.260 -    Gestalt ('sysv', &versionSystem);
   1.261 +    Gestalt('sysv', &versionSystem);
   1.262      if (0x00000860 < (versionSystem & 0x0000FFFF)) {
   1.263  
   1.264          GWorldPtr offscreen;
   1.265          OSStatus err;
   1.266          Rect bounds;
   1.267  
   1.268 -        SetRect (&bounds, 0, 0, 320, 240);
   1.269 +        SetRect(&bounds, 0, 0, 320, 240);
   1.270  
   1.271  #if useDistantHdwrMem && useLocalHdwrMem
   1.272          err =
   1.273 -            NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL,
   1.274 -                       SDL_Display, useDistantHdwrMem | noNewDevice);
   1.275 +            NewGWorld(&offscreen, vformat->BitsPerPixel, &bounds, NULL,
   1.276 +                      SDL_Display, useDistantHdwrMem | noNewDevice);
   1.277          if (err == noErr) {
   1.278              dsp_vram_available = SDL_TRUE;
   1.279 -            DisposeGWorld (offscreen);
   1.280 +            DisposeGWorld(offscreen);
   1.281          }
   1.282  
   1.283          err =
   1.284 -            NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL,
   1.285 -                       SDL_Display, useLocalHdwrMem | noNewDevice);
   1.286 +            NewGWorld(&offscreen, vformat->BitsPerPixel, &bounds, NULL,
   1.287 +                      SDL_Display, useLocalHdwrMem | noNewDevice);
   1.288          if (err == noErr) {
   1.289 -            DisposeGWorld (offscreen);
   1.290 +            DisposeGWorld(offscreen);
   1.291              dsp_agp_available = SDL_TRUE;
   1.292          }
   1.293  #endif
   1.294 @@ -469,12 +468,12 @@
   1.295  }
   1.296  
   1.297  static int
   1.298 -DSp_GetMainDevice (_THIS, GDHandle * device)
   1.299 +DSp_GetMainDevice(_THIS, GDHandle * device)
   1.300  {
   1.301  
   1.302  #if TARGET_API_MAC_OSX
   1.303      /* DSpUserSelectContext not available on OS X */
   1.304 -    *device = GetMainDevice ();
   1.305 +    *device = GetMainDevice();
   1.306      return 0;
   1.307  #else
   1.308  
   1.309 @@ -484,8 +483,8 @@
   1.310      GDHandle main_device;
   1.311      GDHandle device_list;
   1.312  
   1.313 -    device_list = GetDeviceList ();
   1.314 -    main_device = GetMainDevice ();
   1.315 +    device_list = GetDeviceList();
   1.316 +    main_device = GetMainDevice();
   1.317  
   1.318      /* Quick check to avoid slower method when only one display exists */
   1.319      if ((**device_list).gdNextGD == NULL) {
   1.320 @@ -493,7 +492,7 @@
   1.321          return 0;
   1.322      }
   1.323  
   1.324 -    SDL_memset (&attrib, 0, sizeof (DSpContextAttributes));
   1.325 +    SDL_memset(&attrib, 0, sizeof(DSpContextAttributes));
   1.326  
   1.327      /* These attributes are hopefully supported on all devices... */
   1.328      attrib.displayWidth = 640;
   1.329 @@ -505,26 +504,24 @@
   1.330      attrib.colorNeeds = kDSpColorNeeds_Require;
   1.331      attrib.pageCount = 1;
   1.332  
   1.333 -    if (noErr !=
   1.334 -        DMGetDisplayIDByGDevice (main_device, &display_id, SDL_FALSE)) {
   1.335 +    if (noErr != DMGetDisplayIDByGDevice(main_device, &display_id, SDL_FALSE)) {
   1.336          SDL_SetError
   1.337              ("Display Manager couldn't associate GDevice with a Display ID");
   1.338          return (-1);
   1.339      }
   1.340  
   1.341      /* Put up dialog on main display to select which display to use */
   1.342 -    if (noErr != DSpUserSelectContext (&attrib, display_id, NULL, &context)) {
   1.343 -        SDL_SetError ("DrawSprocket couldn't create a context");
   1.344 +    if (noErr != DSpUserSelectContext(&attrib, display_id, NULL, &context)) {
   1.345 +        SDL_SetError("DrawSprocket couldn't create a context");
   1.346          return (-1);
   1.347      }
   1.348  
   1.349 -    if (noErr != DSpContext_GetDisplayID (context, &display_id)) {
   1.350 -        SDL_SetError ("DrawSprocket couldn't get display ID");
   1.351 +    if (noErr != DSpContext_GetDisplayID(context, &display_id)) {
   1.352 +        SDL_SetError("DrawSprocket couldn't get display ID");
   1.353          return (-1);
   1.354      }
   1.355  
   1.356 -    if (noErr !=
   1.357 -        DMGetGDeviceByDisplayID (display_id, &main_device, SDL_FALSE)) {
   1.358 +    if (noErr != DMGetGDeviceByDisplayID(display_id, &main_device, SDL_FALSE)) {
   1.359          SDL_SetError
   1.360              ("Display Manager couldn't associate Display ID with GDevice");
   1.361          return (-1);
   1.362 @@ -536,12 +533,12 @@
   1.363  }
   1.364  
   1.365  static int
   1.366 -DSp_VideoInit (_THIS, SDL_PixelFormat * vformat)
   1.367 +DSp_VideoInit(_THIS, SDL_PixelFormat * vformat)
   1.368  {
   1.369      NumVersion dsp_version = { 0x01, 0x00, 0x00, 0x00 };
   1.370  
   1.371  #if UNIVERSAL_INTERFACES_VERSION > 0x0320
   1.372 -    dsp_version = DSpGetVersion ();
   1.373 +    dsp_version = DSpGetVersion();
   1.374  #endif
   1.375  
   1.376      if ((dsp_version.majorRev == 1 && dsp_version.minorAndBugRev < 0x73) ||
   1.377 @@ -552,25 +549,24 @@
   1.378             "You can find a newer version at http://www.apple.com/swupdates.",
   1.379             NULL, NULL);
   1.380           */
   1.381 -        SDL_SetError
   1.382 -            ("DrawSprocket version is too old. Need 1.7.3 or later.");
   1.383 +        SDL_SetError("DrawSprocket version is too old. Need 1.7.3 or later.");
   1.384          return (-1);
   1.385      }
   1.386  
   1.387 -    if (DSpStartup () != noErr) {
   1.388 -        SDL_SetError ("DrawSprocket couldn't startup");
   1.389 +    if (DSpStartup() != noErr) {
   1.390 +        SDL_SetError("DrawSprocket couldn't startup");
   1.391          return (-1);
   1.392      }
   1.393  
   1.394      /* Start DSpintosh events */
   1.395 -    Mac_InitEvents (this);
   1.396 +    Mac_InitEvents(this);
   1.397  
   1.398      /* Get a handle to the main monitor, or choose one on multiple monitor setups */
   1.399 -    if (DSp_GetMainDevice (this, &SDL_Display) < 0)
   1.400 +    if (DSp_GetMainDevice(this, &SDL_Display) < 0)
   1.401          return (-1);
   1.402  
   1.403      /* Determine pixel format */
   1.404 -    vformat->BitsPerPixel = GetPixDepth ((**SDL_Display).gdPMap);
   1.405 +    vformat->BitsPerPixel = GetPixDepth((**SDL_Display).gdPMap);
   1.406      dsp_old_depth = vformat->BitsPerPixel;
   1.407  
   1.408      switch (vformat->BitsPerPixel) {
   1.409 @@ -583,22 +579,22 @@
   1.410          break;
   1.411      }
   1.412  
   1.413 -    if (DSp_CreatePalette (this) < 0) {
   1.414 -        SDL_SetError ("Could not create palette");
   1.415 +    if (DSp_CreatePalette(this) < 0) {
   1.416 +        SDL_SetError("Could not create palette");
   1.417          return (-1);
   1.418      }
   1.419  
   1.420      /* Get a list of available fullscreen modes */
   1.421 -    SDL_modelist = DSp_BuildModeList (SDL_Display,
   1.422 -                                      &this->info.current_w,
   1.423 -                                      &this->info.current_h);
   1.424 +    SDL_modelist = DSp_BuildModeList(SDL_Display,
   1.425 +                                     &this->info.current_w,
   1.426 +                                     &this->info.current_h);
   1.427      if (SDL_modelist == NULL) {
   1.428 -        SDL_SetError ("DrawSprocket could not build a mode list");
   1.429 +        SDL_SetError("DrawSprocket could not build a mode list");
   1.430          return (-1);
   1.431      }
   1.432  
   1.433      /* Check for VRAM and AGP GWorlds for HW Blitting */
   1.434 -    DSp_IsHWAvailable (this, vformat);
   1.435 +    DSp_IsHWAvailable(this, vformat);
   1.436  
   1.437      this->info.wm_available = 0;
   1.438  
   1.439 @@ -626,7 +622,7 @@
   1.440  }
   1.441  
   1.442  static SDL_Rect **
   1.443 -DSp_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags)
   1.444 +DSp_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
   1.445  {
   1.446      static SDL_Rect *dsp_modes[16];
   1.447      int i = 0, j = 0;
   1.448 @@ -649,14 +645,14 @@
   1.449  }
   1.450  
   1.451  /* Various screen update functions available */
   1.452 -static void DSp_DirectUpdate (_THIS, int numrects, SDL_Rect * rects);
   1.453 +static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
   1.454  
   1.455  #if ! TARGET_API_MAC_OSX
   1.456  
   1.457  static volatile unsigned int retrace_count = 0; /* -dw- need volatile because it updates asychronously */
   1.458  
   1.459  Boolean
   1.460 -DSp_VBLProc (DSpContextReference context, void *ref_con)
   1.461 +DSp_VBLProc(DSpContextReference context, void *ref_con)
   1.462  {
   1.463      retrace_count++;
   1.464  
   1.465 @@ -664,7 +660,7 @@
   1.466  }
   1.467  
   1.468  static void
   1.469 -DSp_SetHWError (OSStatus err, int is_agp)
   1.470 +DSp_SetHWError(OSStatus err, int is_agp)
   1.471  {
   1.472      char message[1024];
   1.473      const char *fmt, *mem;
   1.474 @@ -685,14 +681,14 @@
   1.475          fmt = "Hardware surface could not be allocated in %s - unknown error";
   1.476          break;
   1.477      }
   1.478 -    SDL_snprintf (message, SDL_arraysize (message), fmt, mem);
   1.479 -    SDL_SetError (message);
   1.480 +    SDL_snprintf(message, SDL_arraysize(message), fmt, mem);
   1.481 +    SDL_SetError(message);
   1.482  }
   1.483  #endif // TARGET_API_MAC_OSX
   1.484  
   1.485  /* put up a dialog to verify display change */
   1.486  static int
   1.487 -DSp_ConfirmSwitch ()
   1.488 +DSp_ConfirmSwitch()
   1.489  {
   1.490  
   1.491      /* resource id's for dialog */
   1.492 @@ -706,77 +702,77 @@
   1.493      DialogItemIndex item = 0;
   1.494      GrafPtr savePort;
   1.495  
   1.496 -    GetPort (&savePort);
   1.497 +    GetPort(&savePort);
   1.498  
   1.499 -    dialog = GetNewDialog (rDialog, NULL, (WindowPtr) - 1);
   1.500 +    dialog = GetNewDialog(rDialog, NULL, (WindowPtr) - 1);
   1.501      if (dialog == NULL)
   1.502          return (0);
   1.503  
   1.504  #if TARGET_API_MAC_CARBON
   1.505 -    SetPort (GetDialogPort (dialog));
   1.506 +    SetPort(GetDialogPort(dialog));
   1.507  #else
   1.508 -    SetPort ((WindowPtr) dialog);
   1.509 +    SetPort((WindowPtr) dialog);
   1.510  #endif
   1.511  
   1.512 -    SetDialogDefaultItem (dialog, bCancel);
   1.513 -    SetDialogCancelItem (dialog, bCancel);
   1.514 +    SetDialogDefaultItem(dialog, bCancel);
   1.515 +    SetDialogCancelItem(dialog, bCancel);
   1.516  
   1.517 -    SetEventMask (everyEvent);
   1.518 -    FlushEvents (everyEvent, 0);
   1.519 +    SetEventMask(everyEvent);
   1.520 +    FlushEvents(everyEvent, 0);
   1.521  
   1.522      /* On MacOS 8.5 or later, we can make the dialog go away after 15 seconds */
   1.523      /* This is good since it's possible user can't even see the dialog! */
   1.524      /* Requires linking to DialogsLib */
   1.525 -    err = Gestalt (gestaltSystemVersion, &response);
   1.526 +    err = Gestalt(gestaltSystemVersion, &response);
   1.527      if (err == noErr && response >= 0x00000850) {
   1.528 -        SetDialogTimeout (dialog, bCancel, 15);
   1.529 +        SetDialogTimeout(dialog, bCancel, 15);
   1.530      }
   1.531  
   1.532      do {
   1.533  
   1.534 -        ModalDialog (NULL, &item);
   1.535 +        ModalDialog(NULL, &item);
   1.536  
   1.537      }
   1.538      while (item != bCancel && item != bOK && err != noErr);
   1.539  
   1.540  
   1.541 -    DisposeDialog (dialog);
   1.542 -    SetPort (savePort);
   1.543 +    DisposeDialog(dialog);
   1.544 +    SetPort(savePort);
   1.545  
   1.546 -    SetEventMask (everyEvent - autoKeyMask);
   1.547 -    FlushEvents (everyEvent, 0);
   1.548 +    SetEventMask(everyEvent - autoKeyMask);
   1.549 +    FlushEvents(everyEvent, 0);
   1.550  
   1.551      return (item - 1);
   1.552  }
   1.553  
   1.554  static void
   1.555 -DSp_UnsetVideoMode (_THIS, SDL_Surface * current)
   1.556 +DSp_UnsetVideoMode(_THIS, SDL_Surface * current)
   1.557  {
   1.558  
   1.559  
   1.560      if (current->flags & SDL_INTERNALOPENGL) {
   1.561 -        Mac_GL_Quit (this);
   1.562 +        Mac_GL_Quit(this);
   1.563      }
   1.564  
   1.565      if (dsp_context != NULL) {
   1.566  
   1.567          GWorldPtr front;
   1.568 -        DSpContext_GetFrontBuffer (dsp_context, &front);
   1.569 +        DSpContext_GetFrontBuffer(dsp_context, &front);
   1.570  
   1.571          if (front != dsp_back_buffer)
   1.572 -            DisposeGWorld (dsp_back_buffer);
   1.573 +            DisposeGWorld(dsp_back_buffer);
   1.574  
   1.575          if (current->hwdata)
   1.576 -            SDL_free (current->hwdata);
   1.577 +            SDL_free(current->hwdata);
   1.578  
   1.579 -        DSpContext_SetState (dsp_context, kDSpContextState_Inactive);
   1.580 -        DSpContext_Release (dsp_context);
   1.581 +        DSpContext_SetState(dsp_context, kDSpContextState_Inactive);
   1.582 +        DSpContext_Release(dsp_context);
   1.583  
   1.584          dsp_context = NULL;
   1.585      }
   1.586  
   1.587      if (SDL_Window != NULL) {
   1.588 -        DisposeWindow (SDL_Window);
   1.589 +        DisposeWindow(SDL_Window);
   1.590          SDL_Window = NULL;
   1.591      }
   1.592  
   1.593 @@ -785,9 +781,9 @@
   1.594  }
   1.595  
   1.596  static SDL_Surface *
   1.597 -DSp_SetVideoMode (_THIS,
   1.598 -                  SDL_Surface * current, int width, int height, int bpp,
   1.599 -                  Uint32 flags)
   1.600 +DSp_SetVideoMode(_THIS,
   1.601 +                 SDL_Surface * current, int width, int height, int bpp,
   1.602 +                 Uint32 flags)
   1.603  {
   1.604  
   1.605  #if !TARGET_API_MAC_OSX
   1.606 @@ -803,10 +799,10 @@
   1.607      int hw_surface;
   1.608      int use_dsp_back_buffer;
   1.609  
   1.610 -    DSp_UnsetVideoMode (this, current);
   1.611 +    DSp_UnsetVideoMode(this, current);
   1.612  
   1.613      if (bpp != dsp_old_depth)
   1.614 -        DSp_DestroyPalette (this);
   1.615 +        DSp_DestroyPalette(this);
   1.616  
   1.617      double_buf = (flags & SDL_DOUBLEBUF) != 0;
   1.618      hw_surface = (flags & SDL_HWSURFACE) != 0;
   1.619 @@ -822,7 +818,7 @@
   1.620          page_count = 1;
   1.621      }
   1.622  
   1.623 -    SDL_memset (&attrib, 0, sizeof (DSpContextAttributes));
   1.624 +    SDL_memset(&attrib, 0, sizeof(DSpContextAttributes));
   1.625      attrib.displayWidth = width;
   1.626      attrib.displayHeight = height;
   1.627      attrib.displayBestDepth = bpp;
   1.628 @@ -834,48 +830,47 @@
   1.629      attrib.pageCount = page_count;
   1.630  #if TARGET_API_MAC_OSX || UNIVERSAL_INTERFACES_VERSION == 0x0320
   1.631  
   1.632 -    if (DSpFindBestContext (&attrib, &dsp_context) != noErr) {
   1.633 -        SDL_SetError ("DrawSprocket couldn't find a context");
   1.634 +    if (DSpFindBestContext(&attrib, &dsp_context) != noErr) {
   1.635 +        SDL_SetError("DrawSprocket couldn't find a context");
   1.636          return NULL;
   1.637      }
   1.638  #else
   1.639 -    if (noErr !=
   1.640 -        DMGetDisplayIDByGDevice (SDL_Display, &display_id, SDL_FALSE)) {
   1.641 +    if (noErr != DMGetDisplayIDByGDevice(SDL_Display, &display_id, SDL_FALSE)) {
   1.642          SDL_SetError
   1.643              ("Display Manager couldn't associate GDevice with display_id");
   1.644          return NULL;
   1.645      }
   1.646 -    if (DSpFindBestContextOnDisplayID (&attrib, &dsp_context, display_id) !=
   1.647 +    if (DSpFindBestContextOnDisplayID(&attrib, &dsp_context, display_id) !=
   1.648          noErr) {
   1.649          SDL_SetError
   1.650              ("DrawSprocket couldn't find a suitable context on given display");
   1.651          return NULL;
   1.652      }
   1.653  #endif
   1.654 -    if (DSpContext_Reserve (dsp_context, &attrib) != noErr) {
   1.655 +    if (DSpContext_Reserve(dsp_context, &attrib) != noErr) {
   1.656          SDL_SetError
   1.657              ("DrawSprocket couldn't get the needed resources to build the display");
   1.658          return NULL;
   1.659      }
   1.660  
   1.661      if ((err =
   1.662 -         DSpContext_SetState (dsp_context, kDSpContextState_Active)) != noErr)
   1.663 +         DSpContext_SetState(dsp_context, kDSpContextState_Active)) != noErr)
   1.664      {
   1.665  
   1.666          if (err == kDSpConfirmSwitchWarning) {
   1.667  
   1.668 -            if (!DSp_ConfirmSwitch ()) {
   1.669 +            if (!DSp_ConfirmSwitch()) {
   1.670  
   1.671 -                DSpContext_Release (dsp_context);
   1.672 +                DSpContext_Release(dsp_context);
   1.673                  dsp_context = NULL;
   1.674 -                SDL_SetError ("User cancelled display switch");
   1.675 +                SDL_SetError("User cancelled display switch");
   1.676                  return NULL;
   1.677              } else
   1.678                  /* Have to reactivate context. Why? */
   1.679 -                DSpContext_SetState (dsp_context, kDSpContextState_Active);
   1.680 +                DSpContext_SetState(dsp_context, kDSpContextState_Active);
   1.681  
   1.682          } else {
   1.683 -            SDL_SetError ("DrawSprocket couldn't activate the context");
   1.684 +            SDL_SetError("DrawSprocket couldn't activate the context");
   1.685              return NULL;
   1.686          }
   1.687      }
   1.688 @@ -883,7 +878,7 @@
   1.689  
   1.690      if (bpp != dsp_old_depth) {
   1.691  
   1.692 -        DSp_CreatePalette (this);
   1.693 +        DSp_CreatePalette(this);
   1.694  
   1.695          /* update format if display depth changed */
   1.696          if (bpp == 16) {
   1.697 @@ -892,9 +887,9 @@
   1.698              gmask = 0x000003e0;
   1.699              bmask = 0x0000001f;
   1.700          }
   1.701 -        if (!SDL_ReallocFormat (current, bpp, rmask, gmask, bmask, 0)) {
   1.702 +        if (!SDL_ReallocFormat(current, bpp, rmask, gmask, bmask, 0)) {
   1.703  
   1.704 -            SDL_SetError ("Could not reallocate video format.");
   1.705 +            SDL_SetError("Could not reallocate video format.");
   1.706              return (NULL);
   1.707          }
   1.708      }
   1.709 @@ -902,12 +897,12 @@
   1.710      if (!double_buf) {
   1.711  
   1.712          /* single-buffer context */
   1.713 -        DSpContext_GetFrontBuffer (dsp_context, &dsp_back_buffer);
   1.714 +        DSpContext_GetFrontBuffer(dsp_context, &dsp_back_buffer);
   1.715  
   1.716          current->hwdata =
   1.717 -            (private_hwdata *) SDL_malloc (sizeof (private_hwdata));
   1.718 +            (private_hwdata *) SDL_malloc(sizeof(private_hwdata));
   1.719          if (current->hwdata == NULL) {
   1.720 -            SDL_OutOfMemory ();
   1.721 +            SDL_OutOfMemory();
   1.722              return NULL;
   1.723          }
   1.724          current->hwdata->offscreen = dsp_back_buffer;
   1.725 @@ -915,8 +910,8 @@
   1.726          this->UpdateRects = DSp_DirectUpdate;
   1.727      } else if (use_dsp_back_buffer) {
   1.728  
   1.729 -        DSpContext_GetBackBuffer (dsp_context, kDSpBufferKind_Normal,
   1.730 -                                  &dsp_back_buffer);
   1.731 +        DSpContext_GetBackBuffer(dsp_context, kDSpBufferKind_Normal,
   1.732 +                                 &dsp_back_buffer);
   1.733  
   1.734          current->flags |= SDL_DOUBLEBUF | SDL_SWSURFACE;        /* only front buffer is in VRAM */
   1.735          this->UpdateRects = DSp_DSpUpdate;
   1.736 @@ -924,25 +919,25 @@
   1.737                 (this, &dsp_back_buffer, bpp, width - 1, height - 1) == 0) {
   1.738  
   1.739          current->hwdata =
   1.740 -            (private_hwdata *) SDL_malloc (sizeof (private_hwdata));
   1.741 +            (private_hwdata *) SDL_malloc(sizeof(private_hwdata));
   1.742          if (current->hwdata == NULL) {
   1.743 -            SDL_OutOfMemory ();
   1.744 +            SDL_OutOfMemory();
   1.745              return NULL;
   1.746          }
   1.747  
   1.748 -        SDL_memset (current->hwdata, 0, sizeof (private_hwdata));
   1.749 +        SDL_memset(current->hwdata, 0, sizeof(private_hwdata));
   1.750          current->hwdata->offscreen = dsp_back_buffer;
   1.751          current->flags |= SDL_DOUBLEBUF | SDL_HWSURFACE;
   1.752          this->UpdateRects = DSp_DirectUpdate;   /* hardware doesn't do update rects, must be page-flipped */
   1.753      } else {
   1.754  
   1.755 -        DSpContext_Release (dsp_context);
   1.756 +        DSpContext_Release(dsp_context);
   1.757          use_dsp_back_buffer = SDL_TRUE;
   1.758          goto rebuild;
   1.759      }
   1.760  
   1.761 -    current->pitch = GetPortPixRowBytes (dsp_back_buffer) & 0x3FFF;
   1.762 -    current->pixels = GetPixBaseAddr (GetPortPixMap (dsp_back_buffer));
   1.763 +    current->pitch = GetPortPixRowBytes(dsp_back_buffer) & 0x3FFF;
   1.764 +    current->pixels = GetPixBaseAddr(GetPortPixMap(dsp_back_buffer));
   1.765  
   1.766      current->w = width;
   1.767      current->h = height;
   1.768 @@ -951,14 +946,14 @@
   1.769  
   1.770      if (use_dsp_back_buffer) {
   1.771  
   1.772 -        DSpContext_GetMonitorFrequency (dsp_context, &freq);
   1.773 -        DSpContext_SetMaxFrameRate (dsp_context, freq >> 16);
   1.774 +        DSpContext_GetMonitorFrequency(dsp_context, &freq);
   1.775 +        DSpContext_SetMaxFrameRate(dsp_context, freq >> 16);
   1.776      }
   1.777  
   1.778  
   1.779      if ((current->flags & SDL_HWSURFACE)
   1.780          || (current->flags & SDL_INTERNALOPENGL))
   1.781 -        DSpContext_SetVBLProc (dsp_context, DSp_VBLProc, NULL);
   1.782 +        DSpContext_SetVBLProc(dsp_context, DSp_VBLProc, NULL);
   1.783  #endif
   1.784  
   1.785      if (bpp == 8)
   1.786 @@ -970,10 +965,10 @@
   1.787          RGBColor rgb = { 0.0, 0.0, 0.0 };
   1.788          GrafPtr save_port;
   1.789  
   1.790 -        SetRect (&rect, 0, 0, width, height);
   1.791 +        SetRect(&rect, 0, 0, width, height);
   1.792          SDL_Window =
   1.793 -            NewCWindow (nil, &((**SDL_Display).gdRect), "\p", SDL_TRUE,
   1.794 -                        plainDBox, (WindowPtr) - 1, SDL_FALSE, 0);
   1.795 +            NewCWindow(nil, &((**SDL_Display).gdRect), "\p", SDL_TRUE,
   1.796 +                       plainDBox, (WindowPtr) - 1, SDL_FALSE, 0);
   1.797  
   1.798          if (SDL_Window == NULL) {
   1.799  
   1.800 @@ -983,20 +978,20 @@
   1.801          }
   1.802  
   1.803          /* Set window color to black to avoid white flash */
   1.804 -        GetPort (&save_port);
   1.805 +        GetPort(&save_port);
   1.806  #if TARGET_API_MAC_CARBON
   1.807 -        SetPort (GetWindowPort (SDL_Window));
   1.808 +        SetPort(GetWindowPort(SDL_Window));
   1.809  #else
   1.810 -        SetPort (SDL_Window);
   1.811 +        SetPort(SDL_Window);
   1.812  #endif
   1.813 -        RGBForeColor (&rgb);
   1.814 -        PaintRect (&rect);
   1.815 -        SetPort (save_port);
   1.816 +        RGBForeColor(&rgb);
   1.817 +        PaintRect(&rect);
   1.818 +        SetPort(save_port);
   1.819  
   1.820 -        SetPortWindowPort (SDL_Window);
   1.821 -        SelectWindow (SDL_Window);
   1.822 +        SetPortWindowPort(SDL_Window);
   1.823 +        SelectWindow(SDL_Window);
   1.824  
   1.825 -        if (Mac_GL_Init (this) < 0) {
   1.826 +        if (Mac_GL_Init(this) < 0) {
   1.827  
   1.828              SDL_SetError
   1.829                  ("DSp_SetVideoMode : could not create OpenGL context.");
   1.830 @@ -1012,7 +1007,7 @@
   1.831  #ifdef DSP_TRY_CC_AND_AA
   1.832  
   1.833  static int
   1.834 -DSp_MakeHWMask (_THIS, SDL_Surface * surface)
   1.835 +DSp_MakeHWMask(_THIS, SDL_Surface * surface)
   1.836  {
   1.837      GDHandle save_device;
   1.838      CGrafPtr save_port;
   1.839 @@ -1021,44 +1016,44 @@
   1.840      RGBColor white = { 0xFFFF, 0xFFFF, 0xFFFF };
   1.841      Rect rect;
   1.842  
   1.843 -    Uint32 depth = GetPixDepth (GetGDevPixMap (SDL_Display));
   1.844 +    Uint32 depth = GetPixDepth(GetGDevPixMap(SDL_Display));
   1.845  
   1.846 -    SetRect (&rect, 0, 0, surface->w, surface->h);
   1.847 +    SetRect(&rect, 0, 0, surface->w, surface->h);
   1.848  
   1.849      if (noErr !=
   1.850 -        NewGWorld (&(surface->hwdata->mask), depth, &rect, 0, SDL_Display,
   1.851 -                   0) < 0) {
   1.852 +        NewGWorld(&(surface->hwdata->mask), depth, &rect, 0, SDL_Display,
   1.853 +                  0) < 0) {
   1.854  
   1.855 -        SDL_OutOfMemory ();
   1.856 +        SDL_OutOfMemory();
   1.857          return (-1);
   1.858      }
   1.859  
   1.860 -    if (noErr != NewGWorld (&temp, depth, &rect, 0, SDL_Display, 0)) {
   1.861 +    if (noErr != NewGWorld(&temp, depth, &rect, 0, SDL_Display, 0)) {
   1.862  
   1.863 -        SDL_OutOfMemory ();
   1.864 +        SDL_OutOfMemory();
   1.865          return (-1);
   1.866      }
   1.867  
   1.868  
   1.869 -    GetGWorld (&save_port, &save_device);
   1.870 -    SetGWorld (surface->hwdata->mask, SDL_Display);
   1.871 +    GetGWorld(&save_port, &save_device);
   1.872 +    SetGWorld(surface->hwdata->mask, SDL_Display);
   1.873  
   1.874 -    RGBForeColor (&white);
   1.875 -    PaintRect (&rect);
   1.876 +    RGBForeColor(&white);
   1.877 +    PaintRect(&rect);
   1.878  
   1.879 -    RGBBackColor (&(surface->hwdata->trans));
   1.880 +    RGBBackColor(&(surface->hwdata->trans));
   1.881  
   1.882 -    CopyBits (GetPortBitMapForCopyBits (surface->hwdata->offscreen),
   1.883 -              GetPortBitMapForCopyBits (surface->hwdata->mask),
   1.884 -              &rect, &rect, transparent, NULL);
   1.885 +    CopyBits(GetPortBitMapForCopyBits(surface->hwdata->offscreen),
   1.886 +             GetPortBitMapForCopyBits(surface->hwdata->mask),
   1.887 +             &rect, &rect, transparent, NULL);
   1.888  
   1.889 -    SetGWorld (surface->hwdata->mask, SDL_Display);
   1.890 -    SetGWorld (save_port, save_device);
   1.891 +    SetGWorld(surface->hwdata->mask, SDL_Display);
   1.892 +    SetGWorld(save_port, save_device);
   1.893      return (0);
   1.894  }
   1.895  
   1.896  static int
   1.897 -DSp_SetHWAlpha (_THIS, SDL_Surface * surface, UInt8 alpha)
   1.898 +DSp_SetHWAlpha(_THIS, SDL_Surface * surface, UInt8 alpha)
   1.899  {
   1.900      surface->hwdata->alpha.red = (alpha / 255.0) * 65535;
   1.901      surface->hwdata->alpha.blue = (alpha / 255.0) * 65535;
   1.902 @@ -1067,27 +1062,27 @@
   1.903      surface->flags |= SDL_SRCALPHA;
   1.904  
   1.905      if (surface->flags & SDL_SRCCOLORKEY) {
   1.906 -        return (DSp_MakeHWMask (this, surface));
   1.907 +        return (DSp_MakeHWMask(this, surface));
   1.908      }
   1.909      return (0);
   1.910  }
   1.911  
   1.912  static int
   1.913 -DSp_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key)
   1.914 +DSp_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key)
   1.915  {
   1.916      CGrafPtr save_port;
   1.917      GDHandle save_device;
   1.918  
   1.919 -    GetGWorld (&save_port, &save_device);
   1.920 -    SetGWorld (surface->hwdata->offscreen, NULL);
   1.921 +    GetGWorld(&save_port, &save_device);
   1.922 +    SetGWorld(surface->hwdata->offscreen, NULL);
   1.923  
   1.924 -    Index2Color (key, &(surface->hwdata->trans));
   1.925 +    Index2Color(key, &(surface->hwdata->trans));
   1.926      surface->flags |= SDL_SRCCOLORKEY;
   1.927  
   1.928 -    SetGWorld (save_port, save_device);
   1.929 +    SetGWorld(save_port, save_device);
   1.930  
   1.931      if (surface->flags & SDL_SRCALPHA) {
   1.932 -        return (DSp_MakeHWMask (this, surface));
   1.933 +        return (DSp_MakeHWMask(this, surface));
   1.934      }
   1.935      return (0);
   1.936  }
   1.937 @@ -1095,22 +1090,22 @@
   1.938  #endif /* DSP_TRY_CC_AND_AA */
   1.939  
   1.940  static int
   1.941 -DSp_NewHWSurface (_THIS, CGrafPtr * port, int depth, int width, int height)
   1.942 +DSp_NewHWSurface(_THIS, CGrafPtr * port, int depth, int width, int height)
   1.943  {
   1.944  
   1.945      OSStatus err;
   1.946      Rect bounds;
   1.947  
   1.948 -    SetRect (&bounds, 0, 0, width, height);
   1.949 +    SetRect(&bounds, 0, 0, width, height);
   1.950  
   1.951  #if useDistantHdwrMem && useLocalHdwrMem
   1.952      if (dsp_vram_available) {
   1.953          /* try VRAM */
   1.954          err =
   1.955 -            NewGWorld (port, depth, &bounds, 0, SDL_Display,
   1.956 -                       useDistantHdwrMem | noNewDevice);
   1.957 +            NewGWorld(port, depth, &bounds, 0, SDL_Display,
   1.958 +                      useDistantHdwrMem | noNewDevice);
   1.959          if (err != noErr)
   1.960 -            DSp_SetHWError (err, SDL_FALSE);
   1.961 +            DSp_SetHWError(err, SDL_FALSE);
   1.962          else
   1.963              return (0);
   1.964      }
   1.965 @@ -1118,11 +1113,11 @@
   1.966      if (dsp_agp_available) {
   1.967          /* try AGP */
   1.968          err =
   1.969 -            NewGWorld (port, depth, &bounds, 0, SDL_Display,
   1.970 -                       useLocalHdwrMem | noNewDevice);
   1.971 +            NewGWorld(port, depth, &bounds, 0, SDL_Display,
   1.972 +                      useLocalHdwrMem | noNewDevice);
   1.973  
   1.974          if (err != noErr)
   1.975 -            DSp_SetHWError (err, SDL_TRUE);
   1.976 +            DSp_SetHWError(err, SDL_TRUE);
   1.977          else
   1.978              return (0);
   1.979      }
   1.980 @@ -1132,7 +1127,7 @@
   1.981  }
   1.982  
   1.983  static int
   1.984 -DSp_AllocHWSurface (_THIS, SDL_Surface * surface)
   1.985 +DSp_AllocHWSurface(_THIS, SDL_Surface * surface)
   1.986  {
   1.987      GWorldPtr temp;
   1.988  
   1.989 @@ -1141,16 +1136,16 @@
   1.990           surface->h) < 0)
   1.991          return (-1);
   1.992  
   1.993 -    surface->hwdata = (private_hwdata *) SDL_malloc (sizeof (private_hwdata));
   1.994 +    surface->hwdata = (private_hwdata *) SDL_malloc(sizeof(private_hwdata));
   1.995      if (surface->hwdata == NULL) {
   1.996 -        SDL_OutOfMemory ();
   1.997 +        SDL_OutOfMemory();
   1.998          return -1;
   1.999      }
  1.1000  
  1.1001 -    SDL_memset (surface->hwdata, 0, sizeof (private_hwdata));
  1.1002 +    SDL_memset(surface->hwdata, 0, sizeof(private_hwdata));
  1.1003      surface->hwdata->offscreen = temp;
  1.1004 -    surface->pitch = GetPixRowBytes (GetPortPixMap (temp)) & 0x3FFF;
  1.1005 -    surface->pixels = GetPixBaseAddr (GetPortPixMap (temp));
  1.1006 +    surface->pitch = GetPixRowBytes(GetPortPixMap(temp)) & 0x3FFF;
  1.1007 +    surface->pixels = GetPixBaseAddr(GetPortPixMap(temp));
  1.1008      surface->flags |= SDL_HWSURFACE;
  1.1009  #ifdef DSP_TRY_CC_AND_AA
  1.1010      surface->flags |= SDL_HWACCEL;
  1.1011 @@ -1159,17 +1154,17 @@
  1.1012  }
  1.1013  
  1.1014  static void
  1.1015 -DSp_FreeHWSurface (_THIS, SDL_Surface * surface)
  1.1016 +DSp_FreeHWSurface(_THIS, SDL_Surface * surface)
  1.1017  {
  1.1018      if (surface->hwdata->offscreen != NULL)
  1.1019 -        DisposeGWorld (surface->hwdata->offscreen);
  1.1020 -    SDL_free (surface->hwdata);
  1.1021 +        DisposeGWorld(surface->hwdata->offscreen);
  1.1022 +    SDL_free(surface->hwdata);
  1.1023  
  1.1024      surface->pixels = NULL;
  1.1025  }
  1.1026  
  1.1027  static int
  1.1028 -DSp_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dest)
  1.1029 +DSp_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dest)
  1.1030  {
  1.1031      int accelerated;
  1.1032  
  1.1033 @@ -1197,8 +1192,8 @@
  1.1034  }
  1.1035  
  1.1036  static int
  1.1037 -DSp_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect,
  1.1038 -                 SDL_Surface * dst, SDL_Rect * dstrect)
  1.1039 +DSp_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
  1.1040 +                SDL_Surface * dst, SDL_Rect * dstrect)
  1.1041  {
  1.1042      CGrafPtr save_port;
  1.1043      GDHandle save_device;
  1.1044 @@ -1210,84 +1205,84 @@
  1.1045      UInt32 mode;
  1.1046  #endif
  1.1047  
  1.1048 -    SetRect (&src_rect, srcrect->x, srcrect->y, srcrect->x + srcrect->w,
  1.1049 -             srcrect->y + srcrect->h);
  1.1050 -    SetRect (&dst_rect, dstrect->x, dstrect->y, dstrect->x + dstrect->w,
  1.1051 -             dstrect->y + dstrect->h);
  1.1052 +    SetRect(&src_rect, srcrect->x, srcrect->y, srcrect->x + srcrect->w,
  1.1053 +            srcrect->y + srcrect->h);
  1.1054 +    SetRect(&dst_rect, dstrect->x, dstrect->y, dstrect->x + dstrect->w,
  1.1055 +            dstrect->y + dstrect->h);
  1.1056  
  1.1057 -    GetGWorld (&save_port, &save_device);
  1.1058 -    SetGWorld (dst->hwdata->offscreen, NULL);
  1.1059 +    GetGWorld(&save_port, &save_device);
  1.1060 +    SetGWorld(dst->hwdata->offscreen, NULL);
  1.1061  
  1.1062 -    RGBForeColor (&black);
  1.1063 -    RGBBackColor (&white);
  1.1064 +    RGBForeColor(&black);
  1.1065 +    RGBBackColor(&white);
  1.1066  
  1.1067  #ifdef DSP_TRY_CC_AND_AA
  1.1068  
  1.1069      if ((src->flags & SDL_SRCCOLORKEY) && (src->flags & SDL_SRCALPHA)) {
  1.1070  
  1.1071 -        OpColor (&(src->hwdata->alpha));
  1.1072 +        OpColor(&(src->hwdata->alpha));
  1.1073  
  1.1074 -        CopyDeepMask (GetPortBitMapForCopyBits (src->hwdata->offscreen),
  1.1075 -                      GetPortBitMapForCopyBits (src->hwdata->mask),
  1.1076 -                      GetPortBitMapForCopyBits (dst->hwdata->offscreen),
  1.1077 -                      &src_rect, &src_rect, &dst_rect, blend, NULL);
  1.1078 +        CopyDeepMask(GetPortBitMapForCopyBits(src->hwdata->offscreen),
  1.1079 +                     GetPortBitMapForCopyBits(src->hwdata->mask),
  1.1080 +                     GetPortBitMapForCopyBits(dst->hwdata->offscreen),
  1.1081 +                     &src_rect, &src_rect, &dst_rect, blend, NULL);
  1.1082      } else {
  1.1083  
  1.1084          if (src->flags & SDL_SRCCOLORKEY) {
  1.1085 -            RGBBackColor (&(src->hwdata->trans));
  1.1086 +            RGBBackColor(&(src->hwdata->trans));
  1.1087              mode = transparent;
  1.1088          } else if (src->flags & SDL_SRCALPHA) {
  1.1089  
  1.1090 -            OpColor (&(src->hwdata->alpha));
  1.1091 +            OpColor(&(src->hwdata->alpha));
  1.1092              mode = blend;
  1.1093          } else {
  1.1094  
  1.1095              mode = srcCopy;
  1.1096          }
  1.1097  
  1.1098 -        CopyBits (GetPortBitMapForCopyBits (src->hwdata->offscreen),
  1.1099 -                  GetPortBitMapForCopyBits (dst->hwdata->offscreen),
  1.1100 -                  &src_rect, &dst_rect, mode, NULL);
  1.1101 +        CopyBits(GetPortBitMapForCopyBits(src->hwdata->offscreen),
  1.1102 +                 GetPortBitMapForCopyBits(dst->hwdata->offscreen),
  1.1103 +                 &src_rect, &dst_rect, mode, NULL);
  1.1104      }
  1.1105  #else
  1.1106  
  1.1107 -    CopyBits (&(((GrafPtr) (src->hwdata->offscreen))->portBits),
  1.1108 -              &(((GrafPtr) (dst->hwdata->offscreen))->portBits),
  1.1109 -              &src_rect, &dst_rect, srcCopy, NULL);
  1.1110 +    CopyBits(&(((GrafPtr) (src->hwdata->offscreen))->portBits),
  1.1111 +             &(((GrafPtr) (dst->hwdata->offscreen))->portBits),
  1.1112 +             &src_rect, &dst_rect, srcCopy, NULL);
  1.1113  
  1.1114  #endif /* DSP_TRY_CC_AND_AA */
  1.1115  
  1.1116 -    SetGWorld (save_port, save_device);
  1.1117 +    SetGWorld(save_port, save_device);
  1.1118  
  1.1119      return (0);
  1.1120  }
  1.1121  
  1.1122  static int
  1.1123 -DSp_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
  1.1124 +DSp_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
  1.1125  {
  1.1126      CGrafPtr save_port;
  1.1127      GDHandle save_device;
  1.1128      Rect fill_rect;
  1.1129      RGBColor rgb;
  1.1130  
  1.1131 -    SetRect (&fill_rect, rect->x, rect->y, rect->x + rect->w,
  1.1132 -             rect->y + rect->h);
  1.1133 +    SetRect(&fill_rect, rect->x, rect->y, rect->x + rect->w,
  1.1134 +            rect->y + rect->h);
  1.1135  
  1.1136 -    GetGWorld (&save_port, &save_device);
  1.1137 -    SetGWorld (dst->hwdata->offscreen, NULL);
  1.1138 +    GetGWorld(&save_port, &save_device);
  1.1139 +    SetGWorld(dst->hwdata->offscreen, NULL);
  1.1140  
  1.1141 -    Index2Color (color, &rgb);
  1.1142 +    Index2Color(color, &rgb);
  1.1143  
  1.1144 -    RGBForeColor (&rgb);
  1.1145 -    PaintRect (&fill_rect);
  1.1146 +    RGBForeColor(&rgb);
  1.1147 +    PaintRect(&fill_rect);
  1.1148  
  1.1149 -    SetGWorld (save_port, save_device);
  1.1150 +    SetGWorld(save_port, save_device);
  1.1151  
  1.1152      return (0);
  1.1153  }
  1.1154  
  1.1155  static int
  1.1156 -DSp_FlipHWSurface (_THIS, SDL_Surface * surface)
  1.1157 +DSp_FlipHWSurface(_THIS, SDL_Surface * surface)
  1.1158  {
  1.1159      if ((surface->flags & SDL_HWSURFACE)) {
  1.1160          CGrafPtr dsp_front_buffer, save_port;
  1.1161 @@ -1298,11 +1293,11 @@
  1.1162  #endif
  1.1163  
  1.1164          /* pseudo page flipping for VRAM back buffer */
  1.1165 -        DSpContext_GetFrontBuffer (dsp_context, &dsp_front_buffer);
  1.1166 -        SetRect (&rect, 0, 0, surface->w - 1, surface->h - 1);
  1.1167 +        DSpContext_GetFrontBuffer(dsp_context, &dsp_front_buffer);
  1.1168 +        SetRect(&rect, 0, 0, surface->w - 1, surface->h - 1);
  1.1169  
  1.1170 -        GetPort ((GrafPtr *) & save_port);
  1.1171 -        SetPort ((GrafPtr) dsp_front_buffer);
  1.1172 +        GetPort((GrafPtr *) & save_port);
  1.1173 +        SetPort((GrafPtr) dsp_front_buffer);
  1.1174  
  1.1175          /* wait for retrace */
  1.1176          /* I have tried doing the swap in interrupt routine (VBL Proc) to do */
  1.1177 @@ -1315,46 +1310,46 @@
  1.1178  #endif
  1.1179  #endif
  1.1180  
  1.1181 -        CopyBits (GetPortBitMapForCopyBits (dsp_back_buffer),
  1.1182 -                  GetPortBitMapForCopyBits (dsp_front_buffer),
  1.1183 -                  &rect, &rect, srcCopy, NULL);
  1.1184 +        CopyBits(GetPortBitMapForCopyBits(dsp_back_buffer),
  1.1185 +                 GetPortBitMapForCopyBits(dsp_front_buffer),
  1.1186 +                 &rect, &rect, srcCopy, NULL);
  1.1187  
  1.1188 -        SetPort ((GrafPtr) save_port);
  1.1189 +        SetPort((GrafPtr) save_port);
  1.1190  
  1.1191      } else {
  1.1192          /* not really page flipping at all: DSp just blits the dirty rectangles from DSp_UpdateRects */
  1.1193          Boolean busy_flag;
  1.1194 -        DSpContext_SwapBuffers (dsp_context, NULL, &busy_flag); /* this  waits for VBL */
  1.1195 -        DSpContext_GetBackBuffer (dsp_context, kDSpBufferKind_Normal,
  1.1196 -                                  &dsp_back_buffer);
  1.1197 -        surface->pixels = GetPixBaseAddr (GetPortPixMap (dsp_back_buffer));
  1.1198 +        DSpContext_SwapBuffers(dsp_context, NULL, &busy_flag);  /* this  waits for VBL */
  1.1199 +        DSpContext_GetBackBuffer(dsp_context, kDSpBufferKind_Normal,
  1.1200 +                                 &dsp_back_buffer);
  1.1201 +        surface->pixels = GetPixBaseAddr(GetPortPixMap(dsp_back_buffer));
  1.1202      }
  1.1203      return (0);
  1.1204  }
  1.1205  
  1.1206  static int
  1.1207 -DSp_LockHWSurface (_THIS, SDL_Surface * surface)
  1.1208 +DSp_LockHWSurface(_THIS, SDL_Surface * surface)
  1.1209  {
  1.1210 -    if (LockPixels (GetGWorldPixMap (surface->hwdata->offscreen)))
  1.1211 +    if (LockPixels(GetGWorldPixMap(surface->hwdata->offscreen)))
  1.1212          return 0;
  1.1213      else
  1.1214          return -1;
  1.1215  }
  1.1216  
  1.1217  static void
  1.1218 -DSp_UnlockHWSurface (_THIS, SDL_Surface * surface)
  1.1219 +DSp_UnlockHWSurface(_THIS, SDL_Surface * surface)
  1.1220  {
  1.1221 -    UnlockPixels (GetGWorldPixMap (surface->hwdata->offscreen));
  1.1222 +    UnlockPixels(GetGWorldPixMap(surface->hwdata->offscreen));
  1.1223  }
  1.1224  
  1.1225  static void
  1.1226 -DSp_DirectUpdate (_THIS, int numrects, SDL_Rect * sdl_rects)
  1.1227 +DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * sdl_rects)
  1.1228  {
  1.1229      return;
  1.1230  }
  1.1231  
  1.1232  static void
  1.1233 -DSp_DSpUpdate (_THIS, int numrects, SDL_Rect * sdl_rects)
  1.1234 +DSp_DSpUpdate(_THIS, int numrects, SDL_Rect * sdl_rects)
  1.1235  {
  1.1236  #if ! TARGET_API_MAC_OSX        /* Unsupported DSp in here */
  1.1237      int i;
  1.1238 @@ -1367,51 +1362,51 @@
  1.1239          rect.bottom = sdl_rects[i].h + sdl_rects[i].y;
  1.1240          rect.right = sdl_rects[i].w + sdl_rects[i].x;
  1.1241  
  1.1242 -        DSpContext_InvalBackBufferRect (dsp_context, &rect);
  1.1243 +        DSpContext_InvalBackBufferRect(dsp_context, &rect);
  1.1244      }
  1.1245  #endif
  1.1246  }
  1.1247  
  1.1248  static int
  1.1249 -DSp_CreatePalette (_THIS)
  1.1250 +DSp_CreatePalette(_THIS)
  1.1251  {
  1.1252  
  1.1253  
  1.1254      /* Create our palette */
  1.1255 -    SDL_CTab = (CTabHandle) NewHandle (sizeof (ColorSpec) * 256 + 8);
  1.1256 +    SDL_CTab = (CTabHandle) NewHandle(sizeof(ColorSpec) * 256 + 8);
  1.1257      if (SDL_CTab == nil) {
  1.1258 -        SDL_OutOfMemory ();
  1.1259 +        SDL_OutOfMemory();
  1.1260          return (-1);
  1.1261      }
  1.1262 -    (**SDL_CTab).ctSeed = GetCTSeed ();
  1.1263 +    (**SDL_CTab).ctSeed = GetCTSeed();
  1.1264      (**SDL_CTab).ctFlags = 0;
  1.1265      (**SDL_CTab).ctSize = 255;
  1.1266 -    CTabChanged (SDL_CTab);
  1.1267 -    SDL_CPal = NewPalette (256, SDL_CTab, pmExplicit + pmTolerant, 0);
  1.1268 +    CTabChanged(SDL_CTab);
  1.1269 +    SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit + pmTolerant, 0);
  1.1270  
  1.1271      return 0;
  1.1272  }
  1.1273  
  1.1274  static int
  1.1275 -DSp_DestroyPalette (_THIS)
  1.1276 +DSp_DestroyPalette(_THIS)
  1.1277  {
  1.1278  
  1.1279      /* Free palette and restore original one */
  1.1280      if (SDL_CTab != nil) {
  1.1281 -        DisposeHandle ((Handle) SDL_CTab);
  1.1282 +        DisposeHandle((Handle) SDL_CTab);
  1.1283          SDL_CTab = nil;
  1.1284      }
  1.1285      if (SDL_CPal != nil) {
  1.1286 -        DisposePalette (SDL_CPal);
  1.1287 +        DisposePalette(SDL_CPal);
  1.1288          SDL_CPal = nil;
  1.1289      }
  1.1290 -    RestoreDeviceClut (SDL_Display);
  1.1291 +    RestoreDeviceClut(SDL_Display);
  1.1292  
  1.1293      return (0);
  1.1294  }
  1.1295  
  1.1296  static int
  1.1297 -DSp_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  1.1298 +DSp_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  1.1299  {
  1.1300      CTabHandle cTab;
  1.1301  
  1.1302 @@ -1433,41 +1428,41 @@
  1.1303          (**cTab).ctTable[j].rgb.blue = colors[i].b << 8 | colors[i].b;
  1.1304      }
  1.1305  
  1.1306 -    SetGDevice (SDL_Display);
  1.1307 -    SetEntries (0, (**cTab).ctSize, (ColorSpec *) & (**cTab).ctTable);
  1.1308 +    SetGDevice(SDL_Display);
  1.1309 +    SetEntries(0, (**cTab).ctSize, (ColorSpec *) & (**cTab).ctTable);
  1.1310  
  1.1311      return (1);
  1.1312  }
  1.1313  
  1.1314  void
  1.1315 -DSp_VideoQuit (_THIS)
  1.1316 +DSp_VideoQuit(_THIS)
  1.1317  {
  1.1318      int i;
  1.1319  
  1.1320      /* Free current video mode */
  1.1321 -    DSp_UnsetVideoMode (this, this->screen);
  1.1322 +    DSp_UnsetVideoMode(this, this->screen);
  1.1323  
  1.1324      /* Free Palette and restore original */
  1.1325 -    DSp_DestroyPalette (this);
  1.1326 +    DSp_DestroyPalette(this);
  1.1327  
  1.1328      /* Free list of video modes */
  1.1329      if (SDL_modelist != NULL) {
  1.1330          for (i = 0; SDL_modelist[i]; i++) {
  1.1331 -            SDL_free (SDL_modelist[i]);
  1.1332 +            SDL_free(SDL_modelist[i]);
  1.1333          }
  1.1334 -        SDL_free (SDL_modelist);
  1.1335 +        SDL_free(SDL_modelist);
  1.1336          SDL_modelist = NULL;
  1.1337      }
  1.1338  
  1.1339      /* Unload DrawSprocket */
  1.1340 -    DSpShutdown ();
  1.1341 +    DSpShutdown();
  1.1342  }
  1.1343  
  1.1344  #if SDL_VIDEO_OPENGL
  1.1345  
  1.1346  /* swap buffers with v-sync */
  1.1347  static void
  1.1348 -DSp_GL_SwapBuffers (_THIS)
  1.1349 +DSp_GL_SwapBuffers(_THIS)
  1.1350  {
  1.1351  
  1.1352  #ifndef DSP_NO_SYNC_OPENGL
  1.1353 @@ -1478,7 +1473,7 @@
  1.1354      while (old_count == retrace_count);
  1.1355  #endif
  1.1356  
  1.1357 -    aglSwapBuffers (glContext);
  1.1358 +    aglSwapBuffers(glContext);
  1.1359  }
  1.1360  
  1.1361  #endif