commit d04d4156875db61ec974555347523d3a3dc0d3cb
parent 4696d352b148baf5cfeab7825d3f6f8593f63487
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Thu, 28 Jul 2022 12:47:30 -0400
drv/vga: add scrolling
This is a bruteforce memory copying scroll. I've played a bit with VGA window
panning, it worked, but I had problems when getting towards the end of VGA
memory and having to wrap around. I was debugging this when it occurred to me
that the Dusk console will likely have some tmux-like status bar and widgets and
that this will conflict with VGA window panning anyways, so let's just
bruteforce the thing for now.
Diffstat:
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/fs/drv/pc/vga.fs b/fs/drv/pc/vga.fs
@@ -1,10 +1,16 @@
\ Video driver for PC's 80x25 mode
-$b8000 const _membase
+$b8000 const _mem(
80 const COLS
25 const LINES
-: cell! ( c pos -- ) << _membase + swap $700 or swap w! ;
+: cell! ( c pos -- ) << _mem( + swap $700 or swap w! ;
-: cursor! ( pos -- )
- $0f $3d4 pc! dup $3d5 pc! $0e $3d4 pc! 8 rshift $3d5 pc! ;
+: vgareg@ ( idx -- c ) $3d4 pc! $3d5 pc@ ;
+: vgareg! ( c idx -- ) $3d4 pc! $3d5 pc! ;
+: cursor! ( pos -- ) dup $0f vgareg! 8 rshift $0e vgareg! ;
+: scroll ( -- )
+ _mem( COLS << + ( src ) _mem( ( src dst ) COLS LINES 1- * << ( src dst u )
+ move ;
+: newln ( oldln -- newln )
+ dup LINES 1- = if scroll else 1+ then ;
diff --git a/fs/sys/grid.fs b/fs/sys/grid.fs
@@ -7,7 +7,7 @@
: clrline ( ln -- ) COLS * COLS >r begin ( pos ) SPC over cell! 1+ next drop ;
: linefeed ( -- )
- gridpos COLS / 1+ LINES mod dup clrline COLS * pos! ;
+ gridpos COLS / newln dup clrline COLS * pos! ;
: (emit) ( c -- ) case
8 ( BS ) of = SPC pcell! gridpos 1- pos! endof