src/SDL12_compat.c
changeset 38 3f4404bfd179
parent 37 43520e2731a7
child 39 354ef2d7f999
equal deleted inserted replaced
37:43520e2731a7 38:3f4404bfd179
   529 SDL_Init(Uint32 sdl12flags)
   529 SDL_Init(Uint32 sdl12flags)
   530 {
   530 {
   531     return SDL_InitSubSubsystem(sdl12flags);   /* there's no difference betwee Init and InitSubSystem in SDL2. */
   531     return SDL_InitSubSubsystem(sdl12flags);   /* there's no difference betwee Init and InitSubSystem in SDL2. */
   532 }
   532 }
   533 
   533 
   534 DECLSPEC Uint32 SDLCALL
   534 
   535 SDL_WasInit(Uint32 sdl12flags)
   535 static void
   536 {
   536 InitFlags12To20(const Uint32 flags12, Uint32 *_flags20, Uint32 *_extraflags)
   537     // !!! FIXME: this is cut and pasted several places.
   537 {
   538     Uint32 sdl20flags = 0;
   538     Uint32 flags20 = 0;
   539     Uint32 extraflags = 0;
   539     Uint32 extraflags = 0;
   540 
   540 
   541     #define SETFLAG(flag) if (sdl12flags & SDL12_INIT_##flag) sdl20flags |= SDL_INIT_##flag
   541     #define SETFLAG(flag) if (flags12 & SDL12_INIT_##flag) flags20 |= SDL_INIT_##flag
   542     SETFLAG(TIMER);
   542     SETFLAG(TIMER);
   543     SETFLAG(AUDIO);
   543     SETFLAG(AUDIO);
   544     SETFLAG(VIDEO);
   544     SETFLAG(VIDEO);
   545     SETFLAG(JOYSTICK);
   545     SETFLAG(JOYSTICK);
   546     SETFLAG(NOPARACHUTE);
   546     SETFLAG(NOPARACHUTE);
   547     #undef SETFLAG
   547     #undef SETFLAG
   548 
   548 
   549     if ((sdl12flags & SDL12_INIT_CDROM) && (CDRomInit))
   549     if ((flags12 & SDL12_INIT_CDROM) && (CDRomInit)) {
   550         extraflags |= SDL12_INIT_CDROM;
   550         extraflags |= SDL12_INIT_CDROM;
       
   551     }
   551 
   552 
   552     // !!! FIXME: do something about SDL12_INIT_EVENTTHREAD
   553     // !!! FIXME: do something about SDL12_INIT_EVENTTHREAD
   553 
   554 
   554     // !!! FIXME: convert back to 1.2
   555     *_flags20 = flags20;
   555     return SDL20_WasInit(sdl20flags) | extraflags;
   556     *_extraflags = extraflags;
   556 }
   557 }
   557 
   558 
   558 DECLSPEC void SDLCALL
   559 static Uint32
   559 SDL_QuitSubSystem(Uint32 sdl12flags)
   560 InitFlags20to12(const Uint32 flags20)
   560 {
   561 {
   561     Uint32 sdl20flags = 0;
   562     Uint32 flags12 = 0;
   562 
   563 
   563     #define SETFLAG(flag) if (sdl12flags & SDL12_INIT_##flag) sdl20flags |= SDL_INIT_##flag
   564     #define SETFLAG(flag) if (flags20 & SDL_INIT_##flag) flags12 |= SDL12_INIT_##flag
   564     SETFLAG(TIMER);
   565     SETFLAG(TIMER);
   565     SETFLAG(AUDIO);
   566     SETFLAG(AUDIO);
   566     SETFLAG(VIDEO);
   567     SETFLAG(VIDEO);
   567     SETFLAG(JOYSTICK);
   568     SETFLAG(JOYSTICK);
   568     SETFLAG(NOPARACHUTE);
   569     SETFLAG(NOPARACHUTE);
   569     // There's no CDROM in 2.0, but we'll just pretend it succeeded.
       
   570     #undef SETFLAG
   570     #undef SETFLAG
   571 
   571 
   572     if (sdl12flags & SDL12_INIT_CDROM)
   572     return flags12;
       
   573 }
       
   574 
       
   575 
       
   576 DECLSPEC Uint32 SDLCALL
       
   577 SDL_WasInit(Uint32 sdl12flags)
       
   578 {
       
   579     Uint32 sdl20flags, extraflags;
       
   580     InitFlags12To20(sdl12flags, &sdl20flags, &extraflags);
       
   581 
       
   582     return InitFlags20to12(SDL20_WasInit(sdl20flags)) | extraflags;
       
   583 }
       
   584 
       
   585 DECLSPEC void SDLCALL
       
   586 SDL_QuitSubSystem(Uint32 sdl12flags)
       
   587 {
       
   588     Uint32 sdl20flags, extraflags;
       
   589     InitFlags12To20(sdl12flags, &sdl20flags, &extraflags);
       
   590 
       
   591     if (extraflags & SDL12_INIT_CDROM) {
   573         CDRomInit = 0;
   592         CDRomInit = 0;
       
   593     }
   574 
   594 
   575     // !!! FIXME: reset a bunch of other global variables too.
   595     // !!! FIXME: reset a bunch of other global variables too.
   576     if (sdl12flags & SDL12_INIT_VIDEO) {
   596     if (sdl12flags & SDL12_INIT_VIDEO) {
   577         EventFilter12 = NULL;
   597         EventFilter12 = NULL;
   578         EventQueueAvailable = EventQueueHead = EventQueueTail = NULL;
   598         EventQueueAvailable = EventQueueHead = EventQueueTail = NULL;