code wiki / _hdl_build / nx_companion_identity.nx
nx_companion_identity.nx source
↩ module page · 66 lines · 4356 B
1// nx_companion_identity.nx -- the COMPANION IDENTITY / PHENOTYPE-GENOME object: turns "who a companion is"
2// (data-driven per-character files: elara_appearance/loras/shots.txt) + presentation into the identity portion of
3// a gen prompt. First-class + reusable = the seat for many companions (customize + proc-gen) and the digital-twin /
4// genome direction. Extracted from nx_gen_orchestrator (monolith -> objects); behaviour-preserving. Object model:
5// companion_arch.md. ⚠identity terms are Z-IMAGE COUNTERBALANCED (see the counterbalance registry) -- do not naive-edit.
6// Self-contained (private ci_* helpers) so there is zero symbol collision with the orchestrator. license_tier: ORIGINAL
7import "nx_syscalls.nx"
8
9func ci_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
10func ci_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=(0 as u8){dst[o]=s[i]; o=o+1; i=i+1} return o }
11
12// a companion's visual identity (data-driven elara_appearance.txt; baked default = a CLEARLY-ADULT early-20s anchor,
13// counterweighted vs Z-Image's 40s age-up drift). Identity carries FIGURE not exposed anatomy (wardrobe resolves that).
14func go_load_appearance(out: *u8, cap: i64) -> i64 {
15 let lp: *i64 = sys_mmap(16) as *i64
16 let b: *u8 = sys_read_file("elara_appearance.txt" as *u8, lp)
17 if (b as i64) != 0 { if lp[0] > 0 {
18 var n: i64 = lp[0]; if n > cap-1 { n = cap-1 }
19 var i: i64 = 0; while i < n { out[i]=b[i]; i=i+1 } out[n]=0 as u8; return n
20 } }
21 let d: *u8 = "photograph of Elara, a recognizable young woman in her early twenties, a sexually mature adult woman (clearly grown and adult, NOT middle-aged, NOT a teenager), platinum blonde hair, light blue eyes, an attractive feminine face, golden sun-kissed tanned skin with real natural skin texture, a curvy voluptuous top-heavy hourglass figure with a large full bust, narrow waist, delicate silver cross necklace" as *u8
22 let n2: i64 = ci_cat(out, 0, d); out[n2]=0 as u8; return n2
23}
24// realism loras (data-driven elara_loras.txt); default = realism stack, NOT nudity-forcing; NSFW loras stay scene-gated.
25func go_load_loras(out: *u8, cap: i64) -> i64 {
26 let lp: *i64 = sys_mmap(16) as *i64
27 let b: *u8 = sys_read_file("elara_loras.txt" as *u8, lp)
28 if (b as i64) != 0 { if lp[0] > 0 {
29 var n: i64 = lp[0]; if n > cap-1 { n = cap-1 }
30 var i: i64 = 0; while i < n { if (b[i]&0xff) >= 32 { out[i]=b[i] } else { out[i]=32 as u8 } i=i+1 } out[n]=0 as u8; return n
31 } }
32 let d: *u8 = "<lora:RealisticSnapshot-Zimage-Turbov5:0.7> <lora:amateur_photography_zimage_v1:0.45>" as *u8
33 let n2: i64 = ci_cat(out, 0, d); out[n2]=0 as u8; return n2
34}
35// photographic-STYLE variety (data-driven elara_shots.txt), rotated by seed; STYLE tokens only (never a setting) so
36// they never fight the scene. One descriptor per line; baked default below.
37func go_pick_shot(out: *u8, cap: i64, idx: i64) -> i64 {
38 let lp: *i64 = sys_mmap(16) as *i64
39 var b: *u8 = sys_read_file("elara_shots.txt" as *u8, lp)
40 var n: i64 = 0
41 if (b as i64) != 0 { n = lp[0] }
42 if n <= 0 {
43 b = "candid iphone selfie, natural skin texture, subtle skin pores and freckles\n35mm film photograph, soft natural grain, true-to-life colors\ngolden hour warm sunlight, shallow depth of field, gentle bokeh\nsoft overcast daylight, crisp sharp focus, fine realistic skin detail\ncozy warm indoor lamp light, creamy background bokeh\nbright clean natural daylight, high detail, lifelike complexion\nmoody cinematic low light, soft rim light, filmic tones" as *u8
44 n = ci_slen(b)
45 }
46 var lines: i64 = 1; var i: i64 = 0
47 while i < n { if (b[i]&0xff)==10 { lines=lines+1 } i=i+1 }
48 var target: i64 = idx % lines
49 if target < 0 { target = 0 - target }
50 var cur: i64 = 0; var ls: i64 = 0; i = 0
51 var start: i64 = 0; var end: i64 = 0
52 var got: i64 = 0
53 while i <= n {
54 var atend: i64 = 0
55 if i==n { atend=1 } else { if (b[i]&0xff)==10 { atend=1 } }
56 if atend==1 {
57 if cur==target { start=ls; end=i; got=1; i=n }
58 cur=cur+1; ls=i+1
59 }
60 i=i+1
61 }
62 if got==0 { out[0]=0 as u8; return 0 }
63 var o: i64 = 0; var k: i64 = start
64 while k < end { if o<cap-1 { out[o]=b[k]; o=o+1 } k=k+1 }
65 out[o]=0 as u8; return o
66}