Quellcode durchsuchen

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.
master
Virgil Dupras vor 3 Jahren
Ursprung
Commit
7bfec5d9e9
3 geänderte Dateien mit 14 neuen und 9 gelöschten Zeilen
  1. +7
    -7
      blk.fs
  2. +2
    -2
      cvm/forth.fs
  3. +5
    -0
      doc/protocol.txt

+ 7
- 7
blk.fs Datei anzeigen

@@ -2214,24 +2214,24 @@ 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 ! ;
COLS * XYPOS! ;
: _bs 0 ( blank ) XYPOS @ TUCK CELL! ( pos ) 1- XYPOS! ;
( ----- 403 )
: (emit)
DUP 0x08 = IF DROP _bs EXIT THEN
DUP 0x0d = IF DROP _lf EXIT THEN
0x20 - DUP 0< IF DROP EXIT THEN
XYPOS @ CELL!
XYPOS @ 1+ DUP COLS MOD IF XYPOS ! ELSE _lf THEN ;
: GRID$ 0 XYPOS ! 0 XYMODE C! ;
XYPOS @ 1+ DUP COLS MOD IF XYPOS! ELSE _lf THEN ;
: GRID$ 0 XYPOS! 0 XYMODE C! ;
( ----- 410 )
PS/2 keyboard subsystem



+ 2
- 2
cvm/forth.fs Datei anzeigen

@@ -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


+ 5
- 0
doc/protocol.txt Datei anzeigen

@@ -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).

Laden…
Abbrechen
Speichern