diff --git a/src/libsrc/conio.pla b/src/libsrc/conio.pla index 6cd28bf..3cff845 100644 --- a/src/libsrc/conio.pla +++ b/src/libsrc/conio.pla @@ -352,8 +352,8 @@ def a3grmode(mix) dev_control(cmdsys.devcons, 17, @grcharset) a3viewport(0, 20, 40, 4) for i = 0 to mix - memset(txt1scrn[i], 40, $0000) // text screen - memset(txt2scrn[i], 40, $0000) // color screen + memset(txt1scrn[i], $0000, 40) // text screen + memset(txt2scrn[i], $0000, 40) // color screen next return a2grscrn(@txt2scrn) // point to color screen end @@ -379,23 +379,10 @@ def a13rnd randnum = (randnum << 1) + randnum + 123 return randnum & $7FFF end - // // Machine specific initialization. // when MACHID & MACHID_MODEL - is MACHID_I - conio:keypressed = @a1keypressed - conio:getkey = @a13getkey - conio:home = @a1home - conio:gotoxy = @a1gotoxy - conio:viewport = @a1viewport - conio:texttype = @a1texttype - conio:textmode = @a1textmode - conio:grmode = @a1grmode - conio:tone = @a1tone - conio:rnd = @a13rnd - break is MACHID_III conio:keypressed = @a3keypressed conio:getkey = @a13getkey @@ -408,6 +395,18 @@ when MACHID & MACHID_MODEL conio:tone = @a3tone conio:rnd = @a13rnd break - //otherwise // MACHID_II + is MACHID_I + conio:keypressed = @a1keypressed + conio:getkey = @a13getkey + conio:home = @a1home + conio:gotoxy = @a1gotoxy + conio:viewport = @a1viewport + conio:texttype = @a1texttype + conio:textmode = @a1textmode + conio:grmode = @a1grmode + conio:tone = @a1tone + conio:rnd = @a13rnd + break + otherwise // MACHID_II puts("Found MACHID_MODEL = $"); putb(MACHID & MACHID_MODEL); putln wend done diff --git a/src/libsrc/fileio.pla b/src/libsrc/fileio.pla index 0c35c7f..b96ee59 100644 --- a/src/libsrc/fileio.pla +++ b/src/libsrc/fileio.pla @@ -40,14 +40,14 @@ struc t_fileio end predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a23geteof(refnum), a2openbuf(path, iobuf), a2open(path), a23close(refnum) predef a23read(refnum, buf, len), a2write(refnum, buf, len), a2create(path, type, aux), a23destroy(path) -predef a23newline(refnum, emask, nlchar), a2readblock(unit, buf, block), a2writeblock(unit, buf, block) +predef a2newline(refnum, emask, nlchar), a2readblock(unit, buf, block), a2writeblock(unit, buf, block) // // Exported function table. // word fileio[] word = @a2getpfx, @a23setpfx, @a2getfileinfo, @a23geteof, @a2openbuf, @a2open, @a23close word = @a23read, @a2write, @a2create, @a23destroy -word = @a23newline, @a2readblock, @a2writeblock +word = @a2newline, @a2readblock, @a2writeblock // // SOS/ProDOS error code // @@ -263,7 +263,7 @@ end def a1newline(refnum, emask, nlchar) return perr end -def a23newline(refnum, emask, nlchar) +def a2newline(refnum, emask, nlchar) byte params[4] params.0 = 3 @@ -273,6 +273,16 @@ def a23newline(refnum, emask, nlchar) perr = syscall($C9, @params) return perr end +def a3newline(refnum, emask, nlchar) + byte params[4] + + params.0 = 3 + params.1 = refnum + params.2 = emask ?? $FF :: $00 + params.3 = nlchar + perr = syscall($C9, @params) + return perr +end def a13readblock(unit, buf, block) perr = $27 // IOERR return perr @@ -304,8 +314,18 @@ end // // Machine specific initialization. // -when MACHID & $C8 - is $08 // Apple 1 +when MACHID & MACHID_MODEL + is MACHID_III + fileio:getpfx = @a3getpfx + fileio:getfileinfo = @a3getfileinfo + fileio:open = @a3open + fileio:write = @a3write + fileio:create = @a3create + fileio:newline = @a3newline + fileio:readblock = @a13readblock + fileio:writeblock = @a13writeblock + break + is MACHID_I fileio:getpfx = @a1getpfx fileio:setpfx = @a1setpfx fileio:getfileinfo = @a1getfileinfo @@ -320,15 +340,6 @@ when MACHID & $C8 fileio:readblock = @a13readblock fileio:writeblock = @a13writeblock break - is $C0 // Apple /// - fileio:getpfx = @a3getpfx - fileio:getfileinfo = @a3getfileinfo - fileio:open = @a3open - fileio:write = @a3write - fileio:create = @a3create - fileio:readblock = @a13readblock - fileio:writeblock = @a13writeblock - break otherwise // Apple ][ wend done diff --git a/src/libsrc/longjmp.pla b/src/libsrc/longjmp.pla index 9a4df23..78c9128 100644 --- a/src/libsrc/longjmp.pla +++ b/src/libsrc/longjmp.pla @@ -1,5 +1,12 @@ asm incs !SOURCE "vmsrc/plvmzp.inc" +XPAGE = $1600 +NEXTOP = $F0 +FETCHOP = NEXTOP+1 +IP = FETCHOP+1 +IPL = IP +IPH = IPL+1 +IPX = XPAGE+IPH end // // Save environment (PLASMA ZP and stack) for below and return 0 @@ -13,6 +20,8 @@ export asm except(env) TSX STX TMPL LDY TMPL + LDA IPX ; APPLE 3-ISM + STA TMPH - LDA $0100,Y STA (SRC),Y INY @@ -51,6 +60,8 @@ export asm throw(env, retval) INX BNE - DEC DST+1 + LDA TMPH ; APPLE 3-ISM + STA IPX LDX TMPL TXS LDY TMPL @@ -65,3 +76,4 @@ export asm throw(env, retval) STA ESTKH,X RTS end +done diff --git a/src/toolsrc/ed.pla b/src/toolsrc/ed.pla index c745d4c..ff17804 100755 --- a/src/toolsrc/ed.pla +++ b/src/toolsrc/ed.pla @@ -84,6 +84,8 @@ word strplsize = MAXSTRPLSIZE word strpool, strplmapsize, strlinbuf, strpoolmap byte cursx, cursy, scrnleft, curscol, underchr, curschr word keyin, cursrow, scrntop, cursptr +byte a3echo = $80 +byte a3noecho = $00 // // Predeclared functions // @@ -316,8 +318,8 @@ end def readtxt(filename)#0 byte txtbuf[81], refnum, i, j - if refnum refnum = fileio:open(filename) + if refnum fileio:newline(refnum, $7F, $0D) repeat txtbuf = fileio:read(refnum, @txtbuf + 1, MAXLNLEN) @@ -370,7 +372,11 @@ end // Screen routines // def clrscrn#0 - call($FC58, 0, 0, 0, 0) + if MACHID == $F2 // Apple 3 + putc(28) + else + call($FC58, 0, 0, 0, 0) + fin end def drawrow(row, ofst, strptr)#0 byte numchars @@ -562,6 +568,34 @@ end // // Keyboard routines // +def dev_status(devnum, code, list) + byte params[5] + + params.0 = 3 + params.1 = devnum + params.2 = code + params:3 = list + return syscall($82, @params) +end +def dev_control(devnum, code, list)#1 + byte params[5] + + params.0 = 3 + params.1 = devnum + params.2 = code + params:3 = list + perr = syscall($83, @params) + return perr +end +def keyin3 + byte count, key + repeat + cursflash + dev_status(cmdsys.devcons, 5, @count) + until count + key = getc + return key | $80 +end def keyin2e byte key repeat @@ -603,7 +637,7 @@ def keyin2 elsif key == keyctrlp key = $DF // _ elsif key == keyctrlb - key = $DC // \ + key = $DC // \ elsif key == keyarrowleft if ^pushbttn3 < 128 key = $FF @@ -623,6 +657,19 @@ def keyin2 fin return key end +def setkeyin#0 + when MACHID & MACHID_MODEL + is MACHID_IIE + is MACHID_IIC + keyin = @keyin2e + break + is MACHID_III + keyin = @keyin3 + break + otherwise // ][ or ][+ + keyin = @keyin2 + wend +end def tabkeyin return curscol < MAXLNLEN and curscol & $01 ?? keyspace :: 0 end @@ -827,6 +874,9 @@ def editline(key) return key end def editmode#0 + if MACHID == $F2 // Apple 3 + dev_control(cmdsys.devcons, 11, @a3noecho) + fin repeat when editline(keyin()) is keyarrowup @@ -877,7 +927,7 @@ def editmode#0 is keyctrli keyin = @tabkeyin editline(keyspace) - keyin = !(MACHID & $80) ?? @keyin2 :: @keyin2e + setkeyin break is keyctrlb if flags & insmode @@ -897,9 +947,15 @@ def editmode#0 redraw break is keyescape + if MACHID == $F2 // Apple 3 + dev_control(cmdsys.devcons, 11, @a3echo) + fin cursoff cmdmode if not exit + if MACHID == $F2 // Apple 3 + dev_control(cmdsys.devcons, 11, @a3noecho) + fin redraw fin break @@ -1060,7 +1116,7 @@ def cmdmode#0 wend if perr puts("ERROR: $") - call($FDDA, perr, 0, 0, 0) + putb(perr) else puts("OK") fin @@ -1070,11 +1126,9 @@ end // // Init editor // -if !(MACHID & $80) +setkeyin +if not (MACHID & $80) // ][ or ][+ flags = uppercase | shiftlock - keyin = @keyin2 -else - keyin = @keyin2e fin inittxtbuf arg = argNext(argFirst) diff --git a/src/vmsrc/a1cmd.pla b/src/vmsrc/a1cmd.pla index bd9a226..bae391d 100755 --- a/src/vmsrc/a1cmd.pla +++ b/src/vmsrc/a1cmd.pla @@ -1,6 +1,3 @@ -const FALSE = 0 -const TRUE = not FALSE - const RELADDR = $1000 const inbuff = $200 const freemem = $0006 @@ -803,7 +800,7 @@ def loadmod(mod)#1 moddep = @header.1 defofst = modsize + RELADDR init = 0 - if rdlen > 4 and heap=>2 == $DA7F // DAVE+1 = magic number :-) + if rdlen > 4 and heap=>2 == $6502 // magic number // // This is an EXTended RELocatable (data+bytecode) module. // @@ -1045,7 +1042,7 @@ fin // // Handle commands. // -while TRUE +while 1 if ^cmdptr when toupper(parsecmd(cmdptr)) is 'Q' diff --git a/src/vmsrc/cmd.pla b/src/vmsrc/cmd.pla index 01b715a..db0195d 100755 --- a/src/vmsrc/cmd.pla +++ b/src/vmsrc/cmd.pla @@ -1058,7 +1058,7 @@ def loadmod(mod)#1 moddep = @header.1 defofst = modsize + RELADDR init = 0 - if rdlen > 4 and header:2 == $6502 // DAVE+1 = magic number :-) + if rdlen > 4 and header:2 == $6502 // magic number // // This is an EXTended RELocatable (data+bytecode) module. // @@ -1271,24 +1271,19 @@ def volumes()#0 strbuf = strbuf + 16 next end -def catalog(optpath)#1 - byte path[64] +def catalog(path)#0 byte refnum byte firstblk byte entrylen, entriesblk byte i, type, len word entry, filecnt - if ^optpath - strcpy(@path, optpath) - else - pfxop(@path, GET_PFX) - prstr(@path) - crout() + if !^path + path = @prefix fin - refnum = open(@path) + refnum = open(path) if perr - return perr + return fin firstblk = 1 repeat @@ -1332,7 +1327,6 @@ def catalog(optpath)#1 until !filecnt close(refnum) crout() - return 0 end def stripchars(strptr)#1 while ^strptr and ^(strptr + 1) > ' ' diff --git a/src/vmsrc/plvm03.s b/src/vmsrc/plvm03.s index 8e7ca9a..f1ccde9 100755 --- a/src/vmsrc/plvm03.s +++ b/src/vmsrc/plvm03.s @@ -27,6 +27,7 @@ DROPX = XPAGE+DROP IFPX = XPAGE+IFPH PPX = XPAGE+PPH IPX = XPAGE+IPH +JMPTMPX = XPAGE+JMPTMP TMPX = XPAGE+TMPH SRCX = XPAGE+SRCH DSTX = XPAGE+DSTH @@ -59,6 +60,10 @@ SEGSTART = $A000 STA DROPX,Y DEY BPL - + LDX #$4C ; SET JMPTMP OPCODE + STX JMPTMP +; STA JMPTMPX +; STA JMPTMPX+1 STA TMPX ; CLEAR ALL EXTENDED POINTERS STA SRCX STA DSTX @@ -70,6 +75,8 @@ SEGSTART = $A000 LDA #>SEGSTART STA PPH STA IFPH + LDX #$FF ; INIT STACK POINTER + TXS LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX JMP SOSCMD ;PRHEX PHA @@ -874,6 +881,17 @@ ISLT LDA ESTKL+1,X + BMI ISFLS BPL ISTRU ;* +;* NORMALIZE IP+Y BEFORE CALLING NEXTOP +;* +FIXNEXT TYA + LDY #$00 + CLC + ADC IPL + STA IPL + BCC + + INC IPH ++ JMP NEXTOP +;* ;* BRANCHES ;* BRTRU INX @@ -884,14 +902,6 @@ NOBRNCH INY ;+INC_IP INY ;+INC_IP BMI FIXNEXT JMP NEXTOP -FIXNEXT TYA - LDY #$00 - CLC - ADC IPL - STA IPL - BCC + - INC IPH -+ JMP NEXTOP BRFLS INX LDA ESTKH-1,X ORA ESTKL-1,X @@ -904,6 +914,8 @@ BRNCH TYA ; FLATTEN IP TAY ADC IPH STA TMPH ; ADD BRANCH OFFSET + LDA IPX ; COPY XBYTE FROM IP + STA TMPX LDA (TMP),Y ;CLC ; BETTER NOT CARRY OUT OF IP+Y ADC TMPL @@ -913,6 +925,7 @@ BRNCH TYA ; FLATTEN IP ADC TMPH STA IPH DEY + STY TMPX ; CLEAR TMPX JMP FETCHOP BREQ INX LDA ESTKL-1,X diff --git a/src/vmsrc/soscmd.pla b/src/vmsrc/soscmd.pla index 840fa08..82c422c 100755 --- a/src/vmsrc/soscmd.pla +++ b/src/vmsrc/soscmd.pla @@ -37,7 +37,7 @@ predef execmod(modfile)#1 // word version = $0100 // 01.00 word syspath -word cmdptr +word cmdlnptr word = @execmod byte refcons = 0 byte devcons = 0 @@ -45,7 +45,6 @@ byte devcons = 0 // String pool. // byte console[] = ".CONSOLE" -byte autorun[] = "AUTORUN" byte textmode[] = 16, 0, 15 byte hexchar[] = '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' // @@ -53,6 +52,11 @@ byte hexchar[] = '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E', // byte machid = $F2 // Apple ///, 80 columns // +// Working input buffer overlayed with strings table +// +word cmdptr +byte cmdln = "" +// // Standard Library exported functions. // byte sysmodstr[] = "CMDSYS" @@ -75,16 +79,17 @@ byte hpalignstr[] = "HEAPALLOCALIGN" byte hpallocstr[] = "HEAPALLOC" byte hprelstr[] = "HEAPRELEASE" byte hpavlstr[] = "HEAPAVAIL" +byte sysmods[] = "" // overlay with exported strings byte memsetstr[] = "MEMSET" byte memcpystr[] = "MEMCPY" byte uisgtstr[] = "ISUGT" byte uisgestr[] = "ISUGE" byte uisltstr[] = "ISULT" byte uislestr[] = "ISULE" -byte sysmods[] // overlay with exported strings byte sextstr[] = "SEXT" byte divmodstr[] = "DIVMOD" -byte prefix[] // Overlay with exported symbols table +byte autorun[] = "AUTORUN" +byte prefix[] = "" // Overlay with exported symbols table word exports[] = @sysmodstr, @version word = @sysstr, @syscall word = @callstr, @call @@ -104,6 +109,8 @@ word = @hprelstr, @releaseheap word = @hpavlstr, @availheap word = @memsetstr, @memset word = @memcpystr, @memcpy +word = @strcpystr, @strcpy +word = @strcatstr, @strcat word = @uisgtstr, @uword_isgt word = @uisgestr, @uword_isge word = @uisltstr, @uword_islt @@ -543,43 +550,6 @@ TOUPR AND #$7F RTS end // -// Module symbols are entered into the symbol table -// pre-pended with a '#' to differentiate them -// from normal symbols. -// -//def modtosym(mod, dci) -// byte len, c -// (dci).0 = '#'|$80 -// len = 0 -// repeat -// c = (mod).[len] -// len = len + 1 -// (dci).[len] = c -// until !(c & $80) -// return dci -//end -//asm modtosym(mod, dci)#1 -// LDA ESTKL+1,X -// STA SRCL -// LDA ESTKH+1,X -// STA SRCH -// LDA ESTKL,X -// STA ESTKL+1,X -// STA DSTL -// LDA ESTKH,X -// STA ESTKH+1,X -// STA DSTH -// INX -// LDY #$00 -// LDA #'#'+$80 -//- STA (DST),Y -// ASL -// LDA (SRC),Y -// INY -// BCS - -// RTS -//end -// // Lookup routines. // //def lookuptbl(dci, tbl) @@ -698,7 +668,7 @@ end // if deftbl=>3 == addr // return deftbl // fin -// deftbl = deftbl + 5 +// deftbl = deftbl + 6 // loop // return 0 //end @@ -725,7 +695,7 @@ asm lookupdef(addr, deftbl)#1 LDA SRCH STA ESTKH,X RTS -+ LDA #$05 ++ LDA #$06 CLC ADC SRCL STA SRCL @@ -963,17 +933,6 @@ def seg_release(segnum)#1 perr = syscall($45, @params) return perr end -// -// Other SOS calls. -// -def quit()#0 - byte params[1] - - close(0) - params.0 = 0 - perr = syscall($65, @params) -end - // // CONSOLE I/O // @@ -1099,14 +1058,6 @@ end // // Module routines. // -//def lookupmod(mod)#1 -// byte dci[17] -// return lookuptbl(modtosym(mod, @dci), symtbl) -//end -//def addmod(mod, addr)#0 -// byte dci[17] -// addsym(modtosym(mod, @dci), addr) -//end def lookupextern(esd, index)#1 word sym, addr byte str[16] @@ -1156,16 +1107,17 @@ def loadmod(mod)#1 modsize = header:0 moddep = @header.1 defofst = modsize + RELADDR + defext = 0 init = 0 - if rdlen > 4 and header:2 == $6502 // DAVE+1 = magic number :-) + if rdlen > 4 and header:2 == $6502 // magic number // // This is an EXTended RELocatable (data+bytecode) module. // systemflags = header:4 | systemflags - defofst = header:6 - defcnt = header:8 - init = header:10 - moddep = @header.12 + defofst = header:6 + defcnt = header:8 + init = header:10 + moddep = @header.12 // // Load module dependencies. // @@ -1230,18 +1182,20 @@ def loadmod(mod)#1 esd = esd + 4 loop esd = esd + 1 - // - // Locate bytecode defs in allocated segment. - // - modseg[modid] = seg_find($00, @codeseg, @defaddr, (rld - bytecode + 255) >> 8, modid + $12) - if perr - return -perr + if defcnt + // + // Locate bytecode defs in allocated segment. + // + modseg[modid] = seg_find($00, @codeseg, @defaddr, (rld - bytecode + 255) >> 8, modid + $12) + if perr + return -perr + fin + modid = modid + 1 + defext = (codeseg.0 | $80) - 1 + defaddr = (codeseg & $FF00) + $6000 + codefix = defaddr - bytecode + defofst = defaddr - defofst fin - modid = modid + 1 - defext = (codeseg.0 | $80) - 1 - defaddr = (codeseg & $FF00) + $6000 - codefix = defaddr - bytecode - defofst = defaddr - defofst // // Run through the DeFinition Dictionary. // @@ -1350,7 +1304,7 @@ def volumes()#0 if dev_info(i, @devname, @info, 11) == 0 prstr(@devname) if volume(@devname, @volname, @ttlblks, @freblks) == 0 - prstr(" => ") + prstr(" => /") prstr(@volname) cout('/') fin @@ -1359,24 +1313,19 @@ def volumes()#0 next perr = 0 end -def catalog(optpath)#1 - byte path[64] +def catalog(path)#0 byte refnum byte firstblk byte entrylen, entriesblk byte i, type, len word entry, filecnt - if ^optpath - memcpy(@path, optpath, ^optpath + 1) - else - getpfx(@path) - prstr(@path) - crout() + if !^path + path = @prefix fin - refnum = open(@path) + refnum = open(path) if perr - return perr + return fin firstblk = 1 repeat @@ -1420,7 +1369,6 @@ def catalog(optpath)#1 until filecnt == 0 close(refnum) crout() - return 0 end def stripchars(strptr)#1 while ^strptr and ^(strptr + 1) > ' ' @@ -1493,7 +1441,7 @@ init_cons // // Print PLASMA version // -prstr("PLASMA Pre3 "); prbyte(version.1); cout('.'); prbyte(version.0); crout +prstr("PLASMA Pre4 "); prbyte(version.1); cout('.'); prbyte(version.0); crout // // Init 2K symbol table. // @@ -1513,9 +1461,10 @@ syspath = @sysmods // // Try to load autorun. // -cmdptr = heap -^cmdptr = 0 -autorun = open(@autorun) +cmdlnptr = @cmdln +cmdptr = heap +^cmdptr = 0 +autorun = open(@autorun) if autorun > 0 ^cmdptr = read(autorun, cmdptr + 1, 64) close(autorun) @@ -1534,13 +1483,16 @@ perr = 0 while 1 if ^cmdptr when toupper(parsecmd(cmdptr)) - is 'Q' - quit is 'C' catalog(cmdptr) break is 'P' - setpfx(cmdptr) + if ^cmdptr and ^(cmdptr + 1) <> '/' + strcat(@prefix, cmdptr) + else + strcpy(@prefix, cmdptr) + fin + setpfx(@prefix) break is '/' repeat @@ -1561,7 +1513,7 @@ while 1 saveX execmod(striptrail(cmdptr)) restoreX - write(refcons, @textmode, 3) + init_cons break otherwise prstr("?\n") @@ -1578,5 +1530,6 @@ while 1 fin prstr(getpfx(@prefix)) cmdptr = rdstr($BA) + strcpy(@cmdln, cmdptr) loop done