allow cpm.sys in directory

This commit is contained in:
Denis Molony 2016-02-28 10:17:34 +11:00
parent 91b63158f1
commit 21e7f8f226
2 changed files with 32 additions and 23 deletions

View File

@ -56,27 +56,26 @@ public class CPMDisk extends AbstractFormattedDisk
for (int i = 0; i < buffer.length; i += 32) for (int i = 0; i < buffer.length; i += 32)
{ {
if (buffer[i] != 0 && buffer[i] != (byte) 0xE5) int val = buffer[i] & 0xFF;
if (val == 0xE5)
break; break;
if (buffer[i] == 0)
{
DirectoryEntry entry = new DirectoryEntry (this, buffer, i);
SectorType sectorType = getSectorType (entry.getType ());
for (DiskAddress block : entry.getSectors ())
if (!disk.isSectorEmpty (block))
sectorTypes[block.getBlock ()] = sectorType;
DirectoryEntry parent = findParent (entry); DirectoryEntry entry = new DirectoryEntry (this, buffer, i);
if (parent == null) SectorType sectorType = getSectorType (entry.getType ());
{ for (DiskAddress block : entry.getSectors ())
fileEntries.add (entry); if (!disk.isSectorEmpty (block))
DefaultMutableTreeNode node = new DefaultMutableTreeNode (entry); sectorTypes[block.getBlock ()] = sectorType;
root.add (node);
node.setAllowsChildren (false); DirectoryEntry parent = findParent (entry);
} if (parent == null)
else {
parent.add (entry); fileEntries.add (entry);
DefaultMutableTreeNode node = new DefaultMutableTreeNode (entry);
root.add (node);
node.setAllowsChildren (false);
} }
else
parent.add (entry);
} }
} }
@ -175,6 +174,13 @@ public class CPMDisk extends AbstractFormattedDisk
return true; return true;
if (val > 31) if (val > 31)
return false; return false;
for (int j = 1; j <= 8; j++)
{
val = buffer[i + j] & 0xFF;
// System.out.printf ("%3d %s%n", val, (char) val);
if (val < 32 || val > 126)
return false;
}
} }
} }

View File

@ -64,12 +64,15 @@ public class DirectoryEntry implements AppleFileSource
if (b == 0) if (b == 0)
break; break;
int blockNumber = b * 4 + 48; int blockNumber;
if ((b & 0x80) == 0)
blockNumber = (b * 4 + 48);
else
blockNumber = (b & 0x7F) * 4;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ blocks.add (new AppleDiskAddress (blockNumber + i, disk));
AppleDiskAddress da = new AppleDiskAddress (blockNumber + i, disk);
blocks.add (da);
}
} }
} }