diff --git a/blk/402 b/blk/402 index ac94de5..67a9a87 100644 --- a/blk/402 +++ b/blk/402 @@ -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 ! ; diff --git a/blk/403 b/blk/403 index 284a357..0d8ab68 100644 --- a/blk/403 +++ b/blk/403 @@ -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 ; diff --git a/doc/protocol.txt b/doc/protocol.txt index f9caf31..50c913f 100644 --- a/doc/protocol.txt +++ b/doc/protocol.txt @@ -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.