diff options
author | Kartik Agaram <vc@akkartik.com> | 2021-02-07 23:45:31 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2021-02-07 23:45:31 -0800 |
commit | bfcf5c7252302c27c2b07b900063fdb547de7987 (patch) | |
tree | 9f396159c0ebfc3b1e6886cd86cfa389fe381a73 /baremetal/500text-screen.mu | |
parent | 0be63b75c29306ecf70eb8024a6a3b1711f4a225 (diff) | |
download | mu-bfcf5c7252302c27c2b07b900063fdb547de7987.tar.gz |
7698 - starting to test-drive baremetal shell
Diffstat (limited to 'baremetal/500text-screen.mu')
-rw-r--r-- | baremetal/500text-screen.mu | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/baremetal/500text-screen.mu b/baremetal/500text-screen.mu index 88ebc104..050cf4db 100644 --- a/baremetal/500text-screen.mu +++ b/baremetal/500text-screen.mu @@ -90,8 +90,17 @@ fn draw-grapheme screen: (addr screen), g: grapheme, x: int, y: int, color: int, copy-to *dest-color, src-color } +# not really needed for a real screen, though it shouldn't do any harm fn screen-cell-index screen-on-stack: (addr screen), x: int, y: int -> _/ecx: int { var screen/esi: (addr screen) <- copy screen-on-stack + # only one bounds check isn't automatically handled + { + var xmax/eax: (addr int) <- get screen, width + var xcurr/ecx: int <- copy x + compare xcurr, *xmax + break-if-< + abort "tried to print out of screen bounds" + } var height-addr/eax: (addr int) <- get screen, height var result/ecx: int <- copy y result <- multiply *height-addr |