From 6bb7a9dca9db621f42c48fbe0ddfa8b944481658 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Sun, 31 Dec 2023 10:19:37 -0800 Subject: [PATCH] Include conio inside plforth for keypress() --- src/libsrc/apple/conio.pla | 4 ++-- src/mkrel | 2 +- src/samplesrc/bounce.4th | 7 ++++--- src/samplesrc/cmdsys.4th | 12 ------------ src/samplesrc/plasma.4th | 26 ++++++++++++++++++++++++++ src/toolsrc/plforth.pla | 17 +++++++++-------- 6 files changed, 42 insertions(+), 26 deletions(-) delete mode 100644 src/samplesrc/cmdsys.4th create mode 100644 src/samplesrc/plasma.4th diff --git a/src/libsrc/apple/conio.pla b/src/libsrc/apple/conio.pla index 2db6822..f1885c2 100644 --- a/src/libsrc/apple/conio.pla +++ b/src/libsrc/apple/conio.pla @@ -151,7 +151,7 @@ end // Apple 1 routines. // def a1keypressed - return ^$D011 >= 128 + return ^$D011 >= 128 ?? ^$D011 :: 0 end def a12echo(state) return 0 @@ -198,7 +198,7 @@ end // Apple II routines. // def a2keypressed - return ^keyboard >= 128 + return ^keyboard >= 128 ?? ^keyboard :: 0 end def a2home //curshpos = 0 diff --git a/src/mkrel b/src/mkrel index 4e28f5a..0b15dc4 100755 --- a/src/mkrel +++ b/src/mkrel @@ -202,7 +202,7 @@ cp samplesrc/lz4cat.pla prodos/bld/samples/LZ4CAT.PLA.TXT cp samplesrc/sfm.pla prodos/bld/samples/SFM.PLA.TXT cp samplesrc/sfmsprt.pla prodos/bld/samples/SFMSPRT.PLA.TXT cp samplesrc/fppow.pla prodos/bld/samples/FPPOW.PLA.TXT -cp samplesrc/cmdsys.4th prodos/bld/samples/CMDSYS.4TH.TXT +cp samplesrc/plasma.4th prodos/bld/samples/PLASMA.4TH.TXT cp samplesrc/bounce.4th prodos/bld/samples/BOUNCE.4TH.TXT cp utilsrc/apple/mon.pla prodos/bld/samples/MON.PLA.TXT cp utilsrc/apple/zipchip.pla prodos/bld/samples/ZIPCHIP.PLA.TXT diff --git a/src/samplesrc/bounce.4th b/src/samplesrc/bounce.4th index 692e09f..5e61203 100644 --- a/src/samplesrc/bounce.4th +++ b/src/samplesrc/bounce.4th @@ -1,7 +1,6 @@ -SRC" CMDSYS.4TH" +SRC" PLASMA.4TH" -" CONIO" EXECMOD -." Load module returns " . CR +( LOADMOD" CONIO" CONIO is already available in plforth ) LOOKUP CONIO CONSTANT CONIOAPI CONIOAPI 3 IFACE PLASMA HOME @@ -45,3 +44,5 @@ CONIOAPI 12 IFACE PLASMA RAND KEY 40 TEXTMODE DROP ; + +BOUNCE diff --git a/src/samplesrc/cmdsys.4th b/src/samplesrc/cmdsys.4th deleted file mode 100644 index f6a9abf..0000000 --- a/src/samplesrc/cmdsys.4th +++ /dev/null @@ -1,12 +0,0 @@ -: IFACE 2 * + @ ; - -LOOKUP CMDSYS 3 IFACE PLASMA EXECMOD -LOOKUP CMDSYS 2 IFACE CONSTANT CMDLINE -LOOKUP STRCPY PLASMA STRCPY -LOOKUP STRCAT PLASMA STRCAT - -: EDIT" - CMDLINE " ED " STRCPY - CMDLINE 34 WORD STRCAT - " ED" EXECMOD -; diff --git a/src/samplesrc/plasma.4th b/src/samplesrc/plasma.4th new file mode 100644 index 0000000..258e45c --- /dev/null +++ b/src/samplesrc/plasma.4th @@ -0,0 +1,26 @@ +: IFACE 2 * + @ ; + +LOOKUP CMDSYS 3 IFACE PLASMA EXECMOD +LOOKUP CMDSYS 2 IFACE CONSTANT CMDLINE +LOOKUP STRCPY PLASMA STRCPY +LOOKUP STRCAT PLASMA STRCAT + +: CPYCMD + CMDLINE " . " STRCPY DROP ( Need a dummy value for the module name ) + 34 WORD CMDLINE SWAP STRCAT DROP ( Quote deliminted string ) +; + +: CMDEXEC + CPYCMD + EXECMOD 0< IF ." Failed to exec module" CR THEN +; + +: LOADMOD" + 34 WORD ( Quote deliminted string ) + EXECMOD 0< IF ." Failed to load module" CR THEN +; + +: EDIT" + CPYCMD + " ED" EXECMOD 0< IF ." Failed to run ED" CR ABORT THEN +; diff --git a/src/toolsrc/plforth.pla b/src/toolsrc/plforth.pla index ca49ed0..366cb9c 100644 --- a/src/toolsrc/plforth.pla +++ b/src/toolsrc/plforth.pla @@ -1,6 +1,7 @@ include "inc/cmdsys.plh" include "inc/args.plh" include "inc/fileio.plh" +include "inc/conio.plh" include "inc/longjmp.plh" // // FORTH dictionary layout @@ -731,16 +732,16 @@ end // def execword(dentry)#0 - if ^$C000 & $80 - if ^$C000 == $83 // CTRL-C - ^$C010 // Clear KB strobe + when conio:keypressed() + is $83 // CTRL-C + getc // Clear KB brkhandle(dentry) - fin - if ^$C000 == $94 // CTRL-T - ^$C010 // Clear KB strobe + break + is $94 // CTRL-T + getc // Clear KB strobe state = state ^ trace_flag - fin - fin + break + wend if state & trace_flag showtrace(dentry) fin