Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

SpecValue
AestheticPS1/N64/Saturn (5th gen)
Resolution360p, 540p (default), 720p, 1080p
Color depthRGBA8
Tick rate24, 30, 60 (default), 120 fps
ROM (Cartridge)12MB (WASM code + data pack assets)
RAM4MB (WASM linear memory for game state)
VRAM4MB (GPU textures and mesh buffers)
CPU budget4ms per tick (at 60fps)
NetcodeDeterministic rollback via GGRS
Max players4 (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

CategoryDescription
SystemTime, logging, random, session info
InputButtons, sticks, triggers
GraphicsResolution, render mode, state
CameraView and projection
TransformsMatrix stack operations
TexturesLoading and binding textures
MeshesLoading and drawing meshes
MaterialsPBR and Blinn-Phong properties
LightingDirectional and point lights
SkinningSkeletal animation
AnimationKeyframe playback
ProceduralGenerated primitives
2D DrawingSprites, text, rectangles
BillboardsCamera-facing quads
SkyProcedural sky rendering
AudioSound effects and music
Save DataPersistent storage
ROM LoadingData pack access
DebugRuntime value inspection

Screen Capture

The host application includes screenshot and GIF recording capabilities:

KeyDefaultAction
ScreenshotF9Save PNG to screenshots folder
GIF ToggleF10Start/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

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