This commit is contained in:
Denis Molony 2019-08-06 14:54:04 +10:00
parent 6af546ce46
commit d4ae96aef1
7 changed files with 48 additions and 51 deletions

View File

@ -143,8 +143,9 @@ class CatalogEntry extends AbstractCatalogEntry
if (dataSectors.size () == 0)
message += "No data ";
String catName = catalogName.length () >= 8 ? catalogName.substring (7) : catalogName;
String text = String.format ("%1s %1s %03d %-30.30s %-5s %-13s %3d %3d %s",
lockedFlag, getFileType (), actualSize, name, addressText, lengthText,
lockedFlag, getFileType (), actualSize, catName, addressText, lengthText,
tsSectors.size (), (dataSectors.size () - textFileGaps), message.trim ());
if (actualSize == 0)
text = text.substring (0, 50);

View File

@ -106,12 +106,8 @@ public class DosDisk extends AbstractFormattedDisk
if (!disk.isValidAddress (track, sector))
break;
// int thisBlock = da.getBlock ();
da = disk.getDiskAddress (track, sector);
// if (CHECK_SELF_POINTER && da.getBlock () == thisBlock)
// break;
} while (da.getBlock () != 0);
// same loop, but now all the catalog sectors are properly flagged
@ -134,7 +130,6 @@ public class DosDisk extends AbstractFormattedDisk
int track = entry[0] & 0xFF;
boolean deletedFlag = (entry[0] & 0x80) != 0;
// if (entry[0] == (byte) 0xFF) // deleted file
if (deletedFlag) // deleted file
{
DeletedCatalogEntry deletedCatalogEntry =
@ -181,7 +176,6 @@ public class DosDisk extends AbstractFormattedDisk
if (fe2.getUniqueName ().equals (partner1)
|| fe2.getUniqueName ().equals (partner2))
{
// System.out.printf ("%s %s%n", name, partner1);
((CatalogEntry) fe2).link ((CatalogEntry) fe);
((CatalogEntry) fe).link ((CatalogEntry) fe2);
}
@ -343,20 +337,11 @@ public class DosDisk extends AbstractFormattedDisk
}
catalogAddresses.add (da);
// catalogBlocks++;
// if (catalogBlocks > 1000) // looping
// {
// System.out.println ("Disk appears to be looping in countCatalogBlocks()");
// return 0;
// }
// int thisBlock = da.getBlock ();
da = disk.getDiskAddress (buffer[1], buffer[2]);
} while (da.getBlock () != 0);
// if (catalogBlocks != catalogAddresses.size ())
// System.out.printf ("CB: %d, size: %d%n", catalogBlocks, catalogAddresses.size ());
return catalogAddresses.size ();
}
@ -411,8 +396,8 @@ public class DosDisk extends AbstractFormattedDisk
+ " Length TS Data Comment" + newLine);
text.append (line);
for (AppleFileSource ce : fileEntries)
text.append (((CatalogEntry) ce).getDetails () + newLine);
for (AppleFileSource fileEntry : fileEntries)
text.append (((CatalogEntry) fileEntry).getDetails () + newLine);
text.append (line);
text.append (String.format (

View File

@ -1,6 +1,6 @@
package com.bytezone.diskbrowser.nib;
public abstract class ByteTranslator
public interface ByteTranslator
{
abstract byte encode (byte b);

View File

@ -1,6 +1,6 @@
package com.bytezone.diskbrowser.nib;
public class ByteTranslator5and3 extends ByteTranslator
public class ByteTranslator5and3 implements ByteTranslator
{
// 32 valid bytes that can be stored on a disk (plus 0xAA and 0xD5)
private static byte[] writeTranslateTable5and3 =
@ -42,7 +42,7 @@ public class ByteTranslator5and3 extends ByteTranslator
// ---------------------------------------------------------------------------------//
@Override
byte encode (byte b)
public byte encode (byte b)
{
System.out.println ("encode() not written");
return 0;
@ -53,7 +53,7 @@ public class ByteTranslator5and3 extends ByteTranslator
// ---------------------------------------------------------------------------------//
@Override
byte decode (byte b) throws DiskNibbleException
public byte decode (byte b) throws DiskNibbleException
{
int val = (b & 0xFF) - 0xAB; // 0 - 84
if (val < 0 || val > 84)

View File

@ -1,6 +1,6 @@
package com.bytezone.diskbrowser.nib;
public class ByteTranslator6and2 extends ByteTranslator
public class ByteTranslator6and2 implements ByteTranslator
{
// 64 valid bytes that can be stored on a disk (plus 0xAA and 0xD5)
private static byte[] writeTranslateTable6and2 =
@ -33,7 +33,7 @@ public class ByteTranslator6and2 extends ByteTranslator
// ---------------------------------------------------------------------------------//
@Override
byte encode (byte b)
public byte encode (byte b)
{
return writeTranslateTable6and2[(b & 0xFC)];
}
@ -43,7 +43,7 @@ public class ByteTranslator6and2 extends ByteTranslator
// ---------------------------------------------------------------------------------//
@Override
byte decode (byte b) throws DiskNibbleException
public byte decode (byte b) throws DiskNibbleException
{
int val = (b & 0xFF) - 0x96; // 0 - 105
if (val < 0 || val > 105)

View File

@ -20,7 +20,7 @@ public abstract class DiskReader
}
// ---------------------------------------------------------------------------------//
static DiskReader getDiskReader (int sectors)
static DiskReader getInstance (int sectors)
// ---------------------------------------------------------------------------------//
{
if (sectors == 13)
@ -36,6 +36,7 @@ public abstract class DiskReader
reader16 = new DiskReader16Sector ();
return reader16;
}
return null;
}

View File

@ -39,7 +39,7 @@ public class WozFile
private int diskSectors;
private byte[] addressPrologue;
private final byte[] diskBuffer;
private byte[] diskBuffer;
private final boolean debug1 = false;
private final boolean debug2 = false;
@ -98,16 +98,13 @@ public class WozFile
ptr += size + 8;
}
DiskReader diskReader = DiskReader.getDiskReader (diskSectors);
diskBuffer = new byte[35 * diskSectors * 256];
int ndx = diskSectors == 13 ? 0 : 1;
if (info.diskType == 1) // 5.25"
{
diskBuffer = new byte[35 * diskSectors * SECTOR_SIZE];
if (info.diskType == 1)
for (Track track : tracks)
for (Sector sector : track)
if (sector.dataOffset > 0)
sector.pack (diskReader, diskBuffer, SECTOR_SIZE
* (sector.trackNo * diskSectors + interleave[ndx][sector.sectorNo]));
track.pack (diskBuffer);
}
}
// ---------------------------------------------------------------------------------//
@ -340,19 +337,19 @@ public class WozFile
class Track implements Iterable<Sector>
// -----------------------------------------------------------------------------------//
{
int trackNo;
int startingBlock;
int blockCount; // WOZ2 - not needed
int bitCount;
int bytesUsed; // WOZ1 - not needed
private int trackNo;
private int startingBlock;
private int blockCount; // WOZ2 - not needed
private int bitCount;
private int bytesUsed; // WOZ1 - not needed
byte[] rawBuffer;
byte[] newBuffer;
private byte[] rawBuffer;
private byte[] newBuffer;
int bitIndex;
int byteIndex;
int trackIndex;
int revolutions;
private int bitIndex;
private int byteIndex;
private int trackIndex;
private int revolutions;
List<Sector> sectors = new ArrayList<> ();
@ -408,8 +405,7 @@ public class WozFile
break;
Sector sector = new Sector (this, offset);
if (debug1 && sectors.size () > 0)
checkDuplicates (sector);
checkDuplicates (sector);
sectors.add (sector);
}
}
@ -504,6 +500,19 @@ public class WozFile
return -1;
}
// ---------------------------------------------------------------------------------//
void pack (byte[] diskBuffer) throws DiskNibbleException
// ---------------------------------------------------------------------------------//
{
int ndx = diskSectors == 13 ? 0 : 1;
DiskReader diskReader = DiskReader.getInstance (diskSectors);
for (Sector sector : sectors)
if (sector.dataOffset > 0)
sector.pack (diskReader, diskBuffer, SECTOR_SIZE
* (sector.trackNo * diskSectors + interleave[ndx][sector.sectorNo]));
}
// ---------------------------------------------------------------------------------//
@Override
public String toString ()
@ -538,9 +547,10 @@ public class WozFile
public class Sector
// ---------------------------------------------------------------------------------//
{
Track track;
public final int trackNo, sectorNo, volume, checksum;
int addressOffset, dataOffset;
private final Track track;
private final int trackNo, sectorNo, volume, checksum;
private final int addressOffset;
private int dataOffset;
// ---------------------------------------------------------------------------------//
Sector (Track track, int addressOffset)