Skip to content

Conversation

@wayjake
Copy link

@wayjake wayjake commented Oct 30, 2025

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)

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)
@wayjake wayjake marked this pull request as draft October 30, 2025 20:15
jake and others added 2 commits October 30, 2025 18:21
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)
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.

1 participant