code wiki / _hdl_build / _pe_coach_msg.nx
_pe_coach_msg.nx source
↩ module page · 20 lines · 627 B
1// AUTHORED BY THE NISHI BUILDER (pattern: STRUCT_WALK v2 magic/tailrest) -- field-table walk, no Claude logic
2import "nx_syscalls.nx"
3func _pe_coach_msg_locate(b: *u8, n: i64, out: *i64) -> i64 {
4 var off: i64 = 0
5 off = off + 1
6 if off > n { return 0 - 1 }
7 off = off + 1
8 if off > n { return 0 - 1 }
9 off = off + 1
10 if off > n { return 0 - 1 }
11 off = off + 2
12 if off > n { return 0 - 1 }
13 if off + 2 > n { return 0 - 1 }
14 let tl: i64 = ((b[off] & 0xff) << 8) | (b[off + 1] & 0xff)
15 if off + 2 + tl > n { return 0 - 1 }
16 out[0] = off + 2
17 out[1] = tl
18 return 0
19 return 0 - 1
20}