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-sky.om

121 lines · 2002 bytes Raw Blame History
1note tests/look-sky.om: the sky as the C oracle (layer 1, cref2/oracle W H 0 1) draws it, as a P6 PPM on
2note stdout: argv 1 W, argv 2 H. k and the centre as allen_ui.c sets them: k = min(w*4/30, h*4/25)
3note rounded to 2 (ck_night_init's caller), cx = w/2, cy = h*2/5. Then one twinkle check (argv 3 = "tw"):
4note Nfrm black, clip (100, 100, w-200, h-200), sktwink of every listed star with amount 96, PPM of Nfrm.
5global Targ uchar 16
6fn targ i ulong to long
7n = argread i Targ 0 16
8if lt n 0
9ret -1
10end
11v = long 0
12for j ulong ulong n
13v = add mul v 10 long sub ulong get Targ j 48
14end
15ret v
16end
17fn tppm to void
18w = ulong get Lg 0
19h = ulong get Lg 1
20tc 80
21tc 54
22tc 10
23tu w
24tc 32
25tu h
26tc 10
27tu 255
28tc 10
29tflush
30for y ulong h
31r = mul y w
32for x ulong w
33c = ulong 0
34if eq get Sktgt 0 0
35c = ulong get Nsky add r x
36else
37c = ulong get Nfrm add r x
38end
39tc uchar and shr c 16 255
40tc uchar and shr c 8 255
41tc uchar and c 255
42end
43tflush
44end
45end
46fn tgsum i ulong to void
47b = mul i 4
48n = mul ulong get Skgbox add b 2 ulong get Skgbox add b 3
49o = get Skgoff i
50sl = ulong 0
51sp = ulong 0
52for k ulong n
53b = add o k
54sl = add sl mul ulong get Skglit b add rem k 1000 1
55sp = add sp mul ulong get Skgpha b add rem k 997 1
56end
57tu sl
58tc 32
59tu sp
60end
61fn main to int
62w = targ 1
63h = targ 2
64if lt w 1
65ret 2
66end
67if lt h 1
68ret 2
69end
70put Lg 0 w
71put Lg 1 h
72k = pkmin div mul w 4 30 div mul h 4 25
73put Lg 2 and k -2
74put Lg 3 div w 2
75put Lg 4 div mul h 2 5
76pkinit
77skmake
78if eq argcnt 3
79tppm
80ret 0
81end
82n = argread 3 Targ 0 16
83if eq get Targ 0 103
84note argv 3 "gal": per galaxy i box tint period and weighted sums of light and phase, then ntw
85for i ulong 6
86b = mul i 4
87tu i
88tc 32
89tl get Skgbox b
90tc 32
91tl get Skgbox add b 1
92tc 32
93tl get Skgbox add b 2
94tc 32
95tl get Skgbox add b 3
96tc 32
97tu ulong get Skgtint i
98tc 32
99tu get Skgper i
100tc 32
101tgsum i
102tnl
103end
104tu 103
105tc 32
106tu get Sktwn 0
107tnl
108tflush
109ret 0
110end
111put Lg 5 100
112put Lg 6 100
113put Lg 7 sub w 200
114put Lg 8 sub h 200
115for i ulong get Sktwn 0
116sktwink i 96
117end
118put Sktgt 0 1
119tppm
120ret 0
121end