1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 07:08:05 +11:00

Integrate RDLN input buffer into sysvars

In the beginning of Collapse OS' Forth version, the readline sub-
system was optional. This is why we had this separate RDLN$ routine
and that the input buffer was allocated at boot time.

It's been a while since the RDLN system has been made mandatory, but
we still paid the complexity tax of this separation. Not anymore.
This commit is contained in:
Virgil Dupras 2021-01-02 14:20:50 -05:00
parent 64f0f6716e
commit d09de0a0d3
19 changed files with 45 additions and 50 deletions

View File

@ -75,7 +75,7 @@ CODE AT-XY ( x y )
( ----- 612 )
0xff00 CONSTANT RS_ADDR
0xfffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xa0 - CONSTANT SYSVARS
30 LOAD ( 8086 asm )
262 LOAD ( xcomp ) 270 LOAD ( xcomp overrides )
445 461 LOADR ( 8086 boot code )

View File

@ -71,7 +71,7 @@ CODE SIOB>
( ----- 619 )
( RC2014 classic with MC6850 )
0xff00 CONSTANT RS_ADDR 0xfffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xa0 - CONSTANT SYSVARS
0x8000 CONSTANT HERESTART
0x80 CONSTANT 6850_CTL 0x81 CONSTANT 6850_IO
4 CONSTANT SPI_DATA 5 CONSTANT SPI_CTL 1 CONSTANT SDC_DEVID
@ -88,7 +88,7 @@ PC ORG @ 8 + ! ( Update LATEST )
( ----- 620 )
( RC2014 classic with SIO )
0xff00 CONSTANT RS_ADDR 0xfffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xa0 - CONSTANT SYSVARS
0x8000 CONSTANT HERESTART
0x80 CONSTANT SIOA_CTL 0x81 CONSTANT SIOA_DATA
0x82 CONSTANT SIOB_CTL 0x83 CONSTANT SIOB_DATA

View File

@ -2,16 +2,16 @@
0xdd00 CONSTANT RS_ADDR
( Memory register at the end of RAM. Must not overwrite )
0xddca CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xb0 - CONSTANT SYSVARS
0xc000 CONSTANT HERESTART
0xbf CONSTANT TMS_CTLPORT
0xbe CONSTANT TMS_DATAPORT
SYSVARS 0x70 + CONSTANT GRID_MEM
SYSVARS 0x73 + CONSTANT CPORT_MEM
SYSVARS 0xa0 + CONSTANT GRID_MEM
SYSVARS 0xa3 + CONSTANT CPORT_MEM
0x3f CONSTANT CPORT_CTL
0xdc CONSTANT CPORT_D1
0xdd CONSTANT CPORT_D2
SYSVARS 0x74 + CONSTANT PAD_MEM
SYSVARS 0xa4 + CONSTANT PAD_MEM
5 LOAD ( z80 assembler )
262 LOAD ( xcomp )
524 LOAD ( font compiler )

View File

@ -3,16 +3,16 @@
0xdd00 CONSTANT RS_ADDR
( Memory register at the end of RAM. Must not overwrite )
0xddca CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xb0 - CONSTANT SYSVARS
0xc000 CONSTANT HERESTART
0xbf CONSTANT TMS_CTLPORT
0xbe CONSTANT TMS_DATAPORT
SYSVARS 0x70 + CONSTANT GRID_MEM
SYSVARS 0x73 + CONSTANT CPORT_MEM
SYSVARS 0xa0 + CONSTANT GRID_MEM
SYSVARS 0xa3 + CONSTANT CPORT_MEM
0x3f CONSTANT CPORT_CTL
0xdc CONSTANT CPORT_D1
0xdd CONSTANT CPORT_D2
SYSVARS 0x74 + CONSTANT PS2_MEM
SYSVARS 0xa4 + CONSTANT PS2_MEM
5 LOAD ( z80 assembler )
262 LOAD ( xcomp )
524 LOAD ( font compiler )

View File

@ -4,16 +4,16 @@
0xdd00 CONSTANT RS_ADDR
( Memory register at the end of RAM. Must not overwrite )
0xddca CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xb0 - CONSTANT SYSVARS
0xc000 CONSTANT HERESTART
0xbf CONSTANT TMS_CTLPORT
0xbe CONSTANT TMS_DATAPORT
SYSVARS 0x70 + CONSTANT GRID_MEM
SYSVARS 0x73 + CONSTANT CPORT_MEM
SYSVARS 0xa0 + CONSTANT GRID_MEM
SYSVARS 0xa3 + CONSTANT CPORT_MEM
0x3f CONSTANT CPORT_CTL
0xdc CONSTANT CPORT_D1
0xdd CONSTANT CPORT_D2
SYSVARS 0x74 + CONSTANT PS2_MEM
SYSVARS 0xa4 + CONSTANT PS2_MEM
5 LOAD ( z80 assembler )
262 LOAD ( xcomp )
524 LOAD ( font compiler )

