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/native/omega/allen/tests/look-home.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 / native / omega / allen / tests / look-home.om` 197 lines ยท 4022 bytes Raw Blame History 1 note tests/look-home.om: drives look-home.om on the C harness's schedule (~/work/IMacLook/home/harness.c) and writes 2 note the same regions as P6 PPMs to fd 1, in the harness's order: flashA flashB barA barB wordsC barC wordsD barD. 3 note NIGHT's hole radius at the two flash frames is taken from the C harness log (346/417 at 1280, 1066/1285 at 3840). 4 note stdin: the harness's -night.ppm files, in that order (the bare night each frame is drawn on). 5 note Unit: font-data.om font.om look-paint.om look-night.om look-mind.om look-home.om tio.om tests/look-home.om. 6 global Tbg uchar 16384 7 global Thead ulong 4 8 global Tnow long 1 9 text Tsay "Opening the Allen repository on GitHub, aien-dev/aienux. The same code runs on the Spark, so ask me about any file." 10 text Ttyped "open allen github repository" 11 note reads exactly n bytes from fd 0 into Tbg 12 fn tfill n ulong to void 13 got = ulong 0 14 while lt got n 15 r = read 0 Tbg got sub n got 16 if le r 0 17 trap 2 18 end 19 got = add got ulong r 20 end 21 end 22 note one P6 header: "P6\n \n255\n" read byte by byte; Thead 1 2 = w h 23 fn thead to void 24 nl = ulong 0 25 v = ulong 0 26 k = ulong 0 27 while lt nl 4 28 tfill 1 29 c = get Tbg 0 30 if or eq c 10 eq c 32 31 if ne k 0 32 put Thead nl v 33 nl = add nl 1 34 end 35 v = 0 36 k = 0 37 else 38 if ge c 48 39 v = add mul v 10 sub ulong c 48 40 k = add k 1 41 end 42 end 43 end 44 end 45 note one P6 from fd 0 into Nfrm (the frame's size must match Lg 0 1) 46 fn tpx p ulong to ulong 47 c = shl ulong get Tbg p 16 48 c = or c shl ulong get Tbg add p 1 8 49 ret or c ulong get Tbg add p 2 50 end 51 fn trow at ulong w ulong to void 52 for i ulong w 53 put Nfrm add at i uint tpx mul i 3 54 end 55 end 56 fn tload to void 57 thead 58 w = get Thead 1 59 for j ulong get Thead 2 60 tfill mul w 3 61 trow mul j w w 62 end 63 end 64 fn tpix c ulong to void 65 tc uchar and shr c 16 255 66 tc uchar and shr c 8 255 67 tc uchar and c 255 68 end 69 fn tprow at ulong w ulong to void 70 for i ulong w 71 tpix ulong get Nfrm add at i 72 end 73 end 74 fn tppm x long y long w long h long to void 75 tc 80 76 tc 54 77 tc 10 78 tu ulong w 79 tc 32 80 tu ulong h 81 tc 10 82 tu 255 83 tc 10 84 at = add mul ulong y ulong get Lg 0 ulong x 85 for j ulong ulong h 86 tprow at ulong w 87 at = add at ulong get Lg 0 88 end 89 end 90 fn trun upto long to void 91 while le get Tnow 0 upto 92 hmstep get Tnow 0 93 put Tnow 0 add get Tnow 0 16 94 end 95 end 96 note draws the frame last stepped on the bare night from stdin, and writes the region 97 fn tdump x long y long w long h long to void 98 tload 99 hmflash 0 0 get Lg 0 get Lg 1 100 hmtext 0 0 get Lg 0 get Lg 1 101 tppm x y w h 102 end 103 note the regions the C harness dumps: the flash box, the bar box (Hm 28..31) and the words box of lay_out 104 fn tflash to void 105 r = add shr hmfrad get Hm 12 4 2 106 x = sub get Lg 3 r 107 y = sub get Lg 4 r 108 r = add mul 2 r 1 109 tppm x y r r 110 end 111 fn tbar to void 112 tppm get Hm 28 get Hm 29 get Hm 30 get Hm 31 113 end 114 fn twords to void 115 x = sub sub get Lg 3 hms 450 hms 8 116 y = sub add get Lg 4 hms 250 hms 34 117 w = add hms 900 hms 16 118 h = add mul 5 hms 40 hms 30 119 tppm x y w h 120 end 121 fn tdraw to void 122 hmflash 0 0 get Lg 0 get Lg 1 123 hmtext 0 0 get Lg 0 get Lg 1 124 end 125 fn main to long 126 note the first night file gives the size (all frames share it): Lg 0 1 are only placeholders for its load 127 put Lg 0 1280 128 put Lg 1 800 129 tload 130 put Lg 0 long get Thead 1 131 put Lg 1 long get Thead 2 132 kw = div mul get Lg 0 256 1920 133 kh = div mul get Lg 1 256 1080 134 put Lg 2 pkmin kw kh 135 put Lg 3 div get Lg 0 2 136 put Lg 4 div mul get Lg 1 40 100 137 pkinit 138 hminit 139 put Tnow 0 0 140 put Nthol 0 1 141 put Nthole 0 add mul get Lg 3 16 8 142 put Nthole 1 add mul get Lg 4 16 8 143 trun 12100 144 put Nthole 3 346 145 if ne get Lg 0 1280 146 put Nthole 3 1066 147 end 148 tdraw 149 tflash 150 trun 12290 151 put Nthole 3 417 152 if ne get Lg 0 1280 153 put Nthole 3 1285 154 end 155 tload 156 tdraw 157 tflash 158 put Nthol 0 0 159 trun 16500 160 tload 161 tdraw 162 tbar 163 for i ulong len Ttyped 164 hmkey ulong get Ttyped i 165 trun add get Tnow 0 120 166 end 167 tload 168 tdraw 169 tbar 170 trun 20500 171 hmkey 13 172 hmthink 1 173 trun 23500 174 for i ulong len Tsay 175 put Hmsay i get Tsay i 176 end 177 put Hmsayn 0 len Tsay 178 hmsaid 179 speak = add get Tnow 0 400 180 n = long len Tsay 181 trun add speak div mul n 35 2 182 tload 183 tdraw 184 twords 185 tload 186 tdraw 187 tbar 188 trun add add speak mul n 35 500 189 tload 190 tdraw 191 twords 192 tload 193 tdraw 194 tbar 195 tflush 196 ret 0 197 end