code wiki / _hdl_build / nx_voxchunk.nx
nx_voxchunk.nx
buildroot/runtime/_hdl_build/nx_voxchunk.nx
about
nx_voxchunk.nx -- the SOVEREIGN CHUNKED VOXEL WORLD PART. nx_gamebench gap-queue rank 1
(voxel-world-chunked, PARTIAL): the craft organ's world is a FIXED 64x32x64 volume -- honest
evidence for rendering and editing, but NOT for the Minecraft-class bar the capability names:
an unbounded world streamed through a BOUNDED resident set of chunks. This part is that bar,
built on the certified parts (persistence = nx_gamesave, so a dirty chunk survives eviction
with atomicity/corruption-refusal/additive-only inherited, not re-derived).
THE INVARIANTS THIS PART EXISTS TO HOLD (each a gate tooth in nx_voxchunk_gate):
1. DETERMINISTIC GENERATION. A virgin chunk is a pure function of (world_seed, cx, cz):
load -> evict -> reload is bit-identical. No stored world is needed for unvisited land.
2. BOUNDED RESIDENCY BY CONSTRUCTION. At most `cap` chunks are ever resident; walking
10,000 chunks costs the same memory as walking 10. The eviction is the design, not an
afterthought.
3. EDITS SURVIVE EVICTION. A modified (dirty) chunk is flushed through gs_save before its
slot is reused, and reload prefers the saved file over regeneration -- the Minecraft law:
virgin land from the seed, touched land from disk. Losing edits on eviction is the classic
chunk-corruption bug class; here it is structurally impossible while the flush path holds.
4. SEAM-CONSISTENT WORLD ACCESS. Callers address blocks in WORLD coordinates; chunk math is
internal. A query at a chunk border resolves identically whether the neighbour is resident,
evicted, or never visited.
5. WHOLE-SESSION DURABILITY. The session arena is flat i64 words -> gs_save; dirty state is
flushed first, so a saved world reopens exactly where it left off.
Chunk geometry: 16 x 32 x 16 blocks (8192 bytes), packed 8 blocks/word in the arena tail.
license_tier: ORIGINAL expect_exit: 0
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_gamesave.nx
imported by: nx_voxchunk_gate.nx
structs
| none |
consts
| 27 | const VXC_MAGIC_374761393: i64 = 374761393 |
| 28 | const VXC_MAGIC_668265263: i64 = 668265263 |
| 29 | const VXC_MAGIC_2246822519: i64 = 2246822519 |
| 30 | const VXC_MAGIC_1274126177: i64 = 1274126177 |
| 31 | const VXC_MAGIC_60630: i64 = 60630 |
| 32 | const VXC_MAGIC_1785430000: i64 = 1785430000 |
| 33 | const VXC_MAGIC_52711: i64 = 52711 |
| 34 | const VXC_MAGIC_8191: i64 = 8191 |
| 36 | const VXC_CW: i64 = 16 |
| 37 | const VXC_CH: i64 = 32 |
| 38 | const VXC_CD: i64 = 16 |
| 39 | const VXC_CBYTES: i64 = 8192 |
| 40 | const VXC_CWORDS: i64 = 1024 |
| 41 | const VXC_HDR: i64 = 8 |
| 42 | const VXC_SLOTW: i64 = 4 |
| 43 | const VXC_SEA: i64 = 12 |
| 46 | const VXC_S_EMPTY: i64 = 0 |
| 47 | const VXC_S_CLEAN: i64 = 1 |
| 48 | const VXC_S_DIRTY: i64 = 2 |
| 51 | const VXC_E_RANGE: i64 = 0-1 |
| 52 | const VXC_E_FLUSH: i64 = 0-2 |
functions
| 55 | func vxc_cap(a: *i64) -> i64 { return a[0] } |
| 56 | func vxc_seed(a: *i64) -> i64 { return a[1] } called by 1: vxc_ensure |
| 57 | func vxc_resident(a: *i64) -> i64 { return a[3] } called by 1: main |
| 58 | func vxc_loads(a: *i64) -> i64 { return a[4] } |
| 59 | func vxc_evictions(a: *i64) -> i64 { return a[5] } called by 1: main |
| 60 | func vxc_flushes(a: *i64) -> i64 { return a[6] } called by 1: main |
| 61 | func vxc_diskloads(a: *i64) -> i64 { return a[7] } called by 1: main |
| 63 | func vxc_words(cap: i64) -> i64 { return VXC_HDR + cap*VXC_SLOTW + cap*VXC_CWORDS } |
| 64 | func vxc_bytes(cap: i64) -> i64 { return vxc_words(cap) * 8 } calls 1: vxc_words |
| 65 | func vxc_o_slot(a: *i64, s: i64) -> i64 { return VXC_HDR + s*VXC_SLOTW } |
| 67 | func vxc_blocks(a: *i64, s: i64) -> *u8 |
| 71 | func vxc_init(a: *i64, cap: i64, seed: i64) -> i64 |
| 94 | func vxc_hash(x: i64, z: i64, seed: i64) -> i64 |
| 102 | func vxc_height(wx: i64, wz: i64, seed: i64) -> i64 |
| 116 | func vxc_gen(blocks: *u8, cx: i64, cz: i64, seed: i64) -> i64 |
| 143 | func vxc_itoa_at(p: *u8, at: i64, v: i64) -> i64 |
| 155 | func vxc_path(p: *u8, cx: i64, cz: i64) -> i64 |
| 166 | func vxc_flush_slot(a: *i64, s: i64) -> i64 |
| 176 | func vxc_disk_load(a: *i64, s: i64, cx: i64, cz: i64) -> i64 |
| 186 | func vxc_find(a: *i64, cx: i64, cz: i64) -> i64 |
| 198 | func vxc_victim(a: *i64) -> i64 |
| 219 | func vxc_ensure(a: *i64, cx: i64, cz: i64) -> i64 |
| 242 | func vxc_cdiv(v: i64, d: i64) -> i64 |
| 247 | func vxc_get(a: *i64, wx: i64, wy: i64, wz: i64) -> i64 |
| 259 | func vxc_set(a: *i64, wx: i64, wy: i64, wz: i64, b: i64) -> i64 |
| 277 | func vxc_flush_all(a: *i64) -> i64 |
| 294 | func vxc_checksum(a: *i64) -> i64 |