src/SDL12_compat.c
changeset 35 365748d8ff6c
parent 34 946cbc18ba19
child 36 d71bb358e954
     1.1 --- a/src/SDL12_compat.c	Sat Apr 13 23:38:00 2013 -0400
     1.2 +++ b/src/SDL12_compat.c	Sun Apr 14 00:11:20 2013 -0400
     1.3 @@ -36,10 +36,6 @@
     1.4  
     1.5  #include <stdarg.h>
     1.6  
     1.7 -//#include "video/SDL_sysvideo.h"
     1.8 -//#include "video/SDL_pixels_c.h"
     1.9 -//#include "render/SDL_yuv_sw_c.h"
    1.10 -
    1.11  // !!! IMPLEMENT_ME SDL_ConvertSurface
    1.12  // !!! IMPLEMENT_ME SDL_GetKeyName
    1.13  // !!! IMPLEMENT_ME SDL_GetKeyState
    1.14 @@ -56,7 +52,7 @@
    1.15  
    1.16  
    1.17  #define SDL20_SYM(rc,fn,params,args,ret) \
    1.18 -    typedef rc (*SDL20_##fn##_t) params; \
    1.19 +    typedef rc (SDLCALL *SDL20_##fn##_t) params; \
    1.20      static SDL20_##fn##_t SDL20_##fn = NULL;
    1.21  #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \
    1.22      SDL20_SYM(rc,fn,params,args,ret)
    1.23 @@ -64,13 +60,13 @@
    1.24  #undef SDL20_SYM_PASSTHROUGH
    1.25  #undef SDL20_SYM
    1.26  
    1.27 -typedef int (*SDL20_SetError_t)(const char *fmt, ...);
    1.28 +typedef int (SDLCALL *SDL20_SetError_t)(const char *fmt, ...);
    1.29  static SDL20_SetError_t SDL20_SetError = NULL;
    1.30  
    1.31  /* Things that _should_ be binary compatible pass right through... */
    1.32  #define SDL20_SYM(rc,fn,params,args,ret)
    1.33  #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \
    1.34 -    rc SDL_##fn params { ret SDL20_##fn args; }
    1.35 +    DECLSPEC rc SDLCALL SDL_##fn params { ret SDL20_##fn args; }
    1.36  #include "SDL20_syms.h"
    1.37  #undef SDL20_SYM_PASSTHROUGH
    1.38  #undef SDL20_SYM
    1.39 @@ -396,12 +392,6 @@
    1.40  static EventQueueType *EventQueueTail = NULL;
    1.41  static EventQueueType *EventQueueAvailable = NULL;
    1.42  
    1.43 -const SDL_version *
    1.44 -SDL_Linked_Version(void)
    1.45 -{
    1.46 -    static const SDL_version version = { 1, 2, SDL12_COMPAT_VERSION };
    1.47 -    return &version;
    1.48 -}
    1.49  
    1.50  /* Obviously we can't use SDL_LoadObject() to load SDL2.  :)  */
    1.51  #if defined(_WINDOWS)
    1.52 @@ -471,6 +461,12 @@
    1.53      return okay;
    1.54  }
    1.55  
    1.56 +DECLSPEC const SDL_version * SDLCALL
    1.57 +SDL_Linked_Version(void)
    1.58 +{
    1.59 +    static const SDL_version version = { 1, 2, SDL12_COMPAT_VERSION };
    1.60 +    return &version;
    1.61 +}
    1.62  
    1.63  static int
    1.64  GetVideoDisplay()
    1.65 @@ -529,19 +525,19 @@
    1.66      return rc;
    1.67  }
    1.68  
    1.69 -int
    1.70 +DECLSPEC int SDLCALL
    1.71  SDL_InitSubSystem(Uint32 sdl12flags)
    1.72  {
    1.73      return DoSDLInit(1, sdl12flags);
    1.74  }
    1.75  
    1.76 -int
    1.77 +DECLSPEC int SDLCALL
    1.78  SDL_Init(Uint32 sdl12flags)
    1.79  {
    1.80      return DoSDLInit(0, sdl12flags);
    1.81  }
    1.82  
    1.83 -Uint32
    1.84 +DECLSPEC Uint32 SDLCALL
    1.85  SDL_WasInit(Uint32 sdl12flags)
    1.86  {
    1.87      // !!! FIXME: this is cut and pasted several places.
    1.88 @@ -565,7 +561,7 @@
    1.89      return SDL20_WasInit(sdl20flags) | extraflags;
    1.90  }
    1.91  
    1.92 -void
    1.93 +DECLSPEC void SDLCALL
    1.94  SDL_QuitSubSystem(Uint32 sdl12flags)
    1.95  {
    1.96      Uint32 sdl20flags = 0;
    1.97 @@ -597,7 +593,7 @@
    1.98      // !!! FIXME: UnloadSDL20() ?
    1.99  }
   1.100  
   1.101 -void
   1.102 +DECLSPEC void SDLCALL
   1.103  SDL_Quit(void)
   1.104  {
   1.105      // !!! FIXME: reset a bunch of other global variables too.
   1.106 @@ -611,7 +607,7 @@
   1.107      UnloadSDL20();
   1.108  }
   1.109  
   1.110 -void
   1.111 +DECLSPEC void SDLCALL
   1.112  SDL_SetError(const char *fmt, ...)
   1.113  {
   1.114      char ch;
   1.115 @@ -635,7 +631,7 @@
   1.116      }
   1.117  }
   1.118  
   1.119 -const char *
   1.120 +DECLSPEC const char * SDLCALL
   1.121  SDL_GetError(void)
   1.122  {
   1.123      if (!Loaded_SDL20)
   1.124 @@ -661,19 +657,19 @@
   1.125      return NULL;
   1.126  }
   1.127  
   1.128 -const char *
   1.129 +DECLSPEC const char * SDLCALL
   1.130  SDL_AudioDriverName(char *namebuf, int maxlen)
   1.131  {
   1.132      return GetDriverName(SDL20_GetCurrentAudioDriver(), namebuf, maxlen);
   1.133  }
   1.134  
   1.135 -const char *
   1.136 +DECLSPEC const char * SDLCALL
   1.137  SDL_VideoDriverName(char *namebuf, int maxlen)
   1.138  {
   1.139      return GetDriverName(SDL20_GetCurrentVideoDriver(), namebuf, maxlen);
   1.140  }
   1.141  
   1.142 -int
   1.143 +DECLSPEC int SDLCALL
   1.144  SDL_PollEvent(SDL12_Event *event12)
   1.145  {
   1.146      EventQueueType *next;
   1.147 @@ -691,7 +687,7 @@
   1.148      return 1;
   1.149  }
   1.150  
   1.151 -int
   1.152 +DECLSPEC int SDLCALL
   1.153  SDL_PushEvent(SDL12_Event *event12)
   1.154  {
   1.155      EventQueueType *item = EventQueueAvailable;
   1.156 @@ -709,7 +705,7 @@
   1.157      return 0;
   1.158  }
   1.159  
   1.160 -int
   1.161 +DECLSPEC int SDLCALL
   1.162  SDL_PeepEvents(SDL12_Event *events12, int numevents, SDL_eventaction action, Uint32 mask)
   1.163  {
   1.164      if (action == SDL_ADDEVENT)
   1.165 @@ -765,7 +761,7 @@
   1.166      return 0;
   1.167  }
   1.168  
   1.169 -int
   1.170 +DECLSPEC int SDLCALL
   1.171  SDL_WaitEvent(SDL12_Event *event12)
   1.172  {
   1.173      /* In 1.2, this only fails (-1) if you haven't SDL_Init()'d. */
   1.174 @@ -788,10 +784,7 @@
   1.175      return SDL_FALSE;
   1.176  }
   1.177  
   1.178 -Uint8 SDL_GetMouseState(int *x, int *y);
   1.179 -
   1.180 -
   1.181 -Uint8
   1.182 +DECLSPEC Uint8 SDLCALL
   1.183  SDL_EventState(Uint8 type, int state)
   1.184  {
   1.185      /* the values of "state" match between 1.2 and 2.0 */
   1.186 @@ -806,6 +799,21 @@
   1.187      return retval;
   1.188  }
   1.189  
   1.190 +DECLSPEC Uint8 SDLCALL
   1.191 +SDL_GetMouseState(int *x, int *y)
   1.192 +{
   1.193 +    const Uint32 state20 = SDL20_GetMouseState(x, y);
   1.194 +    Uint8 retval = (state20 & 0x7);  /* left, right, and middle will match. */
   1.195 +
   1.196 +    /* the X[12] buttons are different in 1.2; mousewheel was in the way. */
   1.197 +    if (state20 & SDL_BUTTON(SDL_BUTTON_X1))
   1.198 +        retval |= (1<<5);
   1.199 +    if (state20 & SDL_BUTTON(SDL_BUTTON_X2))
   1.200 +        retval |= (1<<6);
   1.201 +
   1.202 +    return retval;
   1.203 +}
   1.204 +
   1.205  static int
   1.206  EventFilter20to12(void *data, SDL_Event *event20)
   1.207  {
   1.208 @@ -998,14 +1006,14 @@
   1.209      return 0;  /* always drop it from the 2.0 event queue. */
   1.210  }
   1.211  
   1.212 -void
   1.213 +DECLSPEC void SDLCALL
   1.214  SDL_SetEventFilter(SDL12_EventFilter filter12)
   1.215  {
   1.216      /* We always have a filter installed, but will call the app's too. */
   1.217      EventFilter12 = filter12;
   1.218  }
   1.219  
   1.220 -SDL12_EventFilter
   1.221 +DECLSPEC SDL12_EventFilter SDLCALL
   1.222  SDL_GetEventFilter(void)
   1.223  {
   1.224      return EventFilter12;
   1.225 @@ -1086,7 +1094,7 @@
   1.226      return NULL;
   1.227  }
   1.228  
   1.229 -SDL12_Surface *
   1.230 +DECLSPEC SDL12_Surface * SDLCALL
   1.231  SDL_CreateRGBSurface(Uint32 sdl12flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
   1.232  {
   1.233      SDL_Surface *surface20 = SDL20_CreateRGBSurface(0, width, height, depth, Rmask, Gmask, Bmask, Amask);
   1.234 @@ -1100,7 +1108,7 @@
   1.235      return surface12;
   1.236  }
   1.237  
   1.238 -SDL12_Surface *
   1.239 +DECLSPEC SDL12_Surface * SDLCALL
   1.240  SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
   1.241  {
   1.242      SDL_Surface *surface20 = SDL20_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask);
   1.243 @@ -1114,7 +1122,8 @@
   1.244      return surface12;
   1.245  }
   1.246  
   1.247 -void SDL_FreeSurface(SDL12_Surface *surface12)
   1.248 +DECLSPEC void SDLCALL
   1.249 +SDL_FreeSurface(SDL12_Surface *surface12)
   1.250  {
   1.251      if (surface12) {
   1.252          SDL20_FreeSurface(surface12->surface20);
   1.253 @@ -1126,14 +1135,14 @@
   1.254      }
   1.255  }
   1.256  
   1.257 -void
   1.258 +DECLSPEC void SDLCALL
   1.259  SDL_GetClipRect(SDL12_Surface *surface12, SDL_Rect *rect)
   1.260  {
   1.261      if (surface12 && rect)
   1.262  	    SDL_memcpy(rect, &surface12->clip_rect, sizeof (SDL_Rect));
   1.263  }
   1.264  
   1.265 -SDL_bool
   1.266 +DECLSPEC SDL_bool SDLCALL
   1.267  SDL_SetClipRect(SDL12_Surface *surface12, const SDL_Rect *rect)
   1.268  {
   1.269      SDL_bool retval = SDL_FALSE;
   1.270 @@ -1145,7 +1154,7 @@
   1.271      return retval;
   1.272  }
   1.273  
   1.274 -int
   1.275 +DECLSPEC int SDLCALL
   1.276  SDL_FillRect(SDL12_Surface *dst, SDL_Rect *dstrect, Uint32 color)
   1.277  {
   1.278      const SDL_Rect orig_dstrect = *dstrect;
   1.279 @@ -1187,7 +1196,7 @@
   1.280      return format20;
   1.281  }
   1.282  
   1.283 -Uint32
   1.284 +DECLSPEC Uint32 SDLCALL
   1.285  SDL_MapRGB(const SDL12_PixelFormat *format12, Uint8 r, Uint8 g, Uint8 b)
   1.286  {
   1.287      /* This is probably way slower than apps expect. */
   1.288 @@ -1196,7 +1205,7 @@
   1.289      return SDL20_MapRGB(PixelFormat12to20(&format20, &palette20, format12), r, g, b);
   1.290  }
   1.291  
   1.292 -Uint32
   1.293 +DECLSPEC Uint32 SDLCALL
   1.294  SDL_MapRGBA(const SDL12_PixelFormat *format12, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
   1.295  {
   1.296      /* This is probably way slower than apps expect. */
   1.297 @@ -1205,7 +1214,7 @@
   1.298      return SDL20_MapRGBA(PixelFormat12to20(&format20, &palette20, format12), r, g, b, a);
   1.299  }
   1.300  
   1.301 -void
   1.302 +DECLSPEC void SDLCALL
   1.303  SDL_GetRGB(Uint32 pixel, const SDL12_PixelFormat *format12, Uint8 *r, Uint8 *g, Uint8 *b)
   1.304  {
   1.305      /* This is probably way slower than apps expect. */
   1.306 @@ -1214,7 +1223,7 @@
   1.307      return SDL20_GetRGB(pixel, PixelFormat12to20(&format20, &palette20, format12), r, g, b);
   1.308  }
   1.309  
   1.310 -void
   1.311 +DECLSPEC void SDLCALL
   1.312  SDL_GetRGBA(Uint32 pixel, const SDL12_PixelFormat *format12, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
   1.313  {
   1.314      /* This is probably way slower than apps expect. */
   1.315 @@ -1223,7 +1232,7 @@
   1.316      return SDL20_GetRGBA(pixel, PixelFormat12to20(&format20, &palette20, format12), r, g, b, a);
   1.317  }
   1.318  
   1.319 -const SDL12_VideoInfo *
   1.320 +DECLSPEC const SDL12_VideoInfo * SDLCALL
   1.321  SDL_GetVideoInfo(void)
   1.322  {
   1.323      SDL_DisplayMode mode;
   1.324 @@ -1239,7 +1248,7 @@
   1.325      return &VideoInfo;
   1.326  }
   1.327  
   1.328 -int
   1.329 +DECLSPEC int SDLCALL
   1.330  SDL_VideoModeOK(int width, int height, int bpp, Uint32 sdl12flags)
   1.331  {
   1.332      int i, nummodes, actual_bpp = 0;
   1.333 @@ -1271,7 +1280,7 @@
   1.334  }
   1.335  
   1.336  #if SANITY_CHECK_THIS_CODE
   1.337 -SDL_Rect **
   1.338 +DECLSPEC SDL_Rect ** SDLCALL
   1.339  SDL_ListModes(const SDL12_PixelFormat *format, Uint32 flags)
   1.340  {
   1.341      int i, nmodes;
   1.342 @@ -1337,7 +1346,7 @@
   1.343  }
   1.344  #endif
   1.345  
   1.346 -void
   1.347 +DECLSPEC void SDLCALL
   1.348  SDL_FreeCursor(SDL12_Cursor *cursor12)
   1.349  {
   1.350      if (cursor12)
   1.351 @@ -1350,7 +1359,7 @@
   1.352      }
   1.353  }
   1.354  
   1.355 -SDL12_Cursor *
   1.356 +DECLSPEC SDL12_Cursor * SDLCALL
   1.357  SDL_CreateCursor(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
   1.358  {
   1.359      const size_t datasize = h * (w / 8);
   1.360 @@ -1395,14 +1404,14 @@
   1.361      return NULL;
   1.362  }
   1.363  
   1.364 -void
   1.365 +DECLSPEC void SDLCALL
   1.366  SDL_SetCursor(SDL12_Cursor *cursor)
   1.367  {
   1.368      CurrentCursor = cursor;
   1.369      SDL20_SetCursor(cursor ? cursor->wm_cursor : NULL);
   1.370  }
   1.371  
   1.372 -SDL12_Cursor *
   1.373 +DECLSPEC SDL12_Cursor * SDLCALL
   1.374  SDL_GetCursor(void)
   1.375  {
   1.376      return CurrentCursor;
   1.377 @@ -1531,7 +1540,7 @@
   1.378      return 0;
   1.379  }
   1.380  
   1.381 -SDL_Surface *
   1.382 +DECLSPEC SDL12_Surface * SDLCALL
   1.383  SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
   1.384  {
   1.385      SDL_DisplayMode desktop_mode;
   1.386 @@ -1709,14 +1718,14 @@
   1.387      return PublicSurface;
   1.388  }
   1.389  
   1.390 -SDL_Surface *
   1.391 +DECLSPEC SDL12_Surface * SDLCALL
   1.392  SDL_GetVideoSurface(void)
   1.393  {
   1.394      return PublicSurface;
   1.395  }
   1.396  
   1.397 -int
   1.398 -SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
   1.399 +DECLSPEC int SDLCALL
   1.400 +SDL_SetAlpha(SDL12_Surface * surface, Uint32 flag, Uint8 value)
   1.401  {
   1.402      if (flag & SDL_SRCALPHA) {
   1.403          /* According to the docs, value is ignored for alpha surfaces */
   1.404 @@ -1734,7 +1743,7 @@
   1.405      return 0;
   1.406  }
   1.407  
   1.408 -SDL12_Surface *
   1.409 +DECLSPEC SDL12_Surface * SDLCALL
   1.410  SDL_DisplayFormat(SDL12_Surface *surface12)
   1.411  {
   1.412      SDL12_PixelFormat *format;
   1.413 @@ -1749,7 +1758,7 @@
   1.414      return SDL_ConvertSurface(surface, format, SDL12_RLEACCEL);
   1.415  }
   1.416  
   1.417 -SDL12_Surface *
   1.418 +DECLSPEC SDL12_Surface * SDLCALL
   1.419  SDL_DisplayFormatAlpha(SDL12_Surface *surface)
   1.420  {
   1.421      SDL_PixelFormat *vf;
   1.422 @@ -1806,7 +1815,7 @@
   1.423      return converted;
   1.424  }
   1.425  
   1.426 -void
   1.427 +DECLSPEC void SDLCALL
   1.428  SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects)
   1.429  {
   1.430      int i;
   1.431 @@ -1844,27 +1853,27 @@
   1.432  }
   1.433  #endif
   1.434  
   1.435 -void
   1.436 -SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
   1.437 +DECLSPEC void SDLCALL
   1.438 +SDL_UpdateRect(SDL12_Surface *screen12, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
   1.439  {
   1.440 -    if (screen) {
   1.441 +    if (screen12) {
   1.442          SDL_Rect rect;
   1.443          rect.x = (int) x;
   1.444          rect.y = (int) y;
   1.445 -        rect.w = (int) (w ? w : screen->w);
   1.446 -        rect.h = (int) (h ? h : screen->h);
   1.447 -        SDL_UpdateRects(screen, 1, &rect);
   1.448 +        rect.w = (int) (w ? w : screen12->w);
   1.449 +        rect.h = (int) (h ? h : screen12->h);
   1.450 +        SDL_UpdateRects(screen12, 1, &rect);
   1.451      }
   1.452  }
   1.453  
   1.454 -int
   1.455 -SDL_Flip(SDL_Surface * screen)
   1.456 +DECLSPEC int SDLCALL
   1.457 +SDL_Flip(SDL12_Surface *screen12)
   1.458  {
   1.459 -    SDL_UpdateRect(screen, 0, 0, 0, 0);
   1.460 +    SDL_UpdateRect(screen12, 0, 0, 0, 0);
   1.461      return 0;
   1.462  }
   1.463  
   1.464 -void
   1.465 +DECLSPEC void SDLCALL
   1.466  SDL_WM_SetCaption(const char *title, const char *icon)
   1.467  {
   1.468      if (WindowTitle) {
   1.469 @@ -1878,7 +1887,7 @@
   1.470      SDL20_SetWindowTitle(VideoWindow20, WindowTitle);
   1.471  }
   1.472  
   1.473 -void
   1.474 +DECLSPEC void SDLCALL
   1.475  SDL_WM_GetCaption(const char **title, const char **icon)
   1.476  {
   1.477      if (title) {
   1.478 @@ -1890,7 +1899,7 @@
   1.479  }
   1.480  
   1.481  #if SANITY_CHECK_THIS_CODE
   1.482 -void
   1.483 +DECLSPEC void SDLCALL
   1.484  SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask)
   1.485  {
   1.486      // !!! FIXME: free previous icon?
   1.487 @@ -1899,7 +1908,7 @@
   1.488  }
   1.489  #endif
   1.490  
   1.491 -int
   1.492 +DECLSPEC int SDLCALL
   1.493  SDL_WM_IconifyWindow(void)
   1.494  {
   1.495      SDL20_MinimizeWindow(VideoWindow20);
   1.496 @@ -1907,7 +1916,7 @@
   1.497  }
   1.498  
   1.499  #if SANITY_CHECK_THIS_CODE
   1.500 -int
   1.501 +DECLSPEC int SDLCALL
   1.502  SDL_WM_ToggleFullScreen(SDL_Surface *surface)
   1.503  {
   1.504      int length;
   1.505 @@ -2035,7 +2044,7 @@
   1.506      SDL12_GRAB_ON = 1
   1.507  } SDL12_GrabMode;
   1.508  
   1.509 -SDL12_GrabMode
   1.510 +DECLSPEC SDL12_GrabMode SDLCALL
   1.511  SDL_WM_GrabInput(SDL12_GrabMode mode)
   1.512  {
   1.513      if (mode != SDL12_GRAB_QUERY) {
   1.514 @@ -2044,28 +2053,13 @@
   1.515      return SDL20_GetWindowGrab(VideoWindow20) ? SDL12_GRAB_ON : SDL12_GRAB_OFF;
   1.516  }
   1.517  
   1.518 -Uint8
   1.519 -SDL_GetMouseState(int *x, int *y)
   1.520 -{
   1.521 -    const Uint32 state20 = SDL20_GetMouseState(x, y);
   1.522 -    Uint8 retval = (state20 & 0x7);  /* left, right, and middle will match. */
   1.523 -
   1.524 -    /* the X[12] buttons are different in 1.2; mousewheel was in the way. */
   1.525 -    if (state20 & SDL_BUTTON(SDL_BUTTON_X1))
   1.526 -        retval |= (1<<5);
   1.527 -    if (state20 & SDL_BUTTON(SDL_BUTTON_X2))
   1.528 -        retval |= (1<<6);
   1.529 -
   1.530 -    return retval;
   1.531 -}
   1.532 -
   1.533 -void
   1.534 +DECLSPEC void SDLCALL
   1.535  SDL_WarpMouse(Uint16 x, Uint16 y)
   1.536  {
   1.537      SDL20_WarpMouseInWindow(VideoWindow20, x, y);
   1.538  }
   1.539  
   1.540 -Uint8
   1.541 +DECLSPEC Uint8 SDLCALL
   1.542  SDL_GetAppState(void)
   1.543  {
   1.544      Uint8 state12 = 0;
   1.545 @@ -2085,18 +2079,18 @@
   1.546  }
   1.547  
   1.548  #if SANITY_CHECK_THIS_CODE
   1.549 -int
   1.550 -SDL_SetPalette(SDL_Surface * surface, int flags, const SDL_Color * colors,
   1.551 +DECLSPEC int SDLCALL
   1.552 +SDL_SetPalette(SDL12_Surface *surface12, int flags, const SDL_Color *colors,
   1.553                 int firstcolor, int ncolors)
   1.554  {
   1.555 -    return SDL_SetColors(surface, colors, firstcolor, ncolors);
   1.556 +    return SDL_SetColors(surface12, colors, firstcolor, ncolors);
   1.557  }
   1.558  
   1.559 -int
   1.560 -SDL_SetColors(SDL_Surface * surface, const SDL_Color * colors, int firstcolor,
   1.561 +DECLSPEC int SDLCALL
   1.562 +SDL_SetColors(SDL12_Surface *surface12, const SDL_Color * colors, int firstcolor,
   1.563                int ncolors)
   1.564  {
   1.565 -    if (SDL_SetPaletteColors
   1.566 +    if (SDL20_SetPaletteColors
   1.567          (surface->format->palette, colors, firstcolor, ncolors) == 0) {
   1.568          return 1;
   1.569      } else {
   1.570 @@ -2104,7 +2098,7 @@
   1.571      }
   1.572  }
   1.573  
   1.574 -int
   1.575 +DECLSPEC int SDLCALL
   1.576  SDL_GetWMInfo(SDL_SysWMinfo * info)
   1.577  {
   1.578      return SDL_GetWindowWMInfo(VideoWindow20, info);
   1.579 @@ -2595,8 +2589,8 @@
   1.580      Uint32 display_format;
   1.581  };
   1.582  
   1.583 -SDL_Overlay *
   1.584 -SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display)
   1.585 +DECLSPEC SDL_Overlay * SDLCALL
   1.586 +SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL12_Surface *display)
   1.587  {
   1.588      SDL_Overlay *overlay;
   1.589      Uint32 texture_format;
   1.590 @@ -2672,7 +2666,7 @@
   1.591      return overlay;
   1.592  }
   1.593  
   1.594 -int
   1.595 +DECLSPEC int SDLCALL
   1.596  SDL_LockYUVOverlay(SDL_Overlay * overlay)
   1.597  {
   1.598      SDL_Rect rect;
   1.599 @@ -2712,7 +2706,7 @@
   1.600      return 0;
   1.601  }
   1.602  
   1.603 -void
   1.604 +DECLSPEC void SDLCALL
   1.605  SDL_UnlockYUVOverlay(SDL_Overlay * overlay)
   1.606  {
   1.607      if (!overlay) {
   1.608 @@ -2722,7 +2716,7 @@
   1.609      SDL_SW_UnlockYUVTexture(overlay->hwdata->texture);
   1.610  }
   1.611  
   1.612 -int
   1.613 +DECLSPEC int SDLCALL
   1.614  SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
   1.615  {
   1.616      SDL_Surface *display;
   1.617 @@ -2768,7 +2762,7 @@
   1.618      return 0;
   1.619  }
   1.620  
   1.621 -void
   1.622 +DECLSPEC void SDLCALL
   1.623  SDL_FreeYUVOverlay(SDL_Overlay * overlay)
   1.624  {
   1.625      if (!overlay) {
   1.626 @@ -2784,7 +2778,7 @@
   1.627  }
   1.628  #endif
   1.629  
   1.630 -int
   1.631 +DECLSPEC int SDLCALL
   1.632  SDL_GL_SetAttribute(SDL12_GLattr attr, int value)
   1.633  {
   1.634      if (attr >= SDL12_GL_MAX_ATTRIBUTE)
   1.635 @@ -2800,7 +2794,7 @@
   1.636      return SDL20_GL_SetAttribute((SDL_GLattr) attr, value);
   1.637  }
   1.638  
   1.639 -int
   1.640 +DECLSPEC int SDLCALL
   1.641  SDL_GL_GetAttribute(SDL12_GLattr attr, int* value)
   1.642  {
   1.643      if (attr >= SDL12_GL_MAX_ATTRIBUTE)
   1.644 @@ -2817,14 +2811,14 @@
   1.645  }
   1.646  
   1.647  
   1.648 -void
   1.649 +DECLSPEC void SDLCALL
   1.650  SDL_GL_SwapBuffers(void)
   1.651  {
   1.652      if (VideoWindow20)
   1.653          SDL20_GL_SwapWindow(VideoWindow20);
   1.654  }
   1.655  
   1.656 -int
   1.657 +DECLSPEC int SDLCALL
   1.658  SDL_SetGamma(float red, float green, float blue)
   1.659  {
   1.660      Uint16 red_ramp[256];
   1.661 @@ -2847,25 +2841,25 @@
   1.662      return SDL20_SetWindowGammaRamp(VideoWindow20, red_ramp, green_ramp, blue_ramp);
   1.663  }
   1.664  
   1.665 -int
   1.666 +DECLSPEC int SDLCALL
   1.667  SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue)
   1.668  {
   1.669      return SDL20_SetWindowGammaRamp(VideoWindow20, red, green, blue);
   1.670  }
   1.671  
   1.672 -int
   1.673 +DECLSPEC int SDLCALL
   1.674  SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue)
   1.675  {
   1.676      return SDL20_GetWindowGammaRamp(VideoWindow20, red, green, blue);
   1.677  }
   1.678  
   1.679 -int
   1.680 +DECLSPEC int SDLCALL
   1.681  SDL_EnableKeyRepeat(int delay, int interval)
   1.682  {
   1.683      return 0;
   1.684  }
   1.685  
   1.686 -void
   1.687 +DECLSPEC void SDLCALL
   1.688  SDL_GetKeyRepeat(int *delay, int *interval)
   1.689  {
   1.690      if (delay) {
   1.691 @@ -2877,7 +2871,7 @@
   1.692  }
   1.693  
   1.694  #if SANITY_CHECK_THIS_CODE
   1.695 -int
   1.696 +DECLSPEC int SDLCALL
   1.697  SDL_EnableUNICODE(int enable)
   1.698  {
   1.699      int previous = EnabledUnicode;
   1.700 @@ -2902,7 +2896,7 @@
   1.701      return ((SDL12_TimerCallback)param)(interval);
   1.702  }
   1.703  
   1.704 -int
   1.705 +DECLSPEC int SDLCALL
   1.706  SDL_SetTimer(Uint32 interval, SDL12_TimerCallback callback)
   1.707  {
   1.708      static SDL_TimerID compat_timer;
   1.709 @@ -2921,7 +2915,7 @@
   1.710      return 0;
   1.711  }
   1.712  
   1.713 -int
   1.714 +DECLSPEC int SDLCALL
   1.715  SDL_putenv(const char *_var)
   1.716  {
   1.717      char *ptr = NULL;
   1.718 @@ -2949,32 +2943,32 @@
   1.719  typedef void *SDL12_CD;  /* close enough.  :) */
   1.720  typedef int SDL12_CDstatus;  /* close enough.  :) */
   1.721  
   1.722 -int
   1.723 +DECLSPEC int SDLCALL
   1.724  SDL_CDNumDrives(void)
   1.725  {
   1.726      return 0;  /* !!! FIXME: should return -1 without SDL_INIT_CDROM */
   1.727  }
   1.728  
   1.729 -const char *SDL_CDName(int drive) { SDL20_Unsupported(); return NULL; }
   1.730 -SDL12_CD * SDL_CDOpen(int drive) { SDL20_Unsupported(); return NULL; }
   1.731 -SDL12_CDstatus SDL_CDStatus(SDL12_CD *cdrom) { return SDL20_Unsupported(); }
   1.732 -int SDL_CDPlayTracks(SDL12_CD *cdrom, int start_track, int start_frame, int ntracks, int nframes) { return SDL20_Unsupported(); }
   1.733 -int SDL_CDPlay(SDL12_CD *cdrom, int start, int length) { return SDL20_Unsupported(); }
   1.734 -int SDL_CDPause(SDL12_CD *cdrom) { return SDL20_Unsupported(); }
   1.735 -int SDL_CDResume(SDL12_CD *cdrom) { return SDL20_Unsupported(); }
   1.736 -int SDL_CDStop(SDL12_CD *cdrom) { return SDL20_Unsupported(); }
   1.737 -int SDL_CDEject(SDL12_CD *cdrom) { return SDL20_Unsupported(); }
   1.738 -void SDL_CDClose(SDL12_CD *cdrom) {}
   1.739 +DECLSPEC const char *SDLCALL SDL_CDName(int drive) { SDL20_Unsupported(); return NULL; }
   1.740 +DECLSPEC SDL12_CD *SDLCALL SDL_CDOpen(int drive) { SDL20_Unsupported(); return NULL; }
   1.741 +DECLSPEC SDL12_CDstatus SDLCALL SDL_CDStatus(SDL12_CD *cdrom) { return SDL20_Unsupported(); }
   1.742 +DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL12_CD *cdrom, int start_track, int start_frame, int ntracks, int nframes) { return SDL20_Unsupported(); }
   1.743 +DECLSPEC int SDLCALL SDL_CDPlay(SDL12_CD *cdrom, int start, int length) { return SDL20_Unsupported(); }
   1.744 +DECLSPEC int SDLCALL SDL_CDPause(SDL12_CD *cdrom) { return SDL20_Unsupported(); }
   1.745 +DECLSPEC int SDLCALL SDL_CDResume(SDL12_CD *cdrom) { return SDL20_Unsupported(); }
   1.746 +DECLSPEC int SDLCALL SDL_CDStop(SDL12_CD *cdrom) { return SDL20_Unsupported(); }
   1.747 +DECLSPEC int SDLCALL SDL_CDEject(SDL12_CD *cdrom) { return SDL20_Unsupported(); }
   1.748 +DECLSPEC void SDLCALL SDL_CDClose(SDL12_CD *cdrom) {}
   1.749  
   1.750  
   1.751  #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
   1.752 -SDL_Thread *
   1.753 +DECLSPEC SDL_Thread * SDLCALL
   1.754  SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
   1.755  {
   1.756      return SDL20_CreateThread(fn, NULL, data, pfnBeginThread, pfnEndThread);
   1.757  }
   1.758  #else
   1.759 -SDL_Thread *
   1.760 +DECLSPEC SDL_Thread * SDLCALL
   1.761  SDL_CreateThread(int (SDLCALL *fn)(void *), void *data)
   1.762  {
   1.763      return SDL20_CreateThread(fn, NULL, data);
   1.764 @@ -2983,20 +2977,20 @@
   1.765  
   1.766  
   1.767  /* !!! FIXME: Removed from 2.0; do nothing. We can't even report failure. */
   1.768 -void SDL_KillThread(SDL_Thread *thread) {}
   1.769 +DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread) {}
   1.770  
   1.771  /* This changed from an opaque pointer to an int in 2.0. */
   1.772  typedef struct _SDL12_TimerID *SDL12_TimerID;
   1.773  SDL_COMPILE_TIME_ASSERT(timer, sizeof(SDL12_TimerID) >= sizeof(SDL_TimerID));
   1.774  
   1.775  
   1.776 -SDL12_TimerID
   1.777 +DECLSPEC SDL12_TimerID SDLCALL
   1.778  SDL_AddTimer(Uint32 interval, SDL12_NewTimerCallback callback, void *param)
   1.779  {
   1.780      return (SDL12_TimerID) ((size_t) SDL20_AddTimer(interval, callback, param));
   1.781  }
   1.782  
   1.783 -SDL_bool
   1.784 +DECLSPEC SDL_bool SDLCALL
   1.785  SDL_RemoveTimer(SDL12_TimerID id)
   1.786  {
   1.787      return SDL20_RemoveTimer((SDL_TimerID) ((size_t)id));
   1.788 @@ -3014,7 +3008,7 @@
   1.789  } SDL12_RWops;
   1.790  
   1.791  
   1.792 -SDL12_RWops *
   1.793 +DECLSPEC SDL12_RWops * SDLCALL
   1.794  SDL_AllocRW(void)
   1.795  {
   1.796      SDL12_RWops *rwops = (SDL12_RWops *) SDL20_malloc(sizeof (SDL12_RWops));
   1.797 @@ -3023,7 +3017,7 @@
   1.798      return rwops;
   1.799  }
   1.800  
   1.801 -void
   1.802 +DECLSPEC void SDLCALL
   1.803  SDL_FreeRW(SDL12_RWops *rwops12)
   1.804  {
   1.805      SDL20_free(rwops12);
   1.806 @@ -3083,32 +3077,32 @@
   1.807      return rwops12;
   1.808  }
   1.809  
   1.810 -SDL12_RWops *
   1.811 +DECLSPEC SDL12_RWops * SDLCALL
   1.812  SDL_RWFromFile(const char *file, const char *mode)
   1.813  {
   1.814      return RWops20to12(SDL20_RWFromFile(file, mode));
   1.815  }
   1.816  
   1.817 -SDL12_RWops *
   1.818 +DECLSPEC SDL12_RWops * SDLCALL
   1.819  SDL_RWFromFP(FILE *io, int autoclose)
   1.820  {
   1.821      return RWops20to12(SDL20_RWFromFP(io, autoclose));
   1.822  }
   1.823  
   1.824 -SDL12_RWops *
   1.825 +DECLSPEC SDL12_RWops * SDLCALL
   1.826  SDL_RWFromMem(void *mem, int size)
   1.827  {
   1.828      return RWops20to12(SDL20_RWFromMem(mem, size));
   1.829  }
   1.830  
   1.831 -SDL12_RWops *
   1.832 +DECLSPEC SDL12_RWops * SDLCALL
   1.833  SDL_RWFromConstMem(const void *mem, int size)
   1.834  {
   1.835      return RWops20to12(SDL20_RWFromConstMem(mem, size));
   1.836  }
   1.837  
   1.838  #define READ_AND_BYTESWAP(endian, bits) \
   1.839 -    Uint##bits SDL_Read##endian##bits(SDL12_RWops *rwops12) { \
   1.840 +    DECLSPEC Uint##bits SDLCALL SDL_Read##endian##bits(SDL12_RWops *rwops12) { \
   1.841          Uint##bits val; rwops12->read(rwops12, &val, sizeof (val), 1); \
   1.842          return SDL_Swap##endian##bits(val); \
   1.843      }
   1.844 @@ -3122,7 +3116,7 @@
   1.845  #undef READ_AND_BYTESWAP
   1.846  
   1.847  #define BYTESWAP_AND_WRITE(endian, bits) \
   1.848 -    int SDL_Write##endian##bits(SDL12_RWops *rwops12, Uint##bits val) { \
   1.849 +    DECLSPEC int SDLCALL SDL_Write##endian##bits(SDL12_RWops *rwops12, Uint##bits val) { \
   1.850          val = SDL_Swap##endian##bits(val); \
   1.851          return rwops12->write(rwops12, &val, sizeof (val), 1); \
   1.852      }
   1.853 @@ -3158,7 +3152,7 @@
   1.854      return size;
   1.855  }
   1.856  
   1.857 -static Sint64
   1.858 +static Sint64 SDLCALL
   1.859  RWops12to20_seek(struct SDL_RWops *rwops20, Sint64 offset, int whence)
   1.860  {
   1.861      /* !!! FIXME: fail if (offset) is too big */
   1.862 @@ -3220,7 +3214,7 @@
   1.863      return rwops20;
   1.864  }
   1.865  
   1.866 -SDL12_Surface *
   1.867 +DECLSPEC SDL12_Surface * SDLCALL
   1.868  SDL_LoadBMP_RW(SDL12_RWops *rwops12, int freerwops12)
   1.869  {
   1.870      SDL_RWops *rwops20 = RWops12to20(rwops12);
   1.871 @@ -3233,7 +3227,7 @@
   1.872      return surface12;
   1.873  }
   1.874  
   1.875 -int
   1.876 +DECLSPEC int SDLCALL
   1.877  SDL_SaveBMP_RW(SDL12_Surface *surface12, SDL12_RWops *rwops12, int freerwops12)
   1.878  {
   1.879      // !!! FIXME: wrap surface.
   1.880 @@ -3244,7 +3238,7 @@
   1.881      return retval;
   1.882  }
   1.883  
   1.884 -SDL_AudioSpec *
   1.885 +DECLSPEC SDL_AudioSpec * SDLCALL
   1.886  SDL_LoadWAV_RW(SDL12_RWops *rwops12, int freerwops12,
   1.887                 SDL_AudioSpec *spec, Uint8 **buf, Uint32 *len)
   1.888  {