interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / omega / allen / tests / look-home.om

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