From 75531bbc2f299661083ff83f217ecd742fe147cb Mon Sep 17 00:00:00 2001 From: Dennis Ranke Date: Tue, 2 Nov 2021 23:27:15 +0100 Subject: [PATCH] time is now a parameter to the tic function instead of a mutable import --- trainride.hw | 3 +-- uw8loader.hw | 10 +++++----- warptunnel.hw | 3 +-- xorscroll.hw | 3 +-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/trainride.hw b/trainride.hw index 3e7cb7b..666e254 100644 --- a/trainride.hw +++ b/trainride.hw @@ -1,7 +1,6 @@ import "uw8.ram" memory(2); -import "uw8.time" global mut time: i32; -export fn tic() { +export fn tic(time: i32) { let i: i32; let defer t = time as f32 / 1000 as f32; loop pixels { diff --git a/uw8loader.hw b/uw8loader.hw index 4c4f367..477ff77 100644 --- a/uw8loader.hw +++ b/uw8loader.hw @@ -4,7 +4,7 @@ export fn load_uw8(module_start: i32, module_end: i32, base_start: i32, base_end if ?module_start == 0 { let defer length = module_end - module_start; copy(base_end, module_start, length); - return length; + return base_end + length; } 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 { 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; if base_start < base_end & ?src == ?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 { - let length3 = copy_section(dest, base_start); + let defer length3 = copy_section(dest, base_start); dest = dest + length3; base_start = base_start + length3; branch sections; @@ -39,10 +39,10 @@ fn section_size(ptr: i32) -> i32 { let l = 0; let shift = 0; loop size { - let b = ?p; - p = p + 1; + let defer b = ?p; l = l | ((b & 127) << shift); shift = shift + 7; + p = p + 1; branch_if b & 128: size; } p - ptr + l diff --git a/warptunnel.hw b/warptunnel.hw index c31f9c9..8d9f03a 100644 --- a/warptunnel.hw +++ b/warptunnel.hw @@ -1,7 +1,6 @@ import "uw8.ram" memory(2); -import "uw8.time" global mut time: i32; -export fn tic() { +export fn tic(time: i32) { let i: i32; loop pixels { let defer x = (i % 320) as f32 - 160.1; diff --git a/xorscroll.hw b/xorscroll.hw index d4175fb..725f2df 100644 --- a/xorscroll.hw +++ b/xorscroll.hw @@ -1,7 +1,6 @@ import "uw8.ram" memory(2); -import "uw8.time" global mut time: i32; -export fn tic() { +export fn tic(time: i32) { let i: i32; loop frame { i?120 = (i % 320 + time / 10) ^ (i / 320);