Statically links the real PinMAME emulation core (libpinmame) instead of leaving VPinMAME.Controller creation to fail, which was crashing table scripts on ROM-based tables before they could spawn a ball. PinMAME's own run_game()->cpu_run() loop is split into a one-shot init, a per-frame step, and a one-shot teardown (patches/pinmame/0004) so it runs cooperatively on the same frame callback as vpinball's own loop instead of on a real std::thread, which hard-aborts under Emscripten's single-threaded runtime - three smaller wasm32 portability fixes to libpinmame itself round out the patch set (0001-0003). Adds pinball.loadRom() to supply a ROM zip, written to the table-relative pinmame/roms/ path vpinball's own plugin already checks. Confirmed against a real community ROM-based table: Controller creation and game identification succeed, and a missing ROM now fails cleanly instead of crashing the page - actual ROM-driven gameplay is still unconfirmed since no ROM was available (or sought out) to test with. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SoSarxLgY33Kax5UNXcafZ
40 lines
942 B
Diff
40 lines
942 B
Diff
diff --git a/src/cpuexec.c b/src/cpuexec.c
|
|
index ca7401f..07db6a1 100644
|
|
--- a/src/cpuexec.c
|
|
+++ b/src/cpuexec.c
|
|
@@ -943,6 +943,34 @@ void time_fence_exit()
|
|
}
|
|
}
|
|
|
|
+#elif defined(__EMSCRIPTEN__)
|
|
+
|
|
+// No cross-thread wait primitive is used here: this build is single-threaded
|
|
+// (see vpinball-wasm's README on why pthreads/SharedArrayBuffer are out of
|
|
+// scope), and time_fence is purely an *optional* external-clock-sync feature
|
|
+// (mirrored by Controller.TimeFence in controller.vbs) - reporting it as
|
|
+// unsupported just means the emulator paces itself on its own internal
|
|
+// timing instead of syncing to the host's clock, which is what every other
|
|
+// platform this library runs on outside of this fence do anyway.
|
|
+int time_fence_is_supported()
|
|
+{
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+void time_fence_post()
|
|
+{
|
|
+}
|
|
+
|
|
+int time_fence_wait(double secs)
|
|
+{
|
|
+ (void)secs;
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+void time_fence_exit()
|
|
+{
|
|
+}
|
|
+
|
|
#else
|
|
|
|
#include <semaphore.h>
|