From 10618711b861905824b233884808e246f85c5197 Mon Sep 17 00:00:00 2001 From: dschmenk Date: Tue, 16 Aug 2016 18:53:44 -0700 Subject: [PATCH] Use file extension for sector order --- src/samplesrc/fatreaddsk.pla | 33 ++++++++++++++++++++++++++++----- src/samplesrc/fatwritedsk.pla | 33 ++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/samplesrc/fatreaddsk.pla b/src/samplesrc/fatreaddsk.pla index 7822f6f..089f213 100644 --- a/src/samplesrc/fatreaddsk.pla +++ b/src/samplesrc/fatreaddsk.pla @@ -9,9 +9,15 @@ const COPY_BLK_CNT = COPY_BLK_SIZE-1 const DRIVE1 = $60 // drive 1, slot 6 const DRIVE2 = $D0 // drive 2, slot 6 const LOWER_DIFF = 'a' - 'A' +// +// Track sector order +// +const ORDER_DOS = 0 +const ORDER_PRODOS = 1 word arg, image byte unit = DRIVE1 +byte order // // DOS to ProDOS sector ordering // @@ -109,7 +115,7 @@ def bigFatWrite(buf, len) return xferLen end -def fatReadImage(src, drv) +def fatReadImage(src, drv, order) word inBuf, outBuf, copyLen, freeAddr word blocknum, bufblk @@ -118,7 +124,11 @@ def fatReadImage(src, drv) puts("Not enough free memory!\n"); putln return -1 fin - outBuf = inBuf + COPY_BUF_SIZE + if order == ORDER_DOS + outBuf = inBuf + COPY_BUF_SIZE + else + outBuf = inBuf + fin // // Copy FAT image over one track at a time // @@ -135,7 +145,9 @@ def fatReadImage(src, drv) fin next fin - trkSecToBlk(inBuf, outBuf) + if order == ORDER_DOS + trkSecToBlk(inBuf, outBuf) + fin copyLen = bigFatWrite(outBuf, COPY_BUF_SIZE) if copyLen <> COPY_BUF_SIZE puts("Write image file error\n"); @@ -174,8 +186,19 @@ if ^arg else puts("Speed test writing 143K to SD card"); 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 else puts("Read DSK image from floppy disk drive\n") diff --git a/src/samplesrc/fatwritedsk.pla b/src/samplesrc/fatwritedsk.pla index 376d74d..2c786af 100644 --- a/src/samplesrc/fatwritedsk.pla +++ b/src/samplesrc/fatwritedsk.pla @@ -9,9 +9,15 @@ const COPY_BLK_CNT = COPY_BLK_SIZE-1 const DRIVE1 = $60 // drive 1, slot 6 const DRIVE2 = $D0 // drive 2, slot 6 const LOWER_DIFF = 'a' - 'A' +// +// Track sector order +// +const ORDER_DOS = 0 +const ORDER_PRODOS = 1 word arg, image byte unit = DRIVE1 +byte order // // DOS to ProDOS sector ordering @@ -110,7 +116,7 @@ def bigFatRead(buf, len) return xferLen end -def fatWriteImage(src, drv) +def fatWriteImage(src, drv, order) word inBuf, outBuf, copyLen, freeAddr word blocknum, bufblk @@ -119,7 +125,11 @@ def fatWriteImage(src, drv) puts("Not enough free memory!\n"); putln return -1 fin - inBuf = outBuf + COPY_BUF_SIZE + if order == ORDER_DOS + inBuf = outBuf + COPY_BUF_SIZE + else + inBuf = outBuf + fin // // Copy FAT image over one track at a time // @@ -131,7 +141,9 @@ def fatWriteImage(src, drv) if drv ^$24=^$20 // Move cursor to left edge puts("Writing blocks: "); puti(blocknum) - trkSecToBlk(inBuf, outBuf) + if order == ORDER_DOS + trkSecToBlk(inBuf, outBuf) + fin for bufblk = 0 to COPY_BLK_CNT if writeblock(drv, outBuf + (bufblk << 9), blocknum + bufblk) puts("Write disk error: $"); putb(perr); putln @@ -176,8 +188,19 @@ if ^arg else puts("Speed test reading 143K from SD card"); 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 else puts("Write DSK image to floppy disk drive\n")