mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-27 14:49:25 +00:00
colours!
This commit is contained in:
parent
13f8229db8
commit
37b0f587e7
@ -14,14 +14,23 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
private final Color green = new Color (0, 200, 0);
|
private final Color green = new Color (0, 200, 0);
|
||||||
public final SectorType catalogSector = new SectorType ("Catalog", green);
|
public final SectorType catalogSector = new SectorType ("Catalog", green);
|
||||||
public final SectorType cpmSector = new SectorType ("CPM", Color.lightGray);
|
public final SectorType cpmSector = new SectorType ("CPM", Color.lightGray);
|
||||||
|
public final SectorType comSector = new SectorType ("COM", Color.red);
|
||||||
|
public final SectorType dataSector = new SectorType ("Data", Color.blue);
|
||||||
|
public final SectorType docSector = new SectorType ("DOC", Color.cyan);
|
||||||
|
public final SectorType xxxSector = new SectorType ("xxx", Color.gray);
|
||||||
|
|
||||||
private int version; // http://www.seasip.info/Cpm/format22.html
|
private int version; // http://www.seasip.info/Cpm/format22.html
|
||||||
|
|
||||||
public CPMDisk (Disk disk)
|
public CPMDisk (Disk disk)
|
||||||
{
|
{
|
||||||
super (disk);
|
super (disk);
|
||||||
|
|
||||||
sectorTypesList.add (catalogSector);
|
sectorTypesList.add (catalogSector);
|
||||||
sectorTypesList.add (cpmSector);
|
sectorTypesList.add (cpmSector);
|
||||||
|
sectorTypesList.add (comSector);
|
||||||
|
sectorTypesList.add (dataSector);
|
||||||
|
sectorTypesList.add (xxxSector);
|
||||||
|
sectorTypesList.add (docSector);
|
||||||
|
|
||||||
byte[] sectorBuffer = disk.readSector (0, 0); // Boot sector
|
byte[] sectorBuffer = disk.readSector (0, 0); // Boot sector
|
||||||
bootSector = new BootSector (disk, sectorBuffer, "CPM");
|
bootSector = new BootSector (disk, sectorBuffer, "CPM");
|
||||||
@ -47,6 +56,10 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
if (buffer[i] == 0)
|
if (buffer[i] == 0)
|
||||||
{
|
{
|
||||||
DirectoryEntry entry = new DirectoryEntry (this, buffer, i);
|
DirectoryEntry entry = new DirectoryEntry (this, buffer, i);
|
||||||
|
SectorType sectorType = getSectorType (entry.getType ());
|
||||||
|
for (DiskAddress block : entry.getSectors ())
|
||||||
|
sectorTypes[block.getBlock ()] = sectorType;
|
||||||
|
|
||||||
DirectoryEntry parent = findParent (entry);
|
DirectoryEntry parent = findParent (entry);
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
{
|
{
|
||||||
@ -65,6 +78,16 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
makeNodeVisible (root.getFirstLeaf ());
|
makeNodeVisible (root.getFirstLeaf ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SectorType getSectorType (String type)
|
||||||
|
{
|
||||||
|
if ("COM".equals (type))
|
||||||
|
return comSector;
|
||||||
|
if ("DOC".equals (type))
|
||||||
|
return docSector;
|
||||||
|
|
||||||
|
return dataSector;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DiskAddress> getFileSectors (int fileNo)
|
public List<DiskAddress> getFileSectors (int fileNo)
|
||||||
{
|
{
|
||||||
@ -84,10 +107,11 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
public AppleFileSource getCatalog ()
|
public AppleFileSource getCatalog ()
|
||||||
{
|
{
|
||||||
String newLine = String.format ("%n");
|
String newLine = String.format ("%n");
|
||||||
String line = "---- --------- ---- ---- ----" + newLine;
|
String line = "---- --------- ---- ---- ---- ----------------------------"
|
||||||
|
+ "-------------------" + newLine;
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
text.append (String.format ("Disk : %s%n%n", getAbsolutePath ()));
|
text.append (String.format ("Disk : %s%n%n", getAbsolutePath ()));
|
||||||
text.append ("User Name Type Exts Size" + newLine);
|
text.append ("User Name Type Exts Size Blocks" + newLine);
|
||||||
text.append (line);
|
text.append (line);
|
||||||
|
|
||||||
for (AppleFileSource entry : fileEntries)
|
for (AppleFileSource entry : fileEntries)
|
||||||
@ -95,6 +119,7 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
text.append (((DirectoryEntry) entry).line ());
|
text.append (((DirectoryEntry) entry).line ());
|
||||||
text.append (newLine);
|
text.append (newLine);
|
||||||
}
|
}
|
||||||
|
text.append (line);
|
||||||
|
|
||||||
return new DefaultAppleFileSource ("CPM Disk ", text.toString (), this);
|
return new DefaultAppleFileSource ("CPM Disk ", text.toString (), this);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
|
import com.bytezone.diskbrowser.disk.AppleDiskAddress;
|
||||||
|
import com.bytezone.diskbrowser.disk.Disk;
|
||||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||||
import com.bytezone.diskbrowser.gui.DataSource;
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
@ -21,6 +23,7 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
private final int rc;
|
private final int rc;
|
||||||
private final byte[] blockList = new byte[16];
|
private final byte[] blockList = new byte[16];
|
||||||
private final List<DirectoryEntry> entries = new ArrayList<DirectoryEntry> ();
|
private final List<DirectoryEntry> entries = new ArrayList<DirectoryEntry> ();
|
||||||
|
private final List<DiskAddress> blocks = new ArrayList<DiskAddress> ();
|
||||||
|
|
||||||
public DirectoryEntry (CPMDisk parent, byte[] buffer, int offset)
|
public DirectoryEntry (CPMDisk parent, byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
@ -33,6 +36,22 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
s1 = buffer[offset + 14] & 0xFF;
|
s1 = buffer[offset + 14] & 0xFF;
|
||||||
rc = buffer[offset + 15] & 0xFF;
|
rc = buffer[offset + 15] & 0xFF;
|
||||||
System.arraycopy (buffer, offset + 16, blockList, 0, 16);
|
System.arraycopy (buffer, offset + 16, blockList, 0, 16);
|
||||||
|
|
||||||
|
Disk disk = parent.getDisk ();
|
||||||
|
for (byte b : blockList)
|
||||||
|
{
|
||||||
|
if (b == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
int blockNumber = b * 4 + 48;
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
blocks.add (new AppleDiskAddress (blockNumber + i, disk));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType ()
|
||||||
|
{
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches (DirectoryEntry directoryEntry)
|
public boolean matches (DirectoryEntry directoryEntry)
|
||||||
@ -44,13 +63,33 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
public void add (DirectoryEntry entry)
|
public void add (DirectoryEntry entry)
|
||||||
{
|
{
|
||||||
entries.add (entry);
|
entries.add (entry);
|
||||||
|
|
||||||
|
Disk disk = parent.getDisk ();
|
||||||
|
for (byte b : entry.blockList)
|
||||||
|
{
|
||||||
|
if (b == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
int blockNumber = b * 4 + 48;
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
blocks.add (new AppleDiskAddress (blockNumber + i, disk));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String line ()
|
public String line ()
|
||||||
{
|
{
|
||||||
int blocks = ((rc & 0xF0) >> 3) + (((rc & 0x0F) + 7) / 8);
|
int blocks = ((rc & 0xF0) >> 3) + (((rc & 0x0F) + 7) / 8);
|
||||||
return String.format ("%3d %-8s %-3s %3d %3d", userNumber, name, type,
|
String bytes = HexFormatter.getHexString (blockList, 0, 16);
|
||||||
entries.size () + 1, blocks);
|
bytes = bytes.replaceAll ("00", " ");
|
||||||
|
String text = String.format ("%3d %-8s %-3s %3d %3d %s", userNumber, name,
|
||||||
|
type, entries.size () + 1, blocks, bytes);
|
||||||
|
for (DirectoryEntry entry : entries)
|
||||||
|
{
|
||||||
|
bytes = HexFormatter.getHexString (entry.blockList, 0, 16);
|
||||||
|
bytes = bytes.replaceAll ("00", " ");
|
||||||
|
text = text + String.format ("%n%-36.36s%s", "", bytes);
|
||||||
|
}
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toDetailedString ()
|
public String toDetailedString ()
|
||||||
@ -93,7 +132,7 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
@Override
|
@Override
|
||||||
public List<DiskAddress> getSectors ()
|
public List<DiskAddress> getSectors ()
|
||||||
{
|
{
|
||||||
return null;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -355,6 +355,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||||||
public FileEntry (byte[] buffer)
|
public FileEntry (byte[] buffer)
|
||||||
{
|
{
|
||||||
super (buffer);
|
super (buffer);
|
||||||
|
|
||||||
bytesUsedInLastBlock = HexFormatter.intValue (buffer[22], buffer[23]);
|
bytesUsedInLastBlock = HexFormatter.intValue (buffer[22], buffer[23]);
|
||||||
date = HexFormatter.getPascalDate (buffer, 24);
|
date = HexFormatter.getPascalDate (buffer, 24);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user