Add WebAssembly port with libretro API validation#806
Draft
wayjake wants to merge 3 commits intolibretro:masterfrom
Draft
Add WebAssembly port with libretro API validation#806wayjake wants to merge 3 commits intolibretro:masterfrom
wayjake wants to merge 3 commits intolibretro:masterfrom
Conversation
This commit adds support for compiling parallel-n64 to WebAssembly and validates the libretro API in a browser environment. Changes: - Makefile: Export malloc, free, UTF8ToString, addFunction, and HEAP views - Makefile: Add ALLOW_TABLE_GROWTH=1 for dynamic function table support - test_libretro.html: Browser test harness for libretro API validation - Documentation: Complete milestone 07 tracking All 6 core libretro API tests pass: - retro_api_version() - retro_get_system_info() - retro_set_environment() - retro_init() / retro_deinit() Build output: 1.6 MB total (187 KB JS + 1.4 MB WASM)
Complete interactive N64 emulation in browser with full input and audio support. Features: - Keyboard input with full N64 button mapping (D-Pad, A/B, Start, L/R/Z, C-buttons) - Gamepad API support with automatic controller detection - Web Audio API integration (44.1kHz stereo output with batch processing) - Real-time input callbacks replacing previous stubs - On-screen controls guide for keyboard and gamepad - Audio buffer management with automatic queue flushing - Analog stick support for both keyboard and gamepad Build improvements: - Optimize Emscripten build flags for better performance (-O3) - Export additional heap types (HEAP16, HEAPF32, HEAPF64) for audio - Enable SIMD128 support - Add aggressive variable elimination and function deduplication - Disable unused renderers (GLIDE64, RICE) for smaller WASM binary Testing: - Full interactive gameplay confirmed with WaveRace 64 - Consistent 60 FPS performance - Audio playback functional - Gamepad detection and mapping verified
Add audio-driven frame generation based on N64Wasm approach. Replaces requestAnimationFrame timing with Web Audio callback for superior accuracy and cross-monitor consistency. Key improvements: - Ring buffer audio system (64K samples) - ScriptProcessor callback drives frame generation - Dual timing modes (audio-sync and classic RAF) - Self-regulating speed control via buffer fill - UI toggle for timing mode selection Benefits: - Eliminates FPS drift across different refresh rate monitors - Perfect audio/video synchronization - Emulation speed locked to audio hardware clock (44100Hz) - Consistent performance on 60Hz, 75Hz, and 144Hz displays Technical details: - Audio callback fires ~43 times/second (1024 samples) - Generates 1-3 frames per callback as needed - Maintains 2000-4000 sample buffer ahead - Latency: 46-93ms (imperceptible)
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.
This commit adds support for compiling parallel-n64 to WebAssembly and validates the libretro API in a browser environment.
Changes:
All 6 core libretro API tests pass:
Build output: 1.6 MB total (187 KB JS + 1.4 MB WASM)