code wiki / (root) / nx_game_save.nx

nx_game_save.nx

buildroot/runtime/nx_game_save.nx

3998 B90 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic game
docsdependenciesstructsconstsfunctions

about

nx_game_save.nx -- SOVEREIGN SAVE / LOAD for game state. Built because the gamebench ruler ranks save-load-persistence as the #1 blocker across the ingested corpus (11 of 12 real titles need it), i.e. this is demand-ranked by measurement, not chosen by taste. STATE IS AN i64 VECTOR, so this is game-agnostic: any game that can describe itself as integers can use it. THE CONTRACT -- a save file is either loaded EXACTLY or REFUSED WITH A REASON. It is never partially applied and never silently accepted when damaged, because a corrupted save that half-loads is worse than one that fails: it strands the player in an impossible world state and looks like a game bug forever. Layout (all i64, little-endian): [magic][version][count][payload...][checksum-of-everything-before]. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_game_save.nx nx_gx9_saveload_gate.nx

imports: nx_syscalls.nx

imported by: nx_gx9_saveload_gate.nx

structs

none

consts

11const GS_MAGIC_1469598103: i64 = 1469598103
12const GS_MAGIC_1000000007: i64 = 1000000007
14const GS_MAGIC: i64 = 5182089520394403 // distinctive, so a wrong file type is rejected on sight
15const GS_VERSION: i64 = 1
16const GS_HDR: i64 = 3 // magic, version, count
19const GS_ERR_UNREADABLE: i64 = 0 - 1
20const GS_ERR_TRUNCATED: i64 = 0 - 2
21const GS_ERR_MAGIC: i64 = 0 - 3
22const GS_ERR_VERSION: i64 = 0 - 4
23const GS_ERR_CHECKSUM: i64 = 0 - 5
24const GS_ERR_TOOBIG: i64 = 0 - 6

functions

26func gs_put64(b: *u8, at: i64, v: i64) -> i64
called by 2: gs_savemain
32func gs_get64(b: *u8, at: i64) -> i64
called by 1: gs_load
40func gs_ck(words: *i64, n: i64) -> i64
called by 2: gs_savegs_load
48func gs_save(path: *u8, words: *i64, n: i64) -> i64
70func gs_load(path: *u8, out: *i64, maxn: i64) -> i64