mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-03-20 03:31:27 +00:00
Fix some SOS exemod memory problems and remove last hard-coded Apple
II-ism from PLFORTH
This commit is contained in:
parent
ef9fc81ece
commit
85710bbfdf
@ -23,14 +23,14 @@ const sysbuf = $0800
|
||||
//
|
||||
// External interface
|
||||
//
|
||||
predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a2setfileinfo(path, fileinfo), a23geteof(refnum)#2, a23seteof(refnum, eofl, eofh), a2iobufs(iobufs), a2open(path), a2close(refnum)
|
||||
predef a2getpfx(path), a2setpfx(path), a2getfileinfo(path, fileinfo), a2setfileinfo(path, fileinfo), a23geteof(refnum)#2, a23seteof(refnum, eofl, eofh), a2iobufs(iobufs), a2open(path), a2close(refnum)
|
||||
predef a23read(refnum, buf, len), a2write(refnum, buf, len), a2create(path, type, aux), a23destroy(path), a23rename(path, newpath)
|
||||
predef a2newline(refnum, emask, nlchar), a2online(unit, buf), a2readblock(unit, buf, block), a2writeblock(unit, buf, block)
|
||||
//
|
||||
// Exported function table.
|
||||
//
|
||||
word fileio[]
|
||||
word = @a2getpfx, @a23setpfx, @a2getfileinfo, @a2setfileinfo, @a23geteof, @a23seteof, @a2iobufs, @a2open, @a2close
|
||||
word = @a2getpfx, @a2setpfx, @a2getfileinfo, @a2setfileinfo, @a23geteof, @a23seteof, @a2iobufs, @a2open, @a2close
|
||||
word = @a23read, @a2write, @a2create, @a23destroy, @a23rename
|
||||
word = @a2newline, @a2online, @a2readblock, @a2writeblock
|
||||
//
|
||||
@ -60,7 +60,7 @@ def a2getpfx(path)
|
||||
return path
|
||||
end
|
||||
def a3getpfx(path)
|
||||
byte params[3]
|
||||
byte params[4]
|
||||
|
||||
params.0 = 2
|
||||
params:1 = path
|
||||
@ -71,7 +71,7 @@ end
|
||||
def a1setpfx(path)
|
||||
return path
|
||||
end
|
||||
def a23setpfx(path)
|
||||
def a2setpfx(path)
|
||||
byte params[3]
|
||||
|
||||
params.0 = 1
|
||||
@ -79,6 +79,29 @@ def a23setpfx(path)
|
||||
perr = syscall($C6, @params)
|
||||
return path
|
||||
end
|
||||
def a3setpfx(path)
|
||||
byte params[6]
|
||||
byte fileinfo[2]
|
||||
char fullpath[65]
|
||||
|
||||
if ^path and ^(path + 1) <> '/' and ^(path + 1) <> '.'
|
||||
a3getpfx(@fullpath)
|
||||
strcat(@fullpath, path)
|
||||
path = @fullpath
|
||||
fin
|
||||
params.0 = 3
|
||||
params:1 = path
|
||||
params:3 = @fileinfo
|
||||
params.5 = 2
|
||||
if not syscall($C4, @params) and (fileinfo.1 == $00 or fileinfo.1 == $0F) // Make sure it's a directory
|
||||
params.0 = 1
|
||||
params:1 = path
|
||||
syscall($C6, @params)
|
||||
else
|
||||
a3getpfx(path) // Get current path
|
||||
fin
|
||||
return path
|
||||
end
|
||||
def a1getfileinfo(path, fileinfo)
|
||||
perr = $01
|
||||
return perr
|
||||
@ -445,6 +468,7 @@ end
|
||||
when MACHID & MACHID_MODEL
|
||||
is MACHID_III
|
||||
fileio:getpfx = @a3getpfx
|
||||
fileio:setpfx = @a3setpfx
|
||||
fileio:getfileinfo = @a3getfileinfo
|
||||
fileio:setfileinfo = @a3setfileinfo
|
||||
fileio:iobufalloc = @a13iobufs
|
||||
|
@ -6,22 +6,25 @@ include "inc/longjmp.plh"
|
||||
//
|
||||
// Internal variables
|
||||
//
|
||||
word vlist, infunc, inptr, IIP, W
|
||||
word vmvect, startheap, arg
|
||||
word keyinbuf = $1FF
|
||||
const JSR = $20 // 6502 JSR opcode needed for VM entry
|
||||
const SRCREFS = 2
|
||||
const INBUF_SIZE = 128
|
||||
word vlist, infunc, inptr, IIP, W
|
||||
word vmvect, startheap, arg
|
||||
byte srclevel = 0
|
||||
word inbufptr
|
||||
byte inref[SRCREFS]
|
||||
word previnptr[SRCREFS]
|
||||
//
|
||||
// Internal buffers
|
||||
//
|
||||
res[SRCREFS * INBUF_SIZE] inbuf
|
||||
res[t_except] exitforth
|
||||
//
|
||||
// Input references, pointers, and saved values
|
||||
//
|
||||
word keyinbuf = @inbuf // Point somewhere benign for starters (updated in keyin)
|
||||
word inbufptr
|
||||
byte inref[SRCREFS]
|
||||
word previnptr[SRCREFS]
|
||||
//
|
||||
// RSTACK
|
||||
//
|
||||
const RSTK_SIZE = 16
|
||||
|
@ -189,7 +189,7 @@ def shell#1
|
||||
catalog(cmdptr)
|
||||
break
|
||||
is 'P'
|
||||
if ^cmdptr and ^(cmdptr + 1) <> '/'
|
||||
if ^cmdptr and ^(cmdptr + 1) <> '/' and ^(cmdptr + 1) <> '.'
|
||||
strcat(@prefix, cmdptr)
|
||||
else
|
||||
strcpy(@prefix, cmdptr)
|
||||
|
@ -264,7 +264,7 @@ def shell#1
|
||||
catalog(cmdptr)
|
||||
break
|
||||
is 'P'
|
||||
if ^cmdptr and ^(cmdptr + 1) <> '/'
|
||||
if ^cmdptr and ^(cmdptr + 1) <> '/' and ^(cmdptr + 1) <> '.'
|
||||
strcat(@prefix, cmdptr)
|
||||
else
|
||||
strcpy(@prefix, cmdptr)
|
||||
|
@ -1225,24 +1225,23 @@ def loadmod(mod)#1
|
||||
end
|
||||
def execmod(modfile)#1
|
||||
byte moddci[63]
|
||||
word saveheap, savesym, saveflags
|
||||
word saveheap, savesym, saveflags, savemodid
|
||||
|
||||
perr = 1
|
||||
if stodci(modfile, @moddci)
|
||||
saveheap = heap
|
||||
savesym = lastsym
|
||||
saveflags = systemflags
|
||||
savemodid = modid
|
||||
if loadmod(@moddci) < modkeep
|
||||
lastsym = savesym
|
||||
heap = saveheap
|
||||
while modid
|
||||
while modid > savemodid
|
||||
modid--
|
||||
seg_release(modseg[modid])
|
||||
loop
|
||||
xpokeb(symtbl.0, lastsym, 0)
|
||||
systemflags = saveflags
|
||||
else
|
||||
modid = 0
|
||||
fin
|
||||
fin
|
||||
return -perr
|
||||
|
@ -1248,24 +1248,23 @@ def loadmod(mod)#1
|
||||
end
|
||||
def execmod(modfile)#1
|
||||
byte moddci[63]
|
||||
word saveheap, savesym, saveflags
|
||||
word saveheap, savesym, saveflags, savemodid
|
||||
|
||||
perr = 1
|
||||
if stodci(modfile, @moddci)
|
||||
saveheap = heap
|
||||
savesym = lastsym
|
||||
saveflags = systemflags
|
||||
savemodid = modid
|
||||
if loadmod(@moddci) < modkeep
|
||||
lastsym = savesym
|
||||
heap = saveheap
|
||||
while modid
|
||||
while modid > savemodid
|
||||
modid--
|
||||
seg_release(modseg[modid])
|
||||
loop
|
||||
xpokeb(symtbl.0, lastsym, 0)
|
||||
systemflags = saveflags
|
||||
else
|
||||
modid = 0
|
||||
fin
|
||||
fin
|
||||
return -perr
|
||||
|
Loading…
x
Reference in New Issue
Block a user