about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-29 16:20:37 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-29 16:24:31 -0700
commitcb0caab25c66170266a2ad6ad60c077b863aac43 (patch)
tree560d40d82a9c3d72bdefc3d1e4e6b19e7cecfecd /apps
parent77b43b007f08a49ac1fa35ce394e38429da747e6 (diff)
downloadmu-cb0caab25c66170266a2ad6ad60c077b863aac43.tar.gz
6437 - check screen/window dimensions
This was why I was trying to use a different output register: a second
function to call.

And I managed to mess it up again, changing the output of load-file, but
not how it was computed in the body.
Diffstat (limited to 'apps')
-rw-r--r--apps/browse.mu17
1 files changed, 11 insertions, 6 deletions
diff --git a/apps/browse.mu b/apps/browse.mu
index fc391430..a2a25584 100644
--- a/apps/browse.mu
+++ b/apps/browse.mu
@@ -2,11 +2,14 @@
 
 fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
   var filename/eax: (addr array byte) <- first-arg args
-  var file/eax: (addr buffered-file) <- load-file filename
+  var file/esi: (addr buffered-file) <- load-file filename
   enable-screen-grid-mode
+  var nrows/eax: int <- copy 0
+  var ncols/ecx: int <- copy 0
+  nrows, ncols <- screen-size
   enable-keyboard-immediate-mode
   {
-    render file, 0x20, 0x30  # nrows, ncols
+    render file, nrows, ncols
     var key/eax: byte <- read-key
     compare key, 0x71  # 'q'
     loop-if-!=
@@ -16,14 +19,15 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
   exit-status <- copy 0
 }
 
+# decide how to lay out pages on screen
 fn render in: (addr buffered-file), nrows: int, ncols: int {
   # hardcoded parameter: text-width
   var toprow/eax: int <- copy 2
   var botrow/ecx: int <- copy toprow
-  botrow <- add nrows
+  botrow <- add 0x20
   var leftcol/edx: int <- copy 5
   var rightcol/ebx: int <- copy leftcol
-  rightcol <- add ncols
+  rightcol <- add 0x30
   render-page in, toprow, leftcol, botrow, rightcol
 }
 
@@ -80,13 +84,14 @@ fn first-arg args-on-stack: (addr array (addr array byte)) -> out/eax: (addr arr
   out <- copy *result
 }
 
-fn load-file filename: (addr array byte) -> out/eax: (addr buffered-file) {
+fn load-file filename: (addr array byte) -> out/esi: (addr buffered-file) {
   var result: (handle buffered-file)
   {
     var tmp1/eax: (addr handle buffered-file) <- address result
     open filename, 0, tmp1
   }
-  out <- lookup result
+  var tmp2/eax: (addr buffered-file) <- lookup result
+  out <- copy tmp2
 }
 
 fn dump in: (addr buffered-file) {