implement unsigned operators

This commit is contained in:
2021-11-11 23:04:41 +01:00
parent d3e882cba0
commit 51cf8a8d28
7 changed files with 161 additions and 51 deletions

View File

@@ -9,14 +9,14 @@ fn random() -> i32 {
fn random64() -> i64 {
let state: i64;
randomState = (state := (
state := randomState ^ (randomState >> 12i64)
state := randomState ^ (randomState #>> 12i64)
) ^ (state << 25i64)
) ^ (state >> 27i64);
) ^ (state #>> 27i64);
randomState * 2685821657736338717i64
}
fn randomf() -> f32 {
f32.reinterpret_i32(1065353216 | (random() >> 9)) - 1 as f32
f32.reinterpret_i32(1065353216 | (random() #>> 9)) - 1 as f32
}
fn seed(s: i32) {
@@ -28,8 +28,8 @@ fn seed(s: i32) {
export fn tic(time: i32) {
let i: i32;
loop pixels {
seed(i + (time / 100) * 320);
i?120 = (randomf() * 256 as f32 + time as f32 / 10 as f32) as i32;
seed(i + (time / 10) * 320);
i?120 = (randomf() * 256 as f32 + time as f32 / 10 as f32) as i32 & 128;
branch_if (i := i + 1) < 320*256: pixels
}
}

View File

@@ -14,7 +14,7 @@ global mut s: f32 = 0.0;
global mut f: f32 = 0.0;
fn rng(state: i32) -> i32 {
94614859 * (state ^ (state >> 17))
94614859 * (state ^ (state #>> 17))
}
fn set_color(color: i32) -> i32 {
@@ -35,7 +35,7 @@ export fn update() {
loop lines {
?(8003-y) = (score := score / 10) % 10 + 48;
let defer z = (4000 / (y := y + 1) + pz) / 20;
let defer x = (rng(rng(rng(rng(z)))) >>> 30) as f32 - px;
let defer x = (rng(rng(rng(rng(z)))) >> 30) as f32 - px;
let defer w = 9 as f32 / sqrt(z as f32);
let defer rx = 80 + (y as f32 * x) as i32;
let defer rw = (y as f32 * w) as i32;
@@ -47,10 +47,10 @@ export fn update() {
if y == 120 & py > zero {
if x < -w | x > zero {
if pad & 2 { // (*)
pz = 30; // (*)
px = zero; // (*)
} // (*)
if pad & 2 {
pz = 30;
px = zero;
}
return;
}
py = zero;