mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-12-24 23:31:31 +00:00
CPM catalog sector
This commit is contained in:
parent
54f037b2aa
commit
465be7c41f
37
src/com/bytezone/diskbrowser/cpm/CPMCatalogSector.java
Normal file
37
src/com/bytezone/diskbrowser/cpm/CPMCatalogSector.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.bytezone.diskbrowser.cpm;
|
||||
|
||||
import com.bytezone.diskbrowser.disk.AbstractSector;
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
|
||||
public class CPMCatalogSector extends AbstractSector
|
||||
{
|
||||
private static int CATALOG_ENTRY_SIZE = 32;
|
||||
|
||||
public CPMCatalogSector (Disk disk, byte[] buffer)
|
||||
{
|
||||
super (disk, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createText ()
|
||||
{
|
||||
StringBuilder text = getHeader ("Catalog Sector");
|
||||
|
||||
for (int i = 0; i <= 255; i += CATALOG_ENTRY_SIZE)
|
||||
{
|
||||
if (buffer[i] == (byte) 0xE5)
|
||||
break;
|
||||
addText (text, buffer, i, 1, "User number");
|
||||
addText (text, buffer, i + 1, 4, "File name : " + new String (buffer, i + 1, 8));
|
||||
addText (text, buffer, i + 9, 3, "File type : " + new String (buffer, i + 9, 3));
|
||||
addText (text, buffer, i + 12, 1, "Extent counter LO");
|
||||
addText (text, buffer, i + 13, 1, "Reserved");
|
||||
addText (text, buffer, i + 14, 1, "Extent counter HI");
|
||||
addText (text, buffer, i + 15, 1, "Record count");
|
||||
text.append ("\n");
|
||||
}
|
||||
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||
import com.bytezone.diskbrowser.disk.*;
|
||||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
|
||||
public class CPMDisk extends AbstractFormattedDisk
|
||||
{
|
||||
@ -112,15 +113,28 @@ public class CPMDisk extends AbstractFormattedDisk
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getFormattedSector (DiskAddress da)
|
||||
{
|
||||
SectorType type = sectorTypes[da.getBlock ()];
|
||||
byte[] buffer = disk.readSector (da);
|
||||
|
||||
if (type == catalogSector)
|
||||
return new CPMCatalogSector (disk, buffer);
|
||||
|
||||
return super.getFormattedSector (da);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppleFileSource getCatalog ()
|
||||
{
|
||||
String newLine = String.format ("%n");
|
||||
String line = "---- --------- ---- ---- ---- ----------------------------"
|
||||
+ "-------------------" + newLine;
|
||||
String line =
|
||||
"---- --------- --- -- -- -- -- ----------------------------"
|
||||
+ "-------------------" + newLine;
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (String.format ("Disk : %s%n%n", getAbsolutePath ()));
|
||||
text.append ("User Name Type Exts Size Blocks" + newLine);
|
||||
text.append ("User Name Typ Ex S2 S1 RC Blocks" + newLine);
|
||||
text.append (line);
|
||||
|
||||
for (AppleFileSource entry : fileEntries)
|
||||
|
@ -98,15 +98,11 @@ public class DirectoryEntry implements AppleFileSource
|
||||
int blocks = ((rc & 0xF0) >> 3) + (((rc & 0x0F) + 7) / 8);
|
||||
String bytes = HexFormatter.getHexString (blockList, 0, 16);
|
||||
bytes = bytes.replaceAll ("00", " ");
|
||||
String text = String.format ("%3d %-8s %-3s %3d %3d %s", userNumber, name,
|
||||
type, entries.size () + 1, blocks, bytes);
|
||||
String text = String.format ("%3d %-8s %-3s %02X %02X %02X %02X %s",
|
||||
userNumber, name, type, ex, s2, s1, rc, bytes);
|
||||
for (DirectoryEntry entry : entries)
|
||||
{
|
||||
bytes = HexFormatter.getHexString (entry.blockList, 0, 16);
|
||||
bytes = bytes.replaceAll ("00", " ").trim ();
|
||||
if (!bytes.isEmpty ())
|
||||
text = text + String.format ("%n%-36.36s%s", "", bytes);
|
||||
}
|
||||
text = text + "\n" + entry.line ();
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,6 @@ public abstract class AbstractSector implements DataSource
|
||||
@Override
|
||||
public JComponent getComponent ()
|
||||
{
|
||||
System.out.println ("In AbstractSector.getComponent()");
|
||||
JPanel panel = new JPanel ();
|
||||
return panel;
|
||||
}
|
||||
|
@ -6,10 +6,9 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
class DosCatalogSector extends AbstractSector
|
||||
{
|
||||
private static final String[] fileTypes = { "Text file", "Integer Basic program",
|
||||
"Applesoft Basic program", "Binary file",
|
||||
"SS file", "Relocatable file", "AA file",
|
||||
"BB file" };
|
||||
private static final String[] fileTypes =
|
||||
{ "Text file", "Integer Basic program", "Applesoft Basic program", "Binary file",
|
||||
"SS file", "Relocatable file", "AA file", "BB file" };
|
||||
private static int CATALOG_ENTRY_SIZE = 35;
|
||||
|
||||
public DosCatalogSector (Disk disk, byte[] buffer)
|
||||
@ -33,12 +32,9 @@ class DosCatalogSector extends AbstractSector
|
||||
{
|
||||
if (buffer[i] == (byte) 0xFF)
|
||||
{
|
||||
addText (text,
|
||||
buffer,
|
||||
i + 0,
|
||||
2,
|
||||
addText (text, buffer, i + 0, 2,
|
||||
"DEL: file @ " + HexFormatter.format2 (buffer[i + 32]) + " "
|
||||
+ HexFormatter.format2 (buffer[i + 1]));
|
||||
+ HexFormatter.format2 (buffer[i + 1]));
|
||||
addText (text, buffer, i + 2, 1, "DEL: File type " + getType (buffer[i + 2]));
|
||||
if (buffer[i + 3] == 0)
|
||||
addText (text, buffer, i + 3, 4, "");
|
||||
|
Loading…
Reference in New Issue
Block a user