diff --git a/random.cwa b/random.cwa new file mode 100644 index 0000000..5166bca --- /dev/null +++ b/random.cwa @@ -0,0 +1,23 @@ +import "env.memory" memory(4); + +fn random() -> i32 { + let seed = !0; + seed = seed ^ (seed << 13); + seed = seed ^ (seed >> 17); + seed = seed ^ (seed << 5); + !0 = seed; + seed * 625341585 +} + +fn seed(s: i32) { + !0 = (s + (s >>> 31)) * 2060714111; +} + +export fn tic(time: i32) { + let i: i32; + loop pixels { + seed(i + time / 10); + i?120 = random(); + branch_if (i := i + 1) < 320*256: pixels + } +} diff --git a/technotunnel.cwa b/technotunnel.cwa index 222a433..aa9875c 100644 --- a/technotunnel.cwa +++ b/technotunnel.cwa @@ -1,6 +1,6 @@ import "env.memory" memory(4); -import "math.sin" fn sin(f32) -> f32; -import "math.atan2" fn atan2(f32, f32) -> f32; +import "env.sin" fn sin(f32) -> f32; +import "env.atan2" fn atan2(f32, f32) -> f32; export fn tic(time: i32) { let i: i32;