diff --git a/images/apple/PLFORTH.PO b/images/apple/PLFORTH.PO index da9a0ee..5f2f6cc 100755 Binary files a/images/apple/PLFORTH.PO and b/images/apple/PLFORTH.PO differ diff --git a/src/mkrel b/src/runrel similarity index 99% rename from src/mkrel rename to src/runrel index 5419115..78c4cce 100755 --- a/src/mkrel +++ b/src/runrel @@ -1,3 +1,5 @@ +make apple + cp rel/apple/CMD#061000 prodos/CMD.BIN cp rel/apple/CMD128#061000 prodos/CMD128.BIN cp rel/apple/PLASMA.SYSTEM#FF2000 prodos/PLASMA.SYSTEM.SYS @@ -286,3 +288,6 @@ cp inc/testlib.plh prodos/bld/inc/TESTLIB.PLH.TXT cp inc/grafix.plh prodos/bld/inc/GRAFIX.PLH.TXT cp inc/lz4.plh prodos/bld/inc/LZ4.PLH.TXT cp vmsrc/apple/plvmzp.inc prodos/bld/inc/PLVMZP.INC.TXT + +open /Applications/Virtual\ \]\[/Virtual\ \]\[.app/ + diff --git a/src/scripts/bounce.4th b/src/scripts/bounce.4th index 2d36b93..004a8b7 100644 --- a/src/scripts/bounce.4th +++ b/src/scripts/bounce.4th @@ -1,32 +1,6 @@ -: ?PLASMA - " IFACE" FIND - SWAP DROP - 0= IF - " PLASMA.4TH" SRC - THEN -; - -?PLASMA ( Load PLASMA if not already ) - -: ?CONIO - " CONIOAPI" FIND - SWAP DROP - 0= IF - " CONIO.4TH" SRC - THEN -; - -?CONIO ( Load CONIO if not already ) - -: ?GRLIB - " GRLIB" FIND - SWAP DROP - 0= IF - " GRLIB.4TH" SRC - THEN -; - -?GRLIB ( Load GRLIB if not already ) +SRC" PLASMA.4TH" +SRC" CONIO.4TH" +SRC" GRLIB.4TH" 5 VARIABLE BALLCLR 10 VARIABLE BALLX diff --git a/src/scripts/conio.4th b/src/scripts/conio.4th index ac88382..9bcc917 100644 --- a/src/scripts/conio.4th +++ b/src/scripts/conio.4th @@ -1,3 +1,5 @@ +' CONIOAPI ENDSRC ( Avoid multiple loads ) + ( LOADMOD" CONIO" CONIO is already available in plforth ) LOOKUP CONIO CONSTANT CONIOAPI diff --git a/src/scripts/fileio.4th b/src/scripts/fileio.4th index ee64a97..8dc89c4 100644 --- a/src/scripts/fileio.4th +++ b/src/scripts/fileio.4th @@ -1,3 +1,5 @@ +' FILEIOAPI ENDSRC ( Avoid multiple loads ) + ( LOADMOD" FILEIO" FILEIO is already available in plforth ) LOOKUP FILEIO CONSTANT FILEIOAPI diff --git a/src/scripts/fpu.4th b/src/scripts/fpu.4th index fdf939b..c25e307 100644 --- a/src/scripts/fpu.4th +++ b/src/scripts/fpu.4th @@ -1,3 +1,5 @@ +' FPULIB ENDSRC ( Avoid multipe loads ) + " SANE" LOADMOD" " " FPSTR" LOADMOD" " " FPU" LOADMOD" " diff --git a/src/scripts/grlib.4th b/src/scripts/grlib.4th index ce85fbd..af2326d 100644 --- a/src/scripts/grlib.4th +++ b/src/scripts/grlib.4th @@ -1,3 +1,5 @@ +' GRMODE ENDSRC ( Avoid multiple loads ) + " GRLIB" LOADMOD" " LOOKUP GRPLOT PLASMA GRPLOT diff --git a/src/scripts/hgrlib.4th b/src/scripts/hgrlib.4th index 3fe2bd1..f55d274 100644 --- a/src/scripts/hgrlib.4th +++ b/src/scripts/hgrlib.4th @@ -1,3 +1,5 @@ +' HGRMODE ENDSRC ( Avoid multiple loads ) + " HGRLIB" LOADMOD" " LOOKUP HGRPLOT PLASMA HGRPLOT diff --git a/src/scripts/hrbounce.4th b/src/scripts/hrbounce.4th index 37758ca..4edd9f8 100644 --- a/src/scripts/hrbounce.4th +++ b/src/scripts/hrbounce.4th @@ -2,35 +2,9 @@ LOOKUP HRFORTH ( HGR page 1 reserved ) LOOKUP HR2FORTH ( HGR page 1 and 2 reserved ) OR NOT ABORT" Must run with HRFORTH." -: ?PLASMA - " IFACE" FIND - SWAP DROP - 0= IF - " PLASMA.4TH" SRC - THEN -; - -?PLASMA ( Load PLASMA if not already ) - -: ?CONIO - " CONIOAPI" FIND - SWAP DROP - 0= IF - " CONIO.4TH" SRC - THEN -; - -?CONIO ( Load CONIO if not already ) - -: ?HGRLIB - " HGRLIB" FIND - SWAP DROP - 0= IF - " HGRLIB.4TH" SRC - THEN -; - -?HGRLIB ( Load GRLIB if not already ) +SRC" PLASMA.4TH" +SRC" CONIO.4TH" +SRC" HGRLIB.4TH" 5 VARIABLE BALLCLR 10 VARIABLE BALLX diff --git a/src/scripts/int32.4th b/src/scripts/int32.4th index bfdc6c9..663701a 100644 --- a/src/scripts/int32.4th +++ b/src/scripts/int32.4th @@ -1,3 +1,5 @@ +' DVAR ENDSRC ( Avoid multiple loads ) + " INT32" LOADMOD" " LOOKUP ZERO32 PLASMA ZERO32 ( -- ) diff --git a/src/scripts/plasma.4th b/src/scripts/plasma.4th index efd1b58..3731ea2 100644 --- a/src/scripts/plasma.4th +++ b/src/scripts/plasma.4th @@ -1,3 +1,5 @@ +' IFACE ENDSRC ( Avoid multiple loads ) + : IFACE 2 * + @ ; LOOKUP CMDSYS 0 IFACE CONSTANT PLASMAVER @@ -69,4 +71,3 @@ LOOKUP FILEIO 1 IFACE PLASMA SETPFX : PFX" 34 WORD SETPFX DROP ; -HERE FENCE \ No newline at end of file diff --git a/src/scripts/rod.4th b/src/scripts/rod.4th index cae9595..3d5c845 100644 --- a/src/scripts/rod.4th +++ b/src/scripts/rod.4th @@ -1,22 +1,5 @@ -: ?PLASMA - " IFACE" FIND - SWAP DROP - 0= IF - " PLASMA.4TH" SRC - THEN -; - -?PLASMA ( Load PLASMA if not already ) - -: ?CONIO - " CONIOAPI" FIND - SWAP DROP - 0= IF - " CONIO.4TH" SRC - THEN -; - -?CONIO ( Load CONIO if not already ) +SRC" PLASMA.4TH" +SRC" CONIO.4TH" 0 VARIABLE K 0 VARIABLE W diff --git a/src/toolsrc/plforth.pla b/src/toolsrc/plforth.pla index a69fc9c..252a462 100644 --- a/src/toolsrc/plforth.pla +++ b/src/toolsrc/plforth.pla @@ -19,7 +19,7 @@ word previnptr[SRCREFS] // Internal buffers // res[SRCREFS * INBUF_SIZE] inbuf -res[t_except] exit +res[t_except] exitforth // // RSTACK // @@ -111,15 +111,15 @@ predef _immediate_#0, _exit_#0, _pad_#1, _trailing_(a,b)#2 predef _tors_(a)#0, _fromrs_#1, _toprs_#1, _lookup_#1 predef _move_(a,b,c)#0, _fill_(a,b,c)#0, _plasma_(a)#0 predef _var_(a)#0, _const_(a)#0, _lit_#1, _slit_#1, _find_(a)#2, _tick_#1 -predef _fence_(a)#0, _forget_#0, _terminal_#1, _prat_(a)#0, _prhexat_(a)#0 +predef _forget_#0, _terminal_#1, _prat_(a)#0 predef _char_#0, _str_#0, _prstr_#0, _prpstr_#0 -predef _prval_(a)#0, _prbyte_(a)#0, _prshex_(a)#0, _prsbyte_(a)#0, _prhex_(a)#0 -predef _accept_(a,b)#1, _src_(a)#0, _srcstr_#0, _query_#0, _expect_(a,b)#0, _type_(a,b)#0 +predef _prval_(a)#0, _prbyte_(a)#0, _prhex_(a)#0 +predef _accept_(a,b)#1, _query_#0, _expect_(a,b)#0, _type_(a,b)#0 predef _vlist_#0, _tron_#0, _troff_#0, _stepon_#0, _stepoff_#0 -predef _itc_#0, _pbc_#0, _comment_#0 +predef _itc_#0, _pbc_#0, _comment_#0, _src_(a)#0, _srcstr_#0, _endsrc_(a)#0 predef _brk_#0, _brkon_#0, _brkoff_#0, _word_(a)#1, _count_(a)#2 predef _space_#0, _spaces_(a)#0, _show_#0, _showstack_#0, _showrstack_#0 -predef _showhash_#0, _cont_#0, _restart_#0, _bye_#0, _quit_#0 +predef _showhash_#0, _cont_#0, _exitforth_#0, _bye_#0, _quit_#0 predef _abort_(a)#0, _doabortstr_(a,b)#0, _abortstr_#0 predef compword(dentry)#0, execword(dentry)#0 // DROP @@ -422,22 +422,14 @@ word = @d_until, 0, @_while_ char d_repeat = "REPEAT" byte = imm_flag word = @d_while, 0, @_repeat_ -// FENCE -char d_fence = "FENCE" -byte = 0 -word = @d_repeat, 0, @_fence_ // FORGET char d_forget = "FORGET" byte = 0 -word = @d_fence, 0, @_forget_ +word = @d_repeat, 0, @_forget_ // CREATE char d_create = "CREATE" byte = 0 word = @d_forget, 0, @_create_ -// BUILDS ( same as CREATE ) -char d_builds = " 0 + srclevel-- + fileio:close(inref[srclevel]) // EOF + inref[srclevel] = 0 + inbufptr = inbufptr - INBUF_SIZE + inptr = previnptr[srclevel] + if srclevel == 0 // - switch back to keyboard input + infunc = @keyin + keyin + fin + fin + return srclevel == 0 +end def filein#0 byte len repeat @@ -742,15 +740,8 @@ def filein#0 ^(inbufptr + len) = 0 // NULL terminate inptr = inbufptr else - srclevel-- - fileio:close(inref[srclevel]) // EOF - inref[srclevel] = 0 - inbufptr = inbufptr - INBUF_SIZE - inptr = previnptr[srclevel] - if srclevel == 0 // - switch back to keyboard input - infunc = @keyin - keyin - return + if endsrc + return fin fin until len @@ -961,20 +952,15 @@ def warmstart#0 brk = 0 brkcfa = 0 RSP = RSTK_SIZE - infunc = @keyin - inptr = keyinbuf - ^inptr = 0 if state & comp_flag // Undo compilation state heaprelease(vlist) vlist = *_lfa_(vlist) - buildhashtbl fin state = 0 - while srclevel - srclevel-- - fileio:close(inref[srclevel]) - inref[srclevel] = 0 - loop + while !endsrc; loop + infunc = @keyin + inptr = keyinbuf + ^inptr = 0 end // // Cold start @@ -1019,10 +1005,20 @@ def compliteral(value)#0 pfillw(@d_lit) pfillw(value) // Poke literal value into dictionary else // comp_pbc_flag - if value >= 0 and value <= 15 - pfillb(value << 1) // CONSTANT NIBBLE - elsif value == -1 - pfillb($20) // CONSTANT MINUS_ONE + if value >= 0 and value <= 255 + if value <= 15 + pfillb(value << 1) // CONSTANT NIBBLE + else + pfillb($2A) // CONSTANT BYTE + pfillb(value) // Poke literal value into dictionary + fin + elsif value < 0 and value >= -256 + if value == -1 + pfillb($20) // CONSTANT MINUS_ONE + else + pfillb($5E) // CONSTANT NEGATIVE BYTE + pfillb(value) // Poke literal value into dictionary + fin else pfillb($2C) // CONSTANT WORD pfillw(value) // Poke literal value into dictionary @@ -1596,26 +1592,14 @@ end def _tick_#1 return find(nextword(' ')) end -def _fence_(a)#0 - if isult(a, startheap) - a = startheap - fin - fence = a -end def _forget_#0 word dentry dentry = find(nextword(' ')) if dentry - if isult(dentry, fence) - if isuge(vlist, fence) - repeat - dentry = vlist - vlist = *_lfa_(dentry) - until isult(vlist, fence) - else - return // Do nothing - fin + if isult(dentry, startheap) + vlist = @d_vlist + dentry = startheap else vlist = *_lfa_(dentry) fin @@ -1684,23 +1668,14 @@ def _prval_(a)#0 puti(a); putc(' ') end def _prbyte_(a)#0 - putb(a); putc(' ') -end -def _prhex_(a)#0 - puth(a); putc(' ') -end -def _prsbyte_(a)#0 putc('$'); putb(a); putc(' ') end -def _prshex_(a)#0 +def _prhex_(a)#0 putc('$'); puth(a); putc(' ') end def _prat_(a)#0 puti(*a); putc(' ') end -def _prhexat_(a)#0 - putc('$'); puth(*a); putc(' ') -end def _char_#0 word str byte len @@ -1830,6 +1805,11 @@ def _srcstr_#0 _src_(filename) fin end +def _endsrc_(a)#0 + if a + endsrc + fin +end def _show_#0 word dentry, pfa, w @@ -1971,7 +1951,7 @@ end // def _quit_#0 warmstart - throw(@exit, FALSE) + throw(@exitforth, FALSE) end // // Abort @@ -2000,20 +1980,20 @@ def _abortstr_#0 fin end // -// Restart +// exitforth // -def _restart_#0 +def _exitforth_#0 coldstart - throw(@exit, FALSE) + throw(@exitforth, FALSE) end // // Leave FORTH // def _bye_#0 - throw(@exit, TRUE) + throw(@exitforth, TRUE) end -puts("FORTH for PLASMA 2.1 WIP\n") +puts("FORTH WIP for PLASMA 2.1\n") if cmdsys:sysver < $0201 puts("PLASMA >= 2.01 required\n") return @@ -2024,7 +2004,7 @@ fileio:iobufalloc(4) // Allocate a bunch of file buffers startheap = heapmark coldstart inptr = argNext(argFirst) -if not except(@exit) +if not except(@exitforth) if ^inptr; inptr++; _srcstr_; fin interpret fin