nx_game_save.nx
buildroot/runtime/nx_game_save.nx
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
imports: nx_syscalls.nx
imported by: nx_gx9_saveload_gate.nx
structs
| none |
consts
| 11 | const GS_MAGIC_1469598103: i64 = 1469598103 |
| 12 | const GS_MAGIC_1000000007: i64 = 1000000007 |
| 14 | const GS_MAGIC: i64 = 5182089520394403 // distinctive, so a wrong file type is rejected on sight |
| 15 | const GS_VERSION: i64 = 1 |
| 16 | const GS_HDR: i64 = 3 // magic, version, count |
| 19 | const GS_ERR_UNREADABLE: i64 = 0 - 1 |
| 20 | const GS_ERR_TRUNCATED: i64 = 0 - 2 |
| 21 | const GS_ERR_MAGIC: i64 = 0 - 3 |
| 22 | const GS_ERR_VERSION: i64 = 0 - 4 |
| 23 | const GS_ERR_CHECKSUM: i64 = 0 - 5 |
| 24 | const GS_ERR_TOOBIG: i64 = 0 - 6 |
functions
| 26 | func gs_put64(b: *u8, at: i64, v: i64) -> i64 |
| 32 | func gs_get64(b: *u8, at: i64) -> i64 called by 1: gs_load |
| 40 | func gs_ck(words: *i64, n: i64) -> i64 |
| 48 | func gs_save(path: *u8, words: *i64, n: i64) -> i64 |
| 70 | func gs_load(path: *u8, out: *i64, maxn: i64) -> i64 |