mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-08-21 06:29:07 +00:00
change opensys to allocate number of I/O buffers for open
This commit is contained in:
parent
384c6e8a18
commit
16932e90f7
@ -38,7 +38,7 @@ import fileio
|
||||
word setpfx
|
||||
word getfileinfo
|
||||
word geteof
|
||||
word openbuf
|
||||
word iobufalloc
|
||||
word open
|
||||
word close
|
||||
word read
|
||||
|
@ -27,7 +27,7 @@ struc t_fileio
|
||||
word setpfx
|
||||
word getfileinfo
|
||||
word geteof
|
||||
word openbuf
|
||||
word iobufalloc
|
||||
word open
|
||||
word close
|
||||
word read
|
||||
@ -38,14 +38,14 @@ struc t_fileio
|
||||
word readblock
|
||||
word writeblock
|
||||
end
|
||||
predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a23geteof(refnum), a2openbuf(path, iobuf), a2open(path), a23close(refnum)
|
||||
predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a23geteof(refnum), a2iobufs(iobufs), a2open(path), a2close(refnum)
|
||||
predef a23read(refnum, buf, len), a2write(refnum, buf, len), a2create(path, type, aux), a23destroy(path)
|
||||
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 = @a2getpfx, @a23setpfx, @a2getfileinfo, @a23geteof, @a2iobufs, @a2open, @a2close
|
||||
word = @a23read, @a2write, @a2create, @a23destroy
|
||||
word = @a2newline, @a2readblock, @a2writeblock
|
||||
//
|
||||
@ -53,6 +53,12 @@ word = @a2newline, @a2readblock, @a2writeblock
|
||||
//
|
||||
export byte perr
|
||||
//
|
||||
// I/O buffers
|
||||
//
|
||||
const MAX_IOBUFS = 4
|
||||
byte iobuf_ref[MAX_IOBUFS]
|
||||
word iobuf_addr[MAX_IOBUFS] = sysbuf
|
||||
//
|
||||
// ProDOS/SOS routines
|
||||
//
|
||||
def a1getpfx(path)
|
||||
@ -128,34 +134,54 @@ def a1open(path)
|
||||
*CFFA1FileName = path
|
||||
return 0
|
||||
end
|
||||
def a2openbuf(path, iobuf)
|
||||
byte params[6]
|
||||
params.0 = 3
|
||||
params:1 = path
|
||||
params:3 = iobuf
|
||||
params.5 = 0
|
||||
perr = syscall($C8, @params)
|
||||
return params.5
|
||||
def a2iobufs(iobufs)
|
||||
byte i
|
||||
word freebuf, bufaddr
|
||||
|
||||
if iobufs > MAX_IOBUFS
|
||||
iobufs = MAX_IOBUFS
|
||||
fin
|
||||
if iobufs
|
||||
iobufs-- // Subtract off system I/O buffer
|
||||
if iobufs
|
||||
bufaddr = heapallocalign(1024 * iobufs, 8, @freebuf)
|
||||
for i = 1 to MAX_IOBUFS-1
|
||||
if not iobuf_addr[i]
|
||||
iobuf_addr[i] = bufaddr
|
||||
bufaddr = bufaddr + 1024
|
||||
iobufs--
|
||||
if not iobufs
|
||||
return freebuf
|
||||
fin
|
||||
fin
|
||||
next
|
||||
return freebuf
|
||||
fin
|
||||
else
|
||||
for i = 1 to MAX_IOBUFS-1
|
||||
iobuf_addr[i] = 0 // Free I/O buffers if 0 passed in
|
||||
next
|
||||
fin
|
||||
return 0
|
||||
end
|
||||
def a13iobufs(iobufs)
|
||||
return 0
|
||||
end
|
||||
def a2open(path)
|
||||
byte params[6]
|
||||
params.0 = 3
|
||||
params:1 = path
|
||||
params:3 = sysbuf
|
||||
params.5 = 0
|
||||
perr = syscall($C8, @params)
|
||||
return params.5
|
||||
end
|
||||
def a3openbuf(path, iobuf)
|
||||
byte params[7]
|
||||
|
||||
params.0 = 4
|
||||
params:1 = path
|
||||
params.3 = 0
|
||||
params:4 = iobuf
|
||||
params.6 = 0
|
||||
perr = syscall($C8, @params)
|
||||
return params.3
|
||||
byte i, params[6]
|
||||
|
||||
for i = 0 to MAX_IOBUFS-1
|
||||
if iobuf_addr[i] and not iobuf_ref[i]
|
||||
params.0 = 3
|
||||
params:1 = path
|
||||
params:3 = iobuf_addr[i]
|
||||
params.5 = 0
|
||||
perr = syscall($C8, @params)
|
||||
iobuf_ref[i] = params.5
|
||||
return params.5
|
||||
fin
|
||||
next
|
||||
return 0
|
||||
end
|
||||
def a3open(path)
|
||||
byte params[7]
|
||||
@ -171,7 +197,22 @@ end
|
||||
def a1close(refnum)
|
||||
return perr
|
||||
end
|
||||
def a23close(refnum)
|
||||
def a2close(refnum)
|
||||
byte i, params[2]
|
||||
|
||||
for i = 0 to MAX_IOBUFS-1
|
||||
if refnum == iobuf_ref[i]
|
||||
iobuf_ref[i] = 0
|
||||
params.0 = 1
|
||||
params.1 = refnum
|
||||
perr = syscall($CC, @params)
|
||||
return perr
|
||||
fin
|
||||
next
|
||||
perr = $45
|
||||
return perr
|
||||
end
|
||||
def a3close(refnum)
|
||||
byte params[2]
|
||||
|
||||
params.0 = 1
|
||||
@ -318,7 +359,9 @@ when MACHID & MACHID_MODEL
|
||||
is MACHID_III
|
||||
fileio:getpfx = @a3getpfx
|
||||
fileio:getfileinfo = @a3getfileinfo
|
||||
fileio:iobufalloc = @a13iobufs
|
||||
fileio:open = @a3open
|
||||
fileio:close = @a3close
|
||||
fileio:write = @a3write
|
||||
fileio:create = @a3create
|
||||
fileio:newline = @a3newline
|
||||
@ -330,6 +373,7 @@ when MACHID & MACHID_MODEL
|
||||
fileio:setpfx = @a1setpfx
|
||||
fileio:getfileinfo = @a1getfileinfo
|
||||
fileio:geteof = @a1geteof
|
||||
fileio:iobufalloc = @a13iobufs
|
||||
fileio:open = @a1open
|
||||
fileio:close = @a1close
|
||||
fileio:read = @a1read
|
||||
|
@ -508,7 +508,7 @@ def init_idglobal#0
|
||||
fixup_addr = heapalloc(fixup_num*2)
|
||||
idglobal_tbl = heapalloc(globalbufsz)
|
||||
idlocal_tbl = heapalloc(localbufsz)
|
||||
codebufsz = heapavail - 4096
|
||||
codebufsz = heapavail - 2048
|
||||
codebuff = heapalloc(codebufsz)
|
||||
codeptr = codebuff
|
||||
lastglobal = idglobal_tbl
|
||||
|
@ -343,8 +343,7 @@ def nextln
|
||||
if incref; puts("Nested INCLUDEs not allowed\n"); exit_err(0); fin
|
||||
if scan <> STR_TKN; puts("Missing INCLUDE file\n"); exit_err(0); fin
|
||||
strcpy(@incfile, constval)
|
||||
sysincbuf = heapallocalign(1024, 8, @sysincfre)
|
||||
incref = fileio:openbuf(@incfile, sysincbuf)
|
||||
incref = fileio:open(@incfile)
|
||||
if not incref
|
||||
puts("Unable to open INCLUDE file: ")
|
||||
puts(@incfile)
|
||||
@ -362,7 +361,6 @@ def nextln
|
||||
else
|
||||
if refnum == incref
|
||||
fileio:close(incref)
|
||||
heaprelease(sysincfre)
|
||||
incref = 0
|
||||
refnum = srcref
|
||||
parsefile = @srcfile
|
||||
|
@ -278,7 +278,6 @@ byte outflags
|
||||
byte refnum, srcref, incref
|
||||
byte[32] srcfile, incfile, relfile
|
||||
word parsefile // Pointer to current file
|
||||
word sysincbuf, sysincfre // System I/O buffer for include files
|
||||
word srcline // Saved source line number
|
||||
//
|
||||
// Scanner variables
|
||||
@ -464,6 +463,7 @@ if ^arg
|
||||
fin
|
||||
fin
|
||||
if srcfile and relfile
|
||||
fileio:iobufalloc(2) // Reserve two I/O buffers
|
||||
srcref = fileio:open(@srcfile)
|
||||
if srcref
|
||||
fileio:newline(srcref, $7F, $0D)
|
||||
|
Loading…
Reference in New Issue
Block a user