about summary refs log tree commit diff stats
path: root/shell/cell.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-04-10 15:59:40 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-04-10 15:59:40 -0700
commit97cffa20d4d847c76ae58c44a265ffd31dfb13a2 (patch)
tree217ce519fc5fd245bdc50009b54808095a449e6d /shell/cell.mu
parent1d724f926031a73dc2e6af18b6731593a548526c (diff)
downloadmu-97cffa20d4d847c76ae58c44a265ffd31dfb13a2.tar.gz
shell: start of 'print' primitive
Diffstat (limited to 'shell/cell.mu')
-rw-r--r--shell/cell.mu19
1 files changed, 19 insertions, 0 deletions
diff --git a/shell/cell.mu b/shell/cell.mu
index 1aed590d..11a16821 100644
--- a/shell/cell.mu
+++ b/shell/cell.mu
@@ -10,6 +10,8 @@ type cell {
   text-data: (handle stream byte)
   # type 4: primitive function
   index-data: int
+  # type 5: screen
+  screen-data: (handle screen)
   # TODO: array, (associative) table, stream
 }
 
@@ -114,3 +116,20 @@ fn new-primitive-function out: (addr handle cell), n: int {
   allocate-primitive-function out
   initialize-primitive-function out, n
 }
+
+fn allocate-screen _out: (addr handle cell) {
+  var out/eax: (addr handle cell) <- copy _out
+  allocate out
+  var out-addr/eax: (addr cell) <- lookup *out
+  var type/ecx: (addr int) <- get out-addr, type
+  copy-to *type, 5/screen
+}
+
+fn new-screen _out: (addr handle cell), width: int, height: int {
+  var out/eax: (addr handle cell) <- copy _out
+  allocate-screen out
+  var out-addr/eax: (addr cell) <- lookup *out
+  var dest-ah/eax: (addr handle screen) <- get out-addr, screen-data
+  var dest-addr/eax: (addr screen) <- lookup *dest-ah
+  initialize-screen dest-addr, width, height
+}