1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-08-21 21:29:08 +00:00

Make fileio intarface consistent among 1, II, and ///

This commit is contained in:
David Schmenk 2017-12-05 20:15:28 -08:00
parent f5ea22af02
commit 3c47c5067c
4 changed files with 52 additions and 37 deletions

View File

@ -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

View File

@ -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)
@ -90,7 +104,7 @@ def a1getfileinfo(path, fileinfo)
end
def a2getfileinfo(path, fileinfo)
byte params[18]
params.0 = 10
params:1 = path
perr = syscall($C4, @params)
@ -99,7 +113,7 @@ def a2getfileinfo(path, fileinfo)
end
def a3getfileinfo(path, fileinfo)
byte params[6]
params.0 = 3
params:1 = path
params:3 = fileinfo
@ -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]
@ -243,7 +262,7 @@ def a13readblock(unit, buf, block)
end
def a2readblock(unit, buf, block)
byte params[6]
params.0 = 3
params.1 = unit
params:2 = buf
@ -257,7 +276,7 @@ def a13writeblock(unit, buf, block)
end
def a2writeblock(unit, buf, block)
byte params[6]
params.0 = 3
params.1 = unit
params:2 = buf

View File

@ -39,7 +39,7 @@ end
def hexByte(hexChars)
byte lo, hi
lo = charUpper(^(hexChars + 1)) - '0'
if lo > 9
lo = lo - 7
@ -57,7 +57,7 @@ end
def mkProName(fatName, proName, proType, proAux)
byte n, l
^proType = $02 // default to BIN
*proAux = $0000 // default to 0
//
@ -86,7 +86,7 @@ end
def getYN(prompt)
byte yn
puts(prompt)
yn = getc
return yn == 'Y' or yn == 'y'
@ -94,7 +94,7 @@ end
def bigFatRead(buf, len)
word xferLen, fatLen
xferLen = 0
repeat
if len > MAX_FAT_BUF_SIZE
@ -117,7 +117,7 @@ end
def fatCopyFrom(src, dst, type, aux)
word copyBuf, copyLen, freeAddr
byte ref
copyBuf = heapallocalign(COPY_BUF_SIZE, 8, @freeAddr)
if not copyBuf
puts("Not enough free memory!\n"); putln
@ -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

View File

@ -25,7 +25,7 @@ end
def hexChars(cptr, b)
byte h
h = ((b >> 4) & $0F) + '0'
if h > '9'
h = h + 7
@ -42,7 +42,7 @@ end
def mkFatName(proName, fatName)
word l, n
byte fileinfo[t_fileinfo]
if !fileio:getfileinfo(proName, @fileinfo)
//
// Scan backward looking for dir seperator
@ -73,7 +73,7 @@ end
def getYN(prompt)
byte yn
puts(prompt)
yn = getc
return yn == 'Y' or yn == 'y'
@ -81,7 +81,7 @@ end
def bigFatWrite(buf, len)
word xferLen, fatLen
xferLen = 0
repeat
if len > MAX_FAT_BUF_SIZE
@ -104,13 +104,13 @@ end
def fatCopyTo(src, dst)
word copyBuf, copyLen, freeAddr
byte ref
copyBuf = heapallocalign(COPY_BUF_SIZE, 8, @freeAddr)
if not copyBuf
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