Repository navigation
Make the WASM build playable in the browser - #88
Open
sspilleman wants to merge 1 commit into
Open
sspilleman wants to merge 1 commit into
sspilleman wants to merge 1 commit into
Conversation
- Keep writable files (players, settings, savegames, hall of fame) in an IDBFS mount at /persistent, backed by IndexedDB. Its contents are synced in before main starts and synced out shortly after each write, so progress survives page reloads. - Yield in getMouseState so the menus' "wait for button release" loops let the browser deliver the mouseup event. Without it, clicking a menu button froze the page. - Build SDL2_mixer with libmodplug (-sSDL2_MIXER_FORMATS=mod) so the .xm music plays, and link the C++ runtime that libmodplug needs. - Link with -sJSPI=1 so SDL_Delay suspends instead of busy-waiting on the browser's main thread. - Add a `make deploy` target that fills wasm/deploy/ with a self-contained copy for static hosting, and start-http-wasm.sh to serve the build locally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
wasm/build compiled, but wasn't playable in a browser. This fixes it:-sJSPI=1, soSDL_Delaysuspends instead of busy-waiting on the browser's main thread.getMouseStatenow yields briefly under Emscripten, so the browser can deliver themouseupevent.-sSDL2_MIXER_FORMATS=modand link the C++ runtime that libmodplug needs./persistent, backed by IndexedDB. It's synced in beforemainreads any file, and synced out shortly after each write.make deployfillswasm/deploy/with a self-contained copy for static hosting (with a README on serving and embedding it), andstart-http-wasm.shserves the build locally.All changes outside
wasm/are behind__EMSCRIPTEN__, so other ports are unaffected.Testing
The browser build isn't part of CI yet. I'm happy to add it to
.github/platform-builds.jsonin a follow-up if you'd like.🤖 Generated with Claude Code