run --browser is working (very unpolished)

This commit is contained in:
2022-02-19 23:58:13 +01:00
parent 4c75ba2e44
commit 266493ca1c

View File

@@ -1,25 +1,29 @@
import "env.memory" memory(4); import "env.memory" memory(4);
import "env.sin" fn sin(f32) -> f32; import "env.sin" fn sin(f32) -> f32;
import "env.time" fn time() -> f32; import "env.time" fn time() -> f32;
import "env.setPixel" fn setPixel(i32, i32, i32);
export fn upd() { export fn upd() {
let i: i32; let x: i32;
let y: i32;
loop screen { loop screen {
let inline t = time() / 2 as f32; let inline t = time() / 2 as f32;
let lazy o = sin(t) * 0.8; let lazy o = sin(t) * 0.75;
let lazy q = (i % 320) as f32 - 160.1; let inline q = x as f32 - 160.5;
let lazy w = (i / 320 - 120) as f32; let inline w = (y - 120) as f32;
let lazy r = sqrt(q*q + w*w); let lazy r = sqrt(q*q + w*w);
let lazy z = q / r; let lazy z = q / r;
let lazy s = z * o + sqrt(z * z * o * o + 1 as f32 - o * o); let lazy s = z * o + sqrt(z * z * o * o + 1 as f32 - o * o);
let lazy q2 = (z * s - o) * 10 as f32 + t; let inline q2 = (z * s - o) * 10 as f32 + t;
let lazy w2 = w / r * s * 10 as f32 + t; let inline w2 = w / r * s * 10 as f32 + t;
let lazy s2 = s * 100 as f32 / r; let inline s2 = s * 100 as f32 / r;
i?120 = max( let inline color = max(
0 as f32, 0 as f32,
((q2 as i32 ^ w2 as i32 & ((s2 + time()) * 10 as f32) as i32) & 5) as f32 * ((q2 as i32 ^ w2 as i32 & ((s2 + time()) * 10 as f32) as i32) & 5) as f32 *
(4 as f32 - s2) as f32 (4 as f32 - s2) as f32
) as i32 - 32; ) as i32 - 32;
branch_if (i := i + 1) < 320*240: screen setPixel(x, y, color);
branch_if x := (x + 1) % 320: screen;
branch_if y := (y + 1) % 320: screen;
} }
} }