Improve Emscripten build
This is what I got so far for a working emscripten build of DevilutionX, using the most recent version of emscripten
- Had to remove the --as-needed linker flag, as that isn't valid anymore (wasm-ld complained about it)
- Added pthread support so the Lua things load
- Disable strip attempt on js files (it didn't like it)
- Disable LTO for web builds
- Created a custom loader for the .mpq files. Right now this loads from the same directory as index.html, not from something the user has to supply, so we will need to rework this so that the user has to supply the .mpq file
I also disabled the intro videos for myself as I thought that was the hangup, but it turns out doing the sASYNCIFY flag, along with yielding to the browser in dx.cpp, made everything run smoothly
And I made it so the resulting index.html makes the game smol and disable fullscreen and fit to screen by default.
What doesn't work/needs taking a look at:
- ~~Save games persisting~~ Got this working
Please let me know if there is anything I ought to focus on or fix so that it's up to DevX standards, I am just making this draft PR right now so people can try out the web stuff
https://github.com/user-attachments/assets/0bfb3320-e1a2-423f-a547-8b006c90435f
Added a simple looking File Manager button + dialog for allowing the user to load their own .mpq file, which is saved in the browser for future use. I tried to keep the styling as plain as possible, but still functional
Also, saves and settings are persisted to the browser too
Very nice work!
If we can get it to work as well as https://d07riv.github.io/diabloweb/ i have access to update it.
You can grab the optimized shareware data from here: https://github.com/diasurgical/devilutionx-assets/releases/download/v4/spawn.mpq (it would be good to handle language packs from here as well, since http is easy on the browser).
If we can get it to work as well as https://d07riv.github.io/diabloweb/ i have access to update it.
That would be awesome! As long as we can preserve that current build it has, just for historical purposes lol. I also nabbed up https://devilutionx.app (running on Cloudflare Pages) for people to test out the most current changes to this PR, so that we can test that things are running how we want them to. (styling is of my own doing, it'll look very plain in the actual build)
Next steps I think to change/look at is finding a good dynamic sizing for the canvas. Right now it's hard-coded to 640x480
You can grab the optimized shareware data from here: https://github.com/diasurgical/devilutionx-assets/releases/download/v4/spawn.mpq (it would be good to handle language packs from here as well, since http is easy on the browser).
Perfect! Thanks so much for this, I've switch to using that version in the deployed version - seems good!
Oh language pack loading would be cool to add
I think this is good to go for full review, been playing on web for a while and testing it on different platforms/deployments and it works!
In terms of the language pack features - I think this PR is good for a baseline working Emscripten build, where we can then add the language support stuff to the GitHub page deployment of the game ourselves