浏览代码

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 3 年前
父节点
当前提交
7bfec5d9e9
共有 3 个文件被更改,包括 14 次插入9 次删除
  1. +7
    -7
      blk.fs
  2. +2
    -2
      cvm/forth.fs
  3. +5
    -0
      doc/protocol.txt

+ 7
- 7
blk.fs 查看文件

@@ -2214,24 +2214,24 @@ See doc/grid.txt.
Load range: B402-B403 Load range: B402-B403
( ----- 402 ) ( ----- 402 )
: XYPOS [ GRID_MEM LITN ] ; : XYMODE [ GRID_MEM LITN ] 2+ ; : 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 NIP NOT [IF]
: NEWLN ( ln -- ) COLS * DUP COLS + SWAP DO 0 I CELL! LOOP ; : NEWLN ( ln -- ) COLS * DUP COLS + SWAP DO 0 I CELL! LOOP ;
[THEN] [THEN]
: _lf XYMODE C@ IF EXIT THEN : _lf XYMODE C@ IF EXIT THEN
XYPOS @ COLS / 1+ LINES MOD DUP NEWLN 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 ) ( ----- 403 )
: (emit) : (emit)
DUP 0x08 = IF DROP _bs EXIT THEN DUP 0x08 = IF DROP _bs EXIT THEN
DUP 0x0d = IF DROP _lf EXIT THEN DUP 0x0d = IF DROP _lf EXIT THEN
0x20 - DUP 0< IF DROP EXIT THEN 0x20 - DUP 0< IF DROP EXIT THEN
XYPOS @ CELL! 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 ) ( ----- 410 )
PS/2 keyboard subsystem PS/2 keyboard subsystem




+ 2
- 2
cvm/forth.fs 查看文件

@@ -1,6 +1,6 @@
: COLS 80 ; : LINES 32 ; : 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! ; : NEWLN ( ln -- ) DROP 0xa 0 PC! ;


SYSVARS 0x70 + CONSTANT GRID_MEM SYSVARS 0x70 + CONSTANT GRID_MEM


+ 5
- 0
doc/protocol.txt 查看文件

@@ -48,6 +48,7 @@ CELL! g pos -- Set glyph at pos


Optional: Optional:
NEWLN ln -- "Enter" line ln NEWLN ln -- "Enter" line ln
CURSOR! pos -- Set cursor's position


"pos" is a simple number (y * cols) + x. For example, if we "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. 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! If it's not defined, the grid system uses multiple CELL!
calls to clear it. On some devices, this is highly inefficient. calls to clear it. On some devices, this is highly inefficient.
Drivers for those devices should define NEWLINE. 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).

正在加载...
取消
保存