mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-09 13:33:26 +00:00
Use DOS order for sectors. Will detect proper oder shortly
This commit is contained in:
parent
e3f9c43f03
commit
29afb2e607
@ -22,9 +22,23 @@ import fileio
|
||||
//
|
||||
const sysbuf = $0800
|
||||
//
|
||||
// File info struc
|
||||
struc t_fileinfo
|
||||
byte file_access
|
||||
byte file_type
|
||||
word aux_type
|
||||
byte storage_type
|
||||
word blocks_used
|
||||
word mod_date
|
||||
word mod_time
|
||||
word create_date
|
||||
word create_time
|
||||
end
|
||||
//
|
||||
// File functions
|
||||
//
|
||||
predef getpfx, setpfx, open, close, read, write, create, destroy, newline
|
||||
predef getpfx, setpfx, getfileinfo
|
||||
predef open, close, read, write, create, destroy, newline
|
||||
//
|
||||
// Block level I/O functions
|
||||
//
|
||||
|
@ -23,6 +23,15 @@ export def setpfx(path)
|
||||
perr = syscall($C6, @params)
|
||||
return path
|
||||
end
|
||||
export def getfileinfo(path, fileinfo)
|
||||
byte params[18]
|
||||
|
||||
params.0 = 10
|
||||
params:1 = path
|
||||
perr = syscall($C4, @params)
|
||||
memcpy(fileinfo, @params + 3, 15)
|
||||
return perr
|
||||
end
|
||||
export def open(path, buf)
|
||||
byte params[6]
|
||||
|
||||
|
@ -14,6 +14,7 @@ SPIPORT = SPIPORT\#FE1000
|
||||
SDFAT = SDFAT\#FE1000
|
||||
FATCAT = FATCAT\#FE1000
|
||||
FATGET = FATGET\#FE1000
|
||||
FATPUT = FATPUT\#FE1000
|
||||
FATWDSK = FATWRITEDSK\#FE1000
|
||||
FATRDSK = FATREADDSK\#FE1000
|
||||
FILEIO = FILEIO\#FE1000
|
||||
@ -61,7 +62,7 @@ TXTTYPE = .TXT
|
||||
#SYSTYPE = \#FF2000
|
||||
#TXTTYPE = \#040000
|
||||
|
||||
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(SB) $(MON) $(ROD) $(SIEVE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1) $(TONE) $(DGR) $(DGRTEST) $(FILEIO) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATWDSK) $(FATRDSK)
|
||||
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(SB) $(MON) $(ROD) $(SIEVE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1) $(TONE) $(DGR) $(DGRTEST) $(FILEIO) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK)
|
||||
|
||||
clean:
|
||||
-rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03)
|
||||
@ -186,6 +187,10 @@ $(FATGET): samplesrc/fatget.pla $(PLVM02) $(PLASM)
|
||||
./$(PLASM) -AM < samplesrc/fatget.pla > samplesrc/fatget.a
|
||||
acme --setpc 4094 -o $(FATGET) samplesrc/fatget.a
|
||||
|
||||
$(FATPUT): samplesrc/fatput.pla $(PLVM02) $(PLASM)
|
||||
./$(PLASM) -AM < samplesrc/fatput.pla > samplesrc/fatput.a
|
||||
acme --setpc 4094 -o $(FATPUT) samplesrc/fatput.a
|
||||
|
||||
$(FATWDSK): samplesrc/fatwritedsk.pla $(PLVM02) $(PLASM)
|
||||
./$(PLASM) -AM < samplesrc/fatwritedsk.pla > samplesrc/fatwritedsk.a
|
||||
acme --setpc 4094 -o $(FATWDSK) samplesrc/fatwritedsk.a
|
||||
|
@ -103,7 +103,7 @@ def bigFatRead(buf, len)
|
||||
fatLen = len
|
||||
fin
|
||||
fatLen = sdFAT:fileRead(buf, fatLen)
|
||||
if fatLen > 0 and fatLen <= 512
|
||||
if fatLen > 0
|
||||
xferLen = xferLen + fatLen
|
||||
len = len - fatLen
|
||||
buf = buf + fatLen
|
||||
@ -174,7 +174,7 @@ end
|
||||
arg = argNext(argFirst)
|
||||
if ^arg
|
||||
mkProName(arg, @proname, @protype, @proaux)
|
||||
puts(arg);puts("==>");puts(@proname)
|
||||
puts(arg);puts(" ==> ");puts(@proname)
|
||||
putc(' ');putByte(protype);putc(',');putWord(proaux);putln
|
||||
fatCopyFrom(arg, @proname, protype, proaux)
|
||||
else
|
||||
|
147
src/samplesrc/fatput.pla
Normal file
147
src/samplesrc/fatput.pla
Normal file
@ -0,0 +1,147 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "inc/args.plh"
|
||||
include "inc/sdfat.plh"
|
||||
|
||||
const COPY_BUF_SIZE = 8192 // 8K
|
||||
const LOWER_DIFF = 'a' - 'A'
|
||||
|
||||
word arg
|
||||
byte[24] fatName
|
||||
|
||||
def putByte(val)
|
||||
byte c
|
||||
c = ((val >> 4) & $0F) + '0'
|
||||
if c > '9'
|
||||
c = c + 7
|
||||
fin
|
||||
putc(c)
|
||||
c = (val & $0F) + '0'
|
||||
if c > '9'
|
||||
c = c + 7
|
||||
fin
|
||||
return putc(c)
|
||||
end
|
||||
|
||||
def hexChars(cptr, b)
|
||||
byte h
|
||||
|
||||
h = ((b >> 4) & $0F) + '0'
|
||||
if h > '9'
|
||||
h = h + 7
|
||||
fin
|
||||
^cptr = h
|
||||
cptr++
|
||||
h = (b & $0F) + '0'
|
||||
if h > '9'
|
||||
h = h + 7
|
||||
fin
|
||||
^cptr = h
|
||||
end
|
||||
|
||||
def mkFatName(proName, fatName)
|
||||
word l, n
|
||||
byte fileinfo[t_fileinfo]
|
||||
|
||||
if !getfileinfo(proName, @fileinfo)
|
||||
//
|
||||
// Scan backward looking for dir seperator
|
||||
//
|
||||
l = ^proName
|
||||
for n = l downto 1
|
||||
if ^(proName + n) == '/'
|
||||
break
|
||||
fin
|
||||
next
|
||||
memcpy(fatName + 1, proName + 1 + n, l - n)
|
||||
^fatName = l - n + 7
|
||||
//
|
||||
// Build CiderPress style extension
|
||||
//
|
||||
n = fatName + ^fatName - 6
|
||||
^n = '#'
|
||||
hexChars(n + 1, fileinfo.file_type)
|
||||
hexChars(n + 3, fileinfo.aux_type.1)
|
||||
hexChars(n + 5, fileinfo.aux_type)
|
||||
else
|
||||
//
|
||||
// Error getting info on file
|
||||
//
|
||||
puts("Error reading "); puts(proName); putln
|
||||
fin
|
||||
end
|
||||
|
||||
def getYN(prompt)
|
||||
byte yn
|
||||
|
||||
puts(prompt)
|
||||
yn = getc
|
||||
return yn == 'Y' or yn == 'y'
|
||||
end
|
||||
|
||||
def bigFatWrite(buf, len)
|
||||
word xferLen, fatLen
|
||||
|
||||
xferLen = 0
|
||||
repeat
|
||||
if len > MAX_FAT_BUF_SIZE
|
||||
fatLen = MAX_FAT_BUF_SIZE
|
||||
else
|
||||
fatLen = len
|
||||
fin
|
||||
fatLen = sdFAT:fileWrite(buf, fatLen)
|
||||
if fatLen > 0
|
||||
xferLen = xferLen + fatLen
|
||||
len = len - fatLen
|
||||
buf = buf + fatLen
|
||||
else
|
||||
len = 0
|
||||
fin
|
||||
until len == 0
|
||||
return xferLen
|
||||
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 = open(src, sysbuf)
|
||||
if not ref
|
||||
puts("Error opening file: "); puts(src); putln
|
||||
puts("Open file error: "); putByte(perr); putln
|
||||
return -1
|
||||
fin
|
||||
//
|
||||
// Copy file over in big chunks
|
||||
//
|
||||
if sdFAT:fileOpen(dst, O_READ | O_WRITE | O_CREAT)
|
||||
repeat
|
||||
copyLen = read(ref, copyBuf, COPY_BUF_SIZE)
|
||||
if copyLen
|
||||
copyLen = bigFatWrite(copyBuf, copyLen)
|
||||
if !copyLen
|
||||
fin
|
||||
fin
|
||||
until copyLen == 0
|
||||
sdFAT:fileClose()
|
||||
else
|
||||
puts("Error opening FAT file:"); puts(dst); putln
|
||||
fin
|
||||
close(ref)
|
||||
heaprelease(freeAddr)
|
||||
end
|
||||
|
||||
arg = argNext(argFirst)
|
||||
if ^arg
|
||||
mkFatName(arg, @fatName)
|
||||
puts(arg); puts(" ==> "); puts(@fatName); putln
|
||||
fatCopyTo(arg, @fatName)
|
||||
else
|
||||
puts("Usage: +FATPUT <filename>"); putln
|
||||
fin
|
||||
done
|
@ -12,6 +12,10 @@ const LOWER_DIFF = 'a' - 'A'
|
||||
|
||||
word arg, image
|
||||
byte unit = DRIVE1
|
||||
//
|
||||
// DOS to ProDOS sector ordering
|
||||
//
|
||||
byte[] secOrder = $0,$E,$D,$C,$B,$A,$9,$8,$7,$6,$5,$4,$3,$2,$1,$F
|
||||
|
||||
def putb(b)
|
||||
byte c
|
||||
@ -75,6 +79,14 @@ def getYN(prompt)
|
||||
return yn == 'Y' or yn == 'y'
|
||||
end
|
||||
|
||||
def trkSecToBlk(bufSec, bufBlk)
|
||||
byte sector
|
||||
|
||||
for sector = 0 to 15
|
||||
memcpy(bufBlk + (sector << 8), bufSec + (secOrder[sector] << 8), 256)
|
||||
next
|
||||
end
|
||||
|
||||
def bigFatWrite(buf, len)
|
||||
word xferLen, fatLen
|
||||
|
||||
@ -98,14 +110,15 @@ def bigFatWrite(buf, len)
|
||||
end
|
||||
|
||||
def fatReadImage(src, drv)
|
||||
word copyBuf, copyLen, freeAddr
|
||||
word inBuf, outBuf, copyLen, freeAddr
|
||||
word blocknum, bufblk
|
||||
|
||||
copyBuf = heapallocalign(COPY_BUF_SIZE, 8, @freeAddr)
|
||||
if not copyBuf
|
||||
inBuf = heapallocalign(COPY_BUF_SIZE * 2, 8, @freeAddr)
|
||||
if not inBuf
|
||||
puts("Not enough free memory!\n"); putln
|
||||
return -1
|
||||
fin
|
||||
outBuf = inBuf + COPY_BUF_SIZE
|
||||
//
|
||||
// Copy FAT image over one track at a time
|
||||
//
|
||||
@ -116,13 +129,14 @@ def fatReadImage(src, drv)
|
||||
^$24=^$20 // Move cursor to left edge
|
||||
puts("Reading blocks: "); puti(blocknum)
|
||||
for bufblk = 0 to COPY_BLK_CNT
|
||||
if readblock(drv, copyBuf + (bufblk << 9), blocknum + bufblk)
|
||||
if readblock(drv, inBuf + (bufblk << 9), blocknum + bufblk)
|
||||
puts("Read disk error: $"); putb(perr); putln
|
||||
break
|
||||
fin
|
||||
next
|
||||
fin
|
||||
copyLen = bigFatWrite(copyBuf, COPY_BUF_SIZE)
|
||||
trkSecToBlk(inBuf, outBuf)
|
||||
copyLen = bigFatWrite(outBuf, COPY_BUF_SIZE)
|
||||
if copyLen <> COPY_BUF_SIZE
|
||||
puts("Write image file error\n");
|
||||
fin
|
||||
|
@ -13,6 +13,11 @@ const LOWER_DIFF = 'a' - 'A'
|
||||
word arg, image
|
||||
byte unit = DRIVE1
|
||||
|
||||
//
|
||||
// DOS to ProDOS sector ordering
|
||||
//
|
||||
byte[] secOrder = $0,$E,$D,$C,$B,$A,$9,$8,$7,$6,$5,$4,$3,$2,$1,$F
|
||||
|
||||
def putb(b)
|
||||
byte c
|
||||
c = ((b >> 4) & $0F) + '0'
|
||||
@ -75,6 +80,14 @@ def getYN(prompt)
|
||||
return yn == 'Y' or yn == 'y'
|
||||
end
|
||||
|
||||
def trkSecToBlk(bufSec, bufBlk)
|
||||
byte sector
|
||||
|
||||
for sector = 0 to 15
|
||||
memcpy(bufBlk + (sector << 8), bufSec + (secOrder[sector] << 8), 256)
|
||||
next
|
||||
end
|
||||
|
||||
def bigFatRead(buf, len)
|
||||
word xferLen, fatLen
|
||||
|
||||
@ -98,27 +111,29 @@ def bigFatRead(buf, len)
|
||||
end
|
||||
|
||||
def fatWriteImage(src, drv)
|
||||
word copyBuf, copyLen, freeAddr
|
||||
word inBuf, outBuf, copyLen, freeAddr
|
||||
word blocknum, bufblk
|
||||
|
||||
copyBuf = heapallocalign(COPY_BUF_SIZE, 8, @freeAddr)
|
||||
if not copyBuf
|
||||
outBuf = heapallocalign(COPY_BUF_SIZE * 2, 8, @freeAddr)
|
||||
if not outBuf
|
||||
puts("Not enough free memory!\n"); putln
|
||||
return -1
|
||||
fin
|
||||
inBuf = outBuf + COPY_BUF_SIZE
|
||||
//
|
||||
// Copy FAT image over one track at a time
|
||||
//
|
||||
if sdFAT:fileOpen(src, O_READ)
|
||||
if !drv; putc(7); fin
|
||||
for blocknum = 0 to 279 step COPY_BLK_SIZE
|
||||
copyLen = bigFatRead(copyBuf, COPY_BUF_SIZE)
|
||||
copyLen = bigFatRead(inBuf, COPY_BUF_SIZE)
|
||||
if copyLen == COPY_BUF_SIZE
|
||||
if drv
|
||||
^$24=^$20 // Move cursor to left edge
|
||||
puts("Writing blocks: "); puti(blocknum)
|
||||
trkSecToBlk(inBuf, outBuf)
|
||||
for bufblk = 0 to COPY_BLK_CNT
|
||||
if writeblock(drv, copyBuf + (bufblk << 9), blocknum + bufblk)
|
||||
if writeblock(drv, outBuf + (bufblk << 9), blocknum + bufblk)
|
||||
puts("Write disk error: $"); putb(perr); putln
|
||||
break
|
||||
fin
|
||||
|
Loading…
x
Reference in New Issue
Block a user