diff --git a/build.zig b/build.zig index 93e8250..214a659 100644 --- a/build.zig +++ b/build.zig @@ -58,24 +58,12 @@ pub fn build(b: *Build) void { const feature_test_cart = add_cart(&dep, b, .{ .name = "feature_test", .optimize = optimize, - .root_source_file = b.path("samples/feature_test.zig"), + .root_source_file = b.path("src/badge/feature_test.zig"), }); feature_test_cart.install(b); const watch_run_step = feature_test_cart.install_with_watcher(&dep, b, .{}); - //{ - // const cart = add_cart(&dep, b, .{ - // .name = "blobs", - // .optimize = .ReleaseSmall, - // .root_source_file = .{ .path = "samples/blobs/blobs.zig" }, - // }); - // cart.install(b); - // b.step("watch-blobs", "Watch/run blobs in the simulator").dependOn( - // &cart.install_with_watcher(&dep, b, .{}).step, - // ); - //} - - const watch_step = b.step("watch", ""); + const watch_step = b.step("feature-test", ""); watch_step.dependOn(&watch_run_step.step); inline for (.{ diff --git a/docs/introduction/src/hello.zig b/docs/introduction/src/hello.zig index 3200ab3..5cf0cdf 100644 --- a/docs/introduction/src/hello.zig +++ b/docs/introduction/src/hello.zig @@ -147,11 +147,11 @@ fn scene_game() void { fn set_background() void { const ratio = (4095 - @as(f32, @floatFromInt(cart.light_level.*))) / 4095 * 0.2; - @memset(cart.framebuffer, cart.DisplayColor{ + @memset(@as(*volatile [cart.screen_width * cart.screen_height]cart.Pixel, @ptrCast(cart.framebuffer)), cart.Pixel.fromColor(.{ .r = @intFromFloat(ratio * 31), .g = @intFromFloat(ratio * 63), .b = @intFromFloat(ratio * 31), - }); + })); } fn check_win() bool { diff --git a/samples/feature_test.zig b/src/badge/feature_test.zig similarity index 99% rename from samples/feature_test.zig rename to src/badge/feature_test.zig index 458fa2d..d221bb0 100644 --- a/samples/feature_test.zig +++ b/src/badge/feature_test.zig @@ -1,3 +1,5 @@ +//! Test all features at once! + const std = @import("std"); const cart = @import("cart-api"); diff --git a/src/cart/api.zig b/src/cart/api.zig index da4a6fb..4e56e4f 100644 --- a/src/cart/api.zig +++ b/src/cart/api.zig @@ -51,9 +51,11 @@ pub const Pixel = extern struct { pub fn fromColor(color: DisplayColor) Pixel { return .{ .bits = @byteSwap(@as(u16, @bitCast(color))) }; } + pub fn toColor(pixel: Pixel) DisplayColor { return @bitCast(@byteSwap(pixel.bits)); } + pub fn setColor(pixel: *volatile Pixel, color: DisplayColor) void { pixel.* = fromColor(color); }