ZX FFI Reference
The ZX console provides a broad FFI surface. Always read nethercore/include/zx.rs for accurate signatures.
FFI Categories
| Category |
Key Functions |
Find In zx.rs |
| System |
delta_time, tick_count, log |
Lines 1-100 |
| Random |
random, random_range, random_f32 |
Search "random" |
| Input |
button_held, button_pressed, left_stick_x |
Search "button" |
| Camera |
camera_set, camera_fov |
Search "camera" |
| Transforms |
push_translate, push_rotate_y, push_scale, push_identity |
Search "push_" |
| Meshes |
load_mesh, draw_mesh, cube, sphere |
Search "mesh" |
| Textures |
load_texture, texture_bind |
Search "texture" |
| Materials |
material_albedo, material_mre, material_normal |
Search "material" |
| Audio |
load_sound, play_sound, music_play |
Search "sound" |
| 2D Drawing |
draw_sprite, draw_text, draw_rect |
Search "draw_" |
| Environment |
epu_set, epu_textures, epu_asset, draw_epu |
Search "epu_" |
| Debug |
debug_register_*, debug_watch_*, debug_group_* |
Search "debug_" |
Init-Only Functions
Must call only during init():
set_clear_color(color) - 0xRRGGBBAA
- All
rom_*(), load_*(), procedural mesh functions
Render-Only Functions
Call only during render():
- All
draw_* functions
camera_set(), camera_fov()
push_translate(), push_rotate_y(), push_scale()
texture_bind(), font_bind()
begin_pass(), begin_pass_stencil_write()
set_color(), z_index()
epu_set(), epu_textures(), epu_asset(), draw_epu()
Asset Loading
// In init()
let tex = rom_texture_str("player");
let mesh = rom_mesh_str("character");
let sfx = rom_sound_str("jump");
let music = rom_tracker_str("theme");
Transform State
There is no generic push/pop transform API. Compose transforms with the
push_* calls, then use push_identity() (or transform_set() with a
column-major 4x4 matrix) when starting an independent object.
// In render()
push_translate(x, y, z);
push_rotate_y(angle_degrees);
push_scale_uniform(scale);
draw_mesh(MESH);
push_identity(); // Reset before the next independent object
Resource Lifetime
Resource creation/loading is init-only. The FFI exposes no resource unload or
free call; loaded handles live until game shutdown.
EPU Environment
The current EPU config is 16 u64 values (128 bytes). Select a source with
epu_set(config_ptr), epu_textures(px, nx, py, ny, pz, nz), or
epu_asset(id_ptr, id_len) before the geometry that should use it, then call
draw_epu() afterward to draw the environment background. There is no EPU
time-setting API; animate deterministic instruction parameters from game state.
For packed animation clips, keep rigs at 255 bones or fewer: the runtime
skeleton path accepts 256, but the packed keyframe format stores bone_count
as u8.
Coordinate System
- Y-up, right-handed, -Z forward
- When yaw=0, camera looks toward -Z
- Angles in degrees for FFI functions
1---2name: ffi-reference3description: ZX fantasy console FFI bindings reference. Documents the current functions for rendering, input, audio, camera, transforms, textures, materials, and debug. Includes init-only vs render-only call rules and the coordinate system. Use when writing or debugging ZX FFI calls in game code.4license: Apache-2.05---67# ZX FFI Reference89The ZX console provides a broad FFI surface. **Always read `nethercore/include/zx.rs` for accurate signatures.**1011## FFI Categories1213| Category | Key Functions | Find In zx.rs |14|----------|--------------|---------------|15| System | `delta_time`, `tick_count`, `log` | Lines 1-100 |16| Random | `random`, `random_range`, `random_f32` | Search "random" |17| Input | `button_held`, `button_pressed`, `left_stick_x` | Search "button" |18| Camera | `camera_set`, `camera_fov` | Search "camera" |19| Transforms | `push_translate`, `push_rotate_y`, `push_scale`, `push_identity` | Search "push_" |20| Meshes | `load_mesh`, `draw_mesh`, `cube`, `sphere` | Search "mesh" |21| Textures | `load_texture`, `texture_bind` | Search "texture" |22| Materials | `material_albedo`, `material_mre`, `material_normal` | Search "material" |23| Audio | `load_sound`, `play_sound`, `music_play` | Search "sound" |24| 2D Drawing | `draw_sprite`, `draw_text`, `draw_rect` | Search "draw_" |25| Environment | `epu_set`, `epu_textures`, `epu_asset`, `draw_epu` | Search "epu_" |26| Debug | `debug_register_*`, `debug_watch_*`, `debug_group_*` | Search "debug_" |2728## Init-Only Functions2930Must call only during `init()`:31- `set_clear_color(color)` - 0xRRGGBBAA32- All `rom_*()`, `load_*()`, procedural mesh functions3334## Render-Only Functions3536Call only during `render()`:37- All `draw_*` functions38- `camera_set()`, `camera_fov()`39- `push_translate()`, `push_rotate_y()`, `push_scale()`40- `texture_bind()`, `font_bind()`41- `begin_pass()`, `begin_pass_stencil_write()`42- `set_color()`, `z_index()`43- `epu_set()`, `epu_textures()`, `epu_asset()`, `draw_epu()`4445## Asset Loading4647```rust48// In init()49let tex = rom_texture_str("player");50let mesh = rom_mesh_str("character");51let sfx = rom_sound_str("jump");52let music = rom_tracker_str("theme");53```5455## Transform State5657There is no generic push/pop transform API. Compose transforms with the58`push_*` calls, then use `push_identity()` (or `transform_set()` with a59column-major 4x4 matrix) when starting an independent object.6061```rust62// In render()63push_translate(x, y, z);64push_rotate_y(angle_degrees);65push_scale_uniform(scale);66draw_mesh(MESH);67push_identity(); // Reset before the next independent object68```6970## Resource Lifetime7172Resource creation/loading is init-only. The FFI exposes no resource unload or73free call; loaded handles live until game shutdown.7475## EPU Environment7677The current EPU config is 16 `u64` values (128 bytes). Select a source with78`epu_set(config_ptr)`, `epu_textures(px, nx, py, ny, pz, nz)`, or79`epu_asset(id_ptr, id_len)` before the geometry that should use it, then call80`draw_epu()` afterward to draw the environment background. There is no EPU81time-setting API; animate deterministic instruction parameters from game state.8283For packed animation clips, keep rigs at 255 bones or fewer: the runtime84skeleton path accepts 256, but the packed keyframe format stores `bone_count`85as `u8`.8687## Coordinate System8889- Y-up, right-handed, -Z forward90- When yaw=0, camera looks toward -Z91- Angles in degrees for FFI functions