1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-24 14:28:06 +11:00

grid: change the meaning of CELL!

Replace the "g" arg (glyph) with "c" (character). The reason why "g"
was used was to save a "0x20 -" operation at all CELL! implementations,
but this came with too big a drawback: it made CELL! hardly usable
outside of the Grid subsystem, mostly because the user of CELL! would
often have to do "0x20 -".

For example, I want the SMS's Pad driver to use CELL! directly instead
of having to do EMIT+XYPOS-messing-around. I would have had to do a
"0x20 -" there.
This commit is contained in:
Virgil Dupras 2020-11-16 09:11:47 -05:00
parent 7bfec5d9e9
commit b1e162b8a3
7 changed files with 19 additions and 19 deletions

View File

@ -15,7 +15,7 @@ $(SMSROM):
$(BLKPACK):
$(MAKE) -C ../tools
blkfs: $(BLKPACK)
blkfs: $(BLKPACK) $(BASE)/blk.fs blk.fs
cat $(BASE)/blk.fs blk.fs | $(BLKPACK) > $@
$(STAGE):

View File

@ -27,9 +27,9 @@ always stay zero. )
: _sfont ( a -- Send font to VDP )
7 0 DO C@+ _data 3 _zero LOOP DROP
( blank row ) 4 _zero ;
: CELL! ( tilenum pos )
2 * 0x7800 OR _ctl ( tilenum )
0x5e MOD _data 1 _zero ;
: CELL! ( c pos )
2 * 0x7800 OR _ctl ( c )
0x20 - ( glyph ) 0x5e MOD _data 0 _data ;
( ----- 604 )
: VDP$
9 0 DO _idat I 2 * + @ _ctl LOOP _blank

View File

@ -15,7 +15,7 @@ $(TARGET): xcomp.fs $(STAGE) blkfs
$(BLKPACK):
$(MAKE) -C ../tools
blkfs: $(BLKPACK)
blkfs: $(BLKPACK) $(BASE)/blk.fs blk.fs
cat $(BASE)/blk.fs blk.fs | $(BLKPACK) > $@
$(STAGE):

View File

@ -110,9 +110,9 @@ CODE _wait
( ----- 609 )
: _atrow! ( pos -- ) COLS / FNTH 1+ * _row! ;
: _tocol ( pos -- col off ) COLS MOD FNTW 1+ * 8 /MOD ;
: CELL! ( g pos -- )
DUP _atrow! DUP _tocol _col! ROT ( pos coff g )
FNTH * ~FNT + ( pos coff a )
: CELL! ( c pos -- )
DUP _atrow! DUP _tocol _col! ROT ( pos coff c )
0x20 - FNTH * ~FNT + ( pos coff a )
_xinc _data@ DROP
FNTH 0 DO ( pos coff a )
C@+ 2 PICK 8 -^ LSHIFT

10
blk.fs
View File

@ -2218,7 +2218,7 @@ Load range: B402-B403
: XYPOS! COLS LINES * MOD DUP CURSOR! XYPOS ! ;
: AT-XY ( x y -- ) COLS * + XYPOS! ;
'? NEWLN NIP NOT [IF]
: NEWLN ( ln -- ) COLS * DUP COLS + SWAP DO 0 I CELL! LOOP ;
: NEWLN ( ln -- ) COLS * DUP COLS + SWAP DO 0x20 I CELL! LOOP ;
[THEN]
: _lf XYMODE C@ IF EXIT THEN
XYPOS @ COLS / 1+ LINES MOD DUP NEWLN
@ -2228,7 +2228,7 @@ Load range: B402-B403
: (emit)
DUP 0x08 = IF DROP _bs EXIT THEN
DUP 0x0d = IF DROP _lf EXIT THEN
0x20 - DUP 0< IF DROP EXIT THEN
DUP 0x20 < IF DROP EXIT THEN
XYPOS @ CELL!
XYPOS @ 1+ DUP COLS MOD IF XYPOS! ELSE _lf THEN ;
: GRID$ 0 XYPOS! 0 XYMODE C! ;
@ -2795,15 +2795,15 @@ them. We insert a blank one at the end of those 7. )
: _sfont ( a -- Send font to TMS )
7 0 DO C@+ _data LOOP DROP
( blank row ) 0 _data ;
: CELL! ( tilenum pos )
: CELL! ( c pos )
0x7800 OR _ctl ( tilenum )
0x5e MOD _data ;
0x20 - ( glyph ) 0x5e MOD _data ;
: COLS 40 ; : LINES 24 ;
: TMS$
0x8100 _ctl ( blank screen ) _blank
0x4000 _ctl 0x5e 0 DO ~FNT I 7 * + _sfont LOOP
0x820e _ctl ( name table 0x3800 )
0x8400 _ctl ( patter table 0x0000 )
0x8400 _ctl ( pattern table 0x0000 )
0x87f0 _ctl ( colors 0 and 1 )
0x8000 _ctl 0x81d0 _ctl ( text mode, display on ) ;
( ----- 520 )

View File

@ -1,6 +1,6 @@
: COLS 80 ; : LINES 32 ;
: CURSOR! ( pos -- ) COLS /MOD 6 PC! ( y ) 5 PC! ( x ) ;
: CELL! ( g pos -- ) CURSOR! 0x20 + 0 PC! ;
: CELL! ( c pos -- ) CURSOR! 0 PC! ;
: NEWLN ( ln -- ) DROP 0xa 0 PC! ;
SYSVARS 0x70 + CONSTANT GRID_MEM

View File

@ -44,7 +44,7 @@ allows random access to it.
COLS -- n Number of columns in the device
LINES -- n Number of lines in the device
CELL! g pos -- Set glyph at pos
CELL! c pos -- Set character at pos
Optional:
NEWLN ln -- "Enter" line ln
@ -53,10 +53,10 @@ CURSOR! pos -- Set cursor's position
"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.
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.
CELL! is not expected to be called with an out-of-range char-
acter. For example, glyphs are often mapped starting at 0x20
(space). On most systems, CELL! should not be called with c <
0x20.If it is, CELL! should do nothing.
NEWLN is called when we "enter" a new line, that is, when we
overflow from previous line or when 0x0d ( ASCII CR ) is emit-