1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 09:08:06 +11:00

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.
This commit is contained in:
Virgil Dupras 2020-11-10 19:19:44 -05:00
parent e0bcf3473e
commit 2d54c3243d
3 changed files with 13 additions and 5 deletions

View File

@ -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 ) XYPOS @ COLS / 1+ DUP CLRLN
0 ( blank ) SWAP TUCK CELL! COLS * _cl* MOD XYPOS ! ;
1+ DUP COLS MOD NOT UNTIL
_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 ! ;

View File

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

View File

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