don't assign sector type to an empty sector
This commit is contained in:
parent
fa07a88b1e
commit
918af9a110
|
@ -154,6 +154,8 @@ public class AppleworksWPFile extends AbstractFile
|
|||
|
||||
public Header ()
|
||||
{
|
||||
// see Asimov disks/images 2/pd_collections/apple_linc/
|
||||
// 1988-02 side A (no boot).dsk
|
||||
assert buffer[4] == 0x4F;
|
||||
|
||||
int ptr = 5;
|
||||
|
|
|
@ -292,10 +292,10 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||
@Override
|
||||
public void setSectorType (int block, SectorType type)
|
||||
{
|
||||
if (block < sectorTypes.length)
|
||||
sectorTypes[block] = type;
|
||||
else
|
||||
if (block >= sectorTypes.length)
|
||||
System.out.println ("Invalid block number: " + block);
|
||||
else if (sectorTypes[block] != emptySector)
|
||||
sectorTypes[block] = type;
|
||||
}
|
||||
|
||||
// Override this so that the correct sector type can be displayed
|
||||
|
|
|
@ -73,7 +73,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
for (int i = 3; i < max; i++)
|
||||
{
|
||||
int c = buffer[i] & 0xFF;
|
||||
if (c == 136 && !base.isEmpty ()) // allow backspaces
|
||||
if (c == 136 && !base.isEmpty ()) // allow backspaces
|
||||
{
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
|
@ -103,13 +103,13 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
return "A";
|
||||
case Binary:
|
||||
return "B";
|
||||
case SS: // what is this?
|
||||
case SS: // what is this?
|
||||
return "S";
|
||||
case Relocatable:
|
||||
return "R";
|
||||
case AA: // what is this?
|
||||
case AA: // what is this?
|
||||
return "A";
|
||||
case BB: // what is this?
|
||||
case BB: // what is this?
|
||||
return "B";
|
||||
default:
|
||||
System.out.println ("Unknown file type : " + fileType);
|
||||
|
|
|
@ -16,6 +16,7 @@ public class DosDisk extends AbstractFormattedDisk
|
|||
{
|
||||
private static final int ENTRY_SIZE = 35;
|
||||
private static final int CATALOG_TRACK = 17;
|
||||
private static final int VTOC_SECTOR = 0;
|
||||
|
||||
private final DosVTOCSector dosVTOCSector;
|
||||
private final Color green = new Color (0, 200, 0);
|
||||
|
@ -51,7 +52,7 @@ public class DosDisk extends AbstractFormattedDisk
|
|||
byte[] sectorBuffer = disk.readSector (da); // Boot sector
|
||||
bootSector = new BootSector (disk, sectorBuffer, "DOS", da);
|
||||
|
||||
da = disk.getDiskAddress (CATALOG_TRACK, 0);
|
||||
da = disk.getDiskAddress (CATALOG_TRACK, VTOC_SECTOR);
|
||||
sectorBuffer = disk.readSector (da); // VTOC
|
||||
dosVTOCSector = new DosVTOCSector (this, disk, sectorBuffer, da);
|
||||
|
||||
|
|
|
@ -135,6 +135,11 @@ class DiskLayoutImage extends JPanel implements Scrollable, RedoListener
|
|||
boolean selected)
|
||||
{
|
||||
SectorType type = disk.getSectorType (blockNo);
|
||||
if (type == null)
|
||||
{
|
||||
System.out.println ("Sector type is null " + blockNo);
|
||||
return;
|
||||
}
|
||||
int offset = (bw - 4) / 2 + 1;
|
||||
|
||||
Rectangle rect = new Rectangle (x, y, bw, bh);
|
||||
|
|
|
@ -83,7 +83,8 @@ public class ProdosDisk extends AbstractFormattedDisk
|
|||
do
|
||||
{
|
||||
byte[] sectorBuffer = disk.readSector (block);
|
||||
sectorTypes[block] = currentSectorType;
|
||||
if (!disk.isSectorEmpty (block))
|
||||
sectorTypes[block] = currentSectorType;
|
||||
|
||||
int max = disk.getBlockSize () - ProdosConstants.ENTRY_SIZE;
|
||||
for (int ptr = 4; ptr < max; ptr += ProdosConstants.ENTRY_SIZE)
|
||||
|
@ -104,7 +105,8 @@ public class ProdosDisk extends AbstractFormattedDisk
|
|||
assert localHeader.entryLength == ProdosConstants.ENTRY_SIZE;
|
||||
headerEntries.add (localHeader);
|
||||
currentSectorType = catalogSector;
|
||||
sectorTypes[block] = currentSectorType;
|
||||
if (!disk.isSectorEmpty (block))
|
||||
sectorTypes[block] = currentSectorType;
|
||||
for (int i = 0; i < vdh.totalBitMapBlocks; i++)
|
||||
sectorTypes[vdh.bitMapBlock + i] = volumeMapSector;
|
||||
parentNode.setUserObject (vdh); // populate the empty volume node
|
||||
|
@ -114,7 +116,8 @@ public class ProdosDisk extends AbstractFormattedDisk
|
|||
localHeader = new SubDirectoryHeader (this, entry, parent);
|
||||
headerEntries.add (localHeader);
|
||||
currentSectorType = subcatalogSector;
|
||||
sectorTypes[block] = currentSectorType;
|
||||
if (!disk.isSectorEmpty (block))
|
||||
sectorTypes[block] = currentSectorType;
|
||||
break;
|
||||
|
||||
case ProdosConstants.TYPE_SUBDIRECTORY:
|
||||
|
@ -158,7 +161,6 @@ public class ProdosDisk extends AbstractFormattedDisk
|
|||
if (fe2.getUniqueName ().equals (partner1)
|
||||
|| fe2.getUniqueName ().equals (partner2))
|
||||
{
|
||||
// System.out.printf ("%s %s%n", name, partner1);
|
||||
((FileEntry) fe2).link ((FileEntry) fe);
|
||||
((FileEntry) fe).link ((FileEntry) fe2);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class HexFormatter
|
|||
public static String format (byte[] buffer, int offset, int length, boolean header,
|
||||
int startingAddress)
|
||||
{
|
||||
StringBuffer line = new StringBuffer ();
|
||||
StringBuilder line = new StringBuilder ();
|
||||
int[] freq = new int[256];
|
||||
boolean startedOnBoundary = offset % 0x100 == 0;
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class HexFormatter
|
|||
|
||||
public static String getString (byte[] buffer, int offset, int length)
|
||||
{
|
||||
StringBuffer text = new StringBuffer ();
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
for (int i = offset; i < offset + length; i++)
|
||||
{
|
||||
|
@ -167,16 +167,15 @@ public class HexFormatter
|
|||
|
||||
public static String getString2 (byte[] buffer, int offset, int length)
|
||||
{
|
||||
StringBuffer text = new StringBuffer ();
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
for (int i = offset; i < offset + length; i++)
|
||||
{
|
||||
int c = buffer[i] & 0xFF;
|
||||
if (c == 136 && text.length () > 0)
|
||||
if (c == 136)
|
||||
{
|
||||
System.out.println (text.toString ());
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
System.out.println ("deleted");
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
continue;
|
||||
}
|
||||
if (c > 127)
|
||||
|
|
Loading…
Reference in New Issue