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

Nethercore ZX API Reference

Nethercore 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)
Resolution960×540 (fixed, upscaled to display)
Color depthRGBA8
Tick rate24, 30, 60 (default), 120 fps
ROM (Cartridge)16MB (WASM code + data pack assets)
RAM4MB (WASM linear memory for game state)
VRAM4MB (GPU textures and mesh buffers)
Compute budgetWASM GAS metering
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

Nethercore ZX uses a 16MB ROM + 4MB RAM memory model:

  • ROM (16MB): 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.

Coordinate System

Nethercore ZX uses standard graphics conventions with wgpu as the rendering backend.

Screen Space (2D)

All 2D drawing functions (draw_sprite, draw_rect, draw_text, etc.) use screen coordinates:

PropertyValue
Resolution960×540 pixels (fixed, 16:9 aspect)
OriginTop-left corner (0, 0)
X-axisIncreases rightward (0 → 960)
Y-axisIncreases downward (0 → 540)
Sprite anchorTop-left corner of sprite
(0,0) ────────────────────► X (960)
  │
  │     Screen Space
  │
  ▼
  Y (540)

World Space (3D)

For 3D rendering with camera_set() and draw_mesh():

PropertyValue
Coordinate systemRight-handed, Y-up
X-axisRight
Y-axisUp
Z-axisOut of screen (toward viewer)
HandednessRight-handed (cross X into Y to get Z)
        Y (up)
        │
        │
        │
        └──────► X (right)
       ╱
      ╱
     Z (toward viewer)

NDC (Normalized Device Coordinates)

The rendering pipeline uses wgpu’s standard NDC conventions:

PropertyValue
X-axis-1.0 (left) to +1.0 (right)
Y-axis-1.0 (bottom) to +1.0 (top)
Z-axis0.0 (near) to 1.0 (far)

Screen-space drawing functions automatically handle the conversion from screen pixels to NDC. For 3D, the view and projection matrices handle the transformation.

Texture Coordinates (UV)

PropertyValue
OriginTop-left (0, 0)
U-axis0 (left) to 1 (right)
V-axis0 (top) to 1 (bottom)

Matrix Conventions

All matrix functions use column-major order (standard for wgpu/WGSL):

| m0  m4  m8  m12 |    Column 0: m0, m1, m2, m3
| m1  m5  m9  m13 |    Column 1: m4, m5, m6, m7
| m2  m6  m10 m14 |    Column 2: m8, m9, m10, m11
| m3  m7  m11 m15 |    Column 3: m12, m13, m14, m15

Transformations use column vectors: v' = M × v

Default Projection

When using camera_set() and camera_fov():

PropertyValue
TypePerspective
Default FOV60° (vertical)
Aspect ratio16:9 (fixed)
Near plane0.1 units
Far plane1000 units
Functionperspective_rh (right-handed)

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
Environment (EPU)Procedural environments
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: your Nethercore data directory under screenshots/
  • GIFs: your Nethercore data directory under gifs/

Filenames include game name and timestamp (e.g., platformer_screenshot_2025-01-15_14-30-45.png).

Configuration (config.toml in your platform-specific config directory):

[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 mdbook-tabs

# Build static HTML (outputs to docs/book/book/)
cd docs/book
mdbook build

# Or serve locally with live reload
mdbook serve