From 1783aaef7a38ec5e1296707db73f90e8f594362c Mon Sep 17 00:00:00 2001 From: Dave Schmenk Date: Fri, 27 Apr 2018 13:06:49 -0700 Subject: [PATCH] Fix resetmemfiles, use heap for catalog/volumes, and free CMD init code --- src/libsrc/apple/jit.pla | 2 +- src/libsrc/apple/jit16.pla | 2 +- src/libsrc/apple/mouse.pla | 2 +- src/vmsrc/apple/cmd.pla | 124 +++++++++++++++++--------------- src/vmsrc/apple/cmdjit.pla | 132 +++++++++++++++++++---------------- src/vmsrc/apple/cmdjitstub.s | 4 -- src/vmsrc/apple/cmdstub.s | 4 -- src/vmsrc/apple/plvmjit02.s | 17 ++--- 8 files changed, 150 insertions(+), 137 deletions(-) diff --git a/src/libsrc/apple/jit.pla b/src/libsrc/apple/jit.pla index dc4331c..356f791 100644 --- a/src/libsrc/apple/jit.pla +++ b/src/libsrc/apple/jit.pla @@ -42,6 +42,6 @@ fin *jitcomp = @compiler cmdsys.jitcount = 44 cmdsys.jitsize = 96 -puts("JITC") +puts("JITC enabled\n") return modkeep done diff --git a/src/libsrc/apple/jit16.pla b/src/libsrc/apple/jit16.pla index 0b61a9f..7b0c39c 100644 --- a/src/libsrc/apple/jit16.pla +++ b/src/libsrc/apple/jit16.pla @@ -48,6 +48,6 @@ fin *jitcomp = @compiler cmdsys.jitcount = 44 cmdsys.jitsize = 96 -puts("16-bit VM/JITC") +puts("16-bit VM/JITC enabled\n") return modkeep done diff --git a/src/libsrc/apple/mouse.pla b/src/libsrc/apple/mouse.pla index 885278f..baa8c97 100644 --- a/src/libsrc/apple/mouse.pla +++ b/src/libsrc/apple/mouse.pla @@ -98,7 +98,7 @@ export def mouseInit // // Hook mouse IRQ handler into ProDOS IRQ chain // - puts("serviceMouse @ $"); puth(@serviceMouse); putln; getc + puts("serviceMouse @ $"); puth(@serviceMouse); putln params.0 = 2 params.1 = 0 params:2 = @serviceMouse diff --git a/src/vmsrc/apple/cmd.pla b/src/vmsrc/apple/cmd.pla index 61f450f..b445618 100755 --- a/src/vmsrc/apple/cmd.pla +++ b/src/vmsrc/apple/cmd.pla @@ -1,6 +1,5 @@ const MACHID = $BF98 const iobuffer = $0800 -const databuff = $2000 const RELADDR = $1000 const symtbl = $0C00 const freemem = $0006 @@ -1157,9 +1156,9 @@ def volumes()#0 params.0 = 2 params.1 = 0 - params:2 = databuff + params:2 = heap perr = syscall($C5, @params) - strbuf = databuff + strbuf = heap for i = 0 to 15 ^strbuf = ^strbuf & $0F if ^strbuf @@ -1184,12 +1183,12 @@ def catalog(path)#0 fin firstblk = 1 repeat - if read(refnum, databuff, 512) == 512 - entry = databuff + 4 + if read(refnum, heap, 512) == 512 + entry = heap + 4 if firstblk - entrylen = databuff.$23 - entriesblk = databuff.$24 - filecnt = databuff:$25 + entrylen = heap->$23 + entriesblk = heap->$24 + filecnt = heap=>$25 entry = entry + entrylen fin for i = firstblk to entriesblk @@ -1272,7 +1271,7 @@ def resetmemfiles()#0 // // Close all files // - ^$BFD8 = 0 + ^$BF94 = 0 close(0) // // Set memory bitmap @@ -1291,7 +1290,7 @@ def execsys(sysfile)#0 striptrail(sysfile) refnum = open(sysfile) if refnum - len = read(refnum, databuff, $FFFF) + len = read(refnum, $2000, $FFFF) resetmemfiles() if len strcpy(sysfile, $280) @@ -1326,13 +1325,68 @@ def execmod(modfile)#1 return -perr end // +// Command line processor +// +def docmds#0 + while 1 + if ^getlnbuf + strcpy(@cmdln, getlnbuf) + when toupper(parsecmd(getlnbuf)) + is 'C' + catalog(getlnbuf) + break + is 'P' + pfxop(getlnbuf, SET_PFX) + break + is '/' + repeat + prefix-- + until prefix[prefix] == '/' + if prefix > 1 + pfxop(@prefix, SET_PFX) + fin + break + is 'V' + volumes() + break + is '-' + execsys(getlnbuf) + break + is '+' + execmod(striptrail(getlnbuf)) + // + // Clean up + // + resetmemfiles + break + otherwise + cout('?') + wend + if perr + prstr("ERR:$") + prbyte(perr) + else + prstr("OK") + fin + crout() + fin + prstr(pfxop(@prefix, GET_PFX)) + rdstr($BA) + loop +end +// +// Dummy definition to get free heap +// +def lastdef#0 +end +// // Get heap start. // -heap = *freemem +heap = @lastdef // // Print PLASMA version // -prstr("PLASMA 2.0 Dev 64K \n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout +prstr("PLASMA 2.0 Dev 64K\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout // // Init symbol table. // @@ -1361,49 +1415,5 @@ else prstr("MEM FREE:$"); prword(availheap); crout fin perr = 0 -while 1 - if ^getlnbuf - strcpy(@cmdln, getlnbuf) - when toupper(parsecmd(getlnbuf)) - is 'C' - catalog(getlnbuf) - break - is 'P' - pfxop(getlnbuf, SET_PFX) - break - is '/' - repeat - prefix-- - until prefix[prefix] == '/' - if prefix > 1 - pfxop(@prefix, SET_PFX) - fin - break - is 'V' - volumes() - break - is '-' - execsys(getlnbuf) - break - is '+' - execmod(striptrail(getlnbuf)) - // - // Clean up - // - resetmemfiles - break - otherwise - cout(perr)//cout('?') - wend - if perr - prstr("ERR:$") - prbyte(perr) - else - prstr("OK") - fin - crout() - fin - prstr(pfxop(@prefix, GET_PFX)) - rdstr($BA) -loop +docmds done diff --git a/src/vmsrc/apple/cmdjit.pla b/src/vmsrc/apple/cmdjit.pla index 8931509..ced5103 100755 --- a/src/vmsrc/apple/cmdjit.pla +++ b/src/vmsrc/apple/cmdjit.pla @@ -1,6 +1,5 @@ const MACHID = $BF98 const iobuffer = $0800 -const databuff = $2000 const RELADDR = $1000 const symtbl = $0C00 const freemem = $0006 @@ -1221,9 +1220,9 @@ def volumes()#0 params.0 = 2 params.1 = 0 - params:2 = databuff + params:2 = heap perr = syscall($C5, @params) - strbuf = databuff + strbuf = heap for i = 0 to 15 ^strbuf = ^strbuf & $0F if ^strbuf @@ -1248,12 +1247,12 @@ def catalog(path)#0 fin firstblk = 1 repeat - if read(refnum, databuff, 512) == 512 - entry = databuff + 4 + if read(refnum, heap, 512) == 512 + entry = heap + 4 if firstblk - entrylen = databuff.$23 - entriesblk = databuff.$24 - filecnt = databuff:$25 + entrylen = heap->$23 + entriesblk = heap->$24 + filecnt = heap=>$25 entry = entry + entrylen fin for i = firstblk to entriesblk @@ -1336,7 +1335,7 @@ def resetmemfiles()#0 // // Close all files // - ^$BFD8 = 0 + ^$BF94 = 0 close(0) // // Set memory bitmap @@ -1355,7 +1354,7 @@ def execsys(sysfile)#0 striptrail(sysfile) refnum = open(sysfile) if refnum - len = read(refnum, databuff, $FFFF) + len = read(refnum, $2000, $FFFF) resetmemfiles() if len strcpy(sysfile, $280) @@ -1394,13 +1393,71 @@ def execmod(modfile)#1 return -perr end // +// Command line processor +// +def docmds#0 + loadmod(jitmod) // Cannot do this in init code - it will overwrite it! + xheap = $0400 // Reset heap to point at low memory + xheaptop = $A000 // Top below JITC + while 1 + if ^getlnbuf + strcpy(@cmdln, getlnbuf) + when toupper(parsecmd(getlnbuf)) + is 'C' + catalog(getlnbuf) + break + is 'P' + pfxop(getlnbuf, SET_PFX) + break + is '/' + repeat + prefix-- + until prefix[prefix] == '/' + if prefix > 1 + pfxop(@prefix, SET_PFX) + fin + break + is 'V' + volumes() + break + is '-' + execsys(getlnbuf) + break + is '+' + execmod(striptrail(getlnbuf)) + // + // Clean up + // + resetmemfiles + break + otherwise + cout('?') + wend + if perr + prstr("ERR:$") + prbyte(perr) + else + prstr("OK") + fin + crout() + fin + prstr(pfxop(@prefix, GET_PFX)) + rdstr($BA) + loop +end +// +// Dummy definition to get free heap +// +def lastdef#0 +end +// // Get heap start. // -heap = *freemem +heap = @lastdef // // Print PLASMA version // -prstr("PLASMA 2.0 Dev 128K ")//; prbyte(version.1); cout('.'); prbyte(version.0); crout +prstr("PLASMA 2.0 Dev 128K\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout // // Init symbol table. // @@ -1415,9 +1472,6 @@ loop strcat(strcpy(@sysmods, $280), "SYS/")) // This is the path to CMD syspath = @sysmods // Update external interface table syscmdln = @cmdln -loadmod(jitmod) -xheap = $0400 // Reset heap to point at low memory -xheaptop = $A000 // Top where JIT loaded // // Try to load autorun. // @@ -1429,52 +1483,8 @@ else // // Print some startup info. // - prstr("\nMEM FREE:$"); prword(availheap); crout + prstr("MEM FREE:$"); prword(availheap); crout fin perr = 0 -while 1 - if ^getlnbuf - strcpy(@cmdln, getlnbuf) - when toupper(parsecmd(getlnbuf)) - is 'C' - catalog(getlnbuf) - break - is 'P' - pfxop(getlnbuf, SET_PFX) - break - is '/' - repeat - prefix-- - until prefix[prefix] == '/' - if prefix > 1 - pfxop(@prefix, SET_PFX) - fin - break - is 'V' - volumes() - break - is '-' - execsys(getlnbuf) - break - is '+' - execmod(striptrail(getlnbuf)) - // - // Clean up - // - resetmemfiles - break - otherwise - cout('?') - wend - if perr - prstr("ERR:$") - prbyte(perr) - else - prstr("OK") - fin - crout() - fin - prstr(pfxop(@prefix, GET_PFX)) - rdstr($BA) -loop +docmds done diff --git a/src/vmsrc/apple/cmdjitstub.s b/src/vmsrc/apple/cmdjitstub.s index ba4e9af..4f8957a 100644 --- a/src/vmsrc/apple/cmdjitstub.s +++ b/src/vmsrc/apple/cmdjitstub.s @@ -27,10 +27,6 @@ JITCODE = $03E4 INC DSTH DEX ; STOP WHEN DST=$2000 REACHED BNE - - LDA #<_CMDEND - STA SRCL - LDA #>_CMDEND - STA SRCH ; ; INIT VM ENVIRONMENT STACK POINTERS ; diff --git a/src/vmsrc/apple/cmdstub.s b/src/vmsrc/apple/cmdstub.s index 54527d4..dc7ee90 100644 --- a/src/vmsrc/apple/cmdstub.s +++ b/src/vmsrc/apple/cmdstub.s @@ -25,10 +25,6 @@ LCBNK1 = $08 INC DSTH DEX ; STOP WHEN DST=$2000 REACHED BNE - - LDA #<_CMDEND - STA SRCL - LDA #>_CMDEND - STA SRCH ; ; INIT VM ENVIRONMENT STACK POINTERS ; diff --git a/src/vmsrc/apple/plvmjit02.s b/src/vmsrc/apple/plvmjit02.s index 3e10cd2..9c05eab 100755 --- a/src/vmsrc/apple/plvmjit02.s +++ b/src/vmsrc/apple/plvmjit02.s @@ -1832,7 +1832,7 @@ CALL INY ;+INC_IP LDA (IP),Y STA TMPH TYA - CLC + SEC ADC IPL PHA LDA IPH @@ -1845,7 +1845,7 @@ CALL INY ;+INC_IP STA IPL LDA #>OPTBL ; MAKE SURE WE'RE INDEXING THE RIGHT TABLE STA OPPAGE - LDY #$01 + LDY #$00 JMP FETCHOP CALLX INY ;+INC_IP LDA (IP),Y @@ -1854,7 +1854,7 @@ CALLX INY ;+INC_IP LDA (IP),Y STA TMPH TYA - CLC + SEC ADC IPL PHA LDA IPH @@ -1876,7 +1876,7 @@ CALLX INY ;+INC_IP STA IPL LDA #>OPXTBL ; MAKE SURE WE'RE INDEXING THE RIGHT TABLE STA OPPAGE - LDY #$01 + LDY #$00 JMP FETCHOP ;* ;* INDIRECT CALL TO ADDRESS (NATIVE CODE) @@ -1887,7 +1887,7 @@ ICAL LDA ESTKL,X STA TMPH INX TYA - CLC + SEC ADC IPL PHA LDA IPH @@ -1900,7 +1900,7 @@ ICAL LDA ESTKL,X STA IPL LDA #>OPTBL ; MAKE SURE WE'RE INDEXING THE RIGHT TABLE STA OPPAGE - LDY #$01 + LDY #$00 JMP FETCHOP ICALX LDA ESTKL,X STA TMPL @@ -1908,7 +1908,7 @@ ICALX LDA ESTKL,X STA TMPH INX TYA - CLC + SEC ADC IPL PHA LDA IPH @@ -1922,6 +1922,7 @@ ICALX LDA ESTKL,X PHP PLA STA PSR + SEI STA ALTRDON PLA STA IPH @@ -1929,7 +1930,7 @@ ICALX LDA ESTKL,X STA IPL LDA #>OPXTBL ; MAKE SURE WE'RE INDEXING THE RIGHT TABLE STA OPPAGE - LDY #$01 + LDY #$00 JMP FETCHOP ;* ;* JUMP INDIRECT TRHOUGH TMP