checking CPM format

This commit is contained in:
Denis Molony 2016-02-24 23:32:36 +11:00
parent 71e94c61ba
commit 7c401c240d
3 changed files with 29 additions and 14 deletions

View File

@ -16,6 +16,8 @@ public class CPMDisk extends AbstractFormattedDisk
public final SectorType catalogSector = new SectorType ("Catalog", green);
public final SectorType cpmSector = new SectorType ("CPM", Color.lightGray);
private int version; // http://www.seasip.info/Cpm/format22.html
public CPMDisk (Disk disk)
{
super (disk);
@ -26,6 +28,11 @@ public class CPMDisk extends AbstractFormattedDisk
bootSector = new BootSector (disk, sectorBuffer, "CPM");
sectorTypes[0] = cpmSector;
byte[] buffer = disk.readSector (0, 8);
String text = new String (buffer, 16, 24);
if ("DIR ERA TYPESAVEREN USER".equals (text))
version = buffer[41] & 0xFF;
for (int sector = 0; sector < 8; sector++)
{
DiskAddress da = disk.getDiskAddress (3, sector);
@ -43,21 +50,27 @@ public class CPMDisk extends AbstractFormattedDisk
{
disk.setInterleave (3);
byte[] buffer = disk.readSector (0, 8);
String text = new String (buffer, 16, 24);
System.out.println (text);
if ("DIR ERA TYPESAVEREN USER".equals (text))
return true;
buffer = disk.readSector (0, 4);
text = new String (buffer, 16, 24);
System.out.println (text);
if ("DIR ERA TYPESAVEREN USER".equals (text))
return true;
for (int sector = 0; sector < 8; sector++)
{
byte[] buffer = disk.readSector (3, sector);
buffer = disk.readSector (3, sector);
for (int i = 0; i < buffer.length; i += 32)
{
if (buffer[i] != 0 && buffer[i] != (byte) 0xE5)
return false;
if (buffer[i] == 0)
{
// String filename = HexFormatter.getString (buffer, i + 1, 8);
// String filetype = HexFormatter.getString (buffer, i + 9, 3);
// String bytes = HexFormatter.getHexString (buffer, i + 12, 20);
// System.out.println (filename + " " + filetype + " " + bytes);
System.out.println (new DirectoryEntry (buffer, i));
}
}
}

View File

@ -32,16 +32,15 @@ public class DirectoryEntry
text.append (String.format ("User number .... %d%n", userNumber));
text.append (String.format ("File name ...... %s%n", name + "." + type));
// text.append (String.format ("File type ...... %s%n", type));
text.append (String.format ("Extents lo ..... %d%n", ex));
text.append (String.format ("Extents hi ..... %d%n", s2));
text.append (String.format ("Reserved ....... %d%n", s1));
int blocks = ((rc & 0xF0) >> 3) + (((rc & 0x0F) + 7) / 8);
text.append (String.format ("Records ........ %02X (%d)%n", rc, blocks));
text.append (String
.format ("Allocation ..... %s%n",
HexFormatter.formatNoHeader (blockList, 0, 16).subSequence (8, 55)));
String bytes = HexFormatter.getHexString (blockList, 0, 16);
text.append (String.format ("Allocation ..... %s%n", bytes));
return text.toString ();
}

View File

@ -178,9 +178,9 @@ public class DiskFactory
else if (checksum == 3028642627L || checksum == 2070151659L)
disk = checkInfocomDisk (file);
else if (checksum == 1212926910L || checksum == 1365043894L
|| checksum == 2128073918L)
disk = checkCPMDisk (file);
// else if (checksum == 1212926910L || checksum == 1365043894L
// || checksum == 2128073918L)
// disk = checkCPMDisk (file);
// System.out.println (checksum);
@ -220,6 +220,9 @@ public class DiskFactory
if (disk == null)
disk = checkPascalDisk (file);
if (disk == null)
disk = checkCPMDisk (file);
if (disk == null)
{
disk2 = checkInfocomDisk (file);