Pārlūkot izejas kodu

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 pirms 3 gadiem
vecāks
revīzija
2d54c3243d
3 mainītis faili ar 13 papildinājumiem un 5 dzēšanām
  1. +5
    -4
      blk/402
  2. +1
    -1
      blk/403
  3. +7
    -0
      doc/protocol.txt

+ 5
- 4
blk/402 Parādīt failu

@@ -1,10 +1,11 @@
: XYPOS [ GRID_MEM LITN ] ; : XYPOS [ GRID_MEM LITN ] ;
: _cl* COLS LINES * ; : _cl* COLS LINES * ;
: AT-XY ( x y -- ) LINES * + _cl* MOD XYPOS ! ; : 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 : _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- : _bs 0 ( blank ) XYPOS @ TUCK CELL! ( pos ) 1-
_cl* MOD XYPOS ! ; _cl* MOD XYPOS ! ;

+ 1
- 1
blk/403 Parādīt failu

@@ -3,4 +3,4 @@
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+ _cl* MOD XYPOS ! ;
XYPOS @ 1+ DUP COLS MOD IF XYPOS ! ELSE _lf THEN ;

+ 7
- 0
doc/protocol.txt Parādīt failu

@@ -46,6 +46,9 @@ COLS -- n Number of columns in the device
LINES -- n Number of lines in the device LINES -- n Number of lines in the device
CELL! g pos -- Set glyph at pos 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 "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.


@@ -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. number of glyphs in the font, it's up to CELL! to ignore it.


Glyph 0 is always blank. 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.

Notiek ielāde…
Atcelt
Saglabāt