diff options
author | Kartik Agaram <vc@akkartik.com> | 2021-01-15 20:30:07 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2021-01-15 20:30:07 -0800 |
commit | 6e36ce06dd035408d43a6599b75b933a0709cc78 (patch) | |
tree | b5b90ee59b5387036d311096fed1c96aa588cacb /baremetal/500text-screen.mu | |
parent | 20d6be52405130930fde9ca5bb5e95131ba4e659 (diff) | |
download | mu-6e36ce06dd035408d43a6599b75b933a0709cc78.tar.gz |
7521 - new plan for tests
It's not really manageable to make the fake screen pixel-oriented. Feels excessive to compare things pixel by pixel when we will mostly be writing text to screen. It'll also make expected screen assertions more difficult to manage. So I'm not sure how to make assertions about pixels for now. Instead we'll introduce fake screens at draw-grapheme.
Diffstat (limited to 'baremetal/500text-screen.mu')
-rw-r--r-- | baremetal/500text-screen.mu | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/baremetal/500text-screen.mu b/baremetal/500text-screen.mu new file mode 100644 index 00000000..525ddb03 --- /dev/null +++ b/baremetal/500text-screen.mu @@ -0,0 +1,64 @@ +# Screen primitives for character-oriented output. +# +# Unlike the top-level, this text mode has no scrolling. + +fn draw-grapheme screen: (addr screen), g: grapheme, x: int, y: int, color: int { + { + compare screen, 0 + break-if-!= + draw-grapheme-on-real-screen g, x, y, color + return + } + # TODO: fake screen +} + +fn cursor-position screen: (addr screen) -> _/eax: int, _/ecx: int { + { + compare screen, 0 + break-if-!= + var x/eax: int <- copy 0 + var y/ecx: int <- copy 0 + x, y <- cursor-position-on-real-screen + return x, y + } + # TODO: fake screen + return 0, 0 +} + +fn set-cursor-position screen: (addr screen), x: int, y: int { + { + compare screen, 0 + break-if-!= + set-cursor-position-on-real-screen x, y + return + } + # TODO: fake screen +} + +fn clear-screen screen: (addr screen) { + { + compare screen, 0 + break-if-!= + clear-real-screen + return + } + # TODO: fake screen +} + +fn clear-real-screen { + var y/eax: int <- copy 0 + { + compare y, 0x300 # 768 + break-if->= + var x/edx: int <- copy 0 + { + compare x, 0x400 # 1024 + break-if->= + pixel-on-real-screen x, y, 0 # black + x <- increment + loop + } + y <- increment + loop + } +} |