code wiki / (root) / nx_chaos.nx

nx_chaos.nx

buildroot/runtime/nx_chaos.nx

4347 B87 linesdepth 0pulls 0 transitivereach 1 importersview sourcekind librarytopic chaos
docsdependenciesstructsconstsfunctions

about

nx_chaos.nx -- Simulates chaotic behavior using integer arithmetic to demonstrate deterministic chaos and sensitive dependence on initial conditions.

dependencies 0 imports · 1 importers

nx_chaos.nx nx_chaos_gate.nx

imports: none

imported by: nx_chaos_gate.nx

structs

none

consts

2const O_MAGIC_500000: i64 = 500000
3const O_MAGIC_500001: i64 = 500001
4const O_MAGIC_3900: i64 = 3900
5const O_MAGIC_4096: i64 = 4096
14const W: i64 = 256
15const H: i64 = 256
16const O_FB: i64 = 0
17const O_XA: i64 = 524288
18const O_XB: i64 = 524296
19const O_R: i64 = 524304 // r * 1000
20const O_STEP: i64 = 524312
21const O_HA: i64 = 524320 // trajectory A history
22const O_HB: i64 = 524320 + 240*8 // trajectory B history
23const HISTN: i64 = 240
24const SC: i64 = 1000000 // x in [0, SC] == [0,1]
25const STEPS_PER_TICK: i64 = 1

functions

27func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) }
called by 2: render_implmain
29func logistic(x: i64, R: i64) -> i64 { let tmp: i64 = x*(SC-x)/SC; return tmp*R/1000 }
31func putpx(base: i64, px: i64, py: i64, c: i64) -> i64
called by 1: disc
35func disc(base: i64, px: i64, py: i64, r: i64, c: i64) -> i64
called by 1: render_impl calls 1: putpx
42func clear_fb(base: i64, c: i64) -> i64 { let fb: *i64=(base+O_FB) as *i64; var i: i64=0; while i<W*H { fb[i]=c; i=i+1 } return 0 }
called by 1: render_impl
44func init_impl(base: i64) -> i64
called by 3: tick_implinitmain
52func step_one_impl(base: i64) -> i64
called by 1: tick_impl calls 1: logistic
57func tick_impl(base: i64, cmd: i64) -> i64
called by 2: tickmain calls 2: init_implstep_one_impl
67func render_impl(base: i64) -> i64
called by 2: rendermain calls 3: clear_fbrgbdisc
81func ww() -> i64 { return W }
called by 1: main
82func hh() -> i64 { return H }
called by 1: main
83func fb_off() -> i64 { return O_FB }
called by 1: main
84func init() -> i64 { return init_impl(0) }
calls 1: init_impl
85func tick(cmd: i64) -> i64 { return tick_impl(0, cmd) }
calls 1: tick_impl
86func render() -> i64 { return render_impl(0) }
calls 1: render_impl
87func mem_bytes() -> i64 { return O_HB + HISTN*8 + O_MAGIC_4096 }