diff --git a/src/inc/cmdsys.plh b/src/inc/cmdsys.plh index b204545..1dd3ae8 100644 --- a/src/inc/cmdsys.plh +++ b/src/inc/cmdsys.plh @@ -51,9 +51,9 @@ import cmdsys word sysread word syswrite byte syserr - byte modid // Apple /// specific byte refcons // Apple /// specific byte devcons // Apple /// specific + byte cmdparser end // // CMD exported functions diff --git a/src/vmsrc/apple/soscmd.pla b/src/vmsrc/apple/soscmd.pla index 2a0697b..5eefeb7 100755 --- a/src/vmsrc/apple/soscmd.pla +++ b/src/vmsrc/apple/soscmd.pla @@ -2,9 +2,6 @@ include "inc/cmdsys.plh" byte console[] = ".CONSOLE" byte textmode[] = 16, 0, 15 byte prefix[64] = "" -byte err[] -byte autorun -word cmdptr // // Utility functions // @@ -217,9 +214,78 @@ def parsecmd(strptr)#1 return cmd end // -// Clear out module memory segment +// Command line handler // -cmdsys.modid = 0 +def shell#0 + byte err[] + byte autorun + word cmdptr + // + // Try to load autorun. + // + cmdptr = heapmark + ^cmdptr = 0 + autorun = cmdsys:sysopen("AUTORUN") + if autorun > 0 + ^cmdptr = cmdsys:sysread(autorun, cmdptr + 1, 64) + cmdsys:sysclose(autorun) + fin + // + // Handle commands. + // + while 1 + if ^cmdptr + when toupper(parsecmd(cmdptr)) + is 'C' + catalog(cmdptr) + break + is 'P' + if ^cmdptr and ^(cmdptr + 1) <> '/' + strcat(@prefix, cmdptr) + else + strcpy(@prefix, cmdptr) + fin + setpfx(@prefix) + break + is '/' + repeat + prefix-- + until prefix[prefix] == '/' + if prefix > 1 + setpfx(@prefix) + fin + break + is 'S' + setpfx(cmdptr) + strcat(getpfx(cmdsys:syspath), "SYS/")) + break + is 'V' + volumes + break + is '+' + saveX + cmdsys:modexec(striptrail(cmdptr)) + restoreX + cmdsys:sysclose(0) + init_cons + break + otherwise + puts("?\n") + wend + if cmdsys.syserr + err = cmdsys.syserr + puts("ERR:$") + putb(err) + else + puts("OK") + fin + putln + fin + puts(getpfx(@prefix)) + cmdptr = gets($BA) + strcpy(cmdsys:cmdline, cmdptr) + loop +end // // Init console. // @@ -227,77 +293,10 @@ init_cons // // Print PLASMA version // -puts("PLASMA 2.0 Dev\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout +puts("PLASMA 2.0 Dev\n")//; putb(version.1); putc('.'); putb(version.0); putln +puts("MEM:$"); puth(heapavail); putln // -// Try to load autorun. +// Save pointer to command line handler // -cmdptr = heapmark -^cmdptr = 0 -autorun = cmdsys:sysopen("AUTORUN") -if autorun > 0 - ^cmdptr = cmdsys:sysread(autorun, cmdptr + 1, 64) - cmdsys:sysclose(autorun) -else - // - // Print some startup info. - // - puts("MEM:$") - puth(heapavail) - putln -fin -// -// Handle commands. -// -while 1 - if ^cmdptr - when toupper(parsecmd(cmdptr)) - is 'C' - catalog(cmdptr) - break - is 'P' - if ^cmdptr and ^(cmdptr + 1) <> '/' - strcat(@prefix, cmdptr) - else - strcpy(@prefix, cmdptr) - fin - setpfx(@prefix) - break - is '/' - repeat - prefix-- - until prefix[prefix] == '/' - if prefix > 1 - setpfx(@prefix) - fin - break - is 'S' - setpfx(cmdptr) - strcat(getpfx(cmdsys:syspath), "SYS/")) - break - is 'V' - volumes - break - is '+' - saveX - cmdsys:modexec(striptrail(cmdptr)) - restoreX - cmdsys:sysclose(0) - init_cons - break - otherwise - puts("?\n") - wend - if cmdsys.syserr - err = cmdsys.syserr - puts("ERR:$") - putb(err) - else - puts("OK") - fin - putln - fin - puts(getpfx(@prefix)) - cmdptr = gets($BA) - strcpy(cmdsys:cmdline, cmdptr) -loop +cmdsys:cmdparser = @shell done diff --git a/src/vmsrc/apple/sossys.pla b/src/vmsrc/apple/sossys.pla index 9e12fa4..5664b20 100755 --- a/src/vmsrc/apple/sossys.pla +++ b/src/vmsrc/apple/sossys.pla @@ -29,14 +29,14 @@ predef execmod(modfile)#1, open(path)#1, close(refnum)#1, read(refnum, buff, len // // Exported CMDSYS table // -word version = $0200 // 02.00 +word version = $0200 // 02.00 word syspath word cmdlnptr -word = @execmod, @open, @close, @read, @write +word = @execmod, @open, @close, @read, @write byte perr -byte modid = 0 -byte refcons = 0 -byte devcons = 0 +byte refcons = 0 +byte devcons = 0 +word cmdparser // // String pool. // @@ -48,7 +48,11 @@ byte machid = $F2 // Apple ///, 80 columns // // Working input buffer overlayed with strings table // -byte cmdln = "" +byte cmdln = "" +// +// SOS.CMD as DCI string +// +byte soscmd = 'S'|$80,'O'|$80,'S'|$80,'.'|$80,'C'|$80,'M'|$80,'D' // // Standard Library exported functions. // @@ -116,6 +120,7 @@ word sysmodsym = @exports // word systemflags = 0 word heap = $2000 +byte modid = 0 byte modseg[15] word symtbl, lastsym // @@ -1225,5 +1230,7 @@ cmdlnptr = @cmdln // // Exec command line parser // -execmod("SOS.CMD") +loadmod(@soscmd) +modid = 0 +cmdparser()#0 done