Emberware ZX API Reference
Emberware ZX is a 5th-generation fantasy console targeting PS1/N64/Saturn aesthetics with modern conveniences like deterministic rollback netcode.
Console Specs
| Spec | Value |
|---|---|
| Aesthetic | PS1/N64/Saturn (5th gen) |
| Resolution | 360p, 540p (default), 720p, 1080p |
| Color depth | RGBA8 |
| Tick rate | 24, 30, 60 (default), 120 fps |
| ROM (Cartridge) | 12MB (WASM code + data pack assets) |
| RAM | 4MB (WASM linear memory for game state) |
| VRAM | 4MB (GPU textures and mesh buffers) |
| CPU budget | 4ms per tick (at 60fps) |
| Netcode | Deterministic rollback via GGRS |
| Max players | 4 (any mix of local + remote) |
Game Lifecycle
Games export three functions:
#![allow(unused)]
fn main() {
#[no_mangle]
pub extern "C" fn init() {
// Called once at startup
// Load resources, configure console settings
}
#[no_mangle]
pub extern "C" fn update() {
// Called every tick (deterministic for rollback)
// Update game state, handle input
}
#[no_mangle]
pub extern "C" fn render() {
// Called every frame (skipped during rollback replay)
// Draw to screen
}
}
Memory Model
Emberware ZX uses a 12MB ROM + 4MB RAM memory model:
- ROM (12MB): WASM bytecode + data pack (textures, meshes, sounds)
- RAM (4MB): WASM linear memory for game state
- VRAM (4MB): GPU textures and mesh buffers
Assets loaded via rom_* functions go directly to VRAM/audio memory, keeping RAM free for game state.
API Categories
| Category | Description |
|---|---|
| System | Time, logging, random, session info |
| Input | Buttons, sticks, triggers |
| Graphics | Resolution, render mode, state |
| Camera | View and projection |
| Transforms | Matrix stack operations |
| Textures | Loading and binding textures |
| Meshes | Loading and drawing meshes |
| Materials | PBR and Blinn-Phong properties |
| Lighting | Directional and point lights |
| Skinning | Skeletal animation |
| Animation | Keyframe playback |
| Procedural | Generated primitives |
| 2D Drawing | Sprites, text, rectangles |
| Billboards | Camera-facing quads |
| Sky | Procedural sky rendering |
| Audio | Sound effects and music |
| Save Data | Persistent storage |
| ROM Loading | Data pack access |
| Debug | Runtime value inspection |
Screen Capture
The host application includes screenshot and GIF recording capabilities:
| Key | Default | Action |
|---|---|---|
| Screenshot | F9 | Save PNG to screenshots folder |
| GIF Toggle | F10 | Start/stop GIF recording |
Files are saved to:
- Screenshots:
~/.emberware/Emberware/screenshots/ - GIFs:
~/.emberware/Emberware/gifs/
Filenames include game name and timestamp (e.g., platformer_screenshot_2025-01-15_14-30-45.png).
Configuration (~/.emberware/config.toml):
[capture]
screenshot = "F9"
gif_toggle = "F10"
gif_fps = 30 # GIF framerate
gif_max_seconds = 60 # Max duration
Quick Links
- Cheat Sheet - All functions on one page
- Getting Started - Your first game
- Render Modes - Mode 0-3 explained
- Rollback Safety - Writing deterministic code
Building These Docs
These docs are built with mdBook.
# Install mdBook
cargo install mdbook
# Build static HTML (outputs to docs/book/book/)
cd docs/book
mdbook build
# Or serve locally with live reload
mdbook serve