Converted to support image order and image layout instead of a simple

byte array.
This commit is contained in:
Robert Greene 2003-12-26 21:40:10 +00:00
parent b3a72347d8
commit 3bae1f3c87
13 changed files with 170 additions and 94 deletions

View File

@ -19,6 +19,7 @@
*/
package com.webcodepro.applecommander.storage;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil;
import java.util.ArrayList;
@ -101,17 +102,16 @@ public class DosFormatDisk extends FormattedDisk {
* @param diskImage
* @param order
*/
public DosFormatDisk(String filename, byte[] diskImage) {
super(filename, diskImage);
public DosFormatDisk(String filename, ImageOrder imageOrder) {
super(filename, imageOrder);
}
/**
* Create a DosFormatDisk. All DOS disk images are expected to
* be 140K in size.
*/
public static DosFormatDisk[] create(String filename) {
DosFormatDisk disk =
new DosFormatDisk(filename, new byte[APPLE_140KB_DISK]);
public static DosFormatDisk[] create(String filename, ImageOrder imageOrder) {
DosFormatDisk disk = new DosFormatDisk(filename, imageOrder);
disk.format();
return new DosFormatDisk[] { disk };
}
@ -537,6 +537,7 @@ public class DosFormatDisk extends FormattedDisk {
* @see com.webcodepro.applecommander.storage.FormattedDisk#format()
*/
public void format() {
getImageOrder().format();
format(15, 35, 16);
}

View File

@ -19,6 +19,8 @@
*/
package com.webcodepro.applecommander.storage;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
@ -122,8 +124,8 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
* @param filename
* @param diskImage
*/
public FormattedDisk(String filename, byte[] diskImage) {
super(filename, diskImage);
public FormattedDisk(String filename, ImageOrder imageOrder) {
super(filename, imageOrder);
}
/**

View File

@ -19,6 +19,8 @@
*/
package com.webcodepro.applecommander.storage;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
/**
* Manages a disk that is in OzDOS format.
* This is basically DOS 3.3 except that the disk has two volumes of
@ -50,20 +52,17 @@ public class OzDosFormatDisk extends DosFormatDisk {
* @param filename
* @param diskImage
*/
public OzDosFormatDisk(String filename, byte[] diskImage, int logicalOffset) {
super(filename, diskImage);
public OzDosFormatDisk(String filename, ImageOrder imageOrder, int logicalOffset) {
super(filename, imageOrder);
this.logicalOffset = logicalOffset;
}
/**
* Create a OzDosFormatDisk.
*/
public static DosFormatDisk[] create(String filename) {
byte[] diskImage = new byte[APPLE_800KB_2IMG_DISK];
OzDosFormatDisk disk1 = new OzDosFormatDisk(filename,
diskImage, OZDOS_DISK_1);
public static DosFormatDisk[] create(String filename, ImageOrder imageOrder) {
OzDosFormatDisk disk1 = new OzDosFormatDisk(filename, imageOrder, OZDOS_DISK_1);
OzDosFormatDisk disk2 = new OzDosFormatDisk(filename, imageOrder, OZDOS_DISK_2);
disk1.format();
OzDosFormatDisk disk2 = new OzDosFormatDisk(filename,
diskImage, OZDOS_DISK_2);
disk2.format();
return new OzDosFormatDisk[] { disk1, disk2 };
}
@ -93,28 +92,12 @@ public class OzDosFormatDisk extends DosFormatDisk {
return 0;
}
}
/**
* Compute the track and sector offset into the disk image.
* This varies with OzDOS.
*/
protected int getOffset(int track, int sector) throws IllegalArgumentException {
if ((track * 32 + sector) * SECTOR_SIZE > getPhysicalSize()) {
throw new IllegalArgumentException(
"The track (" + track + ") and sector (" + sector
+ ") do not match the disk image size.");
} else if (isProdosOrder()) {
return ((track * 32) + sector) * BLOCK_SIZE + logicalOffset;
} else {
// Note that DOS format is unexpected.
throw new IllegalArgumentException(
"Unknown disk format.");
}
}
/**
* Format the disk as OzDOS.
* @see com.webcodepro.applecommander.storage.FormattedDisk#format()
*/
public void format() {
getImageOrder().format();
format(31, 50, 32);
}
}

View File

@ -19,6 +19,7 @@
*/
package com.webcodepro.applecommander.storage;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil;
import java.util.ArrayList;
@ -108,19 +109,17 @@ public class PascalFormatDisk extends FormattedDisk {
* @param filename
* @param diskImage
*/
public PascalFormatDisk(String filename, byte[] diskImage) {
super(filename, diskImage);
public PascalFormatDisk(String filename, ImageOrder imageOrder) {
super(filename, imageOrder);
}
/**
* Create a PascalFormatDisk.
*/
public static PascalFormatDisk[] create(String filename, String volumeName,
int size) {
PascalFormatDisk disk = new PascalFormatDisk(filename, new byte[size]);
disk.setDiskName(volumeName);
public static PascalFormatDisk[] create(String filename, String volumeName, ImageOrder imageOrder) {
PascalFormatDisk disk = new PascalFormatDisk(filename, imageOrder);
disk.format();
disk.setDiskName(volumeName);
return new PascalFormatDisk[] { disk };
}
@ -445,6 +444,7 @@ public class PascalFormatDisk extends FormattedDisk {
* @see com.webcodepro.applecommander.storage.FormattedDisk#format()
*/
public void format() {
getImageOrder().format();
writeBootCode();
// Create volume name
byte[] directory = readDirectory();

View File

@ -19,6 +19,7 @@
*/
package com.webcodepro.applecommander.storage;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil;
import java.io.IOException;
@ -130,8 +131,8 @@ public class ProdosFormatDisk extends FormattedDisk {
* @param filename
* @param diskImage
*/
public ProdosFormatDisk(String filename, byte[] diskImage) {
super(filename, diskImage);
public ProdosFormatDisk(String filename, ImageOrder imageOrder) {
super(filename, imageOrder);
volumeHeader = new ProdosVolumeDirectoryHeader(this);
initialize();
}
@ -167,10 +168,10 @@ public class ProdosFormatDisk extends FormattedDisk {
/**
* Create a ProdosFormatDisk.
*/
public static ProdosFormatDisk[] create(String filename, String diskName, int imageSize) {
ProdosFormatDisk disk = new ProdosFormatDisk(filename, new byte[imageSize]);
disk.setDiskName(diskName);
public static ProdosFormatDisk[] create(String filename, String diskName, ImageOrder imageOrder) {
ProdosFormatDisk disk = new ProdosFormatDisk(filename, imageOrder);
disk.format();
disk.setDiskName(diskName);
return new ProdosFormatDisk[] { disk };
}
@ -683,7 +684,7 @@ public class ProdosFormatDisk extends FormattedDisk {
int blocksOnDisk = getBitmapLength();
while (block < blocksOnDisk) {
if (isBlockFree(volumeBitmap,block)) {
if ((block+1) * BLOCK_SIZE < getDiskImage().length) {
if ((block+1) * BLOCK_SIZE < getPhysicalSize()) {
return block;
}
throw new ProdosDiskSizeDoesNotMatchException(
@ -771,9 +772,10 @@ public class ProdosFormatDisk extends FormattedDisk {
* @see com.webcodepro.applecommander.storage.FormattedDisk#format()
*/
public void format() {
getImageOrder().format();
writeBootCode();
String volumeName = volumeHeader.getVolumeName();
int totalBlocks = getDiskImage().length / BLOCK_SIZE;
int totalBlocks = getPhysicalSize() / BLOCK_SIZE;
int usedBlocks = (totalBlocks / 4096) + 7;
// setup volume directory
byte[] data = new byte[BLOCK_SIZE];

View File

@ -19,6 +19,7 @@
*/
package com.webcodepro.applecommander.storage;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil;
import java.util.ArrayList;
@ -122,16 +123,15 @@ public class RdosFormatDisk extends FormattedDisk {
* @param filename
* @param diskImage
*/
public RdosFormatDisk(String filename, byte[] diskImage) {
super(filename, diskImage);
public RdosFormatDisk(String filename, ImageOrder imageOrder) {
super(filename, imageOrder);
}
/**
* Create a RdosFormatDisk.
*/
public static RdosFormatDisk[] create(String filename) {
RdosFormatDisk disk =
new RdosFormatDisk(filename, new byte[APPLE_140KB_DISK]);
public static RdosFormatDisk[] create(String filename, ImageOrder imageOrder) {
RdosFormatDisk disk = new RdosFormatDisk(filename, imageOrder);
disk.format();
return new RdosFormatDisk[] { disk };
}
@ -395,6 +395,7 @@ public class RdosFormatDisk extends FormattedDisk {
* @see com.webcodepro.applecommander.storage.FormattedDisk#format()
*/
public void format() {
getImageOrder().format();
writeBootCode();
// minor hack - ensure that AppleCommander itself recognizes the
// RDOS disk!

View File

@ -19,6 +19,8 @@
*/
package com.webcodepro.applecommander.storage;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
/**
* Manages a disk that is in UniDOS format.
* This is basically DOS 3.3 except that the disk has two volumes of
@ -48,20 +50,17 @@ public class UniDosFormatDisk extends DosFormatDisk {
* @param filename
* @param diskImage
*/
public UniDosFormatDisk(String filename, byte[] diskImage, int logicalOffset) {
super(filename, diskImage);
public UniDosFormatDisk(String filename, ImageOrder imageOrder, int logicalOffset) {
super(filename, imageOrder);
this.logicalOffset = logicalOffset;
}
/**
* Create a UniDosFormatDisk.
*/
public static DosFormatDisk[] create(String filename) {
byte[] diskImage = new byte[APPLE_800KB_2IMG_DISK];
UniDosFormatDisk disk1 = new UniDosFormatDisk(filename,
diskImage, UNIDOS_DISK_1);
public static DosFormatDisk[] create(String filename, ImageOrder imageOrder) {
UniDosFormatDisk disk1 = new UniDosFormatDisk(filename, imageOrder, UNIDOS_DISK_1);
UniDosFormatDisk disk2 = new UniDosFormatDisk(filename, imageOrder, UNIDOS_DISK_2);
disk1.format();
UniDosFormatDisk disk2 = new UniDosFormatDisk(filename,
diskImage, UNIDOS_DISK_2);
disk2.format();
return new UniDosFormatDisk[] { disk1, disk2 };
}
@ -79,15 +78,6 @@ public class UniDosFormatDisk extends DosFormatDisk {
}
}
/**
* Modify the disk offset by the logical disk offset. This allows
* simple support for two DOS volumes on a UniDOS disk.
* @see com.webcodepro.applecommander.storage.Disk#getOffset(int, int)
*/
protected int getOffset(int track, int sector) throws IllegalArgumentException {
return super.getOffset(track, sector) + logicalOffset;
}
/**
* Returns the logical disk number. This can be used to identify
* between disks when a format supports multiple logical volumes.
@ -106,6 +96,7 @@ public class UniDosFormatDisk extends DosFormatDisk {
* @see com.webcodepro.applecommander.storage.FormattedDisk#format()
*/
public void format() {
getImageOrder().format();
format(31, 50, 32);
}
}

View File

@ -22,6 +22,7 @@ package com.webcodepro.applecommander.storage.cpm;
import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import java.util.ArrayList;
import java.util.HashMap;
@ -91,12 +92,21 @@ public class CpmFormatDisk extends FormattedDisk {
}
}
/**
* Construct a CP/M formatted disk.
*/
public CpmFormatDisk(String filename, ImageOrder imageOrder) {
super(filename, imageOrder);
}
/**
* Create a CP/M formatted disk.
* Create a CpmFormatDisk. All CP/M disk images are expected to
* be 140K in size.
*/
public CpmFormatDisk(String filename, byte[] diskImage) {
super(filename, diskImage);
public static CpmFormatDisk[] create(String filename, ImageOrder imageOrder) {
CpmFormatDisk disk = new CpmFormatDisk(filename, imageOrder);
disk.format();
return new CpmFormatDisk[] { disk };
}
/**
@ -267,6 +277,7 @@ public class CpmFormatDisk extends FormattedDisk {
* @see com.webcodepro.applecommander.storage.FormattedDisk#format()
*/
public void format() {
getImageOrder().format();
byte[] sectorData = new byte[SECTOR_SIZE];
for (int i=0; i<SECTOR_SIZE; i++) {
sectorData[i] = (byte) 0xe5;

View File

@ -29,6 +29,11 @@ import com.webcodepro.applecommander.storage.OzDosFormatDisk;
import com.webcodepro.applecommander.storage.ProdosFormatDisk;
import com.webcodepro.applecommander.storage.UniDosFormatDisk;
import com.webcodepro.applecommander.storage.FormattedDisk.DiskUsage;
import com.webcodepro.applecommander.storage.physical.ByteArrayImageLayout;
import com.webcodepro.applecommander.storage.physical.DosOrder;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.storage.physical.NibbleOrder;
import com.webcodepro.applecommander.storage.physical.ProdosOrder;
import java.io.IOException;
import java.util.List;
@ -46,7 +51,7 @@ public class DiskWriterTest extends TestCase {
* Determine if the created disk images should be saved for later
* perusal.
*/
private static final boolean saveImage = false;
private boolean saveImage = false;
/**
* Create the DiskWriterTest.
@ -66,17 +71,34 @@ public class DiskWriterTest extends TestCase {
* Test writing and reading random files to a DOS 3.3 140K disk.
*/
public void testWriteToDos33() throws DiskFullException, IOException {
FormattedDisk[] disks = DosFormatDisk.create("write-test-dos33.dsk");
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = DosFormatDisk.create("write-test-dos33.dsk", imageOrder);
writeFiles(disks, "B", "T", false);
saveDisks(disks);
}
/**
* Test writing and reading random files to a DOS 3.3 140K nibbilized disk.
*/
public void testWriteToDos33Nibble() throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_NIBBLE_DISK);
ImageOrder imageOrder = new NibbleOrder(imageLayout);
FormattedDisk[] disks = DosFormatDisk.create("write-test-dos33.nib", imageOrder);
writeFiles(disks, "B", "T", false);
saveImage = true;
saveDisks(disks);
saveImage = false;
}
/**
* Test writing and reading random files to a ProDOS 140K disk.
*/
public void testWriteToProdos140kDisk() throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create(
"write-test-prodos-140k.dsk", "TEST", ProdosFormatDisk.APPLE_140KB_DISK);
"write-test-prodos-140k.dsk", "TEST", imageOrder);
writeFiles(disks, "BIN", "TXT", true);
saveDisks(disks);
}
@ -85,8 +107,10 @@ public class DiskWriterTest extends TestCase {
* Test writing and reading random files to a ProDOS 800K disk.
*/
public void testWriteToProdos800kDisk() throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create(
"write-test-prodos-800k.po", "TEST", ProdosFormatDisk.APPLE_800KB_DISK);
"write-test-prodos-800k.po", "TEST", imageOrder);
writeFiles(disks, "BIN", "TXT", true);
saveDisks(disks);
}
@ -95,8 +119,10 @@ public class DiskWriterTest extends TestCase {
* Test writing and reading random files to a ProDOS 5MB disk.
*/
public void testWriteToProdos5mbDisk() throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_5MB_HARDDISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create(
"write-test-prodos-5mb.hdv", "TEST", ProdosFormatDisk.APPLE_5MB_HARDDISK);
"write-test-prodos-5mb.hdv", "TEST", imageOrder);
writeFiles(disks, "BIN", "TXT", true);
saveDisks(disks);
}
@ -105,8 +131,10 @@ public class DiskWriterTest extends TestCase {
* Test creating and deleting many files on a DOS 3.3 140K disk.
*/
public void testCreateAndDeleteDos33() throws IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = DosFormatDisk.create(
"createanddelete-test-dos33.dsk");
"createanddelete-test-dos33.dsk", imageOrder);
createAndDeleteFiles(disks, "B");
saveDisks(disks);
}
@ -115,8 +143,10 @@ public class DiskWriterTest extends TestCase {
* Test creating and deleting many files on an OzDOS 800K disk.
*/
public void testCreateAndDeleteOzDos() throws IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = OzDosFormatDisk.create(
"createanddelete-test-ozdos.po");
"createanddelete-test-ozdos.po", imageOrder);
createAndDeleteFiles(disks, "B");
saveDisks(disks);
}
@ -125,8 +155,10 @@ public class DiskWriterTest extends TestCase {
* Test creating and deleting many files on a UniDOS 800K disk.
*/
public void testCreateAndDeleteUniDos() throws IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = UniDosFormatDisk.create(
"createanddelete-test-unidos.dsk");
"createanddelete-test-unidos.dsk", imageOrder);
createAndDeleteFiles(disks, "B");
saveDisks(disks);
}
@ -135,9 +167,11 @@ public class DiskWriterTest extends TestCase {
* Test creating and deleting many files on a ProDOS 140K disk.
*/
public void testCreateAndDeleteProdos140kDisk() throws IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create(
"createanddelete-test-prodos-140k.dsk", "TEST",
ProdosFormatDisk.APPLE_140KB_DISK);
imageOrder);
createAndDeleteFiles(disks, "BIN");
saveDisks(disks);
}
@ -146,9 +180,11 @@ public class DiskWriterTest extends TestCase {
* Test creating and deleting many files on a ProDOS 800K disk.
*/
public void testCreateAndDeleteProdos800kDisk() throws IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create(
"createanddelete-test-prodos-800k.dsk", "TEST",
ProdosFormatDisk.APPLE_800KB_2IMG_DISK);
imageOrder);
createAndDeleteFiles(disks, "BIN");
saveDisks(disks);
}
@ -159,8 +195,10 @@ public class DiskWriterTest extends TestCase {
*/
public void testCreateDeleteCreateDosDisk()
throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = DosFormatDisk.create(
"createdeletecreate-test-dos-140k.dsk");
"createdeletecreate-test-dos-140k.dsk", imageOrder);
createDeleteCreate(disks, "B");
saveDisks(disks);
}
@ -171,8 +209,10 @@ public class DiskWriterTest extends TestCase {
*/
public void testCreateDeleteCreateOzdosDisk()
throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = OzDosFormatDisk.create(
"createdeletecreate-test-ozdos-800k.po");
"createdeletecreate-test-ozdos-800k.po", imageOrder);
createDeleteCreate(disks, "B");
saveDisks(disks);
}
@ -183,8 +223,10 @@ public class DiskWriterTest extends TestCase {
*/
public void testCreateDeleteCreateUnidosDisk()
throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = UniDosFormatDisk.create(
"createdeletecreate-test-unidos-800k.dsk");
"createdeletecreate-test-unidos-800k.dsk", imageOrder);
createDeleteCreate(disks, "B");
saveDisks(disks);
}
@ -195,9 +237,11 @@ public class DiskWriterTest extends TestCase {
*/
public void testCreateDeleteCreateProdosDisk()
throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create(
"createdeletecreate-test-prodos-140k.dsk", "TEST",
ProdosFormatDisk.APPLE_140KB_DISK);
imageOrder);
createDeleteCreate(disks, "BIN");
saveDisks(disks);
}
@ -224,7 +268,8 @@ public class DiskWriterTest extends TestCase {
writeFile(disk,
"This is a test text file create from the DiskWriterTest".getBytes(),
textType, testText);
if (disk.getPhysicalSize() > Disk.APPLE_140KB_DISK) {
if (disk.getPhysicalSize() > Disk.APPLE_140KB_DISK
&& disk.getPhysicalSize() != Disk.APPLE_140KB_NIBBLE_DISK) {
// create a few big files
writeFile(disk, 150000, binaryType, true);
writeFile(disk, 300000, binaryType, true);

View File

@ -28,6 +28,9 @@ import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.FileFilter;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.ProdosFormatDisk;
import com.webcodepro.applecommander.storage.physical.ByteArrayImageLayout;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.storage.physical.ProdosOrder;
import java.io.IOException;
import java.util.List;
@ -210,8 +213,10 @@ public class ac {
*/
static void createPDisk(String fileName, String volName, int imageSize)
throws IOException {
ByteArrayImageLayout layout = new ByteArrayImageLayout(imageSize);
ImageOrder imageOrder = new ProdosOrder(layout);
FormattedDisk[] disks =
ProdosFormatDisk.create(fileName, volName, imageSize);
ProdosFormatDisk.create(fileName, volName, imageOrder);
disks[0].save();
}

View File

@ -57,6 +57,7 @@ public class DiskImageFormatPane extends WizardPane {
switch (wizard.getFormat()) {
case DiskImageWizard.FORMAT_DOS33:
case DiskImageWizard.FORMAT_RDOS:
case DiskImageWizard.FORMAT_CPM:
wizard.setOrder(DiskImageWizard.ORDER_DOS);
wizard.setSize(FormattedDisk.APPLE_140KB_DISK);
return new DiskImageNamePane(parent, wizard);
@ -123,6 +124,8 @@ public class DiskImageFormatPane extends WizardPane {
+ "that I've seen have been mapped onto a 16 sector disk (leaving 3\n"
+ "sectors of each track unused. The only image size RDOS supports\n"
+ "is 140K.");
createRadioButton(buttonSubpanel, "CP/M", DiskImageWizard.FORMAT_CPM,
"CP/M for the Apple computer.");
control.pack();
}
/**

View File

@ -19,6 +19,8 @@
*/
package com.webcodepro.applecommander.ui.swt;
import com.webcodepro.applecommander.storage.Disk;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@ -87,6 +89,13 @@ public class DiskImageOrderPane extends WizardPane {
createRadioButton(buttonSubpanel, "ProDOS ordered",
DiskImageWizard.ORDER_PRODOS,
"Indicates that image data should be stored by block.");
if (wizard.getSize() == Disk.APPLE_140KB_DISK) {
createRadioButton(buttonSubpanel, "Nibble ordered",
DiskImageWizard.ORDER_NIBBLE,
"Indicates that this is a disk stored as a nibble image. This is "
+ "an image that consists of disk bytes. It is only available for "
+ "140KB 5.25\" disks.");
}
label = new Label(control, SWT.WRAP);
if (wizard.isHardDisk()) {

View File

@ -27,6 +27,12 @@ import com.webcodepro.applecommander.storage.PascalFormatDisk;
import com.webcodepro.applecommander.storage.ProdosFormatDisk;
import com.webcodepro.applecommander.storage.RdosFormatDisk;
import com.webcodepro.applecommander.storage.UniDosFormatDisk;
import com.webcodepro.applecommander.storage.cpm.CpmFormatDisk;
import com.webcodepro.applecommander.storage.physical.ByteArrayImageLayout;
import com.webcodepro.applecommander.storage.physical.DosOrder;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.storage.physical.NibbleOrder;
import com.webcodepro.applecommander.storage.physical.ProdosOrder;
import org.eclipse.swt.widgets.Shell;
@ -43,8 +49,10 @@ public class DiskImageWizard extends Wizard {
public static final int FORMAT_PASCAL = 4;
public static final int FORMAT_RDOS = 5;
public static final int FORMAT_OZDOS = 6;
public static final int FORMAT_CPM = 7;
public static final int ORDER_DOS = 1;
public static final int ORDER_PRODOS = 2;
public static final int ORDER_NIBBLE = 3;
private int format = FORMAT_DOS33;
private int size = FormattedDisk.APPLE_140KB_DISK;
private String fileName = "";
@ -79,19 +87,34 @@ public class DiskImageWizard extends Wizard {
if (isCompressed()) {
name.append(".gz");
}
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(getSize());
ImageOrder imageOrder = null;
switch (getOrder()) {
case ORDER_DOS:
imageOrder = new DosOrder(imageLayout);
break;
case ORDER_NIBBLE:
imageOrder = new NibbleOrder(imageLayout);
break;
case ORDER_PRODOS:
imageOrder = new ProdosOrder(imageLayout);
break;
}
switch (format) {
case FORMAT_DOS33:
return DosFormatDisk.create(name.toString());
return DosFormatDisk.create(name.toString(), imageOrder);
case FORMAT_OZDOS:
return OzDosFormatDisk.create(name.toString());
return OzDosFormatDisk.create(name.toString(), imageOrder);
case FORMAT_PASCAL:
return PascalFormatDisk.create(name.toString(), volumeName, size);
return PascalFormatDisk.create(name.toString(), volumeName, imageOrder);
case FORMAT_PRODOS:
return ProdosFormatDisk.create(name.toString(), volumeName, size);
return ProdosFormatDisk.create(name.toString(), volumeName, imageOrder);
case FORMAT_RDOS:
return RdosFormatDisk.create(name.toString());
return RdosFormatDisk.create(name.toString(), imageOrder);
case FORMAT_UNIDOS:
return UniDosFormatDisk.create(name.toString());
return UniDosFormatDisk.create(name.toString(), imageOrder);
case FORMAT_CPM:
return CpmFormatDisk.create(name.toString(), imageOrder);
}
return null;
}