diff --git a/bitplane-thingie.p8 b/bitplane-thingie.p8 index 3cb643f..2ea83a4 100644 --- a/bitplane-thingie.p8 +++ b/bitplane-thingie.p8 @@ -137,6 +137,34 @@ function handle_ui_click(x, y) return end + -- checkboxes: qualify + if (y < 113 or y > 120 or x < 32) return + + if x <= 67 then + x -= 32 + if (x % 9 == 8) return + local box = x \ 9 + --check range + if (box < 0 or box > 3) return + toggle_mask_bit(box) + return + end + + x -= 90 + if (x % 9 == 8) return + local box = x \ 9 + --check range + if (box < 0 or box > 3) return + toggle_mask_bit(box + 4) + return +end + +function toggle_mask_bit(n) + local sel = 1 << n + local b = plane_mask & sel + plane_mask = plane_mask & ~sel + if (b > 0) return + plane_mask = plane_mask | sel end -->8 -- draw_cursor