mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-12-26 05:32:16 +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.applefile.AppleFileSource;
|
||||||
import com.bytezone.diskbrowser.disk.*;
|
import com.bytezone.diskbrowser.disk.*;
|
||||||
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
|
|
||||||
public class CPMDisk extends AbstractFormattedDisk
|
public class CPMDisk extends AbstractFormattedDisk
|
||||||
{
|
{
|
||||||
@ -112,15 +113,28 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
return null;
|
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
|
@Override
|
||||||
public AppleFileSource getCatalog ()
|
public AppleFileSource getCatalog ()
|
||||||
{
|
{
|
||||||
String newLine = String.format ("%n");
|
String newLine = String.format ("%n");
|
||||||
String line = "---- --------- ---- ---- ---- ----------------------------"
|
String line =
|
||||||
|
"---- --------- --- -- -- -- -- ----------------------------"
|
||||||
+ "-------------------" + newLine;
|
+ "-------------------" + 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 Blocks" + newLine);
|
text.append ("User Name Typ Ex S2 S1 RC Blocks" + newLine);
|
||||||
text.append (line);
|
text.append (line);
|
||||||
|
|
||||||
for (AppleFileSource entry : fileEntries)
|
for (AppleFileSource entry : fileEntries)
|
||||||
|
@ -98,15 +98,11 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
int blocks = ((rc & 0xF0) >> 3) + (((rc & 0x0F) + 7) / 8);
|
int blocks = ((rc & 0xF0) >> 3) + (((rc & 0x0F) + 7) / 8);
|
||||||
String bytes = HexFormatter.getHexString (blockList, 0, 16);
|
String bytes = HexFormatter.getHexString (blockList, 0, 16);
|
||||||
bytes = bytes.replaceAll ("00", " ");
|
bytes = bytes.replaceAll ("00", " ");
|
||||||
String text = String.format ("%3d %-8s %-3s %3d %3d %s", userNumber, name,
|
String text = String.format ("%3d %-8s %-3s %02X %02X %02X %02X %s",
|
||||||
type, entries.size () + 1, blocks, bytes);
|
userNumber, name, type, ex, s2, s1, rc, bytes);
|
||||||
for (DirectoryEntry entry : entries)
|
for (DirectoryEntry entry : entries)
|
||||||
{
|
text = text + "\n" + entry.line ();
|
||||||
bytes = HexFormatter.getHexString (entry.blockList, 0, 16);
|
|
||||||
bytes = bytes.replaceAll ("00", " ").trim ();
|
|
||||||
if (!bytes.isEmpty ())
|
|
||||||
text = text + String.format ("%n%-36.36s%s", "", bytes);
|
|
||||||
}
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,6 @@ public abstract class AbstractSector implements DataSource
|
|||||||
@Override
|
@Override
|
||||||
public JComponent getComponent ()
|
public JComponent getComponent ()
|
||||||
{
|
{
|
||||||
System.out.println ("In AbstractSector.getComponent()");
|
|
||||||
JPanel panel = new JPanel ();
|
JPanel panel = new JPanel ();
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,9 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|||||||
|
|
||||||
class DosCatalogSector extends AbstractSector
|
class DosCatalogSector extends AbstractSector
|
||||||
{
|
{
|
||||||
private static final String[] fileTypes = { "Text file", "Integer Basic program",
|
private static final String[] fileTypes =
|
||||||
"Applesoft Basic program", "Binary file",
|
{ "Text file", "Integer Basic program", "Applesoft Basic program", "Binary file",
|
||||||
"SS file", "Relocatable file", "AA file",
|
"SS file", "Relocatable file", "AA file", "BB file" };
|
||||||
"BB file" };
|
|
||||||
private static int CATALOG_ENTRY_SIZE = 35;
|
private static int CATALOG_ENTRY_SIZE = 35;
|
||||||
|
|
||||||
public DosCatalogSector (Disk disk, byte[] buffer)
|
public DosCatalogSector (Disk disk, byte[] buffer)
|
||||||
@ -33,10 +32,7 @@ class DosCatalogSector extends AbstractSector
|
|||||||
{
|
{
|
||||||
if (buffer[i] == (byte) 0xFF)
|
if (buffer[i] == (byte) 0xFF)
|
||||||
{
|
{
|
||||||
addText (text,
|
addText (text, buffer, i + 0, 2,
|
||||||
buffer,
|
|
||||||
i + 0,
|
|
||||||
2,
|
|
||||||
"DEL: file @ " + HexFormatter.format2 (buffer[i + 32]) + " "
|
"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]));
|
addText (text, buffer, i + 2, 1, "DEL: File type " + getType (buffer[i + 2]));
|
||||||
|
Loading…
Reference in New Issue
Block a user