View File

@ -4,16 +4,16 @@
0xdd00 CONSTANT RS_ADDR
( Memory register at the end of RAM. Must not overwrite )
0xddca CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xb0 - CONSTANT SYSVARS
0xc000 CONSTANT HERESTART
0xbf CONSTANT TMS_CTLPORT
0xbe CONSTANT TMS_DATAPORT
SYSVARS 0x70 + CONSTANT GRID_MEM
SYSVARS 0x73 + CONSTANT CPORT_MEM
SYSVARS 0xa0 + CONSTANT GRID_MEM
SYSVARS 0xa3 + CONSTANT CPORT_MEM
0x3f CONSTANT CPORT_CTL
0xdc CONSTANT CPORT_D1
0xdd CONSTANT CPORT_D2
SYSVARS 0x74 + CONSTANT PS2_MEM
SYSVARS 0xa4 + CONSTANT PS2_MEM
5 LOAD ( z80 assembler )
262 LOAD ( xcomp )
523 LOAD ( font compiler )

View File

@ -1,10 +1,10 @@
0xbf00 CONSTANT RS_ADDR
0xbffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xb0 - CONSTANT SYSVARS
0x8000 CONSTANT HERESTART
SYSVARS 0x70 + CONSTANT LCD_MEM
SYSVARS 0x72 + CONSTANT GRID_MEM
SYSVARS 0x75 + CONSTANT KBD_MEM
SYSVARS 0xa0 + CONSTANT LCD_MEM
SYSVARS 0xa2 + CONSTANT GRID_MEM
SYSVARS 0xa5 + CONSTANT KBD_MEM
0x01 CONSTANT KBD_PORT
5 LOAD ( z80 assembler )
262 LOAD ( xcomp )

View File

@ -1,6 +1,6 @@
0xff00 CONSTANT RS_ADDR
0xfffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xa0 - CONSTANT SYSVARS
0 CONSTANT HERESTART
5 LOAD ( z80 assembler )
262 LOAD ( xcomp )

View File

@ -1,5 +1,5 @@
0xff00 CONSTANT RS_ADDR 0xfffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xa0 - CONSTANT SYSVARS
0 CONSTANT HERESTART
5 LOAD ( z80 assembler )
262 LOAD ( xcomp )

23
blk.fs
View File

