nx_world_seed.nx
buildroot/runtime/nx_world_seed.nx
about
nx_world_seed.nx -- deterministic worldgen for voxel tissue.
xorshift64 PRNG + procedural worldgen. Same seed = same world,
byte-for-byte. Foundation for Minecraft-equivalent procedural
terrain on T1/MCU — no float, no allocation, MCU-compatible.
V1 generates a simple terrain:
z=0..2 : stone (palette idx 1)
z=3..h : dirt (idx 2) where h is per-column Q14 noise
z=h+1..z_max : air (idx 0)
The "Q14 noise" is a cheap pseudo-Perlin: hash (x, y, seed) into
a height in [3, z_max). Not smooth, but deterministic + repeatable.
Composes:
nx_tissue -- the world being filled
nx_palette -- voxel indices (0=air, 1=stone, 2=dirt, 3=grass)
nx_q14_math -- sin lookup for cheap noise
dependencies 4 imports · 3 importers
imports: nx_syscalls.nxnx_tier.nxnx_tissue.nxnx_palette.nx
imported by: nx_game_engine_compose_test.nxnx_voxel_native.nxnx_world_seed_test.nx
structs
| 38 | struct NxWorldSeedState |
consts
| 24 | const NX_MAGIC_73856093: i64 = 73856093 |
| 25 | const NX_MAGIC_19349663: i64 = 19349663 |
| 27 | const NX_WS_PAL_AIR: nx_int = 0 |
| 28 | const NX_WS_PAL_STONE: nx_int = 1 |
| 29 | const NX_WS_PAL_DIRT: nx_int = 2 |
| 30 | const NX_WS_PAL_GRASS: nx_int = 3 |
| 31 | const NX_WS_PAL_WATER: nx_int = 4 |
| 33 | const NX_WS_OK: nx_int = 0 |
| 34 | const NX_WS_ERR_BAD_TISSUE: nx_int = 1 |
functions
| 49 | func nx_xorshift64(state: nx_size) -> nx_size |
| 60 | func nx_world_seed_state_new(seed: nx_size) -> *NxWorldSeedState |
| 69 | func nx_world_seed_next(s: *NxWorldSeedState) -> nx_size |
| 80 | func _height_at(seed: nx_size, x: nx_size, y: nx_size, |
| 93 | func nx_world_seed_generate(world: *NxTissue, seed: nx_size) -> nx_int |