mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-08-07 18:25:03 +00:00
Make fileio intarface consistent among 1, II, and ///
This commit is contained in:
@@ -10,17 +10,13 @@ import fileio
|
||||
// Memory alocate bitmap
|
||||
const MEMTABL = $BF58
|
||||
//
|
||||
// ProDOS error codes
|
||||
// SOS/ProDOS error codes
|
||||
//
|
||||
const PRODOS_ERR_OK = $00
|
||||
const PRODOS_ERR_BAD_CALL_NUM = $01
|
||||
const PRODOS_ERR_BAD_PARAM_CNT = $04
|
||||
const PRODOS_ERR_INT_TBL_FULL = $25
|
||||
const PRODOS_ERR_IO = $27
|
||||
//
|
||||
// System I/O buffer for PLASMA. Used when loading modules, free otherwise
|
||||
//
|
||||
const sysbuf = $0800
|
||||
const FILE_ERR_OK = $00
|
||||
const FILE_ERR_BAD_CALL_NUM = $01
|
||||
const FILE_ERR_BAD_PARAM_CNT = $04
|
||||
const FILE_ERR_INT_TBL_FULL = $25
|
||||
const FILE_ERR_IO = $27
|
||||
//
|
||||
// File info struc
|
||||
struc t_fileinfo
|
||||
|
@@ -10,6 +10,16 @@ const CFFA1AuxType = $07
|
||||
const CFFA1FileSize = $09
|
||||
const CFFA1EntryPtr = $0B
|
||||
//
|
||||
// SOS access modes
|
||||
//
|
||||
const O_READ = 1
|
||||
const O_WRITE = 2
|
||||
const O_READ_WRITE = 3
|
||||
//
|
||||
// System I/O buffer for PLASMA. Used when loading modules, free otherwise
|
||||
//
|
||||
const sysbuf = $0800
|
||||
//
|
||||
// All our file I/O routines
|
||||
//
|
||||
struc t_fileio
|
||||
@@ -49,6 +59,10 @@ word = @a1newline, @a13readblock, @a13writeblock
|
||||
//
|
||||
export byte perr
|
||||
//
|
||||
// ProDOS default system buffer
|
||||
//
|
||||
word iobuf = $0000
|
||||
//
|
||||
// ProDOS/SOS routines
|
||||
//
|
||||
def a1getpfx(path)
|
||||
@@ -107,24 +121,28 @@ def a3getfileinfo(path, fileinfo)
|
||||
perr = syscall($C4, @params)
|
||||
return perr
|
||||
end
|
||||
def a1open(path, buf)
|
||||
def a1open(path)
|
||||
*CFFA1FileName = path
|
||||
*CFFA1Dest = buf
|
||||
return 0
|
||||
end
|
||||
def a2open(path, buf)
|
||||
def a2open(path)
|
||||
byte params[6]
|
||||
|
||||
if !iobuf
|
||||
iobuf = sysbuf
|
||||
fin
|
||||
params.0 = 3
|
||||
params:1 = path
|
||||
params:3 = buf
|
||||
params:3 = iobuf
|
||||
params.5 = 0
|
||||
perr = syscall($C8, @params)
|
||||
return params.5
|
||||
end
|
||||
def a3open(path, access)
|
||||
def a3open(path)
|
||||
byte params[7]
|
||||
word access
|
||||
|
||||
access = O_READ_WRITE
|
||||
params.0 = 4
|
||||
params:1 = path
|
||||
params.3 = 0
|
||||
@@ -145,6 +163,7 @@ def a23close(refnum)
|
||||
return perr
|
||||
end
|
||||
def a1read(refnum, buf, len)
|
||||
*CFFA1Dest = buf
|
||||
perr = syscall($22) // This reads the entire file on CFFA
|
||||
return perr
|
||||
end
|
||||
@@ -183,15 +202,15 @@ def a3write(refnum, buff, len)
|
||||
perr = syscall($CB, @params)
|
||||
return perr
|
||||
end
|
||||
def a1create(path, access, type, aux)
|
||||
def a1create(path, type, aux)
|
||||
return perr
|
||||
end
|
||||
def a2create(path, access, type, aux)
|
||||
def a2create(path, type, aux)
|
||||
byte params[12]
|
||||
|
||||
params.0 = 7
|
||||
params:1 = path
|
||||
params.3 = access
|
||||
params.3 = $C3
|
||||
params.4 = type
|
||||
params:5 = aux
|
||||
params.7 = $1
|
||||
@@ -200,7 +219,7 @@ def a2create(path, access, type, aux)
|
||||
perr = syscall($C0, @params)
|
||||
return perr
|
||||
end
|
||||
def a3create(path, access, type, aux)
|
||||
def a3create(path, type, aux)
|
||||
byte params[6]
|
||||
byte options[4]
|
||||
|
||||
|
@@ -126,7 +126,7 @@ def fatCopyFrom(src, dst, type, aux)
|
||||
//
|
||||
// Check if dst already exists
|
||||
//
|
||||
ref = fileio:open(dst, sysbuf)
|
||||
ref = fileio:open(dst)
|
||||
if ref
|
||||
fileio:close(ref)
|
||||
puts("Overwrite "); puts(dst)
|
||||
@@ -140,10 +140,10 @@ def fatCopyFrom(src, dst, type, aux)
|
||||
//
|
||||
// Create dst file
|
||||
//
|
||||
if fileio:create(dst, $C3, type, aux)
|
||||
if fileio:create(dst, type, aux)
|
||||
puts("Create file error: "); putByte(perr); putln
|
||||
fin
|
||||
ref = fileio:open(dst, sysbuf)
|
||||
ref = fileio:open(dst)
|
||||
if not ref
|
||||
puts("Error opening file: "); puts(dst); putln
|
||||
puts("Open file error: "); putByte(perr); putln
|
||||
|
@@ -110,7 +110,7 @@ def fatCopyTo(src, dst)
|
||||
puts("Not enough free memory!\n"); putln
|
||||
return -1
|
||||
fin
|
||||
ref = fileio:open(src, sysbuf)
|
||||
ref = fileio:open(src)
|
||||
if not ref
|
||||
puts("Error opening file: "); puts(src); putln
|
||||
puts("Open file error: "); putByte(perr); putln
|
||||
|
Reference in New Issue
Block a user