@ -1682,14 +1682,13 @@ with "390 LOAD"
: H@ HERE @ ;
: FIND ( w -- a f ) CURRENT @ SWAP _find ;
: IN> 0x30 RAM+ ; ( current position in INBUF )
: IN( 0x32 RAM+ @ ; ( points to INBUF )
: IN) 0x40 ( buffer size ) IN( + ; ( INBUF's end )
: IN( 0x60 RAM+ ; ( points to INBUF )
: IN$ 0 IN( DUP IN> ! ! ; ( flush input buffer )
: QUIT
(resRS) 0 0x08 RAM+ ! ( C<* override ) IN$
LIT" (main)" FIND DROP EXECUTE
;
1 33 LOADR+
1 31 LOADR+
( ----- 354 )
: ABORT (resSP) QUIT ;
: = CMP NOT ; : < CMP -1 = ; : > CMP 1 = ;
@ -1978,7 +1977,7 @@ SYSVARS 0x55 + :** KEY?
: RDLN ( Read 1 line in input buff and make IN> point to it )
IN$ BEGIN
( buffer overflow? same as if we typed a newline )
IN> @ IN) 1- = IF CR ELSE KEY THEN ( c )
IN> @ IN( - 0x3e = IF CR ELSE KEY THEN ( c )
DUP BS? IF
IN> @ IN( > IF -1 IN> +! BS EMIT THEN SPC> BS EMIT
ELSE DUP LF = IF DROP CR THEN ( same as CR )
@ -1996,13 +1995,6 @@ SYSVARS 0x55 + :** KEY?
( update C<? flag )
IN> @ C@ 0 > 0x06 RAM+ ! ( 06 == C<? ) ;
( ----- 381 )
( Initializes the readln subsystem )
: RDLN$
H@ 0x32 ( IN(* ) RAM+ !
IN) IN( - ALLOT IN$
['] RDLN< ['] C<* **!
1 0x06 RAM+ ! ( 06 == C<? ) ;
( ----- 382 )
: LIST
BLK@
16 0 DO
@ -2012,7 +2004,7 @@ SYSVARS 0x55 + :** KEY?
LOOP
NL>
LOOP ;
( ----- 383 )
( ----- 382 )
: INTERPRET
BEGIN
WORD DUP @ 0x0401 = ( EOT ) IF DROP EXIT THEN
@ -2028,7 +2020,7 @@ SYSVARS 0x55 + :** KEY?
is to check whether we're restoring to "_", the word above.
if yes, then we're in a nested load. Also, the 1 in 0x06 is
to avoid tons of "ok" displays. )
( ----- 384 )
( ----- 383 )
: LOAD
BLK> @ >R ( save restorable variables to RSP )
0x08 RAM+ @ >R ( 08 == C<* override )
@ -2045,7 +2037,7 @@ SYSVARS 0x55 + :** KEY?
ELSE ( not nested )
R> 0x08 RAM+ ! R> DROP ( BLK> )
THEN ;
( ----- 385 )
( ----- 384 )
: LOAD+ BLK> @ + LOAD ;
( b1 b2 -- )
: LOADR 1+ SWAP DO I DUP . SPC> LOAD LOOP ;
@ -2062,7 +2054,8 @@ SYSVARS 0x55 + :** KEY?
['] (boot<) ['] C<* **!
( boot< always has a char waiting. 06 == C<?* )
1 0x06 RAM+ ! INTERPRET
RDLN$ LIT" _sys" [entry]
['] RDLN< ['] C<* **! IN$
LIT" _sys" [entry]
LIT" Collapse OS" STYPE NL> (main) ;
XCURRENT @ _xapply ORG @ 0x04 ( stable ABI BOOT ) + !
1 4 LOADR+

View File

@ -2,7 +2,7 @@
binaries. )
0xff00 CONSTANT RS_ADDR
0xfffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xb0 - CONSTANT SYSVARS
0 CONSTANT HERESTART
: CODE ( natidx -- ) (entry) 0 C, C, ;
VARIABLE ORG

View File

@ -3,7 +3,7 @@
DROP COLS /MOD 6 PC! ( y ) 5 PC! ( x ) ;
: CELL! ( c pos -- ) 0 CURSOR! 0 PC! ;
SYSVARS 0x70 + CONSTANT GRID_MEM
SYSVARS 0xa0 + CONSTANT GRID_MEM
402 403 LOADR ( Grid )
390 LOAD ( xcomp core high )
(entry) _

Binary file not shown.

View File

@ -3,7 +3,7 @@
#define SP_ADDR 0xffff
#define RS_ADDR 0xff00
#define SYSVARS RS_ADDR-0x80
#define SYSVARS RS_ADDR-0xb0
#define MEMSIZE 0x10000
typedef uint8_t byte;

View File

@ -68,7 +68,7 @@ First, we need a "(ps2kc)" routine (see doc/protocol.txt). In
this case, it's easy, it's ": (ps2kc) 8 PC@ ;". Then, we can
load PS/2 subsystem. You add "411 414 LOADR". Then, at
initialization, you add "PS2$". You also need to define PS2_MEM
at the top. You can probably use "SYSVARS + 0x7a".
at the top. You can probably use "SYSVARS + 0xaa".
The PS/2 subsystem provides "(key)" from "(ps2kc)".

View File

@ -113,7 +113,7 @@ it with /cvm/avra.sh.
We start with the base SMS xcomp and add a few things:
1. at the top: "SYSVARS 0x72 + CONSTANT PS2_MEM"
1. at the top: "SYSVARS 0xa2 + CONSTANT PS2_MEM"
2. After VDP load: "621 LOAD : (ps2kc) (ps2kcB) ;" (that binds
us to port B)
3. Right after: "411 414 LOADR" (that gives us "(key)")

View File

@ -153,6 +153,9 @@ fact, they're mostly referred to directly as their numerical
offset along with a comment indicating what this offset refers
to.
SYSVARS occupy 0xa0 bytes in memory in addition to driver mem-
ory, which typically follows SYSVARS.
This system is a bit fragile because every time we change those
offsets, we have to be careful to adjust all system variables
offsets, but thankfully, there aren't many system variables.
@ -167,9 +170,8 @@ SYSVARS FUTURE USES +3c BLK(*
+0c C<* +53 EMIT ialias
+0e WORDBUF +55 KEY? ialias
+2e BOOT C< PTR +57 FUTURE USES
+30 IN>
+32 IN(* +70 DRIVERS
+34 BLK@* +80 RAMEND
+30 IN> +60 INPUT BUFFER
+32 FUTURE USES +a0 DRIVERS
+36 BLK!*
+38 BLK>
+3a BLKDTY

View File

@ -1,6 +1,6 @@
0xff00 CONSTANT RS_ADDR
0xfffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xa0 - CONSTANT SYSVARS
30 LOAD ( 8086 asm )
262 LOAD ( xcomp ) 270 LOAD ( xcomp overrides )
445 461 LOADR ( 8086 boot code )

View File

@ -1,6 +1,6 @@
0xff00 CONSTANT RS_ADDR
0xfffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT SYSVARS
RS_ADDR 0xa0 - CONSTANT SYSVARS
0 CONSTANT HERESTART
5 LOAD ( z80 assembler )
262 LOAD ( xcomp )