mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 08:28:06 +11:00
grid: add XYMODE
In VE on the SMS, the first contents line would always be cleared because of NEWLN being called when the FBUF would spit its last char. Inconvenient... I've added a "graphical" mode to the grid subsystem to inhibit this behavior in a graphical situation such as in VE. Also, write a more complete Grid documentation.
This commit is contained in:
parent
7722db0762
commit
d3049b2404
@ -7,11 +7,11 @@ RS_ADDR 0x80 - CONSTANT SYSVARS
|
||||
0xbf CONSTANT TMS_CTLPORT
|
||||
0xbe CONSTANT TMS_DATAPORT
|
||||
SYSVARS 0x70 + CONSTANT GRID_MEM
|
||||
SYSVARS 0x72 + CONSTANT CPORT_MEM
|
||||
SYSVARS 0x73 + CONSTANT CPORT_MEM
|
||||
0x3f CONSTANT CPORT_CTL
|
||||
0xdc CONSTANT CPORT_D1
|
||||
0xdd CONSTANT CPORT_D2
|
||||
SYSVARS 0x73 + CONSTANT PAD_MEM
|
||||
SYSVARS 0x74 + CONSTANT PAD_MEM
|
||||
5 LOAD ( z80 assembler )
|
||||
: ZFILL, ( u ) 0 DO 0 A, LOOP ;
|
||||
262 LOAD ( xcomp )
|
||||
@ -36,6 +36,6 @@ CREATE ~FNT CPFNT7x7
|
||||
(entry) _
|
||||
( Update LATEST )
|
||||
PC ORG @ 8 + !
|
||||
," VDP$ 0 0 AT-XY PAD$ (im1) " EOT,
|
||||
," VDP$ GRID$ PAD$ (im1) " EOT,
|
||||
ORG @ 0x100 - 256 /MOD 2 PC! 2 PC!
|
||||
H@ 256 /MOD 2 PC! 2 PC!
|
||||
|
@ -8,11 +8,11 @@ RS_ADDR 0x80 - CONSTANT SYSVARS
|
||||
0xbf CONSTANT TMS_CTLPORT
|
||||
0xbe CONSTANT TMS_DATAPORT
|
||||
SYSVARS 0x70 + CONSTANT GRID_MEM
|
||||
SYSVARS 0x72 + CONSTANT CPORT_MEM
|
||||
SYSVARS 0x73 + CONSTANT CPORT_MEM
|
||||
0x3f CONSTANT CPORT_CTL
|
||||
0xdc CONSTANT CPORT_D1
|
||||
0xdd CONSTANT CPORT_D2
|
||||
SYSVARS 0x73 + CONSTANT PS2_MEM
|
||||
SYSVARS 0x74 + CONSTANT PS2_MEM
|
||||
5 LOAD ( z80 assembler )
|
||||
: ZFILL, ( u ) 0 DO 0 A, LOOP ;
|
||||
262 LOAD ( xcomp )
|
||||
@ -37,6 +37,6 @@ CREATE ~FNT CPFNT7x7
|
||||
(entry) _
|
||||
( Update LATEST )
|
||||
PC ORG @ 8 + !
|
||||
," VDP$ 0 0 AT-XY PS2$ (im1) " EOT,
|
||||
," VDP$ GRID$ PS2$ (im1) " EOT,
|
||||
ORG @ 0x100 - 256 /MOD 2 PC! 2 PC!
|
||||
H@ 256 /MOD 2 PC! 2 PC!
|
||||
|
@ -9,11 +9,11 @@ RS_ADDR 0x80 - CONSTANT SYSVARS
|
||||
0xbf CONSTANT TMS_CTLPORT
|
||||
0xbe CONSTANT TMS_DATAPORT
|
||||
SYSVARS 0x70 + CONSTANT GRID_MEM
|
||||
SYSVARS 0x72 + CONSTANT CPORT_MEM
|
||||
SYSVARS 0x73 + CONSTANT CPORT_MEM
|
||||
0x3f CONSTANT CPORT_CTL
|
||||
0xdc CONSTANT CPORT_D1
|
||||
0xdd CONSTANT CPORT_D2
|
||||
SYSVARS 0x73 + CONSTANT PS2_MEM
|
||||
SYSVARS 0x74 + CONSTANT PS2_MEM
|
||||
5 LOAD ( z80 assembler )
|
||||
: ZFILL, ( u ) 0 DO 0 A, LOOP ;
|
||||
262 LOAD ( xcomp )
|
||||
@ -40,6 +40,6 @@ CREATE ~FNT CPFNT7x7
|
||||
(entry) _
|
||||
( Update LATEST )
|
||||
PC ORG @ 8 + !
|
||||
," VDP$ 0 0 AT-XY PS2$ BLK$ (im1) " EOT,
|
||||
," VDP$ GRID$ PS2$ BLK$ (im1) " EOT,
|
||||
ORG @ 0x100 - 256 /MOD 2 PC! 2 PC!
|
||||
H@ 256 /MOD 2 PC! 2 PC!
|
||||
|
@ -9,11 +9,11 @@ RS_ADDR 0x80 - CONSTANT SYSVARS
|
||||
0xbf CONSTANT TMS_CTLPORT
|
||||
0xbe CONSTANT TMS_DATAPORT
|
||||
SYSVARS 0x70 + CONSTANT GRID_MEM
|
||||
SYSVARS 0x72 + CONSTANT CPORT_MEM
|
||||
SYSVARS 0x73 + CONSTANT CPORT_MEM
|
||||
0x3f CONSTANT CPORT_CTL
|
||||
0xdc CONSTANT CPORT_D1
|
||||
0xdd CONSTANT CPORT_D2
|
||||
SYSVARS 0x73 + CONSTANT PS2_MEM
|
||||
SYSVARS 0x74 + CONSTANT PS2_MEM
|
||||
5 LOAD ( z80 assembler )
|
||||
: ZFILL, ( u ) 0 DO 0 A, LOOP ;
|
||||
262 LOAD ( xcomp )
|
||||
@ -33,10 +33,12 @@ CREATE ~FNT CPFNT5x7
|
||||
402 404 LOADR ( Grid )
|
||||
625 626 LOADR ( SMS ports )
|
||||
620 LOAD ( PAD ) : (ps2kc) (ps2kcA) ; 411 414 LOADR
|
||||
622 LOAD ( SPI )
|
||||
1 CONSTANT SDC_DEVID 423 436 LOADR ( SDC )
|
||||
390 LOAD ( xcomp core high )
|
||||
(entry) _
|
||||
( Update LATEST )
|
||||
PC ORG @ 8 + !
|
||||
," TMS$ 0 0 AT-XY PS2$ (im1) " EOT,
|
||||
," TMS$ GRID$ PS2$ BLK$ ' SDC@ BLK@* ! (im1) " EOT,
|
||||
ORG @ 0x100 - 256 /MOD 2 PC! 2 PC!
|
||||
H@ 256 /MOD 2 PC! 2 PC!
|
||||
|
@ -4,7 +4,7 @@ RS_ADDR 0x80 - CONSTANT SYSVARS
|
||||
0x8000 CONSTANT HERESTART
|
||||
SYSVARS 0x70 + CONSTANT LCD_MEM
|
||||
SYSVARS 0x72 + CONSTANT GRID_MEM
|
||||
SYSVARS 0x74 + CONSTANT KBD_MEM
|
||||
SYSVARS 0x75 + CONSTANT KBD_MEM
|
||||
0x01 CONSTANT KBD_PORT
|
||||
5 LOAD ( z80 assembler )
|
||||
: ZFILL, ( u ) 0 DO 0 A, LOOP ;
|
||||
@ -72,6 +72,6 @@ CREATE ~FNT CPFNT3x5
|
||||
(entry) _
|
||||
( Update LATEST )
|
||||
PC ORG @ 8 + !
|
||||
," LCD$ KBD$ " EOT,
|
||||
," LCD$ KBD$ GRID$ " EOT,
|
||||
ORG @ 0x100 - 256 /MOD 2 PC! 2 PC!
|
||||
H@ 256 /MOD 2 PC! 2 PC!
|
||||
|
19
blk.fs
19
blk.fs
@ -902,15 +902,15 @@ CREATE PREVPOS 0 , CREATE PREVBLK 0 , CREATE xoff 0 ,
|
||||
DUP CMD 2+ C! CMD FIND IF EXECUTE ELSE DROP THEN
|
||||
0 ACC ! UPPER 'Q' = ;
|
||||
: bufp ( buf -- )
|
||||
DUP 3 col- + SWAP DO I C@ 0x20 MAX EMIT LOOP ;
|
||||
DUP 3 col- + SWAP DO I C@ EMIT LOOP ;
|
||||
: bufs
|
||||
1 aty ." I: " IBUF bufp
|
||||
2 aty ." F: " FBUF bufp
|
||||
large? IF 0 3 gutter THEN ;
|
||||
: VE
|
||||
clrscr 0 ACC ! 0 PREVPOS ! nums contents
|
||||
1 XYMODE C! clrscr 0 ACC ! 0 PREVPOS ! nums contents
|
||||
BEGIN xoff? status bufs setpos KEY handle UNTIL
|
||||
19 aty (infl) ;
|
||||
0 XYMODE C! 19 aty (infl) ;
|
||||
( ----- 160 )
|
||||
( AVR Programmer, load range 160-163. doc/avr.txt )
|
||||
( page size in words, 64 is default on atmega328P )
|
||||
@ -2209,23 +2209,17 @@ XCURRENT @ _xapply ORG @ 0x04 ( stable ABI BOOT ) + !
|
||||
( ----- 401 )
|
||||
Grid subsystem
|
||||
|
||||
Given a device driver following the Grid protocol, implement
|
||||
AT-XY and (emit). (emit) makes the grid behave like a regular
|
||||
terminal, honoring line feeds and backspaces, wrapping at the
|
||||
end of a line.
|
||||
|
||||
2 bytes of system memory at GRID_MEM are needed for cursor
|
||||
position.
|
||||
See doc/grid.txt.
|
||||
|
||||
Load range: B402-B403
|
||||
( ----- 402 )
|
||||
: XYPOS [ GRID_MEM LITN ] ;
|
||||
: XYPOS [ GRID_MEM LITN ] ; : XYMODE [ GRID_MEM LITN ] 2+ ;
|
||||
: _cl* COLS LINES * ;
|
||||
: AT-XY ( x y -- ) COLS * + _cl* MOD XYPOS ! ;
|
||||
'? NEWLN NIP NOT [IF]
|
||||
: NEWLN ( ln -- ) COLS * DUP COLS + SWAP DO 0 I CELL! LOOP ;
|
||||
[THEN]
|
||||
: _lf
|
||||
: _lf XYMODE C@ IF EXIT THEN
|
||||
XYPOS @ COLS / 1+ LINES MOD DUP NEWLN
|
||||
COLS * XYPOS ! ;
|
||||
: _bs 0 ( blank ) XYPOS @ TUCK CELL! ( pos ) 1-
|
||||
@ -2237,6 +2231,7 @@ Load range: B402-B403
|
||||
0x20 - DUP 0< IF DROP EXIT THEN
|
||||
XYPOS @ CELL!
|
||||
XYPOS @ 1+ DUP COLS MOD IF XYPOS ! ELSE _lf THEN ;
|
||||
: GRID$ 0 XYPOS ! 0 XYMODE C! ;
|
||||
( ----- 410 )
|
||||
PS/2 keyboard subsystem
|
||||
|
||||
|
@ -52,11 +52,8 @@ static void iowr_stdio(uint8_t val)
|
||||
if (fp != NULL) {
|
||||
putchar(val);
|
||||
} else {
|
||||
if (val >= 0x20 || val == '\n') {
|
||||
if (val >= 0x20) {
|
||||
wechochar(w, val);
|
||||
} else if (val == 0x08) {
|
||||
int y, x; getyx(w, y, x);
|
||||
wmove(w, y, x-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ SYSVARS 0x70 + CONSTANT GRID_MEM
|
||||
(entry) _
|
||||
( Update LATEST )
|
||||
PC ORG @ 8 + !
|
||||
," BLK$ ' EFS@ BLK@* ! ' EFS! BLK!* ! 0 0 AT-XY " EOT,
|
||||
," BLK$ ' EFS@ BLK@* ! ' EFS! BLK!* ! GRID$ " EOT,
|
||||
ORG @ 256 /MOD 2 PC! 2 PC!
|
||||
H@ 256 /MOD 2 PC! 2 PC!
|
||||
|
||||
|
40
doc/grid.txt
Normal file
40
doc/grid.txt
Normal file
@ -0,0 +1,40 @@
|
||||
# The Grid subsystem
|
||||
|
||||
The grid subsystem at B401 supplies a set of words on top of
|
||||
the Grid protocol (see doc/protocol.txt) that facilitates the
|
||||
development of programs presenting a complex text interface,
|
||||
for example, the Visual Editor.
|
||||
|
||||
It create the concept of a cursor, always being a some position
|
||||
on screen. That position is in the variable XYPOS, which is a
|
||||
simple integer following the same "pos" logic as in the Grid
|
||||
protocol.
|
||||
|
||||
It implements (emit), which sets the cell under the cursor to
|
||||
the specified character, then moves the cursor right. If the
|
||||
cursor is at the last column of the screen, it overflows to the
|
||||
next line. If it's on the last line, it overflows to the first
|
||||
line.
|
||||
|
||||
Grid's (emit) handles 0xd by moving the cursor to the next line
|
||||
and 0x8 by moving the cursor left.
|
||||
|
||||
AT-XY ( x y -- ) moves the cursor to the specified position. It
|
||||
is equivalent to setting XYPOS directly, but uses separate X
|
||||
and y numbers.
|
||||
|
||||
When the grid's cursor enters a new line, it clears its
|
||||
contents through a repeated call to CELL!. That implementation
|
||||
is in its world named NEWLN ( ln -- ). This word can be over-
|
||||
ridden. If it exists when the grid subsystem is loaded, the ex-
|
||||
isting NEWLN will be used.
|
||||
|
||||
The clearing of the newly entered line is usually only desirable
|
||||
when in "shell" mode. In "graphical" mode, we usually don't
|
||||
want this to happen. XYMODE is a flag to indicate whether the
|
||||
grid system is in "graphical" mode. When its value is nonzero,
|
||||
NEWLN is not called when entering a new line.
|
||||
|
||||
At build time, the Grid subsystem needs 3 bytes of system me-
|
||||
mory through the GRID_MEM constant. At run time, GRID$ needs to
|
||||
be called to initialize the system.
|
Loading…
Reference in New Issue
Block a user