aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / omega / allen / demo.om
| 1 | note SPDX-License-Identifier: MIT |
| 2 | note Repository demonstration screen state. Platform independent; no device calls. |
| 3 | note UI state (Dmo, Dprm, Dprmn, Dstat) is declared in platform.om. |
| 4 | text Dmotext "Allen\nType a request, then press Enter.\nI recognise requests to open Allen's GitHub repository.\nRequest:\nRecognised as a deterministic repository request; no model was used.\nNative boot: UEFI firmware services remain active.\nNetwork is up. Type a request.\nNo firmware network yet, retrying. Code: \n" |
| 5 | fn dmglyphs at ulong n ulong x long y long color ulong to bool |
| 6 | pen = mul x 256 |
| 7 | for i ulong n |
| 8 | if not afglyph get Dmotext add at i |
| 9 | ret false |
| 10 | end |
| 11 | cvblit affloor pen y color |
| 12 | pen = add pen long get Af 5 |
| 13 | end |
| 14 | ret true |
| 15 | end |
| 16 | fn dmline wanted ulong x long y long color ulong to bool |
| 17 | line = ulong 0 |
| 18 | at = ulong 0 |
| 19 | for i ulong len Dmotext |
| 20 | if eq get Dmotext i 10 |
| 21 | if eq line wanted |
| 22 | ret dmglyphs at sub i at x y color |
| 23 | end |
| 24 | line = add line 1 |
| 25 | at = add i 1 |
| 26 | end |
| 27 | end |
| 28 | ret false |
| 29 | end |
| 30 | fn dmprompt x long y long to bool |
| 31 | pen = mul x 256 |
| 32 | for i ulong get Dprmn 0 |
| 33 | if not afglyph get Dprm i |
| 34 | ret false |
| 35 | end |
| 36 | cvblit affloor pen y 16777215 |
| 37 | pen = add pen long get Af 5 |
| 38 | end |
| 39 | ret true |
| 40 | end |
| 41 | fn dmnum v ulong x long y long color ulong to bool |
| 42 | note Reuse the existing decimal writer, then draw those bytes with the Allen font. |
| 43 | outreset |
| 44 | emitn v |
| 45 | pen = mul x 256 |
| 46 | for i ulong get Outlen 0 |
| 47 | if not afglyph get Outb i |
| 48 | ret false |
| 49 | end |
| 50 | cvblit affloor pen y color |
| 51 | pen = add pen long get Af 5 |
| 52 | end |
| 53 | ret true |
| 54 | end |
| 55 | fn dmrender to bool |
| 56 | if eq get Dmo 0 1 |
| 57 | ret ghrender |
| 58 | end |
| 59 | if or lt get Cv 0 320 lt get Cv 1 288 |
| 60 | ret false |
| 61 | end |
| 62 | if not cvclip 0 0 get Cv 0 get Cv 1 |
| 63 | ret false |
| 64 | end |
| 65 | for i ulong mul get Cv 0 get Cv 1 |
| 66 | at = mul i 3 |
| 67 | put Canvas at 6 |
| 68 | put Canvas add at 1 8 |
| 69 | put Canvas add at 2 18 |
| 70 | end |
| 71 | if not afinit 22 1300 |
| 72 | ret false |
| 73 | end |
| 74 | if not dmline 0 32 52 16777215 |
| 75 | ret false |
| 76 | end |
| 77 | if not afinit 11 1000 |
| 78 | ret false |
| 79 | end |
| 80 | if not dmline 1 32 92 13161215 |
| 81 | ret false |
| 82 | end |
| 83 | if not dmline 2 32 116 13161215 |
| 84 | ret false |
| 85 | end |
| 86 | if not dmline 5 32 140 9871556 |
| 87 | ret false |
| 88 | end |
| 89 | if not afinit 13 1100 |
| 90 | ret false |
| 91 | end |
| 92 | if not dmline 3 32 196 16766102 |
| 93 | ret false |
| 94 | end |
| 95 | if ne get Es 6 0 |
| 96 | if not dmline 6 32 260 8555696 |
| 97 | ret false |
| 98 | end |
| 99 | else |
| 100 | if not dmline 7 32 260 8555696 |
| 101 | ret false |
| 102 | end |
| 103 | if not dmnum get Es 12 364 260 8555696 |
| 104 | ret false |
| 105 | end |
| 106 | end |
| 107 | ret dmprompt 112 196 |
| 108 | end |
| 109 | fn dmsubmit to bool |
| 110 | n = get Dprmn 0 |
| 111 | if or eq n 0 gt n 159 |
| 112 | ret false |
| 113 | end |
| 114 | if eq get Es 6 0 |
| 115 | note Never show a transport error for a network that was never up: keep the request. |
| 116 | put Dstat 0 1 |
| 117 | ret false |
| 118 | end |
| 119 | put Dstat 0 0 |
| 120 | for i ulong n |
| 121 | put In i get Dprm i |
| 122 | end |
| 123 | put Inlen 0 n |
| 124 | if not ghask |
| 125 | ret false |
| 126 | end |
| 127 | put Dmo 0 1 |
| 128 | put Dprmn 0 0 |
| 129 | ret true |
| 130 | end |
| 131 | fn dmkey key ulong to bool |
| 132 | if eq get Dmo 0 1 |
| 133 | if eq key 27 |
| 134 | put Dmo 0 0 |
| 135 | put Dprmn 0 0 |
| 136 | ghinit |
| 137 | ret true |
| 138 | end |
| 139 | ghkey key |
| 140 | ret true |
| 141 | end |
| 142 | if and ge key 32 le key 126 |
| 143 | n = get Dprmn 0 |
| 144 | if ge n len Dprm |
| 145 | ret false |
| 146 | end |
| 147 | put Dprm n uchar key |
| 148 | put Dprmn 0 add n 1 |
| 149 | ret true |
| 150 | end |
| 151 | if or eq key 8 eq key 127 |
| 152 | if gt get Dprmn 0 0 |
| 153 | put Dprmn 0 sub get Dprmn 0 1 |
| 154 | end |
| 155 | ret true |
| 156 | end |
| 157 | if or eq key 10 eq key 13 |
| 158 | ret dmsubmit |
| 159 | end |
| 160 | ret false |
| 161 | end |
| 162 | fn dminit to void |
| 163 | ghinit |
| 164 | put Dmo 0 0 |
| 165 | put Dprmn 0 0 |
| 166 | end |