src/video/windx5/SDL_dx5video.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
child 1705 fc731a7d83ed
     1.1 --- a/src/video/windx5/SDL_dx5video.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/windx5/SDL_dx5video.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -56,10 +56,10 @@
     1.4  
     1.5  
     1.6  /* DirectX function pointers for video and events */
     1.7 -HRESULT (WINAPI * DDrawCreate) (GUID FAR * lpGUID, LPDIRECTDRAW FAR * lplpDD,
     1.8 -                                IUnknown FAR * pUnkOuter);
     1.9 -HRESULT (WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion,
    1.10 -                                 LPDIRECTINPUT * ppDI, LPUNKNOWN punkOuter);
    1.11 +HRESULT(WINAPI * DDrawCreate) (GUID FAR * lpGUID, LPDIRECTDRAW FAR * lplpDD,
    1.12 +                               IUnknown FAR * pUnkOuter);
    1.13 +HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion,
    1.14 +                                LPDIRECTINPUT * ppDI, LPUNKNOWN punkOuter);
    1.15  
    1.16  /* This is the rect EnumModes2 uses */
    1.17  struct DX5EnumRect
    1.18 @@ -406,41 +406,41 @@
    1.19  
    1.20  
    1.21  /* Initialization/Query functions */
    1.22 -static int DX5_VideoInit (_THIS, SDL_PixelFormat * vformat);
    1.23 -static SDL_Rect **DX5_ListModes (_THIS, SDL_PixelFormat * format,
    1.24 -                                 Uint32 flags);
    1.25 -static SDL_Surface *DX5_SetVideoMode (_THIS, SDL_Surface * current, int width,
    1.26 -                                      int height, int bpp, Uint32 flags);
    1.27 -static int DX5_SetColors (_THIS, int firstcolor, int ncolors,
    1.28 -                          SDL_Color * colors);
    1.29 -static int DX5_SetGammaRamp (_THIS, Uint16 * ramp);
    1.30 -static int DX5_GetGammaRamp (_THIS, Uint16 * ramp);
    1.31 -static void DX5_VideoQuit (_THIS);
    1.32 +static int DX5_VideoInit(_THIS, SDL_PixelFormat * vformat);
    1.33 +static SDL_Rect **DX5_ListModes(_THIS, SDL_PixelFormat * format,
    1.34 +                                Uint32 flags);
    1.35 +static SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface * current, int width,
    1.36 +                                     int height, int bpp, Uint32 flags);
    1.37 +static int DX5_SetColors(_THIS, int firstcolor, int ncolors,
    1.38 +                         SDL_Color * colors);
    1.39 +static int DX5_SetGammaRamp(_THIS, Uint16 * ramp);
    1.40 +static int DX5_GetGammaRamp(_THIS, Uint16 * ramp);
    1.41 +static void DX5_VideoQuit(_THIS);
    1.42  
    1.43  /* Hardware surface functions */
    1.44 -static int DX5_AllocHWSurface (_THIS, SDL_Surface * surface);
    1.45 -static int DX5_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst);
    1.46 -static int DX5_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect,
    1.47 -                           Uint32 color);
    1.48 -static int DX5_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key);
    1.49 -static int DX5_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha);
    1.50 -static int DX5_LockHWSurface (_THIS, SDL_Surface * surface);
    1.51 -static void DX5_UnlockHWSurface (_THIS, SDL_Surface * surface);
    1.52 -static int DX5_FlipHWSurface (_THIS, SDL_Surface * surface);
    1.53 -static void DX5_FreeHWSurface (_THIS, SDL_Surface * surface);
    1.54 +static int DX5_AllocHWSurface(_THIS, SDL_Surface * surface);
    1.55 +static int DX5_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst);
    1.56 +static int DX5_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect,
    1.57 +                          Uint32 color);
    1.58 +static int DX5_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key);
    1.59 +static int DX5_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha);
    1.60 +static int DX5_LockHWSurface(_THIS, SDL_Surface * surface);
    1.61 +static void DX5_UnlockHWSurface(_THIS, SDL_Surface * surface);
    1.62 +static int DX5_FlipHWSurface(_THIS, SDL_Surface * surface);
    1.63 +static void DX5_FreeHWSurface(_THIS, SDL_Surface * surface);
    1.64  
    1.65 -static int DX5_AllocDDSurface (_THIS, SDL_Surface * surface,
    1.66 -                               LPDIRECTDRAWSURFACE3 requested, Uint32 flag);
    1.67 +static int DX5_AllocDDSurface(_THIS, SDL_Surface * surface,
    1.68 +                              LPDIRECTDRAWSURFACE3 requested, Uint32 flag);
    1.69  
    1.70  /* Windows message handling functions */
    1.71 -static void DX5_RealizePalette (_THIS);
    1.72 -static void DX5_PaletteChanged (_THIS, HWND window);
    1.73 -static void DX5_WinPAINT (_THIS, HDC hdc);
    1.74 +static void DX5_RealizePalette(_THIS);
    1.75 +static void DX5_PaletteChanged(_THIS, HWND window);
    1.76 +static void DX5_WinPAINT(_THIS, HDC hdc);
    1.77  
    1.78  /* WinDIB driver functions for manipulating gamma ramps */
    1.79 -extern int DIB_SetGammaRamp (_THIS, Uint16 * ramp);
    1.80 -extern int DIB_GetGammaRamp (_THIS, Uint16 * ramp);
    1.81 -extern void DIB_QuitGamma (_THIS);
    1.82 +extern int DIB_SetGammaRamp(_THIS, Uint16 * ramp);
    1.83 +extern int DIB_GetGammaRamp(_THIS, Uint16 * ramp);
    1.84 +extern void DIB_QuitGamma(_THIS);
    1.85  
    1.86  /* Functions for loading the DirectX functions dynamically */
    1.87  static int DX5_loaded = 0;
    1.88 @@ -448,42 +448,42 @@
    1.89  static HINSTANCE DInputDLL = NULL;
    1.90  
    1.91  void
    1.92 -DX5_Unload (void)
    1.93 +DX5_Unload(void)
    1.94  {
    1.95      if (--DX5_loaded == 0) {
    1.96          if (DDrawDLL != NULL) {
    1.97 -            FreeLibrary (DDrawDLL);
    1.98 +            FreeLibrary(DDrawDLL);
    1.99              DDrawCreate = NULL;
   1.100              DDrawDLL = NULL;
   1.101          }
   1.102          if (DInputDLL != NULL) {
   1.103 -            FreeLibrary (DInputDLL);
   1.104 +            FreeLibrary(DInputDLL);
   1.105              DInputCreate = NULL;
   1.106              DInputDLL = NULL;
   1.107          }
   1.108      }
   1.109  }
   1.110  int
   1.111 -DX5_Load (void)
   1.112 +DX5_Load(void)
   1.113  {
   1.114      int status = 0;
   1.115  
   1.116      if (++DX5_loaded == 1) {
   1.117 -        DDrawDLL = LoadLibrary (TEXT ("DDRAW.DLL"));
   1.118 +        DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL"));
   1.119          if (DDrawDLL != NULL) {
   1.120 -            DDrawCreate = (void *) GetProcAddress (DDrawDLL,
   1.121 -                                                   TEXT ("DirectDrawCreate"));
   1.122 +            DDrawCreate = (void *) GetProcAddress(DDrawDLL,
   1.123 +                                                  TEXT("DirectDrawCreate"));
   1.124          }
   1.125 -        DInputDLL = LoadLibrary (TEXT ("DINPUT.DLL"));
   1.126 +        DInputDLL = LoadLibrary(TEXT("DINPUT.DLL"));
   1.127          if (DInputDLL != NULL) {
   1.128 -            DInputCreate = (void *) GetProcAddress (DInputDLL,
   1.129 -                                                    TEXT
   1.130 -                                                    ("DirectInputCreateA"));
   1.131 +            DInputCreate = (void *) GetProcAddress(DInputDLL,
   1.132 +                                                   TEXT
   1.133 +                                                   ("DirectInputCreateA"));
   1.134          }
   1.135          if (DDrawDLL && DDrawCreate && DInputDLL && DInputCreate) {
   1.136              status = 0;
   1.137          } else {
   1.138 -            DX5_Unload ();
   1.139 +            DX5_Unload();
   1.140              status = -1;
   1.141          }
   1.142      }
   1.143 @@ -493,36 +493,34 @@
   1.144  /* DX5 driver bootstrap functions */
   1.145  
   1.146  static int
   1.147 -DX5_Available (void)
   1.148 +DX5_Available(void)
   1.149  {
   1.150      int ddraw_ok = 0;
   1.151 -    HRESULT (WINAPI * DDrawCreate) (GUID *, LPDIRECTDRAW *, IUnknown *);
   1.152 +    HRESULT(WINAPI * DDrawCreate) (GUID *, LPDIRECTDRAW *, IUnknown *);
   1.153      LPDIRECTDRAW DDraw;
   1.154  
   1.155      /* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */
   1.156 -    if (DX5_Load () < 0) {
   1.157 +    if (DX5_Load() < 0) {
   1.158          return -1;
   1.159      }
   1.160  
   1.161      /* Try to create a valid DirectDraw object */
   1.162 -    DDrawCreate =
   1.163 -        (void *) GetProcAddress (DDrawDLL, TEXT ("DirectDrawCreate"));
   1.164 -    if ((DDrawCreate != NULL) && !FAILED (DDrawCreate (NULL, &DDraw, NULL))) {
   1.165 -        if (!FAILED (IDirectDraw_SetCooperativeLevel (DDraw,
   1.166 -                                                      NULL, DDSCL_NORMAL))) {
   1.167 +    DDrawCreate = (void *) GetProcAddress(DDrawDLL, TEXT("DirectDrawCreate"));
   1.168 +    if ((DDrawCreate != NULL) && !FAILED(DDrawCreate(NULL, &DDraw, NULL))) {
   1.169 +        if (!FAILED(IDirectDraw_SetCooperativeLevel(DDraw,
   1.170 +                                                    NULL, DDSCL_NORMAL))) {
   1.171              DDSURFACEDESC desc;
   1.172              LPDIRECTDRAWSURFACE DDrawSurf;
   1.173              LPDIRECTDRAWSURFACE3 DDrawSurf3;
   1.174  
   1.175              /* Try to create a DirectDrawSurface3 object */
   1.176 -            SDL_memset (&desc, 0, sizeof (desc));
   1.177 -            desc.dwSize = sizeof (desc);
   1.178 +            SDL_memset(&desc, 0, sizeof(desc));
   1.179 +            desc.dwSize = sizeof(desc);
   1.180              desc.dwFlags = DDSD_CAPS;
   1.181              desc.ddsCaps.dwCaps =
   1.182                  DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY;
   1.183              if (!FAILED
   1.184 -                (IDirectDraw_CreateSurface
   1.185 -                 (DDraw, &desc, &DDrawSurf, NULL))) {
   1.186 +                (IDirectDraw_CreateSurface(DDraw, &desc, &DDrawSurf, NULL))) {
   1.187                  if (!FAILED
   1.188                      (IDirectDrawSurface_QueryInterface
   1.189                       (DDrawSurf, &IID_IDirectDrawSurface3,
   1.190 @@ -531,66 +529,66 @@
   1.191                      ddraw_ok = 1;
   1.192  
   1.193                      /* Clean up.. */
   1.194 -                    IDirectDrawSurface3_Release (DDrawSurf3);
   1.195 +                    IDirectDrawSurface3_Release(DDrawSurf3);
   1.196                  }
   1.197 -                IDirectDrawSurface_Release (DDrawSurf);
   1.198 +                IDirectDrawSurface_Release(DDrawSurf);
   1.199              }
   1.200          }
   1.201 -        IDirectDraw_Release (DDraw);
   1.202 +        IDirectDraw_Release(DDraw);
   1.203      }
   1.204  
   1.205 -    DX5_Unload ();
   1.206 +    DX5_Unload();
   1.207  
   1.208      return ddraw_ok;
   1.209  }
   1.210  
   1.211  static void
   1.212 -DX5_DeleteDevice (SDL_VideoDevice * this)
   1.213 +DX5_DeleteDevice(SDL_VideoDevice * this)
   1.214  {
   1.215      /* Free DirectDraw object */
   1.216      if (ddraw2 != NULL) {
   1.217 -        IDirectDraw2_Release (ddraw2);
   1.218 +        IDirectDraw2_Release(ddraw2);
   1.219      }
   1.220 -    DX5_Unload ();
   1.221 +    DX5_Unload();
   1.222  
   1.223      if (this) {
   1.224          if (this->hidden) {
   1.225 -            SDL_free (this->hidden);
   1.226 +            SDL_free(this->hidden);
   1.227          }
   1.228          if (this->gl_data) {
   1.229 -            SDL_free (this->gl_data);
   1.230 +            SDL_free(this->gl_data);
   1.231          }
   1.232 -        SDL_free (this);
   1.233 +        SDL_free(this);
   1.234      }
   1.235  }
   1.236  
   1.237  static SDL_VideoDevice *
   1.238 -DX5_CreateDevice (int devindex)
   1.239 +DX5_CreateDevice(int devindex)
   1.240  {
   1.241      SDL_VideoDevice *device;
   1.242  
   1.243      /* Load DirectX */
   1.244 -    if (DX5_Load () < 0) {
   1.245 +    if (DX5_Load() < 0) {
   1.246          return (NULL);
   1.247      }
   1.248  
   1.249      /* Initialize all variables that we clean on shutdown */
   1.250 -    device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice));
   1.251 +    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
   1.252      if (device) {
   1.253 -        SDL_memset (device, 0, (sizeof *device));
   1.254 +        SDL_memset(device, 0, (sizeof *device));
   1.255          device->hidden = (struct SDL_PrivateVideoData *)
   1.256 -            SDL_malloc ((sizeof *device->hidden));
   1.257 +            SDL_malloc((sizeof *device->hidden));
   1.258          device->gl_data = (struct SDL_PrivateGLData *)
   1.259 -            SDL_malloc ((sizeof *device->gl_data));
   1.260 +            SDL_malloc((sizeof *device->gl_data));
   1.261      }
   1.262      if ((device == NULL) || (device->hidden == NULL) ||
   1.263          (device->gl_data == NULL)) {
   1.264 -        SDL_OutOfMemory ();
   1.265 -        DX5_DeleteDevice (device);
   1.266 +        SDL_OutOfMemory();
   1.267 +        DX5_DeleteDevice(device);
   1.268          return (NULL);
   1.269      }
   1.270 -    SDL_memset (device->hidden, 0, (sizeof *device->hidden));
   1.271 -    SDL_memset (device->gl_data, 0, (sizeof *device->gl_data));
   1.272 +    SDL_memset(device->hidden, 0, (sizeof *device->hidden));
   1.273 +    SDL_memset(device->gl_data, 0, (sizeof *device->gl_data));
   1.274  
   1.275      /* Set the function pointers */
   1.276      device->VideoInit = DX5_VideoInit;
   1.277 @@ -650,7 +648,7 @@
   1.278  };
   1.279  
   1.280  static int
   1.281 -cmpmodes (const void *va, const void *vb)
   1.282 +cmpmodes(const void *va, const void *vb)
   1.283  {
   1.284      SDL_Rect *a = *(SDL_Rect **) va;
   1.285      SDL_Rect *b = *(SDL_Rect **) vb;
   1.286 @@ -661,7 +659,7 @@
   1.287  }
   1.288  
   1.289  static HRESULT WINAPI
   1.290 -EnumModes2 (DDSURFACEDESC * desc, VOID * udata)
   1.291 +EnumModes2(DDSURFACEDESC * desc, VOID * udata)
   1.292  {
   1.293      SDL_VideoDevice *this = (SDL_VideoDevice *) udata;
   1.294      struct DX5EnumRect *enumrect;
   1.295 @@ -695,19 +693,19 @@
   1.296                  refreshRate <= maxRefreshRate) {
   1.297                  enumlists[bpp]->refreshRate = refreshRate;
   1.298  #ifdef DDRAW_DEBUG
   1.299 -                fprintf (stderr,
   1.300 -                         "New refresh rate for %d bpp: %dx%d at %d Hz\n",
   1.301 -                         (bpp + 1) * 8, (int) desc->dwWidth,
   1.302 -                         (int) desc->dwHeight, refreshRate);
   1.303 +                fprintf(stderr,
   1.304 +                        "New refresh rate for %d bpp: %dx%d at %d Hz\n",
   1.305 +                        (bpp + 1) * 8, (int) desc->dwWidth,
   1.306 +                        (int) desc->dwHeight, refreshRate);
   1.307  #endif
   1.308              }
   1.309              break;
   1.310          }
   1.311          ++SDL_nummodes[bpp];
   1.312          enumrect =
   1.313 -            (struct DX5EnumRect *) SDL_malloc (sizeof (struct DX5EnumRect));
   1.314 +            (struct DX5EnumRect *) SDL_malloc(sizeof(struct DX5EnumRect));
   1.315          if (!enumrect) {
   1.316 -            SDL_OutOfMemory ();
   1.317 +            SDL_OutOfMemory();
   1.318              return (DDENUMRET_CANCEL);
   1.319          }
   1.320          enumrect->refreshRate = refreshRate;
   1.321 @@ -718,9 +716,9 @@
   1.322          enumrect->next = enumlists[bpp];
   1.323          enumlists[bpp] = enumrect;
   1.324  #ifdef DDRAW_DEBUG
   1.325 -        fprintf (stderr, "New mode for %d bpp: %dx%d at %d Hz\n",
   1.326 -                 (bpp + 1) * 8, (int) desc->dwWidth, (int) desc->dwHeight,
   1.327 -                 refreshRate);
   1.328 +        fprintf(stderr, "New mode for %d bpp: %dx%d at %d Hz\n",
   1.329 +                (bpp + 1) * 8, (int) desc->dwWidth, (int) desc->dwHeight,
   1.330 +                refreshRate);
   1.331  #endif
   1.332          break;
   1.333      }
   1.334 @@ -729,7 +727,7 @@
   1.335  }
   1.336  
   1.337  void
   1.338 -SetDDerror (const char *function, int code)
   1.339 +SetDDerror(const char *function, int code)
   1.340  {
   1.341      static char *error;
   1.342      static char errbuf[1024];
   1.343 @@ -839,21 +837,21 @@
   1.344          error = "Interface not present";
   1.345          break;
   1.346      default:
   1.347 -        SDL_snprintf (errbuf, SDL_arraysize (errbuf),
   1.348 -                      "%s: Unknown DirectDraw error: 0x%x", function, code);
   1.349 +        SDL_snprintf(errbuf, SDL_arraysize(errbuf),
   1.350 +                     "%s: Unknown DirectDraw error: 0x%x", function, code);
   1.351          break;
   1.352      }
   1.353      if (!errbuf[0]) {
   1.354 -        SDL_snprintf (errbuf, SDL_arraysize (errbuf), "%s: %s", function,
   1.355 -                      error);
   1.356 +        SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
   1.357 +                     error);
   1.358      }
   1.359 -    SDL_SetError ("%s", errbuf);
   1.360 +    SDL_SetError("%s", errbuf);
   1.361      return;
   1.362  }
   1.363  
   1.364  
   1.365  static int
   1.366 -DX5_UpdateVideoInfo (_THIS)
   1.367 +DX5_UpdateVideoInfo(_THIS)
   1.368  {
   1.369      /* This needs to be DDCAPS_DX5 for the DirectDraw2 interface */
   1.370  #if DIRECTDRAW_VERSION <= 0x300
   1.371 @@ -868,11 +866,11 @@
   1.372      HRESULT result;
   1.373  
   1.374      /* Fill in our hardware acceleration capabilities */
   1.375 -    SDL_memset (&DDCaps, 0, sizeof (DDCaps));
   1.376 -    DDCaps.dwSize = sizeof (DDCaps);
   1.377 -    result = IDirectDraw2_GetCaps (ddraw2, (DDCAPS *) & DDCaps, NULL);
   1.378 +    SDL_memset(&DDCaps, 0, sizeof(DDCaps));
   1.379 +    DDCaps.dwSize = sizeof(DDCaps);
   1.380 +    result = IDirectDraw2_GetCaps(ddraw2, (DDCAPS *) & DDCaps, NULL);
   1.381      if (result != DD_OK) {
   1.382 -        SetDDerror ("DirectDraw2::GetCaps", result);
   1.383 +        SetDDerror("DirectDraw2::GetCaps", result);
   1.384          return (-1);
   1.385      }
   1.386      this->info.hw_available = 1;
   1.387 @@ -904,8 +902,8 @@
   1.388          DDSCAPS ddsCaps;
   1.389          DWORD total_mem;
   1.390          ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
   1.391 -        result = IDirectDraw2_GetAvailableVidMem (ddraw2,
   1.392 -                                                  &ddsCaps, &total_mem, NULL);
   1.393 +        result = IDirectDraw2_GetAvailableVidMem(ddraw2,
   1.394 +                                                 &ddsCaps, &total_mem, NULL);
   1.395          if (result != DD_OK) {
   1.396              total_mem = DDCaps.dwVidMemTotal;
   1.397          }
   1.398 @@ -915,7 +913,7 @@
   1.399  }
   1.400  
   1.401  int
   1.402 -DX5_VideoInit (_THIS, SDL_PixelFormat * vformat)
   1.403 +DX5_VideoInit(_THIS, SDL_PixelFormat * vformat)
   1.404  {
   1.405      HRESULT result;
   1.406      LPDIRECTDRAW ddraw;
   1.407 @@ -935,36 +933,36 @@
   1.408      colorchange_expected = 0;
   1.409  
   1.410      /* Create the window */
   1.411 -    if (DX5_CreateWindow (this) < 0) {
   1.412 +    if (DX5_CreateWindow(this) < 0) {
   1.413          return (-1);
   1.414      }
   1.415  #if !SDL_AUDIO_DISABLED
   1.416 -    DX5_SoundFocus (SDL_Window);
   1.417 +    DX5_SoundFocus(SDL_Window);
   1.418  #endif
   1.419  
   1.420      /* Create the DirectDraw object */
   1.421 -    result = DDrawCreate (NULL, &ddraw, NULL);
   1.422 +    result = DDrawCreate(NULL, &ddraw, NULL);
   1.423      if (result != DD_OK) {
   1.424 -        SetDDerror ("DirectDrawCreate", result);
   1.425 +        SetDDerror("DirectDrawCreate", result);
   1.426          return (-1);
   1.427      }
   1.428 -    result = IDirectDraw_QueryInterface (ddraw, &IID_IDirectDraw2,
   1.429 -                                         (LPVOID *) & ddraw2);
   1.430 -    IDirectDraw_Release (ddraw);
   1.431 +    result = IDirectDraw_QueryInterface(ddraw, &IID_IDirectDraw2,
   1.432 +                                        (LPVOID *) & ddraw2);
   1.433 +    IDirectDraw_Release(ddraw);
   1.434      if (result != DD_OK) {
   1.435 -        SetDDerror ("DirectDraw::QueryInterface", result);
   1.436 +        SetDDerror("DirectDraw::QueryInterface", result);
   1.437          return (-1);
   1.438      }
   1.439  
   1.440      /* Determine the screen depth */
   1.441 -    hdc = GetDC (SDL_Window);
   1.442 -    vformat->BitsPerPixel = GetDeviceCaps (hdc, PLANES) *
   1.443 -        GetDeviceCaps (hdc, BITSPIXEL);
   1.444 -    ReleaseDC (SDL_Window, hdc);
   1.445 +    hdc = GetDC(SDL_Window);
   1.446 +    vformat->BitsPerPixel = GetDeviceCaps(hdc, PLANES) *
   1.447 +        GetDeviceCaps(hdc, BITSPIXEL);
   1.448 +    ReleaseDC(SDL_Window, hdc);
   1.449  
   1.450  #ifndef NO_CHANGEDISPLAYSETTINGS
   1.451      /* Query for the desktop resolution */
   1.452 -    EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode);
   1.453 +    EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode);
   1.454      this->info.current_w = SDL_desktop_mode.dmPelsWidth;
   1.455      this->info.current_h = SDL_desktop_mode.dmPelsHeight;
   1.456  #endif
   1.457 @@ -974,18 +972,18 @@
   1.458          enumlists[i] = NULL;
   1.459  
   1.460      result =
   1.461 -        IDirectDraw2_EnumDisplayModes (ddraw2, DDEDM_REFRESHRATES, NULL, this,
   1.462 -                                       EnumModes2);
   1.463 +        IDirectDraw2_EnumDisplayModes(ddraw2, DDEDM_REFRESHRATES, NULL, this,
   1.464 +                                      EnumModes2);
   1.465      if (result != DD_OK) {
   1.466 -        SetDDerror ("DirectDraw2::EnumDisplayModes", result);
   1.467 +        SetDDerror("DirectDraw2::EnumDisplayModes", result);
   1.468          return (-1);
   1.469      }
   1.470      for (i = 0; i < NUM_MODELISTS; ++i) {
   1.471          struct DX5EnumRect *rect;
   1.472          SDL_modelist[i] = (SDL_Rect **)
   1.473 -            SDL_malloc ((SDL_nummodes[i] + 1) * sizeof (SDL_Rect *));
   1.474 +            SDL_malloc((SDL_nummodes[i] + 1) * sizeof(SDL_Rect *));
   1.475          if (SDL_modelist[i] == NULL) {
   1.476 -            SDL_OutOfMemory ();
   1.477 +            SDL_OutOfMemory();
   1.478              return (-1);
   1.479          }
   1.480          for (j = 0, rect = enumlists[i]; rect; ++j, rect = rect->next) {
   1.481 @@ -994,8 +992,8 @@
   1.482          SDL_modelist[i][j] = NULL;
   1.483  
   1.484          if (SDL_nummodes[i] > 0) {
   1.485 -            SDL_qsort (SDL_modelist[i], SDL_nummodes[i],
   1.486 -                       sizeof *SDL_modelist[i], cmpmodes);
   1.487 +            SDL_qsort(SDL_modelist[i], SDL_nummodes[i],
   1.488 +                      sizeof *SDL_modelist[i], cmpmodes);
   1.489          }
   1.490      }
   1.491  
   1.492 @@ -1003,13 +1001,13 @@
   1.493      this->info.wm_available = 1;
   1.494  
   1.495      /* Fill in the video hardware capabilities */
   1.496 -    DX5_UpdateVideoInfo (this);
   1.497 +    DX5_UpdateVideoInfo(this);
   1.498  
   1.499      return (0);
   1.500  }
   1.501  
   1.502  SDL_Rect **
   1.503 -DX5_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags)
   1.504 +DX5_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
   1.505  {
   1.506      int bpp;
   1.507  
   1.508 @@ -1038,12 +1036,12 @@
   1.509  }
   1.510  
   1.511  /* Various screen update functions available */
   1.512 -static void DX5_WindowUpdate (_THIS, int numrects, SDL_Rect * rects);
   1.513 -static void DX5_DirectUpdate (_THIS, int numrects, SDL_Rect * rects);
   1.514 +static void DX5_WindowUpdate(_THIS, int numrects, SDL_Rect * rects);
   1.515 +static void DX5_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
   1.516  
   1.517  SDL_Surface *
   1.518 -DX5_SetVideoMode (_THIS, SDL_Surface * current,
   1.519 -                  int width, int height, int bpp, Uint32 flags)
   1.520 +DX5_SetVideoMode(_THIS, SDL_Surface * current,
   1.521 +                 int width, int height, int bpp, Uint32 flags)
   1.522  {
   1.523      SDL_Surface *video;
   1.524      HRESULT result;
   1.525 @@ -1059,28 +1057,28 @@
   1.526  
   1.527      SDL_resizing = 1;
   1.528  #ifdef DDRAW_DEBUG
   1.529 -    fprintf (stderr, "Setting %dx%dx%d video mode\n", width, height, bpp);
   1.530 +    fprintf(stderr, "Setting %dx%dx%d video mode\n", width, height, bpp);
   1.531  #endif
   1.532      /* Clean up any previous DirectDraw surfaces */
   1.533      if (current->hwdata) {
   1.534 -        this->FreeHWSurface (this, current);
   1.535 +        this->FreeHWSurface(this, current);
   1.536          current->hwdata = NULL;
   1.537      }
   1.538      if (SDL_primary != NULL) {
   1.539 -        IDirectDrawSurface3_Release (SDL_primary);
   1.540 +        IDirectDrawSurface3_Release(SDL_primary);
   1.541          SDL_primary = NULL;
   1.542      }
   1.543  #ifndef NO_CHANGEDISPLAYSETTINGS
   1.544      /* Unset any previous OpenGL fullscreen mode */
   1.545      if ((current->flags & (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) ==
   1.546          (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) {
   1.547 -        ChangeDisplaySettings (NULL, 0);
   1.548 +        ChangeDisplaySettings(NULL, 0);
   1.549      }
   1.550  #endif
   1.551  
   1.552      /* Clean up any GL context that may be hanging around */
   1.553      if (current->flags & SDL_INTERNALOPENGL) {
   1.554 -        WIN_GL_ShutDown (this);
   1.555 +        WIN_GL_ShutDown(this);
   1.556      }
   1.557  
   1.558      /* If we are setting a GL mode, use GDI, not DirectX (yuck) */
   1.559 @@ -1119,10 +1117,10 @@
   1.560                  Bmask = 0x00000000;
   1.561                  break;
   1.562              }
   1.563 -            video = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0, bpp,
   1.564 -                                          Rmask, Gmask, Bmask, 0);
   1.565 +            video = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, bpp,
   1.566 +                                         Rmask, Gmask, Bmask, 0);
   1.567              if (video == NULL) {
   1.568 -                SDL_OutOfMemory ();
   1.569 +                SDL_OutOfMemory();
   1.570                  return (NULL);
   1.571              }
   1.572          }
   1.573 @@ -1131,7 +1129,7 @@
   1.574          video->flags = 0;       /* Clear flags */
   1.575          video->w = width;
   1.576          video->h = height;
   1.577 -        video->pitch = SDL_CalculatePitch (video);
   1.578 +        video->pitch = SDL_CalculatePitch(video);
   1.579  
   1.580  #ifndef NO_CHANGEDISPLAYSETTINGS
   1.581          /* Set fullscreen mode if appropriate.
   1.582 @@ -1144,8 +1142,8 @@
   1.583              DEVMODE settings;
   1.584              BOOL changed;
   1.585  
   1.586 -            SDL_memset (&settings, 0, sizeof (DEVMODE));
   1.587 -            settings.dmSize = sizeof (DEVMODE);
   1.588 +            SDL_memset(&settings, 0, sizeof(DEVMODE));
   1.589 +            settings.dmSize = sizeof(DEVMODE);
   1.590              settings.dmBitsPerPel = video->format->BitsPerPixel;
   1.591              settings.dmPelsWidth = width;
   1.592              settings.dmPelsHeight = height;
   1.593 @@ -1157,11 +1155,11 @@
   1.594                  settings.dmFields |= DM_DISPLAYFREQUENCY;
   1.595              }
   1.596              changed =
   1.597 -                (ChangeDisplaySettings (&settings, CDS_FULLSCREEN) ==
   1.598 +                (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) ==
   1.599                   DISP_CHANGE_SUCCESSFUL);
   1.600              if (!changed && (settings.dmFields & DM_DISPLAYFREQUENCY)) {
   1.601                  settings.dmFields &= ~DM_DISPLAYFREQUENCY;
   1.602 -                changed = (ChangeDisplaySettings (&settings, CDS_FULLSCREEN)
   1.603 +                changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN)
   1.604                             == DISP_CHANGE_SUCCESSFUL);
   1.605              }
   1.606              if (changed) {
   1.607 @@ -1171,7 +1169,7 @@
   1.608          }
   1.609  #endif /* !NO_CHANGEDISPLAYSETTINGS */
   1.610  
   1.611 -        style = GetWindowLong (SDL_Window, GWL_STYLE);
   1.612 +        style = GetWindowLong(SDL_Window, GWL_STYLE);
   1.613          style &= ~(resizestyle | WS_MAXIMIZE);
   1.614          if (video->flags & SDL_FULLSCREEN) {
   1.615              style &= ~windowstyle;
   1.616 @@ -1190,17 +1188,17 @@
   1.617                  }
   1.618              }
   1.619  #if WS_MAXIMIZE
   1.620 -            if (IsZoomed (SDL_Window))
   1.621 +            if (IsZoomed(SDL_Window))
   1.622                  style |= WS_MAXIMIZE;
   1.623  #endif
   1.624          }
   1.625  
   1.626          /* DJM: Don't piss of anyone who has setup his own window */
   1.627          if (!SDL_windowid)
   1.628 -            SetWindowLong (SDL_Window, GWL_STYLE, style);
   1.629 +            SetWindowLong(SDL_Window, GWL_STYLE, style);
   1.630  
   1.631          /* Resize the window (copied from SDL WinDIB driver) */
   1.632 -        if (!SDL_windowid && !IsZoomed (SDL_Window)) {
   1.633 +        if (!SDL_windowid && !IsZoomed(SDL_Window)) {
   1.634              RECT bounds;
   1.635              int x, y;
   1.636              HWND top;
   1.637 @@ -1209,14 +1207,14 @@
   1.638              const char *center = NULL;
   1.639  
   1.640              if (!SDL_windowX && !SDL_windowY) {
   1.641 -                window = SDL_getenv ("SDL_VIDEO_WINDOW_POS");
   1.642 -                center = SDL_getenv ("SDL_VIDEO_CENTERED");
   1.643 +                window = SDL_getenv("SDL_VIDEO_WINDOW_POS");
   1.644 +                center = SDL_getenv("SDL_VIDEO_CENTERED");
   1.645                  if (window) {
   1.646 -                    if (SDL_sscanf (window, "%d,%d", &x, &y) == 2) {
   1.647 +                    if (SDL_sscanf(window, "%d,%d", &x, &y) == 2) {
   1.648                          SDL_windowX = x;
   1.649                          SDL_windowY = y;
   1.650                      }
   1.651 -                    if (SDL_strcmp (window, "center") == 0) {
   1.652 +                    if (SDL_strcmp(window, "center") == 0) {
   1.653                          center = window;
   1.654                      }
   1.655                  }
   1.656 @@ -1227,17 +1225,17 @@
   1.657              bounds.top = SDL_windowY;
   1.658              bounds.right = SDL_windowX + video->w;
   1.659              bounds.bottom = SDL_windowY + video->h;
   1.660 -            AdjustWindowRectEx (&bounds,
   1.661 -                                GetWindowLong (SDL_Window, GWL_STYLE),
   1.662 -                                FALSE, 0);
   1.663 +            AdjustWindowRectEx(&bounds,
   1.664 +                               GetWindowLong(SDL_Window, GWL_STYLE),
   1.665 +                               FALSE, 0);
   1.666              width = bounds.right - bounds.left;
   1.667              height = bounds.bottom - bounds.top;
   1.668              if ((flags & SDL_FULLSCREEN)) {
   1.669 -                x = (GetSystemMetrics (SM_CXSCREEN) - width) / 2;
   1.670 -                y = (GetSystemMetrics (SM_CYSCREEN) - height) / 2;
   1.671 +                x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2;
   1.672 +                y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2;
   1.673              } else if (center) {
   1.674 -                x = (GetSystemMetrics (SM_CXSCREEN) - width) / 2;
   1.675 -                y = (GetSystemMetrics (SM_CYSCREEN) - height) / 2;
   1.676 +                x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2;
   1.677 +                y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2;
   1.678              } else if (SDL_windowX || SDL_windowY || window) {
   1.679                  x = bounds.left;
   1.680                  y = bounds.top;
   1.681 @@ -1250,17 +1248,17 @@
   1.682              } else {
   1.683                  top = HWND_NOTOPMOST;
   1.684              }
   1.685 -            SetWindowPos (SDL_Window, top, x, y, width, height, swp_flags);
   1.686 +            SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags);
   1.687              if (!(flags & SDL_FULLSCREEN)) {
   1.688                  SDL_windowX = SDL_bounds.left;
   1.689                  SDL_windowY = SDL_bounds.top;
   1.690              }
   1.691 -            SetForegroundWindow (SDL_Window);
   1.692 +            SetForegroundWindow(SDL_Window);
   1.693          }
   1.694          SDL_resizing = 0;
   1.695  
   1.696          /* Set up for OpenGL */
   1.697 -        if (WIN_GL_SetupWindow (this) < 0) {
   1.698 +        if (WIN_GL_SetupWindow(this) < 0) {
   1.699              return (NULL);
   1.700          }
   1.701          video->flags |= SDL_INTERNALOPENGL;
   1.702 @@ -1268,7 +1266,7 @@
   1.703      }
   1.704  
   1.705      /* Set the appropriate window style */
   1.706 -    style = GetWindowLong (SDL_Window, GWL_STYLE);
   1.707 +    style = GetWindowLong(SDL_Window, GWL_STYLE);
   1.708      style &= ~(resizestyle | WS_MAXIMIZE);
   1.709      if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) {
   1.710          style &= ~windowstyle;
   1.711 @@ -1285,13 +1283,13 @@
   1.712              }
   1.713          }
   1.714  #if WS_MAXIMIZE
   1.715 -        if (IsZoomed (SDL_Window))
   1.716 +        if (IsZoomed(SDL_Window))
   1.717              style |= WS_MAXIMIZE;
   1.718  #endif
   1.719      }
   1.720      /* DJM: Don't piss of anyone who has setup his own window */
   1.721      if (!SDL_windowid)
   1.722 -        SetWindowLong (SDL_Window, GWL_STYLE, style);
   1.723 +        SetWindowLong(SDL_Window, GWL_STYLE, style);
   1.724  
   1.725      /* Set DirectDraw sharing mode.. exclusive when fullscreen */
   1.726      if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) {
   1.727 @@ -1299,9 +1297,9 @@
   1.728      } else {
   1.729          sharemode = DDSCL_NORMAL;
   1.730      }
   1.731 -    result = IDirectDraw2_SetCooperativeLevel (ddraw2, SDL_Window, sharemode);
   1.732 +    result = IDirectDraw2_SetCooperativeLevel(ddraw2, SDL_Window, sharemode);
   1.733      if (result != DD_OK) {
   1.734 -        SetDDerror ("DirectDraw2::SetCooperativeLevel", result);
   1.735 +        SetDDerror("DirectDraw2::SetCooperativeLevel", result);
   1.736          return (NULL);
   1.737      }
   1.738  
   1.739 @@ -1314,17 +1312,17 @@
   1.740          /* Cover up desktop during mode change */
   1.741          bounds.left = 0;
   1.742          bounds.top = 0;
   1.743 -        bounds.right = GetSystemMetrics (SM_CXSCREEN);
   1.744 -        bounds.bottom = GetSystemMetrics (SM_CYSCREEN);
   1.745 -        AdjustWindowRectEx (&bounds, GetWindowLong (SDL_Window, GWL_STYLE),
   1.746 -                            FALSE, 0);
   1.747 -        SetWindowPos (SDL_Window, HWND_TOPMOST, bounds.left, bounds.top,
   1.748 -                      bounds.right - bounds.left,
   1.749 -                      bounds.bottom - bounds.top, SWP_NOCOPYBITS);
   1.750 -        ShowWindow (SDL_Window, SW_SHOW);
   1.751 -        while (GetForegroundWindow () != SDL_Window) {
   1.752 -            SetForegroundWindow (SDL_Window);
   1.753 -            SDL_Delay (100);
   1.754 +        bounds.right = GetSystemMetrics(SM_CXSCREEN);
   1.755 +        bounds.bottom = GetSystemMetrics(SM_CYSCREEN);
   1.756 +        AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE),
   1.757 +                           FALSE, 0);
   1.758 +        SetWindowPos(SDL_Window, HWND_TOPMOST, bounds.left, bounds.top,
   1.759 +                     bounds.right - bounds.left,
   1.760 +                     bounds.bottom - bounds.top, SWP_NOCOPYBITS);
   1.761 +        ShowWindow(SDL_Window, SW_SHOW);
   1.762 +        while (GetForegroundWindow() != SDL_Window) {
   1.763 +            SetForegroundWindow(SDL_Window);
   1.764 +            SDL_Delay(100);
   1.765          }
   1.766  
   1.767          /* find maximum monitor refresh rate for this resolution */
   1.768 @@ -1337,16 +1335,15 @@
   1.769              }
   1.770          }
   1.771  #ifdef DDRAW_DEBUG
   1.772 -        fprintf (stderr, "refresh rate = %d Hz\n", maxRefreshRate);
   1.773 +        fprintf(stderr, "refresh rate = %d Hz\n", maxRefreshRate);
   1.774  #endif
   1.775  
   1.776          result =
   1.777 -            IDirectDraw2_SetDisplayMode (ddraw2, width, height, bpp,
   1.778 -                                         maxRefreshRate, 0);
   1.779 +            IDirectDraw2_SetDisplayMode(ddraw2, width, height, bpp,
   1.780 +                                        maxRefreshRate, 0);
   1.781          if (result != DD_OK) {
   1.782              result =
   1.783 -                IDirectDraw2_SetDisplayMode (ddraw2, width, height, bpp,
   1.784 -                                             0, 0);
   1.785 +                IDirectDraw2_SetDisplayMode(ddraw2, width, height, bpp, 0, 0);
   1.786              if (result != DD_OK) {
   1.787                  /* We couldn't set fullscreen mode, try window */
   1.788                  return (DX5_SetVideoMode
   1.789 @@ -1354,15 +1351,15 @@
   1.790                           flags & ~SDL_FULLSCREEN));
   1.791              }
   1.792          }
   1.793 -        DX5_DInputReset (this, 1);
   1.794 +        DX5_DInputReset(this, 1);
   1.795      } else {
   1.796 -        DX5_DInputReset (this, 0);
   1.797 +        DX5_DInputReset(this, 0);
   1.798      }
   1.799 -    DX5_UpdateVideoInfo (this);
   1.800 +    DX5_UpdateVideoInfo(this);
   1.801  
   1.802      /* Create a primary DirectDraw surface */
   1.803 -    SDL_memset (&ddsd, 0, sizeof (ddsd));
   1.804 -    ddsd.dwSize = sizeof (ddsd);
   1.805 +    SDL_memset(&ddsd, 0, sizeof(ddsd));
   1.806 +    ddsd.dwSize = sizeof(ddsd);
   1.807      ddsd.dwFlags = DDSD_CAPS;
   1.808      ddsd.ddsCaps.dwCaps = (DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY);
   1.809      if ((flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) {
   1.810 @@ -1374,44 +1371,44 @@
   1.811          ddsd.ddsCaps.dwCaps |= (DDSCAPS_COMPLEX | DDSCAPS_FLIP);
   1.812          ddsd.dwBackBufferCount = 1;
   1.813      }
   1.814 -    result = IDirectDraw2_CreateSurface (ddraw2, &ddsd, &dd_surface1, NULL);
   1.815 +    result = IDirectDraw2_CreateSurface(ddraw2, &ddsd, &dd_surface1, NULL);
   1.816      if ((result != DD_OK) && ((flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF)) {
   1.817          ddsd.dwFlags &= ~DDSD_BACKBUFFERCOUNT;
   1.818          ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_COMPLEX | DDSCAPS_FLIP);
   1.819          ddsd.dwBackBufferCount = 0;
   1.820 -        result = IDirectDraw2_CreateSurface (ddraw2,
   1.821 -                                             &ddsd, &dd_surface1, NULL);
   1.822 +        result = IDirectDraw2_CreateSurface(ddraw2,
   1.823 +                                            &ddsd, &dd_surface1, NULL);
   1.824      }
   1.825      if (result != DD_OK) {
   1.826 -        SetDDerror ("DirectDraw2::CreateSurface(PRIMARY)", result);
   1.827 +        SetDDerror("DirectDraw2::CreateSurface(PRIMARY)", result);
   1.828          return (NULL);
   1.829      }
   1.830 -    result = IDirectDrawSurface_QueryInterface (dd_surface1,
   1.831 -                                                &IID_IDirectDrawSurface3,
   1.832 -                                                (LPVOID *) & SDL_primary);
   1.833 +    result = IDirectDrawSurface_QueryInterface(dd_surface1,
   1.834 +                                               &IID_IDirectDrawSurface3,
   1.835 +                                               (LPVOID *) & SDL_primary);
   1.836      if (result != DD_OK) {
   1.837 -        SetDDerror ("DirectDrawSurface::QueryInterface", result);
   1.838 +        SetDDerror("DirectDrawSurface::QueryInterface", result);
   1.839          return (NULL);
   1.840      }
   1.841 -    IDirectDrawSurface_Release (dd_surface1);
   1.842 +    IDirectDrawSurface_Release(dd_surface1);
   1.843  
   1.844      /* Get the format of the primary DirectDraw surface */
   1.845 -    SDL_memset (&ddsd, 0, sizeof (ddsd));
   1.846 -    ddsd.dwSize = sizeof (ddsd);
   1.847 +    SDL_memset(&ddsd, 0, sizeof(ddsd));
   1.848 +    ddsd.dwSize = sizeof(ddsd);
   1.849      ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_CAPS;
   1.850 -    result = IDirectDrawSurface3_GetSurfaceDesc (SDL_primary, &ddsd);
   1.851 +    result = IDirectDrawSurface3_GetSurfaceDesc(SDL_primary, &ddsd);
   1.852      if (result != DD_OK) {
   1.853 -        SetDDerror ("DirectDrawSurface::GetSurfaceDesc", result);
   1.854 +        SetDDerror("DirectDrawSurface::GetSurfaceDesc", result);
   1.855          return (NULL);
   1.856      }
   1.857      if (!(ddsd.ddpfPixelFormat.dwFlags & DDPF_RGB)) {
   1.858 -        SDL_SetError ("Primary DDRAW surface is not RGB format");
   1.859 +        SDL_SetError("Primary DDRAW surface is not RGB format");
   1.860          return (NULL);
   1.861      }
   1.862  
   1.863      /* Free old palette and create a new one if we're in 8-bit mode */
   1.864      if (SDL_palette != NULL) {
   1.865 -        IDirectDrawPalette_Release (SDL_palette);
   1.866 +        IDirectDrawPalette_Release(SDL_palette);
   1.867          SDL_palette = NULL;
   1.868      }
   1.869  #if defined(NONAMELESSUNION)
   1.870 @@ -1451,17 +1448,17 @@
   1.871                  SDL_colors[i].peBlue = 0;
   1.872              }
   1.873          }
   1.874 -        result = IDirectDraw2_CreatePalette (ddraw2,
   1.875 -                                             (DDPCAPS_8BIT |
   1.876 -                                              DDPCAPS_ALLOW256), SDL_colors,
   1.877 -                                             &SDL_palette, NULL);
   1.878 +        result = IDirectDraw2_CreatePalette(ddraw2,
   1.879 +                                            (DDPCAPS_8BIT |
   1.880 +                                             DDPCAPS_ALLOW256), SDL_colors,
   1.881 +                                            &SDL_palette, NULL);
   1.882          if (result != DD_OK) {
   1.883 -            SetDDerror ("DirectDraw2::CreatePalette", result);
   1.884 +            SetDDerror("DirectDraw2::CreatePalette", result);
   1.885              return (NULL);
   1.886          }
   1.887 -        result = IDirectDrawSurface3_SetPalette (SDL_primary, SDL_palette);
   1.888 +        result = IDirectDrawSurface3_SetPalette(SDL_primary, SDL_palette);
   1.889          if (result != DD_OK) {
   1.890 -            SetDDerror ("DirectDrawSurface3::SetPalette", result);
   1.891 +            SetDDerror("DirectDrawSurface3::SetPalette", result);
   1.892              return (NULL);
   1.893          }
   1.894      }
   1.895 @@ -1475,22 +1472,22 @@
   1.896  #else
   1.897              ddsd.ddpfPixelFormat.dwRGBBitCount)) {
   1.898  #endif
   1.899 -        SDL_FreeSurface (video);
   1.900 -        video = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0,
   1.901 +        SDL_FreeSurface(video);
   1.902 +        video = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0,
   1.903  #if defined(NONAMELESSUNION)
   1.904 -                                      ddsd.ddpfPixelFormat.u1.dwRGBBitCount,
   1.905 -                                      ddsd.ddpfPixelFormat.u2.dwRBitMask,
   1.906 -                                      ddsd.ddpfPixelFormat.u3.dwGBitMask,
   1.907 -                                      ddsd.ddpfPixelFormat.u4.dwBBitMask,
   1.908 +                                     ddsd.ddpfPixelFormat.u1.dwRGBBitCount,
   1.909 +                                     ddsd.ddpfPixelFormat.u2.dwRBitMask,
   1.910 +                                     ddsd.ddpfPixelFormat.u3.dwGBitMask,
   1.911 +                                     ddsd.ddpfPixelFormat.u4.dwBBitMask,
   1.912  #else
   1.913 -                                      ddsd.ddpfPixelFormat.dwRGBBitCount,
   1.914 -                                      ddsd.ddpfPixelFormat.dwRBitMask,
   1.915 -                                      ddsd.ddpfPixelFormat.dwGBitMask,
   1.916 -                                      ddsd.ddpfPixelFormat.dwBBitMask,
   1.917 +                                     ddsd.ddpfPixelFormat.dwRGBBitCount,
   1.918 +                                     ddsd.ddpfPixelFormat.dwRBitMask,
   1.919 +                                     ddsd.ddpfPixelFormat.dwGBitMask,
   1.920 +                                     ddsd.ddpfPixelFormat.dwBBitMask,
   1.921  #endif
   1.922 -                                      0);
   1.923 +                                     0);
   1.924          if (video == NULL) {
   1.925 -            SDL_OutOfMemory ();
   1.926 +            SDL_OutOfMemory();
   1.927              return (NULL);
   1.928          }
   1.929          video->w = width;
   1.930 @@ -1520,12 +1517,12 @@
   1.931              video->pitch = (width * video->format->BytesPerPixel);
   1.932              /* Pitch needs to be QWORD (8-byte) aligned */
   1.933              video->pitch = (video->pitch + 7) & ~7;
   1.934 -            video->pixels = (void *) SDL_malloc (video->h * video->pitch);
   1.935 +            video->pixels = (void *) SDL_malloc(video->h * video->pitch);
   1.936              if (video->pixels == NULL) {
   1.937                  if (video != current) {
   1.938 -                    SDL_FreeSurface (video);
   1.939 +                    SDL_FreeSurface(video);
   1.940                  }
   1.941 -                SDL_OutOfMemory ();
   1.942 +                SDL_OutOfMemory();
   1.943                  return (NULL);
   1.944              }
   1.945          }
   1.946 @@ -1548,7 +1545,7 @@
   1.947      } else {
   1.948          /* Necessary if we're going from window to fullscreen */
   1.949          if (video->pixels != NULL) {
   1.950 -            SDL_free (video->pixels);
   1.951 +            SDL_free(video->pixels);
   1.952              video->pixels = NULL;
   1.953          }
   1.954          dd_surface3 = SDL_primary;
   1.955 @@ -1561,10 +1558,10 @@
   1.956      }
   1.957  
   1.958      /* Allocate the SDL surface associated with the primary surface */
   1.959 -    if (DX5_AllocDDSurface (this, video, dd_surface3,
   1.960 -                            video->flags & SDL_HWSURFACE) < 0) {
   1.961 +    if (DX5_AllocDDSurface(this, video, dd_surface3,
   1.962 +                           video->flags & SDL_HWSURFACE) < 0) {
   1.963          if (video != current) {
   1.964 -            SDL_FreeSurface (video);
   1.965 +            SDL_FreeSurface(video);
   1.966          }
   1.967          return (NULL);
   1.968      }
   1.969 @@ -1584,35 +1581,35 @@
   1.970      if ((flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) {
   1.971          /* Create and set a clipper on our primary surface */
   1.972          if (SDL_clipper == NULL) {
   1.973 -            result = IDirectDraw2_CreateClipper (ddraw2,
   1.974 -                                                 0, &SDL_clipper, NULL);
   1.975 +            result = IDirectDraw2_CreateClipper(ddraw2,
   1.976 +                                                0, &SDL_clipper, NULL);
   1.977              if (result != DD_OK) {
   1.978                  if (video != current) {
   1.979 -                    SDL_FreeSurface (video);
   1.980 +                    SDL_FreeSurface(video);
   1.981                  }
   1.982 -                SetDDerror ("DirectDraw2::CreateClipper", result);
   1.983 +                SetDDerror("DirectDraw2::CreateClipper", result);
   1.984                  return (NULL);
   1.985              }
   1.986          }
   1.987 -        result = IDirectDrawClipper_SetHWnd (SDL_clipper, 0, SDL_Window);
   1.988 +        result = IDirectDrawClipper_SetHWnd(SDL_clipper, 0, SDL_Window);
   1.989          if (result != DD_OK) {
   1.990              if (video != current) {
   1.991 -                SDL_FreeSurface (video);
   1.992 +                SDL_FreeSurface(video);
   1.993              }
   1.994 -            SetDDerror ("DirectDrawClipper::SetHWnd", result);
   1.995 +            SetDDerror("DirectDrawClipper::SetHWnd", result);
   1.996              return (NULL);
   1.997          }
   1.998 -        result = IDirectDrawSurface3_SetClipper (SDL_primary, SDL_clipper);
   1.999 +        result = IDirectDrawSurface3_SetClipper(SDL_primary, SDL_clipper);
  1.1000          if (result != DD_OK) {
  1.1001              if (video != current) {
  1.1002 -                SDL_FreeSurface (video);
  1.1003 +                SDL_FreeSurface(video);
  1.1004              }
  1.1005 -            SetDDerror ("DirectDrawSurface3::SetClipper", result);
  1.1006 +            SetDDerror("DirectDrawSurface3::SetClipper", result);
  1.1007              return (NULL);
  1.1008          }
  1.1009  
  1.1010          /* Resize the window (copied from SDL WinDIB driver) */
  1.1011 -        if (!SDL_windowid && !IsZoomed (SDL_Window)) {
  1.1012 +        if (!SDL_windowid && !IsZoomed(SDL_Window)) {
  1.1013              RECT bounds;
  1.1014              int x, y;
  1.1015              UINT swp_flags;
  1.1016 @@ -1620,14 +1617,14 @@
  1.1017              const char *center = NULL;
  1.1018  
  1.1019              if (!SDL_windowX && !SDL_windowY) {
  1.1020 -                window = SDL_getenv ("SDL_VIDEO_WINDOW_POS");
  1.1021 -                center = SDL_getenv ("SDL_VIDEO_CENTERED");
  1.1022 +                window = SDL_getenv("SDL_VIDEO_WINDOW_POS");
  1.1023 +                center = SDL_getenv("SDL_VIDEO_CENTERED");
  1.1024                  if (window) {
  1.1025 -                    if (SDL_sscanf (window, "%d,%d", &x, &y) == 2) {
  1.1026 +                    if (SDL_sscanf(window, "%d,%d", &x, &y) == 2) {
  1.1027                          SDL_windowX = x;
  1.1028                          SDL_windowY = y;
  1.1029                      }
  1.1030 -                    if (SDL_strcmp (window, "center") == 0) {
  1.1031 +                    if (SDL_strcmp(window, "center") == 0) {
  1.1032                          center = window;
  1.1033                      }
  1.1034                  }
  1.1035 @@ -1638,14 +1635,14 @@
  1.1036              bounds.top = SDL_windowY;
  1.1037              bounds.right = SDL_windowX + video->w;
  1.1038              bounds.bottom = SDL_windowY + video->h;
  1.1039 -            AdjustWindowRectEx (&bounds,
  1.1040 -                                GetWindowLong (SDL_Window, GWL_STYLE),
  1.1041 -                                FALSE, 0);
  1.1042 +            AdjustWindowRectEx(&bounds,
  1.1043 +                               GetWindowLong(SDL_Window, GWL_STYLE),
  1.1044 +                               FALSE, 0);
  1.1045              width = bounds.right - bounds.left;
  1.1046              height = bounds.bottom - bounds.top;
  1.1047              if (center) {
  1.1048 -                x = (GetSystemMetrics (SM_CXSCREEN) - width) / 2;
  1.1049 -                y = (GetSystemMetrics (SM_CYSCREEN) - height) / 2;
  1.1050 +                x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2;
  1.1051 +                y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2;
  1.1052              } else if (SDL_windowX || SDL_windowY || window) {
  1.1053                  x = bounds.left;
  1.1054                  y = bounds.top;
  1.1055 @@ -1653,22 +1650,22 @@
  1.1056                  x = y = -1;
  1.1057                  swp_flags |= SWP_NOMOVE;
  1.1058              }
  1.1059 -            SetWindowPos (SDL_Window, HWND_NOTOPMOST, x, y, width, height,
  1.1060 -                          swp_flags);
  1.1061 +            SetWindowPos(SDL_Window, HWND_NOTOPMOST, x, y, width, height,
  1.1062 +                         swp_flags);
  1.1063              SDL_windowX = SDL_bounds.left;
  1.1064              SDL_windowY = SDL_bounds.top;
  1.1065          }
  1.1066  
  1.1067      }
  1.1068 -    ShowWindow (SDL_Window, SW_SHOW);
  1.1069 -    SetForegroundWindow (SDL_Window);
  1.1070 +    ShowWindow(SDL_Window, SW_SHOW);
  1.1071 +    SetForegroundWindow(SDL_Window);
  1.1072      SDL_resizing = 0;
  1.1073  
  1.1074      /* JC 14 Mar 2006
  1.1075         Flush the message loop or this can cause big problems later
  1.1076         Especially if the user decides to use dialog boxes or assert()!
  1.1077       */
  1.1078 -    WIN_FlushMessageQueue ();
  1.1079 +    WIN_FlushMessageQueue();
  1.1080  
  1.1081      /* We're live! */
  1.1082      return (video);
  1.1083 @@ -1681,8 +1678,8 @@
  1.1084  };
  1.1085  
  1.1086  static int
  1.1087 -DX5_AllocDDSurface (_THIS, SDL_Surface * surface,
  1.1088 -                    LPDIRECTDRAWSURFACE3 requested, Uint32 flag)
  1.1089 +DX5_AllocDDSurface(_THIS, SDL_Surface * surface,
  1.1090 +                   LPDIRECTDRAWSURFACE3 requested, Uint32 flag)
  1.1091  {
  1.1092      LPDIRECTDRAWSURFACE dd_surface1;
  1.1093      LPDIRECTDRAWSURFACE3 dd_surface3;
  1.1094 @@ -1694,16 +1691,16 @@
  1.1095  
  1.1096      /* Allocate the hardware acceleration data */
  1.1097      surface->hwdata = (struct private_hwdata *)
  1.1098 -        SDL_malloc (sizeof (*surface->hwdata));
  1.1099 +        SDL_malloc(sizeof(*surface->hwdata));
  1.1100      if (surface->hwdata == NULL) {
  1.1101 -        SDL_OutOfMemory ();
  1.1102 +        SDL_OutOfMemory();
  1.1103          return (-1);
  1.1104      }
  1.1105      dd_surface3 = NULL;
  1.1106  
  1.1107      /* Set up the surface description */
  1.1108 -    SDL_memset (&ddsd, 0, sizeof (ddsd));
  1.1109 -    ddsd.dwSize = sizeof (ddsd);
  1.1110 +    SDL_memset(&ddsd, 0, sizeof(ddsd));
  1.1111 +    ddsd.dwSize = sizeof(ddsd);
  1.1112      ddsd.dwFlags = (DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS |
  1.1113                      DDSD_PITCH | DDSD_PIXELFORMAT);
  1.1114      ddsd.dwWidth = surface->w;
  1.1115 @@ -1718,7 +1715,7 @@
  1.1116      } else {
  1.1117          ddsd.ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY);
  1.1118      }
  1.1119 -    ddsd.ddpfPixelFormat.dwSize = sizeof (ddsd.ddpfPixelFormat);
  1.1120 +    ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
  1.1121      ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
  1.1122      if (surface->format->palette) {
  1.1123          ddsd.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8;
  1.1124 @@ -1739,18 +1736,18 @@
  1.1125      if (requested != NULL) {
  1.1126          dd_surface3 = requested;
  1.1127      } else {
  1.1128 -        result = IDirectDraw2_CreateSurface (ddraw2,
  1.1129 -                                             &ddsd, &dd_surface1, NULL);
  1.1130 +        result = IDirectDraw2_CreateSurface(ddraw2,
  1.1131 +                                            &ddsd, &dd_surface1, NULL);
  1.1132          if (result != DD_OK) {
  1.1133 -            SetDDerror ("DirectDraw2::CreateSurface", result);
  1.1134 +            SetDDerror("DirectDraw2::CreateSurface", result);
  1.1135              goto error_end;
  1.1136          }
  1.1137 -        result = IDirectDrawSurface_QueryInterface (dd_surface1,
  1.1138 -                                                    &IID_IDirectDrawSurface3,
  1.1139 -                                                    (LPVOID *) & dd_surface3);
  1.1140 -        IDirectDrawSurface_Release (dd_surface1);
  1.1141 +        result = IDirectDrawSurface_QueryInterface(dd_surface1,
  1.1142 +                                                   &IID_IDirectDrawSurface3,
  1.1143 +                                                   (LPVOID *) & dd_surface3);
  1.1144 +        IDirectDrawSurface_Release(dd_surface1);
  1.1145          if (result != DD_OK) {
  1.1146 -            SetDDerror ("DirectDrawSurface::QueryInterface", result);
  1.1147 +            SetDDerror("DirectDrawSurface::QueryInterface", result);
  1.1148              goto error_end;
  1.1149          }
  1.1150      }
  1.1151 @@ -1760,44 +1757,43 @@
  1.1152             in video memory, and fail if not.  We expect the
  1.1153             surfaces we create here to actually be in hardware!
  1.1154           */
  1.1155 -        result = IDirectDrawSurface3_GetCaps (dd_surface3, &ddsd.ddsCaps);
  1.1156 +        result = IDirectDrawSurface3_GetCaps(dd_surface3, &ddsd.ddsCaps);
  1.1157          if (result != DD_OK) {
  1.1158 -            SetDDerror ("DirectDrawSurface3::GetCaps", result);
  1.1159 +            SetDDerror("DirectDrawSurface3::GetCaps", result);
  1.1160              goto error_end;
  1.1161          }
  1.1162          if ((ddsd.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY) !=
  1.1163              DDSCAPS_VIDEOMEMORY) {
  1.1164 -            SDL_SetError ("No room in video memory");
  1.1165 +            SDL_SetError("No room in video memory");
  1.1166              goto error_end;
  1.1167          }
  1.1168      } else {
  1.1169          /* Try to hook our surface memory */
  1.1170          ddsd.dwFlags = DDSD_LPSURFACE;
  1.1171          ddsd.lpSurface = surface->pixels;
  1.1172 -        result = IDirectDrawSurface3_SetSurfaceDesc (dd_surface3, &ddsd, 0);
  1.1173 +        result = IDirectDrawSurface3_SetSurfaceDesc(dd_surface3, &ddsd, 0);
  1.1174          if (result != DD_OK) {
  1.1175 -            SetDDerror ("DirectDraw2::SetSurfaceDesc", result);
  1.1176 +            SetDDerror("DirectDraw2::SetSurfaceDesc", result);
  1.1177              goto error_end;
  1.1178          }
  1.1179  
  1.1180      }
  1.1181  
  1.1182      /* Make sure the surface format was set properly */
  1.1183 -    SDL_memset (&ddsd, 0, sizeof (ddsd));
  1.1184 -    ddsd.dwSize = sizeof (ddsd);
  1.1185 -    result = IDirectDrawSurface3_Lock (dd_surface3, NULL,
  1.1186 -                                       &ddsd,
  1.1187 -                                       (DDLOCK_NOSYSLOCK | DDLOCK_WAIT),
  1.1188 -                                       NULL);
  1.1189 +    SDL_memset(&ddsd, 0, sizeof(ddsd));
  1.1190 +    ddsd.dwSize = sizeof(ddsd);
  1.1191 +    result = IDirectDrawSurface3_Lock(dd_surface3, NULL,
  1.1192 +                                      &ddsd,
  1.1193 +                                      (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), NULL);
  1.1194      if (result != DD_OK) {
  1.1195 -        SetDDerror ("DirectDrawSurface3::Lock", result);
  1.1196 +        SetDDerror("DirectDrawSurface3::Lock", result);
  1.1197          goto error_end;
  1.1198      }
  1.1199 -    IDirectDrawSurface3_Unlock (dd_surface3, NULL);
  1.1200 +    IDirectDrawSurface3_Unlock(dd_surface3, NULL);
  1.1201  
  1.1202      if ((flag & SDL_HWSURFACE) == SDL_SWSURFACE) {
  1.1203          if (ddsd.lpSurface != surface->pixels) {
  1.1204 -            SDL_SetError ("DDraw didn't use SDL surface memory");
  1.1205 +            SDL_SetError("DDraw didn't use SDL surface memory");
  1.1206              goto error_end;
  1.1207          }
  1.1208          if (
  1.1209 @@ -1807,7 +1803,7 @@
  1.1210                 ddsd.lPitch
  1.1211  #endif
  1.1212                 != (LONG) surface->pitch) {
  1.1213 -            SDL_SetError ("DDraw created surface with wrong pitch");
  1.1214 +            SDL_SetError("DDraw created surface with wrong pitch");
  1.1215              goto error_end;
  1.1216          }
  1.1217      } else {
  1.1218 @@ -1830,12 +1826,12 @@
  1.1219          (ddsd.ddpfPixelFormat.dwGBitMask != surface->format->Gmask) ||
  1.1220          (ddsd.ddpfPixelFormat.dwBBitMask != surface->format->Bmask)) {
  1.1221  #endif
  1.1222 -        SDL_SetError ("DDraw didn't use SDL surface description");
  1.1223 +        SDL_SetError("DDraw didn't use SDL surface description");
  1.1224          goto error_end;
  1.1225      }
  1.1226      if ((ddsd.dwWidth != (DWORD) surface->w) ||
  1.1227          (ddsd.dwHeight != (DWORD) surface->h)) {
  1.1228 -        SDL_SetError ("DDraw created surface with wrong size");
  1.1229 +        SDL_SetError("DDraw created surface with wrong size");
  1.1230          goto error_end;
  1.1231      }
  1.1232  
  1.1233 @@ -1846,11 +1842,11 @@
  1.1234          LPDIRECTDRAWSURFACE3 dd_writebuf;
  1.1235  
  1.1236          ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
  1.1237 -        result = IDirectDrawSurface3_GetAttachedSurface (dd_surface3,
  1.1238 -                                                         &ddsd.ddsCaps,
  1.1239 -                                                         &dd_writebuf);
  1.1240 +        result = IDirectDrawSurface3_GetAttachedSurface(dd_surface3,
  1.1241 +                                                        &ddsd.ddsCaps,
  1.1242 +                                                        &dd_writebuf);
  1.1243          if (result != DD_OK) {
  1.1244 -            SetDDerror ("DirectDrawSurface3::GetAttachedSurface", result);
  1.1245 +            SetDDerror("DirectDrawSurface3::GetAttachedSurface", result);
  1.1246          } else {
  1.1247              dd_surface3 = dd_writebuf;
  1.1248          }
  1.1249 @@ -1867,65 +1863,64 @@
  1.1250       */
  1.1251    error_end:
  1.1252      if ((dd_surface3 != NULL) && (dd_surface3 != requested)) {
  1.1253 -        IDirectDrawSurface_Release (dd_surface3);
  1.1254 +        IDirectDrawSurface_Release(dd_surface3);
  1.1255      }
  1.1256 -    SDL_free (surface->hwdata);
  1.1257 +    SDL_free(surface->hwdata);
  1.1258      surface->hwdata = NULL;
  1.1259      return (-1);
  1.1260  }
  1.1261  
  1.1262  static int
  1.1263 -DX5_AllocHWSurface (_THIS, SDL_Surface * surface)
  1.1264 +DX5_AllocHWSurface(_THIS, SDL_Surface * surface)
  1.1265  {
  1.1266      /* DDraw limitation -- you need to set cooperative level first */
  1.1267      if (SDL_primary == NULL) {
  1.1268 -        SDL_SetError ("You must set a non-GL video mode first");
  1.1269 +        SDL_SetError("You must set a non-GL video mode first");
  1.1270          return (-1);
  1.1271      }
  1.1272 -    return (DX5_AllocDDSurface (this, surface, NULL, SDL_HWSURFACE));
  1.1273 +    return (DX5_AllocDDSurface(this, surface, NULL, SDL_HWSURFACE));
  1.1274  }
  1.1275  
  1.1276  #ifdef DDRAW_DEBUG
  1.1277  void
  1.1278 -PrintSurface (char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags)
  1.1279 +PrintSurface(char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags)
  1.1280  {
  1.1281      DDSURFACEDESC ddsd;
  1.1282  
  1.1283      /* Lock and load! */
  1.1284 -    SDL_memset (&ddsd, 0, sizeof (ddsd));
  1.1285 -    ddsd.dwSize = sizeof (ddsd);
  1.1286 -    if (IDirectDrawSurface3_Lock (surface, NULL, &ddsd,
  1.1287 -                                  (DDLOCK_NOSYSLOCK | DDLOCK_WAIT),
  1.1288 -                                  NULL) != DD_OK) {
  1.1289 +    SDL_memset(&ddsd, 0, sizeof(ddsd));
  1.1290 +    ddsd.dwSize = sizeof(ddsd);
  1.1291 +    if (IDirectDrawSurface3_Lock(surface, NULL, &ddsd,
  1.1292 +                                 (DDLOCK_NOSYSLOCK | DDLOCK_WAIT),
  1.1293 +                                 NULL) != DD_OK) {
  1.1294          return;
  1.1295      }
  1.1296 -    IDirectDrawSurface3_Unlock (surface, NULL);
  1.1297 +    IDirectDrawSurface3_Unlock(surface, NULL);
  1.1298  
  1.1299 -    fprintf (stderr, "%s:\n", title);
  1.1300 -    fprintf (stderr, "\tSize: %dx%d in %s at %ld bpp (pitch = %ld)\n",
  1.1301 -             ddsd.dwWidth, ddsd.dwHeight,
  1.1302 -             (flags & SDL_HWSURFACE) ? "hardware" : "software",
  1.1303 +    fprintf(stderr, "%s:\n", title);
  1.1304 +    fprintf(stderr, "\tSize: %dx%d in %s at %ld bpp (pitch = %ld)\n",
  1.1305 +            ddsd.dwWidth, ddsd.dwHeight,
  1.1306 +            (flags & SDL_HWSURFACE) ? "hardware" : "software",
  1.1307  #if defined(NONAMELESSUNION)
  1.1308 -             ddsd.ddpfPixelFormat.u1.dwRGBBitCount, ddsd.u1.lPitch);
  1.1309 +            ddsd.ddpfPixelFormat.u1.dwRGBBitCount, ddsd.u1.lPitch);
  1.1310  #else
  1.1311 -             ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.lPitch);
  1.1312 +            ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.lPitch);
  1.1313  #endif
  1.1314 -    fprintf (stderr, "\tR = 0x%X, G = 0x%X, B = 0x%X\n",
  1.1315 +    fprintf(stderr, "\tR = 0x%X, G = 0x%X, B = 0x%X\n",
  1.1316  #if defined(NONAMELESSUNION)
  1.1317 -             ddsd.ddpfPixelFormat.u2.dwRBitMask,
  1.1318 -             ddsd.ddpfPixelFormat.u3.dwGBitMask,
  1.1319 -             ddsd.ddpfPixelFormat.u4.dwBBitMask);
  1.1320 +            ddsd.ddpfPixelFormat.u2.dwRBitMask,
  1.1321 +            ddsd.ddpfPixelFormat.u3.dwGBitMask,
  1.1322 +            ddsd.ddpfPixelFormat.u4.dwBBitMask);
  1.1323  #else
  1.1324 -             ddsd.ddpfPixelFormat.dwRBitMask,
  1.1325 -             ddsd.ddpfPixelFormat.dwGBitMask,
  1.1326 -             ddsd.ddpfPixelFormat.dwBBitMask);
  1.1327 +            ddsd.ddpfPixelFormat.dwRBitMask,
  1.1328 +            ddsd.ddpfPixelFormat.dwGBitMask, ddsd.ddpfPixelFormat.dwBBitMask);
  1.1329  #endif
  1.1330  }
  1.1331  #endif /* DDRAW_DEBUG */
  1.1332  
  1.1333  static int
  1.1334 -DX5_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect,
  1.1335 -                 SDL_Surface * dst, SDL_Rect * dstrect)
  1.1336 +DX5_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
  1.1337 +                SDL_Surface * dst, SDL_Rect * dstrect)
  1.1338  {
  1.1339      LPDIRECTDRAWSURFACE3 src_surface;
  1.1340      LPDIRECTDRAWSURFACE3 dst_surface;
  1.1341 @@ -1950,38 +1945,38 @@
  1.1342      flags |= DDBLTFAST_WAIT;
  1.1343  
  1.1344      /* Do the blit! */
  1.1345 -    result = IDirectDrawSurface3_BltFast (dst_surface,
  1.1346 -                                          dstrect->x, dstrect->y, src_surface,
  1.1347 -                                          &rect, flags);
  1.1348 +    result = IDirectDrawSurface3_BltFast(dst_surface,
  1.1349 +                                         dstrect->x, dstrect->y, src_surface,
  1.1350 +                                         &rect, flags);
  1.1351      if (result != DD_OK) {
  1.1352          if (result == DDERR_SURFACELOST) {
  1.1353 -            result = IDirectDrawSurface3_Restore (src_surface);
  1.1354 -            result = IDirectDrawSurface3_Restore (dst_surface);
  1.1355 +            result = IDirectDrawSurface3_Restore(src_surface);
  1.1356 +            result = IDirectDrawSurface3_Restore(dst_surface);
  1.1357              /* The surfaces need to be reloaded with artwork */
  1.1358 -            SDL_SetError ("Blit surfaces were lost, reload them");
  1.1359 +            SDL_SetError("Blit surfaces were lost, reload them");
  1.1360              return (-2);
  1.1361          }
  1.1362 -        SetDDerror ("IDirectDrawSurface3::BltFast", result);
  1.1363 +        SetDDerror("IDirectDrawSurface3::BltFast", result);
  1.1364  #ifdef DDRAW_DEBUG
  1.1365 -        fprintf (stderr, "Original dest rect: %dx%d at %d,%d\n", dstrect->w,
  1.1366 -                 dstrect->h, dstrect->x, dstrect->y);
  1.1367 -        fprintf (stderr,
  1.1368 -                 "HW accelerated %sblit to from 0x%p to 0x%p at (%d,%d)\n",
  1.1369 -                 (src->flags & SDL_SRCCOLORKEY) ? "colorkey " : "", src,
  1.1370 -                 dst, dstrect->x, dstrect->y);
  1.1371 -        PrintSurface ("SRC", src_surface, src->flags);
  1.1372 -        PrintSurface ("DST", dst_surface, dst->flags);
  1.1373 -        fprintf (stderr, "Source rectangle: (%d,%d) - (%d,%d)\n",
  1.1374 -                 rect.left, rect.top, rect.right, rect.bottom);
  1.1375 +        fprintf(stderr, "Original dest rect: %dx%d at %d,%d\n", dstrect->w,
  1.1376 +                dstrect->h, dstrect->x, dstrect->y);
  1.1377 +        fprintf(stderr,
  1.1378 +                "HW accelerated %sblit to from 0x%p to 0x%p at (%d,%d)\n",
  1.1379 +                (src->flags & SDL_SRCCOLORKEY) ? "colorkey " : "", src,
  1.1380 +                dst, dstrect->x, dstrect->y);
  1.1381 +        PrintSurface("SRC", src_surface, src->flags);
  1.1382 +        PrintSurface("DST", dst_surface, dst->flags);
  1.1383 +        fprintf(stderr, "Source rectangle: (%d,%d) - (%d,%d)\n",
  1.1384 +                rect.left, rect.top, rect.right, rect.bottom);
  1.1385  #endif
  1.1386          /* Unexpected error, fall back to software blit */
  1.1387 -        return (src->map->sw_blit (src, srcrect, dst, dstrect));
  1.1388 +        return (src->map->sw_blit(src, srcrect, dst, dstrect));
  1.1389      }
  1.1390      return (0);
  1.1391  }
  1.1392  
  1.1393  static int
  1.1394 -DX5_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst)
  1.1395 +DX5_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst)
  1.1396  {
  1.1397      int accelerated;
  1.1398  
  1.1399 @@ -1989,7 +1984,7 @@
  1.1400      if ((src->flags & SDL_HWSURFACE) == SDL_SWSURFACE) {
  1.1401          /* Allocate a DDraw surface for the blit */
  1.1402          if (src->hwdata == NULL) {
  1.1403 -            DX5_AllocDDSurface (this, src, NULL, SDL_SWSURFACE);
  1.1404 +            DX5_AllocDDSurface(this, src, NULL, SDL_SWSURFACE);
  1.1405          }
  1.1406      }
  1.1407      if (src->hwdata == NULL) {
  1.1408 @@ -2001,12 +1996,12 @@
  1.1409  
  1.1410      /* Set the surface attributes */
  1.1411      if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
  1.1412 -        if (DX5_SetHWColorKey (this, src, src->format->colorkey) < 0) {
  1.1413 +        if (DX5_SetHWColorKey(this, src, src->format->colorkey) < 0) {
  1.1414              src->flags &= ~SDL_HWACCEL;
  1.1415          }
  1.1416      }
  1.1417      if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
  1.1418 -        if (DX5_SetHWAlpha (this, src, src->format->alpha) < 0) {
  1.1419 +        if (DX5_SetHWAlpha(this, src, src->format->alpha) < 0) {
  1.1420              src->flags &= ~SDL_HWACCEL;
  1.1421          }
  1.1422      }
  1.1423 @@ -2015,7 +2010,7 @@
  1.1424      accelerated = !!(src->flags & SDL_HWACCEL);
  1.1425      if (accelerated) {
  1.1426  #ifdef DDRAW_DEBUG
  1.1427 -        fprintf (stderr, "Setting accelerated blit on 0x%p\n", src);
  1.1428 +        fprintf(stderr, "Setting accelerated blit on 0x%p\n", src);
  1.1429  #endif
  1.1430          src->map->hw_blit = DX5_HWAccelBlit;
  1.1431      }
  1.1432 @@ -2023,7 +2018,7 @@
  1.1433  }
  1.1434  
  1.1435  static int
  1.1436 -DX5_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color)
  1.1437 +DX5_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color)
  1.1438  {
  1.1439      LPDIRECTDRAWSURFACE3 dst_surface;
  1.1440      RECT area;
  1.1441 @@ -2031,39 +2026,39 @@
  1.1442      HRESULT result;
  1.1443  
  1.1444  #ifdef DDRAW_DEBUG
  1.1445 -    fprintf (stderr, "HW accelerated fill at (%d,%d)\n", dstrect->x,
  1.1446 -             dstrect->y);
  1.1447 +    fprintf(stderr, "HW accelerated fill at (%d,%d)\n", dstrect->x,
  1.1448 +            dstrect->y);
  1.1449  #endif
  1.1450      dst_surface = dst->hwdata->dd_writebuf;
  1.1451      area.top = (LONG) dstrect->y;
  1.1452      area.bottom = (LONG) dstrect->y + dstrect->h;
  1.1453      area.left = (LONG) dstrect->x;
  1.1454      area.right = (LONG) dstrect->x + dstrect->w;
  1.1455 -    bltfx.dwSize = sizeof (bltfx);
  1.1456 +    bltfx.dwSize = sizeof(bltfx);
  1.1457  #if defined(NONAMELESSUNION)
  1.1458      bltfx.u5.dwFillColor = color;
  1.1459  #else
  1.1460      bltfx.dwFillColor = color;
  1.1461  #endif
  1.1462 -    result = IDirectDrawSurface3_Blt (dst_surface,
  1.1463 -                                      &area, NULL, NULL,
  1.1464 -                                      DDBLT_COLORFILL | DDBLT_WAIT, &bltfx);
  1.1465 +    result = IDirectDrawSurface3_Blt(dst_surface,
  1.1466 +                                     &area, NULL, NULL,
  1.1467 +                                     DDBLT_COLORFILL | DDBLT_WAIT, &bltfx);
  1.1468      if (result == DDERR_SURFACELOST) {
  1.1469 -        IDirectDrawSurface3_Restore (dst_surface);
  1.1470 -        result = IDirectDrawSurface3_Blt (dst_surface,
  1.1471 -                                          &area, NULL, NULL,
  1.1472 -                                          DDBLT_COLORFILL | DDBLT_WAIT,
  1.1473 -                                          &bltfx);
  1.1474 +        IDirectDrawSurface3_Restore(dst_surface);
  1.1475 +        result = IDirectDrawSurface3_Blt(dst_surface,
  1.1476 +                                         &area, NULL, NULL,
  1.1477 +                                         DDBLT_COLORFILL | DDBLT_WAIT,
  1.1478 +                                         &bltfx);
  1.1479      }
  1.1480      if (result != DD_OK) {
  1.1481 -        SetDDerror ("IDirectDrawSurface3::Blt", result);
  1.1482 +        SetDDerror("IDirectDrawSurface3::Blt", result);
  1.1483          return (-1);
  1.1484      }
  1.1485      return (0);
  1.1486  }
  1.1487  
  1.1488  static int
  1.1489 -DX5_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key)
  1.1490 +DX5_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key)
  1.1491  {
  1.1492      DDCOLORKEY colorkey;
  1.1493      HRESULT result;
  1.1494 @@ -2072,22 +2067,22 @@
  1.1495      colorkey.dwColorSpaceLowValue = key;
  1.1496      colorkey.dwColorSpaceHighValue = key;
  1.1497      result =
  1.1498 -        IDirectDrawSurface3_SetColorKey (surface->hwdata->dd_surface,
  1.1499 -                                         DDCKEY_SRCBLT, &colorkey);
  1.1500 +        IDirectDrawSurface3_SetColorKey(surface->hwdata->dd_surface,
  1.1501 +                                        DDCKEY_SRCBLT, &colorkey);
  1.1502      if (result != DD_OK) {
  1.1503 -        SetDDerror ("IDirectDrawSurface3::SetColorKey", result);
  1.1504 +        SetDDerror("IDirectDrawSurface3::SetColorKey", result);
  1.1505          return (-1);
  1.1506      }
  1.1507      return (0);
  1.1508  }
  1.1509  static int
  1.1510 -DX5_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha)
  1.1511 +DX5_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha)
  1.1512  {
  1.1513      return (-1);
  1.1514  }
  1.1515  
  1.1516  static int
  1.1517 -DX5_LockHWSurface (_THIS, SDL_Surface * surface)
  1.1518 +DX5_LockHWSurface(_THIS, SDL_Surface * surface)
  1.1519  {
  1.1520      HRESULT result;
  1.1521      LPDIRECTDRAWSURFACE3 dd_surface;
  1.1522 @@ -2095,19 +2090,18 @@
  1.1523  
  1.1524      /* Lock and load! */
  1.1525      dd_surface = surface->hwdata->dd_writebuf;
  1.1526 -    SDL_memset (&ddsd, 0, sizeof (ddsd));
  1.1527 -    ddsd.dwSize = sizeof (ddsd);
  1.1528 -    result = IDirectDrawSurface3_Lock (dd_surface, NULL, &ddsd,
  1.1529 -                                       (DDLOCK_NOSYSLOCK | DDLOCK_WAIT),
  1.1530 -                                       NULL);
  1.1531 +    SDL_memset(&ddsd, 0, sizeof(ddsd));
  1.1532 +    ddsd.dwSize = sizeof(ddsd);
  1.1533 +    result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd,
  1.1534 +                                      (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), NULL);
  1.1535      if (result == DDERR_SURFACELOST) {
  1.1536 -        result = IDirectDrawSurface3_Restore (surface->hwdata->dd_surface);
  1.1537 -        result = IDirectDrawSurface3_Lock (dd_surface, NULL, &ddsd,
  1.1538 -                                           (DDLOCK_NOSYSLOCK | DDLOCK_WAIT),
  1.1539 -                                           NULL);
  1.1540 +        result = IDirectDrawSurface3_Restore(surface->hwdata->dd_surface);
  1.1541 +        result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd,
  1.1542 +                                          (DDLOCK_NOSYSLOCK | DDLOCK_WAIT),
  1.1543 +                                          NULL);
  1.1544      }
  1.1545      if (result != DD_OK) {
  1.1546 -        SetDDerror ("DirectDrawSurface3::Lock", result);
  1.1547 +        SetDDerror("DirectDrawSurface3::Lock", result);
  1.1548          return (-1);
  1.1549      }
  1.1550      /* Pitch might have changed -- recalculate pitch and offset */
  1.1551 @@ -2128,14 +2122,14 @@
  1.1552  }
  1.1553  
  1.1554  static void
  1.1555 -DX5_UnlockHWSurface (_THIS, SDL_Surface * surface)
  1.1556 +DX5_UnlockHWSurface(_THIS, SDL_Surface * surface)
  1.1557  {
  1.1558 -    IDirectDrawSurface3_Unlock (surface->hwdata->dd_writebuf, NULL);
  1.1559 +    IDirectDrawSurface3_Unlock(surface->hwdata->dd_writebuf, NULL);
  1.1560      surface->pixels = NULL;
  1.1561  }
  1.1562  
  1.1563  static int
  1.1564 -DX5_FlipHWSurface (_THIS, SDL_Surface * surface)
  1.1565 +DX5_FlipHWSurface(_THIS, SDL_Surface * surface)
  1.1566  {
  1.1567      HRESULT result;
  1.1568      LPDIRECTDRAWSURFACE3 dd_surface;
  1.1569 @@ -2144,37 +2138,37 @@
  1.1570  
  1.1571      /* to prevent big slowdown on fast computers, wait here instead of driver ring 0 code */
  1.1572      /* Dmitry Yakimov (ftech@tula.net) */
  1.1573 -    while (IDirectDrawSurface3_GetFlipStatus (dd_surface, DDGBS_ISBLTDONE) ==
  1.1574 +    while (IDirectDrawSurface3_GetFlipStatus(dd_surface, DDGBS_ISBLTDONE) ==
  1.1575             DDERR_WASSTILLDRAWING);
  1.1576  
  1.1577 -    result = IDirectDrawSurface3_Flip (dd_surface, NULL, DDFLIP_WAIT);
  1.1578 +    result = IDirectDrawSurface3_Flip(dd_surface, NULL, DDFLIP_WAIT);
  1.1579      if (result == DDERR_SURFACELOST) {
  1.1580 -        result = IDirectDrawSurface3_Restore (surface->hwdata->dd_surface);
  1.1581 +        result = IDirectDrawSurface3_Restore(surface->hwdata->dd_surface);
  1.1582          while (IDirectDrawSurface3_GetFlipStatus
  1.1583                 (dd_surface, DDGBS_ISBLTDONE) == DDERR_WASSTILLDRAWING);
  1.1584 -        result = IDirectDrawSurface3_Flip (dd_surface, NULL, DDFLIP_WAIT);
  1.1585 +        result = IDirectDrawSurface3_Flip(dd_surface, NULL, DDFLIP_WAIT);
  1.1586      }
  1.1587      if (result != DD_OK) {
  1.1588 -        SetDDerror ("DirectDrawSurface3::Flip", result);
  1.1589 +        SetDDerror("DirectDrawSurface3::Flip", result);
  1.1590          return (-1);
  1.1591      }
  1.1592      return (0);
  1.1593  }
  1.1594  
  1.1595  static void
  1.1596 -DX5_FreeHWSurface (_THIS, SDL_Surface * surface)
  1.1597 +DX5_FreeHWSurface(_THIS, SDL_Surface * surface)
  1.1598  {
  1.1599      if (surface->hwdata) {
  1.1600          if (surface->hwdata->dd_surface != SDL_primary) {
  1.1601 -            IDirectDrawSurface3_Release (surface->hwdata->dd_surface);
  1.1602 +            IDirectDrawSurface3_Release(surface->hwdata->dd_surface);
  1.1603          }
  1.1604 -        SDL_free (surface->hwdata);
  1.1605 +        SDL_free(surface->hwdata);
  1.1606          surface->hwdata = NULL;
  1.1607      }
  1.1608  }
  1.1609  
  1.1610  void
  1.1611 -DX5_WindowUpdate (_THIS, int numrects, SDL_Rect * rects)
  1.1612 +DX5_WindowUpdate(_THIS, int numrects, SDL_Rect * rects)
  1.1613  {
  1.1614      HRESULT result;
  1.1615      int i;
  1.1616 @@ -2189,21 +2183,21 @@
  1.1617          dst.left = SDL_bounds.left + src.left;
  1.1618          dst.bottom = SDL_bounds.top + src.bottom;
  1.1619          dst.right = SDL_bounds.left + src.right;
  1.1620 -        result = IDirectDrawSurface3_Blt (SDL_primary, &dst,
  1.1621 -                                          this->screen->hwdata->dd_surface,
  1.1622 -                                          &src, DDBLT_WAIT, NULL);
  1.1623 +        result = IDirectDrawSurface3_Blt(SDL_primary, &dst,
  1.1624 +                                         this->screen->hwdata->dd_surface,
  1.1625 +                                         &src, DDBLT_WAIT, NULL);
  1.1626          /* Doh!  Check for lost surface and restore it */
  1.1627          if (result == DDERR_SURFACELOST) {
  1.1628 -            IDirectDrawSurface3_Restore (SDL_primary);
  1.1629 -            IDirectDrawSurface3_Blt (SDL_primary, &dst,
  1.1630 -                                     this->screen->hwdata->dd_surface,
  1.1631 -                                     &src, DDBLT_WAIT, NULL);
  1.1632 +            IDirectDrawSurface3_Restore(SDL_primary);
  1.1633 +            IDirectDrawSurface3_Blt(SDL_primary, &dst,
  1.1634 +                                    this->screen->hwdata->dd_surface,
  1.1635 +                                    &src, DDBLT_WAIT, NULL);
  1.1636          }
  1.1637      }
  1.1638  }
  1.1639  
  1.1640  void
  1.1641 -DX5_DirectUpdate (_THIS, int numrects, SDL_Rect * rects)
  1.1642 +DX5_DirectUpdate(_THIS, int numrects, SDL_Rect * rects)
  1.1643  {
  1.1644  }
  1.1645  
  1.1646 @@ -2234,7 +2228,7 @@
  1.1647  	(r*r + g*g + b*b);						\
  1.1648  })
  1.1649  static void
  1.1650 -DX5_CompressPalette (_THIS, SDL_Color * colors, int ncolors, int maxcolors)
  1.1651 +DX5_CompressPalette(_THIS, SDL_Color * colors, int ncolors, int maxcolors)
  1.1652  {
  1.1653  #ifdef SIMPLE_COMPRESSION
  1.1654      int i, j;
  1.1655 @@ -2260,19 +2254,19 @@
  1.1656      }
  1.1657  #else
  1.1658      /* Allocate memory for the arrays we use */
  1.1659 -    pool = SDL_stack_alloc (int, 2 * ncolors);
  1.1660 +    pool = SDL_stack_alloc(int, 2 * ncolors);
  1.1661      if (pool == NULL) {
  1.1662          /* No worries, just return */ ;
  1.1663          return;
  1.1664      }
  1.1665      seen = pool;
  1.1666 -    SDL_memset (seen, 0, ncolors * sizeof (int));
  1.1667 +    SDL_memset(seen, 0, ncolors * sizeof(int));
  1.1668      order = pool + ncolors;
  1.1669  
  1.1670      /* Start with the brightest color */
  1.1671      max = 0;
  1.1672      for (i = 0; i < ncolors; ++i) {
  1.1673 -        dist = CS_CS_DIST (zero, colors[i]);
  1.1674 +        dist = CS_CS_DIST(zero, colors[i]);
  1.1675          if (dist >= max) {
  1.1676              max = dist;
  1.1677              next = i;
  1.1678 @@ -2290,7 +2284,7 @@
  1.1679              if (seen[i]) {
  1.1680                  continue;
  1.1681              }
  1.1682 -            dist = CS_CS_DIST (colors[i], colors[prev]);
  1.1683 +            dist = CS_CS_DIST(colors[i], colors[prev]);
  1.1684              if (dist >= max) {
  1.1685                  max = dist;
  1.1686                  next = i;
  1.1687 @@ -2307,13 +2301,13 @@
  1.1688          SDL_colors[j].peGreen = colors[order[i]].g;
  1.1689          SDL_colors[j].peBlue = colors[order[i]].b;
  1.1690      }
  1.1691 -    SDL_stack_free (pool);
  1.1692 +    SDL_stack_free(pool);
  1.1693  #endif /* SIMPLE_COMPRESSION */
  1.1694  }
  1.1695  
  1.1696  /* Set the system colormap in both fullscreen and windowed modes */
  1.1697  int
  1.1698 -DX5_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  1.1699 +DX5_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  1.1700  {
  1.1701      int i;
  1.1702      int alloct_all;
  1.1703 @@ -2329,17 +2323,16 @@
  1.1704                  SDL_colors[j].peGreen = colors[i].g;
  1.1705                  SDL_colors[j].peBlue = colors[i].b;
  1.1706              }
  1.1707 -            IDirectDrawPalette_SetEntries (SDL_palette, 0,
  1.1708 -                                           firstcolor, ncolors,
  1.1709 -                                           &SDL_colors[firstcolor]);
  1.1710 +            IDirectDrawPalette_SetEntries(SDL_palette, 0,
  1.1711 +                                          firstcolor, ncolors,
  1.1712 +                                          &SDL_colors[firstcolor]);
  1.1713              alloct_all = 1;
  1.1714          } else {
  1.1715              /* Grab the 236 most diverse colors in the palette */
  1.1716 -            DX5_CompressPalette (this, colors, ncolors, 236);
  1.1717 +            DX5_CompressPalette(this, colors, ncolors, 236);
  1.1718              /* This sends an WM_PALETTECHANGED message to us */
  1.1719              colorchange_expected = 1;
  1.1720 -            IDirectDrawPalette_SetEntries (SDL_palette, 0,
  1.1721 -                                           0, 256, SDL_colors);
  1.1722 +            IDirectDrawPalette_SetEntries(SDL_palette, 0, 0, 256, SDL_colors);
  1.1723          }
  1.1724      }
  1.1725      return (alloct_all);
  1.1726 @@ -2347,7 +2340,7 @@
  1.1727  
  1.1728  /* Gamma code is only available on DirectX 7 and newer */
  1.1729  static int
  1.1730 -DX5_SetGammaRamp (_THIS, Uint16 * ramp)
  1.1731 +DX5_SetGammaRamp(_THIS, Uint16 * ramp)
  1.1732  {
  1.1733  #ifdef IDirectDrawGammaControl_SetGammaRamp
  1.1734      LPDIRECTDRAWGAMMACONTROL gamma;
  1.1735 @@ -2356,45 +2349,45 @@
  1.1736  #endif
  1.1737  
  1.1738      /* In windowed or OpenGL mode, use windib gamma code */
  1.1739 -    if (!DDRAW_FULLSCREEN ()) {
  1.1740 -        return DIB_SetGammaRamp (this, ramp);
  1.1741 +    if (!DDRAW_FULLSCREEN()) {
  1.1742 +        return DIB_SetGammaRamp(this, ramp);
  1.1743      }
  1.1744  #ifndef IDirectDrawGammaControl_SetGammaRamp
  1.1745 -    SDL_SetError ("SDL compiled without DirectX gamma ramp support");
  1.1746 +    SDL_SetError("SDL compiled without DirectX gamma ramp support");
  1.1747      return -1;
  1.1748  #else
  1.1749      /* Check for a video mode! */
  1.1750      if (!SDL_primary) {
  1.1751 -        SDL_SetError ("A video mode must be set for gamma correction");
  1.1752 +        SDL_SetError("A video mode must be set for gamma correction");
  1.1753          return (-1);
  1.1754      }
  1.1755  
  1.1756      /* Get the gamma control object */
  1.1757 -    result = IDirectDrawSurface3_QueryInterface (SDL_primary,
  1.1758 -                                                 &IID_IDirectDrawGammaControl,
  1.1759 -                                                 (LPVOID *) & gamma);
  1.1760 +    result = IDirectDrawSurface3_QueryInterface(SDL_primary,
  1.1761 +                                                &IID_IDirectDrawGammaControl,
  1.1762 +                                                (LPVOID *) & gamma);
  1.1763      if (result != DD_OK) {
  1.1764 -        SetDDerror ("DirectDrawSurface3::QueryInterface(GAMMA)", result);
  1.1765 +        SetDDerror("DirectDrawSurface3::QueryInterface(GAMMA)", result);
  1.1766          return (-1);
  1.1767      }
  1.1768  
  1.1769      /* Set up the gamma ramp */
  1.1770 -    SDL_memcpy (gamma_ramp.red, &ramp[0 * 256], 256 * sizeof (*ramp));
  1.1771 -    SDL_memcpy (gamma_ramp.green, &ramp[1 * 256], 256 * sizeof (*ramp));
  1.1772 -    SDL_memcpy (gamma_ramp.blue, &ramp[2 * 256], 256 * sizeof (*ramp));
  1.1773 -    result = IDirectDrawGammaControl_SetGammaRamp (gamma, 0, &gamma_ramp);
  1.1774 +    SDL_memcpy(gamma_ramp.red, &ramp[0 * 256], 256 * sizeof(*ramp));
  1.1775 +    SDL_memcpy(gamma_ramp.green, &ramp[1 * 256], 256 * sizeof(*ramp));
  1.1776 +    SDL_memcpy(gamma_ramp.blue, &ramp[2 * 256], 256 * sizeof(*ramp));
  1.1777 +    result = IDirectDrawGammaControl_SetGammaRamp(gamma, 0, &gamma_ramp);
  1.1778      if (result != DD_OK) {
  1.1779 -        SetDDerror ("DirectDrawGammaControl::SetGammaRamp()", result);
  1.1780 +        SetDDerror("DirectDrawGammaControl::SetGammaRamp()", result);
  1.1781      }
  1.1782  
  1.1783      /* Release the interface and return */
  1.1784 -    IDirectDrawGammaControl_Release (gamma);
  1.1785 +    IDirectDrawGammaControl_Release(gamma);
  1.1786      return (result == DD_OK) ? 0 : -1;
  1.1787  #endif /* !IDirectDrawGammaControl_SetGammaRamp */
  1.1788  }
  1.1789  
  1.1790  static int
  1.1791 -DX5_GetGammaRamp (_THIS, Uint16 * ramp)
  1.1792 +DX5_GetGammaRamp(_THIS, Uint16 * ramp)
  1.1793  {
  1.1794  #ifdef IDirectDrawGammaControl_SetGammaRamp
  1.1795      LPDIRECTDRAWGAMMACONTROL gamma;
  1.1796 @@ -2403,46 +2396,46 @@
  1.1797  #endif
  1.1798  
  1.1799      /* In windowed or OpenGL mode, use windib gamma code */
  1.1800 -    if (!DDRAW_FULLSCREEN ()) {
  1.1801 -        return DIB_GetGammaRamp (this, ramp);
  1.1802 +    if (!DDRAW_FULLSCREEN()) {
  1.1803 +        return DIB_GetGammaRamp(this, ramp);
  1.1804      }
  1.1805  #ifndef IDirectDrawGammaControl_SetGammaRamp
  1.1806 -    SDL_SetError ("SDL compiled without DirectX gamma ramp support");
  1.1807 +    SDL_SetError("SDL compiled without DirectX gamma ramp support");
  1.1808      return -1;
  1.1809  #else
  1.1810      /* Check for a video mode! */
  1.1811      if (!SDL_primary) {
  1.1812 -        SDL_SetError ("A video mode must be set for gamma correction");
  1.1813 +        SDL_SetError("A video mode must be set for gamma correction");
  1.1814          return (-1);
  1.1815      }
  1.1816  
  1.1817      /* Get the gamma control object */
  1.1818 -    result = IDirectDrawSurface3_QueryInterface (SDL_primary,
  1.1819 -                                                 &IID_IDirectDrawGammaControl,
  1.1820 -                                                 (LPVOID *) & gamma);
  1.1821 +    result = IDirectDrawSurface3_QueryInterface(SDL_primary,
  1.1822 +                                                &IID_IDirectDrawGammaControl,
  1.1823 +                                                (LPVOID *) & gamma);
  1.1824      if (result != DD_OK) {
  1.1825 -        SetDDerror ("DirectDrawSurface3::QueryInterface(GAMMA)", result);
  1.1826 +        SetDDerror("DirectDrawSurface3::QueryInterface(GAMMA)", result);
  1.1827          return (-1);
  1.1828      }
  1.1829  
  1.1830      /* Set up the gamma ramp */
  1.1831 -    result = IDirectDrawGammaControl_GetGammaRamp (gamma, 0, &gamma_ramp);
  1.1832 +    result = IDirectDrawGammaControl_GetGammaRamp(gamma, 0, &gamma_ramp);
  1.1833      if (result == DD_OK) {
  1.1834 -        SDL_memcpy (&ramp[0 * 256], gamma_ramp.red, 256 * sizeof (*ramp));
  1.1835 -        SDL_memcpy (&ramp[1 * 256], gamma_ramp.green, 256 * sizeof (*ramp));
  1.1836 -        SDL_memcpy (&ramp[2 * 256], gamma_ramp.blue, 256 * sizeof (*ramp));
  1.1837 +        SDL_memcpy(&ramp[0 * 256], gamma_ramp.red, 256 * sizeof(*ramp));
  1.1838 +        SDL_memcpy(&ramp[1 * 256], gamma_ramp.green, 256 * sizeof(*ramp));
  1.1839 +        SDL_memcpy(&ramp[2 * 256], gamma_ramp.blue, 256 * sizeof(*ramp));
  1.1840      } else {
  1.1841 -        SetDDerror ("DirectDrawGammaControl::GetGammaRamp()", result);
  1.1842 +        SetDDerror("DirectDrawGammaControl::GetGammaRamp()", result);
  1.1843      }
  1.1844  
  1.1845      /* Release the interface and return */
  1.1846 -    IDirectDrawGammaControl_Release (gamma);
  1.1847 +    IDirectDrawGammaControl_Release(gamma);
  1.1848      return (result == DD_OK) ? 0 : -1;
  1.1849  #endif /* !IDirectDrawGammaControl_SetGammaRamp */
  1.1850  }
  1.1851  
  1.1852  void
  1.1853 -DX5_VideoQuit (_THIS)
  1.1854 +DX5_VideoQuit(_THIS)
  1.1855  {
  1.1856      int i, j;
  1.1857  
  1.1858 @@ -2451,18 +2444,18 @@
  1.1859  #ifndef NO_CHANGEDISPLAYSETTINGS
  1.1860          if ((this->screen->flags & (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) ==
  1.1861              (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) {
  1.1862 -            ChangeDisplaySettings (NULL, 0);
  1.1863 -            ShowWindow (SDL_Window, SW_HIDE);
  1.1864 +            ChangeDisplaySettings(NULL, 0);
  1.1865 +            ShowWindow(SDL_Window, SW_HIDE);
  1.1866          }
  1.1867  #endif
  1.1868          if (this->screen->flags & SDL_INTERNALOPENGL) {
  1.1869 -            WIN_GL_ShutDown (this);
  1.1870 +            WIN_GL_ShutDown(this);
  1.1871          }
  1.1872      }
  1.1873  
  1.1874      /* Free any palettes we used */
  1.1875      if (SDL_palette != NULL) {
  1.1876 -        IDirectDrawPalette_Release (SDL_palette);
  1.1877 +        IDirectDrawPalette_Release(SDL_palette);
  1.1878          SDL_palette = NULL;
  1.1879      }
  1.1880  
  1.1881 @@ -2475,42 +2468,42 @@
  1.1882      for (i = 0; i < NUM_MODELISTS; ++i) {
  1.1883          if (SDL_modelist[i] != NULL) {
  1.1884              for (j = 0; SDL_modelist[i][j]; ++j)
  1.1885 -                SDL_free (SDL_modelist[i][j]);
  1.1886 -            SDL_free (SDL_modelist[i]);
  1.1887 +                SDL_free(SDL_modelist[i][j]);
  1.1888 +            SDL_free(SDL_modelist[i]);
  1.1889              SDL_modelist[i] = NULL;
  1.1890          }
  1.1891      }
  1.1892  
  1.1893      /* Free the window */
  1.1894 -    DIB_QuitGamma (this);
  1.1895 +    DIB_QuitGamma(this);
  1.1896      if (SDL_Window) {
  1.1897 -        DX5_DestroyWindow (this);
  1.1898 +        DX5_DestroyWindow(this);
  1.1899      }
  1.1900  
  1.1901      /* Free our window icon */
  1.1902      if (screen_icn) {
  1.1903 -        DestroyIcon (screen_icn);
  1.1904 +        DestroyIcon(screen_icn);
  1.1905          screen_icn = NULL;
  1.1906      }
  1.1907  }
  1.1908  
  1.1909  /* Exported for the windows message loop only */
  1.1910  void
  1.1911 -DX5_RealizePalette (_THIS)
  1.1912 +DX5_RealizePalette(_THIS)
  1.1913  {
  1.1914      if (SDL_palette) {
  1.1915 -        IDirectDrawSurface3_SetPalette (SDL_primary, SDL_palette);
  1.1916 +        IDirectDrawSurface3_SetPalette(SDL_primary, SDL_palette);
  1.1917      }
  1.1918  }
  1.1919  static void
  1.1920 -DX5_Recolor8Bit (_THIS, SDL_Surface * surface, Uint8 * mapping)
  1.1921 +DX5_Recolor8Bit(_THIS, SDL_Surface * surface, Uint8 * mapping)
  1.1922  {
  1.1923      int row, col;
  1.1924      Uint8 *pixels;
  1.1925  
  1.1926      if (surface->w && surface->h) {
  1.1927          if ((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
  1.1928 -            if (this->LockHWSurface (this, surface) < 0) {
  1.1929 +            if (this->LockHWSurface(this, surface) < 0) {
  1.1930                  return;
  1.1931              }
  1.1932          }
  1.1933 @@ -2521,13 +2514,13 @@
  1.1934              }
  1.1935          }
  1.1936          if ((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
  1.1937 -            this->UnlockHWSurface (this, surface);
  1.1938 +            this->UnlockHWSurface(this, surface);
  1.1939          }
  1.1940 -        SDL_UpdateRect (surface, 0, 0, 0, 0);
  1.1941 +        SDL_UpdateRect(surface, 0, 0, 0, 0);
  1.1942      }
  1.1943  }
  1.1944  void
  1.1945 -DX5_PaletteChanged (_THIS, HWND window)
  1.1946 +DX5_PaletteChanged(_THIS, HWND window)
  1.1947  {
  1.1948      SDL_Palette *palette;
  1.1949      SDL_Color *saved = NULL;
  1.1950 @@ -2546,43 +2539,43 @@
  1.1951      if (palette == NULL) {      /* Sometimes we don't have a palette */
  1.1952          return;
  1.1953      }
  1.1954 -    entries = SDL_stack_alloc (PALETTEENTRY, palette->ncolors);
  1.1955 -    hdc = GetDC (window);
  1.1956 -    GetSystemPaletteEntries (hdc, 0, palette->ncolors, entries);
  1.1957 -    ReleaseDC (window, hdc);
  1.1958 +    entries = SDL_stack_alloc(PALETTEENTRY, palette->ncolors);
  1.1959 +    hdc = GetDC(window);
  1.1960 +    GetSystemPaletteEntries(hdc, 0, palette->ncolors, entries);
  1.1961 +    ReleaseDC(window, hdc);
  1.1962      if (!colorchange_expected) {
  1.1963 -        saved = SDL_stack_alloc (SDL_Color, palette->ncolors);
  1.1964 -        SDL_memcpy (saved, palette->colors,
  1.1965 -                    palette->ncolors * sizeof (SDL_Color));
  1.1966 +        saved = SDL_stack_alloc(SDL_Color, palette->ncolors);
  1.1967 +        SDL_memcpy(saved, palette->colors,
  1.1968 +                   palette->ncolors * sizeof(SDL_Color));
  1.1969      }
  1.1970      for (i = 0; i < palette->ncolors; ++i) {
  1.1971          palette->colors[i].r = entries[i].peRed;
  1.1972          palette->colors[i].g = entries[i].peGreen;
  1.1973          palette->colors[i].b = entries[i].peBlue;
  1.1974      }
  1.1975 -    SDL_stack_free (entries);
  1.1976 +    SDL_stack_free(entries);
  1.1977      if (!colorchange_expected) {
  1.1978          Uint8 mapping[256];
  1.1979  
  1.1980 -        SDL_memset (mapping, 0, sizeof (mapping));
  1.1981 +        SDL_memset(mapping, 0, sizeof(mapping));
  1.1982          for (i = 0; i < palette->ncolors; ++i) {
  1.1983 -            mapping[i] = SDL_FindColor (palette,
  1.1984 -                                        saved[i].r, saved[i].g, saved[i].b);
  1.1985 +            mapping[i] = SDL_FindColor(palette,
  1.1986 +                                       saved[i].r, saved[i].g, saved[i].b);
  1.1987          }
  1.1988 -        DX5_Recolor8Bit (this, SDL_VideoSurface, mapping);
  1.1989 -        SDL_stack_free (saved);
  1.1990 +        DX5_Recolor8Bit(this, SDL_VideoSurface, mapping);
  1.1991 +        SDL_stack_free(saved);
  1.1992      }
  1.1993      colorchange_expected = 0;
  1.1994  
  1.1995      /* Notify all mapped surfaces of the change */
  1.1996 -    SDL_FormatChanged (SDL_VideoSurface);
  1.1997 +    SDL_FormatChanged(SDL_VideoSurface);
  1.1998  }
  1.1999  
  1.2000  /* Exported for the windows message loop only */
  1.2001  void
  1.2002 -DX5_WinPAINT (_THIS, HDC hdc)
  1.2003 +DX5_WinPAINT(_THIS, HDC hdc)
  1.2004  {
  1.2005 -    SDL_UpdateRect (SDL_PublicSurface, 0, 0, 0, 0);
  1.2006 +    SDL_UpdateRect(SDL_PublicSurface, 0, 0, 0, 0);
  1.2007  }
  1.2008  
  1.2009  /* vi: set ts=4 sw=4 expandtab: */