diff --git a/src/com/bytezone/diskbrowser/cpm/CPMDisk.java b/src/com/bytezone/diskbrowser/cpm/CPMDisk.java index 05b21c1..5c4dadd 100644 --- a/src/com/bytezone/diskbrowser/cpm/CPMDisk.java +++ b/src/com/bytezone/diskbrowser/cpm/CPMDisk.java @@ -55,7 +55,7 @@ public class CPMDisk extends AbstractFormattedDisk // search for the version string 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); if ("DIR ERA TYPESAVEREN USER".equals (text)) { @@ -72,8 +72,8 @@ public class CPMDisk extends AbstractFormattedDisk { DiskAddress da = disk.getDiskAddress (3, sector); - sectorTypes[da.getBlock ()] = catalogSector; - byte[] buffer = disk.readSector (da); + sectorTypes[da.getBlockNo ()] = catalogSector; + byte[] buffer = disk.readBlock (da); int b1 = buffer[0] & 0xFF; int b2 = buffer[1] & 0xFF; if (b1 == 0xE5) @@ -95,8 +95,8 @@ public class CPMDisk extends AbstractFormattedDisk DirectoryEntry entry = new DirectoryEntry (this, buffer, i); SectorType sectorType = getSectorType (entry.getType ()); for (DiskAddress block : entry.getSectors ()) - if (!disk.isSectorEmpty (block)) - sectorTypes[block.getBlock ()] = sectorType; + if (!disk.isBlockEmpty (block)) + sectorTypes[block.getBlockNo ()] = sectorType; DirectoryEntry parent = findParent (entry); if (parent == null) @@ -166,8 +166,8 @@ public class CPMDisk extends AbstractFormattedDisk public DataSource getFormattedSector (DiskAddress da) // ---------------------------------------------------------------------------------// { - SectorType type = sectorTypes[da.getBlock ()]; - byte[] buffer = disk.readSector (da); + SectorType type = sectorTypes[da.getBlockNo ()]; + byte[] buffer = disk.readBlock (da); if (type == catalogSector) return new CPMCatalogSector (disk, buffer, da); @@ -209,7 +209,7 @@ public class CPMDisk extends AbstractFormattedDisk 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); if ("DIR ERA TYPESAVEREN USER".equals (text)) { @@ -221,7 +221,7 @@ public class CPMDisk extends AbstractFormattedDisk 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) if (bufferContainsAll (buffer, (byte) 0xE5)) diff --git a/src/com/bytezone/diskbrowser/cpm/DirectoryEntry.java b/src/com/bytezone/diskbrowser/cpm/DirectoryEntry.java index 68a56e2..6c3eb2e 100644 --- a/src/com/bytezone/diskbrowser/cpm/DirectoryEntry.java +++ b/src/com/bytezone/diskbrowser/cpm/DirectoryEntry.java @@ -188,7 +188,7 @@ class DirectoryEntry implements AppleFileSource if (appleFile != null) return appleFile; - byte[] buffer = disk.readSectors (blocks); + byte[] buffer = disk.readBlocks (blocks); if (buffer.length == 0) { diff --git a/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java b/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java index c1c6426..838f740 100755 --- a/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java @@ -113,7 +113,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk sectorTypes = new SectorType[disk.getTotalBlocks ()]; for (DiskAddress da : disk) - sectorTypes[da.getBlock ()] = disk.isSectorEmpty (da) ? emptySector : usedSector; + sectorTypes[da.getBlockNo ()] = disk.isBlockEmpty (da) ? emptySector : usedSector; setGridLayout (); } @@ -147,8 +147,8 @@ public abstract class AbstractFormattedDisk implements FormattedDisk break; case 1600: - if (disk.getSectorsPerTrack () == 32) - gridLayout = new Dimension (disk.getSectorsPerTrack (), disk.getTotalTracks ()); + if (disk.getBlocksPerTrack () == 32) + gridLayout = new Dimension (disk.getBlocksPerTrack (), disk.getTotalTracks ()); else gridLayout = new Dimension (16, 100); break; @@ -366,7 +366,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk 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) // ---------------------------------------------------------------------------------// { - if (da.getBlock () == 0 && bootSector != null) + if (da.getBlockNo () == 0 && bootSector != null) return bootSector; - SectorType sectorType = sectorTypes[da.getBlock ()]; - byte[] buffer = disk.readSector (da); - String address = String.format ("%02X %02X", da.getTrack (), da.getSector ()); + SectorType sectorType = sectorTypes[da.getBlockNo ()]; + byte[] buffer = disk.readBlock (da); + + // String address = String.format ("%02X %02X", da.getTrackNo (), da.getSectorNo ()); + String address = String.format ("%02X", da.getBlockNo ()); if (sectorType == emptySector) return new DefaultSector ("Empty sector at " + address, disk, buffer, da); @@ -409,6 +411,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk String name = getSectorFilename (da); if (!name.isEmpty ()) name = " : " + name; + 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) // ---------------------------------------------------------------------------------// { - 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) // ---------------------------------------------------------------------------------// { - return stillAvailable (da.getBlock ()); + return stillAvailable (da.getBlockNo ()); } // ---------------------------------------------------------------------------------// diff --git a/src/com/bytezone/diskbrowser/disk/AppleDisk.java b/src/com/bytezone/diskbrowser/disk/AppleDisk.java index 8e6150f..9604e30 100755 --- a/src/com/bytezone/diskbrowser/disk/AppleDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AppleDisk.java @@ -339,12 +339,12 @@ public class AppleDisk implements Disk for (DiskAddress da : this) // uses blockList.iterator { - byte[] buffer = readSector (da); - hasData[da.getBlock ()] = false; + byte[] buffer = readBlock (da); + hasData[da.getBlockNo ()] = false; for (int i = 0; i < sectorSize; i++) if (buffer[i] != emptyByte) { - hasData[da.getBlock ()] = true; + hasData[da.getBlockNo ()] = true; break; } } @@ -362,13 +362,13 @@ public class AppleDisk implements Disk if (sectorSize == SECTOR_SIZE) // 256 byte sectors { int diskOffset = getBufferOffset (da); - hasData[da.getBlock ()] = check (diskOffset); + hasData[da.getBlockNo ()] = check (diskOffset); } else // 512 byte blocks { int diskOffset1 = getBufferOffset (da, 0); 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 - public int getSectorsPerTrack () + public int getBlocksPerTrack () // ---------------------------------------------------------------------------------// { return trackSize / sectorSize; @@ -429,15 +429,15 @@ public class AppleDisk implements Disk // ---------------------------------------------------------------------------------// @Override - public boolean isSectorEmpty (DiskAddress da) + public boolean isBlockEmpty (DiskAddress da) // ---------------------------------------------------------------------------------// { - return !hasData[da.getBlock ()]; + return !hasData[da.getBlockNo ()]; } // ---------------------------------------------------------------------------------// @Override - public boolean isSectorEmpty (int block) + public boolean isBlockEmpty (int block) // ---------------------------------------------------------------------------------// { return !hasData[block]; @@ -445,10 +445,10 @@ public class AppleDisk implements Disk // ---------------------------------------------------------------------------------// @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 @@ -479,7 +479,7 @@ public class AppleDisk implements Disk // ---------------------------------------------------------------------------------// @Override - public byte[] readSector (DiskAddress da) + public byte[] readBlock (DiskAddress da) // ---------------------------------------------------------------------------------// { byte[] buffer = new byte[sectorSize]; @@ -492,7 +492,7 @@ public class AppleDisk implements Disk // ---------------------------------------------------------------------------------// @Override - public byte[] readSectors (List daList) + public byte[] readBlocks (List daList) // ---------------------------------------------------------------------------------// { byte[] buffer = new byte[daList.size () * sectorSize]; @@ -500,7 +500,7 @@ public class AppleDisk implements Disk for (DiskAddress da : daList) { // 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); ptr += sectorSize; } @@ -509,23 +509,23 @@ public class AppleDisk implements Disk // ---------------------------------------------------------------------------------// @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 - public byte[] readSector (int block) + public byte[] readBlock (int block) // ---------------------------------------------------------------------------------// { - return readSector (getDiskAddress (block)); + return readBlock (getDiskAddress (block)); } // ---------------------------------------------------------------------------------// @Override - public void writeSector (DiskAddress da, byte[] buffer) + public void writeBlock (DiskAddress da, byte[] buffer) // ---------------------------------------------------------------------------------// { writeBuffer (da, buffer); @@ -644,7 +644,7 @@ public class AppleDisk implements Disk 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; - return da.getTrack () * trackSize - + interleaveSector[interleave][da.getSector ()] * SECTOR_SIZE; + return da.getTrackNo () * trackSize + + interleaveSector[interleave][da.getSectorNo ()] * SECTOR_SIZE; } // ---------------------------------------------------------------------------------// @@ -720,8 +720,8 @@ public class AppleDisk implements Disk assert seq == 0 || seq == 1; - return da.getTrack () * trackSize - + interleaveSector[interleave][da.getSector () * 2 + seq] * SECTOR_SIZE; + return da.getTrackNo () * trackSize + + interleaveSector[interleave][da.getSectorNo () * 2 + seq] * SECTOR_SIZE; } // ---------------------------------------------------------------------------------// @@ -807,7 +807,7 @@ public class AppleDisk implements Disk public long getBootChecksum () // ---------------------------------------------------------------------------------// { - byte[] buffer = readSector (0, 0); + byte[] buffer = readBlock (0, 0); Checksum checksum = new CRC32 (); checksum.update (buffer, 0, buffer.length); return checksum.getValue (); diff --git a/src/com/bytezone/diskbrowser/disk/AppleDiskAddress.java b/src/com/bytezone/diskbrowser/disk/AppleDiskAddress.java index e185565..25c74b2 100755 --- a/src/com/bytezone/diskbrowser/disk/AppleDiskAddress.java +++ b/src/com/bytezone/diskbrowser/disk/AppleDiskAddress.java @@ -17,7 +17,7 @@ public class AppleDiskAddress implements DiskAddress { this.owner = owner; this.block = block; - int sectorsPerTrack = owner.getSectorsPerTrack (); + int sectorsPerTrack = owner.getBlocksPerTrack (); if (sectorsPerTrack == 0) { track = 0; @@ -38,7 +38,7 @@ public class AppleDiskAddress implements DiskAddress zeroFlag = (track & 0x40) != 0; this.track = track & 0x3F; 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) // ---------------------------------------------------------------------------------// { - return this.block - that.getBlock (); + return this.block - that.getBlockNo (); } // ---------------------------------------------------------------------------------// @@ -63,12 +63,12 @@ public class AppleDiskAddress implements DiskAddress { if (that == null) return false; - return this.block == that.getBlock (); + return this.block == that.getBlockNo (); } // ---------------------------------------------------------------------------------// @Override - public int getBlock () + public int getBlockNo () // ---------------------------------------------------------------------------------// { return block; @@ -76,7 +76,7 @@ public class AppleDiskAddress implements DiskAddress // ---------------------------------------------------------------------------------// @Override - public int getSector () + public int getSectorNo () // ---------------------------------------------------------------------------------// { return sector; @@ -84,7 +84,7 @@ public class AppleDiskAddress implements DiskAddress // ---------------------------------------------------------------------------------// @Override - public int getTrack () + public int getTrackNo () // ---------------------------------------------------------------------------------// { return track; diff --git a/src/com/bytezone/diskbrowser/disk/DefaultAppleFileSource.java b/src/com/bytezone/diskbrowser/disk/DefaultAppleFileSource.java index 7c9d0d4..d5724ff 100755 --- a/src/com/bytezone/diskbrowser/disk/DefaultAppleFileSource.java +++ b/src/com/bytezone/diskbrowser/disk/DefaultAppleFileSource.java @@ -50,7 +50,7 @@ public class DefaultAppleFileSource implements AppleFileSource this (title, file, owner); this.blocks = blocks; 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; if (file instanceof DefaultDataSource) - ((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks); + ((DefaultDataSource) file).buffer = owner.getDisk ().readBlocks (blocks); } // ---------------------------------------------------------------------------------// diff --git a/src/com/bytezone/diskbrowser/disk/Disk.java b/src/com/bytezone/diskbrowser/disk/Disk.java index d66406b..f91bcbd 100755 --- a/src/com/bytezone/diskbrowser/disk/Disk.java +++ b/src/com/bytezone/diskbrowser/disk/Disk.java @@ -22,7 +22,7 @@ public interface Disk extends Iterable public int getTrackSize (); // bytes per track - 4096 - public int getSectorsPerTrack (); // 8 or 16 + public int getBlocksPerTrack (); // 8 or 16 public void setInterleave (int interleave); @@ -34,21 +34,21 @@ public interface Disk extends Iterable 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 daList); + public byte[] readBlocks (List 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); diff --git a/src/com/bytezone/diskbrowser/disk/DiskAddress.java b/src/com/bytezone/diskbrowser/disk/DiskAddress.java index 46e5d59..eab52df 100755 --- a/src/com/bytezone/diskbrowser/disk/DiskAddress.java +++ b/src/com/bytezone/diskbrowser/disk/DiskAddress.java @@ -4,21 +4,21 @@ package com.bytezone.diskbrowser.disk; public interface DiskAddress extends Comparable // -----------------------------------------------------------------------------------// { - public int getBlock (); + public int getBlockNo (); - public int getTrack (); + public int getTrackNo (); - public int getSector (); + public int getSectorNo (); public Disk getDisk (); public boolean matches (DiskAddress other); // ---------------------------------------------------------------------------------// - public default byte[] readSector () + public default byte[] readBlock () // ---------------------------------------------------------------------------------// { - return getDisk ().readSector (this); + return getDisk ().readBlock (this); } // ---------------------------------------------------------------------------------// diff --git a/src/com/bytezone/diskbrowser/disk/SectorList.java b/src/com/bytezone/diskbrowser/disk/SectorList.java index dcae6fd..aa6f192 100755 --- a/src/com/bytezone/diskbrowser/disk/SectorList.java +++ b/src/com/bytezone/diskbrowser/disk/SectorList.java @@ -28,7 +28,7 @@ public class SectorList extends AbstractFile { if (!disk.isValidAddress (da)) break; - byte[] tempBuffer = disk.readSector (da); + byte[] tempBuffer = disk.readBlock (da); System.arraycopy (tempBuffer, 0, buffer, ptr, disk.getBlockSize ()); ptr += disk.getBlockSize (); } @@ -50,7 +50,7 @@ public class SectorList extends AbstractFile if (owner == null) owner = ""; 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 (); diff --git a/src/com/bytezone/diskbrowser/disk/SectorListConverter.java b/src/com/bytezone/diskbrowser/disk/SectorListConverter.java index 13b7772..12cb7b1 100644 --- a/src/com/bytezone/diskbrowser/disk/SectorListConverter.java +++ b/src/com/bytezone/diskbrowser/disk/SectorListConverter.java @@ -45,7 +45,7 @@ public class SectorListConverter for (DiskAddress da : sectors) { - if (da.getBlock () == firstBlock + 1 + runLength) + if (da.getBlockNo () == firstBlock + 1 + runLength) { ++runLength; continue; @@ -54,7 +54,7 @@ public class SectorListConverter if (firstBlock >= 0) addToText (text, firstBlock, runLength); - firstBlock = da.getBlock (); + firstBlock = da.getBlockNo (); runLength = 0; } addToText (text, firstBlock, runLength); diff --git a/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java b/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java index 4648619..06fda30 100644 --- a/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java +++ b/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java @@ -57,7 +57,10 @@ abstract class AbstractCatalogEntry implements AppleFileSource this.disk = dosDisk.getDisk (); this.catalogSectorDA = catalogSector; + name = getName ("", entryBuffer); reportedSize = HexFormatter.unsignedShort (entryBuffer, 33); + if (reportedSize == 0) + System.out.printf ("%s size 0%n", name); int type = entryBuffer[2] & 0x7F; locked = (entryBuffer[2] & 0x80) != 0; @@ -81,13 +84,12 @@ abstract class AbstractCatalogEntry implements AppleFileSource else System.out.println ("Unknown file type : " + type); - name = getName ("", entryBuffer); if (dosDisk.getVersion () >= 0x41) lastModified = Utility.getDateTime (entryBuffer, 0x1B); // CATALOG command only formats the LO byte - see Beneath Apple DOS pp4-6 - String base = String.format ("%s%s %03d ", (locked) ? "*" : " ", getFileType (), - (entryBuffer[33] & 0xFF)); + String base = + String.format ("%s%s %03d ", (locked) ? "*" : " ", getFileType (), reportedSize); catalogName = getName (base, entryBuffer).replace ("^", ""); } @@ -96,9 +98,11 @@ abstract class AbstractCatalogEntry implements AppleFileSource // ---------------------------------------------------------------------------------// { StringBuilder text = new StringBuilder (base); + int max = buffer[0] == (byte) 0xFF ? 32 : 33; if (dosDisk.getVersion () >= 0x41) max = 27; + for (int i = 3; i < max; i++) { int c = buffer[i] & 0xFF; @@ -115,8 +119,10 @@ abstract class AbstractCatalogEntry implements AppleFileSource else text.append ((char) c); // standard ascii } + while (text.length () > 0 && text.charAt (text.length () - 1) == ' ') text.deleteCharAt (text.length () - 1); // rtrim() + return text.toString (); } @@ -167,7 +173,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource if (appleFile != null) return appleFile; - byte[] buffer = disk.readSectors (dataSectors); + byte[] buffer = disk.readBlocks (dataSectors); int reportedLength; if (buffer.length == 0) { @@ -240,7 +246,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource appleFile = new DoubleHiResImage (name, exactBuffer); else if (link != null) { - byte[] auxBuffer = link.disk.readSectors (link.dataSectors); + byte[] auxBuffer = link.disk.readBlocks (link.dataSectors); byte[] exactAuxBuffer = getExactBuffer (auxBuffer); if (name.endsWith (".AUX")) appleFile = new DoubleHiResImage (name, exactAuxBuffer, exactBuffer); diff --git a/src/com/bytezone/diskbrowser/dos/CatalogEntry.java b/src/com/bytezone/diskbrowser/dos/CatalogEntry.java index 495bd2b..0303173 100644 --- a/src/com/bytezone/diskbrowser/dos/CatalogEntry.java +++ b/src/com/bytezone/diskbrowser/dos/CatalogEntry.java @@ -19,18 +19,19 @@ class CatalogEntry extends AbstractCatalogEntry { 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 DiskAddress da = disk.getDiskAddress (entryBuffer[0], entryBuffer[1]); // 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 (isValidCatalogSector (da)) - dosDisk.sectorTypes[da.getBlock ()] = dosDisk.tsListSector; + dosDisk.sectorTypes[da.getBlockNo ()] = dosDisk.tsListSector; else { System.out.printf ("Attempt to assign invalid TS sector " + ": %s from %s%n", @@ -46,7 +47,7 @@ class CatalogEntry extends AbstractCatalogEntry break; } tsSectors.add (da); - byte[] sectorBuffer = disk.readSector (da); + byte[] sectorBuffer = disk.readBlock (da); int startPtr = 12; // 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 ()); break loop; } - if (da.getBlock () == 0 && !((AppleDiskAddress) da).zeroFlag ()) + if (da.getBlockNo () == 0 && !((AppleDiskAddress) da).zeroFlag ()) { if (fileType != FileType.Text) break; @@ -80,7 +81,7 @@ class CatalogEntry extends AbstractCatalogEntry { dataSectors.add (da); if (dosDisk.stillAvailable (da)) - dosDisk.sectorTypes[da.getBlock ()] = dosDisk.dataSector; + dosDisk.sectorTypes[da.getBlockNo ()] = dosDisk.dataSector; else { System.out @@ -125,7 +126,7 @@ class CatalogEntry extends AbstractCatalogEntry } 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) { case IntegerBasic: @@ -144,13 +145,13 @@ class CatalogEntry extends AbstractCatalogEntry private boolean isValidCatalogSector (DiskAddress da) // ---------------------------------------------------------------------------------// { - byte[] buffer = da.readSector (); + byte[] buffer = da.readBlock (); if (!da.getDisk ().isValidAddress (buffer[1], buffer[2])) return false; if (buffer[3] != 0 || buffer[4] != 0) // not supposed to be used // 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 true; diff --git a/src/com/bytezone/diskbrowser/dos/DeletedCatalogEntry.java b/src/com/bytezone/diskbrowser/dos/DeletedCatalogEntry.java index 40b9a84..3330039 100644 --- a/src/com/bytezone/diskbrowser/dos/DeletedCatalogEntry.java +++ b/src/com/bytezone/diskbrowser/dos/DeletedCatalogEntry.java @@ -42,7 +42,7 @@ class DeletedCatalogEntry extends AbstractCatalogEntry } int totalBlocks = 0; - if (reportedSize <= 1 || !disk.isValidAddress (da.getTrack (), da.getSector ())) + if (reportedSize <= 1 || !disk.isValidAddress (da.getTrackNo (), da.getSectorNo ())) { if (debug) System.out.println ("invalid catalog entry"); @@ -51,7 +51,7 @@ class DeletedCatalogEntry extends AbstractCatalogEntry } // 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)) { @@ -61,16 +61,16 @@ class DeletedCatalogEntry extends AbstractCatalogEntry tsSectors.add (da); totalBlocks++; - byte[] sectorBuffer = disk.readSector (da); + byte[] sectorBuffer = disk.readBlock (da); for (int i = 12, max = disk.getBlockSize (); i < max; i += 2) { da = getValidAddress (sectorBuffer, i); if (da == null) break loop; - if (da.getBlock () > 0 && debug) + if (da.getBlockNo () > 0 && debug) System.out.println (da); - if (da.getBlock () > 0 || ((AppleDiskAddress) da).zeroFlag ()) + if (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ()) { if (!dosDisk.stillAvailable (da)) { diff --git a/src/com/bytezone/diskbrowser/dos/DosDisk.java b/src/com/bytezone/diskbrowser/dos/DosDisk.java index 36e7944..9d06684 100755 --- a/src/com/bytezone/diskbrowser/dos/DosDisk.java +++ b/src/com/bytezone/diskbrowser/dos/DosDisk.java @@ -71,20 +71,20 @@ public class DosDisk extends AbstractFormattedDisk sectorTypesList.add (dataSector); 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); da = disk.getDiskAddress (CATALOG_TRACK, VTOC_SECTOR); - sectorBuffer = disk.readSector (da); // VTOC + sectorBuffer = disk.readBlock (da); // VTOC dosVTOCSector = new DosVTOCSector (this, disk, sectorBuffer, da); - sectorTypes[da.getBlock ()] = vtocSector; + sectorTypes[da.getBlockNo ()] = vtocSector; DiskAddress catalogStart = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]); if (dosVTOCSector.sectorSize != disk.getBlockSize ()) System.out.printf ("%s - invalid sector size : %d%n", disk.getFile ().getName (), dosVTOCSector.sectorSize); - if (dosVTOCSector.maxSectors != disk.getSectorsPerTrack ()) + if (dosVTOCSector.maxSectors != disk.getBlocksPerTrack ()) System.out.printf ("%s - invalid sectors per track : %d%n", disk.getFile ().getName (), dosVTOCSector.maxSectors); @@ -105,12 +105,12 @@ public class DosDisk extends AbstractFormattedDisk rootNode.add (volumeNode); // flag the catalog sectors before any file mistakenly grabs them - da = disk.getDiskAddress (catalogStart.getBlock ()); + da = disk.getDiskAddress (catalogStart.getBlockNo ()); do { if (!disk.isValidAddress (da)) break; - sectorBuffer = disk.readSector (da); + sectorBuffer = disk.readBlock (da); if (!disk.isValidAddress (sectorBuffer[1], sectorBuffer[2])) break; @@ -123,7 +123,7 @@ public class DosDisk extends AbstractFormattedDisk // break; // } - sectorTypes[da.getBlock ()] = catalogSector; + sectorTypes[da.getBlockNo ()] = catalogSector; int track = sectorBuffer[1] & 0xFF; int sector = sectorBuffer[2] & 0xFF; @@ -132,15 +132,15 @@ public class DosDisk extends AbstractFormattedDisk da = disk.getDiskAddress (track, sector); - } while (da.getBlock () != 0); + } while (da.getBlockNo () != 0); // same loop, but now all the catalog sectors are properly flagged - da = disk.getDiskAddress (catalogStart.getBlock ()); + da = disk.getDiskAddress (catalogStart.getBlockNo ()); do { if (!disk.isValidAddress (da)) break; - sectorBuffer = disk.readSector (da); + sectorBuffer = disk.readBlock (da); if (!disk.isValidAddress (sectorBuffer[1], sectorBuffer[2])) break; @@ -186,7 +186,7 @@ public class DosDisk extends AbstractFormattedDisk da = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]); - } while (da.getBlock () != 0); + } while (da.getBlockNo () != 0); // link double hi-res files for (AppleFileSource fe : fileEntries) @@ -210,7 +210,7 @@ public class DosDisk extends AbstractFormattedDisk int lastDosSector = dosVTOCSector.maxSectors * 3; // first three tracks for (DiskAddress da2 : disk) { - int blockNo = da2.getBlock (); + int blockNo = da2.getBlockNo (); if (blockNo < lastDosSector) // in the DOS region { if (freeBlocks.get (blockNo)) // according to the VTOC @@ -277,7 +277,7 @@ public class DosDisk extends AbstractFormattedDisk return true; } - if (disk.getSectorsPerTrack () > 16) + if (disk.getBlocksPerTrack () > 16) return false; int[] cb = new int[3]; @@ -342,7 +342,7 @@ public class DosDisk extends AbstractFormattedDisk 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 // 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 da = disk.getDiskAddress (catalogStart.getBlock ()); + DiskAddress da = disk.getDiskAddress (catalogStart.getBlockNo ()); List catalogAddresses = new ArrayList<> (); do @@ -408,7 +408,7 @@ public class DosDisk extends AbstractFormattedDisk return 0; } - buffer = disk.readSector (da); + buffer = disk.readBlock (da); if (!disk.isValidAddress (buffer[1], buffer[2])) { if (debug) @@ -420,7 +420,7 @@ public class DosDisk extends AbstractFormattedDisk da = disk.getDiskAddress (buffer[1], buffer[2]); - } while (da.getBlock () != 0); + } while (da.getBlockNo () != 0); if (debug) System.out.printf ("Catalog blocks: %d%n", catalogAddresses.size ()); @@ -432,7 +432,7 @@ public class DosDisk extends AbstractFormattedDisk // ---------------------------------------------------------------------------------// { for (DiskAddress diskAddress : catalogAddresses) - if (diskAddress.getBlock () == da.getBlock ()) + if (diskAddress.getBlockNo () == da.getBlockNo ()) return true; return false; } @@ -460,14 +460,14 @@ public class DosDisk extends AbstractFormattedDisk public DataSource getFormattedSector (DiskAddress da) // ---------------------------------------------------------------------------------// { - SectorType type = sectorTypes[da.getBlock ()]; + SectorType type = sectorTypes[da.getBlockNo ()]; if (type == vtocSector) return dosVTOCSector; - if (da.getBlock () == 0) + if (da.getBlockNo () == 0) return bootSector; - byte[] buffer = disk.readSector (da); - String address = String.format ("%02X %02X", da.getTrack (), da.getSector ()); + byte[] buffer = disk.readBlock (da); + String address = String.format ("%02X %02X", da.getTrackNo (), da.getSectorNo ()); if (type == tsListSector) return new DosTSListSector (getSectorFilename (da), disk, buffer, da); diff --git a/src/com/bytezone/diskbrowser/dos/DosTSListSector.java b/src/com/bytezone/diskbrowser/dos/DosTSListSector.java index 543d566..f71a762 100755 --- a/src/com/bytezone/diskbrowser/dos/DosTSListSector.java +++ b/src/com/bytezone/diskbrowser/dos/DosTSListSector.java @@ -36,7 +36,7 @@ class DosTSListSector extends AbstractSector break; // throw exception? } - if (da.getBlock () > 0 && dosDisk.stillAvailable (da)) + if (da.getBlockNo () > 0 && dosDisk.stillAvailable (da)) { System.out.println ("Invalid sector address : " + da); break; // throw exception? @@ -72,8 +72,8 @@ class DosTSListSector extends AbstractSector if ((buffer[3] != 0 || buffer[4] != 0) // not supposed to be used // Diags2E.dsk stores its own sector address here - && (diskAddress.getTrack () == (buffer[3] & 0xFF) - && diskAddress.getSector () == (buffer[4] & 0xFF))) + && (diskAddress.getTrackNo () == (buffer[3] & 0xFF) + && diskAddress.getSectorNo () == (buffer[4] & 0xFF))) addText (text, buffer, 3, 2, "Self-reference"); else addText (text, buffer, 3, 2, "Not used"); diff --git a/src/com/bytezone/diskbrowser/dos/DosVTOCSector.java b/src/com/bytezone/diskbrowser/dos/DosVTOCSector.java index 7c00acf..a4b0d2e 100755 --- a/src/com/bytezone/diskbrowser/dos/DosVTOCSector.java +++ b/src/com/bytezone/diskbrowser/dos/DosVTOCSector.java @@ -76,7 +76,7 @@ class DosVTOCSector extends AbstractSector addTextAndDecimal (text, buffer, 53, 1, "Maximum sectors"); addTextAndDecimal (text, buffer, 54, 2, "Bytes per sector"); - boolean bootSectorEmpty = parentDisk.getDisk ().isSectorEmpty (0); + boolean bootSectorEmpty = parentDisk.getDisk ().isBlockEmpty (0); int firstSector = 0x38; int max = maxTracks * 4 + firstSector; 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, 0x36, 2, "Bytes per sector"); - boolean bootSectorEmpty = parentDisk.getDisk ().isSectorEmpty (0); + boolean bootSectorEmpty = parentDisk.getDisk ().isBlockEmpty (0); int firstSector = 0x38; int max = maxTracks * 4 + firstSector; for (int i = firstSector; i < max; i += 4) diff --git a/src/com/bytezone/diskbrowser/gui/DiskLayoutPanel.java b/src/com/bytezone/diskbrowser/gui/DiskLayoutPanel.java index 3701eb6..7c0902d 100644 --- a/src/com/bytezone/diskbrowser/gui/DiskLayoutPanel.java +++ b/src/com/bytezone/diskbrowser/gui/DiskLayoutPanel.java @@ -183,8 +183,8 @@ class DiskLayoutPanel extends JPanel public Rectangle getLocation (DiskAddress da) { - int y = da.getBlock () / grid.width; - int x = da.getBlock () % grid.width; + int y = da.getBlockNo () / grid.width; + int x = da.getBlockNo () % grid.width; Rectangle r = new Rectangle (x * block.width, y * block.height, block.width, block.height); return r; diff --git a/src/com/bytezone/diskbrowser/gui/DiskLayoutSelection.java b/src/com/bytezone/diskbrowser/gui/DiskLayoutSelection.java index 77911b5..66bfb2b 100755 --- a/src/com/bytezone/diskbrowser/gui/DiskLayoutSelection.java +++ b/src/com/bytezone/diskbrowser/gui/DiskLayoutSelection.java @@ -97,28 +97,28 @@ class DiskLayoutSelection implements Iterable switch (e.getKeyCode ()) { case KeyEvent.VK_LEFT: - int block = first.getBlock () - 1; + int block = first.getBlockNo () - 1; if (block < 0) block = totalBlocks - 1; addHighlight (disk.getDiskAddress (block)); break; case KeyEvent.VK_RIGHT: - block = last.getBlock () + 1; + block = last.getBlockNo () + 1; if (block >= totalBlocks) block = 0; addHighlight (disk.getDiskAddress (block)); break; case KeyEvent.VK_UP: - block = first.getBlock () - rowSize; + block = first.getBlockNo () - rowSize; if (block < 0) block += totalBlocks; addHighlight (disk.getDiskAddress (block)); break; case KeyEvent.VK_DOWN: - block = last.getBlock () + rowSize; + block = last.getBlockNo () + rowSize; if (block >= totalBlocks) block -= totalBlocks; addHighlight (disk.getDiskAddress (block)); @@ -169,7 +169,7 @@ class DiskLayoutSelection implements Iterable highlights.clear (); if (list != null) 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); } @@ -177,8 +177,8 @@ class DiskLayoutSelection implements Iterable private boolean checkContiguous () // ---------------------------------------------------------------------------------// { - int range = highlights.get (highlights.size () - 1).getBlock () - - highlights.get (0).getBlock () + 1; + int range = highlights.get (highlights.size () - 1).getBlockNo () + - highlights.get (0).getBlockNo () + 1; return (range == highlights.size ()); } @@ -189,16 +189,16 @@ class DiskLayoutSelection implements Iterable int lo, hi; // 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 (); - hi = highlights.get (0).getBlock () - 1; + lo = da.getBlockNo (); + hi = highlights.get (0).getBlockNo () - 1; } else // No, must be extending at the end { - lo = highlights.get (highlights.size () - 1).getBlock () + 1; - hi = da.getBlock (); + lo = highlights.get (highlights.size () - 1).getBlockNo () + 1; + hi = da.getBlockNo (); } for (int i = lo; i <= hi; i++) @@ -210,8 +210,8 @@ class DiskLayoutSelection implements Iterable // ---------------------------------------------------------------------------------// { // If we are outside the discontiguous range, just extend as usual - if (da.getBlock () < highlights.get (0).getBlock () - || da.getBlock () > highlights.get (highlights.size () - 1).getBlock ()) + if (da.getBlockNo () < highlights.get (0).getBlockNo () + || da.getBlockNo () > highlights.get (highlights.size () - 1).getBlockNo ()) { extendHighlights (disk, da); return; diff --git a/src/com/bytezone/diskbrowser/gui/SaveSectorsAction.java b/src/com/bytezone/diskbrowser/gui/SaveSectorsAction.java index 0c45654..d344f55 100644 --- a/src/com/bytezone/diskbrowser/gui/SaveSectorsAction.java +++ b/src/com/bytezone/diskbrowser/gui/SaveSectorsAction.java @@ -36,7 +36,7 @@ class SaveSectorsAction extends DefaultAction implements SectorSelectionListener return; } byte[] buffer = - event.getFormattedDisk ().getDisk ().readSectors (event.getSectors ()); + event.getFormattedDisk ().getDisk ().readBlocks (event.getSectors ()); JFileChooser fileChooser = new JFileChooser (); fileChooser.setDialogTitle ("Save sectors"); diff --git a/src/com/bytezone/diskbrowser/infocom/InfocomDisk.java b/src/com/bytezone/diskbrowser/infocom/InfocomDisk.java index 09d9728..6f8e92b 100755 --- a/src/com/bytezone/diskbrowser/infocom/InfocomDisk.java +++ b/src/com/bytezone/diskbrowser/infocom/InfocomDisk.java @@ -54,7 +54,7 @@ public class InfocomDisk extends AbstractFormattedDisk 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 if (false) @@ -131,7 +131,7 @@ public class InfocomDisk extends AbstractFormattedDisk for (int track = 0; track < 3; track++) for (int sector = 0; sector < 16; sector++) - if (!disk.isSectorEmpty (track, sector)) + if (!disk.isBlockEmpty (track, sector)) sectorTypes[track * 16 + sector] = bootSector; } @@ -148,7 +148,7 @@ public class InfocomDisk extends AbstractFormattedDisk while (blockNo <= blockTo) { blocks.add (disk.getDiskAddress (blockNo)); - if (!disk.isSectorEmpty (blockNo)) + if (!disk.isBlockEmpty (blockNo)) sectorTypes[blockNo] = type; blockNo++; } @@ -164,11 +164,11 @@ public class InfocomDisk extends AbstractFormattedDisk int fileSize = 0; for (DiskAddress da : disk) { - if (da.getBlock () > startBlock && disk.isSectorEmpty (da)) + if (da.getBlockNo () > startBlock && disk.isBlockEmpty (da)) { System.out.println ("Empty : " + da); - buffer = disk.readSector (da.getBlock () - 1); - fileSize = (da.getBlock () - 48) * disk.getBlockSize (); + buffer = disk.readBlock (da.getBlockNo () - 1); + fileSize = (da.getBlockNo () - 48) * disk.getBlockSize (); break; } } @@ -193,7 +193,7 @@ public class InfocomDisk extends AbstractFormattedDisk for (int track = 3, ptr = 0; track < 35; track++) 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; if (spaceLeft <= BLOCK_SIZE) { @@ -247,7 +247,7 @@ public class InfocomDisk extends AbstractFormattedDisk public static boolean checkFormat (AppleDisk disk) // ---------------------------------------------------------------------------------// { - byte[] buffer = disk.readSector (3, 0); + byte[] buffer = disk.readBlock (3, 0); int version = buffer[0] & 0xFF; int highMemory = HexFormatter.intValue (buffer[5], buffer[4]); diff --git a/src/com/bytezone/diskbrowser/pascal/FileEntry.java b/src/com/bytezone/diskbrowser/pascal/FileEntry.java index f7d814e..ab9541d 100644 --- a/src/com/bytezone/diskbrowser/pascal/FileEntry.java +++ b/src/com/bytezone/diskbrowser/pascal/FileEntry.java @@ -120,7 +120,7 @@ public class FileEntry extends CatalogEntry private byte[] getExactBuffer () // ---------------------------------------------------------------------------------// { - byte[] buffer = parent.getDisk ().readSectors (blocks); + byte[] buffer = parent.getDisk ().readBlocks (blocks); byte[] exactBuffer; if (buffer.length > 0 && bytesUsedInLastBlock < 512) diff --git a/src/com/bytezone/diskbrowser/pascal/PascalDisk.java b/src/com/bytezone/diskbrowser/pascal/PascalDisk.java index 0870136..f50f144 100755 --- a/src/com/bytezone/diskbrowser/pascal/PascalDisk.java +++ b/src/com/bytezone/diskbrowser/pascal/PascalDisk.java @@ -65,10 +65,10 @@ public class PascalDisk extends AbstractFormattedDisk sectorTypesList.add (badSector); List 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++) - if (!disk.isSectorEmpty (i)) + if (!disk.isBlockEmpty (i)) { sectorTypes[i] = diskBootSector; freeBlocks.set (i, false); @@ -77,7 +77,7 @@ public class PascalDisk extends AbstractFormattedDisk for (int i = 2; i < disk.getTotalBlocks (); i++) freeBlocks.set (i, true); - byte[] buffer = disk.readSector (2); + byte[] buffer = disk.readBlock (2); byte[] data = new byte[CATALOG_ENTRY_SIZE]; System.arraycopy (buffer, 0, data, 0, CATALOG_ENTRY_SIZE); volumeEntry = new VolumeEntry (this, data); @@ -91,20 +91,20 @@ public class PascalDisk extends AbstractFormattedDisk for (int i = 2; i < max; i++) { DiskAddress da = disk.getDiskAddress (i); - if (!disk.isSectorEmpty (da)) + if (!disk.isBlockEmpty (da)) sectorTypes[i] = catalogSector; sectors.add (da); freeBlocks.set (i, false); } diskCatalogSector = - new PascalCatalogSector (disk, disk.readSectors (sectors), sectors); + new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors); // read the catalog List addresses = new ArrayList<> (); for (int i = 2; i < max; 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?) 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) // ---------------------------------------------------------------------------------// { - byte[] buffer = disk.readSector (2); + byte[] buffer = disk.readBlock (2); int nameLength = buffer[6] & 0xFF; if (nameLength < 1 || nameLength > 7) { @@ -187,7 +187,7 @@ public class PascalDisk extends AbstractFormattedDisk List addresses = new ArrayList<> (); for (int i = 2; i < to; i++) addresses.add (disk.getDiskAddress (i)); - buffer = disk.readSectors (addresses); + buffer = disk.readBlocks (addresses); int files = HexFormatter.intValue (buffer[16], buffer[17]); if (files < 0 || files > 77) @@ -228,14 +228,14 @@ public class PascalDisk extends AbstractFormattedDisk public DataSource getFormattedSector (DiskAddress da) // ---------------------------------------------------------------------------------// { - SectorType st = sectorTypes[da.getBlock ()]; + SectorType st = sectorTypes[da.getBlockNo ()]; if (st == diskBootSector) return bootSector; if (st == catalogSector) return diskCatalogSector; String name = getSectorFilename (da); 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); } diff --git a/src/com/bytezone/diskbrowser/pascal/VolumeEntry.java b/src/com/bytezone/diskbrowser/pascal/VolumeEntry.java index 36b2ded..ff1543e 100644 --- a/src/com/bytezone/diskbrowser/pascal/VolumeEntry.java +++ b/src/com/bytezone/diskbrowser/pascal/VolumeEntry.java @@ -30,7 +30,7 @@ class VolumeEntry extends CatalogEntry if (file != null) return file; - byte[] buffer = parent.getDisk ().readSectors (blocks); + byte[] buffer = parent.getDisk ().readBlocks (blocks); file = new DefaultAppleFile (name, buffer); return file; diff --git a/src/com/bytezone/diskbrowser/prodos/FileEntry.java b/src/com/bytezone/diskbrowser/prodos/FileEntry.java index 5cca2a7..73bb46a 100755 --- a/src/com/bytezone/diskbrowser/prodos/FileEntry.java +++ b/src/com/bytezone/diskbrowser/prodos/FileEntry.java @@ -102,7 +102,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants if (diskAddress == null) break; dataBlocks.add (diskAddress); - byte[] buffer = disk.readSector (block); + byte[] buffer = disk.readBlock (block); block = HexFormatter.unsignedShort (buffer, 2); } while (block > 0); break; @@ -125,7 +125,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants parentDisk.setSectorType (keyPtr, parentDisk.extendedKeySector); 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) for (int i = 0; i < 512; i += 256) @@ -194,7 +194,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants parentDisk.setSectorType (blockPtr, parentDisk.indexSector); indexBlocks.add (disk.getDiskAddress (blockPtr)); - byte[] buffer = disk.readSector (blockPtr); + byte[] buffer = disk.readBlock (blockPtr); for (int i = 0; i < 256; i++) { 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); indexBlocks.add (disk.getDiskAddress (keyPtr)); - byte[] buffer = disk.readSector (keyPtr); // master index + byte[] buffer = disk.readBlock (keyPtr); // master index int highest = 0x80; while (highest-- > 0) // decrement after test @@ -537,7 +537,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants List addresses = new ArrayList<> (); int logicalBlock = 0; - byte[] mainIndexBuffer = disk.readSector (keyPtr); + byte[] mainIndexBuffer = disk.readBlock (keyPtr); for (int i = 0; i < 256; i++) { int indexBlock = @@ -548,7 +548,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants { if (addresses.size () > 0) { - byte[] tempBuffer = disk.readSectors (addresses); + byte[] tempBuffer = disk.readBlocks (addresses); buffers.add ( new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ())); addresses.clear (); @@ -603,24 +603,24 @@ class FileEntry extends CatalogEntry implements ProdosConstants case SEEDLING: case SAPLING: case TREE: - return disk.readSectors (dataBlocks); + return disk.readBlocks (dataBlocks); case SUBDIRECTORY: byte[] fullBuffer = new byte[dataBlocks.size () * BLOCK_ENTRY_SIZE]; int offset = 0; for (DiskAddress da : dataBlocks) { - byte[] buffer = disk.readSector (da); + byte[] buffer = disk.readBlock (da); System.arraycopy (buffer, 4, fullBuffer, offset, BLOCK_ENTRY_SIZE); offset += BLOCK_ENTRY_SIZE; } return fullBuffer; 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: - return disk.readSectors (dataBlocks); + return disk.readBlocks (dataBlocks); default: System.out.println ("Unknown storage type in getBuffer : " + storageType); @@ -633,7 +633,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants List buffers, int logicalBlock) // ---------------------------------------------------------------------------------// { - byte[] indexBuffer = disk.readSector (indexBlock); + byte[] indexBuffer = disk.readBlock (indexBlock); for (int j = 0; j < 256; j++) { int block = HexFormatter.intValue (indexBuffer[j], indexBuffer[j + 256]); @@ -641,7 +641,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants addresses.add (disk.getDiskAddress (block)); else if (addresses.size () > 0) { - byte[] tempBuffer = disk.readSectors (addresses); + byte[] tempBuffer = disk.readBlocks (addresses); buffers .add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ())); addresses.clear (); diff --git a/src/com/bytezone/diskbrowser/prodos/ProdosBitMapSector.java b/src/com/bytezone/diskbrowser/prodos/ProdosBitMapSector.java index ea55972..7ef31eb 100755 --- a/src/com/bytezone/diskbrowser/prodos/ProdosBitMapSector.java +++ b/src/com/bytezone/diskbrowser/prodos/ProdosBitMapSector.java @@ -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 // more than a single block int relativeBlock = - diskAddress.getBlock () - parent.getVolumeDirectoryHeader ().bitMapBlock; + diskAddress.getBlockNo () - parent.getVolumeDirectoryHeader ().bitMapBlock; int startBit = relativeBlock * 4096; // int endBit = startBit + 4096; if (startBit >= grid.width * grid.height) diff --git a/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java b/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java index 6a61430..0928075 100755 --- a/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java +++ b/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java @@ -70,11 +70,11 @@ public class ProdosDisk extends AbstractFormattedDisk sectorTypesList.add (extendedKeySector); for (int block = 0; block < 2; block++) - if (!disk.isSectorEmpty (disk.getDiskAddress (block))) + if (!disk.isBlockEmpty (disk.getDiskAddress (block))) sectorTypes[block] = dosSector; DiskAddress da = disk.getDiskAddress (0); - byte[] buffer = disk.readSector (da); + byte[] buffer = disk.readBlock (da); bootSector = new BootSector (disk, buffer, "Prodos", da); DefaultMutableTreeNode root = getCatalogTreeRoot (); @@ -86,7 +86,7 @@ public class ProdosDisk extends AbstractFormattedDisk for (DiskAddress da2 : disk) { - int blockNo = da2.getBlock (); + int blockNo = da2.getBlockNo (); if (freeBlocks.get (blockNo)) { if (!stillAvailable (da2)) @@ -113,8 +113,8 @@ public class ProdosDisk extends AbstractFormattedDisk do { - byte[] sectorBuffer = disk.readSector (block); - if (!disk.isSectorEmpty (block)) + byte[] sectorBuffer = disk.readBlock (block); + if (!disk.isBlockEmpty (block)) sectorTypes[block] = currentSectorType; int max = disk.getBlockSize () - ProdosConstants.ENTRY_SIZE; @@ -135,7 +135,7 @@ public class ProdosDisk extends AbstractFormattedDisk assert vdh.entryLength == ProdosConstants.ENTRY_SIZE; headerEntries.add (vdh); currentSectorType = catalogSector; - if (!disk.isSectorEmpty (block)) + if (!disk.isBlockEmpty (block)) sectorTypes[block] = currentSectorType; for (int i = 0; i < vdh.totalBitMapBlocks; i++) sectorTypes[vdh.bitMapBlock + i] = volumeMapSector; @@ -147,7 +147,7 @@ public class ProdosDisk extends AbstractFormattedDisk localHeader = new SubDirectoryHeader (this, entry, parent); headerEntries.add (localHeader); currentSectorType = subcatalogSector; - if (!disk.isSectorEmpty (block)) + if (!disk.isBlockEmpty (block)) sectorTypes[block] = currentSectorType; break; @@ -221,7 +221,7 @@ public class ProdosDisk extends AbstractFormattedDisk public static boolean checkFormat (AppleDisk disk) // ---------------------------------------------------------------------------------// { - byte[] buffer = disk.readSector (2); // Prodos KEY BLOCK + byte[] buffer = disk.readBlock (2); // Prodos KEY BLOCK if (debug) { System.out.println (HexFormatter.format (buffer)); @@ -271,11 +271,11 @@ public class ProdosDisk extends AbstractFormattedDisk public DataSource getFormattedSector (DiskAddress da) // ---------------------------------------------------------------------------------// { - if (da.getBlock () == 0) + if (da.getBlockNo () == 0) return bootSector; - byte[] buffer = disk.readSector (da); - SectorType type = sectorTypes[da.getBlock ()]; + byte[] buffer = disk.readBlock (da); + SectorType type = sectorTypes[da.getBlockNo ()]; if (type == catalogSector || type == subcatalogSector) return new ProdosCatalogSector (this, disk, buffer, da); diff --git a/src/com/bytezone/diskbrowser/prodos/VolumeDirectoryHeader.java b/src/com/bytezone/diskbrowser/prodos/VolumeDirectoryHeader.java index 8f912dc..57a1388 100755 --- a/src/com/bytezone/diskbrowser/prodos/VolumeDirectoryHeader.java +++ b/src/com/bytezone/diskbrowser/prodos/VolumeDirectoryHeader.java @@ -39,7 +39,7 @@ class VolumeDirectoryHeader extends DirectoryHeader do { dataBlocks.add (disk.getDiskAddress (block)); - byte[] buffer = disk.readSector (block); + byte[] buffer = disk.readBlock (block); block = HexFormatter.unsignedShort (buffer, 2); } while (block > 0); @@ -47,13 +47,13 @@ class VolumeDirectoryHeader extends DirectoryHeader // int bitMapBytes = totalBlocks / 8; // one bit per block int bitMapBytes = (totalBlocks - 1) / 8 + 1; // one bit per block 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 ptr = 0; for (block = bitMapBlock; block <= lastBitMapBlock; block++) { - byte[] temp = disk.readSector (block); + byte[] temp = disk.readBlock (block); int bytesToCopy = buffer.length - ptr; if (bytesToCopy > temp.length) bytesToCopy = temp.length; @@ -101,7 +101,7 @@ class VolumeDirectoryHeader extends DirectoryHeader int block = 2; do { - byte[] buf = disk.readSector (block); + byte[] buf = disk.readBlock (block); blockList.add (buf); block = HexFormatter.intValue (buf[2], buf[3]); // next block } while (block > 0); diff --git a/src/com/bytezone/diskbrowser/wizardry/Header.java b/src/com/bytezone/diskbrowser/wizardry/Header.java index b3f352f..18e06b8 100755 --- a/src/com/bytezone/diskbrowser/wizardry/Header.java +++ b/src/com/bytezone/diskbrowser/wizardry/Header.java @@ -112,7 +112,7 @@ class Header StringBuilder text = new StringBuilder (scenarioTitle + "\n\n"); int ptr = 106; - byte[] buffer = owner.getDisk ().readSector (da); + byte[] buffer = owner.getDisk ().readBlock (da); while (buffer[ptr] != -1) { text.append (HexFormatter.getPascalString (buffer, ptr) + "\n"); @@ -143,7 +143,7 @@ class Header List blocks = new ArrayList<> (); blocks.add (da); - byte[] buffer = owner.getDisk ().readSector (da); + byte[] buffer = owner.getDisk ().readBlock (da); String text = printChars (buffer, 0); DefaultAppleFileSource dafs = new DefaultAppleFileSource (title, text, owner); @@ -163,7 +163,7 @@ class Header int level = 1; 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[] spells = text.split ("\n"); for (String s : spells) diff --git a/src/com/bytezone/diskbrowser/wizardry/Relocator.java b/src/com/bytezone/diskbrowser/wizardry/Relocator.java index 9086449..6c8a1a0 100644 --- a/src/com/bytezone/diskbrowser/wizardry/Relocator.java +++ b/src/com/bytezone/diskbrowser/wizardry/Relocator.java @@ -72,9 +72,9 @@ public class Relocator extends AbstractFile if (diskNo > 0) { Disk disk = dataDisks[diskNo]; - byte[] temp = disk.readSector (diskOffsets[logicalBlock]); + byte[] temp = disk.readBlock (diskOffsets[logicalBlock]); DiskAddress da = master.getDiskAddress (logicalBlock); - master.writeSector (da, temp); + master.writeBlock (da, temp); // if (da.getBlock () == 0x126) // System.out.println (HexFormatter.format (buffer)); // if (Utility.find (temp, key1)) diff --git a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java index 5517c60..d3dfa54 100644 --- a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java +++ b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java @@ -356,12 +356,12 @@ public class Wizardry4BootDisk extends PascalDisk { // Wizardry IV or V boot code 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)) return false; - buffer = disk.readSector (1); + buffer = disk.readBlock (1); if (buffer[510] != 1 || buffer[511] != 0) // disk #1 return false; diff --git a/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java b/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java index 75f60b2..9c65a0c 100755 --- a/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java +++ b/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java @@ -135,7 +135,7 @@ public class WizardryScenarioDisk extends PascalDisk 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]); if (totalFiles != 3) return false; @@ -196,7 +196,7 @@ public class WizardryScenarioDisk extends PascalDisk { List blocks = getTwoBlocks (sd, i, sectors); nodeSectors.addAll (blocks); - byte[] buffer = disk.readSectors (blocks); + byte[] buffer = disk.readBlocks (blocks); seq = addReward (buffer, blocks, node, seq); } @@ -243,7 +243,7 @@ public class WizardryScenarioDisk extends PascalDisk { List blocks = getTwoBlocks (sd, i, sectors); nodeSectors.addAll (blocks); - byte[] buffer = disk.readSectors (blocks); + byte[] buffer = disk.readBlocks (blocks); addCharacters (buffer, blocks, node); } @@ -306,7 +306,7 @@ public class WizardryScenarioDisk extends PascalDisk { List blocks = getTwoBlocks (sd, i, sectors); nodeSectors.addAll (blocks); - byte[] buffer = disk.readSectors (blocks); + byte[] buffer = disk.readBlocks (blocks); addMonsters (buffer, blocks, node); } @@ -363,7 +363,7 @@ public class WizardryScenarioDisk extends PascalDisk { List blocks = getTwoBlocks (sd, i, sectors); nodeSectors.addAll (blocks); - byte[] buffer = disk.readSectors (blocks); + byte[] buffer = disk.readBlocks (blocks); addItems (buffer, blocks, node); } @@ -419,7 +419,7 @@ public class WizardryScenarioDisk extends PascalDisk SpellType spellType = SpellType.MAGE; for (DiskAddress da : blocks) { - byte[] buffer = disk.readSector (da); + byte[] buffer = disk.readBlock (da); int level = 1; int ptr = -1; while (ptr < 255) @@ -459,7 +459,7 @@ public class WizardryScenarioDisk extends PascalDisk for (DiskAddress da : sectors) { - byte[] tempBuffer = disk.readSector (da); + byte[] tempBuffer = disk.readBlock (da); System.arraycopy (tempBuffer, 0, buffer, offset, max); offset += max; } @@ -518,7 +518,7 @@ public class WizardryScenarioDisk extends PascalDisk { List blocks = getTwoBlocks (sd, i, sectors); nodeSectors.addAll (blocks); - byte[] buffer = disk.readSectors (blocks); + byte[] buffer = disk.readBlocks (blocks); byte[] data2 = new byte[896]; System.arraycopy (buffer, 0, data2, 0, data2.length); // System.out.println (HexFormatter.format (data2)); @@ -554,7 +554,7 @@ public class WizardryScenarioDisk extends PascalDisk { DiskAddress da = sectors.get (sd.dataOffset + i); nodeSectors.add (da); - byte[] buffer = disk.readSector (da); + byte[] buffer = disk.readBlock (da); byte[] exactBuffer = new byte[480]; System.arraycopy (buffer, 0, exactBuffer, 0, exactBuffer.length); @@ -596,7 +596,7 @@ public class WizardryScenarioDisk extends PascalDisk { List blocks = getTwoBlocks (sd, i, sectors); nodeSectors.addAll (blocks); - byte[] buffer = disk.readSectors (blocks); + byte[] buffer = disk.readBlocks (blocks); for (int ptr = 0; ptr <= buffer.length; ptr += 78) {