Sfoglia il codice sorgente

grid: add CLRLN and change _lf behavior

Instead of clearing the rest of the line on a _lf, it's simpler
to just clear any new line we're entering into.
master
Virgil Dupras 3 anni fa
parent
commit
2d54c3243d
3 ha cambiato i file con 13 aggiunte e 5 eliminazioni
  1. +5
    -4
      blk/402
  2. +1
    -1
      blk/403
  3. +7
    -0
      doc/protocol.txt

+ 5
- 4
blk/402 Vedi File

@@ -1,10 +1,11 @@
: XYPOS [ GRID_MEM LITN ] ;
: _cl* COLS LINES * ;
: AT-XY ( x y -- ) LINES * + _cl* MOD XYPOS ! ;
'? CLRLN NIP NOT [IF]
: CLRLN ( ln -- ) COLS * DUP COLS + SWAP DO 0 I CELL! LOOP ;
[THEN]
: _lf
XYPOS @ BEGIN ( pos )
0 ( blank ) SWAP TUCK CELL!
1+ DUP COLS MOD NOT UNTIL
_cl* MOD XYPOS ! ;
XYPOS @ COLS / 1+ DUP CLRLN
COLS * _cl* MOD XYPOS ! ;
: _bs 0 ( blank ) XYPOS @ TUCK CELL! ( pos ) 1-
_cl* MOD XYPOS ! ;

+ 1
- 1
blk/403 Vedi File

@@ -3,4 +3,4 @@
DUP 0x0d = IF DROP _lf EXIT THEN
0x20 - DUP 0< IF DROP EXIT THEN
XYPOS @ CELL!
XYPOS @ 1+ _cl* MOD XYPOS ! ;
XYPOS @ 1+ DUP COLS MOD IF XYPOS ! ELSE _lf THEN ;

+ 7
- 0
doc/protocol.txt Vedi File

@@ -46,6 +46,9 @@ COLS -- n Number of columns in the device
LINES -- n Number of lines in the device
CELL! g pos -- Set glyph at pos

Optional:
CLRLN ln -- Clear line number ln.

"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.

@@ -53,3 +56,7 @@ A glyph is ASCII-0x20. If the resulting glyph number exceeds the
number of glyphs in the font, it's up to CELL! to ignore it.

Glyph 0 is always blank.

If CLRLN is 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 CLRLN.

Loading…
Annulla
Salva