about summary refs log tree commit diff stats
path: root/ex11.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-05-16 08:27:24 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-05-16 08:27:24 -0700
commit4d17068bc0a82dfa189ac9f8aa88dc0e1f741d9c (patch)
treefe6604916240a5a1ba77a1403e81b9533c31e725 /ex11.mu
parent5e484fb2d53bfdaa4394ada4927d80a91008d600 (diff)
downloadmu-4d17068bc0a82dfa189ac9f8aa88dc0e1f741d9c.tar.gz
.
Diffstat (limited to 'ex11.mu')
-rw-r--r--ex11.mu30
1 files changed, 29 insertions, 1 deletions
diff --git a/ex11.mu b/ex11.mu
index 9b11c606..b62ff237 100644
--- a/ex11.mu
+++ b/ex11.mu
@@ -3,7 +3,7 @@
 fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
   var env-storage: environment
   var env/esi: (addr environment) <- address env-storage
-  initialize-environment env, 5 5, 0x80 0x100, 0x200 0x140
+  initialize-environment env, 0x10 0x10, 0x80 0x100, 0x200 0x140
   render screen, env
 }
 
@@ -39,6 +39,10 @@ fn render screen: (addr screen), _self: (addr environment) {
   disc    screen, p0,           3/radius, 7/color   0xf/border
   disc    screen, p1,           3/radius, 7/color   0xf/border
   disc    screen, p2,           3/radius, 7/color   0xf/border
+  # cursor last of all
+  var cursor-ah/eax: (addr handle point) <- get self, cursor
+  var cursor/eax: (addr point) <- lookup *cursor-ah
+  cursor screen, cursor, 0xa/side, 3/color
 }
 
 fn bezier screen: (addr screen), _p0: (addr point), _p1: (addr point), _p2: (addr point), color: int {
@@ -54,6 +58,30 @@ fn bezier screen: (addr screen), _p0: (addr point), _p1: (addr point), _p2: (add
   draw-monotonic-bezier screen, *x0 *y0, *x1 *y1, *x2 *y2, color
 }
 
+fn cursor screen: (addr screen), _p: (addr point), side: int, color: int {
+  var half-side/eax: int <- copy side
+  half-side <- shift-right 1
+  var p/esi: (addr point) <- copy _p
+  var x-a/ecx: (addr int) <- get p, x
+  var left-x/ecx: int <- copy *x-a
+  left-x <- subtract half-side
+  var y-a/edx: (addr int) <- get p, y
+  var top-y/edx: int <- copy *y-a
+  top-y <- subtract half-side
+  var max/eax: int <- copy left-x
+  max <- add side
+  draw-horizontal-line screen, top-y, left-x, max, color
+  max <- copy top-y
+  max <- add side
+  draw-vertical-line screen, left-x, top-y, max, color
+  var right-x/ebx: int <- copy left-x
+  right-x <- add side
+  draw-vertical-line screen, right-x, top-y, max, color
+  var bottom-y/edx: int <- copy top-y
+  bottom-y <- add side
+  draw-horizontal-line screen, bottom-y, left-x, right-x, color
+}
+
 fn line screen: (addr screen), _p0: (addr point), _p1: (addr point), color: int {
   var p0/esi: (addr point) <- copy _p0
   var x0/ecx: (addr int) <- get p0, x