mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-29 11:49:29 +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 JTree catalogTree;
|
||||||
protected Path originalPath;
|
protected Path originalPath;
|
||||||
|
|
||||||
protected List<SectorType> sectorTypesList = new ArrayList<SectorType> ();
|
protected List<SectorType> sectorTypesList = new ArrayList<> ();
|
||||||
protected List<AppleFileSource> fileEntries = new ArrayList<AppleFileSource> ();
|
protected List<AppleFileSource> fileEntries = new ArrayList<> ();
|
||||||
|
|
||||||
public SectorType[] sectorTypes;
|
public SectorType[] sectorTypes;
|
||||||
|
|
||||||
@ -113,6 +113,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
private void setGridLayout ()
|
private void setGridLayout ()
|
||||||
{
|
{
|
||||||
int totalBlocks = disk.getTotalBlocks ();
|
int totalBlocks = disk.getTotalBlocks ();
|
||||||
|
|
||||||
switch (totalBlocks)
|
switch (totalBlocks)
|
||||||
{
|
{
|
||||||
case 280:
|
case 280:
|
||||||
@ -132,6 +133,9 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1600:
|
case 1600:
|
||||||
|
if (disk.getSectorsPerTrack () == 32)
|
||||||
|
gridLayout = new Dimension (32, 50);
|
||||||
|
else
|
||||||
gridLayout = new Dimension (16, 100);
|
gridLayout = new Dimension (16, 100);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -39,7 +39,8 @@ public class AppleDisk implements Disk
|
|||||||
|
|
||||||
private int interleave = 0;
|
private int interleave = 0;
|
||||||
private static int[][] interleaveSector = //
|
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, 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, 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
|
{ 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 WozFile wozFile;
|
||||||
|
|
||||||
private final boolean debug = false;
|
private final boolean debug = true;
|
||||||
|
|
||||||
public AppleDisk (File file, int tracks, int sectors) throws FileFormatException
|
public AppleDisk (File file, int tracks, int sectors) throws FileFormatException
|
||||||
{
|
{
|
||||||
@ -170,6 +171,12 @@ public class AppleDisk implements Disk
|
|||||||
this.sectorSize = 512;
|
this.sectorSize = 512;
|
||||||
this.trackSize = sectors * sectorSize;
|
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
|
else
|
||||||
{
|
{
|
||||||
this.blocks = tracks * sectors;
|
this.blocks = tracks * sectors;
|
||||||
@ -316,12 +323,12 @@ public class AppleDisk implements Disk
|
|||||||
|
|
||||||
for (DiskAddress da : this) // uses blockList.iterator
|
for (DiskAddress da : this) // uses blockList.iterator
|
||||||
{
|
{
|
||||||
if (sectorSize == SECTOR_SIZE)
|
if (sectorSize == SECTOR_SIZE) // 256 byte sectors
|
||||||
{
|
{
|
||||||
int diskOffset = getBufferOffset (da);
|
int diskOffset = getBufferOffset (da);
|
||||||
hasData[da.getBlock ()] = check (diskOffset);
|
hasData[da.getBlock ()] = check (diskOffset);
|
||||||
}
|
}
|
||||||
else
|
else // 512 byte blocks
|
||||||
{
|
{
|
||||||
int diskOffset1 = getBufferOffset (da, 0);
|
int diskOffset1 = getBufferOffset (da, 0);
|
||||||
int diskOffset2 = getBufferOffset (da, 1);
|
int diskOffset2 = getBufferOffset (da, 1);
|
||||||
|
@ -201,6 +201,16 @@ public class DiskFactory
|
|||||||
return disk;
|
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)
|
if (debug)
|
||||||
System.out.println (" Checking po or dsk hard drive: " + file.length ());
|
System.out.println (" Checking po or dsk hard drive: " + file.length ());
|
||||||
|
|
||||||
@ -520,6 +530,29 @@ public class DiskFactory
|
|||||||
return null;
|
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)
|
private static FormattedDisk checkHardDisk (File file)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@ -235,12 +235,15 @@ public class DosDisk extends AbstractFormattedDisk
|
|||||||
{
|
{
|
||||||
disk.setInterleave (0);
|
disk.setInterleave (0);
|
||||||
int catalogBlocks = checkFormat (disk);
|
int catalogBlocks = checkFormat (disk);
|
||||||
|
System.out.printf ("Catalog blocks: %d%n", catalogBlocks);
|
||||||
|
|
||||||
if (catalogBlocks > 3)
|
if (catalogBlocks > 3)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (disk.getSectorsPerTrack () <= 16)
|
||||||
|
{
|
||||||
disk.setInterleave (1);
|
disk.setInterleave (1);
|
||||||
int cb2 = checkFormat (disk);
|
int cb2 = checkFormat (disk);
|
||||||
// if (cb2 > catalogBlocks)
|
|
||||||
if (cb2 > 3)
|
if (cb2 > 3)
|
||||||
return true;
|
return true;
|
||||||
disk.setInterleave (2);
|
disk.setInterleave (2);
|
||||||
@ -259,6 +262,7 @@ public class DosDisk extends AbstractFormattedDisk
|
|||||||
|
|
||||||
if (cb2 > 0)
|
if (cb2 > 0)
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -297,7 +301,7 @@ public class DosDisk extends AbstractFormattedDisk
|
|||||||
// if (buffer[1] != 0x11) // first catalog track
|
// if (buffer[1] != 0x11) // first catalog track
|
||||||
// return 0;
|
// 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;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -322,9 +326,8 @@ public class DosDisk extends AbstractFormattedDisk
|
|||||||
private static int countCatalogBlocks (AppleDisk disk, byte[] buffer)
|
private static int countCatalogBlocks (AppleDisk disk, byte[] buffer)
|
||||||
{
|
{
|
||||||
DiskAddress catalogStart = disk.getDiskAddress (buffer[1], buffer[2]);
|
DiskAddress catalogStart = disk.getDiskAddress (buffer[1], buffer[2]);
|
||||||
// int catalogBlocks = 0;
|
|
||||||
DiskAddress da = disk.getDiskAddress (catalogStart.getBlock ());
|
DiskAddress da = disk.getDiskAddress (catalogStart.getBlock ());
|
||||||
List<DiskAddress> catalogAddresses = new ArrayList<DiskAddress> ();
|
List<DiskAddress> catalogAddresses = new ArrayList<> ();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -339,10 +342,7 @@ public class DosDisk extends AbstractFormattedDisk
|
|||||||
|
|
||||||
buffer = disk.readSector (da);
|
buffer = disk.readSector (da);
|
||||||
if (!disk.isValidAddress (buffer[1], buffer[2]))
|
if (!disk.isValidAddress (buffer[1], buffer[2]))
|
||||||
{
|
|
||||||
// System.out.printf ("Invalid address : %02X / %02X%n", buffer[1], buffer[2]);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
catalogAddresses.add (da);
|
catalogAddresses.add (da);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user