renamed sectors to blocks

This commit is contained in:
Denis Molony 2020-04-11 09:47:52 +10:00
parent ed137b5731
commit a8b4577e51
31 changed files with 210 additions and 200 deletions

View File

@ -55,7 +55,7 @@ public class CPMDisk extends AbstractFormattedDisk
// search for the version string // search for the version string
for (int i = 8; i >= 4; i -= 2) for (int i = 8; i >= 4; i -= 2)
{ {
byte[] buffer = disk.readSector (0, i); byte[] buffer = disk.readBlock (0, i);
String text = new String (buffer, 16, 24); String text = new String (buffer, 16, 24);
if ("DIR ERA TYPESAVEREN USER".equals (text)) if ("DIR ERA TYPESAVEREN USER".equals (text))
{ {
@ -72,8 +72,8 @@ public class CPMDisk extends AbstractFormattedDisk
{ {
DiskAddress da = disk.getDiskAddress (3, sector); DiskAddress da = disk.getDiskAddress (3, sector);
sectorTypes[da.getBlock ()] = catalogSector; sectorTypes[da.getBlockNo ()] = catalogSector;
byte[] buffer = disk.readSector (da); byte[] buffer = disk.readBlock (da);
int b1 = buffer[0] & 0xFF; int b1 = buffer[0] & 0xFF;
int b2 = buffer[1] & 0xFF; int b2 = buffer[1] & 0xFF;
if (b1 == 0xE5) if (b1 == 0xE5)
@ -95,8 +95,8 @@ public class CPMDisk extends AbstractFormattedDisk
DirectoryEntry entry = new DirectoryEntry (this, buffer, i); DirectoryEntry entry = new DirectoryEntry (this, buffer, i);
SectorType sectorType = getSectorType (entry.getType ()); SectorType sectorType = getSectorType (entry.getType ());
for (DiskAddress block : entry.getSectors ()) for (DiskAddress block : entry.getSectors ())
if (!disk.isSectorEmpty (block)) if (!disk.isBlockEmpty (block))
sectorTypes[block.getBlock ()] = sectorType; sectorTypes[block.getBlockNo ()] = sectorType;
DirectoryEntry parent = findParent (entry); DirectoryEntry parent = findParent (entry);
if (parent == null) if (parent == null)
@ -166,8 +166,8 @@ public class CPMDisk extends AbstractFormattedDisk
public DataSource getFormattedSector (DiskAddress da) public DataSource getFormattedSector (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
SectorType type = sectorTypes[da.getBlock ()]; SectorType type = sectorTypes[da.getBlockNo ()];
byte[] buffer = disk.readSector (da); byte[] buffer = disk.readBlock (da);
if (type == catalogSector) if (type == catalogSector)
return new CPMCatalogSector (disk, buffer, da); return new CPMCatalogSector (disk, buffer, da);
@ -209,7 +209,7 @@ public class CPMDisk extends AbstractFormattedDisk
for (int i = 8; i >= 4; i -= 2) for (int i = 8; i >= 4; i -= 2)
{ {
byte[] buffer = disk.readSector (0, i); byte[] buffer = disk.readBlock (0, i);
String text = new String (buffer, 16, 24); String text = new String (buffer, 16, 24);
if ("DIR ERA TYPESAVEREN USER".equals (text)) if ("DIR ERA TYPESAVEREN USER".equals (text))
{ {
@ -221,7 +221,7 @@ public class CPMDisk extends AbstractFormattedDisk
for (int sector = 0; sector < 8; sector++) for (int sector = 0; sector < 8; sector++)
{ {
byte[] buffer = disk.readSector (3, sector); byte[] buffer = disk.readBlock (3, sector);
// check if entire sector is empty (everything == 0xE5) // check if entire sector is empty (everything == 0xE5)
if (bufferContainsAll (buffer, (byte) 0xE5)) if (bufferContainsAll (buffer, (byte) 0xE5))

View File

@ -188,7 +188,7 @@ class DirectoryEntry implements AppleFileSource
if (appleFile != null) if (appleFile != null)
return appleFile; return appleFile;
byte[] buffer = disk.readSectors (blocks); byte[] buffer = disk.readBlocks (blocks);
if (buffer.length == 0) if (buffer.length == 0)
{ {

View File

@ -113,7 +113,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
sectorTypes = new SectorType[disk.getTotalBlocks ()]; sectorTypes = new SectorType[disk.getTotalBlocks ()];
for (DiskAddress da : disk) for (DiskAddress da : disk)
sectorTypes[da.getBlock ()] = disk.isSectorEmpty (da) ? emptySector : usedSector; sectorTypes[da.getBlockNo ()] = disk.isBlockEmpty (da) ? emptySector : usedSector;
setGridLayout (); setGridLayout ();
} }
@ -147,8 +147,8 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
break; break;
case 1600: case 1600:
if (disk.getSectorsPerTrack () == 32) if (disk.getBlocksPerTrack () == 32)
gridLayout = new Dimension (disk.getSectorsPerTrack (), disk.getTotalTracks ()); gridLayout = new Dimension (disk.getBlocksPerTrack (), disk.getTotalTracks ());
else else
gridLayout = new Dimension (16, 100); gridLayout = new Dimension (16, 100);
break; break;
@ -366,7 +366,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
public SectorType getSectorType (DiskAddress da) public SectorType getSectorType (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return sectorTypes[da.getBlock ()]; return sectorTypes[da.getBlockNo ()];
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -394,12 +394,14 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
public DataSource getFormattedSector (DiskAddress da) public DataSource getFormattedSector (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (da.getBlock () == 0 && bootSector != null) if (da.getBlockNo () == 0 && bootSector != null)
return bootSector; return bootSector;
SectorType sectorType = sectorTypes[da.getBlock ()]; SectorType sectorType = sectorTypes[da.getBlockNo ()];
byte[] buffer = disk.readSector (da); byte[] buffer = disk.readBlock (da);
String address = String.format ("%02X %02X", da.getTrack (), da.getSector ());
// String address = String.format ("%02X %02X", da.getTrackNo (), da.getSectorNo ());
String address = String.format ("%02X", da.getBlockNo ());
if (sectorType == emptySector) if (sectorType == emptySector)
return new DefaultSector ("Empty sector at " + address, disk, buffer, da); return new DefaultSector ("Empty sector at " + address, disk, buffer, da);
@ -409,6 +411,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
String name = getSectorFilename (da); String name = getSectorFilename (da);
if (!name.isEmpty ()) if (!name.isEmpty ())
name = " : " + name; name = " : " + name;
return new DefaultSector ("Data sector at " + address + name, disk, buffer, da); return new DefaultSector ("Data sector at " + address + name, disk, buffer, da);
} }
@ -449,7 +452,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
public boolean isSectorFree (DiskAddress da) public boolean isSectorFree (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return freeBlocks.get (da.getBlock ()); return freeBlocks.get (da.getBlockNo ());
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -482,7 +485,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
public boolean stillAvailable (DiskAddress da) public boolean stillAvailable (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return stillAvailable (da.getBlock ()); return stillAvailable (da.getBlockNo ());
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//

View File

@ -339,12 +339,12 @@ public class AppleDisk implements Disk
for (DiskAddress da : this) // uses blockList.iterator for (DiskAddress da : this) // uses blockList.iterator
{ {
byte[] buffer = readSector (da); byte[] buffer = readBlock (da);
hasData[da.getBlock ()] = false; hasData[da.getBlockNo ()] = false;
for (int i = 0; i < sectorSize; i++) for (int i = 0; i < sectorSize; i++)
if (buffer[i] != emptyByte) if (buffer[i] != emptyByte)
{ {
hasData[da.getBlock ()] = true; hasData[da.getBlockNo ()] = true;
break; break;
} }
} }
@ -362,13 +362,13 @@ public class AppleDisk implements Disk
if (sectorSize == SECTOR_SIZE) // 256 byte sectors if (sectorSize == SECTOR_SIZE) // 256 byte sectors
{ {
int diskOffset = getBufferOffset (da); int diskOffset = getBufferOffset (da);
hasData[da.getBlock ()] = check (diskOffset); hasData[da.getBlockNo ()] = check (diskOffset);
} }
else // 512 byte blocks else // 512 byte blocks
{ {
int diskOffset1 = getBufferOffset (da, 0); int diskOffset1 = getBufferOffset (da, 0);
int diskOffset2 = getBufferOffset (da, 1); int diskOffset2 = getBufferOffset (da, 1);
hasData[da.getBlock ()] = check (diskOffset1) || check (diskOffset2); hasData[da.getBlockNo ()] = check (diskOffset1) || check (diskOffset2);
} }
} }
} }
@ -389,7 +389,7 @@ public class AppleDisk implements Disk
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public int getSectorsPerTrack () public int getBlocksPerTrack ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return trackSize / sectorSize; return trackSize / sectorSize;
@ -429,15 +429,15 @@ public class AppleDisk implements Disk
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public boolean isSectorEmpty (DiskAddress da) public boolean isBlockEmpty (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return !hasData[da.getBlock ()]; return !hasData[da.getBlockNo ()];
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public boolean isSectorEmpty (int block) public boolean isBlockEmpty (int block)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return !hasData[block]; return !hasData[block];
@ -445,10 +445,10 @@ public class AppleDisk implements Disk
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public boolean isSectorEmpty (int track, int sector) public boolean isBlockEmpty (int track, int sector)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return !hasData[getDiskAddress (track, sector).getBlock ()]; return !hasData[getDiskAddress (track, sector).getBlockNo ()];
} }
// @Override // @Override
@ -479,7 +479,7 @@ public class AppleDisk implements Disk
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public byte[] readSector (DiskAddress da) public byte[] readBlock (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] buffer = new byte[sectorSize]; byte[] buffer = new byte[sectorSize];
@ -492,7 +492,7 @@ public class AppleDisk implements Disk
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public byte[] readSectors (List<DiskAddress> daList) public byte[] readBlocks (List<DiskAddress> daList)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] buffer = new byte[daList.size () * sectorSize]; byte[] buffer = new byte[daList.size () * sectorSize];
@ -500,7 +500,7 @@ public class AppleDisk implements Disk
for (DiskAddress da : daList) for (DiskAddress da : daList)
{ {
// sparse text/PNT/PIC files may have gaps // sparse text/PNT/PIC files may have gaps
if (da != null && (da.getBlock () > 0 || ((AppleDiskAddress) da).zeroFlag ())) if (da != null && (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ()))
readBuffer (da, buffer, ptr); readBuffer (da, buffer, ptr);
ptr += sectorSize; ptr += sectorSize;
} }
@ -509,23 +509,23 @@ public class AppleDisk implements Disk
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public byte[] readSector (int track, int sector) public byte[] readBlock (int track, int sector)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return readSector (getDiskAddress (track, sector)); return readBlock (getDiskAddress (track, sector));
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public byte[] readSector (int block) public byte[] readBlock (int block)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return readSector (getDiskAddress (block)); return readBlock (getDiskAddress (block));
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public void writeSector (DiskAddress da, byte[] buffer) public void writeBlock (DiskAddress da, byte[] buffer)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
writeBuffer (da, buffer); writeBuffer (da, buffer);
@ -644,7 +644,7 @@ public class AppleDisk implements Disk
public boolean isValidAddress (DiskAddress da) public boolean isValidAddress (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return da != null && isValidAddress (da.getTrack (), da.getSector ()); return da != null && isValidAddress (da.getTrackNo (), da.getSectorNo ());
} }
/* /*
@ -708,8 +708,8 @@ public class AppleDisk implements Disk
{ {
assert sectorSize == SECTOR_SIZE; assert sectorSize == SECTOR_SIZE;
return da.getTrack () * trackSize return da.getTrackNo () * trackSize
+ interleaveSector[interleave][da.getSector ()] * SECTOR_SIZE; + interleaveSector[interleave][da.getSectorNo ()] * SECTOR_SIZE;
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -720,8 +720,8 @@ public class AppleDisk implements Disk
assert seq == 0 || seq == 1; assert seq == 0 || seq == 1;
return da.getTrack () * trackSize return da.getTrackNo () * trackSize
+ interleaveSector[interleave][da.getSector () * 2 + seq] * SECTOR_SIZE; + interleaveSector[interleave][da.getSectorNo () * 2 + seq] * SECTOR_SIZE;
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -807,7 +807,7 @@ public class AppleDisk implements Disk
public long getBootChecksum () public long getBootChecksum ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] buffer = readSector (0, 0); byte[] buffer = readBlock (0, 0);
Checksum checksum = new CRC32 (); Checksum checksum = new CRC32 ();
checksum.update (buffer, 0, buffer.length); checksum.update (buffer, 0, buffer.length);
return checksum.getValue (); return checksum.getValue ();

View File

@ -17,7 +17,7 @@ public class AppleDiskAddress implements DiskAddress
{ {
this.owner = owner; this.owner = owner;
this.block = block; this.block = block;
int sectorsPerTrack = owner.getSectorsPerTrack (); int sectorsPerTrack = owner.getBlocksPerTrack ();
if (sectorsPerTrack == 0) if (sectorsPerTrack == 0)
{ {
track = 0; track = 0;
@ -38,7 +38,7 @@ public class AppleDiskAddress implements DiskAddress
zeroFlag = (track & 0x40) != 0; zeroFlag = (track & 0x40) != 0;
this.track = track & 0x3F; this.track = track & 0x3F;
this.sector = sector & 0x1F; this.sector = sector & 0x1F;
this.block = this.track * owner.getSectorsPerTrack () + this.sector; this.block = this.track * owner.getBlocksPerTrack () + this.sector;
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -53,7 +53,7 @@ public class AppleDiskAddress implements DiskAddress
public int compareTo (DiskAddress that) public int compareTo (DiskAddress that)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return this.block - that.getBlock (); return this.block - that.getBlockNo ();
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -63,12 +63,12 @@ public class AppleDiskAddress implements DiskAddress
{ {
if (that == null) if (that == null)
return false; return false;
return this.block == that.getBlock (); return this.block == that.getBlockNo ();
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public int getBlock () public int getBlockNo ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return block; return block;
@ -76,7 +76,7 @@ public class AppleDiskAddress implements DiskAddress
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public int getSector () public int getSectorNo ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return sector; return sector;
@ -84,7 +84,7 @@ public class AppleDiskAddress implements DiskAddress
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public int getTrack () public int getTrackNo ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return track; return track;

View File

@ -50,7 +50,7 @@ public class DefaultAppleFileSource implements AppleFileSource
this (title, file, owner); this (title, file, owner);
this.blocks = blocks; this.blocks = blocks;
if (file instanceof DefaultDataSource) if (file instanceof DefaultDataSource)
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks); ((DefaultDataSource) file).buffer = owner.getDisk ().readBlocks (blocks);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -59,7 +59,7 @@ public class DefaultAppleFileSource implements AppleFileSource
{ {
this.blocks = blocks; this.blocks = blocks;
if (file instanceof DefaultDataSource) if (file instanceof DefaultDataSource)
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks); ((DefaultDataSource) file).buffer = owner.getDisk ().readBlocks (blocks);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//

View File

@ -22,7 +22,7 @@ public interface Disk extends Iterable<DiskAddress>
public int getTrackSize (); // bytes per track - 4096 public int getTrackSize (); // bytes per track - 4096
public int getSectorsPerTrack (); // 8 or 16 public int getBlocksPerTrack (); // 8 or 16
public void setInterleave (int interleave); public void setInterleave (int interleave);
@ -34,21 +34,21 @@ public interface Disk extends Iterable<DiskAddress>
public DiskAddress getDiskAddress (int track, int sector); public DiskAddress getDiskAddress (int track, int sector);
public byte[] readSector (int block); public byte[] readBlock (int block);
public byte[] readSector (int track, int sector); public byte[] readBlock (int track, int sector);
public byte[] readSector (DiskAddress da); public byte[] readBlock (DiskAddress da);
public byte[] readSectors (List<DiskAddress> daList); public byte[] readBlocks (List<DiskAddress> daList);
public void writeSector (DiskAddress da, byte[] buffer); public void writeBlock (DiskAddress da, byte[] buffer);
public boolean isSectorEmpty (int block); public boolean isBlockEmpty (int block);
public boolean isSectorEmpty (int track, int sector); public boolean isBlockEmpty (int track, int sector);
public boolean isSectorEmpty (DiskAddress da); public boolean isBlockEmpty (DiskAddress da);
public boolean isValidAddress (int block); public boolean isValidAddress (int block);

View File

@ -4,21 +4,21 @@ package com.bytezone.diskbrowser.disk;
public interface DiskAddress extends Comparable<DiskAddress> public interface DiskAddress extends Comparable<DiskAddress>
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
public int getBlock (); public int getBlockNo ();
public int getTrack (); public int getTrackNo ();
public int getSector (); public int getSectorNo ();
public Disk getDisk (); public Disk getDisk ();
public boolean matches (DiskAddress other); public boolean matches (DiskAddress other);
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public default byte[] readSector () public default byte[] readBlock ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return getDisk ().readSector (this); return getDisk ().readBlock (this);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//

View File

@ -28,7 +28,7 @@ public class SectorList extends AbstractFile
{ {
if (!disk.isValidAddress (da)) if (!disk.isValidAddress (da))
break; break;
byte[] tempBuffer = disk.readSector (da); byte[] tempBuffer = disk.readBlock (da);
System.arraycopy (tempBuffer, 0, buffer, ptr, disk.getBlockSize ()); System.arraycopy (tempBuffer, 0, buffer, ptr, disk.getBlockSize ());
ptr += disk.getBlockSize (); ptr += disk.getBlockSize ();
} }
@ -50,7 +50,7 @@ public class SectorList extends AbstractFile
if (owner == null) if (owner == null)
owner = ""; owner = "";
text.append ( text.append (
String.format (" %04X %-18s %s%n", da.getBlock (), sectorType.name, owner)); String.format (" %04X %-18s %s%n", da.getBlockNo (), sectorType.name, owner));
} }
return text.toString (); return text.toString ();

View File

@ -45,7 +45,7 @@ public class SectorListConverter
for (DiskAddress da : sectors) for (DiskAddress da : sectors)
{ {
if (da.getBlock () == firstBlock + 1 + runLength) if (da.getBlockNo () == firstBlock + 1 + runLength)
{ {
++runLength; ++runLength;
continue; continue;
@ -54,7 +54,7 @@ public class SectorListConverter
if (firstBlock >= 0) if (firstBlock >= 0)
addToText (text, firstBlock, runLength); addToText (text, firstBlock, runLength);
firstBlock = da.getBlock (); firstBlock = da.getBlockNo ();
runLength = 0; runLength = 0;
} }
addToText (text, firstBlock, runLength); addToText (text, firstBlock, runLength);

View File

@ -57,7 +57,10 @@ abstract class AbstractCatalogEntry implements AppleFileSource
this.disk = dosDisk.getDisk (); this.disk = dosDisk.getDisk ();
this.catalogSectorDA = catalogSector; this.catalogSectorDA = catalogSector;
name = getName ("", entryBuffer);
reportedSize = HexFormatter.unsignedShort (entryBuffer, 33); reportedSize = HexFormatter.unsignedShort (entryBuffer, 33);
if (reportedSize == 0)
System.out.printf ("%s size 0%n", name);
int type = entryBuffer[2] & 0x7F; int type = entryBuffer[2] & 0x7F;
locked = (entryBuffer[2] & 0x80) != 0; locked = (entryBuffer[2] & 0x80) != 0;
@ -81,13 +84,12 @@ abstract class AbstractCatalogEntry implements AppleFileSource
else else
System.out.println ("Unknown file type : " + type); System.out.println ("Unknown file type : " + type);
name = getName ("", entryBuffer);
if (dosDisk.getVersion () >= 0x41) if (dosDisk.getVersion () >= 0x41)
lastModified = Utility.getDateTime (entryBuffer, 0x1B); lastModified = Utility.getDateTime (entryBuffer, 0x1B);
// CATALOG command only formats the LO byte - see Beneath Apple DOS pp4-6 // CATALOG command only formats the LO byte - see Beneath Apple DOS pp4-6
String base = String.format ("%s%s %03d ", (locked) ? "*" : " ", getFileType (), String base =
(entryBuffer[33] & 0xFF)); String.format ("%s%s %03d ", (locked) ? "*" : " ", getFileType (), reportedSize);
catalogName = getName (base, entryBuffer).replace ("^", ""); catalogName = getName (base, entryBuffer).replace ("^", "");
} }
@ -96,9 +98,11 @@ abstract class AbstractCatalogEntry implements AppleFileSource
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (base); StringBuilder text = new StringBuilder (base);
int max = buffer[0] == (byte) 0xFF ? 32 : 33; int max = buffer[0] == (byte) 0xFF ? 32 : 33;
if (dosDisk.getVersion () >= 0x41) if (dosDisk.getVersion () >= 0x41)
max = 27; max = 27;
for (int i = 3; i < max; i++) for (int i = 3; i < max; i++)
{ {
int c = buffer[i] & 0xFF; int c = buffer[i] & 0xFF;
@ -115,8 +119,10 @@ abstract class AbstractCatalogEntry implements AppleFileSource
else else
text.append ((char) c); // standard ascii text.append ((char) c); // standard ascii
} }
while (text.length () > 0 && text.charAt (text.length () - 1) == ' ') while (text.length () > 0 && text.charAt (text.length () - 1) == ' ')
text.deleteCharAt (text.length () - 1); // rtrim() text.deleteCharAt (text.length () - 1); // rtrim()
return text.toString (); return text.toString ();
} }
@ -167,7 +173,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
if (appleFile != null) if (appleFile != null)
return appleFile; return appleFile;
byte[] buffer = disk.readSectors (dataSectors); byte[] buffer = disk.readBlocks (dataSectors);
int reportedLength; int reportedLength;
if (buffer.length == 0) if (buffer.length == 0)
{ {
@ -240,7 +246,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
appleFile = new DoubleHiResImage (name, exactBuffer); appleFile = new DoubleHiResImage (name, exactBuffer);
else if (link != null) else if (link != null)
{ {
byte[] auxBuffer = link.disk.readSectors (link.dataSectors); byte[] auxBuffer = link.disk.readBlocks (link.dataSectors);
byte[] exactAuxBuffer = getExactBuffer (auxBuffer); byte[] exactAuxBuffer = getExactBuffer (auxBuffer);
if (name.endsWith (".AUX")) if (name.endsWith (".AUX"))
appleFile = new DoubleHiResImage (name, exactAuxBuffer, exactBuffer); appleFile = new DoubleHiResImage (name, exactAuxBuffer, exactBuffer);

View File

@ -19,18 +19,19 @@ class CatalogEntry extends AbstractCatalogEntry
{ {
super (dosDisk, catalogSector, entryBuffer); // build lists of ts and data sectors super (dosDisk, catalogSector, entryBuffer); // build lists of ts and data sectors
if (reportedSize > 0 && disk.isValidAddress (entryBuffer[0], entryBuffer[1])) // if (reportedSize > 0 && disk.isValidAddress (entryBuffer[0], entryBuffer[1]))
if (disk.isValidAddress (entryBuffer[0], entryBuffer[1]))
{ {
// Get address of first TS-list sector // Get address of first TS-list sector
DiskAddress da = disk.getDiskAddress (entryBuffer[0], entryBuffer[1]); DiskAddress da = disk.getDiskAddress (entryBuffer[0], entryBuffer[1]);
// Loop through all TS-list sectors // Loop through all TS-list sectors
loop: while (da.getBlock () > 0 || ((AppleDiskAddress) da).zeroFlag ()) loop: while (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ())
{ {
if (dosDisk.stillAvailable (da)) if (dosDisk.stillAvailable (da))
{ {
if (isValidCatalogSector (da)) if (isValidCatalogSector (da))
dosDisk.sectorTypes[da.getBlock ()] = dosDisk.tsListSector; dosDisk.sectorTypes[da.getBlockNo ()] = dosDisk.tsListSector;
else else
{ {
System.out.printf ("Attempt to assign invalid TS sector " + ": %s from %s%n", System.out.printf ("Attempt to assign invalid TS sector " + ": %s from %s%n",
@ -46,7 +47,7 @@ class CatalogEntry extends AbstractCatalogEntry
break; break;
} }
tsSectors.add (da); tsSectors.add (da);
byte[] sectorBuffer = disk.readSector (da); byte[] sectorBuffer = disk.readBlock (da);
int startPtr = 12; int startPtr = 12;
// the tsList *should* start at 0xC0, but some disks start in the unused bytes // the tsList *should* start at 0xC0, but some disks start in the unused bytes
@ -69,7 +70,7 @@ class CatalogEntry extends AbstractCatalogEntry
i, sectorBuffer[i], sectorBuffer[i + 1], name.trim ()); i, sectorBuffer[i], sectorBuffer[i + 1], name.trim ());
break loop; break loop;
} }
if (da.getBlock () == 0 && !((AppleDiskAddress) da).zeroFlag ()) if (da.getBlockNo () == 0 && !((AppleDiskAddress) da).zeroFlag ())
{ {
if (fileType != FileType.Text) if (fileType != FileType.Text)
break; break;
@ -80,7 +81,7 @@ class CatalogEntry extends AbstractCatalogEntry
{ {
dataSectors.add (da); dataSectors.add (da);
if (dosDisk.stillAvailable (da)) if (dosDisk.stillAvailable (da))
dosDisk.sectorTypes[da.getBlock ()] = dosDisk.dataSector; dosDisk.sectorTypes[da.getBlockNo ()] = dosDisk.dataSector;
else else
{ {
System.out System.out
@ -125,7 +126,7 @@ class CatalogEntry extends AbstractCatalogEntry
} }
else if (dataSectors.size () > 0) // get the file length else if (dataSectors.size () > 0) // get the file length
{ {
byte[] buffer = disk.readSector (dataSectors.get (0)); byte[] buffer = disk.readBlock (dataSectors.get (0));
switch (fileType) switch (fileType)
{ {
case IntegerBasic: case IntegerBasic:
@ -144,13 +145,13 @@ class CatalogEntry extends AbstractCatalogEntry
private boolean isValidCatalogSector (DiskAddress da) private boolean isValidCatalogSector (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] buffer = da.readSector (); byte[] buffer = da.readBlock ();
if (!da.getDisk ().isValidAddress (buffer[1], buffer[2])) if (!da.getDisk ().isValidAddress (buffer[1], buffer[2]))
return false; return false;
if (buffer[3] != 0 || buffer[4] != 0) // not supposed to be used if (buffer[3] != 0 || buffer[4] != 0) // not supposed to be used
// Diags2E.dsk stores its own sector address here // Diags2E.dsk stores its own sector address here
if (da.getTrack () != (buffer[3] & 0xFF) && da.getSector () != (buffer[4] & 0xFF)) if (da.getTrackNo () != (buffer[3] & 0xFF) && da.getSectorNo () != (buffer[4] & 0xFF))
return false; return false;
return true; return true;

View File

@ -42,7 +42,7 @@ class DeletedCatalogEntry extends AbstractCatalogEntry
} }
int totalBlocks = 0; int totalBlocks = 0;
if (reportedSize <= 1 || !disk.isValidAddress (da.getTrack (), da.getSector ())) if (reportedSize <= 1 || !disk.isValidAddress (da.getTrackNo (), da.getSectorNo ()))
{ {
if (debug) if (debug)
System.out.println ("invalid catalog entry"); System.out.println ("invalid catalog entry");
@ -51,7 +51,7 @@ class DeletedCatalogEntry extends AbstractCatalogEntry
} }
// Loop through all TS-list sectors // Loop through all TS-list sectors
loop: while (da.getBlock () > 0 || ((AppleDiskAddress) da).zeroFlag ()) loop: while (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ())
{ {
if (!dosDisk.stillAvailable (da)) if (!dosDisk.stillAvailable (da))
{ {
@ -61,16 +61,16 @@ class DeletedCatalogEntry extends AbstractCatalogEntry
tsSectors.add (da); tsSectors.add (da);
totalBlocks++; totalBlocks++;
byte[] sectorBuffer = disk.readSector (da); byte[] sectorBuffer = disk.readBlock (da);
for (int i = 12, max = disk.getBlockSize (); i < max; i += 2) for (int i = 12, max = disk.getBlockSize (); i < max; i += 2)
{ {
da = getValidAddress (sectorBuffer, i); da = getValidAddress (sectorBuffer, i);
if (da == null) if (da == null)
break loop; break loop;
if (da.getBlock () > 0 && debug) if (da.getBlockNo () > 0 && debug)
System.out.println (da); System.out.println (da);
if (da.getBlock () > 0 || ((AppleDiskAddress) da).zeroFlag ()) if (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ())
{ {
if (!dosDisk.stillAvailable (da)) if (!dosDisk.stillAvailable (da))
{ {

View File

@ -71,20 +71,20 @@ public class DosDisk extends AbstractFormattedDisk
sectorTypesList.add (dataSector); sectorTypesList.add (dataSector);
DiskAddress da = disk.getDiskAddress (0, 0); DiskAddress da = disk.getDiskAddress (0, 0);
byte[] sectorBuffer = disk.readSector (da); // Boot sector byte[] sectorBuffer = disk.readBlock (da); // Boot sector
bootSector = new BootSector (disk, sectorBuffer, "DOS", da); bootSector = new BootSector (disk, sectorBuffer, "DOS", da);
da = disk.getDiskAddress (CATALOG_TRACK, VTOC_SECTOR); da = disk.getDiskAddress (CATALOG_TRACK, VTOC_SECTOR);
sectorBuffer = disk.readSector (da); // VTOC sectorBuffer = disk.readBlock (da); // VTOC
dosVTOCSector = new DosVTOCSector (this, disk, sectorBuffer, da); dosVTOCSector = new DosVTOCSector (this, disk, sectorBuffer, da);
sectorTypes[da.getBlock ()] = vtocSector; sectorTypes[da.getBlockNo ()] = vtocSector;
DiskAddress catalogStart = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]); DiskAddress catalogStart = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]);
if (dosVTOCSector.sectorSize != disk.getBlockSize ()) if (dosVTOCSector.sectorSize != disk.getBlockSize ())
System.out.printf ("%s - invalid sector size : %d%n", disk.getFile ().getName (), System.out.printf ("%s - invalid sector size : %d%n", disk.getFile ().getName (),
dosVTOCSector.sectorSize); dosVTOCSector.sectorSize);
if (dosVTOCSector.maxSectors != disk.getSectorsPerTrack ()) if (dosVTOCSector.maxSectors != disk.getBlocksPerTrack ())
System.out.printf ("%s - invalid sectors per track : %d%n", System.out.printf ("%s - invalid sectors per track : %d%n",
disk.getFile ().getName (), dosVTOCSector.maxSectors); disk.getFile ().getName (), dosVTOCSector.maxSectors);
@ -105,12 +105,12 @@ public class DosDisk extends AbstractFormattedDisk
rootNode.add (volumeNode); rootNode.add (volumeNode);
// flag the catalog sectors before any file mistakenly grabs them // flag the catalog sectors before any file mistakenly grabs them
da = disk.getDiskAddress (catalogStart.getBlock ()); da = disk.getDiskAddress (catalogStart.getBlockNo ());
do do
{ {
if (!disk.isValidAddress (da)) if (!disk.isValidAddress (da))
break; break;
sectorBuffer = disk.readSector (da); sectorBuffer = disk.readBlock (da);
if (!disk.isValidAddress (sectorBuffer[1], sectorBuffer[2])) if (!disk.isValidAddress (sectorBuffer[1], sectorBuffer[2]))
break; break;
@ -123,7 +123,7 @@ public class DosDisk extends AbstractFormattedDisk
// break; // break;
// } // }
sectorTypes[da.getBlock ()] = catalogSector; sectorTypes[da.getBlockNo ()] = catalogSector;
int track = sectorBuffer[1] & 0xFF; int track = sectorBuffer[1] & 0xFF;
int sector = sectorBuffer[2] & 0xFF; int sector = sectorBuffer[2] & 0xFF;
@ -132,15 +132,15 @@ public class DosDisk extends AbstractFormattedDisk
da = disk.getDiskAddress (track, sector); da = disk.getDiskAddress (track, sector);
} while (da.getBlock () != 0); } while (da.getBlockNo () != 0);
// same loop, but now all the catalog sectors are properly flagged // same loop, but now all the catalog sectors are properly flagged
da = disk.getDiskAddress (catalogStart.getBlock ()); da = disk.getDiskAddress (catalogStart.getBlockNo ());
do do
{ {
if (!disk.isValidAddress (da)) if (!disk.isValidAddress (da))
break; break;
sectorBuffer = disk.readSector (da); sectorBuffer = disk.readBlock (da);
if (!disk.isValidAddress (sectorBuffer[1], sectorBuffer[2])) if (!disk.isValidAddress (sectorBuffer[1], sectorBuffer[2]))
break; break;
@ -186,7 +186,7 @@ public class DosDisk extends AbstractFormattedDisk
da = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]); da = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]);
} while (da.getBlock () != 0); } while (da.getBlockNo () != 0);
// link double hi-res files // link double hi-res files
for (AppleFileSource fe : fileEntries) for (AppleFileSource fe : fileEntries)
@ -210,7 +210,7 @@ public class DosDisk extends AbstractFormattedDisk
int lastDosSector = dosVTOCSector.maxSectors * 3; // first three tracks int lastDosSector = dosVTOCSector.maxSectors * 3; // first three tracks
for (DiskAddress da2 : disk) for (DiskAddress da2 : disk)
{ {
int blockNo = da2.getBlock (); int blockNo = da2.getBlockNo ();
if (blockNo < lastDosSector) // in the DOS region if (blockNo < lastDosSector) // in the DOS region
{ {
if (freeBlocks.get (blockNo)) // according to the VTOC if (freeBlocks.get (blockNo)) // according to the VTOC
@ -277,7 +277,7 @@ public class DosDisk extends AbstractFormattedDisk
return true; return true;
} }
if (disk.getSectorsPerTrack () > 16) if (disk.getBlocksPerTrack () > 16)
return false; return false;
int[] cb = new int[3]; int[] cb = new int[3];
@ -342,7 +342,7 @@ public class DosDisk extends AbstractFormattedDisk
private static int checkFormat (AppleDisk disk) private static int checkFormat (AppleDisk disk)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] buffer = disk.readSector (0x11, 0x00); byte[] buffer = disk.readBlock (0x11, 0x00);
// DISCCOMMANDER.DSK uses track 0x17 for the catalog // DISCCOMMANDER.DSK uses track 0x17 for the catalog
// if (buffer[1] != 0x11) // first catalog track // if (buffer[1] != 0x11) // first catalog track
@ -386,7 +386,7 @@ public class DosDisk extends AbstractFormattedDisk
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
DiskAddress catalogStart = disk.getDiskAddress (buffer[1], buffer[2]); DiskAddress catalogStart = disk.getDiskAddress (buffer[1], buffer[2]);
DiskAddress da = disk.getDiskAddress (catalogStart.getBlock ()); DiskAddress da = disk.getDiskAddress (catalogStart.getBlockNo ());
List<DiskAddress> catalogAddresses = new ArrayList<> (); List<DiskAddress> catalogAddresses = new ArrayList<> ();
do do
@ -408,7 +408,7 @@ public class DosDisk extends AbstractFormattedDisk
return 0; return 0;
} }
buffer = disk.readSector (da); buffer = disk.readBlock (da);
if (!disk.isValidAddress (buffer[1], buffer[2])) if (!disk.isValidAddress (buffer[1], buffer[2]))
{ {
if (debug) if (debug)
@ -420,7 +420,7 @@ public class DosDisk extends AbstractFormattedDisk
da = disk.getDiskAddress (buffer[1], buffer[2]); da = disk.getDiskAddress (buffer[1], buffer[2]);
} while (da.getBlock () != 0); } while (da.getBlockNo () != 0);
if (debug) if (debug)
System.out.printf ("Catalog blocks: %d%n", catalogAddresses.size ()); System.out.printf ("Catalog blocks: %d%n", catalogAddresses.size ());
@ -432,7 +432,7 @@ public class DosDisk extends AbstractFormattedDisk
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
for (DiskAddress diskAddress : catalogAddresses) for (DiskAddress diskAddress : catalogAddresses)
if (diskAddress.getBlock () == da.getBlock ()) if (diskAddress.getBlockNo () == da.getBlockNo ())
return true; return true;
return false; return false;
} }
@ -460,14 +460,14 @@ public class DosDisk extends AbstractFormattedDisk
public DataSource getFormattedSector (DiskAddress da) public DataSource getFormattedSector (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
SectorType type = sectorTypes[da.getBlock ()]; SectorType type = sectorTypes[da.getBlockNo ()];
if (type == vtocSector) if (type == vtocSector)
return dosVTOCSector; return dosVTOCSector;
if (da.getBlock () == 0) if (da.getBlockNo () == 0)
return bootSector; return bootSector;
byte[] buffer = disk.readSector (da); byte[] buffer = disk.readBlock (da);
String address = String.format ("%02X %02X", da.getTrack (), da.getSector ()); String address = String.format ("%02X %02X", da.getTrackNo (), da.getSectorNo ());
if (type == tsListSector) if (type == tsListSector)
return new DosTSListSector (getSectorFilename (da), disk, buffer, da); return new DosTSListSector (getSectorFilename (da), disk, buffer, da);

View File

@ -36,7 +36,7 @@ class DosTSListSector extends AbstractSector
break; // throw exception? break; // throw exception?
} }
if (da.getBlock () > 0 && dosDisk.stillAvailable (da)) if (da.getBlockNo () > 0 && dosDisk.stillAvailable (da))
{ {
System.out.println ("Invalid sector address : " + da); System.out.println ("Invalid sector address : " + da);
break; // throw exception? break; // throw exception?
@ -72,8 +72,8 @@ class DosTSListSector extends AbstractSector
if ((buffer[3] != 0 || buffer[4] != 0) // not supposed to be used if ((buffer[3] != 0 || buffer[4] != 0) // not supposed to be used
// Diags2E.dsk stores its own sector address here // Diags2E.dsk stores its own sector address here
&& (diskAddress.getTrack () == (buffer[3] & 0xFF) && (diskAddress.getTrackNo () == (buffer[3] & 0xFF)
&& diskAddress.getSector () == (buffer[4] & 0xFF))) && diskAddress.getSectorNo () == (buffer[4] & 0xFF)))
addText (text, buffer, 3, 2, "Self-reference"); addText (text, buffer, 3, 2, "Self-reference");
else else
addText (text, buffer, 3, 2, "Not used"); addText (text, buffer, 3, 2, "Not used");

View File

@ -76,7 +76,7 @@ class DosVTOCSector extends AbstractSector
addTextAndDecimal (text, buffer, 53, 1, "Maximum sectors"); addTextAndDecimal (text, buffer, 53, 1, "Maximum sectors");
addTextAndDecimal (text, buffer, 54, 2, "Bytes per sector"); addTextAndDecimal (text, buffer, 54, 2, "Bytes per sector");
boolean bootSectorEmpty = parentDisk.getDisk ().isSectorEmpty (0); boolean bootSectorEmpty = parentDisk.getDisk ().isBlockEmpty (0);
int firstSector = 0x38; int firstSector = 0x38;
int max = maxTracks * 4 + firstSector; int max = maxTracks * 4 + firstSector;
for (int i = firstSector; i < max; i += 4) for (int i = firstSector; i < max; i += 4)
@ -135,7 +135,7 @@ class DosVTOCSector extends AbstractSector
addTextAndDecimal (text, buffer, 0x35, 1, "Maximum sectors"); addTextAndDecimal (text, buffer, 0x35, 1, "Maximum sectors");
addTextAndDecimal (text, buffer, 0x36, 2, "Bytes per sector"); addTextAndDecimal (text, buffer, 0x36, 2, "Bytes per sector");
boolean bootSectorEmpty = parentDisk.getDisk ().isSectorEmpty (0); boolean bootSectorEmpty = parentDisk.getDisk ().isBlockEmpty (0);
int firstSector = 0x38; int firstSector = 0x38;
int max = maxTracks * 4 + firstSector; int max = maxTracks * 4 + firstSector;
for (int i = firstSector; i < max; i += 4) for (int i = firstSector; i < max; i += 4)

View File

@ -183,8 +183,8 @@ class DiskLayoutPanel extends JPanel
public Rectangle getLocation (DiskAddress da) public Rectangle getLocation (DiskAddress da)
{ {
int y = da.getBlock () / grid.width; int y = da.getBlockNo () / grid.width;
int x = da.getBlock () % grid.width; int x = da.getBlockNo () % grid.width;
Rectangle r = Rectangle r =
new Rectangle (x * block.width, y * block.height, block.width, block.height); new Rectangle (x * block.width, y * block.height, block.width, block.height);
return r; return r;

View File

@ -97,28 +97,28 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
switch (e.getKeyCode ()) switch (e.getKeyCode ())
{ {
case KeyEvent.VK_LEFT: case KeyEvent.VK_LEFT:
int block = first.getBlock () - 1; int block = first.getBlockNo () - 1;
if (block < 0) if (block < 0)
block = totalBlocks - 1; block = totalBlocks - 1;
addHighlight (disk.getDiskAddress (block)); addHighlight (disk.getDiskAddress (block));
break; break;
case KeyEvent.VK_RIGHT: case KeyEvent.VK_RIGHT:
block = last.getBlock () + 1; block = last.getBlockNo () + 1;
if (block >= totalBlocks) if (block >= totalBlocks)
block = 0; block = 0;
addHighlight (disk.getDiskAddress (block)); addHighlight (disk.getDiskAddress (block));
break; break;
case KeyEvent.VK_UP: case KeyEvent.VK_UP:
block = first.getBlock () - rowSize; block = first.getBlockNo () - rowSize;
if (block < 0) if (block < 0)
block += totalBlocks; block += totalBlocks;
addHighlight (disk.getDiskAddress (block)); addHighlight (disk.getDiskAddress (block));
break; break;
case KeyEvent.VK_DOWN: case KeyEvent.VK_DOWN:
block = last.getBlock () + rowSize; block = last.getBlockNo () + rowSize;
if (block >= totalBlocks) if (block >= totalBlocks)
block -= totalBlocks; block -= totalBlocks;
addHighlight (disk.getDiskAddress (block)); addHighlight (disk.getDiskAddress (block));
@ -169,7 +169,7 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
highlights.clear (); highlights.clear ();
if (list != null) if (list != null)
for (DiskAddress da : list) for (DiskAddress da : list)
if (da != null && (da.getBlock () > 0 || ((AppleDiskAddress) da).zeroFlag ())) if (da != null && (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ()))
highlights.add (da); highlights.add (da);
} }
@ -177,8 +177,8 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
private boolean checkContiguous () private boolean checkContiguous ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
int range = highlights.get (highlights.size () - 1).getBlock () int range = highlights.get (highlights.size () - 1).getBlockNo ()
- highlights.get (0).getBlock () + 1; - highlights.get (0).getBlockNo () + 1;
return (range == highlights.size ()); return (range == highlights.size ());
} }
@ -189,16 +189,16 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
int lo, hi; int lo, hi;
// Are we extending in front of the current block? // Are we extending in front of the current block?
if (highlights.get (0).getBlock () > da.getBlock ()) if (highlights.get (0).getBlockNo () > da.getBlockNo ())
{ {
lo = da.getBlock (); lo = da.getBlockNo ();
hi = highlights.get (0).getBlock () - 1; hi = highlights.get (0).getBlockNo () - 1;
} }
else else
// No, must be extending at the end // No, must be extending at the end
{ {
lo = highlights.get (highlights.size () - 1).getBlock () + 1; lo = highlights.get (highlights.size () - 1).getBlockNo () + 1;
hi = da.getBlock (); hi = da.getBlockNo ();
} }
for (int i = lo; i <= hi; i++) for (int i = lo; i <= hi; i++)
@ -210,8 +210,8 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
// If we are outside the discontiguous range, just extend as usual // If we are outside the discontiguous range, just extend as usual
if (da.getBlock () < highlights.get (0).getBlock () if (da.getBlockNo () < highlights.get (0).getBlockNo ()
|| da.getBlock () > highlights.get (highlights.size () - 1).getBlock ()) || da.getBlockNo () > highlights.get (highlights.size () - 1).getBlockNo ())
{ {
extendHighlights (disk, da); extendHighlights (disk, da);
return; return;

View File

@ -36,7 +36,7 @@ class SaveSectorsAction extends DefaultAction implements SectorSelectionListener
return; return;
} }
byte[] buffer = byte[] buffer =
event.getFormattedDisk ().getDisk ().readSectors (event.getSectors ()); event.getFormattedDisk ().getDisk ().readBlocks (event.getSectors ());
JFileChooser fileChooser = new JFileChooser (); JFileChooser fileChooser = new JFileChooser ();
fileChooser.setDialogTitle ("Save sectors"); fileChooser.setDialogTitle ("Save sectors");

View File

@ -54,7 +54,7 @@ public class InfocomDisk extends AbstractFormattedDisk
setInfocomSectorTypes (); setInfocomSectorTypes ();
data = disk.readSector (3, 0); // read first sector to get file size data = disk.readBlock (3, 0); // read first sector to get file size
data = getBuffer (getWord (26) * 2); // read entire file into data buffer data = getBuffer (getWord (26) * 2); // read entire file into data buffer
if (false) if (false)
@ -131,7 +131,7 @@ public class InfocomDisk extends AbstractFormattedDisk
for (int track = 0; track < 3; track++) for (int track = 0; track < 3; track++)
for (int sector = 0; sector < 16; sector++) for (int sector = 0; sector < 16; sector++)
if (!disk.isSectorEmpty (track, sector)) if (!disk.isBlockEmpty (track, sector))
sectorTypes[track * 16 + sector] = bootSector; sectorTypes[track * 16 + sector] = bootSector;
} }
@ -148,7 +148,7 @@ public class InfocomDisk extends AbstractFormattedDisk
while (blockNo <= blockTo) while (blockNo <= blockTo)
{ {
blocks.add (disk.getDiskAddress (blockNo)); blocks.add (disk.getDiskAddress (blockNo));
if (!disk.isSectorEmpty (blockNo)) if (!disk.isBlockEmpty (blockNo))
sectorTypes[blockNo] = type; sectorTypes[blockNo] = type;
blockNo++; blockNo++;
} }
@ -164,11 +164,11 @@ public class InfocomDisk extends AbstractFormattedDisk
int fileSize = 0; int fileSize = 0;
for (DiskAddress da : disk) for (DiskAddress da : disk)
{ {
if (da.getBlock () > startBlock && disk.isSectorEmpty (da)) if (da.getBlockNo () > startBlock && disk.isBlockEmpty (da))
{ {
System.out.println ("Empty : " + da); System.out.println ("Empty : " + da);
buffer = disk.readSector (da.getBlock () - 1); buffer = disk.readBlock (da.getBlockNo () - 1);
fileSize = (da.getBlock () - 48) * disk.getBlockSize (); fileSize = (da.getBlockNo () - 48) * disk.getBlockSize ();
break; break;
} }
} }
@ -193,7 +193,7 @@ public class InfocomDisk extends AbstractFormattedDisk
for (int track = 3, ptr = 0; track < 35; track++) for (int track = 3, ptr = 0; track < 35; track++)
for (int sector = 0; sector < 16; sector++, ptr += BLOCK_SIZE) for (int sector = 0; sector < 16; sector++, ptr += BLOCK_SIZE)
{ {
byte[] temp = disk.readSector (track, sector); byte[] temp = disk.readBlock (track, sector);
int spaceLeft = fileSize - ptr; int spaceLeft = fileSize - ptr;
if (spaceLeft <= BLOCK_SIZE) if (spaceLeft <= BLOCK_SIZE)
{ {
@ -247,7 +247,7 @@ public class InfocomDisk extends AbstractFormattedDisk
public static boolean checkFormat (AppleDisk disk) public static boolean checkFormat (AppleDisk disk)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] buffer = disk.readSector (3, 0); byte[] buffer = disk.readBlock (3, 0);
int version = buffer[0] & 0xFF; int version = buffer[0] & 0xFF;
int highMemory = HexFormatter.intValue (buffer[5], buffer[4]); int highMemory = HexFormatter.intValue (buffer[5], buffer[4]);

View File

@ -120,7 +120,7 @@ public class FileEntry extends CatalogEntry
private byte[] getExactBuffer () private byte[] getExactBuffer ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] buffer = parent.getDisk ().readSectors (blocks); byte[] buffer = parent.getDisk ().readBlocks (blocks);
byte[] exactBuffer; byte[] exactBuffer;
if (buffer.length > 0 && bytesUsedInLastBlock < 512) if (buffer.length > 0 && bytesUsedInLastBlock < 512)

View File

@ -65,10 +65,10 @@ public class PascalDisk extends AbstractFormattedDisk
sectorTypesList.add (badSector); sectorTypesList.add (badSector);
List<DiskAddress> blocks = disk.getDiskAddressList (0, 1); // B0, B1 List<DiskAddress> blocks = disk.getDiskAddressList (0, 1); // B0, B1
this.bootSector = new BootSector (disk, disk.readSectors (blocks), "Pascal"); this.bootSector = new BootSector (disk, disk.readBlocks (blocks), "Pascal");
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
if (!disk.isSectorEmpty (i)) if (!disk.isBlockEmpty (i))
{ {
sectorTypes[i] = diskBootSector; sectorTypes[i] = diskBootSector;
freeBlocks.set (i, false); freeBlocks.set (i, false);
@ -77,7 +77,7 @@ public class PascalDisk extends AbstractFormattedDisk
for (int i = 2; i < disk.getTotalBlocks (); i++) for (int i = 2; i < disk.getTotalBlocks (); i++)
freeBlocks.set (i, true); freeBlocks.set (i, true);
byte[] buffer = disk.readSector (2); byte[] buffer = disk.readBlock (2);
byte[] data = new byte[CATALOG_ENTRY_SIZE]; byte[] data = new byte[CATALOG_ENTRY_SIZE];
System.arraycopy (buffer, 0, data, 0, CATALOG_ENTRY_SIZE); System.arraycopy (buffer, 0, data, 0, CATALOG_ENTRY_SIZE);
volumeEntry = new VolumeEntry (this, data); volumeEntry = new VolumeEntry (this, data);
@ -91,20 +91,20 @@ public class PascalDisk extends AbstractFormattedDisk
for (int i = 2; i < max; i++) for (int i = 2; i < max; i++)
{ {
DiskAddress da = disk.getDiskAddress (i); DiskAddress da = disk.getDiskAddress (i);
if (!disk.isSectorEmpty (da)) if (!disk.isBlockEmpty (da))
sectorTypes[i] = catalogSector; sectorTypes[i] = catalogSector;
sectors.add (da); sectors.add (da);
freeBlocks.set (i, false); freeBlocks.set (i, false);
} }
diskCatalogSector = diskCatalogSector =
new PascalCatalogSector (disk, disk.readSectors (sectors), sectors); new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors);
// read the catalog // read the catalog
List<DiskAddress> addresses = new ArrayList<> (); List<DiskAddress> addresses = new ArrayList<> ();
for (int i = 2; i < max; i++) for (int i = 2; i < max; i++)
addresses.add (disk.getDiskAddress (i)); addresses.add (disk.getDiskAddress (i));
buffer = disk.readSectors (addresses); buffer = disk.readBlocks (addresses);
// loop through each catalog entry (what if there are deleted files?) // loop through each catalog entry (what if there are deleted files?)
for (int i = 1; i <= volumeEntry.totalFiles; i++) for (int i = 1; i <= volumeEntry.totalFiles; i++)
@ -152,7 +152,7 @@ public class PascalDisk extends AbstractFormattedDisk
public static boolean checkFormat (AppleDisk disk, boolean debug) public static boolean checkFormat (AppleDisk disk, boolean debug)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] buffer = disk.readSector (2); byte[] buffer = disk.readBlock (2);
int nameLength = buffer[6] & 0xFF; int nameLength = buffer[6] & 0xFF;
if (nameLength < 1 || nameLength > 7) if (nameLength < 1 || nameLength > 7)
{ {
@ -187,7 +187,7 @@ public class PascalDisk extends AbstractFormattedDisk
List<DiskAddress> addresses = new ArrayList<> (); List<DiskAddress> addresses = new ArrayList<> ();
for (int i = 2; i < to; i++) for (int i = 2; i < to; i++)
addresses.add (disk.getDiskAddress (i)); addresses.add (disk.getDiskAddress (i));
buffer = disk.readSectors (addresses); buffer = disk.readBlocks (addresses);
int files = HexFormatter.intValue (buffer[16], buffer[17]); int files = HexFormatter.intValue (buffer[16], buffer[17]);
if (files < 0 || files > 77) if (files < 0 || files > 77)
@ -228,14 +228,14 @@ public class PascalDisk extends AbstractFormattedDisk
public DataSource getFormattedSector (DiskAddress da) public DataSource getFormattedSector (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
SectorType st = sectorTypes[da.getBlock ()]; SectorType st = sectorTypes[da.getBlockNo ()];
if (st == diskBootSector) if (st == diskBootSector)
return bootSector; return bootSector;
if (st == catalogSector) if (st == catalogSector)
return diskCatalogSector; return diskCatalogSector;
String name = getSectorFilename (da); String name = getSectorFilename (da);
if (name != null) if (name != null)
return new DefaultSector (name, disk, disk.readSector (da), da); return new DefaultSector (name, disk, disk.readBlock (da), da);
return super.getFormattedSector (da); return super.getFormattedSector (da);
} }

View File

@ -30,7 +30,7 @@ class VolumeEntry extends CatalogEntry
if (file != null) if (file != null)
return file; return file;
byte[] buffer = parent.getDisk ().readSectors (blocks); byte[] buffer = parent.getDisk ().readBlocks (blocks);
file = new DefaultAppleFile (name, buffer); file = new DefaultAppleFile (name, buffer);
return file; return file;

View File

@ -102,7 +102,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
if (diskAddress == null) if (diskAddress == null)
break; break;
dataBlocks.add (diskAddress); dataBlocks.add (diskAddress);
byte[] buffer = disk.readSector (block); byte[] buffer = disk.readBlock (block);
block = HexFormatter.unsignedShort (buffer, 2); block = HexFormatter.unsignedShort (buffer, 2);
} while (block > 0); } while (block > 0);
break; break;
@ -125,7 +125,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
parentDisk.setSectorType (keyPtr, parentDisk.extendedKeySector); parentDisk.setSectorType (keyPtr, parentDisk.extendedKeySector);
indexBlocks.add (disk.getDiskAddress (keyPtr)); indexBlocks.add (disk.getDiskAddress (keyPtr));
byte[] buffer2 = disk.readSector (keyPtr); // data fork and resource fork byte[] buffer2 = disk.readBlock (keyPtr); // data fork and resource fork
// read 2 mini entries (data fork & resource fork) // read 2 mini entries (data fork & resource fork)
for (int i = 0; i < 512; i += 256) for (int i = 0; i < 512; i += 256)
@ -194,7 +194,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
parentDisk.setSectorType (blockPtr, parentDisk.indexSector); parentDisk.setSectorType (blockPtr, parentDisk.indexSector);
indexBlocks.add (disk.getDiskAddress (blockPtr)); indexBlocks.add (disk.getDiskAddress (blockPtr));
byte[] buffer = disk.readSector (blockPtr); byte[] buffer = disk.readBlock (blockPtr);
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
int blockNo = (buffer[i] & 0xFF) | ((buffer[i + 0x100] & 0xFF) << 8); int blockNo = (buffer[i] & 0xFF) | ((buffer[i + 0x100] & 0xFF) << 8);
@ -213,7 +213,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
parentDisk.setSectorType (keyPtr, parentDisk.masterIndexSector); parentDisk.setSectorType (keyPtr, parentDisk.masterIndexSector);
indexBlocks.add (disk.getDiskAddress (keyPtr)); indexBlocks.add (disk.getDiskAddress (keyPtr));
byte[] buffer = disk.readSector (keyPtr); // master index byte[] buffer = disk.readBlock (keyPtr); // master index
int highest = 0x80; int highest = 0x80;
while (highest-- > 0) // decrement after test while (highest-- > 0) // decrement after test
@ -537,7 +537,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
List<DiskAddress> addresses = new ArrayList<> (); List<DiskAddress> addresses = new ArrayList<> ();
int logicalBlock = 0; int logicalBlock = 0;
byte[] mainIndexBuffer = disk.readSector (keyPtr); byte[] mainIndexBuffer = disk.readBlock (keyPtr);
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
int indexBlock = int indexBlock =
@ -548,7 +548,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
{ {
if (addresses.size () > 0) if (addresses.size () > 0)
{ {
byte[] tempBuffer = disk.readSectors (addresses); byte[] tempBuffer = disk.readBlocks (addresses);
buffers.add ( buffers.add (
new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ())); new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
addresses.clear (); addresses.clear ();
@ -603,24 +603,24 @@ class FileEntry extends CatalogEntry implements ProdosConstants
case SEEDLING: case SEEDLING:
case SAPLING: case SAPLING:
case TREE: case TREE:
return disk.readSectors (dataBlocks); return disk.readBlocks (dataBlocks);
case SUBDIRECTORY: case SUBDIRECTORY:
byte[] fullBuffer = new byte[dataBlocks.size () * BLOCK_ENTRY_SIZE]; byte[] fullBuffer = new byte[dataBlocks.size () * BLOCK_ENTRY_SIZE];
int offset = 0; int offset = 0;
for (DiskAddress da : dataBlocks) for (DiskAddress da : dataBlocks)
{ {
byte[] buffer = disk.readSector (da); byte[] buffer = disk.readBlock (da);
System.arraycopy (buffer, 4, fullBuffer, offset, BLOCK_ENTRY_SIZE); System.arraycopy (buffer, 4, fullBuffer, offset, BLOCK_ENTRY_SIZE);
offset += BLOCK_ENTRY_SIZE; offset += BLOCK_ENTRY_SIZE;
} }
return fullBuffer; return fullBuffer;
case GSOS_EXTENDED_FILE: case GSOS_EXTENDED_FILE:
return disk.readSectors (dataBlocks); // data and resource forks concatenated return disk.readBlocks (dataBlocks); // data and resource forks concatenated
case PASCAL_ON_PROFILE: case PASCAL_ON_PROFILE:
return disk.readSectors (dataBlocks); return disk.readBlocks (dataBlocks);
default: default:
System.out.println ("Unknown storage type in getBuffer : " + storageType); System.out.println ("Unknown storage type in getBuffer : " + storageType);
@ -633,7 +633,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
List<TextBuffer> buffers, int logicalBlock) List<TextBuffer> buffers, int logicalBlock)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] indexBuffer = disk.readSector (indexBlock); byte[] indexBuffer = disk.readBlock (indexBlock);
for (int j = 0; j < 256; j++) for (int j = 0; j < 256; j++)
{ {
int block = HexFormatter.intValue (indexBuffer[j], indexBuffer[j + 256]); int block = HexFormatter.intValue (indexBuffer[j], indexBuffer[j + 256]);
@ -641,7 +641,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
addresses.add (disk.getDiskAddress (block)); addresses.add (disk.getDiskAddress (block));
else if (addresses.size () > 0) else if (addresses.size () > 0)
{ {
byte[] tempBuffer = disk.readSectors (addresses); byte[] tempBuffer = disk.readBlocks (addresses);
buffers buffers
.add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ())); .add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
addresses.clear (); addresses.clear ();

View File

@ -30,7 +30,7 @@ class ProdosBitMapSector extends AbstractSector
// check range of bits for current block - so far I don't have a disk that needs // check range of bits for current block - so far I don't have a disk that needs
// more than a single block // more than a single block
int relativeBlock = int relativeBlock =
diskAddress.getBlock () - parent.getVolumeDirectoryHeader ().bitMapBlock; diskAddress.getBlockNo () - parent.getVolumeDirectoryHeader ().bitMapBlock;
int startBit = relativeBlock * 4096; int startBit = relativeBlock * 4096;
// int endBit = startBit + 4096; // int endBit = startBit + 4096;
if (startBit >= grid.width * grid.height) if (startBit >= grid.width * grid.height)

View File

@ -70,11 +70,11 @@ public class ProdosDisk extends AbstractFormattedDisk
sectorTypesList.add (extendedKeySector); sectorTypesList.add (extendedKeySector);
for (int block = 0; block < 2; block++) for (int block = 0; block < 2; block++)
if (!disk.isSectorEmpty (disk.getDiskAddress (block))) if (!disk.isBlockEmpty (disk.getDiskAddress (block)))
sectorTypes[block] = dosSector; sectorTypes[block] = dosSector;
DiskAddress da = disk.getDiskAddress (0); DiskAddress da = disk.getDiskAddress (0);
byte[] buffer = disk.readSector (da); byte[] buffer = disk.readBlock (da);
bootSector = new BootSector (disk, buffer, "Prodos", da); bootSector = new BootSector (disk, buffer, "Prodos", da);
DefaultMutableTreeNode root = getCatalogTreeRoot (); DefaultMutableTreeNode root = getCatalogTreeRoot ();
@ -86,7 +86,7 @@ public class ProdosDisk extends AbstractFormattedDisk
for (DiskAddress da2 : disk) for (DiskAddress da2 : disk)
{ {
int blockNo = da2.getBlock (); int blockNo = da2.getBlockNo ();
if (freeBlocks.get (blockNo)) if (freeBlocks.get (blockNo))
{ {
if (!stillAvailable (da2)) if (!stillAvailable (da2))
@ -113,8 +113,8 @@ public class ProdosDisk extends AbstractFormattedDisk
do do
{ {
byte[] sectorBuffer = disk.readSector (block); byte[] sectorBuffer = disk.readBlock (block);
if (!disk.isSectorEmpty (block)) if (!disk.isBlockEmpty (block))
sectorTypes[block] = currentSectorType; sectorTypes[block] = currentSectorType;
int max = disk.getBlockSize () - ProdosConstants.ENTRY_SIZE; int max = disk.getBlockSize () - ProdosConstants.ENTRY_SIZE;
@ -135,7 +135,7 @@ public class ProdosDisk extends AbstractFormattedDisk
assert vdh.entryLength == ProdosConstants.ENTRY_SIZE; assert vdh.entryLength == ProdosConstants.ENTRY_SIZE;
headerEntries.add (vdh); headerEntries.add (vdh);
currentSectorType = catalogSector; currentSectorType = catalogSector;
if (!disk.isSectorEmpty (block)) if (!disk.isBlockEmpty (block))
sectorTypes[block] = currentSectorType; sectorTypes[block] = currentSectorType;
for (int i = 0; i < vdh.totalBitMapBlocks; i++) for (int i = 0; i < vdh.totalBitMapBlocks; i++)
sectorTypes[vdh.bitMapBlock + i] = volumeMapSector; sectorTypes[vdh.bitMapBlock + i] = volumeMapSector;
@ -147,7 +147,7 @@ public class ProdosDisk extends AbstractFormattedDisk
localHeader = new SubDirectoryHeader (this, entry, parent); localHeader = new SubDirectoryHeader (this, entry, parent);
headerEntries.add (localHeader); headerEntries.add (localHeader);
currentSectorType = subcatalogSector; currentSectorType = subcatalogSector;
if (!disk.isSectorEmpty (block)) if (!disk.isBlockEmpty (block))
sectorTypes[block] = currentSectorType; sectorTypes[block] = currentSectorType;
break; break;
@ -221,7 +221,7 @@ public class ProdosDisk extends AbstractFormattedDisk
public static boolean checkFormat (AppleDisk disk) public static boolean checkFormat (AppleDisk disk)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] buffer = disk.readSector (2); // Prodos KEY BLOCK byte[] buffer = disk.readBlock (2); // Prodos KEY BLOCK
if (debug) if (debug)
{ {
System.out.println (HexFormatter.format (buffer)); System.out.println (HexFormatter.format (buffer));
@ -271,11 +271,11 @@ public class ProdosDisk extends AbstractFormattedDisk
public DataSource getFormattedSector (DiskAddress da) public DataSource getFormattedSector (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (da.getBlock () == 0) if (da.getBlockNo () == 0)
return bootSector; return bootSector;
byte[] buffer = disk.readSector (da); byte[] buffer = disk.readBlock (da);
SectorType type = sectorTypes[da.getBlock ()]; SectorType type = sectorTypes[da.getBlockNo ()];
if (type == catalogSector || type == subcatalogSector) if (type == catalogSector || type == subcatalogSector)
return new ProdosCatalogSector (this, disk, buffer, da); return new ProdosCatalogSector (this, disk, buffer, da);

View File

@ -39,7 +39,7 @@ class VolumeDirectoryHeader extends DirectoryHeader
do do
{ {
dataBlocks.add (disk.getDiskAddress (block)); dataBlocks.add (disk.getDiskAddress (block));
byte[] buffer = disk.readSector (block); byte[] buffer = disk.readBlock (block);
block = HexFormatter.unsignedShort (buffer, 2); block = HexFormatter.unsignedShort (buffer, 2);
} while (block > 0); } while (block > 0);
@ -47,13 +47,13 @@ class VolumeDirectoryHeader extends DirectoryHeader
// int bitMapBytes = totalBlocks / 8; // one bit per block // int bitMapBytes = totalBlocks / 8; // one bit per block
int bitMapBytes = (totalBlocks - 1) / 8 + 1; // one bit per block int bitMapBytes = (totalBlocks - 1) / 8 + 1; // one bit per block
byte[] buffer = new byte[bitMapBytes]; byte[] buffer = new byte[bitMapBytes];
int bitMapBlocks = (bitMapBytes - 1) / disk.getSectorsPerTrack () + 1; int bitMapBlocks = (bitMapBytes - 1) / disk.getBlocksPerTrack () + 1;
int lastBitMapBlock = bitMapBlock + bitMapBlocks - 1; int lastBitMapBlock = bitMapBlock + bitMapBlocks - 1;
int ptr = 0; int ptr = 0;
for (block = bitMapBlock; block <= lastBitMapBlock; block++) for (block = bitMapBlock; block <= lastBitMapBlock; block++)
{ {
byte[] temp = disk.readSector (block); byte[] temp = disk.readBlock (block);
int bytesToCopy = buffer.length - ptr; int bytesToCopy = buffer.length - ptr;
if (bytesToCopy > temp.length) if (bytesToCopy > temp.length)
bytesToCopy = temp.length; bytesToCopy = temp.length;
@ -101,7 +101,7 @@ class VolumeDirectoryHeader extends DirectoryHeader
int block = 2; int block = 2;
do do
{ {
byte[] buf = disk.readSector (block); byte[] buf = disk.readBlock (block);
blockList.add (buf); blockList.add (buf);
block = HexFormatter.intValue (buf[2], buf[3]); // next block block = HexFormatter.intValue (buf[2], buf[3]); // next block
} while (block > 0); } while (block > 0);

View File

@ -112,7 +112,7 @@ class Header
StringBuilder text = new StringBuilder (scenarioTitle + "\n\n"); StringBuilder text = new StringBuilder (scenarioTitle + "\n\n");
int ptr = 106; int ptr = 106;
byte[] buffer = owner.getDisk ().readSector (da); byte[] buffer = owner.getDisk ().readBlock (da);
while (buffer[ptr] != -1) while (buffer[ptr] != -1)
{ {
text.append (HexFormatter.getPascalString (buffer, ptr) + "\n"); text.append (HexFormatter.getPascalString (buffer, ptr) + "\n");
@ -143,7 +143,7 @@ class Header
List<DiskAddress> blocks = new ArrayList<> (); List<DiskAddress> blocks = new ArrayList<> ();
blocks.add (da); blocks.add (da);
byte[] buffer = owner.getDisk ().readSector (da); byte[] buffer = owner.getDisk ().readBlock (da);
String text = printChars (buffer, 0); String text = printChars (buffer, 0);
DefaultAppleFileSource dafs = new DefaultAppleFileSource (title, text, owner); DefaultAppleFileSource dafs = new DefaultAppleFileSource (title, text, owner);
@ -163,7 +163,7 @@ class Header
int level = 1; int level = 1;
StringBuilder list = new StringBuilder ("Level " + level + ":\n"); StringBuilder list = new StringBuilder ("Level " + level + ":\n");
byte[] buffer = owner.getDisk ().readSector (da); byte[] buffer = owner.getDisk ().readBlock (da);
String text = HexFormatter.getString (buffer, 0, 512); String text = HexFormatter.getString (buffer, 0, 512);
String[] spells = text.split ("\n"); String[] spells = text.split ("\n");
for (String s : spells) for (String s : spells)

View File

@ -72,9 +72,9 @@ public class Relocator extends AbstractFile
if (diskNo > 0) if (diskNo > 0)
{ {
Disk disk = dataDisks[diskNo]; Disk disk = dataDisks[diskNo];
byte[] temp = disk.readSector (diskOffsets[logicalBlock]); byte[] temp = disk.readBlock (diskOffsets[logicalBlock]);
DiskAddress da = master.getDiskAddress (logicalBlock); DiskAddress da = master.getDiskAddress (logicalBlock);
master.writeSector (da, temp); master.writeBlock (da, temp);
// if (da.getBlock () == 0x126) // if (da.getBlock () == 0x126)
// System.out.println (HexFormatter.format (buffer)); // System.out.println (HexFormatter.format (buffer));
// if (Utility.find (temp, key1)) // if (Utility.find (temp, key1))

View File

@ -356,12 +356,12 @@ public class Wizardry4BootDisk extends PascalDisk
{ {
// Wizardry IV or V boot code // Wizardry IV or V boot code
byte[] header = { 0x00, (byte) 0xEA, (byte) 0xA9, 0x60, (byte) 0x8D, 0x01, 0x08 }; byte[] header = { 0x00, (byte) 0xEA, (byte) 0xA9, 0x60, (byte) 0x8D, 0x01, 0x08 };
byte[] buffer = disk.readSector (0); byte[] buffer = disk.readBlock (0);
if (!Utility.matches (buffer, 0, header)) if (!Utility.matches (buffer, 0, header))
return false; return false;
buffer = disk.readSector (1); buffer = disk.readBlock (1);
if (buffer[510] != 1 || buffer[511] != 0) // disk #1 if (buffer[510] != 1 || buffer[511] != 0) // disk #1
return false; return false;

View File

@ -135,7 +135,7 @@ public class WizardryScenarioDisk extends PascalDisk
public static boolean isWizardryFormat (Disk disk, boolean debug) public static boolean isWizardryFormat (Disk disk, boolean debug)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
byte[] buffer = disk.readSector (2); byte[] buffer = disk.readBlock (2);
int totalFiles = HexFormatter.intValue (buffer[16], buffer[17]); int totalFiles = HexFormatter.intValue (buffer[16], buffer[17]);
if (totalFiles != 3) if (totalFiles != 3)
return false; return false;
@ -196,7 +196,7 @@ public class WizardryScenarioDisk extends PascalDisk
{ {
List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors); List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors);
nodeSectors.addAll (blocks); nodeSectors.addAll (blocks);
byte[] buffer = disk.readSectors (blocks); byte[] buffer = disk.readBlocks (blocks);
seq = addReward (buffer, blocks, node, seq); seq = addReward (buffer, blocks, node, seq);
} }
@ -243,7 +243,7 @@ public class WizardryScenarioDisk extends PascalDisk
{ {
List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors); List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors);
nodeSectors.addAll (blocks); nodeSectors.addAll (blocks);
byte[] buffer = disk.readSectors (blocks); byte[] buffer = disk.readBlocks (blocks);
addCharacters (buffer, blocks, node); addCharacters (buffer, blocks, node);
} }
@ -306,7 +306,7 @@ public class WizardryScenarioDisk extends PascalDisk
{ {
List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors); List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors);
nodeSectors.addAll (blocks); nodeSectors.addAll (blocks);
byte[] buffer = disk.readSectors (blocks); byte[] buffer = disk.readBlocks (blocks);
addMonsters (buffer, blocks, node); addMonsters (buffer, blocks, node);
} }
@ -363,7 +363,7 @@ public class WizardryScenarioDisk extends PascalDisk
{ {
List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors); List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors);
nodeSectors.addAll (blocks); nodeSectors.addAll (blocks);
byte[] buffer = disk.readSectors (blocks); byte[] buffer = disk.readBlocks (blocks);
addItems (buffer, blocks, node); addItems (buffer, blocks, node);
} }
@ -419,7 +419,7 @@ public class WizardryScenarioDisk extends PascalDisk
SpellType spellType = SpellType.MAGE; SpellType spellType = SpellType.MAGE;
for (DiskAddress da : blocks) for (DiskAddress da : blocks)
{ {
byte[] buffer = disk.readSector (da); byte[] buffer = disk.readBlock (da);
int level = 1; int level = 1;
int ptr = -1; int ptr = -1;
while (ptr < 255) while (ptr < 255)
@ -459,7 +459,7 @@ public class WizardryScenarioDisk extends PascalDisk
for (DiskAddress da : sectors) for (DiskAddress da : sectors)
{ {
byte[] tempBuffer = disk.readSector (da); byte[] tempBuffer = disk.readBlock (da);
System.arraycopy (tempBuffer, 0, buffer, offset, max); System.arraycopy (tempBuffer, 0, buffer, offset, max);
offset += max; offset += max;
} }
@ -518,7 +518,7 @@ public class WizardryScenarioDisk extends PascalDisk
{ {
List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors); List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors);
nodeSectors.addAll (blocks); nodeSectors.addAll (blocks);
byte[] buffer = disk.readSectors (blocks); byte[] buffer = disk.readBlocks (blocks);
byte[] data2 = new byte[896]; byte[] data2 = new byte[896];
System.arraycopy (buffer, 0, data2, 0, data2.length); System.arraycopy (buffer, 0, data2, 0, data2.length);
// System.out.println (HexFormatter.format (data2)); // System.out.println (HexFormatter.format (data2));
@ -554,7 +554,7 @@ public class WizardryScenarioDisk extends PascalDisk
{ {
DiskAddress da = sectors.get (sd.dataOffset + i); DiskAddress da = sectors.get (sd.dataOffset + i);
nodeSectors.add (da); nodeSectors.add (da);
byte[] buffer = disk.readSector (da); byte[] buffer = disk.readBlock (da);
byte[] exactBuffer = new byte[480]; byte[] exactBuffer = new byte[480];
System.arraycopy (buffer, 0, exactBuffer, 0, exactBuffer.length); System.arraycopy (buffer, 0, exactBuffer, 0, exactBuffer.length);
@ -596,7 +596,7 @@ public class WizardryScenarioDisk extends PascalDisk
{ {
List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors); List<DiskAddress> blocks = getTwoBlocks (sd, i, sectors);
nodeSectors.addAll (blocks); nodeSectors.addAll (blocks);
byte[] buffer = disk.readSectors (blocks); byte[] buffer = disk.readBlocks (blocks);
for (int ptr = 0; ptr <= buffer.length; ptr += 78) for (int ptr = 0; ptr <= buffer.length; ptr += 78)
{ {