mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 11:16:42 +01:00
optimize hline function, update wasmtime
This commit is contained in:
2
platform/Cargo.lock
generated
2
platform/Cargo.lock
generated
@@ -146,7 +146,7 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
[[package]]
|
||||
name = "curlywas"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/exoticorn/curlywas.git?rev=0a0d90c#0a0d90c8013f1d7856a9b71a19d3d006300f31f9"
|
||||
source = "git+https://github.com/exoticorn/curlywas.git?rev=0e7ea50#0e7ea508cd0e76836283ae68a44c9097df83c8ac"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ariadne",
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
curlywas = { git="https://github.com/exoticorn/curlywas.git", rev="0a0d90c" }
|
||||
curlywas = { git="https://github.com/exoticorn/curlywas.git", rev="0e7ea50" }
|
||||
uw8-tool = { path="../uw8-tool" }
|
||||
anyhow = "1"
|
||||
lodepng = "3.4"
|
||||
Binary file not shown.
@@ -62,11 +62,7 @@ export fn cls(col: i32) {
|
||||
textCursorX = 0;
|
||||
textCursorY = 0;
|
||||
outputChannel = 0;
|
||||
col = (col & 255) * 0x1010101;
|
||||
loop pixels {
|
||||
i!120 = col;
|
||||
branch_if (i := i + 4) < 320*240: pixels;
|
||||
}
|
||||
memory.fill(120, col, 320*240);
|
||||
}
|
||||
|
||||
export fn setPixel(x: i32, y: i32, col: i32) {
|
||||
@@ -90,12 +86,70 @@ fn clamp(v: i32, min: i32, max: i32) -> i32 {
|
||||
export fn hline(x1: i32, x2: i32, y: i32, col: i32) {
|
||||
x1 = clamp(x1, 0, 320);
|
||||
x2 = clamp(x2, 0, 320);
|
||||
if x1 < x2 & y #< 240 {
|
||||
if y #>= 240 {
|
||||
return;
|
||||
}
|
||||
let word_start = (x1 + 3) & -4;
|
||||
let word_end = x2 & -4;
|
||||
if word_end > word_start {
|
||||
col = (col & 255) * 0x1010101;
|
||||
let ptr = y * 320 + x1;
|
||||
let end = ptr + word_start - x1;
|
||||
if ptr + 2 <= end {
|
||||
ptr?120 = col;
|
||||
ptr?121 = col;
|
||||
ptr += 2;
|
||||
}
|
||||
if ptr < end {
|
||||
ptr?120 = col;
|
||||
ptr += 1;
|
||||
}
|
||||
end += word_end - word_start;
|
||||
loop words {
|
||||
if ptr + 16 <= end {
|
||||
ptr!120 = col;
|
||||
ptr!124 = col;
|
||||
ptr!128 = col;
|
||||
ptr!132 = col;
|
||||
ptr += 16;
|
||||
branch words;
|
||||
}
|
||||
if ptr + 8 <= end {
|
||||
ptr!120 = col;
|
||||
ptr!124 = col;
|
||||
ptr += 8;
|
||||
}
|
||||
if ptr < end {
|
||||
ptr!120 = col;
|
||||
ptr += 4;
|
||||
}
|
||||
}
|
||||
end += x2 - word_end;
|
||||
if ptr + 2 <= end {
|
||||
ptr?120 = col;
|
||||
ptr?121 = col;
|
||||
ptr += 2;
|
||||
}
|
||||
if ptr < end {
|
||||
ptr?120 = col;
|
||||
}
|
||||
} else {
|
||||
let ptr = y * 320 + x1;
|
||||
let end = ptr + x2 - x1;
|
||||
loop pixels {
|
||||
if ptr + 4 <= end {
|
||||
ptr?120 = col;
|
||||
ptr?121 = col;
|
||||
ptr?122 = col;
|
||||
ptr?123 = col;
|
||||
ptr += 4;
|
||||
}
|
||||
if ptr + 2 <= end {
|
||||
ptr?120 = col;
|
||||
ptr?121 = col;
|
||||
ptr += 2;
|
||||
}
|
||||
if ptr < end {
|
||||
ptr?120 = col;
|
||||
branch_if (ptr := ptr + 1) < end: pixels;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -548,13 +602,6 @@ export fn endFrame() {
|
||||
68!4 = 68!0;
|
||||
}
|
||||
|
||||
fn memclr(base: i32, size: i32) {
|
||||
loop bytes {
|
||||
(base + (size := size - 1))?0 = 0;
|
||||
branch_if size: bytes;
|
||||
}
|
||||
}
|
||||
|
||||
start fn setup() {
|
||||
let i: i32 = 12*16*3-1;
|
||||
let avg: f32;
|
||||
@@ -587,9 +634,9 @@ start fn setup() {
|
||||
branch_if (i := i - 1) >= 0: expand_sweetie;
|
||||
}
|
||||
|
||||
memclr(0, 64);
|
||||
memclr(112, 8);
|
||||
memclr(0x14000, 0x2c000);
|
||||
memory.fill(0, 0, 64);
|
||||
memory.fill(112, 0, 8);
|
||||
memory.fill(0x14000, 0, 0x2c000);
|
||||
|
||||
|
||||
cls(0);
|
||||
|
||||
Reference in New Issue
Block a user