add hex constants and data segments

This commit is contained in:
2021-11-12 22:08:53 +01:00
parent 51cf8a8d28
commit e4bf292e47
14 changed files with 355 additions and 84 deletions

View File

@@ -1,13 +1,13 @@
import "env.memory" memory(4);
import "math.sin" fn sin(f32) -> f32;
import "math.cos" fn cos(f32) -> f32;
import "env.sin" fn sin(f32) -> f32;
import "env.cos" fn cos(f32) -> f32;
export fn tic(time: i32) {
let i: i32;
loop screen {
let defer x = (i % 320) as f32 / 48 as f32;
let defer y = (i / 320) as f32 / 48 as f32;
let defer t = time as f32 / 200 as f32;
let lazy x = (i % 320) as f32 / 48 as f32;
let lazy y = (i / 320) as f32 / 48 as f32;
let lazy t = time as f32 / 200 as f32;
i?120 = ((sin(x + sin(y - t / 4 as f32) * 3 as f32 + t / 5 as f32) + sin(y + sin(x - t / 3 as f32) + t / 6 as f32)) * 63 as f32) as i32 + 128;

View File

@@ -12,7 +12,7 @@ fn random64() -> i64 {
state := randomState ^ (randomState #>> 12i64)
) ^ (state << 25i64)
) ^ (state #>> 27i64);
randomState * 2685821657736338717i64
randomState * 0x2545f4914f6cdd1di64
}
fn randomf() -> f32 {

View File

@@ -5,16 +5,16 @@ import "env.atan2" fn atan2(f32, f32) -> f32;
export fn tic(time: i32) {
let i: i32;
loop screen {
let defer t = time as f32 / 2000 as f32;
let defer o = sin(t) * 0.8;
let defer q = (i % 320) as f32 - 160.1;
let defer w = (i / 320 - 128) as f32;
let defer r = sqrt(q*q + w*w);
let defer z = q / r;
let defer s = z * o + sqrt(z * z * o * o + 1 as f32 - o * o);
let defer q2 = (z * s - o) * 10 as f32 + t;
let defer w2 = w / r * s * 10 as f32 + t;
let defer s2 = s * 50 as f32 / r;
let lazy t = time as f32 / 2000 as f32;
let lazy o = sin(t) * 0.8;
let lazy q = (i % 320) as f32 - 160.1;
let lazy w = (i / 320 - 128) as f32;
let lazy r = sqrt(q*q + w*w);
let lazy z = q / r;
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 lazy w2 = w / r * s * 10 as f32 + t;
let lazy s2 = s * 50 as f32 / r;
i?120 = max(
0 as f32,
((q2 as i32 ^ w2 as i32 & ((s2 + t) * 20 as f32) as i32) & 5) as f32 *

View File

@@ -2,16 +2,16 @@ import "env.memory" memory(2);
export fn tic(time: i32) {
let i: i32;
let defer t = time as f32 / 1000 as f32;
let lazy t = time as f32 / 1000 as f32;
loop pixels {
let defer x = (i % 320 - 160) as f32;
let defer y = (i / 320) as f32 - 128.5;
let defer z = t + 20 as f32 / sqrt(x*x + y*y);
let defer z_int = z as i32;
let defer q = select(z_int % 9 >= 6, z, (z_int - z_int % 9 + 6) as f32);
let defer w = 9 as f32 / y + t;
let defer s = q - t;
let defer m = x * s / 50 as f32;
let lazy x = (i % 320 - 160) as f32;
let lazy y = (i / 320) as f32 - 128.5;
let lazy z = t + 20 as f32 / sqrt(x*x + y*y);
let lazy z_int = z as i32;
let lazy q = select(z_int % 9 >= 6, z, (z_int - z_int % 9 + 6) as f32);
let lazy w = 9 as f32 / y + t;
let lazy s = q - t;
let lazy m = x * s / 50 as f32;
i?120 = select(y > 0 as f32 & w < q,
select(abs(x * (w - t)) < 9 as f32, 15, 7) - w as i32 % 2,

View File

@@ -4,9 +4,9 @@ import "env.atan2" fn atan2(f32, f32) -> f32;
export fn tic(time: i32) {
let i: i32;
loop screen {
let defer t = time as f32 / 10 as f32;
let defer x = (i % 320) as f32 - 160.1;
let defer y = (i / 320 - 128) as f32;
let lazy t = time as f32 / 10 as f32;
let lazy x = (i % 320) as f32 - 160.1;
let lazy y = (i / 320 - 128) as f32;
i?120 = ((20000 as f32 / sqrt(x * x + y * y) + t) as i32 ^ (atan2(x, y) * 512 as f32 / 3.141 + t) as i32);
branch_if (i := i + 1) < 320*256: screen

View File

@@ -3,10 +3,10 @@ import "env.memory" memory(2);
export fn tic(time: i32) {
let i: i32;
loop pixels {
let defer x = (i % 320) as f32 - 160.1;
let defer y = (i / 320 - 128) as f32;
let defer dist = 10000.0 / (x*x + y*y);
let defer t = time as f32 / 20 as f32;
let lazy x = (i % 320) as f32 - 160.1;
let lazy y = (i / 320 - 128) as f32;
let lazy dist = 10000.0 / (x*x + y*y);
let lazy t = time as f32 / 20 as f32;
i?120 = (x * dist + t) as i32 ^ (y * dist + t) as i32;