added support for function imports

This commit is contained in:
2021-11-03 22:07:55 +01:00
parent 4f70a65866
commit 4793c4eb69
11 changed files with 101 additions and 21 deletions

25
trainride.cwa Normal file
View File

@@ -0,0 +1,25 @@
import "env.memory" memory(2);
export fn tic(time: i32) {
let i: i32;
let defer 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;
i?120 = select(y > 0 as f32 & w < q,
select(abs(x * (w - t)) < 9 as f32, 15, 7) - w as i32 % 2,
select(y * s > -99 as f32 / (m * m + 1 as f32),
select(q == z, z_int % 2, 3),
12 + (y / 23 as f32) as i32
)
) * 16;
branch_if (i := i + 1) < 320*256: pixels;
}
}