Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/evidence/allen-omega-L694/L765/red3.om # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / evidence / allen-omega-L694 / L765 / red3.om` 4410 lines ยท 72875 bytes Raw Blame History 1 note L694 fixed-buffer utilities. No platform effects in product functions. 2 global In uchar 8192 3 global Inlen ulong 1 4 global Outb uchar 8192 5 global Outlen ulong 1 6 global Err ulong 1 7 text Digits "`0123456789abcdef`" 8 fn emitb c uchar to void 9 n = get Outlen 0 10 if ge n len Outb 11 put Err 0 1 12 else 13 put Outb n c 14 put Outlen 0 add n 1 15 end 16 end 17 fn emitn v ulong to void 18 d = new uchar 20 0 19 n = ulong 0 20 x = v 21 put d n uchar add rem x 10 48 22 n = add n 1 23 x = div x 10 24 while gt x 0 25 put d n uchar add rem x 10 48 26 n = add n 1 27 x = div x 10 28 end 29 while gt n 0 30 n = sub n 1 31 emitb get d n 32 end 33 end 34 fn outreset to void 35 put Outlen 0 0 36 put Err 0 0 37 end 38 fn ineq at ulong c uchar to bool 39 if ge at get Inlen 0 40 ret false 41 end 42 ret eq get In at c 43 end 44 fn isdigit c uchar to bool 45 ret and ge c 48 le c 57 46 end 47 note Parser cursor P0, number P1, error P2. Never wraps a u32. 48 global P ulong 3 49 fn number to void 50 v = ulong 0 51 n = ulong 0 52 p = get P 0 53 while lt p get Inlen 0 54 c = get In p 55 if not isdigit c 56 put P 0 p 57 put P 1 v 58 if eq n 0 59 put P 2 1 60 end 61 ret 62 end 63 if or ge n 10 gt v `429496729` 64 put P 2 1 65 ret 66 end 67 v = add mul v 10 sub ulong c 48 68 if gt v `4294967295` 69 put P 2 1 70 ret 71 end 72 n = add n 1 73 p = add p 1 74 end 75 put P 0 p 76 put P 1 v 77 if eq n 0 78 put P 2 1 79 end 80 end 81 fn expect c uchar to void 82 p = get P 0 83 if not ineq p c 84 put P 2 1 85 else 86 put P 0 add p 1 87 end 88 end 89 fn crc off ulong count ulong to uint 90 c = uint `4294967295` 91 for i ulong count 92 c = xor c uint get In add off i 93 for k ulong 8 94 if ne and c 1 0 95 c = xor shr c 1 `3988292384` 96 else 97 c = shr c 1 98 end 99 end 100 end 101 ret not c 102 end 103 note SPDX-License-Identifier: AGPL-3.0-or-later 104 note SHA256 core reused byte-for-byte from native Omega TRN1 at `12251e3403d42931ada27dc1c54b3b610954be5d`. 105 note Reads stdin up to 8 MiB and emits lowercase hex plus LF only after successful EOF. 106 global Buf uchar 8192 107 global H uint 8 108 global Vv uint 8 109 global W uint 64 110 global K uint 64 111 global Hb uchar 64 112 global Hs ulong 2 113 global Hash uchar 32 114 global Out uchar 65 115 text Hex "`0123456789abcdef`" 116 117 fn rotate x uint n uint to uint 118 ret or shr x n shl x sub 32 n 119 end 120 121 fn round i ulong to void 122 e = get Vv 4 123 a = get Vv 0 124 s = xor xor rotate e 6 rotate e 11 rotate e 25 125 c = xor and e get Vv 5 and not e get Vv 6 126 t = add add get Vv 7 s add c add get K i get W i 127 s = xor xor rotate a 2 rotate a 13 rotate a 22 128 c = and a get Vv 1 129 c = xor c and a get Vv 2 130 c = xor c and get Vv 1 get Vv 2 131 u = add s c 132 put Vv 7 get Vv 6 133 put Vv 6 get Vv 5 134 put Vv 5 e 135 put Vv 4 add get Vv 3 t 136 put Vv 3 get Vv 2 137 put Vv 2 get Vv 1 138 put Vv 1 a 139 put Vv 0 add t u 140 end 141 142 fn block to void 143 for i ulong 16 144 x = uint 0 145 for j ulong 4 146 x = or shl x 8 uint get Hb add mul i 4 j 147 end 148 put W i x 149 end 150 for j ulong 48 151 i = add j 16 152 x = get W sub i 15 153 y = get W sub i 2 154 s = xor xor rotate x 7 rotate x 18 shr x 3 155 t = xor xor rotate y 17 rotate y 19 shr y 10 156 put W i add add get W sub i 16 s add get W sub i 7 t 157 end 158 for i ulong 8 159 put Vv i get H i 160 end 161 for i ulong 64 162 round i 163 end 164 for i ulong 8 165 put H i add get H i get Vv i 166 end 167 end 168 169 fn hinit to void 170 put H 0 `1779033703` 171 put H 1 `3144134277` 172 put H 2 `1013904242` 173 put H 3 `2773480762` 174 put H 4 `1359893119` 175 put H 5 `2600822924` 176 put H 6 `528734635` 177 put H 7 `1541459225` 178 put Hs 0 0 179 put Hs 1 0 180 end 181 182 fn hbyte c uchar to void 183 p = get Hs 0 184 put Hb p c 185 p = add p 1 186 put Hs 1 add get Hs 1 1 187 if eq p 64 188 block 189 p = 0 190 end 191 put Hs 0 p 192 end 193 194 fn update off ulong count ulong to void 195 for i ulong count 196 hbyte get Buf add off i 197 end 198 end 199 200 fn finish to void 201 bits = mul get Hs 1 8 202 hbyte 128 203 while ne get Hs 0 56 204 hbyte 0 205 end 206 for i ulong 8 207 hbyte uchar and shr bits mul sub 7 i 8 255 208 end 209 for i ulong 32 210 x = get H div i 4 211 put Hash i uchar and shr x uint mul sub 3 rem i 4 8 255 212 end 213 end 214 215 fn constants to void 216 put K 0 `1116352408` 217 put K 1 `1899447441` 218 put K 2 `3049323471` 219 put K 3 `3921009573` 220 put K 4 `961987163` 221 put K 5 `1508970993` 222 put K 6 `2453635748` 223 put K 7 `2870763221` 224 put K 8 `3624381080` 225 put K 9 `310598401` 226 put K 10 `607225278` 227 put K 11 `1426881987` 228 put K 12 `1925078388` 229 put K 13 `2162078206` 230 put K 14 `2614888103` 231 put K 15 `3248222580` 232 put K 16 `3835390401` 233 put K 17 `4022224774` 234 put K 18 `264347078` 235 put K 19 `604807628` 236 put K 20 `770255983` 237 put K 21 `1249150122` 238 put K 22 `1555081692` 239 put K 23 `1996064986` 240 put K 24 `2554220882` 241 put K 25 `2821834349` 242 put K 26 `2952996808` 243 put K 27 `3210313671` 244 put K 28 `3336571891` 245 put K 29 `3584528711` 246 put K 30 `113926993` 247 put K 31 `338241895` 248 put K 32 `666307205` 249 put K 33 `773529912` 250 put K 34 `1294757372` 251 put K 35 `1396182291` 252 put K 36 `1695183700` 253 put K 37 `1986661051` 254 put K 38 `2177026350` 255 put K 39 `2456956037` 256 put K 40 `2730485921` 257 put K 41 `2820302411` 258 put K 42 `3259730800` 259 put K 43 `3345764771` 260 put K 44 `3516065817` 261 put K 45 `3600352804` 262 put K 46 `4094571909` 263 put K 47 `275423344` 264 put K 48 `430227734` 265 put K 49 `506948616` 266 put K 50 `659060556` 267 put K 51 `883997877` 268 put K 52 `958139571` 269 put K 53 `1322822218` 270 put K 54 `1537002063` 271 put K 55 `1747873779` 272 put K 56 `1955562222` 273 put K 57 `2024104815` 274 put K 58 `2227730452` 275 put K 59 `2361852424` 276 put K 60 `2428436474` 277 put K 61 `2756734187` 278 put K 62 `3204031479` 279 put K 63 `3329325298` 280 end 281 282 note R: seq, active, kind (1 chat 2 code 3 more), asked, heard, slow, 283 note code-visible, prompt length, answer length, history count, session. 284 global R ulong 16 285 global Prompt uchar 160 286 global Answer uchar 160 287 global Hist uchar 5120 288 global Hlen ulong 32 289 text Ack "I need to code that. Let me send it off to the Spark." 290 text Ackmore "Let me take that change to the Spark." 291 fn textok to bool 292 n = get Inlen 0 293 if or eq n 0 gt n 159 294 ret false 295 end 296 for i ulong n 297 c = get In i 298 if or lt c 32 gt c 126 299 ret false 300 end 301 end 302 ret true 303 end 304 fn histadd which ulong to void 305 n = get R 9 306 if eq n 32 307 for i ulong 4960 308 put Hist i get Hist add i 160 309 end 310 for i ulong 31 311 put Hlen i get Hlen add i 1 312 end 313 n = 31 314 end 315 size = get R add which 7 316 for i ulong size 317 if eq which 0 318 put Hist add mul n 160 i get Prompt i 319 else 320 put Hist add mul n 160 i get Answer i 321 end 322 end 323 put Hlen n size 324 put R 9 add n 1 325 end 326 fn start kind ulong now ulong to bool 327 if or ne get R 1 0 ge get R 0 `4294967295` 328 ret false 329 end 330 if or lt kind 1 gt kind 3 331 ret false 332 end 333 if and eq kind 3 eq get R 6 0 334 ret false 335 end 336 if not textok 337 ret false 338 end 339 for i ulong get Inlen 0 340 put Prompt i get In i 341 end 342 put R 7 get Inlen 0 343 put R 0 add get R 0 1 344 put R 1 1 345 put R 2 kind 346 put R 3 now 347 put R 4 now 348 put R 5 0 349 put R 8 0 350 put R 11 0 351 put R 13 0 352 if eq kind 2 353 for i ulong len Ack 354 put Answer i get Ack i 355 end 356 put R 8 len Ack 357 end 358 if eq kind 3 359 for i ulong len Ackmore 360 put Answer i get Ackmore i 361 end 362 put R 8 len Ackmore 363 end 364 histadd 0 365 ret true 366 end 367 fn answer seq ulong now ulong to bool 368 if or eq get R 1 0 ne seq get R 0 369 ret false 370 end 371 if or lt now get R 4 not textok 372 ret false 373 end 374 for i ulong get Inlen 0 375 put Answer i get In i 376 end 377 put R 8 get Inlen 0 378 put R 4 now 379 put R 1 0 380 histadd 1 381 ret true 382 end 383 fn cancel to void 384 put R 1 0 385 end 386 fn heard seq ulong now ulong to bool 387 if or eq get R 1 0 ne seq get R 0 388 ret false 389 end 390 if lt now get R 4 391 ret false 392 end 393 put R 4 now 394 ret true 395 end 396 fn tick now ulong to ulong 397 if or eq get R 1 0 lt now get R 4 398 ret 0 399 end 400 if ge sub now get R 4 30000 401 cancel 402 ret 2 403 end 404 if and eq get R 5 0 ge sub now get R 3 20000 405 put R 5 1 406 ret 1 407 end 408 ret 0 409 end 410 fn reset to void 411 for i ulong 9 412 put R add i 1 0 413 end 414 end 415 note Restore one externally decoded transcript line. No live job or ID reuse. 416 fn restore to bool 417 if or ne get R 1 0 not textok 418 ret false 419 end 420 for i ulong get Inlen 0 421 put Answer i get In i 422 end 423 put R 8 get Inlen 0 424 histadd 1 425 ret true 426 end 427 note CODE protocol: C seq, parts, bytes, crc, got. D parsed header. 428 global C ulong 8 429 global D ulong 8 430 global Code uchar 32769 431 global Have uchar 256 432 global Piece uchar 128 433 global Lang uchar 16 434 global Newlang uchar 16 435 fn codebeg seq ulong to void 436 for i ulong 8 437 put C i 0 438 end 439 put C 0 seq 440 for i ulong 256 441 put Have i 0 442 end 443 put Code 0 0 444 end 445 fn decfield slot ulong sep uchar to void 446 number 447 put D slot get P 1 448 expect sep 449 end 450 fn hexread to void 451 v = ulong 0 452 for i ulong 8 453 p = get P 0 454 if ge p get Inlen 0 455 put P 2 1 456 ret 457 end 458 c = get In p 459 d = ulong 16 460 if isdigit c 461 d = sub ulong c 48 462 else 463 if and ge c 97 le c 102 464 d = sub ulong c 87 465 end 466 end 467 if ge d 16 468 put P 2 1 469 ret 470 end 471 v = add mul v 16 d 472 put P 0 add p 1 473 end 474 put D 4 v 475 expect 32 476 end 477 fn codehead to bool 478 put P 0 0 479 put P 2 0 480 expect 67 481 expect 79 482 expect 68 483 expect 69 484 expect 32 485 decfield 0 32 486 decfield 1 47 487 decfield 2 32 488 decfield 3 32 489 hexread 490 if ne get P 2 0 491 ret false 492 end 493 if or ne get D 0 get C 0 eq get D 3 0 494 ret false 495 end 496 if gt get D 3 32768 497 ret false 498 end 499 if ne get D 2 div add get D 3 127 128 500 ret false 501 end 502 if or lt get D 1 1 gt get D 1 get D 2 503 ret false 504 end 505 if ne get C 1 0 506 if or ne get C 1 get D 2 ne get C 2 get D 3 507 ret false 508 end 509 if ne get C 3 get D 4 510 ret false 511 end 512 end 513 ret true 514 end 515 fn langread to bool 516 for i ulong 16 517 put Newlang i 0 518 end 519 n = ulong 0 520 p = get P 0 521 while lt p get Inlen 0 522 c = get In p 523 if eq c 32 524 if eq n 0 525 ret false 526 end 527 put P 0 add p 1 528 put D 5 n 529 ret true 530 end 531 ok = or and ge c 97 le c 122 isdigit c 532 ok = or ok or eq c 43 eq c 35 533 ok = or ok or eq c 46 or eq c 95 eq c 45 534 if or not ok ge n 15 535 ret false 536 end 537 put Newlang n c 538 p = add p 1 539 n = add n 1 540 end 541 ret false 542 end 543 fn pieceread to ulong 544 p = get P 0 545 n = ulong 0 546 while lt p get Inlen 0 547 c = get In p 548 p = add p 1 549 if eq c 92 550 if ge p get Inlen 0 551 ret 129 552 end 553 c = get In p 554 p = add p 1 555 if eq c 110 556 c = 10 557 else 558 if ne c 92 559 ret 129 560 end 561 end 562 else 563 if or lt c 32 gt c 126 564 ret 129 565 end 566 end 567 if ge n 128 568 ret 129 569 end 570 put Piece n c 571 n = add n 1 572 end 573 ret n 574 end 575 fn codetake to bool 576 if gt get Inlen 0 320 577 ret false 578 end 579 if not codehead 580 ret false 581 end 582 if not langread 583 ret false 584 end 585 n = pieceread 586 want = ulong 128 587 if eq get D 1 get D 2 588 want = sub get D 3 mul sub get D 2 1 128 589 end 590 if ne n want 591 ret false 592 end 593 slot = sub get D 1 1 594 off = mul slot 128 595 if ne get C 1 0 596 for i ulong 16 597 if ne get Lang i get Newlang i 598 ret false 599 end 600 end 601 end 602 if ne get Have slot 0 603 for i ulong n 604 if ne get Code add off i get Piece i 605 ret false 606 end 607 end 608 ret true 609 end 610 put C 1 get D 2 611 put C 2 get D 3 612 put C 3 get D 4 613 for i ulong 16 614 put Lang i get Newlang i 615 end 616 for i ulong n 617 put Code add off i get Piece i 618 end 619 put Have slot 1 620 put C 4 add get C 4 1 621 ret true 622 end 623 fn codecrc to uint 624 c = uint `4294967295` 625 for i ulong get C 2 626 c = xor c uint get Code i 627 for k ulong 8 628 if ne and c 1 0 629 c = xor shr c 1 `3988292384` 630 else 631 c = shr c 1 632 end 633 end 634 end 635 ret not c 636 end 637 fn codestat to ulong 638 if eq get C 1 0 639 ret 0 640 end 641 if lt get C 4 get C 1 642 ret 1 643 end 644 if ne ulong codecrc get C 3 645 ret 3 646 end 647 lines = ulong 0 648 for i ulong get C 2 649 c = get Code i 650 if eq c 0 651 ret 3 652 end 653 if eq c 10 654 lines = add lines 1 655 end 656 end 657 if ne get Code sub get C 2 1 10 658 lines = add lines 1 659 end 660 if gt lines 800 661 ret 3 662 end 663 put Code get C 2 0 664 ret 2 665 end 666 fn missing to ulong 667 if eq get C 1 0 668 ret 1 669 end 670 for i ulong get C 1 671 if eq get Have i 0 672 ret add i 1 673 end 674 end 675 ret 0 676 end 677 note Display admission is distinct from a model's closing sentence. 678 fn codeshow seq ulong to bool 679 if eq get R 1 0 680 ret false 681 end 682 if or ne seq get R 0 ne seq get C 0 683 ret false 684 end 685 if ne codestat 2 686 ret false 687 end 688 put R 6 1 689 ret true 690 end 691 note Pure courier datagrams. Q session, current seq, last LINE, head, count. 692 global Q ulong 8 693 global N ulong 8 694 global Queue uchar 2560 695 global Qlens ulong 8 696 global Jbuf uchar 4096 697 global Jhave uchar 5 698 global J ulong 3 699 text Keys "ALLEN-COURIER v=1 run= kind= seq= part= bytes=" 700 text Kinds "JOBLINEGOTACKHELLOHI" 701 fn keyread off ulong count ulong to void 702 for i ulong count 703 expect get Keys add off i 704 end 705 end 706 fn keyemit off ulong count ulong to void 707 for i ulong count 708 emitb get Keys add off i 709 end 710 end 711 fn kindoff k ulong to ulong 712 if eq k 1 713 ret 0 714 end 715 if eq k 2 716 ret 3 717 end 718 if eq k 3 719 ret 7 720 end 721 if eq k 4 722 ret 10 723 end 724 if eq k 5 725 ret 13 726 end 727 ret 18 728 end 729 fn kindlen k ulong to ulong 730 if eq k 2 731 ret 4 732 end 733 if eq k 5 734 ret 5 735 end 736 if eq k 6 737 ret 2 738 end 739 ret 3 740 end 741 fn qbegin run ulong seq ulong to void 742 for i ulong 8 743 put Q i 0 744 end 745 put Q 0 run 746 put Q 1 seq 747 for i ulong 5 748 put Jhave i 0 749 end 750 for i ulong 3 751 put J i 0 752 end 753 end 754 note Serializer takes body In/Inlen; Outb/Outlen are published only on success. 755 fn packet k ulong seq ulong part ulong total ulong bytes ulong to bool 756 if or lt k 1 gt k 6 757 ret false 758 end 759 if gt get Inlen 0 1000 760 ret false 761 end 762 outreset 763 keyemit 0 22 764 for i ulong 16 765 d = and shr get Q 0 mul sub 15 i 4 15 766 emitb get Digits d 767 end 768 keyemit 22 6 769 off = kindoff k 770 for i ulong kindlen k 771 emitb get Kinds add off i 772 end 773 keyemit 28 5 774 emitn seq 775 keyemit 33 6 776 emitn part 777 emitb 47 778 emitn total 779 keyemit 39 7 780 emitn bytes 781 emitb 10 782 for i ulong get Inlen 0 783 emitb get In i 784 end 785 ret eq get Err 0 0 786 end 787 fn pkparse to bool 788 if or gt get Inlen 0 1200 lt get Inlen 0 65 789 ret false 790 end 791 put P 0 0 792 put P 2 0 793 keyread 0 22 794 run = ulong 0 795 for i ulong 16 796 p = get P 0 797 c = get In p 798 d = ulong 16 799 if isdigit c 800 d = sub ulong c 48 801 else 802 if and ge c 97 le c 102 803 d = sub ulong c 87 804 end 805 end 806 if ge d 16 807 ret false 808 end 809 run = or shl run 4 d 810 put P 0 add p 1 811 end 812 if ne run get Q 0 813 ret false 814 end 815 keyread 22 6 816 kind = ulong 0 817 for k ulong 6 818 at = get P 0 819 off = kindoff add k 1 820 size = kindlen add k 1 821 ok = true 822 for i ulong size 823 if not ineq add at i get Kinds add off i 824 ok = false 825 end 826 end 827 if and ok ineq add at size 32 828 kind = add k 1 829 end 830 end 831 if eq kind 0 832 ret false 833 end 834 put N 0 kind 835 put P 0 add get P 0 kindlen kind 836 keyread 28 5 837 number 838 put N 1 get P 1 839 keyread 33 6 840 number 841 put N 2 get P 1 842 expect 47 843 number 844 put N 3 get P 1 845 keyread 39 7 846 number 847 put N 4 get P 1 848 expect 10 849 put N 5 get P 0 850 put N 6 sub get Inlen 0 get P 0 851 ret eq get P 2 0 852 end 853 fn jobtake to ulong 854 note n via N4 855 note part via N2 856 note total via N3 857 if or eq get N 4 0 gt get N 4 4096 858 ret 0 859 end 860 if ne get N 3 div add get N 4 999 1000 861 ret 0 862 end 863 if or eq get N 2 0 gt get N 2 get N 3 864 ret 0 865 end 866 want = ulong 1000 867 if eq get N 2 get N 3 868 want = sub get N 4 mul sub get N 3 1 1000 869 end 870 if ne want get N 6 871 ret 0 872 end 873 if ne get J 0 0 874 if or ne get J 0 get N 4 ne get J 1 get N 3 875 ret 0 876 end 877 end 878 slot = sub get N 2 1 879 off = mul slot 1000 880 if ne get Jhave slot 0 881 for i ulong want 882 if ne get Jbuf add off i get In add get N 5 i 883 ret 0 884 end 885 end 886 ret 2 887 end 888 for i ulong want 889 put Jbuf add off i get In add get N 5 i 890 end 891 put Jhave slot 1 892 put J 0 get N 4 893 put J 1 get N 3 894 put J 2 add get J 2 1 895 ret 1 896 end 897 note Return0 refused,1 accepted,2 duplicate requiring GOT/ACK again. 898 fn qreceive to ulong 899 if not pkparse 900 ret 0 901 end 902 if ne get N 1 get Q 1 903 ret 0 904 end 905 kind = get N 0 906 if eq kind 1 907 ret jobtake 908 end 909 if ne kind 2 910 if ne get N 6 0 911 ret 0 912 end 913 ret 1 914 end 915 note part via N2 916 if eq get N 2 0 917 ret 0 918 end 919 if le get N 2 get Q 2 920 ret 2 921 end 922 if or ne get N 2 add get Q 2 1 eq get Q 4 8 923 ret 0 924 end 925 n = get N 6 926 if or eq n 0 gt n 319 927 ret 0 928 end 929 slot = rem add get Q 3 get Q 4 8 930 for i ulong n 931 put Queue add mul slot 320 i get In add get N 5 i 932 end 933 put Qlens slot n 934 put Q 4 add get Q 4 1 935 put Q 2 get N 2 936 ret 1 937 end 938 fn qtake to bool 939 if eq get Q 4 0 940 ret false 941 end 942 slot = get Q 3 943 n = get Qlens slot 944 for i ulong n 945 put In i get Queue add mul slot 320 i 946 end 947 put Inlen 0 n 948 put Q 3 rem add slot 1 8 949 put Q 4 sub get Q 4 1 950 ret true 951 end 952 note Courier client lifecycle; injected monotonic milliseconds, no host clock/socket. 953 note T lastclock, HIvalid, HIat, HELLOvalid, HELLOat, active, acked, jobat, 954 note joblength, cursor, pendingkind, pendingpart, reserved, GOTpart, reserved, reserved. 955 note Serialized API: qnext publishes one datagram; qsent records actual send result. 956 note Consume Outb before another serializer; failed sends leave retries due. 957 global T ulong 16 958 global JobOut uchar 4096 959 fn qstart run ulong now ulong to bool 960 if eq run 0 961 ret false 962 end 963 qbegin run 0 964 for i ulong 16 965 put T i 0 966 end 967 put T 0 now 968 ret true 969 end 970 fn qready now ulong to bool 971 if or eq get Q 0 0 lt now get T 0 972 ret false 973 end 974 if eq get T 1 0 975 ret false 976 end 977 ret lt sub now get T 2 30000 978 end 979 fn qsubmit now ulong to bool 980 if or eq get Q 0 0 lt now get T 0 981 ret false 982 end 983 if ne get T 10 0 984 ret false 985 end 986 if and ne get T 5 0 eq get T 6 0 987 ret false 988 end 989 n = get Inlen 0 990 if or eq n 0 gt n 4096 991 ret false 992 end 993 if ge get Q 1 `4294967295` 994 ret false 995 end 996 seq = add get Q 1 1 997 qbegin get Q 0 seq 998 for i ulong n 999 c = get In i 1000 if or eq c 10 eq c 13 1001 c = uchar 32 1002 end 1003 put JobOut i c 1004 end 1005 put T 0 now 1006 put T 5 1 1007 put T 6 0 1008 put T 7 now 1009 put T 8 n 1010 put T 9 1 1011 put T 13 0 1012 ret true 1013 end 1014 fn qnext now ulong link bool to bool 1015 if or eq get Q 0 0 lt now get T 0 1016 ret false 1017 end 1018 if ne get T 10 0 1019 ret false 1020 end 1021 put T 0 now 1022 if not link 1023 ret false 1024 end 1025 if ne get T 13 0 1026 put Inlen 0 0 1027 if not packet 3 get Q 1 get T 13 0 0 1028 ret false 1029 end 1030 put T 10 3 1031 put T 11 get T 13 1032 ret true 1033 end 1034 delay = ulong 2000 1035 if qready now 1036 delay = ulong 10000 1037 end 1038 if or eq get T 3 0 ge sub now get T 4 delay 1039 put Inlen 0 0 1040 if not packet 5 0 0 0 0 1041 ret false 1042 end 1043 put T 10 5 1044 put T 11 0 1045 ret true 1046 end 1047 if or eq get T 5 0 ne get T 6 0 1048 ret false 1049 end 1050 part = get T 9 1051 if eq part 0 1052 if lt sub now get T 7 2000 1053 ret false 1054 end 1055 part = ulong 1 1056 end 1057 n = get T 8 1058 total = div add n 999 1000 1059 off = mul sub part 1 1000 1060 size = sub n off 1061 if gt size 1000 1062 size = ulong 1000 1063 end 1064 for i ulong size 1065 put In i get JobOut add off i 1066 end 1067 put Inlen 0 size 1068 if not packet 1 get Q 1 part total n 1069 ret false 1070 end 1071 put T 10 1 1072 put T 11 part 1073 ret true 1074 end 1075 fn qsent now ulong ok bool to bool 1076 if or eq get T 10 0 lt now get T 0 1077 ret false 1078 end 1079 kind = get T 10 1080 part = get T 11 1081 put T 0 now 1082 put T 10 0 1083 put T 11 0 1084 if not ok 1085 ret true 1086 end 1087 if eq kind 5 1088 put T 3 1 1089 put T 4 now 1090 end 1091 if eq kind 3 1092 if eq get T 13 part 1093 put T 13 0 1094 end 1095 end 1096 if eq kind 1 1097 if or ne get T 6 0 ge part div add get T 8 999 1000 1098 put T 9 0 1099 put T 7 now 1100 else 1101 put T 9 add part 1 1102 end 1103 end 1104 ret true 1105 end 1106 fn qincoming now ulong to ulong 1107 if or eq get Q 0 0 lt now get T 0 1108 ret 0 1109 end 1110 if not pkparse 1111 ret 0 1112 end 1113 kind = get N 0 1114 if eq kind 6 1115 if or ne get N 1 0 ne get N 2 0 1116 ret 0 1117 end 1118 if or ne get N 3 0 ne get N 4 0 1119 ret 0 1120 end 1121 if ne get N 6 0 1122 ret 0 1123 end 1124 put T 0 now 1125 put T 1 1 1126 put T 2 now 1127 ret 1 1128 end 1129 if or eq get T 5 0 ne get N 1 get Q 1 1130 ret 0 1131 end 1132 if eq kind 4 1133 if or ne get N 2 0 ne get N 3 0 1134 ret 0 1135 end 1136 if or ne get N 4 0 ne get N 6 0 1137 ret 0 1138 end 1139 put T 0 now 1140 put T 6 1 1141 put T 9 0 1142 ret 1 1143 end 1144 if ne kind 2 1145 ret 0 1146 end 1147 if or ne get N 3 0 ne get N 4 0 1148 ret 0 1149 end 1150 if and ne get T 13 0 ne get T 13 get N 2 1151 ret 0 1152 end 1153 result = qreceive 1154 if eq result 0 1155 ret 0 1156 end 1157 put T 0 now 1158 put T 6 1 1159 put T 9 0 1160 put T 13 get N 2 1161 ret result 1162 end 1163 fn qcancel to void 1164 put T 5 0 1165 put T 6 0 1166 put T 8 0 1167 put T 9 0 1168 put T 10 0 1169 put T 11 0 1170 put T 13 0 1171 put Q 3 0 1172 put Q 4 0 1173 end 1174 note Legacy application record codec; SHA is unkeyed integrity ONLY. 1175 global Unit uchar 4096 1176 global Enc uchar 4096 1177 global Mem uchar 3692 1178 global Md ulong 3 1179 global Note uchar 128 1180 global Ns ulong 4 1181 text Magic "AIENALM1" 1182 text Nmagic "AIENNOT1" 1183 fn get32 off ulong to ulong 1184 v = ulong 0 1185 for i ulong 4 1186 v = or v shl ulong get Unit add off i mul i 8 1187 end 1188 ret v 1189 end 1190 fn get64 off ulong to ulong 1191 ret or get32 off shl get32 add off 4 32 1192 end 1193 fn put32 off ulong v ulong to void 1194 for i ulong 4 1195 put Unit add off i uchar and shr v mul i 8 255 1196 end 1197 end 1198 fn put64 off ulong v ulong to void 1199 put32 off and v `4294967295` 1200 put32 add off 4 shr v 32 1201 end 1202 fn mem32 off ulong to ulong 1203 v = ulong 0 1204 for i ulong 4 1205 v = or v shl ulong get Mem add off i mul i 8 1206 end 1207 ret v 1208 end 1209 fn mset32 off ulong v ulong to void 1210 for i ulong 4 1211 put Mem add off i uchar and shr v mul i 8 255 1212 end 1213 end 1214 fn zeroend off ulong to bool 1215 for i ulong sub ulong 4096 off 1216 if ne get Unit add off i 0 1217 ret false 1218 end 1219 end 1220 ret true 1221 end 1222 fn fieldok off ulong cap ulong name bool to bool 1223 n = ulong 0 1224 while lt n cap 1225 if eq get Unit add off n 0 1226 for j ulong sub cap n 1227 if ne get Unit add add off n j 0 1228 ret false 1229 end 1230 end 1231 ret true 1232 end 1233 c = get Unit add off n 1234 lower = and ge c 97 le c 122 1235 digit = isdigit c 1236 if name 1237 if eq n 0 1238 if not or and ge c 65 le c 90 digit 1239 ret false 1240 end 1241 else 1242 if not or lower digit 1243 ret false 1244 end 1245 end 1246 else 1247 if eq c 32 1248 if or eq n 0 eq n sub cap 1 1249 ret false 1250 end 1251 if eq get Unit add off add n 1 0 1252 ret false 1253 end 1254 if eq get Unit add off sub n 1 32 1255 ret false 1256 end 1257 else 1258 if not or lower digit 1259 ret false 1260 end 1261 end 1262 end 1263 n = add n 1 1264 end 1265 ret false 1266 end 1267 fn digest count ulong to void 1268 hinit 1269 for i ulong 32 1270 hbyte get Unit i 1271 end 1272 for i ulong count 1273 hbyte get Unit add i 64 1274 end 1275 finish 1276 end 1277 fn hashok count ulong to bool 1278 digest count 1279 d = uchar 0 1280 for i ulong 32 1281 d = or d xor get Hash i get Unit add i 32 1282 end 1283 ret eq d 0 1284 end 1285 fn seal count ulong to void 1286 digest count 1287 for i ulong 32 1288 put Unit add i 32 get Hash i 1289 end 1290 end 1291 fn memvalid to bool 1292 for i ulong 8 1293 if ne get Unit i get Magic i 1294 ret false 1295 end 1296 end 1297 ver = get32 8 1298 if or lt ver 2 gt ver 4 1299 ret false 1300 end 1301 n = get32 96 1302 if or gt n 32 gt get32 100 512 1303 ret false 1304 end 1305 size = add 40 mul n 113 1306 if ge ver 3 1307 size = add size 24 1308 end 1309 if eq ver 4 1310 size = add size 12 1311 end 1312 if or ne size get32 12 eq get64 16 0 1313 ret false 1314 end 1315 for i ulong 8 1316 if ne get Unit add i 24 0 1317 ret false 1318 end 1319 end 1320 if not zeroend add 64 size 1321 ret false 1322 end 1323 if not hashok size 1324 ret false 1325 end 1326 if not fieldok 72 24 true 1327 ret false 1328 end 1329 for i ulong n 1330 off = add 104 mul i 113 1331 if or eq get Unit off 0 eq get Unit add off 48 0 1332 ret false 1333 end 1334 if not fieldok off 48 false 1335 ret false 1336 end 1337 if not fieldok add off 48 64 false 1338 ret false 1339 end 1340 if gt get Unit add off 112 1 1341 ret false 1342 end 1343 end 1344 off = add 104 mul n 113 1345 if ge ver 3 1346 if not fieldok off 24 true 1347 ret false 1348 end 1349 end 1350 if eq ver 4 1351 if ne get Unit add off 27 0 1352 ret false 1353 end 1354 end 1355 ret true 1356 end 1357 fn memdec to bool 1358 if not memvalid 1359 ret false 1360 end 1361 size = get32 12 1362 for i ulong 3692 1363 put Mem i 0 1364 end 1365 for i ulong size 1366 put Mem i get Unit add i 64 1367 end 1368 put Md 0 get64 16 1369 put Md 1 get32 8 1370 put Md 2 size 1371 ret true 1372 end 1373 fn memenc gen ulong to bool 1374 n = mem32 32 1375 if or gt n 32 eq gen 0 1376 ret false 1377 end 1378 size = add 76 mul n 113 1379 for i ulong 4096 1380 put Unit i 0 1381 end 1382 for i ulong 8 1383 put Unit i get Magic i 1384 end 1385 put32 8 4 1386 put32 12 size 1387 put64 16 gen 1388 for i ulong size 1389 put Unit add i 64 get Mem i 1390 end 1391 seal size 1392 if not memvalid 1393 ret false 1394 end 1395 for i ulong 4096 1396 put Enc i get Unit i 1397 end 1398 ret true 1399 end 1400 fn noteval index ulong to bool 1401 for i ulong 8 1402 if ne get Unit i get Nmagic i 1403 ret false 1404 end 1405 end 1406 n = get32 12 1407 if or eq n 0 ge n 128 1408 ret false 1409 end 1410 if or ne get32 8 1 ne get32 16 index 1411 ret false 1412 end 1413 if or gt get32 24 1 ne get32 28 0 1414 ret false 1415 end 1416 if not zeroend add n 64 1417 ret false 1418 end 1419 for i ulong n 1420 c = get Unit add i 64 1421 if or lt c 32 gt c 126 1422 ret false 1423 end 1424 end 1425 ret hashok n 1426 end 1427 fn notedec index ulong to bool 1428 if not noteval index 1429 ret false 1430 end 1431 n = get32 12 1432 for i ulong 128 1433 put Note i 0 1434 end 1435 for i ulong n 1436 put Note i get Unit add i 64 1437 end 1438 put Ns 0 n 1439 put Ns 1 index 1440 put Ns 2 get32 20 1441 put Ns 3 get32 24 1442 ret true 1443 end 1444 fn noteenc to bool 1445 n = get Ns 0 1446 if or eq n 0 ge n 128 1447 ret false 1448 end 1449 if or gt get Ns 1 511 gt get Ns 2 `4294967295` 1450 ret false 1451 end 1452 if gt get Ns 3 1 1453 ret false 1454 end 1455 for i ulong n 1456 c = get Note i 1457 if or lt c 32 gt c 126 1458 ret false 1459 end 1460 end 1461 for i ulong 4096 1462 put Unit i 0 1463 end 1464 for i ulong 8 1465 put Unit i get Nmagic i 1466 end 1467 put32 8 1 1468 put32 12 n 1469 put32 16 get Ns 1 1470 put32 20 get Ns 2 1471 put32 24 get Ns 3 1472 for i ulong n 1473 put Unit add i 64 get Note i 1474 end 1475 seal n 1476 for i ulong 4096 1477 put Enc i get Unit i 1478 end 1479 ret true 1480 end 1481 note Store St gen,newest,valid. Tx phase,target,newgen. Provider owns actual I/O. 1482 global St ulong 3 1483 global Nt ulong 2 1484 global Load ulong 1 1485 global Tx ulong 3 1486 fn txbegin to bool 1487 if ne get Nt 0 0 1488 ret false 1489 end 1490 if or ne get Tx 0 0 eq get St 0 `18446744073709551615` 1491 ret false 1492 end 1493 if not memenc add get St 0 1 1494 ret false 1495 end 1496 put Tx 1 0 1497 if ne get St 0 0 1498 put Tx 1 sub ulong 1 get St 1 1499 end 1500 put Tx 2 add get St 0 1 1501 put Tx 0 1 1502 ret true 1503 end 1504 fn txwrite ok bool to bool 1505 if ne get Tx 0 1 1506 ret false 1507 end 1508 if not ok 1509 put Tx 0 0 1510 ret false 1511 end 1512 put Tx 0 2 1513 ret true 1514 end 1515 fn txflush ok bool to bool 1516 if ne get Tx 0 2 1517 ret false 1518 end 1519 if not ok 1520 put Tx 0 0 1521 ret false 1522 end 1523 put Tx 0 3 1524 ret true 1525 end 1526 fn txread ok bool to bool 1527 if ne get Tx 0 3 1528 ret false 1529 end 1530 put Tx 0 0 1531 if not ok 1532 ret false 1533 end 1534 d = uchar 0 1535 for i ulong 4096 1536 d = or d xor get Unit i get Enc i 1537 end 1538 if ne d 0 1539 ret false 1540 end 1541 put St 0 get Tx 2 1542 put St 1 get Tx 1 1543 if lt get St 2 2 1544 put St 2 add get St 2 1 1545 end 1546 ret true 1547 end 1548 note Load each copy once into Unit. Caller resets St and calls loadcopy0,1. 1549 fn loadbeg to void 1550 for i ulong 3 1551 put St i 0 1552 end 1553 put Load 0 0 1554 end 1555 fn loadcopy slot ulong to bool 1556 if gt slot 1 1557 ret false 1558 end 1559 if ne and get Load 0 shl ulong 1 slot 0 1560 ret false 1561 end 1562 if not memvalid 1563 ret false 1564 end 1565 put Load 0 or get Load 0 shl ulong 1 slot 1566 put St 2 add get St 2 1 1567 if gt get64 16 get St 0 1568 b = memdec 1569 put St 0 get Md 0 1570 put St 1 slot 1571 end 1572 ret true 1573 end 1574 note Note transaction completes before the parent copy may publish its count. 1575 fn nbegin to bool 1576 if or ne get Nt 0 0 ne get Tx 0 0 1577 ret false 1578 end 1579 if not noteenc 1580 ret false 1581 end 1582 put Nt 1 get Ns 1 1583 put Nt 0 1 1584 ret true 1585 end 1586 fn nwrite ok bool to bool 1587 if ne get Nt 0 1 1588 ret false 1589 end 1590 if not ok 1591 put Nt 0 0 1592 ret false 1593 end 1594 put Nt 0 2 1595 ret true 1596 end 1597 fn nflush ok bool to bool 1598 if ne get Nt 0 2 1599 ret false 1600 end 1601 if not ok 1602 put Nt 0 0 1603 ret false 1604 end 1605 put Nt 0 3 1606 ret true 1607 end 1608 fn nread ok bool to bool 1609 if ne get Nt 0 3 1610 ret false 1611 end 1612 put Nt 0 0 1613 if not ok 1614 ret false 1615 end 1616 d = uchar 0 1617 for i ulong 4096 1618 d = or d xor get Enc i get Unit i 1619 end 1620 if ne d 0 1621 ret false 1622 end 1623 ret noteval get Nt 1 1624 end 1625 note Intent vocabulary frozen from svc/allen_intent.c. It selects jobs, never answers. 1626 global Fold uchar 160 1627 global Fn ulong 2 1628 text Lists "please|can you|could you|would you|will you|i d like you to|i want you to|i need you to|allen|hey allen|ok|okay\nwrite|make|build|create|code|program|generate|implement|develop|give me a|i need a|i want a\ncode|program|programs|script|scripts|function|functions|app|apps|application|game|games|website|web page|webpage|calculator|converter|parser|compiler|interpreter|algorithm|class|api|server|bot|regex|unit test|unit tests|cli|command line tool|snake|tetris|pong|todo app|to do app|to do list app|timer app|stopwatch|python|javascript|typescript|rust|golang|java|kotlin|swift|ruby|php|html|css|sql|bash|shell script|c program|c code|in c|c plus plus|cpp|mojo|zig|haskell|lua|perl\npoem|poems|haiku|story|stories|song|songs|letter|email|essay|joke|jokes|limerick|speech\ncode|program|script\nnow|add|also|and|change|make it|make the|rename|remove|delete|replace|use|fix|put|give it|let it|instead|then|next|can it|could it|it should|the|move|turn|show|split|convert it|rewrite|port it|translate it|explain it\nwrite|make|build|create|code|program|draft|compose|generate|design|implement|invent|name|give me a|i need a|i want a\na poem|a haiku|a story|a song|a script|a function|a program|a list of|some code|a letter|an email|a plan for|a name for\nexplain|what is|what are|whats|what s|why|how does|how do|how is|how are|describe|tell me about|what does|who was|who is|define|when was|when did|where is|is it true\ndifference between|mean|means\ndo|run|fix|find|search|look up|check|open|send|start|stop|install|set up|plan|schedule|calculate|work out|convert|translate|summarize|summarise|list|sort|count|compare|turn|go\n" 1629 fn foldin to void 1630 n = ulong 0 1631 space = false 1632 for i ulong get Inlen 0 1633 c = get In i 1634 if and ge c 65 le c 90 1635 c = add sub c 65 97 1636 end 1637 if or and ge c 97 le c 122 isdigit c 1638 if and space gt n 0 1639 put Fold n uchar 32 1640 n = add n 1 1641 end 1642 put Fold n c 1643 n = add n 1 1644 space = false 1645 else 1646 space = true 1647 end 1648 end 1649 put Fn 0 n 1650 put Fn 1 0 1651 end 1652 fn phrase at ulong off ulong size ulong to bool 1653 if gt add at size get Fn 0 1654 ret false 1655 end 1656 for i ulong size 1657 if ne get Fold add at i get Lists add off i 1658 ret false 1659 end 1660 end 1661 if lt add at size get Fn 0 1662 if ne get Fold add at size 32 1663 ret false 1664 end 1665 end 1666 ret true 1667 end 1668 fn inphrase off ulong size ulong anypos bool to bool 1669 if not anypos 1670 ret phrase get Fn 1 off size 1671 end 1672 count = sub get Fn 0 get Fn 1 1673 for i ulong count 1674 at = add i get Fn 1 1675 ok = eq at get Fn 1 1676 if gt at 0 1677 ok = or ok eq get Fold sub at 1 32 1678 end 1679 if ok 1680 if phrase at off size 1681 ret true 1682 end 1683 end 1684 end 1685 ret false 1686 end 1687 fn listed group ulong anypos bool to ulong 1688 g = ulong 0 1689 s = ulong 0 1690 for p ulong len Lists 1691 c = get Lists p 1692 if or eq c 124 eq c 10 1693 if eq g group 1694 if inphrase s sub p s anypos 1695 ret sub p s 1696 end 1697 end 1698 s = add p 1 1699 if eq c 10 1700 g = add g 1 1701 end 1702 end 1703 end 1704 ret 0 1705 end 1706 fn classify to ulong 1707 if not textok 1708 ret 0 1709 end 1710 foldin 1711 skip = listed 0 false 1712 while gt skip 0 1713 if ge add get Fn 1 skip get Fn 0 1714 skip = 0 1715 else 1716 put Fn 1 add add get Fn 1 skip 1 1717 skip = listed 0 false 1718 end 1719 end 1720 if and ne get R 6 0 gt listed 5 false 0 1721 ret 3 1722 end 1723 plain = listed 4 false 1724 if or eq plain 4 eq plain 7 1725 ret 2 1726 end 1727 if and gt listed 3 true 0 eq listed 4 true 0 1728 ret 1 1729 end 1730 if and gt listed 1 false 0 gt listed 2 true 0 1731 ret 2 1732 end 1733 ret 1 1734 end 1735 note Ordinary want enum0chat,1make,2explain,3do. 1736 fn jobwant to ulong 1737 if gt listed 8 false 0 1738 ret 2 1739 end 1740 if or gt listed 6 false 0 gt listed 7 true 0 1741 ret 1 1742 end 1743 if gt listed 10 false 0 1744 ret 3 1745 end 1746 if gt listed 9 true 0 1747 ret 2 1748 end 1749 ret 0 1750 end 1751 text Job "JOB " 1752 text Codeask " asked " 1753 text Forcode " for code.\t" 1754 text Formore " to change the code just shown.\t" 1755 text Wantstr "chatmakeexplaindo" 1756 text Intro "You are the far hands of " 1757 text Home ", a quiet presence living in AIENOS on " 1758 text Comp "'s computer. You answer as " 1759 text Sees "; " 1760 text Words " sees only your words, as if " 1761 text Said " said them. Plain English, short sentences, no headings, no lists, no greetings, no apologies. Plain letters and punctuation only: no dashes, no curly quotes, no symbols. Never mention a model, a prompt or instructions. " 1762 text Make " asked for something to be made. Make it whole and correct. Begin with one short sentence saying what you made, then the work itself." 1763 text Explain " asked to understand something. Explain it in three plain sentences at most, the heart of it first, no more than is needed." 1764 text Doing " asked for something to be done. " 1765 text Cannot " cannot yet act outside this computer, so say in two or three short sentences what you would do, in order, and what you would need." 1766 text Chat " said something in passing. Answer in one or two warm, plain sentences." 1767 text Allen "Allen" 1768 text Person "the person" 1769 fn selfemit to void 1770 off = add 40 mul mem32 32 113 1771 if eq get Mem off 0 1772 for i ulong len Allen 1773 emitb get Allen i 1774 end 1775 else 1776 for i ulong 24 1777 c = get Mem add off i 1778 if eq c 0 1779 ret 1780 end 1781 emitb c 1782 end 1783 end 1784 end 1785 fn whoemit to void 1786 if eq get Mem 8 0 1787 for i ulong len Person 1788 emitb get Person i 1789 end 1790 else 1791 for i ulong 24 1792 c = get Mem add i 8 1793 if eq c 0 1794 ret 1795 end 1796 emitb c 1797 end 1798 end 1799 end 1800 fn jobbuild kind ulong seq ulong to bool 1801 if or lt kind 1 gt kind 3 1802 ret false 1803 end 1804 if or eq seq 0 gt seq `4294967295` 1805 ret false 1806 end 1807 if not textok 1808 ret false 1809 end 1810 outreset 1811 for i ulong len Job 1812 emitb get Job i 1813 end 1814 emitn seq 1815 emitb 32 1816 if gt kind 1 1817 emitb 99 1818 emitb 111 1819 emitb 100 1820 emitb 101 1821 if eq kind 3 1822 emitb 45 1823 emitb 109 1824 emitb 111 1825 emitb 114 1826 emitb 101 1827 end 1828 emitb 32 1829 whoemit 1830 for i ulong len Codeask 1831 emitb get Codeask i 1832 end 1833 selfemit 1834 if eq kind 3 1835 for i ulong len Formore 1836 emitb get Formore i 1837 end 1838 else 1839 for i ulong len Forcode 1840 emitb get Forcode i 1841 end 1842 end 1843 else 1844 w = jobwant 1845 off = ulong 0 1846 size = ulong 4 1847 if eq w 1 1848 off = 4 1849 end 1850 if eq w 2 1851 off = 8 1852 size = 7 1853 end 1854 if eq w 3 1855 off = 15 1856 size = 2 1857 end 1858 for i ulong size 1859 emitb get Wantstr add off i 1860 end 1861 emitb 32 1862 for i ulong len Intro 1863 emitb get Intro i 1864 end 1865 selfemit 1866 for i ulong len Home 1867 emitb get Home i 1868 end 1869 whoemit 1870 for i ulong len Comp 1871 emitb get Comp i 1872 end 1873 selfemit 1874 for i ulong len Sees 1875 emitb get Sees i 1876 end 1877 whoemit 1878 for i ulong len Words 1879 emitb get Words i 1880 end 1881 selfemit 1882 for i ulong len Said 1883 emitb get Said i 1884 end 1885 whoemit 1886 if eq w 0 1887 for i ulong len Chat 1888 emitb get Chat i 1889 end 1890 end 1891 if eq w 1 1892 for i ulong len Make 1893 emitb get Make i 1894 end 1895 end 1896 if eq w 2 1897 for i ulong len Explain 1898 emitb get Explain i 1899 end 1900 end 1901 if eq w 3 1902 for i ulong len Doing 1903 emitb get Doing i 1904 end 1905 selfemit 1906 for i ulong len Cannot 1907 emitb get Cannot i 1908 end 1909 end 1910 emitb 9 1911 end 1912 for i ulong get Inlen 0 1913 emitb get In i 1914 end 1915 ret le get Outlen 0 4096 1916 end 1917 note SAY/WAIT parser, staged folded bytes. Native CODE receive remains separate. 1918 global Say uchar 160 1919 global S ulong 5 1920 fn sayhead to bool 1921 put P 0 0 1922 put P 2 0 1923 if ineq 0 87 1924 expect 87 1925 expect 65 1926 expect 73 1927 expect 84 1928 expect 32 1929 number 1930 put S 0 get P 1 1931 put S 1 0 1932 put S 2 0 1933 if ne get P 0 get Inlen 0 1934 ret false 1935 end 1936 ret eq get P 2 0 1937 end 1938 expect 83 1939 expect 65 1940 expect 89 1941 expect 32 1942 number 1943 put S 0 get P 1 1944 expect 32 1945 if ne get P 2 0 1946 ret false 1947 end 1948 put S 1 1 1949 put S 2 1 1950 save = get P 0 1951 number 1952 part = get P 1 1953 if ineq get P 0 47 1954 expect 47 1955 number 1956 put S 2 get P 1 1957 expect 32 1958 if or ne get P 2 0 eq part 0 1959 ret false 1960 end 1961 put S 1 part 1962 else 1963 put P 0 save 1964 put P 2 0 1965 end 1966 put S 3 get P 0 1967 ret eq get P 2 0 1968 end 1969 fn sayfold to bool 1970 n = ulong 0 1971 p = get S 3 1972 space = true 1973 while lt p get Inlen 0 1974 c = get In p 1975 p = add p 1 1976 if eq c 92 1977 if or ineq p 110 ineq p 116 1978 c = 32 1979 p = add p 1 1980 end 1981 end 1982 if or lt c 32 ge c 127 1983 c = 32 1984 end 1985 if eq c 32 1986 if not space 1987 if ge n 159 1988 ret false 1989 end 1990 put Say n c 1991 n = add n 1 1992 end 1993 space = true 1994 else 1995 if ge n 159 1996 ret false 1997 end 1998 put Say n c 1999 n = add n 1 2000 space = false 2001 end 2002 end 2003 if gt n 0 2004 if eq get Say sub n 1 32 2005 n = sub n 1 2006 end 2007 end 2008 put S 4 n 2009 ret true 2010 end 2011 note Return1 accepted,2 request AGAIN,3 give up after retry;0 rejected. 2012 fn saytake now ulong to ulong 2013 if or eq get R 1 0 gt get Inlen 0 319 2014 ret 0 2015 end 2016 if not sayhead 2017 ret 0 2018 end 2019 if or ne get S 0 get R 0 lt now get R 4 2020 ret 0 2021 end 2022 if eq get S 1 0 2023 b = heard get S 0 now 2024 ret 1 2025 end 2026 if not sayfold 2027 ret 0 2028 end 2029 if gt get R 2 1 2030 if eq get S 2 0 2031 ret 0 2032 end 2033 if ne get C 0 get R 0 2034 ret 0 2035 end 2036 if ne codestat 2 2037 if eq get R 13 0 2038 put R 13 1 2039 outreset 2040 emitb 65 2041 emitb 71 2042 emitb 65 2043 emitb 73 2044 emitb 78 2045 emitb 32 2046 emitn get R 0 2047 ret 2 2048 end 2049 cancel 2050 ret 3 2051 end 2052 else 2053 if ne get S 1 add get R 11 1 2054 ret 0 2055 end 2056 if and ne get S 2 0 ne get S 2 get S 1 2057 ret 0 2058 end 2059 end 2060 n = get R 8 2061 if or eq get S 1 1 gt get R 2 1 2062 n = 0 2063 end 2064 join = ulong 0 2065 if and gt n 0 gt get S 4 0 2066 join = 1 2067 end 2068 if gt add add n join get S 4 159 2069 ret 0 2070 end 2071 if gt get R 2 1 2072 if not codeshow get R 0 2073 ret 0 2074 end 2075 end 2076 if eq join 1 2077 put Answer n uchar 32 2078 n = add n 1 2079 end 2080 for i ulong get S 4 2081 put Answer add n i get Say i 2082 end 2083 put R 8 add n get S 4 2084 put R 11 get S 1 2085 put R 4 now 2086 if ne get S 2 0 2087 put R 1 0 2088 histadd 1 2089 end 2090 ret 1 2091 end 2092 note Exact legacy code row wrapping, at most4096 rows; full code retained. 2093 global Rowst ulong 4096 2094 global Rowlen ulong 4096 2095 global Rowline ulong 4096 2096 global View ulong 4 2097 global Vwork ulong 6 2098 note Vwork cols,maxrows,line,start,end. 2099 fn onerow s ulong first bool to ulong 2100 take = sub get Vwork 4 s 2101 cols = get Vwork 0 2102 if gt take cols 2103 take = cols 2104 j = cols 2105 while gt j div cols 2 2106 if eq get Code sub add s j 1 32 2107 take = j 2108 j = 0 2109 else 2110 j = sub j 1 2111 end 2112 end 2113 end 2114 slot = get View 0 2115 put Rowst slot s 2116 put Rowlen slot take 2117 put Rowline slot 0 2118 if first 2119 put Rowline slot get Vwork 2 2120 end 2121 put View 0 add slot 1 2122 ret add s take 2123 end 2124 fn rowroom pos ulong to bool 2125 ret and lt pos get C 2 lt get View 0 get Vwork 1 2126 end 2127 fn moreline s ulong to bool 2128 ret and lt s get Vwork 4 lt get View 0 get Vwork 1 2129 end 2130 fn rows cols ulong maxrows ulong to bool 2131 if or eq cols 0 gt maxrows 4096 2132 ret false 2133 end 2134 if ne codestat 2 2135 ret false 2136 end 2137 put Vwork 0 cols 2138 put Vwork 1 maxrows 2139 put Vwork 2 1 2140 put View 0 0 2141 put View 1 0 2142 pos = ulong 0 2143 while rowroom pos 2144 stop = pos 2145 while lt stop get C 2 2146 if eq get Code stop 10 2147 put Vwork 4 stop 2148 stop = get C 2 2149 else 2150 stop = add stop 1 2151 put Vwork 4 stop 2152 end 2153 end 2154 s = pos 2155 if lt get View 0 maxrows 2156 s = onerow s true 2157 end 2158 while moreline s 2159 s = onerow s false 2160 end 2161 pos = add get Vwork 4 1 2162 put Vwork 2 add get Vwork 2 1 2163 end 2164 ret true 2165 end 2166 fn scroll delta long page ulong to ulong 2167 last = ulong 0 2168 if gt get View 0 page 2169 last = sub get View 0 page 2170 end 2171 if gt get View 1 last 2172 put View 1 last 2173 end 2174 top = long get View 1 2175 if lt delta 0 2176 if lt delta neg top 2177 put View 1 0 2178 ret 0 2179 end 2180 else 2181 if gt ulong delta sub last get View 1 2182 put View 1 last 2183 ret last 2184 end 2185 end 2186 top = add top delta 2187 put View 1 ulong top 2188 ret ulong top 2189 end 2190 note Scene state: tone,water,has-say,nthings,used,lines,rejected,over. 2191 global Sc ulong 8 2192 global Things ulong 64 2193 global Stext uchar 2304 2194 global Sw ulong 4 2195 global Fields uchar 1536 2196 global Flens ulong 6 2197 global Soffs ulong 6 2198 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|" 2199 fn scword beg ulong size ulong to ulong 2200 s = ulong 0 2201 word = ulong 1 2202 for i ulong len Vocab 2203 if eq get Vocab i 124 2204 if eq sub i s size 2205 same = true 2206 for j ulong size 2207 if ne get In add beg j get Vocab add s j 2208 same = false 2209 end 2210 end 2211 if same 2212 ret word 2213 end 2214 end 2215 word = add word 1 2216 s = add i 1 2217 end 2218 end 2219 ret 0 2220 end 2221 fn fieldcap kind ulong field ulong to ulong 2222 if eq kind 2 2223 if eq field 0 2224 ret 48 2225 end 2226 ret 64 2227 end 2228 if eq kind 1 2229 if eq field 0 2230 ret 48 2231 end 2232 ret 240 2233 end 2234 if eq kind 3 2235 if eq field 0 2236 ret 16 2237 end 2238 ret 64 2239 end 2240 if eq kind 4 2241 if eq field 0 2242 ret 220 2243 end 2244 ret 48 2245 end 2246 if eq kind 5 2247 if eq field 0 2248 ret 32 2249 end 2250 ret 200 2251 end 2252 if eq kind 6 2253 if eq field 0 2254 ret 24 2255 end 2256 ret 64 2257 end 2258 if eq field 0 2259 ret 120 2260 end 2261 ret 64 2262 end 2263 fn scfield slot ulong beg ulong stop ulong kind ulong to bool 2264 s = beg 2265 e = stop 2266 while lt s e 2267 if eq get In s 32 2268 s = add s 1 2269 else 2270 ret fieldend slot s e kind 2271 end 2272 end 2273 put Flens slot 0 2274 ret true 2275 end 2276 fn fieldend slot ulong s ulong stop ulong kind ulong to bool 2277 e = stop 2278 while gt e s 2279 if eq get In sub e 1 32 2280 e = sub e 1 2281 else 2282 n = sub e s 2283 if gt n fieldcap kind slot 2284 ret false 2285 end 2286 for i ulong n 2287 c = get In add s i 2288 if or lt c 32 gt c 126 2289 ret false 2290 end 2291 put Fields add mul slot 256 i c 2292 end 2293 put Flens slot n 2294 ret true 2295 end 2296 end 2297 put Flens slot 0 2298 ret true 2299 end 2300 fn scfields beg ulong stop ulong kind ulong to ulong 2301 slot = ulong 0 2302 s = beg 2303 for i ulong sub stop beg 2304 p = add beg i 2305 if eq get In p 124 2306 if ge slot 5 2307 ret 0 2308 end 2309 if not scfield slot s p kind 2310 ret 0 2311 end 2312 slot = add slot 1 2313 s = add p 1 2314 end 2315 end 2316 if not scfield slot s stop kind 2317 ret 0 2318 end 2319 n = add slot 1 2320 if and ne kind 2 gt n 2 2321 ret 0 2322 end 2323 if eq get Flens 0 0 2324 ret 0 2325 end 2326 if eq kind 5 2327 if or lt n 2 eq get Flens 1 0 2328 ret 0 2329 end 2330 end 2331 if eq kind 3 2332 hasdigit = false 2333 for i ulong get Flens 0 2334 if isdigit get Fields i 2335 hasdigit = true 2336 end 2337 end 2338 if not hasdigit 2339 ret 0 2340 end 2341 end 2342 ret n 2343 end 2344 fn scput slot ulong to ulong 2345 off = get Sc 4 2346 n = get Flens slot 2347 for i ulong n 2348 put Stext add off i get Fields add mul slot 256 i 2349 end 2350 put Stext add off n 0 2351 put Sc 4 add add off n 1 2352 ret off 2353 end 2354 fn scmod word ulong base ulong to void 2355 if and ge word 11 le word 13 2356 put Things add base 1 sub word 10 2357 end 2358 if and ge word 16 le word 18 2359 put Things add base 2 sub word 16 2360 end 2361 if and ge word 19 le word 20 2362 put Things add base 3 sub word 18 2363 end 2364 if eq word 14 2365 put Things add base 4 1 2366 end 2367 if eq word 15 2368 put Things add base 5 1 2369 end 2370 end 2371 fn scsay beg ulong stop ulong to bool 2372 if ne get Sc 2 0 2373 ret false 2374 end 2375 n = sub stop beg 2376 if or eq n 0 gt n 159 2377 ret false 2378 end 2379 for i ulong n 2380 c = get In add beg i 2381 if or lt c 32 gt c 126 2382 ret false 2383 end 2384 put Fields i c 2385 end 2386 put Flens 0 n 2387 put Sc 2 1 2388 put Sw 3 scput 0 2389 ret true 2390 end 2391 fn scln beg ulong stop ulong to bool 2392 p = beg 2393 while lt p stop 2394 if or eq get In p 32 eq get In p 58 2395 ret scbody beg p stop 2396 end 2397 p = add p 1 2398 end 2399 ret false 2400 end 2401 fn scbody beg ulong wordend ulong stop ulong to bool 2402 word = scword beg sub wordend beg 2403 if eq word 2 2404 s = add wordend 1 2405 if lt s stop 2406 if eq get In s 58 2407 s = add s 1 2408 end 2409 end 2410 while lt s stop 2411 if eq get In s 32 2412 s = add s 1 2413 else 2414 ret scsay s stop 2415 end 2416 end 2417 ret false 2418 end 2419 if eq word 1 2420 s = add wordend 1 2421 for p ulong sub stop s 2422 at = add add wordend 1 p 2423 if eq get In at 32 2424 w = scword s sub at s 2425 if and ge w 21 le w 24 2426 put Sc 0 sub w 21 2427 end 2428 if and ge w 25 le w 27 2429 put Sc 1 sub w 25 2430 end 2431 s = add at 1 2432 end 2433 end 2434 w = scword s sub stop s 2435 if and ge w 21 le w 24 2436 put Sc 0 sub w 21 2437 end 2438 if and ge w 25 le w 27 2439 put Sc 1 sub w 25 2440 end 2441 ret true 2442 end 2443 if or lt word 3 gt word 10 2444 ret false 2445 end 2446 if ge get Sc 3 4 2447 put Sc 7 add get Sc 7 1 2448 ret false 2449 end 2450 put Sw 0 sub word 2 2451 colon = wordend 2452 while lt colon stop 2453 if eq get In colon 58 2454 put Sw 1 wordend 2455 put Sw 2 colon 2456 ret scthing add colon 1 stop 2457 end 2458 colon = add colon 1 2459 end 2460 ret false 2461 end 2462 fn scthing beg ulong stop ulong to bool 2463 n = scfields beg stop get Sw 0 2464 if eq n 0 2465 ret false 2466 end 2467 need = n 2468 for i ulong n 2469 need = add need get Flens i 2470 end 2471 if gt add get Sc 4 need 2304 2472 ret false 2473 end 2474 base = mul get Sc 3 16 2475 put Things base get Sw 0 2476 put Things add base 6 n 2477 s = get Sw 1 2478 for p ulong sub get Sw 2 s 2479 at = add get Sw 1 p 2480 if eq get In at 32 2481 w = scword s sub at s 2482 scmod w base 2483 s = add at 1 2484 end 2485 end 2486 w = scword s sub get Sw 2 s 2487 scmod w base 2488 for i ulong n 2489 put Things add add base 7 i scput i 2490 end 2491 put Sc 3 add get Sc 3 1 2492 ret true 2493 end 2494 fn scene to bool 2495 for i ulong 8 2496 put Sc i 0 2497 end 2498 for i ulong 64 2499 put Things i 0 2500 end 2501 put Sw 3 0 2502 n = get Inlen 0 2503 if gt n 2048 2504 n = 2048 2505 end 2506 s = ulong 0 2507 for p ulong n 2508 if eq get In p 10 2509 if gt p s 2510 if lt get Sc 5 12 2511 put Sc 5 add get Sc 5 1 2512 if not scln s p 2513 put Sc 6 add get Sc 6 1 2514 end 2515 else 2516 put Sc 7 add get Sc 7 1 2517 end 2518 end 2519 s = add p 1 2520 end 2521 end 2522 if and lt s n lt get Sc 5 12 2523 put Sc 5 add get Sc 5 1 2524 if not scln s n 2525 put Sc 6 add get Sc 6 1 2526 end 2527 end 2528 ret or ne get Sc 2 0 ne get Sc 3 0 2529 end 2530 note Handwritten Omega port of paint.h ck_add, ck_scale, ck_mix and paint.c ck_glow. 2531 note Bounded192x128 RAM canvas. This is rendering core, not full sky/font/device UI. 2532 global Frame uint 24576 2533 global G ulong 6 2534 global Fb uchar 73728 2535 fn channel c uint shift uint to uint 2536 ret and shr c shift 255 2537 end 2538 fn addcolor d uint c uint a uint to uint 2539 v = uint 0 2540 for i uint 3 2541 s = mul i 8 2542 n = add channel d s shr mul channel c s a 8 2543 if gt n 255 2544 n = 255 2545 end 2546 v = or v shl n s 2547 end 2548 ret v 2549 end 2550 fn scale c uint f uint to uint 2551 ret or and shr mul and c `16711935` f 8 `16711935` and shr mul and c 65280 f 8 65280 2552 end 2553 fn mix d uint c uint a uint to uint 2554 if ge a 256 2555 ret c 2556 end 2557 ret add scale d sub uint 256 a scale c a 2558 end 2559 fn distance x ulong y ulong to ulong 2560 dx = sub add mul long x 16 8 long get G 0 2561 dy = sub add mul long y 16 8 long get G 1 2562 ret ulong add mul dx dx mul dy dy 2563 end 2564 fn weight d2 ulong r2 ulong to ulong 2565 inv = div ulong `1099511627776` r2 2566 f = sub ulong 256 shr mul d2 inv 32 2567 w = shr mul shr mul f f 8 f 8 2568 ret shr mul w get G 4 8 2569 end 2570 fn glowpix x ulong y ulong to void 2571 d2 = distance x y 2572 r2 = mul get G 2 get G 2 2573 if ge d2 r2 2574 ret 2575 end 2576 a = uint weight d2 r2 2577 at = add mul y 192 x 2578 put Frame at addcolor get Frame at uint get G 3 a 2579 end 2580 fn glow cx ulong cy ulong radius ulong color ulong alpha ulong to bool 2581 if or eq radius 0 gt radius 8192 2582 ret false 2583 end 2584 if or gt cx 8192 gt cy 8192 2585 ret false 2586 end 2587 if or gt color `16777215` gt alpha 512 2588 ret false 2589 end 2590 put G 0 cx 2591 put G 1 cy 2592 put G 2 radius 2593 put G 3 color 2594 put G 4 alpha 2595 for y ulong 128 2596 for x ulong 192 2597 glowpix x y 2598 end 2599 end 2600 ret true 2601 end 2602 fn render to void 2603 for i ulong 24576 2604 put Frame i 0 2605 end 2606 note Frozen component pose; same halo and heart colors/weights as ck_mind_draw. 2607 b = glow 1536 1024 1088 `3951314` 68 2608 b = glow 1536 1024 640 `7363839` 46 2609 b = glow 1536 1024 400 `16765610` 89 2610 b = glow 1536 1024 160 `16772310` 218 2611 b = glow 1536 1024 50 `16775920` 230 2612 end 2613 fn frameout to bool 2614 for i ulong 24576 2615 c = get Frame i 2616 put Fb mul i 3 uchar channel c 16 2617 put Fb add mul i 3 1 uchar channel c 8 2618 put Fb add mul i 3 2 uchar channel c 0 2619 end 2620 n = ulong 0 2621 while lt n len Fb 2622 w = write 1 Fb n sub len Fb n 2623 if le w 0 2624 ret false 2625 end 2626 n = add n ulong w 2627 end 2628 ret true 2629 end 2630 note Native application binding: conversation state, courier lifecycle and reply/code. 2631 note A initialized, queued AGAIN bytes, per-call event, reserved. 2632 note Events:0 none,1 visible answer/ack,2 AGAIN queued,3 code give-up, 2633 note 4 refused LINE payload,5 slow notice,6 silence timeout. 2634 note Transport acceptance is separate from payload acceptance: appreceive true 2635 note means envelope accepted; inspect A2 for malformed payload, never invent text. 2636 global A ulong 4 2637 global Appjob uchar 4096 2638 global Appwire uchar 8192 2639 global Askin uchar 160 2640 fn appinit run ulong now ulong to bool 2641 if or ne get A 0 0 ne get R 0 0 2642 ret false 2643 end 2644 if ne get Q 0 0 2645 ret false 2646 end 2647 if not qstart run now 2648 ret false 2649 end 2650 constants 2651 put A 0 1 2652 put A 1 0 2653 put A 2 0 2654 ret true 2655 end 2656 fn appclock now ulong to bool 2657 if eq get A 0 0 2658 ret false 2659 end 2660 ret and ge now get T 0 ge now get R 4 2661 end 2662 fn appask now ulong to bool 2663 if not appclock now 2664 ret false 2665 end 2666 if or ne get R 1 0 ne get A 1 0 2667 ret false 2668 end 2669 if or ne get T 10 0 ne get T 13 0 2670 ret false 2671 end 2672 if and ne get T 5 0 eq get T 6 0 2673 ret false 2674 end 2675 if or ge get R 0 `4294967295` ge get Q 1 `4294967295` 2676 ret false 2677 end 2678 if not textok 2679 ret false 2680 end 2681 kind = classify 2682 if or lt kind 1 gt kind 3 2683 ret false 2684 end 2685 if and eq kind 3 eq get R 6 0 2686 ret false 2687 end 2688 note Validate restored context before jobbuild reads its variable-layout names. 2689 if not ctxmeta 6 2690 ret false 2691 end 2692 if not jobbuild kind add get R 0 1 2693 ret false 2694 end 2695 if not ctxappend 2696 ret false 2697 end 2698 n = get Inlen 0 2699 size = get Outlen 0 2700 for i ulong n 2701 put Askin i get In i 2702 end 2703 for i ulong size 2704 put Appjob i get Outb i 2705 end 2706 for i ulong size 2707 put In i get Appjob i 2708 end 2709 put Inlen 0 size 2710 queued = qsubmit now 2711 for i ulong n 2712 put In i get Askin i 2713 end 2714 put Inlen 0 n 2715 if not queued 2716 ret false 2717 end 2718 note start preconditions were checked before qsubmit; no concurrent calls permitted. 2719 if not start kind now 2720 qcancel 2721 ret false 2722 end 2723 put A 2 0 2724 if gt kind 1 2725 codebeg get R 0 2726 put A 2 1 2727 end 2728 ret true 2729 end 2730 fn appcancel to void 2731 cancel 2732 qcancel 2733 put A 1 0 2734 put A 2 0 2735 end 2736 fn appreset to void 2737 appcancel 2738 reset 2739 end 2740 note First acknowledge the triggering LINE, then submit AGAIN with a new wire 2741 note sequence while retaining the original conversation ID in its body. 2742 fn appqueue now ulong to bool 2743 if eq get A 1 0 2744 ret true 2745 end 2746 if or ne get T 10 0 ne get T 13 0 2747 ret true 2748 end 2749 put Inlen 0 get A 1 2750 for i ulong get A 1 2751 put In i get Appjob i 2752 end 2753 if not qsubmit now 2754 ret false 2755 end 2756 put A 1 0 2757 ret true 2758 end 2759 fn apppoll now ulong link bool to bool 2760 if not appclock now 2761 ret false 2762 end 2763 put A 2 0 2764 put T 0 now 2765 status = tick now 2766 if eq status 1 2767 put A 2 5 2768 end 2769 if eq status 2 2770 qcancel 2771 put A 1 0 2772 put A 2 6 2773 end 2774 if not appqueue now 2775 appcancel 2776 put A 2 3 2777 ret false 2778 end 2779 ret qnext now link 2780 end 2781 fn appsent now ulong ok bool to bool 2782 if not appclock now 2783 ret false 2784 end 2785 if not qsent now ok 2786 ret false 2787 end 2788 put A 2 0 2789 ret true 2790 end 2791 fn appbody now ulong to bool 2792 if eq get R 1 0 2793 put A 2 4 2794 ret true 2795 end 2796 if ineq 0 67 2797 if or le get R 2 1 ne get C 0 get R 0 2798 put A 2 4 2799 ret true 2800 end 2801 if codetake 2802 if heard get C 0 now 2803 ret true 2804 end 2805 end 2806 put A 2 4 2807 ret true 2808 end 2809 if or ineq 0 83 ineq 0 87 2810 status = saytake now 2811 if eq status 1 2812 if eq get R 1 0 2813 put A 1 0 2814 end 2815 if ne get S 1 0 2816 put A 2 1 2817 end 2818 ret true 2819 end 2820 if eq status 2 2821 n = get Outlen 0 2822 if or eq n 0 gt n 4096 2823 cancel 2824 put A 1 0 2825 put A 2 3 2826 ret true 2827 end 2828 for i ulong n 2829 put Appjob i get Outb i 2830 end 2831 put A 1 n 2832 put A 2 2 2833 ret true 2834 end 2835 if eq status 3 2836 put A 1 0 2837 put A 2 3 2838 ret true 2839 end 2840 end 2841 put A 2 4 2842 ret true 2843 end 2844 note Reply parsing can serialize AGAIN internally. Preserve the already offered 2845 note datagram until the provider records its send result, including on refusal. 2846 fn appreceive now ulong to bool 2847 if not appclock now 2848 ret false 2849 end 2850 result = qincoming now 2851 if eq result 0 2852 ret false 2853 end 2854 put A 2 0 2855 if not qtake 2856 ret true 2857 end 2858 n = get Outlen 0 2859 e = get Err 0 2860 for i ulong n 2861 put Appwire i get Outb i 2862 end 2863 ok = appbody now 2864 for i ulong n 2865 put Outb i get Appwire i 2866 end 2867 put Outlen 0 n 2868 put Err 0 e 2869 ret ok 2870 end 2871 note Bounded model scene input. Existing scene stays the strict canonical parser. 2872 note Nm thinking,normalized bytes,tidying count,hidden lines,line bytes,mood seen, 2873 note invalid/overflow,plain candidate bytes,canonical line count. Input restored. 2874 global Nm ulong 9 2875 global Nraw uchar 2048 2876 global Nline uchar 2048 2877 global Nnorm uchar 2048 2878 global Nplain uchar 160 2879 text Ntags "" 2880 fn nlow c uchar to uchar 2881 if and ge c 65 le c 90 2882 ret add sub c 65 97 2883 end 2884 ret c 2885 end 2886 fn nalpha c uchar to bool 2887 v = nlow c 2888 ret and ge v 97 le v 122 2889 end 2890 fn nmatch at ulong off ulong size ulong to bool 2891 if gt add at size get Nm 4 2892 ret false 2893 end 2894 for i ulong size 2895 if ne nlow get Nline add at i get Ntags add off i 2896 ret false 2897 end 2898 end 2899 ret true 2900 end 2901 fn nemit c uchar to void 2902 n = get Nm 1 2903 if ge n 2048 2904 put Nm 6 1 2905 ret 2906 end 2907 put Nnorm n c 2908 put Nm 1 add n 1 2909 end 2910 fn nmark c uchar to bool 2911 if or eq c 45 eq c 42 2912 ret true 2913 end 2914 if or eq c 35 eq c 62 2915 ret true 2916 end 2917 ret eq c 34 2918 end 2919 fn nlead c uchar to bool 2920 if or eq c 32 eq c 42 2921 ret true 2922 end 2923 if eq c 35 2924 ret true 2925 end 2926 ret nalpha c 2927 end 2928 fn ndigits p ulong to ulong 2929 while lt p get Nm 4 2930 if not isdigit get Nline p 2931 ret p 2932 end 2933 p = add p 1 2934 end 2935 ret p 2936 end 2937 fn nspaces p ulong to ulong 2938 while lt p get Nm 4 2939 if ne get Nline p 32 2940 ret p 2941 end 2942 p = add p 1 2943 end 2944 ret p 2945 end 2946 fn npstep s ulong to ulong 2947 n = get Nm 4 2948 c = get Nline s 2949 if nmark c 2950 if eq add s 1 n 2951 ret n 2952 end 2953 if nlead get Nline add s 1 2954 ret add s 1 2955 end 2956 ret s 2957 end 2958 if not isdigit c 2959 ret s 2960 end 2961 p = ndigits s 2962 if ge add p 1 n 2963 ret s 2964 end 2965 if not or eq get Nline p 46 eq get Nline p 41 2966 ret s 2967 end 2968 if ne get Nline add p 1 32 2969 ret s 2970 end 2971 ret add p 2 2972 end 2973 fn nprefix to ulong 2974 s = ulong 0 2975 while lt s get Nm 4 2976 next = npstep s 2977 if eq next s 2978 ret s 2979 end 2980 put Nm 2 add get Nm 2 1 2981 s = nspaces next 2982 end 2983 ret s 2984 end 2985 fn nfinish to void 2986 n = get Nm 4 2987 while gt n 0 2988 if eq get Nline sub n 1 32 2989 n = sub n 1 2990 else 2991 nprocess n 2992 ret 2993 end 2994 end 2995 end 2996 fn nprocess n ulong to void 2997 put Nm 4 n 2998 hide = ne get Nm 0 0 2999 for i ulong n 3000 if nmatch i 0 7 3001 put Nm 0 1 3002 hide = true 3003 end 3004 if nmatch i 7 8 3005 put Nm 0 0 3006 hide = true 3007 end 3008 end 3009 if hide 3010 put Nm 3 add get Nm 3 1 3011 ret 3012 end 3013 if ge n 3 3014 if and eq get Nline 0 96 eq get Nline 1 96 3015 if eq get Nline 2 96 3016 put Nm 2 add get Nm 2 1 3017 ret 3018 end 3019 end 3020 end 3021 s = nprefix 3022 if ge s n 3023 ret 3024 end 3025 w = s 3026 while lt w n 3027 if nalpha get Nline w 3028 w = add w 1 3029 else 3030 nword s w n 3031 ret 3032 end 3033 end 3034 nword s w n 3035 end 3036 fn nword s ulong w ulong n ulong to void 3037 for i ulong sub w s 3038 put In add s i nlow get Nline add s i 3039 end 3040 word = scword s sub w s 3041 if gt word 10 3042 word = 0 3043 end 3044 r = w 3045 while lt r n 3046 c = get Nline r 3047 if or eq c 42 eq c 34 3048 r = add r 1 3049 put Nm 2 add get Nm 2 1 3050 else 3051 nappend s w r n word 3052 ret 3053 end 3054 end 3055 nappend s w r n word 3056 end 3057 fn nappend s ulong w ulong r ulong n ulong word ulong to void 3058 if lt r n 3059 if not or eq get Nline r 32 eq get Nline r 58 3060 word = 0 3061 end 3062 end 3063 if eq word 0 3064 size = sub n s 3065 if and eq get Nm 7 0 le size 159 3066 if lt get Nm 8 12 3067 for i ulong size 3068 put Nplain i get Nline add s i 3069 end 3070 put Nm 7 size 3071 end 3072 end 3073 for i ulong size 3074 nemit get Nline add s i 3075 end 3076 else 3077 if eq word 1 3078 if lt get Nm 8 12 3079 put Nm 5 1 3080 end 3081 end 3082 for i ulong sub w s 3083 nemit nlow get Nline add s i 3084 end 3085 head = ne word 2 3086 for i ulong sub n r 3087 c = get Nline add r i 3088 if eq c 58 3089 if ne word 1 3090 head = false 3091 end 3092 end 3093 if head 3094 c = nlow c 3095 end 3096 nemit c 3097 end 3098 end 3099 nemit 10 3100 put Nm 8 add get Nm 8 1 3101 end 3102 fn nclear to void 3103 for i ulong 8 3104 put Sc i 0 3105 end 3106 for i ulong 64 3107 put Things i 0 3108 end 3109 put Sw 3 0 3110 end 3111 fn scdecode to bool 3112 for i ulong 9 3113 put Nm i 0 3114 end 3115 nclear 3116 n = get Inlen 0 3117 if gt n 2048 3118 put Nm 6 1 3119 ret false 3120 end 3121 for i ulong n 3122 if eq get In i 0 3123 put Nm 6 1 3124 ret false 3125 end 3126 put Nraw i get In i 3127 end 3128 for i ulong n 3129 c = get Nraw i 3130 if eq c 10 3131 nfinish 3132 put Nm 4 0 3133 else 3134 if eq c 9 3135 c = uchar 32 3136 put Nm 2 add get Nm 2 1 3137 end 3138 if and ge c 32 le c 126 3139 p = get Nm 4 3140 keep = true 3141 if eq c 32 3142 if eq p 0 3143 keep = false 3144 else 3145 if eq get Nline sub p 1 32 3146 keep = false 3147 end 3148 end 3149 end 3150 if keep 3151 put Nline p c 3152 put Nm 4 add p 1 3153 else 3154 put Nm 2 add get Nm 2 1 3155 end 3156 else 3157 put Nm 2 add get Nm 2 1 3158 end 3159 end 3160 end 3161 nfinish 3162 ok = false 3163 if eq get Nm 6 0 3164 for i ulong get Nm 1 3165 put In i get Nnorm i 3166 end 3167 put Inlen 0 get Nm 1 3168 ok = scene 3169 if ne get Nm 5 0 3170 ok = true 3171 end 3172 if not ok 3173 if gt get Nm 7 0 3174 for i ulong get Nm 7 3175 put In i get Nplain i 3176 end 3177 put Inlen 0 get Nm 7 3178 ok = scsay 0 get Nm 7 3179 end 3180 end 3181 else 3182 nclear 3183 end 3184 for i ulong n 3185 put In i get Nraw i 3186 end 3187 put Inlen 0 n 3188 ret ok 3189 end 3190 note Restored note catalog and bounded model-job context. No storage provider. 3191 note Cx declared count,visited count,ready,damaged,loading. Damaged notes stay gone. 3192 global Cx ulong 5 3193 global Ctxtext uchar 65536 3194 global Ctxlen ulong 512 3195 global Ctxgone uchar 512 3196 global Ctxseen uchar 512 3197 global Ctxstart ulong 512 3198 global Meta uchar 4096 3199 global Mx ulong 2 3200 global Mdigits uchar 20 3201 text Mtself "\tself=" 3202 text Mtname "\tname=" 3203 text Mtstart "\tstarts=" 3204 text Mtfact "\tfact " 3205 text Mtis " is " 3206 text Mtare " are " 3207 text Mtnote "\tnote " 3208 fn ctxidle to bool 3209 if ne get R 1 0 3210 ret false 3211 end 3212 ret and eq get Tx 0 0 eq get Nt 0 0 3213 end 3214 fn ctxbegin to bool 3215 if not ctxidle 3216 ret false 3217 end 3218 n = mem32 36 3219 if gt n 512 3220 ret false 3221 end 3222 for i ulong 512 3223 put Ctxlen i 0 3224 put Ctxgone i 1 3225 put Ctxseen i 0 3226 put Ctxstart i 0 3227 end 3228 put Cx 0 n 3229 put Cx 1 0 3230 put Cx 2 0 3231 put Cx 3 0 3232 put Cx 4 1 3233 if eq n 0 3234 put Cx 2 1 3235 put Cx 4 0 3236 end 3237 ret true 3238 end 3239 note Returns0 refused without visit,1 valid record retained,2 damaged visit retained. 3240 fn ctxtake index ulong to ulong 3241 if not ctxidle 3242 ret 0 3243 end 3244 if or eq get Cx 4 0 ge index get Cx 0 3245 ret 0 3246 end 3247 if ne get Ctxseen index 0 3248 ret 0 3249 end 3250 status = ulong 2 3251 if notedec index 3252 n = get Ns 0 3253 for i ulong n 3254 put Ctxtext add mul index 128 i get Note i 3255 end 3256 put Ctxlen index n 3257 put Ctxgone index uchar get Ns 3 3258 put Ctxstart index get Ns 2 3259 status = 1 3260 else 3261 put Cx 3 add get Cx 3 1 3262 end 3263 put Ctxseen index 1 3264 put Cx 1 add get Cx 1 1 3265 if eq get Cx 1 get Cx 0 3266 put Cx 2 1 3267 put Cx 4 0 3268 end 3269 ret status 3270 end 3271 fn mtemit c uchar to void 3272 if ne get Mx 1 0 3273 ret 3274 end 3275 n = get Mx 0 3276 if ge n 4096 3277 put Mx 1 1 3278 ret 3279 end 3280 put Meta n c 3281 put Mx 0 add n 1 3282 end 3283 fn mtnum v ulong to void 3284 n = ulong 0 3285 while gt v 9 3286 put Mdigits n uchar rem v 10 3287 v = div v 10 3288 n = add n 1 3289 end 3290 put Mdigits n uchar v 3291 n = add n 1 3292 for i ulong n 3293 mtemit add uchar 48 get Mdigits sub sub n 1 i 3294 end 3295 end 3296 note Memory fields are length-bounded; require a terminator and printable bytes. 3297 fn mtfield off ulong cap ulong to bool 3298 for i ulong cap 3299 c = get Mem add off i 3300 if eq c 0 3301 if eq i 0 3302 put Mx 1 1 3303 ret false 3304 end 3305 ret true 3306 end 3307 if or lt c 32 gt c 126 3308 put Mx 1 1 3309 ret false 3310 end 3311 mtemit c 3312 end 3313 put Mx 1 1 3314 ret false 3315 end 3316 fn mtfacts count ulong to bool 3317 for k ulong count 3318 off = add 40 mul k 113 3319 for i ulong len Mtfact 3320 mtemit get Mtfact i 3321 end 3322 if not mtfield off 48 3323 ret false 3324 end 3325 are = get Mem add off 112 3326 if gt are 1 3327 put Mx 1 1 3328 ret false 3329 end 3330 if eq are 1 3331 for i ulong len Mtare 3332 mtemit get Mtare i 3333 end 3334 else 3335 for i ulong len Mtis 3336 mtemit get Mtis i 3337 end 3338 end 3339 if not mtfield add off 48 64 3340 ret false 3341 end 3342 end 3343 ret eq get Mx 1 0 3344 end 3345 fn mtnotes count ulong limit ulong to void 3346 given = ulong 0 3347 for k ulong count 3348 index = sub sub count 1 k 3349 if and eq get Ctxgone index 0 lt given limit 3350 for i ulong len Mtnote 3351 mtemit get Mtnote i 3352 end 3353 for i ulong get Ctxlen index 3354 mtemit get Ctxtext add mul index 128 i 3355 end 3356 given = add given 1 3357 end 3358 end 3359 end 3360 fn ctxmeta limit ulong to bool 3361 put Mx 0 0 3362 put Mx 1 1 3363 facts = mem32 32 3364 notes = mem32 36 3365 if or gt facts 32 gt notes 512 3366 ret false 3367 end 3368 if gt limit 512 3369 ret false 3370 end 3371 if gt notes 0 3372 if or eq get Cx 2 0 ne get Cx 0 notes 3373 ret false 3374 end 3375 end 3376 put Mx 1 0 3377 for i ulong len Mtself 3378 mtemit get Mtself i 3379 end 3380 off = add 40 mul facts 113 3381 if eq get Mem off 0 3382 for i ulong len Allen 3383 mtemit get Allen i 3384 end 3385 else 3386 if not mtfield off 24 3387 ret false 3388 end 3389 end 3390 if ne get Mem 8 0 3391 for i ulong len Mtname 3392 mtemit get Mtname i 3393 end 3394 if not mtfield 8 24 3395 ret false 3396 end 3397 end 3398 for i ulong len Mtstart 3399 mtemit get Mtstart i 3400 end 3401 mtnum mem32 0 3402 if not mtfacts facts 3403 ret false 3404 end 3405 mtnotes notes limit 3406 ret eq get Mx 1 0 3407 end 3408 note Publish all metadata or none; preserve outgoing bytes/length/error on refusal. 3409 fn ctxappend to bool 3410 if or ne get Mx 1 0 ne get Err 0 0 3411 ret false 3412 end 3413 n = get Outlen 0 3414 size = get Mx 0 3415 if or gt n 4096 gt size 4096 3416 ret false 3417 end 3418 if gt add n size 4096 3419 ret false 3420 end 3421 for i ulong size 3422 put Outb add n i get Meta i 3423 end 3424 put Outlen 0 add n size 3425 ret true 3426 end 3427 note Stable application presentation; see PRESENTATION.md for scope and ownership. 3428 global Ds ulong 8 3429 global Dt ulong 64 3430 global Dtext uchar 2304 3431 global Dsay ulong 1 3432 global Dm ulong 3 3433 global Dcode uchar 32768 3434 global Dstart ulong 4096 3435 global Dlen ulong 4096 3436 global Dline ulong 4096 3437 global Dview ulong 3 3438 global Din uchar 8192 3439 fn dscene to bool 3440 n = get Inlen 0 3441 for i ulong 8192 3442 put Din i get In i 3443 end 3444 for i ulong get R 8 3445 put In i get Answer i 3446 end 3447 put Inlen 0 get R 8 3448 ok = scdecode 3449 for i ulong 8192 3450 put In i get Din i 3451 end 3452 put Inlen 0 n 3453 if not ok 3454 ret false 3455 end 3456 for i ulong 8 3457 put Ds i get Sc i 3458 end 3459 for i ulong 64 3460 put Dt i get Things i 3461 end 3462 for i ulong 2304 3463 put Dtext i 0 3464 end 3465 for i ulong get Sc 4 3466 put Dtext i get Stext i 3467 end 3468 put Dsay 0 get Sw 3 3469 put Dm 0 1 3470 ret true 3471 end 3472 fn dcode to bool 3473 if or le get R 2 1 ne get R 1 0 3474 ret false 3475 end 3476 if or eq get R 6 0 ne get C 0 get R 0 3477 ret false 3478 end 3479 if not rows 80 4096 3480 ret false 3481 end 3482 for i ulong 32768 3483 put Dcode i 0 3484 end 3485 for i ulong get C 2 3486 put Dcode i get Code i 3487 end 3488 for i ulong 4096 3489 put Dstart i 0 3490 put Dlen i 0 3491 put Dline i 0 3492 end 3493 for i ulong get View 0 3494 put Dstart i get Rowst i 3495 put Dlen i get Rowlen i 3496 put Dline i get Rowline i 3497 end 3498 put Dview 0 get View 0 3499 put Dview 1 0 3500 put Dview 2 get C 2 3501 put Dm 1 1 3502 ret true 3503 end 3504 fn dpresent to bool 3505 if or eq get A 0 0 ne get A 2 1 3506 ret false 3507 end 3508 if or gt get R 8 159 gt get Inlen 0 8192 3509 ret false 3510 end 3511 shown = dscene 3512 coded = dcode 3513 if or shown coded 3514 put Dm 2 get R 0 3515 ret true 3516 end 3517 ret false 3518 end 3519 fn dask now ulong to bool 3520 if not appask now 3521 ret false 3522 end 3523 b = dpresent 3524 ret true 3525 end 3526 fn drecv now ulong to bool 3527 if not appreceive now 3528 ret false 3529 end 3530 b = dpresent 3531 ret true 3532 end 3533 fn dreset to void 3534 appreset 3535 for i ulong 8 3536 put Ds i 0 3537 end 3538 for i ulong 64 3539 put Dt i 0 3540 end 3541 for i ulong 2304 3542 put Dtext i 0 3543 end 3544 put Dsay 0 0 3545 for i ulong 3 3546 put Dm i 0 3547 put Dview i 0 3548 end 3549 for i ulong 32768 3550 put Dcode i 0 3551 end 3552 for i ulong 4096 3553 put Dstart i 0 3554 put Dlen i 0 3555 put Dline i 0 3556 end 3557 for i ulong 8192 3558 put Din i 0 3559 end 3560 end 3561 note Host provider stream core. PROVIDER.md is the framing/state contract. 3562 global Ph uchar 40 3563 global Pb uchar 4096 3564 global Pv ulong 4 3565 global Pc ulong 2 3566 global Pe ulong 2 3567 global Pout uchar 65536 3568 global Pn ulong 1 3569 text Prmagic "ALNPRV01" 3570 fn prshape to bool 3571 op = get Pv 0 3572 now = get Pv 1 3573 arg = get Pv 2 3574 n = get Pv 3 3575 if eq op 1 3576 ret and gt arg 0 eq n 0 3577 end 3578 if eq op 2 3579 if ne arg 0 3580 ret false 3581 end 3582 ret and gt n 0 le n 159 3583 end 3584 if or eq op 3 eq op 4 3585 ret and le arg 1 eq n 0 3586 end 3587 if eq op 5 3588 if ne arg 0 3589 ret false 3590 end 3591 ret and ge n 65 le n 1200 3592 end 3593 if ne now 0 3594 ret false 3595 end 3596 if or eq op 6 eq op 7 3597 ret and eq arg 0 eq n 0 3598 end 3599 if eq op 8 3600 ret and le arg 1 eq n 4096 3601 end 3602 if eq op 9 3603 ret and le arg 511 eq n 4096 3604 end 3605 if eq op 10 3606 ret and eq arg 0 eq n 0 3607 end 3608 ret false 3609 end 3610 fn prparse to bool 3611 for i ulong 8 3612 if ne get Ph i get Prmagic i 3613 ret false 3614 end 3615 end 3616 for k ulong 4 3617 v = ulong 0 3618 for i ulong 8 3619 off = add add 8 mul k 8 i 3620 v = or v shl ulong get Ph off mul i 8 3621 end 3622 put Pv k v 3623 end 3624 ret prshape 3625 end 3626 fn prbyte c uchar to void 3627 put Pout get Pn 0 c 3628 put Pn 0 add get Pn 0 1 3629 end 3630 fn prword v ulong to void 3631 for i ulong 8 3632 prbyte uchar and shr v mul i 8 255 3633 end 3634 end 3635 fn prhead op ulong status ulong event ulong size ulong to void 3636 for i ulong 8 3637 prbyte get Prmagic i 3638 end 3639 prword op 3640 prword status 3641 prword event 3642 prword size 3643 end 3644 fn prreply status ulong to void 3645 put Pn 0 0 3646 kind = get Pe 1 3647 size = ulong 0 3648 if eq kind 1 3649 size = get Outlen 0 3650 end 3651 if eq kind 2 3652 size = get R 8 3653 end 3654 prhead get Pv 0 status get Pe 0 size 3655 for i ulong size 3656 if eq kind 1 3657 prbyte get Outb i 3658 else 3659 prbyte get Answer i 3660 end 3661 end 3662 if eq kind 2 3663 if and gt get R 2 1 eq get R 1 0 3664 if and ne get R 6 0 eq codestat 2 3665 prhead 11 1 1 get C 2 3666 for i ulong get C 2 3667 prbyte get Code i 3668 end 3669 end 3670 end 3671 end 3672 end 3673 fn prevent to void 3674 put Pe 0 get A 2 3675 if eq get A 2 1 3676 put Pe 1 2 3677 end 3678 end 3679 fn prload to ulong 3680 if or ne get A 0 0 not ctxidle 3681 ret 0 3682 end 3683 constants 3684 for i ulong 3692 3685 put Mem i 0 3686 end 3687 loadbeg 3688 b = ctxbegin 3689 put Pc 0 1 3690 put Pc 1 0 3691 ret 1 3692 end 3693 fn prcopy to ulong 3694 if or ne get A 0 0 ne get Pc 0 1 3695 ret 0 3696 end 3697 if not ctxidle 3698 ret 0 3699 end 3700 slot = get Pv 2 3701 bit = shl ulong 1 slot 3702 if ne and get Pc 1 bit 0 3703 ret 0 3704 end 3705 for i ulong 4096 3706 put Unit i get Pb i 3707 end 3708 status = ulong 2 3709 if loadcopy slot 3710 status = 1 3711 end 3712 put Pc 1 or get Pc 1 bit 3713 if eq get Pc 1 3 3714 if not ctxbegin 3715 ret 0 3716 end 3717 put Pc 0 2 3718 if ne get Cx 2 0 3719 put Pc 0 3 3720 end 3721 end 3722 ret status 3723 end 3724 fn prnote to ulong 3725 if or ne get A 0 0 ne get Pc 0 2 3726 ret 0 3727 end 3728 if not ctxidle 3729 ret 0 3730 end 3731 for i ulong 4096 3732 put Unit i get Pb i 3733 end 3734 status = ctxtake get Pv 2 3735 if ne get Cx 2 0 3736 put Pc 0 3 3737 end 3738 ret status 3739 end 3740 fn prapply to ulong 3741 op = get Pv 0 3742 now = get Pv 1 3743 arg = get Pv 2 3744 if eq op 10 3745 ret prload 3746 end 3747 if eq op 8 3748 ret prcopy 3749 end 3750 if eq op 9 3751 ret prnote 3752 end 3753 if eq op 1 3754 if or eq get Pc 0 1 eq get Pc 0 2 3755 ret 0 3756 end 3757 if appinit arg now 3758 ret 1 3759 end 3760 ret 0 3761 end 3762 if eq get A 0 0 3763 ret 0 3764 end 3765 if eq op 6 3766 appcancel 3767 ret 1 3768 end 3769 if eq op 7 3770 dreset 3771 ret 1 3772 end 3773 if not appclock now 3774 ret 0 3775 end 3776 if eq op 3 3777 offer = apppoll now ne arg 0 3778 prevent 3779 if offer 3780 put Pe 1 1 3781 ret 3 3782 end 3783 ret 1 3784 end 3785 if eq op 4 3786 if appsent now ne arg 0 3787 ret 1 3788 end 3789 ret 0 3790 end 3791 for i ulong get Pv 3 3792 put In i get Pb i 3793 end 3794 put Inlen 0 get Pv 3 3795 if eq op 2 3796 if not dask now 3797 ret 0 3798 end 3799 else 3800 if not drecv now 3801 ret 0 3802 end 3803 end 3804 prevent 3805 ret 1 3806 end 3807 fn prdo to bool 3808 if not prparse 3809 ret false 3810 end 3811 put Pe 0 0 3812 put Pe 1 0 3813 status = prapply 3814 prreply status 3815 ret true 3816 end 3817 note Declarative Allen glyph designs and integer sine samples, retained from 3818 note native/kernel/ui/allen_font.c at4c7888f. No foreign executable implementation. 3819 text Afdata "w6|w6 M3,0 L3,14 D3,20|w10 M3,0 L3,5 M7,0 L7,5|w15 M6,2 L4,20 M11,2 L9,20 M2,8 L13,8 M1,14 L12,14|w15 A8,5,5,5,-30,-270 A8,15,5,5,270,510 M8,-2 L8,22|w16 A4,4,2,3,0,360 A12,16,2,3,0,360 M13,1 L3,19|w16 M14,20 L5,9 A7,5,3,4,150,400 L3,14 A7,15,4,5,180,60 L13,11|w6 M3,0 L3,5|w9 A10,10,6,12,240,120|w9 A-1,10,6,12,-60,60|w14 M7,2 L7,10 M3,4 L11,8 M11,4 L3,8|w14 M2,12 L12,12 M7,7 L7,17|w6 M3,19 L2,23|w11 M2,13 L9,13|w6 D3,20|w12 M10,0 L2,20|w14 A7,10,5,10,0,360|w14 M3,4 L8,0 L8,20|w14 A7,6,5,6,200,400 L2,20 L12,20|w14 A7,5,5,5,200,450 A7,15,5,5,270,520|w14 M10,20 L10,0 L1,14 L13,14|w14 M12,0 L4,0 L4,9 A7,14,5,6,235,520|w14 A7,14,5,6,0,360 M10,0 L3,11|w14 M2,0 L12,0 L5,20|w14 A7,5,4,5,0,360 A7,15,5,5,0,360|w14 A7,6,5,6,0,360 M4,20 L11,9|w6 D3,8 D3,20|w6 D3,8 M3,19 L2,23|w14 M12,6 L2,12 L12,18|w14 M2,10 L12,10 M2,15 L12,15|w14 M2,6 L12,12 L2,18|w14 A7,5,5,5,190,450 L7,14 D7,20|w19 A9,12,3,4,0,360 M12,8 L12,14 A14,14,2,2,180,0 A9,11,7,9,0,-300|w16 M2,20 L8,0 L14,20 M4,13 L12,13|w15 M2,0 L2,20 M2,0 L8,0 A8,5,4,5,270,450 L2,10 M2,10 L9,10 A9,15,4,5,270,450 L2,20|w17 A9,10,7,10,45,315|w16 M2,0 L2,20 M2,0 L6,0 A6,10,8,10,270,450 L2,20|w14 M12,0 L2,0 L2,20 L12,20 M2,10 L10,10|w13 M12,0 L2,0 L2,20 M2,10 L10,10|w18 A9,10,7,10,-45,-360 M11,10 L16,10|w16 M2,0 L2,20 M14,0 L14,20 M2,10 L14,10|w6 M3,0 L3,20|w13 M10,0 L10,14 A6,14,4,6,0,180|w15 M2,0 L2,20 M13,0 L2,12 M6,8 L14,20|w13 M2,0 L2,20 L12,20|w20 M2,20 L2,0 L10,14 L18,0 L18,20|w16 M2,20 L2,0 L14,20 L14,0|w20 A10,10,8,10,0,360|w15 M2,20 L2,0 L8,0 A8,5,5,5,270,450 L2,10|w20 A10,10,8,10,0,360 M12,14 L18,21|w15 M2,20 L2,0 L8,0 A8,5,5,5,270,450 L2,10 M8,10 L14,20|w16 A8,5,5,5,-30,-270 A8,15,5,5,270,510|w16 M1,0 L15,0 M8,0 L8,20|w16 M2,0 L2,13 A8,13,6,7,180,0 L14,0|w16 M1,0 L8,20 L15,0|w22 M1,0 L6,20 L11,0 L16,20 L21,0|w16 M2,0 L14,20 M14,0 L2,20|w16 M1,0 L8,10 L15,0 M8,10 L8,20|w16 M2,0 L14,0 L2,20 L14,20|w9 M7,-1 L3,-1 L3,21 L7,21|w12 M2,0 L10,20|w9 M2,-1 L6,-1 L6,21 L2,21|w12 M2,8 L6,1 L10,8|w14 M1,23 L13,23|w7 M2,0 L4,4|w15 A7,14,5,6,0,360 M12,8 L12,20|w15 M2,0 L2,20 A7,14,5,6,0,360|w13 A7,14,5,6,40,320|w15 A7,14,5,6,0,360 M12,0 L12,20|w14 M2,14 L12,14 A7,14,5,6,0,-320|w11 M5,20 L5,4 A9,4,4,4,180,300 M2,8 L10,8|w15 A7,14,5,6,0,360 M12,8 L12,22 A7,22,5,5,0,150|w15 M2,0 L2,20 A7,13,5,5,180,360 L12,20|w6 M3,8 L3,20 D3,3|w7 M4,8 L4,22 A0,22,4,5,0,120 D4,3|w13 M2,0 L2,20 M11,8 L2,15 M5,13 L12,20|w6 M3,0 L3,20|w21 M2,8 L2,20 A6,12,4,4,180,360 L10,20 A14,12,4,4,180,360 L18,20|w15 M2,8 L2,20 A7,13,5,5,180,360 L12,20|w14 A7,14,5,6,0,360|w15 M2,8 L2,27 A7,14,5,6,0,360|w15 A7,14,5,6,0,360 M12,8 L12,27|w10 M2,8 L2,20 A7,13,5,5,180,290|w14 A7,11,4,3,-30,-270 A7,17,4,3,270,510|w11 M5,2 L5,17 A8,17,3,3,180,40 M2,8 L10,8|w15 M2,8 L2,15 A7,15,5,5,180,0 M12,8 L12,20|w14 M2,8 L7,20 L12,8|w20 M2,8 L6,20 L10,8 L14,20 L18,8|w14 M2,8 L12,20 M12,8 L2,20|w14 M2,8 L7,20 M12,8 L4,27|w14 M2,8 L12,8 L2,20 L12,20|w10 M8,-1 L6,0 L6,8 L4,10 L6,12 L6,20 L8,21|w6 M3,-1 L3,23|w10 M2,-1 L4,0 L4,8 L6,10 L4,12 L4,20 L2,21|w14 M2,13 L5,11 L9,14 L12,12|" 3820 text Afsines "0 286 572 857 1143 1428 1713 1997 2280 2563 2845 3126 3406 3686 3964 4240 4516 4790 5063 5334 5604 5872 6138 6402 6664 6924 7182 7438 7692 7943 8192 8438 8682 8923 9162 9397 9630 9860 10087 10311 10531 10749 10963 11174 11381 11585 11786 11982 12176 12365 12551 12733 12911 13085 13255 13421 13583 13741 13894 14044 14189 14330 14466 14598 14726 14849 14968 15082 15191 15296 15396 15491 15582 15668 15749 15826 15897 15964 16026 16083 16135 16182 16225 16262 16294 16322 16344 16362 16374 16382 16384 " 3821 note Handwritten bounded Allen stroke rasterizer. Legacy C is an external oracle only. 3822 global Af ulong 6 3823 global Ab long 4 3824 global Ag long 640 3825 global Alpha uchar 65536 3826 global Asin long 91 3827 global Afpos ulong 2 3828 global Apen long 2 3829 global Arc long 6 3830 fn afsqrt value ulong to ulong 3831 r = ulong 0 3832 bit = shl ulong 1 62 3833 while gt bit value 3834 bit = shr bit 2 3835 end 3836 while ne bit 0 3837 if ge value add r bit 3838 value = sub value add r bit 3839 r = add shr r 1 bit 3840 else 3841 r = shr r 1 3842 end 3843 bit = shr bit 2 3844 end 3845 ret r 3846 end 3847 fn afsin deg long to long 3848 a = rem deg 360 3849 if lt a 0 3850 a = add a 360 3851 end 3852 if le a 90 3853 ret get Asin ulong a 3854 end 3855 if le a 180 3856 ret get Asin ulong sub long 180 a 3857 end 3858 if le a 270 3859 ret neg get Asin ulong sub a 180 3860 end 3861 ret neg get Asin ulong sub long 360 a 3862 end 3863 fn afcos deg long to long 3864 ret afsin add rem deg 360 90 3865 end 3866 fn afinit cap ulong wt ulong to bool 3867 if or eq cap 0 gt cap 64 3868 ret false 3869 end 3870 if or eq wt 0 gt wt 2500 3871 ret false 3872 end 3873 for i ulong 6 3874 put Af i 0 3875 end 3876 put Af 0 div mul cap 256 20 3877 put Af 1 div mul wt get Af 0 1000 3878 v = long 0 3879 slot = ulong 0 3880 for i ulong len Afsines 3881 c = get Afsines i 3882 if eq c 32 3883 put Asin slot v 3884 slot = add slot 1 3885 v = 0 3886 else 3887 v = add mul v 10 sub long c 48 3888 end 3889 end 3890 ret eq slot 91 3891 end 3892 fn afpick c uchar to bool 3893 if or lt c 32 gt c 126 3894 c = 63 3895 end 3896 wanted = sub ulong c 32 3897 slot = ulong 0 3898 startat = ulong 0 3899 for i ulong len Afdata 3900 if eq get Afdata i 124 3901 if eq slot wanted 3902 put Afpos 0 startat 3903 put Afpos 1 i 3904 ret true 3905 end 3906 slot = add slot 1 3907 startat = add i 1 3908 end 3909 end 3910 ret false 3911 end 3912 fn afnum to long 3913 p = get Afpos 0 3914 minus = false 3915 if eq get Afdata p 45 3916 minus = true 3917 p = add p 1 3918 end 3919 v = long 0 3920 go = true 3921 while and lt p get Afpos 1 go 3922 c = get Afdata p 3923 if and ge c 48 le c 57 3924 v = add mul v 10 sub long c 48 3925 p = add p 1 3926 else 3927 go = false 3928 end 3929 end 3930 if lt p get Afpos 1 3931 if eq get Afdata p 44 3932 p = add p 1 3933 end 3934 end 3935 put Afpos 0 p 3936 if minus 3937 ret neg v 3938 end 3939 ret v 3940 end 3941 fn afseg nx long ny long to bool 3942 n = get Af 2 3943 if ge n 160 3944 ret false 3945 end 3946 at = mul n 4 3947 put Ag at get Apen 0 3948 put Ag add at 1 get Apen 1 3949 put Ag add at 2 nx 3950 put Ag add at 3 ny 3951 put Apen 0 nx 3952 put Apen 1 ny 3953 put Af 2 add n 1 3954 ret true 3955 end 3956 fn afpoint a long first bool to bool 3957 s = long get Af 0 3958 x = mul get Arc 0 s 3959 x = add x div mul mul get Arc 2 s afcos a 16384 3960 y = mul sub get Arc 1 20 s 3961 y = add y div mul mul get Arc 3 s afsin a 16384 3962 if first 3963 put Apen 0 x 3964 put Apen 1 y 3965 ret true 3966 end 3967 ret afseg x y 3968 end 3969 fn afarc to bool 3970 for i ulong 6 3971 put Arc i afnum 3972 end 3973 span = sub get Arc 5 get Arc 4 3974 if lt span 0 3975 span = neg span 3976 end 3977 steps = div span 9 3978 if lt steps 2 3979 steps = 2 3980 end 3981 for k ulong ulong add steps 1 3982 a = sub get Arc 5 get Arc 4 3983 a = add get Arc 4 div mul a long k steps 3984 if not afpoint a eq k 0 3985 ret false 3986 end 3987 end 3988 ret true 3989 end 3990 fn afcmd cmd uchar to bool 3991 if eq cmd 32 3992 ret true 3993 end 3994 if eq cmd 119 3995 put Af 5 mul ulong afnum get Af 0 3996 ret true 3997 end 3998 if eq cmd 65 3999 ret afarc 4000 end 4001 x = mul afnum long get Af 0 4002 y = mul sub afnum 20 long get Af 0 4003 if or eq cmd 77 eq cmd 68 4004 put Apen 0 x 4005 put Apen 1 y 4006 end 4007 if eq cmd 77 4008 ret true 4009 end 4010 if or eq cmd 76 eq cmd 68 4011 ret afseg x y 4012 end 4013 ret false 4014 end 4015 fn affloor value long to long 4016 if ge value 0 4017 ret div value 256 4018 end 4019 ret neg div add neg value 255 256 4020 end 4021 fn afbound x long y long to void 4022 if lt x get Ab 0 4023 put Ab 0 x 4024 end 4025 if lt y get Ab 1 4026 put Ab 1 y 4027 end 4028 if gt x get Ab 2 4029 put Ab 2 x 4030 end 4031 if gt y get Ab 3 4032 put Ab 3 y 4033 end 4034 end 4035 fn afbox to bool 4036 put Ab 0 get Ag 0 4037 put Ab 2 get Ag 0 4038 put Ab 1 get Ag 1 4039 put Ab 3 get Ag 1 4040 for i ulong get Af 2 4041 at = mul i 4 4042 afbound get Ag at get Ag add at 1 4043 afbound get Ag add at 2 get Ag add at 3 4044 end 4045 pad = add long get Af 1 256 4046 x0 = affloor sub get Ab 0 pad 4047 y0 = affloor sub get Ab 1 pad 4048 x1 = add affloor add get Ab 2 pad 1 4049 y1 = add affloor add get Ab 3 pad 1 4050 put Ab 0 x0 4051 put Ab 1 y0 4052 put Af 3 ulong sub x1 x0 4053 put Af 4 ulong sub y1 y0 4054 ret le mul get Af 3 get Af 4 len Alpha 4055 end 4056 fn afproj qx long qy long dx long dy long to ulong 4057 len2 = add mul dx dx mul dy dy 4058 ex = qx 4059 ey = qy 4060 if ne len2 0 4061 t = add mul qx dx mul qy dy 4062 if gt t 0 4063 if ge t len2 4064 ex = sub qx dx 4065 ey = sub qy dy 4066 else 4067 ex = sub qx div mul dx t len2 4068 ey = sub qy div mul dy t len2 4069 end 4070 end 4071 end 4072 ret ulong add mul ex ex mul ey ey 4073 end 4074 fn afdist slot ulong px long py long to ulong 4075 at = mul slot 4 4076 dx = sub get Ag add at 2 get Ag at 4077 dy = sub get Ag add at 3 get Ag add at 1 4078 qx = sub px get Ag at 4079 qy = sub py get Ag add at 1 4080 ret afproj qx qy dx dy 4081 end 4082 fn afalpha px long py long to uchar 4083 best = ulong `18446744073709551615` 4084 for i ulong get Af 2 4085 d2 = afdist i px py 4086 if lt d2 best 4087 best = d2 4088 end 4089 end 4090 d = long afsqrt best 4091 cov = sub add long get Af 1 128 d 4092 if le cov 0 4093 ret 0 4094 end 4095 if ge cov 256 4096 ret 255 4097 end 4098 ret uchar div mul cov 255 256 4099 end 4100 fn afrow y ulong to void 4101 py = add mul add get Ab 1 long y 256 128 4102 for x ulong get Af 3 4103 px = add mul add get Ab 0 long x 256 128 4104 at = add mul y get Af 3 x 4105 put Alpha at afalpha px py 4106 end 4107 end 4108 fn afpaint to void 4109 for y ulong get Af 4 4110 afrow y 4111 end 4112 end 4113 fn afglyph c uchar to bool 4114 if eq get Af 0 0 4115 ret false 4116 end 4117 if not afpick c 4118 ret false 4119 end 4120 for i ulong 65536 4121 put Alpha i 0 4122 end 4123 put Af 2 0 4124 put Af 3 0 4125 put Af 4 1 4126 put Af 5 0 4127 put Ab 0 0 4128 put Ab 1 0 4129 put Apen 0 0 4130 put Apen 1 0 4131 while lt get Afpos 0 get Afpos 1 4132 cmd = get Afdata get Afpos 0 4133 put Afpos 0 add get Afpos 0 1 4134 if not afcmd cmd 4135 ret false 4136 end 4137 end 4138 if eq get Af 2 0 4139 ret true 4140 end 4141 if not afbox 4142 ret false 4143 end 4144 afpaint 4145 ret true 4146 end 4147 note Compilable surface negative control. 4148 global Canvas uchar 884736 4149 global Cv ulong 8 4150 global Cvpose long 2 4151 fn cvinit w ulong h ulong to bool 4152 ret false 4153 end 4154 fn cvclip x ulong y ulong w ulong h ulong to bool 4155 ret false 4156 end 4157 fn cvpixel x long y long a uchar color ulong to void 4158 end 4159 fn cvglyph c uchar x long y long color ulong to bool 4160 ret false 4161 end 4162 fn cvspan beg ulong size ulong x long y long color ulong to bool 4163 ret false 4164 end 4165 global Fails ulong 1 4166 global Checks ulong 1 4167 fn check ok bool id ulong to void 4168 put Checks 0 add get Checks 0 1 4169 outreset 4170 emitn id 4171 if ok 4172 emitb 32 4173 emitb 48 4174 else 4175 put Fails 0 add get Fails 0 1 4176 emitb 32 4177 emitb 49 4178 end 4179 emitb 10 4180 w = write 1 Outb 0 get Outlen 0 4181 end 4182 note Surface tests: removing clipping, using constant background or bypassing drawing must fail. 4183 global Csave uchar 4096 4184 global Cmeta ulong 8 4185 fn test ok bool to void 4186 check ok add get Checks 0 1 4187 end 4188 fn cvkeep to void 4189 for i ulong 3072 4190 put Csave i get Canvas i 4191 end 4192 for i ulong 8 4193 put Cmeta i get Cv i 4194 end 4195 end 4196 fn cvsame to bool 4197 for i ulong 3072 4198 if ne get Canvas i get Csave i 4199 ret false 4200 end 4201 end 4202 for i ulong 8 4203 if ne get Cv i get Cmeta i 4204 ret false 4205 end 4206 end 4207 ret true 4208 end 4209 fn cvrefclip to bool 4210 ink = ulong 0 4211 for y ulong 32 4212 for x ulong 32 4213 at = mul add mul y 32 x 3 4214 inside = and ge x 8 lt x 16 4215 inside = and inside and ge y 8 lt y 16 4216 for k ulong 3 4217 v = uchar 6 4218 if eq k 1 4219 v = 8 4220 end 4221 if eq k 2 4222 v = 18 4223 end 4224 if inside 4225 v = get Csave add at k 4226 if ne v get Canvas add at k 4227 ret false 4228 end 4229 if gt v 18 4230 ink = add ink 1 4231 end 4232 else 4233 if ne get Canvas add at k v 4234 ret false 4235 end 4236 end 4237 end 4238 end 4239 end 4240 ret gt ink 0 4241 end 4242 fn cvfrac to bool 4243 b = cvinit 32 32 4244 b = afinit 14 900 4245 for i ulong 3 4246 put Dtext i 65 4247 end 4248 if not cvspan 0 3 -1 20 `15528188` 4249 ret false 4250 end 4251 one = get Af 5 4252 if ne get Cv 7 mul one 3 4253 ret false 4254 end 4255 cvkeep 4256 b = cvinit 32 32 4257 for i ulong 3 4258 x = affloor add long -256 long mul one i 4259 if not cvglyph 65 x 20 `15528188` 4260 ret false 4261 end 4262 end 4263 for i ulong 3072 4264 if ne get Canvas i get Csave i 4265 ret false 4266 end 4267 end 4268 ret true 4269 end 4270 fn main to int 4271 test not cvglyph 65 0 0 `15528188` 4272 test not cvinit 0 32 4273 test not cvinit 32 0 4274 test not cvinit 769 32 4275 test not cvinit 32 385 4276 test cvinit 32 32 4277 test eq get Cv 0 32 4278 test eq get Cv 1 32 4279 test eq get Cv 4 32 4280 test eq get Cv 5 32 4281 test eq get Canvas 0 6 4282 test eq get Canvas 1 8 4283 test eq get Canvas 2 18 4284 test eq get Canvas 3071 18 4285 test eq get Canvas 3072 0 4286 test not cvglyph 65 0 0 `15528188` 4287 test afinit 20 1000 4288 note Exact alpha arithmetic and repeated overlap must use current destination. 4289 cvpixel 0 0 0 `15528188` 4290 test eq get Canvas 0 6 4291 cvpixel 0 0 128 `15528188` 4292 test eq get Canvas 0 121 4293 test eq get Canvas 1 124 4294 test eq get Canvas 2 135 4295 cvpixel 0 0 128 `15528188` 4296 test eq get Canvas 0 178 4297 test eq get Canvas 1 182 4298 test eq get Canvas 2 193 4299 cvpixel 0 0 255 `15528188` 4300 test eq get Canvas 0 236 4301 test eq get Canvas 1 240 4302 test eq get Canvas 2 252 4303 cvkeep 4304 cvpixel -1 0 255 0 4305 cvpixel 0 -1 255 0 4306 cvpixel 32 0 255 0 4307 cvpixel 0 32 255 0 4308 test cvsame 4309 test not cvinit `18446744073709551615` 1 4310 test cvsame 4311 test not cvclip 33 0 0 0 4312 test not cvclip 0 33 0 0 4313 test not cvclip 0 0 33 1 4314 test not cvclip 0 0 1 33 4315 test not cvclip 1 1 `18446744073709551615` 1 4316 test cvsame 4317 test not cvglyph 65 -4097 0 `15528188` 4318 test not cvglyph 65 4097 0 `15528188` 4319 test not cvglyph 65 0 -4097 `15528188` 4320 test not cvglyph 65 0 4097 `15528188` 4321 test not cvglyph 65 0 0 `16777216` 4322 test cvsame 4323 note Independent reference crop of the already rendered glyph. 4324 test cvinit 32 32 4325 test cvglyph 65 4 24 `15528188` 4326 test gt get Cv 7 0 4327 cvkeep 4328 test cvinit 32 32 4329 test cvclip 8 8 8 8 4330 put Canvas 3072 165 4331 test cvglyph 65 4 24 `15528188` 4332 test cvrefclip 4333 test eq get Canvas 3072 165 4334 note Zero-area and edge clips cannot draw any pixel. 4335 test cvinit 32 32 4336 test cvclip 32 32 0 0 4337 cvkeep 4338 test cvglyph 65 -8 6 `15528188` 4339 put Cmeta 7 get Cv 7 4340 test cvsame 4341 note A negative origin that intersects the surface must draw without wrapping. 4342 test cvclip 0 0 32 32 4343 test cvglyph 65 -8 6 `15528188` 4344 ink = ulong 0 4345 for i ulong 3072 4346 if gt get Canvas i 18 4347 ink = add ink 1 4348 end 4349 end 4350 test gt ink 0 4351 test eq get Canvas 3072 0 4352 note Explicit retained-text span agrees with two separately positioned glyphs. 4353 put Dtext 0 65 4354 put Dtext 1 65 4355 test cvinit 32 32 4356 put Outb 0 88 4357 put Outlen 0 1 4358 put Err 0 7 4359 put In 8191 99 4360 ok = cvspan 0 2 1 24 `15528188` 4361 clean = and eq get Outb 0 88 eq get Outlen 0 1 4362 clean = and clean eq get Err 0 7 4363 test ok 4364 test clean 4365 test eq get In 8191 99 4366 advance = get Cv 7 4367 cvkeep 4368 test cvinit 32 32 4369 test cvglyph 65 1 24 `15528188` 4370 one = get Cv 7 4371 x = add long 1 long div one 256 4372 test cvglyph 65 x 24 `15528188` 4373 test eq advance mul one 2 4374 same = true 4375 for i ulong 3072 4376 if ne get Canvas i get Csave i 4377 same = false 4378 end 4379 end 4380 test same 4381 note Refused spans and extreme offsets preserve pixels and all surface metadata. 4382 cvkeep 4383 test not cvspan 2305 0 0 0 0 4384 test not cvspan 2304 1 0 0 0 4385 test not cvspan 1 `18446744073709551615` 0 0 0 4386 test not cvspan 0 1 0 0 `18446744073709551615` 4387 test not cvspan 0 1 -4097 0 0 4388 test cvsame 4389 test cvspan 2304 0 0 0 0 4390 test eq get Cv 7 0 4391 test eq get Dtext 0 65 4392 test eq get Dtext 1 65 4393 test cvfrac 4394 for i ulong 2304 4395 put Dtext i 65 4396 end 4397 test cvinit 32 32 4398 cvkeep 4399 test cvspan 0 2304 4096 0 `15528188` 4400 put Cmeta 7 get Cv 7 4401 test cvsame 4402 test cvinit 768 384 4403 test eq get Cv 0 768 4404 test eq get Cv 1 384 4405 test eq get Canvas 884735 18 4406 if ne get Fails 0 0 4407 ret 1 4408 end 4409 ret 0 4410 end