From 35791408748afcf3a461f65f897f7f491e6a7f40 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 7 Sep 2020 23:04:23 -0700 Subject: 6754 --- apps/browse/main.mu | 2 +- apps/browse/paginated-screen.mu | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/browse/main.mu b/apps/browse/main.mu index 611de7f3..e7fea617 100644 --- a/apps/browse/main.mu +++ b/apps/browse/main.mu @@ -12,7 +12,7 @@ fn main args: (addr array addr array byte) -> exit-status/ebx: int { # initialize screen state var paginated-screen-storage: paginated-screen var paginated-screen/eax: (addr paginated-screen) <- address paginated-screen-storage - initialize-paginated-screen paginated-screen + initialize-paginated-screen paginated-screen, 0x40 normal-text paginated-screen # { diff --git a/apps/browse/paginated-screen.mu b/apps/browse/paginated-screen.mu index 9da3e4d7..3723cbf3 100644 --- a/apps/browse/paginated-screen.mu +++ b/apps/browse/paginated-screen.mu @@ -6,6 +6,7 @@ type paginated-screen { screen: (handle screen) nrows: int # const ncols: int # const + page-width: int toprow: int botrow: int leftcol: int @@ -14,20 +15,19 @@ type paginated-screen { col: int } -fn initialize-fake-paginated-screen _self: (addr paginated-screen), nrows: int, ncols: int { +fn initialize-fake-paginated-screen _self: (addr paginated-screen), nrows: int, ncols: int, page-width: int { var self/esi: (addr paginated-screen) <- copy _self var screen-ah/eax: (addr handle screen) <- get self, screen allocate screen-ah var screen-addr/eax: (addr screen) <- lookup *screen-ah initialize-screen screen-addr, nrows, ncols - initialize-paginated-screen self + initialize-paginated-screen self, page-width } -fn initialize-paginated-screen _self: (addr paginated-screen) { +fn initialize-paginated-screen _self: (addr paginated-screen), page-width: int { # hardcoded parameters: # top-margin # page-margin - # page-width var self/esi: (addr paginated-screen) <- copy _self var screen-ah/eax: (addr handle screen) <- get self, screen var _screen-addr/eax: (addr screen) <- lookup *screen-ah @@ -42,6 +42,12 @@ fn initialize-paginated-screen _self: (addr paginated-screen) { # self->ncols = ncols dest <- get self, ncols copy-to *dest, ncols + # self->page-width = page-width + { + var pg/eax: int <- copy page-width + dest <- get self, page-width + copy-to *dest, pg + } # self->toprow = top-margin dest <- get self, toprow copy-to *dest, 2 # top-margin @@ -131,6 +137,7 @@ fn next-line _self: (addr paginated-screen) { fn next-page _self: (addr paginated-screen) { var self/esi: (addr paginated-screen) <- copy _self + var pg/edi: (addr int) <- get self, page-width var tmp/eax: (addr int) <- copy 0 var tmp2/ecx: int <- copy 0 #? # temporary: stop @@ -147,7 +154,7 @@ fn next-page _self: (addr paginated-screen) { copy-to *tmp, tmp2 # self->rightcol = self->leftcol + page-width tmp2 <- copy *tmp - tmp2 <- add 0x40 # page-width + tmp2 <- add *pg tmp <- get self, rightcol copy-to *tmp, tmp2 # self->row = self->toprow -- cgit 1.4.1-2-gfad0