time is now a parameter to the tic function instead of a mutable import

This commit is contained in:
2021-11-02 23:27:15 +01:00
parent 2d901e4c61
commit 75531bbc2f
4 changed files with 8 additions and 11 deletions

View File

@@ -1,7 +1,6 @@
import "uw8.ram" memory(2); import "uw8.ram" memory(2);
import "uw8.time" global mut time: i32;
export fn tic() { export fn tic(time: i32) {
let i: i32; let i: i32;
let defer t = time as f32 / 1000 as f32; let defer t = time as f32 / 1000 as f32;
loop pixels { loop pixels {

View File

@@ -4,7 +4,7 @@ export fn load_uw8(module_start: i32, module_end: i32, base_start: i32, base_end
if ?module_start == 0 { if ?module_start == 0 {
let defer length = module_end - module_start; let defer length = module_end - module_start;
copy(base_end, module_start, length); copy(base_end, module_start, length);
return length; return base_end + length;
} }
copy(base_end, base_start, 8); copy(base_end, base_start, 8);
@@ -14,7 +14,7 @@ export fn load_uw8(module_start: i32, module_end: i32, base_start: i32, base_end
loop sections { loop sections {
if src < module_end & (base_start >= base_end | ?src <= ?base_start) { if src < module_end & (base_start >= base_end | ?src <= ?base_start) {
let length2 = copy_section(dest, src); let defer length2 = copy_section(dest, src);
dest = dest + length2; dest = dest + length2;
if base_start < base_end & ?src == ?base_start { if base_start < base_end & ?src == ?base_start {
base_start = base_start + section_size(base_start); base_start = base_start + section_size(base_start);
@@ -24,7 +24,7 @@ export fn load_uw8(module_start: i32, module_end: i32, base_start: i32, base_end
} }
if base_start < base_end { if base_start < base_end {
let length3 = copy_section(dest, base_start); let defer length3 = copy_section(dest, base_start);
dest = dest + length3; dest = dest + length3;
base_start = base_start + length3; base_start = base_start + length3;
branch sections; branch sections;
@@ -39,10 +39,10 @@ fn section_size(ptr: i32) -> i32 {
let l = 0; let l = 0;
let shift = 0; let shift = 0;
loop size { loop size {
let b = ?p; let defer b = ?p;
p = p + 1;
l = l | ((b & 127) << shift); l = l | ((b & 127) << shift);
shift = shift + 7; shift = shift + 7;
p = p + 1;
branch_if b & 128: size; branch_if b & 128: size;
} }
p - ptr + l p - ptr + l

View File

@@ -1,7 +1,6 @@
import "uw8.ram" memory(2); import "uw8.ram" memory(2);
import "uw8.time" global mut time: i32;
export fn tic() { export fn tic(time: i32) {
let i: i32; let i: i32;
loop pixels { loop pixels {
let defer x = (i % 320) as f32 - 160.1; let defer x = (i % 320) as f32 - 160.1;

View File

@@ -1,7 +1,6 @@
import "uw8.ram" memory(2); import "uw8.ram" memory(2);
import "uw8.time" global mut time: i32;
export fn tic() { export fn tic(time: i32) {
let i: i32; let i: i32;
loop frame { loop frame {
i?120 = (i % 320 + time / 10) ^ (i / 320); i?120 = (i % 320 + time / 10) ^ (i / 320);