src/SDL12_compat.c
changeset 54 3511abf3a80d
parent 53 1c23821d3299
child 55 852e5d3808f2
     1.1 --- a/src/SDL12_compat.c	Sun Feb 10 13:13:38 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Wed Feb 13 08:33:29 2019 -0500
     1.3 @@ -22,6 +22,7 @@
     1.4  /* This file contains functions for backwards compatibility with SDL 1.2 */
     1.5  
     1.6  // !!! FIXME: clean up code conventions
     1.7 +// !!! FIXME: grep for VideoWindow20 places that might care if it's NULL
     1.8  
     1.9  #include "SDL20_include_wrapper.h"
    1.10  
    1.11 @@ -96,6 +97,20 @@
    1.12  
    1.13  // !!! IMPLEMENT_ME X11_KeyToUnicode
    1.14  
    1.15 +
    1.16 +#if 0
    1.17 +#define FIXME(x) do {} while (0)
    1.18 +#else
    1.19 +#define FIXME(x) \
    1.20 +    do { \
    1.21 +        static SDL_bool seen = SDL_FALSE; \
    1.22 +        if (!seen) { \
    1.23 +            fprintf(stderr, "FIXME: %s (%s:%d)\n", x, __FILE__, __LINE__); \
    1.24 +            seen = SDL_TRUE; \
    1.25 +        } \
    1.26 +    } while (0)
    1.27 +#endif
    1.28 +
    1.29  #define SDL20_SYM(rc,fn,params,args,ret) \
    1.30      typedef rc (SDLCALL *SDL20_##fn##_t) params; \
    1.31      static SDL20_##fn##_t SDL20_##fn = NULL;
    1.32 @@ -408,6 +423,7 @@
    1.33      SDL_Rect **modes;  /* ptrs to each item in modeslist, for SDL_ListModes() */
    1.34  } VideoModeList;
    1.35  
    1.36 +// !!! FIXME: go through all of these.
    1.37  static VideoModeList *VideoModes = NULL;
    1.38  static int VideoModesCount = 0;
    1.39  static SDL12_VideoInfo VideoInfo;
    1.40 @@ -642,9 +658,10 @@
    1.41  DECLSPEC int SDLCALL
    1.42  SDL_InitSubSystem(Uint32 sdl12flags)
    1.43  {
    1.44 -    // !!! FIXME: there is never a parachute in SDL2, should we catch segfaults ourselves?
    1.45 +    FIXME("there is never a parachute in SDL2, should we catch segfaults ourselves?");
    1.46  
    1.47 -    // !!! FIXME: support event thread where it makes sense to do so?
    1.48 +    FIXME("support event thread where it makes sense to do so?");
    1.49 +
    1.50  	if ( (sdl12flags & SDL12_INIT_EVENTTHREAD) == SDL12_INIT_EVENTTHREAD ) {
    1.51  		return SDL20_SetError("OS doesn't support threaded events");
    1.52  	}
    1.53 @@ -667,12 +684,13 @@
    1.54      if (sdl12flags & SDL12_INIT_CDROM)
    1.55          CDRomInit = 1;
    1.56  
    1.57 -    // !!! FIXME: do something about SDL12_INIT_EVENTTHREAD
    1.58 +    FIXME("do something about SDL12_INIT_EVENTTHREAD");
    1.59  
    1.60      rc = SDL20_Init(sdl20flags);
    1.61      if ((rc == 0) && (sdl20flags & SDL_INIT_VIDEO)) {
    1.62          if (Init12Video() == -1) {
    1.63 -            return -1;  /* !!! FIXME: should we deinit other subsystems? */
    1.64 +            FIXME("should we deinit other subsystems?");
    1.65 +            return -1;
    1.66          }
    1.67      }
    1.68  
    1.69 @@ -682,7 +700,7 @@
    1.70  DECLSPEC int SDLCALL
    1.71  SDL_Init(Uint32 sdl12flags)
    1.72  {
    1.73 -    // !!! FIXME: what was different in 1.2?
    1.74 +    FIXME("what was different in 1.2?");
    1.75      return SDL_InitSubSystem(sdl12flags);   /* there's no difference betwee Init and InitSubSystem in SDL2. */
    1.76  }
    1.77  
    1.78 @@ -705,7 +723,7 @@
    1.79          extraflags |= SDL12_INIT_CDROM;
    1.80      }
    1.81  
    1.82 -    // !!! FIXME: do something about SDL12_INIT_EVENTTHREAD
    1.83 +    FIXME("do something about SDL12_INIT_EVENTTHREAD");
    1.84  
    1.85      *_flags20 = flags20;
    1.86      *_extraflags = extraflags;
    1.87 @@ -768,12 +786,12 @@
    1.88          CDRomInit = 0;
    1.89      }
    1.90  
    1.91 -    // !!! FIXME: reset a bunch of other global variables too.
    1.92 +    FIXME("reset a bunch of other global variables too.");
    1.93      if (sdl12flags & SDL12_INIT_VIDEO) {
    1.94          Quit12Video();
    1.95      }
    1.96  
    1.97 -    // !!! FIXME: do something about SDL12_INIT_EVENTTHREAD
    1.98 +    FIXME("do something about SDL12_INIT_EVENTTHREAD");
    1.99      SDL20_QuitSubSystem(sdl20flags);
   1.100  
   1.101      if ((SDL20_WasInit(0) == 0) && (!CDRomInit)) {
   1.102 @@ -945,7 +963,7 @@
   1.103  DECLSPEC int SDLCALL
   1.104  SDL_WaitEvent(SDL12_Event *event12)
   1.105  {
   1.106 -    /* !!! FIXME: In 1.2, this only fails (-1) if you haven't SDL_Init()'d. */
   1.107 +    FIXME("In 1.2, this only fails (-1) if you haven't SDL_Init()'d.");
   1.108      while (!SDL_PollEvent(event12))
   1.109          SDL20_Delay(10);
   1.110      return 1;
   1.111 @@ -1025,7 +1043,8 @@
   1.112                      break;
   1.113  
   1.114                  case SDL_WINDOWEVENT_RESIZED:
   1.115 -                case SDL_WINDOWEVENT_SIZE_CHANGED:  // !!! FIXME: what's the difference between RESIZED and SIZE_CHANGED?
   1.116 +                case SDL_WINDOWEVENT_SIZE_CHANGED:
   1.117 +                    FIXME("what's the difference between RESIZED and SIZE_CHANGED?");
   1.118                      event12.type = SDL12_VIDEORESIZE;
   1.119                      event12.resize.w = event20->window.data1;
   1.120                      event12.resize.h = event20->window.data2;
   1.121 @@ -1072,15 +1091,11 @@
   1.122          // !!! FIXME: this is sort of a mess to convert.
   1.123          //case SDL_SYSWMEVENT:
   1.124  
   1.125 -        // !!! FIXME: write me
   1.126 -        case SDL_KEYDOWN:
   1.127 -        case SDL_KEYUP:
   1.128 -            return 0;
   1.129 +        case SDL_KEYDOWN: FIXME("write me"); return 0;
   1.130 +        case SDL_KEYUP: FIXME("write me"); return 0;
   1.131  
   1.132 -        // !!! FIXME: write me
   1.133 -        case SDL_TEXTEDITING:
   1.134 -        case SDL_TEXTINPUT:
   1.135 -            return 0;
   1.136 +        case SDL_TEXTEDITING: FIXME("write me"); return 0;
   1.137 +        case SDL_TEXTINPUT: FIXME("write me"); return 0;
   1.138  
   1.139          case SDL_MOUSEMOTION:
   1.140          	event12.type = SDL12_MOUSEMOTION;
   1.141 @@ -1244,8 +1259,8 @@
   1.142      format12->Gmask = surface20->format->Gmask;
   1.143      format12->Bmask = surface20->format->Bmask;
   1.144      format12->Amask = surface20->format->Amask;
   1.145 -    /* !!! FIXME: format12->colorkey; */
   1.146 -    /* !!! FIXME: format12->alpha; */
   1.147 +    FIXME("format12->colorkey");
   1.148 +    FIXME("format12->alpha");
   1.149  
   1.150      SDL20_zerop(surface12);
   1.151      flags = surface20->flags;
   1.152 @@ -1259,7 +1274,7 @@
   1.153      surface12->format = format12;
   1.154      surface12->w = surface20->w;
   1.155      surface12->h = surface20->h;
   1.156 -    surface12->pitch = (Uint16) surface20->pitch;  /* !!! FIXME: make sure this fits in a Uint16 */
   1.157 +    surface12->pitch = (Uint16) surface20->pitch;  FIXME("make sure this fits in a Uint16");
   1.158      surface12->pixels = surface20->pixels;
   1.159      surface12->offset = 0;
   1.160      surface12->surface20 = surface20;
   1.161 @@ -1626,25 +1641,31 @@
   1.162  DECLSPEC int SDLCALL
   1.163  SDL_SetAlpha(SDL12_Surface * surface, Uint32 flag, Uint8 value)
   1.164  {
   1.165 -#error write me
   1.166 +    FIXME("write me");
   1.167 +    return SDL20_Unsupported();
   1.168  }
   1.169  
   1.170  DECLSPEC SDL12_Surface * SDLCALL
   1.171  SDL_DisplayFormat(SDL12_Surface *surface12)
   1.172  {
   1.173 -#error write me
   1.174 +    FIXME("write me");
   1.175 +    SDL20_Unsupported();
   1.176 +    return NULL;
   1.177  }
   1.178  
   1.179  DECLSPEC SDL12_Surface * SDLCALL
   1.180  SDL_DisplayFormatAlpha(SDL12_Surface *surface)
   1.181  {
   1.182 -#error write me
   1.183 +    FIXME("write me");
   1.184 +    SDL20_Unsupported();
   1.185 +    return NULL;
   1.186  }
   1.187  
   1.188  DECLSPEC void SDLCALL
   1.189  SDL_UpdateRects(SDL12_Surface * screen12, int numrects, SDL_Rect * rects)
   1.190  {
   1.191 -#error write me
   1.192 +    FIXME("write me");
   1.193 +    SDL20_Unsupported();
   1.194  }
   1.195  
   1.196  DECLSPEC void SDLCALL
   1.197 @@ -1695,7 +1716,8 @@
   1.198  DECLSPEC void SDLCALL
   1.199  SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask)
   1.200  {
   1.201 -#error write me
   1.202 +    FIXME("write me");
   1.203 +    SDL20_Unsupported();
   1.204  }
   1.205  
   1.206  DECLSPEC int SDLCALL
   1.207 @@ -1708,7 +1730,8 @@
   1.208  DECLSPEC int SDLCALL
   1.209  SDL_WM_ToggleFullScreen(SDL12_Surface *surface)
   1.210  {
   1.211 -#error write me
   1.212 +    FIXME("write me");
   1.213 +    return SDL20_Unsupported();
   1.214  }
   1.215  
   1.216  typedef enum
   1.217 @@ -1756,21 +1779,24 @@
   1.218  SDL_SetPalette(SDL12_Surface *surface12, int flags, const SDL_Color *colors,
   1.219                 int firstcolor, int ncolors)
   1.220  {
   1.221 -#error write me
   1.222 +    FIXME("write me");
   1.223 +    return SDL20_Unsupported();
   1.224  }
   1.225  
   1.226  DECLSPEC int SDLCALL
   1.227  SDL_SetColors(SDL12_Surface *surface12, const SDL_Color * colors, int firstcolor,
   1.228                int ncolors)
   1.229  {
   1.230 -#error write me
   1.231 +    FIXME("write me");
   1.232 +    return SDL20_Unsupported();
   1.233  }
   1.234  
   1.235  DECLSPEC int SDLCALL
   1.236  SDL_GetWMInfo(SDL_SysWMinfo * info)
   1.237  {
   1.238 -#error write me
   1.239 -    return SDL_GetWindowWMInfo(VideoWindow20, info);
   1.240 +    FIXME("write me");
   1.241 +    //return SDL20_GetWindowWMInfo(VideoWindow20, info);
   1.242 +    return SDL20_Unsupported();
   1.243  }
   1.244  
   1.245  struct private_yuvhwdata
   1.246 @@ -1783,31 +1809,35 @@
   1.247  DECLSPEC SDL_Overlay * SDLCALL
   1.248  SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL12_Surface *display)
   1.249  {
   1.250 -#error write me
   1.251 +    FIXME("write me");
   1.252 +    SDL20_Unsupported();
   1.253 +    return NULL;
   1.254  }
   1.255  
   1.256  DECLSPEC int SDLCALL
   1.257  SDL_LockYUVOverlay(SDL_Overlay * overlay)
   1.258  {
   1.259 -#error write me
   1.260 +    FIXME("write me");
   1.261 +    return SDL20_Unsupported();
   1.262  }
   1.263  
   1.264  DECLSPEC void SDLCALL
   1.265  SDL_UnlockYUVOverlay(SDL_Overlay * overlay)
   1.266  {
   1.267 -#error write me
   1.268 +    FIXME("write me");
   1.269  }
   1.270  
   1.271  DECLSPEC int SDLCALL
   1.272  SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
   1.273  {
   1.274 -#error write me
   1.275 +    FIXME("write me");
   1.276 +    return SDL20_Unsupported();
   1.277  }
   1.278  
   1.279  DECLSPEC void SDLCALL
   1.280  SDL_FreeYUVOverlay(SDL_Overlay * overlay)
   1.281  {
   1.282 -#error write me
   1.283 +    FIXME("write me");
   1.284  }
   1.285  
   1.286  DECLSPEC int SDLCALL
   1.287 @@ -1820,7 +1850,7 @@
   1.288      if (attr == SDL12_GL_SWAP_CONTROL)
   1.289      {
   1.290          SwapInterval = value;
   1.291 -#error Actually set swap interval somewhere.
   1.292 +        FIXME("Actually set swap interval somewhere");
   1.293          return 0;
   1.294      }
   1.295  
   1.296 @@ -1906,7 +1936,8 @@
   1.297  DECLSPEC int SDLCALL
   1.298  SDL_EnableUNICODE(int enable)
   1.299  {
   1.300 -#error write me
   1.301 +    FIXME("write me");
   1.302 +    return SDL20_Unsupported();
   1.303  }
   1.304  
   1.305  static Uint32
   1.306 @@ -1965,7 +1996,8 @@
   1.307  DECLSPEC int SDLCALL
   1.308  SDL_CDNumDrives(void)
   1.309  {
   1.310 -    return 0;  /* !!! FIXME: should return -1 without SDL_INIT_CDROM */
   1.311 +    FIXME("should return -1 without SDL_INIT_CDROM");
   1.312 +    return 0;
   1.313  }
   1.314  
   1.315  DECLSPEC const char *SDLCALL SDL_CDName(int drive) { SDL20_Unsupported(); return NULL; }
   1.316 @@ -2006,10 +2038,9 @@
   1.317      return SDL20_UnlockMutex(mutex);
   1.318  }
   1.319  
   1.320 -
   1.321 -/* !!! FIXME: Removed from 2.0; do nothing. We can't even report failure. */
   1.322  DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread)
   1.323  {
   1.324 +    FIXME("Removed from 2.0; do nothing. We can't even report failure.");
   1.325      fprintf(stderr,
   1.326          "WARNING: this app used SDL_KillThread(), an unforgivable curse.\n"
   1.327          "This program should be fixed. No thread was actually harmed.\n");
   1.328 @@ -2191,7 +2222,7 @@
   1.329  static Sint64 SDLCALL
   1.330  RWops12to20_seek(struct SDL_RWops *rwops20, Sint64 offset, int whence)
   1.331  {
   1.332 -    /* !!! FIXME: fail if (offset) is too big */
   1.333 +    FIXME("fail if (offset) is too big");
   1.334      SDL12_RWops *rwops12 = (SDL12_RWops *) rwops20->hidden.unknown.data1;
   1.335      return (Sint64) rwops12->seek(rwops12, (int) offset, whence);
   1.336  }
   1.337 @@ -2199,7 +2230,7 @@
   1.338  static size_t SDLCALL
   1.339  RWops12to20_read(struct SDL_RWops *rwops20, void *ptr, size_t size, size_t maxnum)
   1.340  {
   1.341 -    /* !!! FIXME: fail if (size) or (maxnum) is too big */
   1.342 +    FIXME("fail if (size) or (maxnum) is too big");
   1.343      SDL12_RWops *rwops12 = (SDL12_RWops *) rwops20->hidden.unknown.data1;
   1.344      return (size_t) rwops12->read(rwops12, ptr, (int) size, (int) maxnum);
   1.345  }
   1.346 @@ -2207,7 +2238,7 @@
   1.347  static size_t SDLCALL
   1.348  RWops12to20_write(struct SDL_RWops *rwops20, const void *ptr, size_t size, size_t num)
   1.349  {
   1.350 -    /* !!! FIXME: fail if (size) or (maxnum) is too big */
   1.351 +    FIXME("fail if (size) or (maxnum) is too big");
   1.352      SDL12_RWops *rwops12 = (SDL12_RWops *) rwops20->hidden.unknown.data1;
   1.353      return (size_t) rwops12->write(rwops12, ptr, (int) size, (int) num);
   1.354  }
   1.355 @@ -2266,7 +2297,7 @@
   1.356  DECLSPEC int SDLCALL
   1.357  SDL_SaveBMP_RW(SDL12_Surface *surface12, SDL12_RWops *rwops12, int freerwops12)
   1.358  {
   1.359 -    // !!! FIXME: wrap surface.
   1.360 +    FIXME("wrap surface");
   1.361      SDL_RWops *rwops20 = RWops12to20(rwops12);
   1.362      const int retval = SDL20_SaveBMP_RW(surface12->surface20, rwops20, freerwops12);
   1.363      if (!freerwops12)  /* free our wrapper if SDL2 didn't close it. */
   1.364 @@ -2280,7 +2311,7 @@
   1.365  {
   1.366      SDL_RWops *rwops20 = RWops12to20(rwops12);
   1.367      SDL_AudioSpec *retval = SDL20_LoadWAV_RW(rwops20, freerwops12, spec, buf, len);
   1.368 -    /* !!! FIXME: deal with non-1.2 formats, like float32 ... */
   1.369 +    FIXME("deal with non-1.2 formats, like float32");
   1.370      if (!freerwops12)  /* free our wrapper if SDL2 didn't close it. */
   1.371          SDL20_FreeRW(rwops20);
   1.372      return retval;