1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-10 06:30:41 +00:00
This commit is contained in:
dschmenk 2016-08-18 10:29:40 -07:00
commit 56aa52038b
8 changed files with 270 additions and 20 deletions

BIN
SDFAT.PO Executable file

Binary file not shown.

View File

@ -22,9 +22,23 @@ import fileio
// //
const sysbuf = $0800 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 // 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 // Block level I/O functions
// //

View File

@ -23,6 +23,15 @@ export def setpfx(path)
perr = syscall($C6, @params) perr = syscall($C6, @params)
return path return path
end 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) export def open(path, buf)
byte params[6] byte params[6]

View File

@ -14,6 +14,7 @@ SPIPORT = SPIPORT\#FE1000
SDFAT = SDFAT\#FE1000 SDFAT = SDFAT\#FE1000
FATCAT = FATCAT\#FE1000 FATCAT = FATCAT\#FE1000
FATGET = FATGET\#FE1000 FATGET = FATGET\#FE1000
FATPUT = FATPUT\#FE1000
FATWDSK = FATWRITEDSK\#FE1000 FATWDSK = FATWRITEDSK\#FE1000
FATRDSK = FATREADDSK\#FE1000 FATRDSK = FATREADDSK\#FE1000
FILEIO = FILEIO\#FE1000 FILEIO = FILEIO\#FE1000
@ -61,7 +62,7 @@ TXTTYPE = .TXT
#SYSTYPE = \#FF2000 #SYSTYPE = \#FF2000
#TXTTYPE = \#040000 #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: clean:
-rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) -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 ./$(PLASM) -AM < samplesrc/fatget.pla > samplesrc/fatget.a
acme --setpc 4094 -o $(FATGET) 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) $(FATWDSK): samplesrc/fatwritedsk.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < samplesrc/fatwritedsk.pla > samplesrc/fatwritedsk.a ./$(PLASM) -AM < samplesrc/fatwritedsk.pla > samplesrc/fatwritedsk.a
acme --setpc 4094 -o $(FATWDSK) samplesrc/fatwritedsk.a acme --setpc 4094 -o $(FATWDSK) samplesrc/fatwritedsk.a

View File

@ -103,7 +103,7 @@ def bigFatRead(buf, len)
fatLen = len fatLen = len
fin fin
fatLen = sdFAT:fileRead(buf, fatLen) fatLen = sdFAT:fileRead(buf, fatLen)
if fatLen > 0 and fatLen <= 512 if fatLen > 0
xferLen = xferLen + fatLen xferLen = xferLen + fatLen
len = len - fatLen len = len - fatLen
buf = buf + fatLen buf = buf + fatLen
@ -174,7 +174,7 @@ end
arg = argNext(argFirst) arg = argNext(argFirst)
if ^arg if ^arg
mkProName(arg, @proname, @protype, @proaux) mkProName(arg, @proname, @protype, @proaux)
puts(arg);puts("==>");puts(@proname) puts(arg);puts(" ==> ");puts(@proname)
putc(' ');putByte(protype);putc(',');putWord(proaux);putln putc(' ');putByte(protype);putc(',');putWord(proaux);putln
fatCopyFrom(arg, @proname, protype, proaux) fatCopyFrom(arg, @proname, protype, proaux)
else else

147
src/samplesrc/fatput.pla Normal file
View 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

View File

@ -9,9 +9,19 @@ const COPY_BLK_CNT = COPY_BLK_SIZE-1
const DRIVE1 = $60 // drive 1, slot 6 const DRIVE1 = $60 // drive 1, slot 6
const DRIVE2 = $D0 // drive 2, slot 6 const DRIVE2 = $D0 // drive 2, slot 6
const LOWER_DIFF = 'a' - 'A' const LOWER_DIFF = 'a' - 'A'
//
// Track sector order
//
const ORDER_DOS = 0
const ORDER_PRODOS = 1
word arg, image word arg, image
byte unit = DRIVE1 byte unit = DRIVE1
byte order
//
// 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) def putb(b)
byte c byte c
@ -75,6 +85,14 @@ def getYN(prompt)
return yn == 'Y' or yn == 'y' return yn == 'Y' or yn == 'y'
end 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) def bigFatWrite(buf, len)
word xferLen, fatLen word xferLen, fatLen
@ -97,15 +115,20 @@ def bigFatWrite(buf, len)
return xferLen return xferLen
end end
def fatReadImage(src, drv) def fatReadImage(src, drv, order)
word copyBuf, copyLen, freeAddr word inBuf, outBuf, copyLen, freeAddr
word blocknum, bufblk word blocknum, bufblk
copyBuf = heapallocalign(COPY_BUF_SIZE, 8, @freeAddr) inBuf = heapallocalign(COPY_BUF_SIZE * 2, 8, @freeAddr)
if not copyBuf if not inBuf
puts("Not enough free memory!\n"); putln puts("Not enough free memory!\n"); putln
return -1 return -1
fin fin
if order == ORDER_DOS
outBuf = inBuf + COPY_BUF_SIZE
else
outBuf = inBuf
fin
// //
// Copy FAT image over one track at a time // Copy FAT image over one track at a time
// //
@ -116,13 +139,16 @@ def fatReadImage(src, drv)
^$24=^$20 // Move cursor to left edge ^$24=^$20 // Move cursor to left edge
puts("Reading blocks: "); puti(blocknum) puts("Reading blocks: "); puti(blocknum)
for bufblk = 0 to COPY_BLK_CNT 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 puts("Read disk error: $"); putb(perr); putln
break break
fin fin
next next
fin fin
copyLen = bigFatWrite(copyBuf, COPY_BUF_SIZE) if order == ORDER_DOS
trkSecToBlk(inBuf, outBuf)
fin
copyLen = bigFatWrite(outBuf, COPY_BUF_SIZE)
if copyLen <> COPY_BUF_SIZE if copyLen <> COPY_BUF_SIZE
puts("Write image file error\n"); puts("Write image file error\n");
fin fin
@ -160,8 +186,19 @@ if ^arg
else else
puts("Speed test writing 143K to SD card"); puts("Speed test writing 143K to SD card");
fin fin
if getYN("\nContinue? (Y/N)") //
fatReadImage(image, unit) // Figure sector ordering from filename
//
puts("\nUsing ")
if charUpper(^(image + ^image)) == 'O' and charUpper(^(image + ^image - 1)) == 'P'
order = ORDER_PRODOS
puts("ProDOS")
else
order = ORDER_DOS
puts("DOS 3.3")
fin
if getYN(" order. Continue? (Y/N)")
fatReadImage(image, unit, order)
fin fin
else else
puts("Read DSK image from floppy disk drive\n") puts("Read DSK image from floppy disk drive\n")

