diff options
-rw-r--r-- | 103screen.subx | 4 | ||||
-rw-r--r-- | apps/browse.mu | 17 |
2 files changed, 11 insertions, 10 deletions
diff --git a/103screen.subx b/103screen.subx index 328b1151..419292c7 100644 --- a/103screen.subx +++ b/103screen.subx @@ -39,8 +39,6 @@ screen-size: # -> nrows/eax: int, ncols/ecx: int 55/push-ebp 89/<- %ebp 4/r32/esp # . save registers - 50/push-eax - 51/push-ecx 52/push-edx 53/push-ebx 56/push-esi @@ -69,8 +67,6 @@ $screen-size:end: 5e/pop-to-esi 5b/pop-to-ebx 5a/pop-to-edx - 59/pop-to-ecx - 58/pop-to-eax # . epilogue 89/<- %esp 5/r32/ebp 5d/pop-to-ebp 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) { |