Home Creators Posts Import Register Favorites Logout

Content

SDL 1.2 is a problem that won't go away.

Although we accept patches in revision control, we aren't ever doing another formal release of it, and it hasn't been seriously maintained in years. 1.2.15, the final release, was born 11 days before my daughter, who's now halfway through 1st grade.

Most of the things you love are using SDL2 at this point, but there are notable exceptions, not to mention legacy things that will never be updated, and often on legacy apps, the most intense piece of bitrot is SDL 1.2.

This is a good thing, in a way, as SDL was intended to be swapped out with better builds as new tech rolled in, isolating the game itself from platform and API incompatibilities. Better to have an open source shared library be the point of failure, instead of a binary blob from a company that folded decades ago.

When we started seriously focusing on SDL2, we made a conscious choice to abandon 1.2. It didn't make sense to maintain two separate APIs that sorta smelled the same, and the internals had changed enough that implementing an audio or video target for one library would be a complete rewrite for the other. If nothing else, we wanted to encourage people to move to the thing we moved to, since we had spent so long fixing interface mistakes of the past in the new version.

In recent years, however, those that remain on 1.2 are feeling the pain. Even if they don't care about new cool features in SDL2, they're left out of new platforms, new targets like Wayland video and WASAPI audio, and if nothing else: bug fixes. Things fall apart, and if you're stuck on 1.2, that's been your problem.

Recently I started back up on an ancient project I never got too far with before, called sdl12-compat. The idea is to provide a binary that looks like SDL 1.2 to the legacy app, but behind the scenes, it loads a real build of SDL2 and lets that do all the hard work, just translating between what the app and SDL2 need.

This removes a massive code surface that no one is maintaining,  eliminating a ton of Mac, Win32, and X11 bugs for old games, lets those games use newer APIs like Wayland and Metal and WASAPI, and gets apps no one is updating onto SDL2. Theoretically even the old Loki games could be using  FULLSCREEN_DESKTOP and SDL_Render behind the scenes.  :) 

My hope is that someday soon, we'll be able to replace libSDL-1.2.so.0 in Linux distros with this little library. The current SDL 1.2, with all its ports and targets and assembly code and blitters is 172,041 lines of code; this will probably be less than 5,000. 

One of the other benefits in modernizing applications is that old, software-rendered games now get pushed to the GPU. The app thinks it is drawing to pixels on an SDL_Surface, but sdl12-compat moves them to a texture to blast them to the screen. This has the nice effect of ancient 2D games going fullscreen with "free" scaling and running at a better framerate. They can use SDL_WINDOW_FULLSCREEN_DESKTOP, which doesn't mess with your desktop resolution and, as an added bonus, will slide into a macOS Fullscreen Space without taking your desktop hostage.

This wrapper is zlib-licensed and uses no code from "classic" SDL 1.2. This means 1.2-based games can live in places they couldn't before, like the Nintendo Switch.

So, in summary:

Want to run these games on Wayland without an X11 fallback? Done.

Want to run these games on Windows UWP? Metal? Direct3D 11? Done.

Want to run these games on platforms that conflict with the LGPL? Done.

Want to run these games on macOS Mojave with all the insane fixes we had to make to SDL2 just to keep things running? Done.

Want to update your dusty old SDL 1.2 package and find it's now several megabytes smaller? Done.

Overall, this is turning out pretty well. Next step, of course, is testing. It works (fairly) well with the handful of things I've tried: UT2004, TuxPaint, etc. If you have a 1.2 program--yours or anyone else's you have on your computer--please give this a test and report issues!

The source code to sdl12-compat is here, and bug reports go here.

Enjoy!

Files

Introducing sdl12-compat

We're working on a compatibility layer, so SDL 1.2 apps will be powered by SDL 2.0 behind the scenes. This gives us a huge number of wins: GPU rendering for 2D games, access to modern API targets and features, a zlib-licensed 1.2 implementation, not to mention deleting 170,000+ lines of code. This is a work in progress, but you can see it's doing pretty well already! You can find sdl12-compat in a Mercurial repository at https://hg.libsdl.org/sdl12-compat If you like this sort of thing, throw a few bucks at my patreon: https://patreon.com/icculus

Comments

Andrew Pam

Excellent!! As a matter of fact I do have a bunch of the old Loki games. You, sir, are a true legend.

boomerz

You see this is why I'm a patron, bc of awesome stuff like this.

mara

this is a really good idea, i love this, will prevent a lot of legacy open source games from being effectively unplayable without porting that no one will ever do

rohit_n

Any plans to make this works on Windows? I made a hacked build, but some apps like Dungeons of Dredmor and Dosbox are complaining about SDL_SetModuleHandle.

Ryan C. Gordon

Yep, Windows is on the TODO list; it should be fairly trivial, but it does need a little bit of magic.

rohit_n

Thanks. One quick fix I can recommend is with the CloseSDL20Library macro for _WINDOWS. There is an extra open bracket that is causing a bunch of unrelated compile errors. I'd submit a patch, but there are other Windows issues that I'm not sure are specific to my setup (MinGW, for example, complains about SDL_CreateMutex and SDL_CreateSemaphore unless I SDL20_SYM them).

Kevin Macey

Going to find my old myth CD from Loki, never finished that game

Robert Mader

Would love to see this project succeed and getting production ready :) +5 from me

tuxayo

> This wrapper is zlib-licensed and uses no code from "classic" SDL 1.2. This means 1.2-based games can live in places they couldn't before, like the Nintendo Switch. > [...] > Want to run these games on platforms that conflict with the LGPL? Done. Can you explain what was the issue with the LGPL and this console?

tuxayo

I though that an LGPL lib could used without issue (as long as if you changes it you agree to gives the changes to the user)

Ryan C. Gordon

LGPL requires you to be able to rebuild the library, but there are roadblocks to that on consoles. More importantly: you can't give out sources to something that uses a console's SDK without violating your NDA with Sony/Nintendo/Microsoft, so you're in an impossible situation; _someone's_ license is getting violated.