wasm96-sdk
A Rust SDK for building WebAssembly applications that run under the wasm96 libretro core.
Overview
wasm96-sdk provides safe, ergonomic bindings to the wasm96 ABI, allowing you to write games and applications in Rust that compile to WebAssembly and run in libretro frontends like RetroArch.
Key features:
- Immediate Mode Graphics: Issue drawing commands (rects, circles, text, etc.) without managing framebuffers.
- Audio Playback: Play WAV, QOA, and XM files with host-mixed channels.
- Input Handling: Query joypad, keyboard, and mouse state.
- Resource Management: Register and draw images (PNG, GIF, SVG), fonts, and other assets by key.
- Storage: Save/load persistent data.
- System Utilities: Logging and timing.
Usage
Add this to your Cargo.toml:
[]
= "my-wasm96-app"
= "0.1.0"
= "2024"
[]
= ["cdylib"]
[]
= "0.1.0"
In your src/lib.rs:
use *;
// Required: Called once on startup
pub extern "C"
// Optional: Called once per frame to update logic
pub extern "C"
// Optional: Called once per frame to draw
pub extern "C"
Build for WebAssembly:
The output .wasm file can be loaded into the wasm96 core in RetroArch.
Features
std(default): Enables standard library features for convenience.wee_alloc: Optional global allocator forwasm32-unknown-unknowntargets.
Examples
See the wasm96 repository for complete examples:
rust-guest/: Basic hello-worldrust-guest-showcase/: Comprehensive feature demo
Documentation
Generate and view docs locally:
ABI Compatibility
This SDK targets the wasm96 ABI as defined in the WIT interface. Ensure your wasm96-core version matches the SDK version for compatibility.
License
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please see the main repository for development guidelines.