From 82fdf176c1209ccc170fb2c9528cb7254c24bf83 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 12 Jun 2021 21:02:50 -0700 Subject: snapshot Looks like what's slowing down screen rendering is in fact _font_ rendering. --- 500fake-screen.mu | 30 +++++++++++++++++++++++++++++- hest-life.mu | 2 +- shell/sandbox.mu | 53 +++++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 71 insertions(+), 14 deletions(-) diff --git a/500fake-screen.mu b/500fake-screen.mu index 641a8d4b..88c5399a 100644 --- a/500fake-screen.mu +++ b/500fake-screen.mu @@ -545,8 +545,36 @@ fn pixel-index _screen: (addr screen), x: int, y: int -> _/ecx: int { # double-buffering primitive # 'screen' must be a fake screen. 'target-screen' is usually real. # Both screens must have the same size. -fn copy-pixels _screen: (addr screen), target-screen: (addr screen) { +fn copy-screen _screen: (addr screen), target-screen: (addr screen) { var screen/esi: (addr screen) <- copy _screen + # copy graphemes + var width-a/edi: (addr int) <- get screen, width + var height-a/ebx: (addr int) <- get screen, height + var y/edx: int <- copy 0 + { + compare y, *height-a + break-if->= + var x/ecx: int <- copy 0 + { + compare x, *width-a + break-if->= + var g: grapheme + var tmp/eax: grapheme <- screen-grapheme-at screen, x, y + copy-to g, tmp + var fg: int + var tmp/eax: int <- screen-color-at screen, x, y + copy-to fg, tmp + var bg: int + tmp <- screen-background-color-at screen, x, y + copy-to bg, tmp + draw-grapheme target-screen, g, x, y, fg, bg + x <- increment + loop + } + y <- increment + loop + } + # copy pixels var pixels-ah/eax: (addr handle array byte) <- get screen, pixels var _pixels/eax: (addr array byte) <- lookup *pixels-ah var pixels/edi: (addr array byte) <- copy _pixels diff --git a/hest-life.mu b/hest-life.mu index e2e4ca64..1ca5923f 100644 --- a/hest-life.mu +++ b/hest-life.mu @@ -28,7 +28,7 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) var second-screen/edi: (addr screen) <- address second-buffer initialize-screen second-screen, 0x80, 0x30, 1/include-pixels render second-screen, env - copy-pixels second-screen, screen + copy-screen second-screen, screen { edit keyboard, env var play?/eax: (addr boolean) <- get env, play? diff --git a/shell/sandbox.mu b/shell/sandbox.mu index aa082349..1a72641d 100644 --- a/shell/sandbox.mu +++ b/shell/sandbox.mu @@ -257,25 +257,54 @@ fn render-empty-screen screen: (addr screen), _target-screen: (addr screen), xmi fn render-screen screen: (addr screen), _target-screen: (addr screen), xmin: int, ymin: int -> _/ecx: int { var target-screen/esi: (addr screen) <- copy _target-screen - var to-y/edi: int <- copy ymin # text data - var width/ebx: (addr int) <- get target-screen, width - var height/edx: (addr int) <- get target-screen, height - var from-y/ecx: int <- copy 0 + var width-a/eax: (addr int) <- get target-screen, width + var width/eax: int <- copy *width-a + var xmax: int + copy-to xmax, width + var tmp/eax: int <- copy xmin + add-to xmax, tmp + var height-a/eax: (addr int) <- get target-screen, height + var height/eax: int <- copy *height-a + var ymax: int + copy-to ymax, height + var tmp/eax: int <- copy ymin + add-to ymax, tmp + clear-rect screen, xmin, ymin, xmax, ymax, 0/bg + var data-ah/eax: (addr handle array screen-cell) <- get target-screen, data + var data/eax: (addr array screen-cell) <- lookup *data-ah + var index/ecx: int <- copy 0 + var to-y/edi: int <- copy ymin { - compare from-y, *height + compare to-y, ymax break-if->= - var from-x/edx: int <- copy 0 - var to-x/eax: int <- copy xmin + var to-x/ebx: int <- copy xmin { - compare from-x, *width + compare to-x, xmax break-if->= - print-screen-cell-of-fake-screen screen, target-screen, from-x, from-y, to-x, to-y - from-x <- increment + $render-screen:iter: { + var offset/ecx: (offset screen-cell) <- compute-offset data, index + var src-cell/edx: (addr screen-cell) <- index data, offset + var src-grapheme/eax: (addr grapheme) <- get src-cell, data + var src-fg/ecx: (addr int) <- get src-cell, color + var src-bg/edx: (addr int) <- get src-cell, background-color + { + compare *src-grapheme, 0x20 + break-if-!= + compare *src-bg, 0 + break-if-!= + break $render-screen:iter + } + abort "aa" + draw-grapheme-on-real-screen *src-grapheme, to-x, to-y, *src-fg, *src-bg +#? var foo/eax: int <- count-of-events +#? draw-grapheme-on-real-screen 0x20/space, to-x, to-y, *src-fg, foo +#? count-event + } + index <- increment to-x <- increment loop } - from-y <- increment to-y <- increment loop } @@ -329,7 +358,7 @@ fn render-screen screen: (addr screen), _target-screen: (addr screen), xmin: int loop } } - return to-y + return ymax } fn has-keyboard? _self: (addr sandbox) -> _/eax: boolean { -- cgit 1.4.1-2-gfad0