interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / omega / allen / tests / look-mind.om

156 lines · 2407 bytes Raw Blame History
1note tests/look-mind.om: Allen's presence alone on a black frame, as mindref.c / oracle.c layer 8.
2note stdin: W H T REPS N then N events "ms op arg" (op 0 mode(arg) 1 word 2 key 3 voice(arg)),
3note applied before the first 16 ms step s >= ms. The mind is stepped every 16 ms from 0 to T,
4note then at T, drawn REPS times over the full frame, and written as a P6 PPM to fd 1.
5note fd 2 gets "box x y w h dirty x y w h nspark n" like mindref.c.
6global Tin uchar 65536
7global Tinn ulong 2
8global Tev long 192
9global Terr uchar 256
10global Terrn ulong 1
11fn tnum to long
12n = get Tinn 0
13end0 = get Tinn 1
14while lt n end0 bound 65536
15if gt get Tin n 32
16break
17end
18n = add n 1
19end
20v = long 0
21while lt n end0 bound 65536
22c = get Tin n
23if le c 32
24break
25end
26v = add mul v 10 sub long c 48
27n = add n 1
28end
29put Tinn 0 n
30ret v
31end
32fn tec c uchar to void
33put Terr get Terrn 0 c
34put Terrn 0 add get Terrn 0 1
35end
36fn teu v ulong to void
37if ge v 10
38teu div v 10
39end
40tec uchar add 48 rem v 10
41end
42fn tel v long to void
43if lt v 0
44tec 45
45teu bitcast ulong neg v
46ret
47end
48teu ulong v
49end
50fn tesp to void
51tec 32
52end
53fn terr to void
54w = write 2 Terr 0 get Terrn 0
55end
56fn tprow n ulong w ulong to void
57for x ulong w
58p = get Nfrm n
59tc uchar and shr p 16 255
60tc uchar and shr p 8 255
61tc uchar and p 255
62n = add n 1
63end
64end
65fn tppm w long h long to void
66tc 80
67tc 54
68tc 10
69tu ulong w
70tc 32
71tu ulong h
72tc 10
73tu 255
74tc 10
75for y ulong ulong h
76tprow mul y ulong w ulong w
77end
78tflush
79end
80fn tevent j long s long to void
81op = get Tev add mul j 3 1
82arg = get Tev add mul j 3 2
83if eq op 0
84mdmode arg s
85end
86if eq op 1
87mdword s
88end
89if eq op 2
90mdkey s
91end
92if eq op 3
93mdvoice arg
94end
95end
96fn main to int
97r = read 0 Tin 0 65536
98if le r 0
99ret 2
100end
101put Tinn 1 ulong r
102w = tnum
103h = tnum
104t = tnum
105reps = tnum
106n = tnum
107for i ulong ulong n
108put Tev mul i 3 tnum
109put Tev add mul i 3 1 tnum
110put Tev add mul i 3 2 tnum
111end
112pkinit
113put Lg 0 w
114put Lg 1 h
115put Lg 2 pkmin div mul w 256 1920 div mul h 256 1080
116put Lg 3 div w 2
117put Lg 4 div mul h 40 100
118pkclip 0 0 w h
119mdinit 12300
120j = long 0
121s = long 0
122note (T / 16) + 1 steps
123while le s t bound 999999
124while lt j n bound 64
125if gt get Tev mul j 3 s
126break
127end
128tevent j s
129j = add j 1
130end
131mdat s
132s = add s 16
133end
134mdat t
135for k ulong ulong reps
136mddraw 0 0 w h
137end
138mddirty
139tec 98
140tesp
141for i ulong 4
142tel get Mdnow i
143tesp
144end
145tec 100
146tesp
147for i ulong 4
148tel get Mdbox i
149tesp
150end
151tel get Mdv 15
152tec 10
153terr
154tppm w h
155ret 0
156end