Skip to content

Port the SDL game loop to coroutines and add WebAssembly support - #87

Open
fyt000 wants to merge 10 commits into
masterfrom
codex/wasm-coroutines
Open

fyt000 wants to merge 10 commits into
masterfrom
codex/wasm-coroutines

Conversation

@fyt000

@fyt000 fyt000 commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Add a browser build with persistent saves and update scene and input handling for the coroutine game loop.

Copilot AI balanced review requested due to automatic review settings November 29, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The FluidSynth package omits required CMake helpers and target exports, causing consumer configuration failures, and coroutine cancellation can leave the status panel hidden across games.

2 open issues
What changed in this PR

This PR replaces nested SDL game loops with shared coroutine-driven UI flows and adds a WebAssembly build with persistent browser saves.

Changes:

  • Moves scenes, menus, battles, and scripts to asynchronous flows with centralized input, rendering, and cancellation.
  • Adds browser packaging, dependency overlays, and IndexedDB persistence for saves and configuration.
  • Updates native build integration, flow-test configuration, window-close checks, and build documentation.
File Description
wasm/​vcpkg.json Declares browser-build dependencies.
wasm/​triplets/​wasm32-emscripten.cmake Configures static WebAssembly dependencies and exceptions.
wasm/​shell.html Adds browser UI and persistent storage handling.
wasm/​ports/​sdl3/​vcpkg.json Defines the SDL3 overlay package.
wasm/​ports/​sdl3/​usage Documents SDL3 CMake targets.
wasm/​ports/​sdl3/​portfile.cmake Builds SDL3 with overlay patches.
wasm/​ports/​sdl3/​fix-gles2-program-cache-tail.patch Repairs GLES2 program-cache links.
wasm/​ports/​sdl3/​fix-freebsd.patch Adjusts SDL3 package installation paths.
wasm/​ports/​fluidsynth/​vcpkg.json Defines the FluidSynth overlay package.
wasm/​ports/​fluidsynth/​usage Documents FluidSynth package consumption.
wasm/​ports/​fluidsynth/​skip-fake-filename-stat.patch Uses error-code-based filesystem queries.
wasm/​ports/​fluidsynth/​portfile.cmake Adds library-only WebAssembly packaging.
wasm/​ports/​fluidsynth/​fix-gcem.patch Uses GCEM's CMake configuration.
wasm/​ports/​fluidsynth/​emscripten-no-pthread.patch Disables browser thread-priority handling.
wasm/​ports/​fluidsynth/​cxx-linkage-pkgconfig.diff Adds C++ runtime linkage metadata.
wasm/​CMakeLists.txt Builds and packages the browser game.
wasm/​build.ps1 Automates Windows browser builds.
wasm/​.gitattributes Preserves patch whitespace and line endings.
tools/​Test-McpStdio.ps1 Checks close-dialog priority and menu resumption.
tests/​flow/​CMakeLists.txt Configures native and browser flow tests.
src/​WebStorage.h Queues completed writes for browser persistence.
src/​Weather.h Stores animation-driven brightness.
src/​Weather.cpp Moves weather updates out of rendering.
src/​VirtualStick.h Declares touch capture and gesture lifecycle handling.
src/​Video.cpp Makes Smallpot linkage conditional.
src/​UiTask.h Introduces UI tasks and scope cleanup.
src/​UISystem.h Declares asynchronous system-menu operations.
src/​UISystem.cpp Awaits dialogs and requests orderly shutdown.
src/​UIStatus.h Declares asynchronous status actions.
src/​UIStatus.cpp Awaits party, equipment, and item selectors.
src/​UIShop.h Declares coroutine-aware shop handlers.
src/​UIShop.cpp Awaits purchase confirmations and messages.
src/​UiSession.h Defines session and presentation ownership.
src/​UiSession.cpp Coordinates input, scenes, rendering, and shutdown.
src/​UiSdlDriver.h Declares queued SDL event dispatch.
src/​UiSdlDriver.cpp Routes platform events and presents frames.
src/​UISave.h Declares flow-aware save operations.
src/​UISave.cpp Uses game context and awaits load feedback.
src/​UiLoop.h Defines the shared coroutine scheduler.
src/​UiLoop.cpp Implements task polling and frame signals.
src/​UiLayers.h Defines presentation ordering and input priority.
src/​UIKeyConfig.h Declares asynchronous key selection.
src/​UIKeyConfig.cpp Awaits key-capture dialogs.
src/​UIItem.h Declares asynchronous item and pointer handlers.
src/​UiInput.h Adds cancellable input waits and notifications.
src/​UiFlow.h Defines scoped UI and scene flows.
src/​UiFlow.cpp Manages presentation lifetimes and scene advancement.
src/​UIConfig.h Separates configuration input and tick handlers.
src/​UIConfig.cpp Updates controller polling and virtual-stick integration.
src/​UiActions.h Serializes deferred UI actions.
src/​UI.h Declares updated party UI lifecycle handlers.
src/​UI.cpp Separates tab updates and deferred child results.
src/​TitleScene.h Declares the asynchronous title flow.
src/​TitleScene.cpp Awaits new-game, load, and gameplay flows.
src/​TextBoxRoll.h Adopts the new input interface.
src/​TextBoxRoll.cpp Uses normalized wheel events.
src/​TextBox.h Adopts the confirmation interface.
src/​TeamMenu.h Declares lifecycle and selection handlers.
src/​TeamMenu.cpp Separates input processing from selection updates.
src/​Talk.h Declares coroutine-compatible dialogue handlers.
src/​Talk.cpp Adapts dialogue entrance and confirmation.
src/​SuperMenuText.h Adopts the new input interface.
src/​SuperMenuText.cpp Uses normalized text, key, and wheel events.
src/​SubScene.h Declares asynchronous movement and event operations.
src/​ShowRoleDifference.h Adopts the confirmation interface.
src/​ShowExp.h Declares updated experience-screen handlers.
src/​ShowExp.cpp Adapts input gating to normalized events.
src/​ScriptCifa.h Bridges script calls to UI tasks.
src/​ScriptCifa.cpp Awaits script-driven game operations.
src/​Scene.h Declares asynchronous animation helpers.
src/​Scene.cpp Implements awaited animation ticks and fades.
src/​SaveSlot.h Resolves bundled and persistent save formats.
src/​Save.h Exposes resolved slot filenames.
src/​Save.cpp Adds persistent save destinations and slot resolution.
src/​RunNode.h Replaces nested loops with flow lifecycle hooks.
src/​RandomRole.h Declares asynchronous character-generation handlers.
src/​RandomRole.cpp Awaits character-menu initialization.
src/​ParticleSystem.h Adds tick-driven particle updates.
src/​ParticleSystem.cpp Removes particle updates from rendering.
src/​Menu.h Separates menu input, ticks, and lifecycle.
src/​Menu.cpp Adapts navigation and confirmation handling.
src/​McpServer.h Uses normalized events and input cancellation.
src/​McpServer.cpp Integrates automation with session ownership.
src/​MainScenePaper.h Declares asynchronous paper-world advancement.
src/​MainScene.h Declares asynchronous world and entrance handling.
src/​kys.vcxproj.filters Organizes new flow files in Visual Studio.
src/​kys.vcxproj Adds coroutine sources and compiler options.
src/​kys.cpp Switches to SDL application callbacks.
src/​InputBox.h Declares focus-based text input handling.
src/​InputBox.cpp Updates text input lifecycle and confirmation.
src/​Head.h Adopts the confirmation interface.
src/​GameUtil.h Sets the browser game-data path.
src/​GameUtil.cpp Restores and persists browser configuration.
src/​Fade.h Removes the nested-loop fade implementation.
src/​EngineEvent.h Introduces owned, platform-independent input events.
src/​Engine.h Replaces direct event polling interfaces.
src/​Engine.cpp Uses session input state and browser keyboard targeting.
src/​DrawableOnCall.h Adapts callback views to the new lifecycle.
src/​DrawableOnCall.cpp Updates callback construction and input dispatch.
src/​Console.h Declares an asynchronous console flow.
src/​Console.cpp Awaits console dialogs and battles.
src/​CMakeLists.txt Links native coroutine and fiber dependencies.
src/​CifaWorkflow.h Declares the synchronous-script bridge.
src/​CifaWorkflow.cpp Suspends interpreter stacks across asynchronous calls.
src/​Button.h Adopts the new button input interface.
src/​Button.cpp Uses normalized pointer and key events.
src/​BattleSceneSekiro.h Declares asynchronous Sekiro battle advancement.
src/​BattleSceneSekiro.cpp Awaits setup and rewards; shares battle behavior.
src/​BattleSceneRTS.h Adds asynchronous advancement and pointer cleanup.
src/​BattleSceneHades.h Declares asynchronous advancement and mouse tracking.
src/​BattleSceneHades.cpp Separates mouse input from battle advancement.
src/​BattleSceneAct.h Declares shared action-battle and camera handlers.
src/​BattleScene.h Converts battle operations to asynchronous tasks.
src/​BattleNetwork.h Replaces worker threads with polling.
src/​BattleNetwork.cpp Awaits connection UI and retains outgoing buffers.
src/​BattleMenu.h Declares asynchronous role-specific menus.
src/​BattleMenu.cpp Moves automatic selection into menu entrance.
src/​BattleCursor.h Separates cursor input and controller ticks.
src/​BattleCursor.cpp Updates touch targeting and controller navigation.
src/​Application.h Gives the application a UI session.
src/​Application.cpp Starts the shared application flow.
readme.md Documents dependencies, browser builds, and persistence.
kys-cpp-androidstudio/​app/​jni/​src/​CMakeLists.txt Adds flow sources and Boost dependencies to Android.

Review effort: Balanced

Comment thread wasm/ports/fluidsynth/portfile.cmake Outdated
Comment on lines +112 to +115
if(EXISTS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/FluidSynthConfig.cmake")
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/FluidSynthConfig.cmake"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/fluidsynth")
endif()
Comment thread src/UIStatus.cpp
menu->setPosition(300, 0);
setVisible(false);
menu->runAtPosition(300, 0);
co_await ui.runAt(menu, 300, 0);

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants