Bring Zelda Classic to the Browser
Finding a device or app that isn’t a web browser doesn’t seem easy. These days it’s either web-connected (looking at you ESP32) or just a web browser pretending to be something else (a la electron, PWA or React Native). So, of course, it’s up to us to create more and more exciting things to go through. [Connor Clark] is one of those people, and he brought Classic Zelda to the browser.
Classic Zelda (ZC) is not an official Zelda Game. Instead, it’s an old engine designed to make the world go round in the OG The Legend of Zelda and be easily modified to support hundreds of different games. To date, there are more than 600 games submitted by a large community. ZC is an Allegro-based Windows-only game, so the first step was to eliminate Emscripten to start tweaking the C++ code to support a web environment. Rather than completely transferring Allegro’s massive code base, [Connor] made the jump from Allegro 4 to 5. Allegro 5 has SDL as its backend and adds support for Emscripten.
Unfortunately, the 4 to 5 was not as simple as changing the addiction. The API has been completely rewritten, and there’s a handy adapter known as Allegro Legacy to help transition a project from one to another. After squashing a slew of bugs, it was a relatively painless procedure. After a little detour to get the music and level data working, [Connor] facing its next challenge: multi-threading. Efforts to move the main loop of the browser thread to a Web Worker have run into performance issues in recursive loops, deadlocks, and mutexes. Finally, it added music and gamepad support after fixing several bugs in SDL and Allegro.
It’s an amazing journey with lots of tips and tricks for debugging seemingly unsolvable bugs. The code is available on GitHub, or jump in and start playing if you’re interested. Why not also check out this browser-based OpenSCAD?