grid: Add CURSOR! to the grid protocol

With the move of CVM's forth to the grid protocol, we've lost the
cursor's visual indication. Now, we have it back.

The challenge now is in implementing it in SMS' text mode. In mode
4, it's easy to mark a cell as inverted, but in text mode, that's
not possible.
This commit is contained in:
Virgil Dupras 2020-11-16 08:41:09 -05:00
parent d3049b2404
commit 7bfec5d9e9
3 changed files with 14 additions and 9 deletions

8
blk.fs
View File

@ -2214,16 +2214,16 @@ See doc/grid.txt.
Load range: B402-B403
( ----- 402 )
: XYPOS [ GRID_MEM LITN ] ; : XYMODE [ GRID_MEM LITN ] 2+ ;
: _cl* COLS LINES * ;
: AT-XY ( x y -- ) COLS * + _cl* MOD XYPOS ! ;
'? CURSOR! NIP NOT [IF] : CURSOR! DROP ; [THEN]
: XYPOS! COLS LINES * MOD DUP CURSOR! XYPOS ! ;
: AT-XY ( x y -- ) COLS * + XYPOS! ;
'? NEWLN NIP NOT [IF]
: NEWLN ( ln -- ) COLS * DUP COLS + SWAP DO 0 I CELL! LOOP ;
[THEN]
: _lf XYMODE C@ IF EXIT THEN
XYPOS @ COLS / 1+ LINES MOD DUP NEWLN
COLS * XYPOS! ;
: _bs 0 ( blank ) XYPOS @ TUCK CELL! ( pos ) 1-
_cl* MOD XYPOS ! ;
: _bs 0 ( blank ) XYPOS @ TUCK CELL! ( pos ) 1- XYPOS! ;
( ----- 403 )
: (emit)
DUP 0x08 = IF DROP _bs EXIT THEN

View File

@ -1,6 +1,6 @@
: COLS 80 ; : LINES 32 ;
: CELL! ( g pos -- )
COLS /MOD 6 PC! ( y ) 5 PC! ( x ) 0x20 + 0 PC! ;
: CURSOR! ( pos -- ) COLS /MOD 6 PC! ( y ) 5 PC! ( x ) ;
: CELL! ( g pos -- ) CURSOR! 0x20 + 0 PC! ;
: NEWLN ( ln -- ) DROP 0xa 0 PC! ;
SYSVARS 0x70 + CONSTANT GRID_MEM

View File

@ -48,6 +48,7 @@ CELL! g pos -- Set glyph at pos
Optional:
NEWLN ln -- "Enter" line ln
CURSOR! pos -- Set cursor's position
"pos" is a simple number (y * cols) + x. For example, if we
have 40 columns per line, the position (x, y) (12, 10) is 412.
@ -69,3 +70,7 @@ time.
If it's not defined, the grid system uses multiple CELL!
calls to clear it. On some devices, this is highly inefficient.
Drivers for those devices should define NEWLINE.
CURSOR! is called whenever we change the cursor's position. If
not implemented, it will be a noop. It is never called with an
out of range "pos" (greater than COLS*LINES).