got trainride working

This commit is contained in:
2021-10-27 22:18:34 +02:00
parent 23d926dbb3
commit 2267eed21c
7 changed files with 248 additions and 32 deletions

26
trainride.hw Normal file
View File

@@ -0,0 +1,26 @@
import "uw8.ram" memory(2);
import "uw8.time" global mut time: i32;
export fn tic() {
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;
}
}