diff --git a/arch/8086/pcat/blk.fs b/arch/8086/pcat/blk.fs index 97d86ee..ecae3a1 100644 --- a/arch/8086/pcat/blk.fs +++ b/arch/8086/pcat/blk.fs @@ -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 ) diff --git a/arch/z80/rc2014/blk.fs b/arch/z80/rc2014/blk.fs index 8eb4d84..3ced90b 100644 --- a/arch/z80/rc2014/blk.fs +++ b/arch/z80/rc2014/blk.fs @@ -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 diff --git a/arch/z80/sms/xcomp.fs b/arch/z80/sms/xcomp.fs index 2a6e769..84d7191 100644 --- a/arch/z80/sms/xcomp.fs +++ b/arch/z80/sms/xcomp.fs @@ -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 ) diff --git a/arch/z80/sms/xcompkbd.fs b/arch/z80/sms/xcompkbd.fs index ea0bc08..50b1786 100644 --- a/arch/z80/sms/xcompkbd.fs +++ b/arch/z80/sms/xcompkbd.fs @@ -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 ) diff --git a/arch/z80/sms/xcompsdc.fs b/arch/z80/sms/xcompsdc.fs index f0f69f3..b97b2f5 100644 --- a/arch/z80/sms/xcompsdc.fs +++ b/arch/z80/sms/xcompsdc.fs @@ -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 ) diff --git a/arch/z80/sms/xcomptextmode.fs b/arch/z80/sms/xcomptextmode.fs index a436312..9dc74b7 100644 --- a/arch/z80/sms/xcomptextmode.fs +++ b/arch/z80/sms/xcomptextmode.fs @@ -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 ) diff --git a/arch/z80/ti84/xcomp.fs b/arch/z80/ti84/xcomp.fs index e13e783..9afca8c 100644 --- a/arch/z80/ti84/xcomp.fs +++ b/arch/z80/ti84/xcomp.fs @@ -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 ) diff --git a/arch/z80/trs80/xcomp.fs b/arch/z80/trs80/xcomp.fs index f0d37ec..3b9b8d3 100644 --- a/arch/z80/trs80/xcomp.fs +++ b/arch/z80/trs80/xcomp.fs @@ -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 ) diff --git a/arch/z80/z80mbc2/xcomp.fs b/arch/z80/z80mbc2/xcomp.fs index b90cdd8..645e861 100644 --- a/arch/z80/z80mbc2/xcomp.fs +++ b/arch/z80/z80mbc2/xcomp.fs @@ -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 ) diff --git a/blk.fs b/blk.fs index 4c193b5..5b9d3a6 100644 --- a/blk.fs +++ b/blk.fs @@ -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 @ C@ 0 > 0x06 RAM+ ! ( 06 == C 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 (main) ; XCURRENT @ _xapply ORG @ 0x04 ( stable ABI BOOT ) + ! 1 4 LOADR+ diff --git a/cvm/common.fs b/cvm/common.fs index e50bfc9..f4531cc 100644 --- a/cvm/common.fs +++ b/cvm/common.fs @@ -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 diff --git a/cvm/forth.fs b/cvm/forth.fs index 11b9e70..06cd97b 100644 --- a/cvm/forth.fs +++ b/cvm/forth.fs @@ -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) _ diff --git a/cvm/stage.bin b/cvm/stage.bin index b50c816..5fc72b9 100644 Binary files a/cvm/stage.bin and b/cvm/stage.bin differ diff --git a/cvm/vm.h b/cvm/vm.h index 21b577e..4b6b588 100644 --- a/cvm/vm.h +++ b/cvm/vm.h @@ -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; diff --git a/doc/hw/z80/ps2.txt b/doc/hw/z80/ps2.txt index b30ea03..706a05e 100644 --- a/doc/hw/z80/ps2.txt +++ b/doc/hw/z80/ps2.txt @@ -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)". diff --git a/doc/hw/z80/sms/ps2.txt b/doc/hw/z80/sms/ps2.txt index 1acfad7..a9edc40 100644 --- a/doc/hw/z80/sms/ps2.txt +++ b/doc/hw/z80/sms/ps2.txt @@ -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)") diff --git a/doc/impl.txt b/doc/impl.txt index 1f086fb..724284d 100644 --- a/doc/impl.txt +++ b/doc/impl.txt @@ -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 diff --git a/emul/8086/xcomp.fs b/emul/8086/xcomp.fs index f6e294b..e1b6839 100644 --- a/emul/8086/xcomp.fs +++ b/emul/8086/xcomp.fs @@ -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 ) diff --git a/emul/z80/xcomp.fs b/emul/z80/xcomp.fs index 571fa4f..224de01 100644 --- a/emul/z80/xcomp.fs +++ b/emul/z80/xcomp.fs @@ -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 )