mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-25 16:34:00 +00:00
initial unidos support
This commit is contained in:
parent
85717fac5e
commit
a32160cc33
@ -31,8 +31,8 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
||||
protected JTree catalogTree;
|
||||
protected Path originalPath;
|
||||
|
||||
protected List<SectorType> sectorTypesList = new ArrayList<SectorType> ();
|
||||
protected List<AppleFileSource> fileEntries = new ArrayList<AppleFileSource> ();
|
||||
protected List<SectorType> sectorTypesList = new ArrayList<> ();
|
||||
protected List<AppleFileSource> fileEntries = new ArrayList<> ();
|
||||
|
||||
public SectorType[] sectorTypes;
|
||||
|
||||
@ -113,6 +113,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
||||
private void setGridLayout ()
|
||||
{
|
||||
int totalBlocks = disk.getTotalBlocks ();
|
||||
|
||||
switch (totalBlocks)
|
||||
{
|
||||
case 280:
|
||||
@ -132,7 +133,10 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
||||
break;
|
||||
|
||||
case 1600:
|
||||
gridLayout = new Dimension (16, 100);
|
||||
if (disk.getSectorsPerTrack () == 32)
|
||||
gridLayout = new Dimension (32, 50);
|
||||
else
|
||||
gridLayout = new Dimension (16, 100);
|
||||
break;
|
||||
|
||||
case 2048:
|
||||
|
@ -39,7 +39,8 @@ public class AppleDisk implements Disk
|
||||
|
||||
private int interleave = 0;
|
||||
private static int[][] interleaveSector = //
|
||||
{ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, // None
|
||||
{ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
||||
22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, // None
|
||||
{ 0, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15 }, // Prodos/Pascal
|
||||
{ 0, 13, 11, 9, 7, 5, 3, 1, 14, 12, 10, 8, 6, 4, 2, 15 }, // Infocom
|
||||
{ 0, 6, 12, 3, 9, 15, 14, 5, 11, 2, 8, 7, 13, 4, 10, 1 } }; // CPM
|
||||
@ -83,7 +84,7 @@ public class AppleDisk implements Disk
|
||||
|
||||
private WozFile wozFile;
|
||||
|
||||
private final boolean debug = false;
|
||||
private final boolean debug = true;
|
||||
|
||||
public AppleDisk (File file, int tracks, int sectors) throws FileFormatException
|
||||
{
|
||||
@ -170,6 +171,12 @@ public class AppleDisk implements Disk
|
||||
this.sectorSize = 512;
|
||||
this.trackSize = sectors * sectorSize;
|
||||
}
|
||||
else if (file.length () == 819200 && tracks == 50 && sectors == 32) // unidisk
|
||||
{
|
||||
this.blocks = tracks * sectors;
|
||||
this.sectorSize = 256;
|
||||
this.trackSize = sectors * sectorSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.blocks = tracks * sectors;
|
||||
@ -316,12 +323,12 @@ public class AppleDisk implements Disk
|
||||
|
||||
for (DiskAddress da : this) // uses blockList.iterator
|
||||
{
|
||||
if (sectorSize == SECTOR_SIZE)
|
||||
if (sectorSize == SECTOR_SIZE) // 256 byte sectors
|
||||
{
|
||||
int diskOffset = getBufferOffset (da);
|
||||
hasData[da.getBlock ()] = check (diskOffset);
|
||||
}
|
||||
else
|
||||
else // 512 byte blocks
|
||||
{
|
||||
int diskOffset1 = getBufferOffset (da, 0);
|
||||
int diskOffset2 = getBufferOffset (da, 1);
|
||||
|
@ -201,6 +201,16 @@ public class DiskFactory
|
||||
return disk;
|
||||
}
|
||||
|
||||
if (file.length () == 819200)
|
||||
{
|
||||
if (debug)
|
||||
System.out.println ("UniDos ?");
|
||||
// 2 x 400k disk images
|
||||
AppleDisk appleDisk = new AppleDisk (file, 50, 32);
|
||||
disk = checkUnidos (appleDisk);
|
||||
return disk == null ? new DataDisk (appleDisk) : disk;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
System.out.println (" Checking po or dsk hard drive: " + file.length ());
|
||||
|
||||
@ -520,6 +530,29 @@ public class DiskFactory
|
||||
return null;
|
||||
}
|
||||
|
||||
private static DosDisk checkUnidos (AppleDisk disk)
|
||||
{
|
||||
if (debug)
|
||||
System.out.println ("Checking UniDOS disk");
|
||||
|
||||
try
|
||||
{
|
||||
if (DosDisk.isCorrectFormat (disk))
|
||||
{
|
||||
if (debug)
|
||||
System.out.println (" --> UniDOS");
|
||||
return new DosDisk (disk);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
if (debug)
|
||||
System.out.println (" not a UniDOS disk");
|
||||
return null;
|
||||
}
|
||||
|
||||
private static FormattedDisk checkHardDisk (File file)
|
||||
{
|
||||
if (debug)
|
||||
|
@ -235,30 +235,34 @@ public class DosDisk extends AbstractFormattedDisk
|
||||
{
|
||||
disk.setInterleave (0);
|
||||
int catalogBlocks = checkFormat (disk);
|
||||
System.out.printf ("Catalog blocks: %d%n", catalogBlocks);
|
||||
|
||||
if (catalogBlocks > 3)
|
||||
return true;
|
||||
disk.setInterleave (1);
|
||||
int cb2 = checkFormat (disk);
|
||||
// if (cb2 > catalogBlocks)
|
||||
if (cb2 > 3)
|
||||
return true;
|
||||
disk.setInterleave (2);
|
||||
if (true)
|
||||
{
|
||||
int cb3 = checkFormat (disk);
|
||||
if (cb3 > 3)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (catalogBlocks > 0)
|
||||
if (disk.getSectorsPerTrack () <= 16)
|
||||
{
|
||||
disk.setInterleave (1);
|
||||
return true;
|
||||
}
|
||||
int cb2 = checkFormat (disk);
|
||||
if (cb2 > 3)
|
||||
return true;
|
||||
disk.setInterleave (2);
|
||||
if (true)
|
||||
{
|
||||
int cb3 = checkFormat (disk);
|
||||
if (cb3 > 3)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cb2 > 0)
|
||||
return true;
|
||||
if (catalogBlocks > 0)
|
||||
{
|
||||
disk.setInterleave (1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cb2 > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -297,7 +301,7 @@ public class DosDisk extends AbstractFormattedDisk
|
||||
// if (buffer[1] != 0x11) // first catalog track
|
||||
// return 0;
|
||||
|
||||
if (buffer[53] != 16 && buffer[53] != 13) // sectors per track
|
||||
if (buffer[53] != 16 && buffer[53] != 13 && buffer[53] != 32) // sectors per track
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -322,9 +326,8 @@ public class DosDisk extends AbstractFormattedDisk
|
||||
private static int countCatalogBlocks (AppleDisk disk, byte[] buffer)
|
||||
{
|
||||
DiskAddress catalogStart = disk.getDiskAddress (buffer[1], buffer[2]);
|
||||
// int catalogBlocks = 0;
|
||||
DiskAddress da = disk.getDiskAddress (catalogStart.getBlock ());
|
||||
List<DiskAddress> catalogAddresses = new ArrayList<DiskAddress> ();
|
||||
List<DiskAddress> catalogAddresses = new ArrayList<> ();
|
||||
|
||||
do
|
||||
{
|
||||
@ -339,10 +342,7 @@ public class DosDisk extends AbstractFormattedDisk
|
||||
|
||||
buffer = disk.readSector (da);
|
||||
if (!disk.isValidAddress (buffer[1], buffer[2]))
|
||||
{
|
||||
// System.out.printf ("Invalid address : %02X / %02X%n", buffer[1], buffer[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
catalogAddresses.add (da);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user