code wiki / (root) / nx_chunk_paginate.nx

nx_chunk_paginate.nx

buildroot/runtime/nx_chunk_paginate.nx

6696 B213 linesdepth 4pulls 5 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_chunk_paginate.nx -- flash-streamed world chunks. THE T1/MCU UNLOCK PRIMITIVE for worlds bigger than RAM. ESP32 has 520 KiB SRAM but ~4 MB flash. A walkable Minecraft-equivalent world at 32³ chunks (12 KiB each at 3bpp) means ~32 chunks comfortably fit in flash; substrate streams them into RAM as player moves. LRU cache: keep N chunks resident in RAM; on miss, evict LRU and load the requested chunk from flash. Caller supplies the "flash storage" as a content-addressed byte buffer (the integration layer maps the actual flash partition). Composes: nx_tissue -- each chunk is a 32³ NxTissue nx_palette -- chunks are palette-packed (3bpp typical for T1) nx_aerobic -- evicted chunks go to aerobic pile for journaling (we never silently lose data) nx_metabolism -- chunk-page-miss is a substrate-level event; metabolism tracks misses per call site

dependencies 3 imports · 2 importers

nx_syscalls.nx nx_tier.nx nx_tissue.nx nx_chunk_paginate.nx nx_chunk_paginate_test.nx nx_minecraft_mcu_compose_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_tissue.nx

imported by: nx_chunk_paginate_test.nxnx_minecraft_mcu_compose_test.nx

structs

38struct NxChunkSlot
45struct NxChunkPaginator

consts

24const NX_MAGIC_1024: i64 = 1024
26const NX_CP_OK: nx_int = 0
27const NX_CP_ERR_NOT_FOUND: nx_int = 1
28const NX_CP_ERR_BAD_COORD: nx_int = 2
29const NX_CP_CACHE_HIT: nx_int = 3
30const NX_CP_CACHE_MISS: nx_int = 4
54const NX_CP_SLOT_BYTES: nx_size = 32

functions

56func nx_chunk_paginator_new(capacity: nx_size) -> *NxChunkPaginator
called by 2: mainmain calls 1: sys_mmap
78func _cp_at(p: *NxChunkPaginator, idx: nx_size) -> *NxChunkSlot
82func _cp_find_loaded(p: *NxChunkPaginator, chunk_id: nx_int) -> nx_int
99func _cp_find_lru(p: *NxChunkPaginator) -> nx_int
called by 1: nx_chunk_request calls 1: _cp_at
123func _cp_find_free(p: *NxChunkPaginator) -> nx_int
called by 1: nx_chunk_request calls 1: _cp_at
140func nx_chunk_request(p: *NxChunkPaginator,
181func nx_chunk_loaded_count(p: *NxChunkPaginator) -> nx_size
185func nx_chunk_hit_count(p: *NxChunkPaginator) -> nx_int
called by 2: mainmain
189func nx_chunk_miss_count(p: *NxChunkPaginator) -> nx_int
called by 2: mainmain
193func nx_chunk_evict_count(p: *NxChunkPaginator) -> nx_int
called by 1: main
202func nx_chunk_hit_rate_q10(p: *NxChunkPaginator) -> nx_int
called by 1: main
210func nx_chunk_is_loaded(p: *NxChunkPaginator, chunk_id: nx_int) -> nx_int
called by 1: main calls 1: _cp_find_loaded