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