src/SDL12_compat.c
changeset 16 ad3e9ebcfd90
parent 15 fd1b88f919e7
child 17 473158daa1de
     1.1 --- a/src/SDL12_compat.c	Thu Mar 07 21:28:24 2013 -0500
     1.2 +++ b/src/SDL12_compat.c	Thu Mar 07 22:34:19 2013 -0500
     1.3 @@ -171,18 +171,18 @@
     1.4  
     1.5  static SDL_Window *VideoWindow = NULL;
     1.6  static SDL_Surface *WindowSurface = NULL;
     1.7 -static SDL_Surface *SDL_VideoSurface = NULL;
     1.8 -static SDL_Surface *SDL_ShadowSurface = NULL;
     1.9 -static SDL_Surface *SDL_PublicSurface = NULL;
    1.10 -static SDL_GLContext *SDL_VideoContext = NULL;
    1.11 -static Uint32 SDL_VideoFlags = 0;
    1.12 -static SDL_Rect SDL_VideoViewport;
    1.13 -static char *wm_title = NULL;
    1.14 -static char *wm_icon_caption = NULL;
    1.15 -static SDL_Surface *SDL_VideoIcon;
    1.16 -static int SDL_enabled_UNICODE = 0;
    1.17 -static int SDL_VideoDisplayIndex = 0;
    1.18 -static int SDL_CDRomInit = 0;
    1.19 +static SDL_Surface *VideoSurface = NULL;
    1.20 +static SDL_Surface *ShadowSurface = NULL;
    1.21 +static SDL_Surface *PublicSurface = NULL;
    1.22 +static SDL_GLContext *VideoContext = NULL;
    1.23 +static Uint32 VideoFlags = 0;
    1.24 +static SDL_Rect VideoViewport;
    1.25 +static char *WindowTitle = NULL;
    1.26 +static char *WindowIconTitle = NULL;
    1.27 +static SDL_Surface *VideoIcon;
    1.28 +static int EnabledUnicode = 0;
    1.29 +static int VideoDisplayIndex = 0;
    1.30 +static int CDRomInit = 0;
    1.31  
    1.32  /* Obviously we can't use SDL_LoadObject() to load SDL2.  :)  */
    1.33  #if defined(_WINDOWS)
    1.34 @@ -284,13 +284,13 @@
    1.35  
    1.36      // There's no CDROM in 2.0, but we'll just pretend it succeeded.
    1.37      if (sdl12flags & SDL12_INIT_CDROM)
    1.38 -        SDL_CDRomInit = 1;
    1.39 +        CDRomInit = 1;
    1.40  
    1.41      // !!! FIXME: do something about SDL12_INIT_EVENTTHREAD
    1.42  
    1.43      rc = justsubs ? SDL20_InitSubSystem(sdl20flags) : SDL20_Init(sdl20flags);
    1.44      if ((rc == 0) && (sdl20flags & SDL_INIT_VIDEO))
    1.45 -        SDL_VideoDisplayIndex = GetVideoDisplay();
    1.46 +        VideoDisplayIndex = GetVideoDisplay();
    1.47      return rc;
    1.48  }
    1.49  
    1.50 @@ -321,7 +321,7 @@
    1.51      SETFLAG(NOPARACHUTE);
    1.52      #undef SETFLAG
    1.53  
    1.54 -    if ((sdl12flags & SDL12_INIT_CDROM) && (SDL_CDRomInit))
    1.55 +    if ((sdl12flags & SDL12_INIT_CDROM) && (CDRomInit))
    1.56          extraflags |= SDL12_INIT_CDROM;
    1.57  
    1.58      // !!! FIXME: do something about SDL12_INIT_EVENTTHREAD
    1.59 @@ -344,6 +344,9 @@
    1.60      // There's no CDROM in 2.0, but we'll just pretend it succeeded.
    1.61      #undef SETFLAG
    1.62  
    1.63 +    if (sdl12flags & SDL12_INIT_CDROM)
    1.64 +        CDRomInit = 0;
    1.65 +
    1.66      // !!! FIXME: do something about SDL12_INIT_EVENTTHREAD
    1.67      SDL20_QuitSubSystem(sdl20flags);
    1.68  
    1.69 @@ -353,6 +356,7 @@
    1.70  void
    1.71  SDL_Quit(void)
    1.72  {
    1.73 +    CDRomInit = 0;
    1.74      SDL20_Quit();
    1.75      UnloadSDL20();
    1.76  }
    1.77 @@ -552,7 +556,7 @@
    1.78      SDL_DisplayMode mode;
    1.79  
    1.80      /* !!! FIXME: Memory leak, compatibility code, who cares? */
    1.81 -    if (!info.vfmt && SDL20_GetDesktopDisplayMode(SDL_VideoDisplayIndex, &mode) == 0) {
    1.82 +    if (!info.vfmt && SDL20_GetDesktopDisplayMode(VideoDisplayIndex, &mode) == 0) {
    1.83          info.vfmt = SDL20_AllocFormat(mode.format);
    1.84          info.current_w = mode.w;
    1.85          info.current_h = mode.h;
    1.86 @@ -574,14 +578,14 @@
    1.87  
    1.88      if (!(sdl12flags & SDL12_FULLSCREEN)) {
    1.89          SDL_DisplayMode mode;
    1.90 -        SDL20_GetDesktopDisplayMode(SDL_VideoDisplayIndex, &mode);
    1.91 +        SDL20_GetDesktopDisplayMode(VideoDisplayIndex, &mode);
    1.92          return SDL_BITSPERPIXEL(mode.format);
    1.93      }
    1.94  
    1.95 -    nummodes = SDL20_GetNumDisplayModes(SDL_VideoDisplayIndex);
    1.96 +    nummodes = SDL20_GetNumDisplayModes(VideoDisplayIndex);
    1.97      for (i = 0; i < nummodes; ++i) {
    1.98          SDL_DisplayMode mode;
    1.99 -        SDL20_GetDisplayMode(SDL_VideoDisplayIndex, i, &mode);
   1.100 +        SDL20_GetDisplayMode(VideoDisplayIndex, i, &mode);
   1.101          if (!mode.w || !mode.h || (width == mode.w && height == mode.h)) {
   1.102              if (!mode.format) {
   1.103                  return bpp;
   1.104 @@ -615,11 +619,11 @@
   1.105      /* Memory leak, but this is a compatibility function, who cares? */
   1.106      nmodes = 0;
   1.107      modes = NULL;
   1.108 -    for (i = 0; i < SDL20_GetNumDisplayModes(SDL_VideoDisplayIndex); ++i) {
   1.109 +    for (i = 0; i < SDL20_GetNumDisplayModes(VideoDisplayIndex); ++i) {
   1.110          SDL_DisplayMode mode;
   1.111          int bpp;
   1.112  
   1.113 -        SDL20_GetDisplayMode(SDL_VideoDisplayIndex, i, &mode);
   1.114 +        SDL20_GetDisplayMode(VideoDisplayIndex, i, &mode);
   1.115          if (!mode.w || !mode.h) {
   1.116              return (SDL_Rect **) (-1);
   1.117          }
   1.118 @@ -678,7 +682,7 @@
   1.119              /* We don't want to expose that the window width and height will
   1.120                 be different if we don't get the desired fullscreen mode.
   1.121              */
   1.122 -            if (SDL_VideoWindow && !(SDL_GetWindowFlags(SDL_VideoWindow) & SDL_WINDOW_FULLSCREEN)) {
   1.123 +            if (VideoWindow && !(SDL_GetWindowFlags(VideoWindow) & SDL_WINDOW_FULLSCREEN)) {
   1.124                  fake.type = SDL_VIDEORESIZE;
   1.125                  fake.resize.w = event->window.data1;
   1.126                  fake.resize.h = event->window.data2;
   1.127 @@ -753,15 +757,15 @@
   1.128          }
   1.129      case SDL_MOUSEMOTION:
   1.130          {
   1.131 -            event->motion.x -= SDL_VideoViewport.x;
   1.132 -            event->motion.y -= SDL_VideoViewport.y;
   1.133 +            event->motion.x -= VideoViewport.x;
   1.134 +            event->motion.y -= VideoViewport.y;
   1.135              break;
   1.136          }
   1.137      case SDL_MOUSEBUTTONDOWN:
   1.138      case SDL_MOUSEBUTTONUP:
   1.139          {
   1.140 -            event->button.x -= SDL_VideoViewport.x;
   1.141 -            event->button.y -= SDL_VideoViewport.y;
   1.142 +            event->button.x -= VideoViewport.x;
   1.143 +            event->button.y -= VideoViewport.y;
   1.144              break;
   1.145          }
   1.146      case SDL_MOUSEWHEEL:
   1.147 @@ -803,7 +807,7 @@
   1.148  static void
   1.149  GetEnvironmentWindowPosition(int w, int h, int *x, int *y)
   1.150  {
   1.151 -    int display = SDL_VideoDisplayIndex;
   1.152 +    int display = VideoDisplayIndex;
   1.153      const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS");
   1.154      const char *center = SDL_getenv("SDL_VIDEO_CENTERED");
   1.155      if (window) {
   1.156 @@ -823,12 +827,12 @@
   1.157  static void
   1.158  ClearVideoSurface()
   1.159  {
   1.160 -    if (SDL_ShadowSurface) {
   1.161 -        SDL_FillRect(SDL_ShadowSurface, NULL,
   1.162 -            SDL_MapRGB(SDL_ShadowSurface->format, 0, 0, 0));
   1.163 +    if (ShadowSurface) {
   1.164 +        SDL_FillRect(ShadowSurface, NULL,
   1.165 +            SDL_MapRGB(ShadowSurface->format, 0, 0, 0));
   1.166      }
   1.167 -    SDL_FillRect(SDL_WindowSurface, NULL, 0);
   1.168 -    SDL_UpdateWindowSurface(SDL_VideoWindow);
   1.169 +    SDL_FillRect(WindowSurface, NULL, 0);
   1.170 +    SDL_UpdateWindowSurface(VideoWindow);
   1.171  }
   1.172  
   1.173  static void
   1.174 @@ -859,7 +863,7 @@
   1.175      int w, h;
   1.176  
   1.177      /* We can't resize something we don't have... */
   1.178 -    if (!SDL_VideoSurface) {
   1.179 +    if (!VideoSurface) {
   1.180          return -1;
   1.181      }
   1.182  
   1.183 @@ -869,50 +873,50 @@
   1.184      }
   1.185  
   1.186      /* I don't think there's any change we can gracefully make in flags */
   1.187 -    if (flags != SDL_VideoFlags) {
   1.188 +    if (flags != VideoFlags) {
   1.189          return -1;
   1.190      }
   1.191 -    if (bpp != SDL_VideoSurface->format->BitsPerPixel) {
   1.192 +    if (bpp != VideoSurface->format->BitsPerPixel) {
   1.193          return -1;
   1.194      }
   1.195  
   1.196      /* Resize the window */
   1.197 -    SDL_GetWindowSize(SDL_VideoWindow, &w, &h);
   1.198 +    SDL_GetWindowSize(VideoWindow, &w, &h);
   1.199      if (w != width || h != height) {
   1.200 -        SDL_SetWindowSize(SDL_VideoWindow, width, height);
   1.201 +        SDL_SetWindowSize(VideoWindow, width, height);
   1.202      }
   1.203  
   1.204      /* If we're in OpenGL mode, just resize the stub surface and we're done! */
   1.205      if (flags & SDL_OPENGL) {
   1.206 -        SDL_VideoSurface->w = width;
   1.207 -        SDL_VideoSurface->h = height;
   1.208 +        VideoSurface->w = width;
   1.209 +        VideoSurface->h = height;
   1.210          return 0;
   1.211      }
   1.212  
   1.213 -    SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow);
   1.214 -    if (!SDL_WindowSurface) {
   1.215 +    WindowSurface = SDL_GetWindowSurface(VideoWindow);
   1.216 +    if (!WindowSurface) {
   1.217          return -1;
   1.218      }
   1.219 -    if (SDL_VideoSurface->format != SDL_WindowSurface->format) {
   1.220 +    if (VideoSurface->format != WindowSurface->format) {
   1.221          return -1;
   1.222      }
   1.223 -    SDL_VideoSurface->w = width;
   1.224 -    SDL_VideoSurface->h = height;
   1.225 -    SDL_VideoSurface->pixels = SDL_WindowSurface->pixels;
   1.226 -    SDL_VideoSurface->pitch = SDL_WindowSurface->pitch;
   1.227 -    SDL_SetClipRect(SDL_VideoSurface, NULL);
   1.228 +    VideoSurface->w = width;
   1.229 +    VideoSurface->h = height;
   1.230 +    VideoSurface->pixels = WindowSurface->pixels;
   1.231 +    VideoSurface->pitch = WindowSurface->pitch;
   1.232 +    SDL_SetClipRect(VideoSurface, NULL);
   1.233  
   1.234 -    if (SDL_ShadowSurface) {
   1.235 -        SDL_ShadowSurface->w = width;
   1.236 -        SDL_ShadowSurface->h = height;
   1.237 -        SDL_ShadowSurface->pitch = SDL_CalculatePitch(SDL_ShadowSurface);
   1.238 -        SDL_ShadowSurface->pixels =
   1.239 -            SDL_realloc(SDL_ShadowSurface->pixels,
   1.240 -                        SDL_ShadowSurface->h * SDL_ShadowSurface->pitch);
   1.241 -        SDL_SetClipRect(SDL_ShadowSurface, NULL);
   1.242 -        SDL_InvalidateMap(SDL_ShadowSurface->map);
   1.243 +    if (ShadowSurface) {
   1.244 +        ShadowSurface->w = width;
   1.245 +        ShadowSurface->h = height;
   1.246 +        ShadowSurface->pitch = SDL_CalculatePitch(ShadowSurface);
   1.247 +        ShadowSurface->pixels =
   1.248 +            SDL_realloc(ShadowSurface->pixels,
   1.249 +                        ShadowSurface->h * ShadowSurface->pitch);
   1.250 +        SDL_SetClipRect(ShadowSurface, NULL);
   1.251 +        SDL_InvalidateMap(ShadowSurface->map);
   1.252      } else {
   1.253 -        SDL_PublicSurface = SDL_VideoSurface;
   1.254 +        PublicSurface = VideoSurface;
   1.255      }
   1.256  
   1.257      ClearVideoSurface();
   1.258 @@ -924,7 +928,7 @@
   1.259  SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
   1.260  {
   1.261      SDL_DisplayMode desktop_mode;
   1.262 -    int display = SDL_VideoDisplayIndex;
   1.263 +    int display = VideoDisplayIndex;
   1.264      int window_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(display);
   1.265      int window_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(display);
   1.266      int window_w;
   1.267 @@ -952,29 +956,29 @@
   1.268  
   1.269      /* See if we can simply resize the existing window and surface */
   1.270      if (SDL_ResizeVideoMode(width, height, bpp, flags) == 0) {
   1.271 -        return SDL_PublicSurface;
   1.272 +        return PublicSurface;
   1.273      }
   1.274  
   1.275      /* Destroy existing window */
   1.276 -    SDL_PublicSurface = NULL;
   1.277 -    if (SDL_ShadowSurface) {
   1.278 -        SDL_ShadowSurface->flags &= ~SDL_DONTFREE;
   1.279 -        SDL_FreeSurface(SDL_ShadowSurface);
   1.280 -        SDL_ShadowSurface = NULL;
   1.281 +    PublicSurface = NULL;
   1.282 +    if (ShadowSurface) {
   1.283 +        ShadowSurface->flags &= ~SDL_DONTFREE;
   1.284 +        SDL_FreeSurface(ShadowSurface);
   1.285 +        ShadowSurface = NULL;
   1.286      }
   1.287 -    if (SDL_VideoSurface) {
   1.288 -        SDL_VideoSurface->flags &= ~SDL_DONTFREE;
   1.289 -        SDL_FreeSurface(SDL_VideoSurface);
   1.290 -        SDL_VideoSurface = NULL;
   1.291 +    if (VideoSurface) {
   1.292 +        VideoSurface->flags &= ~SDL_DONTFREE;
   1.293 +        SDL_FreeSurface(VideoSurface);
   1.294 +        VideoSurface = NULL;
   1.295      }
   1.296 -    if (SDL_VideoContext) {
   1.297 +    if (VideoContext) {
   1.298          /* SDL_GL_MakeCurrent(0, NULL); *//* Doesn't do anything */
   1.299 -        SDL_GL_DeleteContext(SDL_VideoContext);
   1.300 -        SDL_VideoContext = NULL;
   1.301 +        SDL_GL_DeleteContext(VideoContext);
   1.302 +        VideoContext = NULL;
   1.303      }
   1.304 -    if (SDL_VideoWindow) {
   1.305 -        SDL_GetWindowPosition(SDL_VideoWindow, &window_x, &window_y);
   1.306 -        SDL_DestroyWindow(SDL_VideoWindow);
   1.307 +    if (VideoWindow) {
   1.308 +        SDL_GetWindowPosition(VideoWindow, &window_x, &window_y);
   1.309 +        SDL_DestroyWindow(VideoWindow);
   1.310      }
   1.311  
   1.312      /* Set up the event filter */
   1.313 @@ -997,17 +1001,17 @@
   1.314          window_flags |= SDL_WINDOW_BORDERLESS;
   1.315      }
   1.316      GetEnvironmentWindowPosition(width, height, &window_x, &window_y);
   1.317 -    SDL_VideoWindow =
   1.318 -        SDL_CreateWindow(wm_title, window_x, window_y, width, height,
   1.319 +    VideoWindow =
   1.320 +        SDL_CreateWindow(WindowTitle, window_x, window_y, width, height,
   1.321                           window_flags);
   1.322 -    if (!SDL_VideoWindow) {
   1.323 +    if (!VideoWindow) {
   1.324          return NULL;
   1.325      }
   1.326 -    SDL_SetWindowIcon(SDL_VideoWindow, SDL_VideoIcon);
   1.327 +    SDL_SetWindowIcon(VideoWindow, VideoIcon);
   1.328  
   1.329      SetupScreenSaver(flags);
   1.330  
   1.331 -    window_flags = SDL_GetWindowFlags(SDL_VideoWindow);
   1.332 +    window_flags = SDL_GetWindowFlags(VideoWindow);
   1.333      surface_flags = 0;
   1.334      if (window_flags & SDL_WINDOW_FULLSCREEN) {
   1.335          surface_flags |= SDL_FULLSCREEN;
   1.336 @@ -1022,87 +1026,87 @@
   1.337          surface_flags |= SDL_NOFRAME;
   1.338      }
   1.339  
   1.340 -    SDL_VideoFlags = flags;
   1.341 +    VideoFlags = flags;
   1.342  
   1.343      /* If we're in OpenGL mode, just create a stub surface and we're done! */
   1.344      if (flags & SDL_OPENGL) {
   1.345 -        SDL_VideoContext = SDL_GL_CreateContext(SDL_VideoWindow);
   1.346 -        if (!SDL_VideoContext) {
   1.347 +        VideoContext = SDL_GL_CreateContext(VideoWindow);
   1.348 +        if (!VideoContext) {
   1.349              return NULL;
   1.350          }
   1.351 -        if (SDL_GL_MakeCurrent(SDL_VideoWindow, SDL_VideoContext) < 0) {
   1.352 +        if (SDL_GL_MakeCurrent(VideoWindow, VideoContext) < 0) {
   1.353              return NULL;
   1.354          }
   1.355 -        SDL_VideoSurface =
   1.356 +        VideoSurface =
   1.357              SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0);
   1.358 -        if (!SDL_VideoSurface) {
   1.359 +        if (!VideoSurface) {
   1.360              return NULL;
   1.361          }
   1.362 -        SDL_VideoSurface->flags |= surface_flags;
   1.363 -        SDL_PublicSurface = SDL_VideoSurface;
   1.364 -        return SDL_PublicSurface;
   1.365 +        VideoSurface->flags |= surface_flags;
   1.366 +        PublicSurface = VideoSurface;
   1.367 +        return PublicSurface;
   1.368      }
   1.369  
   1.370      /* Create the screen surface */
   1.371 -    SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow);
   1.372 -    if (!SDL_WindowSurface) {
   1.373 +    WindowSurface = SDL_GetWindowSurface(VideoWindow);
   1.374 +    if (!WindowSurface) {
   1.375          return NULL;
   1.376      }
   1.377  
   1.378      /* Center the public surface in the window surface */
   1.379 -    SDL_GetWindowSize(SDL_VideoWindow, &window_w, &window_h);
   1.380 -    SDL_VideoViewport.x = (window_w - width)/2;
   1.381 -    SDL_VideoViewport.y = (window_h - height)/2;
   1.382 -    SDL_VideoViewport.w = width;
   1.383 -    SDL_VideoViewport.h = height;
   1.384 +    SDL_GetWindowSize(VideoWindow, &window_w, &window_h);
   1.385 +    VideoViewport.x = (window_w - width)/2;
   1.386 +    VideoViewport.y = (window_h - height)/2;
   1.387 +    VideoViewport.w = width;
   1.388 +    VideoViewport.h = height;
   1.389  
   1.390 -    SDL_VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0);
   1.391 -    SDL_VideoSurface->flags |= surface_flags;
   1.392 -    SDL_VideoSurface->flags |= SDL_DONTFREE;
   1.393 -    SDL_FreeFormat(SDL_VideoSurface->format);
   1.394 -    SDL_VideoSurface->format = SDL_WindowSurface->format;
   1.395 -    SDL_VideoSurface->format->refcount++;
   1.396 -    SDL_VideoSurface->w = width;
   1.397 -    SDL_VideoSurface->h = height;
   1.398 -    SDL_VideoSurface->pitch = SDL_WindowSurface->pitch;
   1.399 -    SDL_VideoSurface->pixels = (void *)((Uint8 *)SDL_WindowSurface->pixels +
   1.400 -        SDL_VideoViewport.y * SDL_VideoSurface->pitch +
   1.401 -        SDL_VideoViewport.x  * SDL_VideoSurface->format->BytesPerPixel);
   1.402 -    SDL_SetClipRect(SDL_VideoSurface, NULL);
   1.403 +    VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0);
   1.404 +    VideoSurface->flags |= surface_flags;
   1.405 +    VideoSurface->flags |= SDL_DONTFREE;
   1.406 +    SDL_FreeFormat(VideoSurface->format);
   1.407 +    VideoSurface->format = WindowSurface->format;
   1.408 +    VideoSurface->format->refcount++;
   1.409 +    VideoSurface->w = width;
   1.410 +    VideoSurface->h = height;
   1.411 +    VideoSurface->pitch = WindowSurface->pitch;
   1.412 +    VideoSurface->pixels = (void *)((Uint8 *)WindowSurface->pixels +
   1.413 +        VideoViewport.y * VideoSurface->pitch +
   1.414 +        VideoViewport.x  * VideoSurface->format->BytesPerPixel);
   1.415 +    SDL_SetClipRect(VideoSurface, NULL);
   1.416  
   1.417      /* Create a shadow surface if necessary */
   1.418 -    if ((bpp != SDL_VideoSurface->format->BitsPerPixel)
   1.419 +    if ((bpp != VideoSurface->format->BitsPerPixel)
   1.420          && !(flags & SDL_ANYFORMAT)) {
   1.421 -        SDL_ShadowSurface =
   1.422 +        ShadowSurface =
   1.423              SDL_CreateRGBSurface(0, width, height, bpp, 0, 0, 0, 0);
   1.424 -        if (!SDL_ShadowSurface) {
   1.425 +        if (!ShadowSurface) {
   1.426              return NULL;
   1.427          }
   1.428 -        SDL_ShadowSurface->flags |= surface_flags;
   1.429 -        SDL_ShadowSurface->flags |= SDL_DONTFREE;
   1.430 +        ShadowSurface->flags |= surface_flags;
   1.431 +        ShadowSurface->flags |= SDL_DONTFREE;
   1.432  
   1.433 -        /* 8-bit SDL_ShadowSurface surfaces report that they have exclusive palette */
   1.434 -        if (SDL_ShadowSurface->format->palette) {
   1.435 -            SDL_ShadowSurface->flags |= SDL_HWPALETTE;
   1.436 -            SDL_DitherColors(SDL_ShadowSurface->format->palette->colors,
   1.437 -                             SDL_ShadowSurface->format->BitsPerPixel);
   1.438 +        /* 8-bit ShadowSurface surfaces report that they have exclusive palette */
   1.439 +        if (ShadowSurface->format->palette) {
   1.440 +            ShadowSurface->flags |= SDL_HWPALETTE;
   1.441 +            SDL_DitherColors(ShadowSurface->format->palette->colors,
   1.442 +                             ShadowSurface->format->BitsPerPixel);
   1.443          }
   1.444 -        SDL_FillRect(SDL_ShadowSurface, NULL,
   1.445 -            SDL_MapRGB(SDL_ShadowSurface->format, 0, 0, 0));
   1.446 +        SDL_FillRect(ShadowSurface, NULL,
   1.447 +            SDL_MapRGB(ShadowSurface->format, 0, 0, 0));
   1.448      }
   1.449 -    SDL_PublicSurface =
   1.450 -        (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface);
   1.451 +    PublicSurface =
   1.452 +        (ShadowSurface ? ShadowSurface : VideoSurface);
   1.453  
   1.454      ClearVideoSurface();
   1.455  
   1.456      /* We're finally done! */
   1.457 -    return SDL_PublicSurface;
   1.458 +    return PublicSurface;
   1.459  }
   1.460  
   1.461  SDL_Surface *
   1.462  SDL_GetVideoSurface(void)
   1.463  {
   1.464 -    return SDL_PublicSurface;
   1.465 +    return PublicSurface;
   1.466  }
   1.467  
   1.468  int
   1.469 @@ -1129,11 +1133,11 @@
   1.470  {
   1.471      SDL_PixelFormat *format;
   1.472  
   1.473 -    if (!SDL_PublicSurface) {
   1.474 +    if (!PublicSurface) {
   1.475          SDL_SetError("No video mode has been set");
   1.476          return NULL;
   1.477      }
   1.478 -    format = SDL_PublicSurface->format;
   1.479 +    format = PublicSurface->format;
   1.480  
   1.481      /* Set the flags appropriate for copying to display surface */
   1.482      return SDL_ConvertSurface(surface, format, SDL_RLEACCEL);
   1.483 @@ -1151,11 +1155,11 @@
   1.484      Uint32 gmask = 0x0000ff00;
   1.485      Uint32 bmask = 0x000000ff;
   1.486  
   1.487 -    if (!SDL_PublicSurface) {
   1.488 +    if (!PublicSurface) {
   1.489          SDL_SetError("No video mode has been set");
   1.490          return NULL;
   1.491      }
   1.492 -    vf = SDL_PublicSurface->format;
   1.493 +    vf = PublicSurface->format;
   1.494  
   1.495      switch (vf->BytesPerPixel) {
   1.496      case 2:
   1.497 @@ -1223,17 +1227,17 @@
   1.498  {
   1.499      int i;
   1.500  
   1.501 -    if (screen == SDL_ShadowSurface) {
   1.502 +    if (screen == ShadowSurface) {
   1.503          for (i = 0; i < numrects; ++i) {
   1.504 -            SDL_BlitSurface(SDL_ShadowSurface, &rects[i], SDL_VideoSurface,
   1.505 +            SDL_BlitSurface(ShadowSurface, &rects[i], VideoSurface,
   1.506                              &rects[i]);
   1.507          }
   1.508  
   1.509          /* Fall through to video surface update */
   1.510 -        screen = SDL_VideoSurface;
   1.511 +        screen = VideoSurface;
   1.512      }
   1.513 -    if (screen == SDL_VideoSurface) {
   1.514 -        if (SDL_VideoViewport.x || SDL_VideoViewport.y) {
   1.515 +    if (screen == VideoSurface) {
   1.516 +        if (VideoViewport.x || VideoViewport.y) {
   1.517              SDL_Rect *stackrects = SDL_stack_alloc(SDL_Rect, numrects);
   1.518              SDL_Rect *stackrect;
   1.519              const SDL_Rect *rect;
   1.520 @@ -1242,15 +1246,15 @@
   1.521              for (i = 0; i < numrects; ++i) {
   1.522                  rect = &rects[i];
   1.523                  stackrect = &stackrects[i];
   1.524 -                stackrect->x = SDL_VideoViewport.x + rect->x;
   1.525 -                stackrect->y = SDL_VideoViewport.y + rect->y;
   1.526 +                stackrect->x = VideoViewport.x + rect->x;
   1.527 +                stackrect->y = VideoViewport.y + rect->y;
   1.528                  stackrect->w = rect->w;
   1.529                  stackrect->h = rect->h;
   1.530              }
   1.531 -            SDL_UpdateWindowSurfaceRects(SDL_VideoWindow, stackrects, numrects);
   1.532 +            SDL_UpdateWindowSurfaceRects(VideoWindow, stackrects, numrects);
   1.533              SDL_stack_free(stackrects);
   1.534          } else {
   1.535 -            SDL_UpdateWindowSurfaceRects(SDL_VideoWindow, rects, numrects);
   1.536 +            SDL_UpdateWindowSurfaceRects(VideoWindow, rects, numrects);
   1.537          }
   1.538      }
   1.539  }
   1.540 @@ -1258,25 +1262,25 @@
   1.541  void
   1.542  SDL_WM_SetCaption(const char *title, const char *icon)
   1.543  {
   1.544 -    if (wm_title) {
   1.545 -        SDL_free(wm_title);
   1.546 +    if (WindowTitle) {
   1.547 +        SDL_free(WindowTitle);
   1.548      }
   1.549 -    if (wm_icon_caption) {
   1.550 -        SDL_free(wm_icon_caption);
   1.551 +    if (WindowIconTitle) {
   1.552 +        SDL_free(WindowIconTitle);
   1.553      }
   1.554 -    wm_title = title ? SDL_strdup(title) : NULL;
   1.555 -    wm_icon_caption = icon ? SDL_strdup(icon) : NULL;
   1.556 -    SDL_SetWindowTitle(SDL_VideoWindow, wm_title);
   1.557 +    WindowTitle = title ? SDL_strdup(title) : NULL;
   1.558 +    WindowIconTitle = icon ? SDL_strdup(icon) : NULL;
   1.559 +    SDL_SetWindowTitle(VideoWindow, WindowTitle);
   1.560  }
   1.561  
   1.562  void
   1.563  SDL_WM_GetCaption(const char **title, const char **icon)
   1.564  {
   1.565      if (title) {
   1.566 -        *title = wm_title;
   1.567 +        *title = WindowTitle;
   1.568      }
   1.569      if (icon) {
   1.570 -        *icon = wm_icon_caption;
   1.571 +        *icon = WindowIconTitle;
   1.572      }
   1.573  }
   1.574  
   1.575 @@ -1284,14 +1288,14 @@
   1.576  SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
   1.577  {
   1.578      // !!! FIXME: free previous icon?
   1.579 -    SDL_VideoIcon = icon;
   1.580 -    ++SDL_VideoIcon->refcount;
   1.581 +    VideoIcon = icon;
   1.582 +    ++VideoIcon->refcount;
   1.583  }
   1.584  
   1.585  int
   1.586  SDL_WM_IconifyWindow(void)
   1.587  {
   1.588 -    SDL_MinimizeWindow(SDL_VideoWindow);
   1.589 +    SDL_MinimizeWindow(VideoWindow);
   1.590      return 0;
   1.591  }
   1.592  
   1.593 @@ -1305,109 +1309,109 @@
   1.594      int window_w;
   1.595      int window_h;
   1.596  
   1.597 -    if (!SDL_PublicSurface) {
   1.598 +    if (!PublicSurface) {
   1.599          SDL_SetError("SDL_SetVideoMode() hasn't been called");
   1.600          return 0;
   1.601      }
   1.602  
   1.603      /* Copy the old bits out */
   1.604 -    length = SDL_PublicSurface->w * SDL_PublicSurface->format->BytesPerPixel;
   1.605 -    pixels = SDL_malloc(SDL_PublicSurface->h * length);
   1.606 -    if (pixels && SDL_PublicSurface->pixels) {
   1.607 -        src = (Uint8*)SDL_PublicSurface->pixels;
   1.608 +    length = PublicSurface->w * PublicSurface->format->BytesPerPixel;
   1.609 +    pixels = SDL_malloc(PublicSurface->h * length);
   1.610 +    if (pixels && PublicSurface->pixels) {
   1.611 +        src = (Uint8*)PublicSurface->pixels;
   1.612          dst = (Uint8*)pixels;
   1.613 -        for (row = 0; row < SDL_PublicSurface->h; ++row) {
   1.614 +        for (row = 0; row < PublicSurface->h; ++row) {
   1.615              SDL_memcpy(dst, src, length);
   1.616 -            src += SDL_PublicSurface->pitch;
   1.617 +            src += PublicSurface->pitch;
   1.618              dst += length;
   1.619          }
   1.620      }
   1.621  
   1.622      /* Do the physical mode switch */
   1.623 -    if (SDL_GetWindowFlags(SDL_VideoWindow) & SDL_WINDOW_FULLSCREEN) {
   1.624 -        if (SDL_SetWindowFullscreen(SDL_VideoWindow, 0) < 0) {
   1.625 +    if (SDL_GetWindowFlags(VideoWindow) & SDL_WINDOW_FULLSCREEN) {
   1.626 +        if (SDL_SetWindowFullscreen(VideoWindow, 0) < 0) {
   1.627              return 0;
   1.628          }
   1.629 -        SDL_PublicSurface->flags &= ~SDL_FULLSCREEN;
   1.630 +        PublicSurface->flags &= ~SDL_FULLSCREEN;
   1.631      } else {
   1.632 -        if (SDL_SetWindowFullscreen(SDL_VideoWindow, 1) < 0) {
   1.633 +        if (SDL_SetWindowFullscreen(VideoWindow, 1) < 0) {
   1.634              return 0;
   1.635          }
   1.636 -        SDL_PublicSurface->flags |= SDL_FULLSCREEN;
   1.637 +        PublicSurface->flags |= SDL_FULLSCREEN;
   1.638      }
   1.639  
   1.640      /* Recreate the screen surface */
   1.641 -    SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow);
   1.642 -    if (!SDL_WindowSurface) {
   1.643 +    WindowSurface = SDL_GetWindowSurface(VideoWindow);
   1.644 +    if (!WindowSurface) {
   1.645          /* We're totally hosed... */
   1.646          return 0;
   1.647      }
   1.648  
   1.649      /* Center the public surface in the window surface */
   1.650 -    SDL_GetWindowSize(SDL_VideoWindow, &window_w, &window_h);
   1.651 -    SDL_VideoViewport.x = (window_w - SDL_VideoSurface->w)/2;
   1.652 -    SDL_VideoViewport.y = (window_h - SDL_VideoSurface->h)/2;
   1.653 -    SDL_VideoViewport.w = SDL_VideoSurface->w;
   1.654 -    SDL_VideoViewport.h = SDL_VideoSurface->h;
   1.655 +    SDL_GetWindowSize(VideoWindow, &window_w, &window_h);
   1.656 +    VideoViewport.x = (window_w - VideoSurface->w)/2;
   1.657 +    VideoViewport.y = (window_h - VideoSurface->h)/2;
   1.658 +    VideoViewport.w = VideoSurface->w;
   1.659 +    VideoViewport.h = VideoSurface->h;
   1.660  
   1.661      /* Do some shuffling behind the application's back if format changes */
   1.662 -    if (SDL_VideoSurface->format->format != SDL_WindowSurface->format->format) {
   1.663 -        if (SDL_ShadowSurface) {
   1.664 -            if (SDL_ShadowSurface->format->format == SDL_WindowSurface->format->format) {
   1.665 +    if (VideoSurface->format->format != WindowSurface->format->format) {
   1.666 +        if (ShadowSurface) {
   1.667 +            if (ShadowSurface->format->format == WindowSurface->format->format) {
   1.668                  /* Whee!  We don't need a shadow surface anymore! */
   1.669 -                SDL_VideoSurface->flags &= ~SDL_DONTFREE;
   1.670 -                SDL_FreeSurface(SDL_VideoSurface);
   1.671 -                SDL_free(SDL_ShadowSurface->pixels);
   1.672 -                SDL_VideoSurface = SDL_ShadowSurface;
   1.673 -                SDL_VideoSurface->flags |= SDL_PREALLOC;
   1.674 -                SDL_ShadowSurface = NULL;
   1.675 +                VideoSurface->flags &= ~SDL_DONTFREE;
   1.676 +                SDL_FreeSurface(VideoSurface);
   1.677 +                SDL_free(ShadowSurface->pixels);
   1.678 +                VideoSurface = ShadowSurface;
   1.679 +                VideoSurface->flags |= SDL_PREALLOC;
   1.680 +                ShadowSurface = NULL;
   1.681              } else {
   1.682                  /* No problem, just change the video surface format */
   1.683 -                SDL_FreeFormat(SDL_VideoSurface->format);
   1.684 -                SDL_VideoSurface->format = SDL_WindowSurface->format;
   1.685 -                SDL_VideoSurface->format->refcount++;
   1.686 -                SDL_InvalidateMap(SDL_ShadowSurface->map);
   1.687 +                SDL_FreeFormat(VideoSurface->format);
   1.688 +                VideoSurface->format = WindowSurface->format;
   1.689 +                VideoSurface->format->refcount++;
   1.690 +                SDL_InvalidateMap(ShadowSurface->map);
   1.691              }
   1.692          } else {
   1.693              /* We can make the video surface the shadow surface */
   1.694 -            SDL_ShadowSurface = SDL_VideoSurface;
   1.695 -            SDL_ShadowSurface->pitch = SDL_CalculatePitch(SDL_ShadowSurface);
   1.696 -            SDL_ShadowSurface->pixels = SDL_malloc(SDL_ShadowSurface->h * SDL_ShadowSurface->pitch);
   1.697 -            if (!SDL_ShadowSurface->pixels) {
   1.698 +            ShadowSurface = VideoSurface;
   1.699 +            ShadowSurface->pitch = SDL_CalculatePitch(ShadowSurface);
   1.700 +            ShadowSurface->pixels = SDL_malloc(ShadowSurface->h * ShadowSurface->pitch);
   1.701 +            if (!ShadowSurface->pixels) {
   1.702                  /* Uh oh, we're hosed */
   1.703 -                SDL_ShadowSurface = NULL;
   1.704 +                ShadowSurface = NULL;
   1.705                  return 0;
   1.706              }
   1.707 -            SDL_ShadowSurface->flags &= ~SDL_PREALLOC;
   1.708 +            ShadowSurface->flags &= ~SDL_PREALLOC;
   1.709  
   1.710 -            SDL_VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0);
   1.711 -            SDL_VideoSurface->flags = SDL_ShadowSurface->flags;
   1.712 -            SDL_VideoSurface->flags |= SDL_PREALLOC;
   1.713 -            SDL_FreeFormat(SDL_VideoSurface->format);
   1.714 -            SDL_VideoSurface->format = SDL_WindowSurface->format;
   1.715 -            SDL_VideoSurface->format->refcount++;
   1.716 -            SDL_VideoSurface->w = SDL_ShadowSurface->w;
   1.717 -            SDL_VideoSurface->h = SDL_ShadowSurface->h;
   1.718 +            VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0);
   1.719 +            VideoSurface->flags = ShadowSurface->flags;
   1.720 +            VideoSurface->flags |= SDL_PREALLOC;
   1.721 +            SDL_FreeFormat(VideoSurface->format);
   1.722 +            VideoSurface->format = WindowSurface->format;
   1.723 +            VideoSurface->format->refcount++;
   1.724 +            VideoSurface->w = ShadowSurface->w;
   1.725 +            VideoSurface->h = ShadowSurface->h;
   1.726          }
   1.727      }
   1.728  
   1.729      /* Update the video surface */
   1.730 -    SDL_VideoSurface->pitch = SDL_WindowSurface->pitch;
   1.731 -    SDL_VideoSurface->pixels = (void *)((Uint8 *)SDL_WindowSurface->pixels +
   1.732 -        SDL_VideoViewport.y * SDL_VideoSurface->pitch +
   1.733 -        SDL_VideoViewport.x  * SDL_VideoSurface->format->BytesPerPixel);
   1.734 -    SDL_SetClipRect(SDL_VideoSurface, NULL);
   1.735 +    VideoSurface->pitch = WindowSurface->pitch;
   1.736 +    VideoSurface->pixels = (void *)((Uint8 *)WindowSurface->pixels +
   1.737 +        VideoViewport.y * VideoSurface->pitch +
   1.738 +        VideoViewport.x  * VideoSurface->format->BytesPerPixel);
   1.739 +    SDL_SetClipRect(VideoSurface, NULL);
   1.740  
   1.741      /* Copy the old bits back */
   1.742      if (pixels) {
   1.743          src = (Uint8*)pixels;
   1.744 -        dst = (Uint8*)SDL_PublicSurface->pixels;
   1.745 -        for (row = 0; row < SDL_PublicSurface->h; ++row) {
   1.746 +        dst = (Uint8*)PublicSurface->pixels;
   1.747 +        for (row = 0; row < PublicSurface->h; ++row) {
   1.748              SDL_memcpy(dst, src, length);
   1.749              src += length;
   1.750 -            dst += SDL_PublicSurface->pitch;
   1.751 +            dst += PublicSurface->pitch;
   1.752          }
   1.753 -        SDL_Flip(SDL_PublicSurface);
   1.754 +        SDL_Flip(PublicSurface);
   1.755          SDL_free(pixels);
   1.756      }
   1.757  
   1.758 @@ -1419,15 +1423,15 @@
   1.759  SDL_WM_GrabInput(SDL_GrabMode mode)
   1.760  {
   1.761      if (mode != SDL_GRAB_QUERY) {
   1.762 -        SDL_SetWindowGrab(SDL_VideoWindow, mode);
   1.763 +        SDL_SetWindowGrab(VideoWindow, mode);
   1.764      }
   1.765 -    return (SDL_GrabMode) SDL_GetWindowGrab(SDL_VideoWindow);
   1.766 +    return (SDL_GrabMode) SDL_GetWindowGrab(VideoWindow);
   1.767  }
   1.768  
   1.769  void
   1.770  SDL_WarpMouse(Uint16 x, Uint16 y)
   1.771  {
   1.772 -    SDL_WarpMouseInWindow(SDL_VideoWindow, x, y);
   1.773 +    SDL_WarpMouseInWindow(VideoWindow, x, y);
   1.774  }
   1.775  
   1.776  Uint8
   1.777 @@ -1436,7 +1440,7 @@
   1.778      Uint8 state = 0;
   1.779      Uint32 flags = 0;
   1.780  
   1.781 -    flags = SDL_GetWindowFlags(SDL_VideoWindow);
   1.782 +    flags = SDL_GetWindowFlags(VideoWindow);
   1.783      if ((flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED)) {
   1.784          state |= SDL_APPACTIVE;
   1.785      }
   1.786 @@ -1479,7 +1483,7 @@
   1.787  int
   1.788  SDL_GetWMInfo(SDL_SysWMinfo * info)
   1.789  {
   1.790 -    return SDL_GetWindowWMInfo(SDL_VideoWindow, info);
   1.791 +    return SDL_GetWindowWMInfo(VideoWindow, info);
   1.792  }
   1.793  
   1.794  #if 0
   1.795 @@ -1492,10 +1496,10 @@
   1.796      if (SHOULD_DRAWCURSOR(SDL_cursorstate)) {
   1.797          /* Erase and redraw mouse cursor in new position */
   1.798          SDL_LockCursor();
   1.799 -        SDL_EraseCursor(SDL_VideoSurface);
   1.800 +        SDL_EraseCursor(VideoSurface);
   1.801          SDL_cursor->area.x = (x - SDL_cursor->hot_x);
   1.802          SDL_cursor->area.y = (y - SDL_cursor->hot_y);
   1.803 -        SDL_DrawCursor(SDL_VideoSurface);
   1.804 +        SDL_DrawCursor(VideoSurface);
   1.805          SDL_UnlockCursor();
   1.806      } else if (_this->MoveWMCursor) {
   1.807          _this->MoveWMCursor(_this, x, y);
   1.808 @@ -1527,11 +1531,11 @@
   1.809          area->h += area->y;
   1.810          area->y = 0;
   1.811      }
   1.812 -    clip_diff = (area->x + area->w) - SDL_VideoSurface->w;
   1.813 +    clip_diff = (area->x + area->w) - VideoSurface->w;
   1.814      if (clip_diff > 0) {
   1.815          area->w = area->w < clip_diff ? 0 : area->w - clip_diff;
   1.816      }
   1.817 -    clip_diff = (area->y + area->h) - SDL_VideoSurface->h;
   1.818 +    clip_diff = (area->y + area->h) - VideoSurface->h;
   1.819      if (clip_diff > 0) {
   1.820          area->h = area->h < clip_diff ? 0 : area->h - clip_diff;
   1.821      }
   1.822 @@ -1747,7 +1751,7 @@
   1.823      SDL_loblit RunBlit;
   1.824  
   1.825      /* Make sure we can steal the blit mapping */
   1.826 -    if (screen->map->dst != SDL_VideoSurface) {
   1.827 +    if (screen->map->dst != VideoSurface) {
   1.828          return;
   1.829      }
   1.830  
   1.831 @@ -1763,7 +1767,7 @@
   1.832      info.aux_data = screen->map->sw_data->aux_data;
   1.833      info.src = screen->format;
   1.834      info.table = screen->map->table;
   1.835 -    info.dst = SDL_VideoSurface->format;
   1.836 +    info.dst = VideoSurface->format;
   1.837      RunBlit = screen->map->sw_data->blit;
   1.838  
   1.839      /* Run the actual software blit */
   1.840 @@ -1789,8 +1793,8 @@
   1.841  
   1.842          /* Set up the copy pointers */
   1.843          screenbpp = screen->format->BytesPerPixel;
   1.844 -        if ((screen == SDL_VideoSurface) ||
   1.845 -            FORMAT_EQUAL(screen->format, SDL_VideoSurface->format)) {
   1.846 +        if ((screen == VideoSurface) ||
   1.847 +            FORMAT_EQUAL(screen->format, VideoSurface->format)) {
   1.848              dst = SDL_cursor->save[0];
   1.849          } else {
   1.850              dst = SDL_cursor->save[1];
   1.851 @@ -1979,7 +1983,7 @@
   1.852          return NULL;
   1.853      }
   1.854  
   1.855 -    if (display != SDL_PublicSurface) {
   1.856 +    if (display != PublicSurface) {
   1.857          SDL_SetError("YUV display is only supported on the screen surface");
   1.858          return NULL;
   1.859      }
   1.860 @@ -2109,8 +2113,8 @@
   1.861      }
   1.862  
   1.863      display = overlay->hwdata->display;
   1.864 -    if (display != SDL_VideoSurface) {
   1.865 -        overlay->hwdata->display = display = SDL_VideoSurface;
   1.866 +    if (display != VideoSurface) {
   1.867 +        overlay->hwdata->display = display = VideoSurface;
   1.868          overlay->hwdata->display_format = SDL_MasksToPixelFormatEnum(
   1.869                                                  display->format->BitsPerPixel,
   1.870                                                  display->format->Rmask,
   1.871 @@ -2138,7 +2142,7 @@
   1.872                              pixels, display->pitch) < 0) {
   1.873          return -1;
   1.874      }
   1.875 -    SDL_UpdateWindowSurface(SDL_VideoWindow);
   1.876 +    SDL_UpdateWindowSurface(VideoWindow);
   1.877      return 0;
   1.878  }
   1.879  
   1.880 @@ -2160,7 +2164,7 @@
   1.881  void
   1.882  SDL_GL_SwapBuffers(void)
   1.883  {
   1.884 -    SDL_GL_SwapWindow(SDL_VideoWindow);
   1.885 +    SDL_GL_SwapWindow(VideoWindow);
   1.886  }
   1.887  
   1.888  int
   1.889 @@ -2181,19 +2185,19 @@
   1.890      } else {
   1.891          SDL_CalculateGammaRamp(blue, blue_ramp);
   1.892      }
   1.893 -    return SDL_SetWindowGammaRamp(SDL_VideoWindow, red_ramp, green_ramp, blue_ramp);
   1.894 +    return SDL_SetWindowGammaRamp(VideoWindow, red_ramp, green_ramp, blue_ramp);
   1.895  }
   1.896  
   1.897  int
   1.898  SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue)
   1.899  {
   1.900 -    return SDL_SetWindowGammaRamp(SDL_VideoWindow, red, green, blue);
   1.901 +    return SDL_SetWindowGammaRamp(VideoWindow, red, green, blue);
   1.902  }
   1.903  
   1.904  int
   1.905  SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
   1.906  {
   1.907 -    return SDL_GetWindowGammaRamp(SDL_VideoWindow, red, green, blue);
   1.908 +    return SDL_GetWindowGammaRamp(VideoWindow, red, green, blue);
   1.909  }
   1.910  
   1.911  int
   1.912 @@ -2216,15 +2220,15 @@
   1.913  int
   1.914  SDL_EnableUNICODE(int enable)
   1.915  {
   1.916 -    int previous = SDL_enabled_UNICODE;
   1.917 +    int previous = EnabledUnicode;
   1.918  
   1.919      switch (enable) {
   1.920      case 1:
   1.921 -        SDL_enabled_UNICODE = 1;
   1.922 +        EnabledUnicode = 1;
   1.923          SDL_StartTextInput();
   1.924          break;
   1.925      case 0:
   1.926 -        SDL_enabled_UNICODE = 0;
   1.927 +        EnabledUnicode = 0;
   1.928          SDL_StopTextInput();
   1.929          break;
   1.930      }