View File

@ -9,9 +9,20 @@ const COPY_BLK_CNT = COPY_BLK_SIZE-1
const DRIVE1 = $60 // drive 1, slot 6 const DRIVE1 = $60 // drive 1, slot 6
const DRIVE2 = $D0 // drive 2, slot 6 const DRIVE2 = $D0 // drive 2, slot 6
const LOWER_DIFF = 'a' - 'A' const LOWER_DIFF = 'a' - 'A'
//
// Track sector order
//
const ORDER_DOS = 0
const ORDER_PRODOS = 1
word arg, image word arg, image
byte unit = DRIVE1 byte unit = DRIVE1
byte order
//
// 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) def putb(b)
byte c byte c
@ -75,6 +86,14 @@ def getYN(prompt)
return yn == 'Y' or yn == 'y' return yn == 'Y' or yn == 'y'
end 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) def bigFatRead(buf, len)
word xferLen, fatLen word xferLen, fatLen
@ -97,28 +116,36 @@ def bigFatRead(buf, len)
return xferLen return xferLen
end end
def fatWriteImage(src, drv) def fatWriteImage(src, drv, order)
word copyBuf, copyLen, freeAddr word inBuf, outBuf, copyLen, freeAddr
word blocknum, bufblk word blocknum, bufblk
copyBuf = heapallocalign(COPY_BUF_SIZE, 8, @freeAddr) outBuf = heapallocalign(COPY_BUF_SIZE * 2, 8, @freeAddr)
if not copyBuf if not outBuf
puts("Not enough free memory!\n"); putln puts("Not enough free memory!\n"); putln
return -1 return -1
fin fin
if order == ORDER_DOS
inBuf = outBuf + COPY_BUF_SIZE
else
inBuf = outBuf
fin
// //
// Copy FAT image over one track at a time // Copy FAT image over one track at a time
// //
if sdFAT:fileOpen(src, O_READ) if sdFAT:fileOpen(src, O_READ)
if !drv; putc(7); fin if !drv; putc(7); fin
for blocknum = 0 to 279 step COPY_BLK_SIZE 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 copyLen == COPY_BUF_SIZE
if drv if drv
^$24=^$20 // Move cursor to left edge ^$24=^$20 // Move cursor to left edge
puts("Writing blocks: "); puti(blocknum) puts("Writing blocks: "); puti(blocknum)
if order == ORDER_DOS
trkSecToBlk(inBuf, outBuf)
fin
for bufblk = 0 to COPY_BLK_CNT 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 puts("Write disk error: $"); putb(perr); putln
break break
fin fin
@ -161,8 +188,19 @@ if ^arg
else else
puts("Speed test reading 143K from SD card"); puts("Speed test reading 143K from SD card");
fin fin
if getYN("\nContinue? (Y/N)") //
fatWriteImage(image, unit) // Figure sector ordering from filename
//
puts("\nUsing ")
if charUpper(^(image + ^image)) == 'O' and charUpper(^(image + ^image - 1)) == 'P'
order = ORDER_PRODOS
puts("ProDOS")
else
order = ORDER_DOS
puts("DOS 3.3")
fin
if getYN(" order. Continue? (Y/N)")
fatWriteImage(image, unit, order)
fin fin
else else
puts("Write DSK image to floppy disk drive\n") puts("Write DSK image to floppy disk drive\n")