diff --git a/platform/bin/loader.wasm b/platform/bin/loader.wasm index ab4860e..bf56884 100644 Binary files a/platform/bin/loader.wasm and b/platform/bin/loader.wasm differ diff --git a/platform/bin/platform.uw8 b/platform/bin/platform.uw8 index b51d958..fe2d3bc 100644 Binary files a/platform/bin/platform.uw8 and b/platform/bin/platform.uw8 differ diff --git a/platform/src/platform.cwa b/platform/src/platform.cwa index 85f0c76..4a53486 100644 --- a/platform/src/platform.cwa +++ b/platform/src/platform.cwa @@ -115,6 +115,26 @@ export fn rectangle(x: f32, y: f32, w: f32, h: f32, col: i32) { } } +export fn rectangle_outline(x: f32, y: f32, w: f32, h: f32, col: i32) { + let xl = nearest(x) as i32; + let xr = nearest(x + w) as i32; + let yt = nearest(y) as i32; + let yb = nearest(y + h) as i32; + + hline(xl, xr, yt, col); + if yt < yb { + hline(xl, xr, yb - 1, col); + + loop y { + setPixel(xl, yt, col); + if xl < xr { + setPixel(xr - 1, yt, col); + } + branch_if (yt := yt + 1) < yb: y; + } + } +} + export fn circle(cx: f32, cy: f32, radius: f32, col: i32) { let y = clamp(nearest(cy - radius) as i32, 0, 240); let maxY = clamp(nearest(cy + radius) as i32, 0, 240); diff --git a/uw8-tool/src/base_module.rs b/uw8-tool/src/base_module.rs index c59a93b..d2e5588 100644 --- a/uw8-tool/src/base_module.rs +++ b/uw8-tool/src/base_module.rs @@ -89,6 +89,9 @@ impl BaseModule { add_function(&mut functions, &type_map, "setBackgroundColor", &[I32], None); add_function(&mut functions, &type_map, "setCursorPosition", &[I32, I32], None); + add_function(&mut functions, &type_map, "rectangle_outline", &[F32, F32, F32, F32, I32], None); + add_function(&mut functions, &type_map, "circle_outline", &[F32, F32, F32, I32], None); + for i in functions.len()..64 { add_function( &mut functions,