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 / scene.om

340 lines · 4986 bytes Raw Blame History
1note Scene state: tone,water,has-say,nthings,used,lines,rejected,over.
2global Sc ulong 8
3global Things ulong 64
4global Stext uchar 2304
5global Sw ulong 4
6global Fields uchar 1536
7global Flens ulong 6
8global Soffs ulong 6
9text Vocab "mood|say|note|list|number|quote|person|timer|picture|video|left|right|above|warm|quiet|bloom|rise|fade|to|from|night|dawn|deep|clear|slow|still|lively|"
10fn scword beg ulong size ulong to ulong
11s = ulong 0
12word = ulong 1
13for i ulong len Vocab
14if eq get Vocab i 124
15if eq sub i s size
16same = true
17for j ulong size
18if ne get In add beg j get Vocab add s j
19same = false
20end
21end
22if same
23ret word
24end
25end
26word = add word 1
27s = add i 1
28end
29end
30ret 0
31end
32fn fieldcap kind ulong field ulong to ulong
33if eq kind 2
34if eq field 0
35ret 48
36end
37ret 64
38end
39if eq kind 1
40if eq field 0
41ret 48
42end
43ret 240
44end
45if eq kind 3
46if eq field 0
47ret 16
48end
49ret 64
50end
51if eq kind 4
52if eq field 0
53ret 220
54end
55ret 48
56end
57if eq kind 5
58if eq field 0
59ret 32
60end
61ret 200
62end
63if eq kind 6
64if eq field 0
65ret 24
66end
67ret 64
68end
69if eq field 0
70ret 120
71end
72ret 64
73end
74fn scfield slot ulong beg ulong stop ulong kind ulong to bool
75s = beg
76e = stop
77while lt s e
78if eq get In s 32
79s = add s 1
80else
81ret fieldend slot s e kind
82end
83end
84put Flens slot 0
85ret true
86end
87fn fieldend slot ulong s ulong stop ulong kind ulong to bool
88e = stop
89while gt e s
90if eq get In sub e 1 32
91e = sub e 1
92else
93n = sub e s
94if gt n fieldcap kind slot
95ret false
96end
97for i ulong n
98c = get In add s i
99if or lt c 32 gt c 126
100ret false
101end
102put Fields add mul slot 256 i c
103end
104put Flens slot n
105ret true
106end
107end
108put Flens slot 0
109ret true
110end
111fn scfields beg ulong stop ulong kind ulong to ulong
112slot = ulong 0
113s = beg
114for i ulong sub stop beg
115p = add beg i
116if eq get In p 124
117if ge slot 5
118ret 0
119end
120if not scfield slot s p kind
121ret 0
122end
123slot = add slot 1
124s = add p 1
125end
126end
127if not scfield slot s stop kind
128ret 0
129end
130n = add slot 1
131if and ne kind 2 gt n 2
132ret 0
133end
134if eq get Flens 0 0
135ret 0
136end
137if eq kind 5
138if or lt n 2 eq get Flens 1 0
139ret 0
140end
141end
142if eq kind 3
143hasdigit = false
144for i ulong get Flens 0
145if isdigit get Fields i
146hasdigit = true
147end
148end
149if not hasdigit
150ret 0
151end
152end
153ret n
154end
155fn scput slot ulong to ulong
156off = get Sc 4
157n = get Flens slot
158for i ulong n
159put Stext add off i get Fields add mul slot 256 i
160end
161put Stext add off n 0
162put Sc 4 add add off n 1
163ret off
164end
165fn scmod word ulong base ulong to void
166if and ge word 11 le word 13
167put Things add base 1 sub word 10
168end
169if and ge word 16 le word 18
170put Things add base 2 sub word 16
171end
172if and ge word 19 le word 20
173put Things add base 3 sub word 18
174end
175if eq word 14
176put Things add base 4 1
177end
178if eq word 15
179put Things add base 5 1
180end
181end
182fn scsay beg ulong stop ulong to bool
183if ne get Sc 2 0
184ret false
185end
186n = sub stop beg
187if or eq n 0 gt n 159
188ret false
189end
190for i ulong n
191c = get In add beg i
192if or lt c 32 gt c 126
193ret false
194end
195put Fields i c
196end
197put Flens 0 n
198put Sc 2 1
199put Sw 3 scput 0
200ret true
201end
202fn scln beg ulong stop ulong to bool
203p = beg
204while lt p stop
205if or eq get In p 32 eq get In p 58
206ret scbody beg p stop
207end
208p = add p 1
209end
210ret false
211end
212fn scbody beg ulong wordend ulong stop ulong to bool
213word = scword beg sub wordend beg
214if eq word 2
215s = add wordend 1
216if lt s stop
217if eq get In s 58
218s = add s 1
219end
220end
221while lt s stop
222if eq get In s 32
223s = add s 1
224else
225ret scsay s stop
226end
227end
228ret false
229end
230if eq word 1
231s = add wordend 1
232for p ulong sub stop s
233at = add add wordend 1 p
234if eq get In at 32
235w = scword s sub at s
236if and ge w 21 le w 24
237put Sc 0 sub w 21
238end
239if and ge w 25 le w 27
240put Sc 1 sub w 25
241end
242s = add at 1
243end
244end
245w = scword s sub stop s
246if and ge w 21 le w 24
247put Sc 0 sub w 21
248end
249if and ge w 25 le w 27
250put Sc 1 sub w 25
251end
252ret true
253end
254if or lt word 3 gt word 10
255ret false
256end
257if ge get Sc 3 4
258put Sc 7 add get Sc 7 1
259ret false
260end
261put Sw 0 sub word 2
262colon = wordend
263while lt colon stop
264if eq get In colon 58
265put Sw 1 wordend
266put Sw 2 colon
267ret scthing add colon 1 stop
268end
269colon = add colon 1
270end
271ret false
272end
273fn scthing beg ulong stop ulong to bool
274n = scfields beg stop get Sw 0
275if eq n 0
276ret false
277end
278need = n
279for i ulong n
280need = add need get Flens i
281end
282if gt add get Sc 4 need 2304
283ret false
284end
285base = mul get Sc 3 16
286put Things base get Sw 0
287put Things add base 6 n
288s = get Sw 1
289for p ulong sub get Sw 2 s
290at = add get Sw 1 p
291if eq get In at 32
292w = scword s sub at s
293scmod w base
294s = add at 1
295end
296end
297w = scword s sub get Sw 2 s
298scmod w base
299for i ulong n
300put Things add add base 7 i scput i
301end
302put Sc 3 add get Sc 3 1
303ret true
304end
305fn scene to bool
306for i ulong 8
307put Sc i 0
308end
309for i ulong 64
310put Things i 0
311end
312put Sw 3 0
313n = get Inlen 0
314if gt n 2048
315n = 2048
316end
317s = ulong 0
318for p ulong n
319if eq get In p 10
320if gt p s
321if lt get Sc 5 12
322put Sc 5 add get Sc 5 1
323if not scln s p
324put Sc 6 add get Sc 6 1
325end
326else
327put Sc 7 add get Sc 7 1
328end
329end
330s = add p 1
331end
332end
333if and lt s n lt get Sc 5 12
334put Sc 5 add get Sc 5 1
335if not scln s n
336put Sc 6 add get Sc 6 1
337end
338end
339ret or ne get Sc 2 0 ne get Sc 3 0
340end