From 1642954f8b7756806b9c6febe09026dadd839dd2 Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Sat, 6 Aug 2016 20:00:01 +1000 Subject: [PATCH] fixed extra boot sectors --- .../diskbrowser/applefile/BootSector.java | 15 +++++++------ .../diskbrowser/disk/AbstractSector.java | 21 ++++++++----------- .../bytezone/diskbrowser/gui/DataPanel.java | 4 ++-- .../pascal/PascalCatalogSector.java | 2 +- .../diskbrowser/pascal/PascalDisk.java | 9 ++++---- 5 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/com/bytezone/diskbrowser/applefile/BootSector.java b/src/com/bytezone/diskbrowser/applefile/BootSector.java index 28506bb..18afd93 100644 --- a/src/com/bytezone/diskbrowser/applefile/BootSector.java +++ b/src/com/bytezone/diskbrowser/applefile/BootSector.java @@ -1,7 +1,5 @@ package com.bytezone.diskbrowser.applefile; -import java.util.List; - import com.bytezone.diskbrowser.disk.AbstractSector; import com.bytezone.diskbrowser.disk.Disk; import com.bytezone.diskbrowser.disk.DiskAddress; @@ -22,10 +20,10 @@ public class BootSector extends AbstractSector this.name = name; } - public BootSector (Disk disk, byte[] buffer, String name, - List diskAddressList) + public BootSector (Disk disk, byte[] buffer, String name)//, + // List diskAddressList) { - super (disk, buffer, diskAddressList); + super (disk, buffer);//, diskAddressList); this.name = name; } @@ -58,10 +56,11 @@ public class BootSector extends AbstractSector byte[] newBuffer = new byte[buffer.length * 2]; System.arraycopy (buffer, 0, newBuffer, 0, buffer.length); - byte[] buf = disk.readSector (1); - System.arraycopy (buf, 0, newBuffer, buf.length, buf.length); + // byte[] buf = disk.readSector (1); + // System.arraycopy (buf, 0, newBuffer, buf.length, buf.length); - buffer = newBuffer; + // this was doubling the size of Pascal boot blocks - 06/08/2016 + // buffer = newBuffer; assembler1 = new AssemblerProgram (name + " Boot Loader", buffer, 0x00, 0); } } diff --git a/src/com/bytezone/diskbrowser/disk/AbstractSector.java b/src/com/bytezone/diskbrowser/disk/AbstractSector.java index b53b1ff..2c06894 100755 --- a/src/com/bytezone/diskbrowser/disk/AbstractSector.java +++ b/src/com/bytezone/diskbrowser/disk/AbstractSector.java @@ -1,7 +1,6 @@ package com.bytezone.diskbrowser.disk; import java.awt.image.BufferedImage; -import java.util.List; import javax.swing.JComponent; import javax.swing.JPanel; @@ -15,10 +14,10 @@ public abstract class AbstractSector implements DataSource private static String newLine = String.format ("%n"); private static String newLine2 = newLine + newLine; - public byte[] buffer; + final public byte[] buffer; protected Disk disk; protected DiskAddress diskAddress; - protected List diskAddressList; + // private List diskAddressList; AssemblerProgram assembler; String description; @@ -29,11 +28,11 @@ public abstract class AbstractSector implements DataSource this.diskAddress = diskAddress; } - public AbstractSector (Disk disk, byte[] buffer, List diskAddressList) + public AbstractSector (Disk disk, byte[] buffer)//, List diskAddressList) { this.buffer = buffer; this.disk = disk; - this.diskAddressList = diskAddressList; + // this.diskAddressList = diskAddressList; } @Override @@ -95,22 +94,20 @@ public abstract class AbstractSector implements DataSource switch (size) { case 1: - text.append (String.format ("%03X %02X %s%n", offset, b[offset], - desc)); + text.append ( + String.format ("%03X %02X %s%n", offset, b[offset], desc)); break; case 2: text.append (String.format ("%03X-%03X %02X %02X %s%n", offset, - offset + 1, b[offset], b[offset + 1], desc)); + offset + 1, b[offset], b[offset + 1], desc)); break; case 3: text.append (String.format ("%03X-%03X %02X %02X %02X %s%n", offset, - offset + 2, b[offset], b[offset + 1], b[offset + 2], - desc)); + offset + 2, b[offset], b[offset + 1], b[offset + 2], desc)); break; case 4: text.append (String.format ("%03X-%03X %02X %02X %02X %02X %s%n", offset, - offset + 3, b[offset], b[offset + 1], b[offset + 2], - b[offset + 3], desc)); + offset + 3, b[offset], b[offset + 1], b[offset + 2], b[offset + 3], desc)); break; default: System.out.println ("Invalid length : " + size); diff --git a/src/com/bytezone/diskbrowser/gui/DataPanel.java b/src/com/bytezone/diskbrowser/gui/DataPanel.java index d611843..4a8d63a 100755 --- a/src/com/bytezone/diskbrowser/gui/DataPanel.java +++ b/src/com/bytezone/diskbrowser/gui/DataPanel.java @@ -284,7 +284,7 @@ class DataPanel extends JTabbedPane { Graphics2D g2 = image.createGraphics (); g2.setRenderingHint (RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + RenderingHints.VALUE_ANTIALIAS_ON); width = image.getWidth (); height = image.getHeight (); } @@ -314,7 +314,7 @@ class DataPanel extends JTabbedPane Graphics2D g2 = ((Graphics2D) g); g2.transform (AffineTransform.getScaleInstance (scale, scale)); g2.drawImage (image, (getWidth () - image.getWidth () * scale) / 2 / scale, 4, - this); + this); } } } diff --git a/src/com/bytezone/diskbrowser/pascal/PascalCatalogSector.java b/src/com/bytezone/diskbrowser/pascal/PascalCatalogSector.java index 2b595fb..84f45b1 100644 --- a/src/com/bytezone/diskbrowser/pascal/PascalCatalogSector.java +++ b/src/com/bytezone/diskbrowser/pascal/PascalCatalogSector.java @@ -17,7 +17,7 @@ class PascalCatalogSector extends AbstractSector public PascalCatalogSector (Disk disk, byte[] buffer, List diskAddress) { - super (disk, buffer, diskAddress); + super (disk, buffer);//, diskAddress); } @Override diff --git a/src/com/bytezone/diskbrowser/pascal/PascalDisk.java b/src/com/bytezone/diskbrowser/pascal/PascalDisk.java index bd745eb..d43ded9 100755 --- a/src/com/bytezone/diskbrowser/pascal/PascalDisk.java +++ b/src/com/bytezone/diskbrowser/pascal/PascalDisk.java @@ -52,10 +52,9 @@ public class PascalDisk extends AbstractFormattedDisk // DiskAddress da = disk.getDiskAddress (0); List blocks = disk.getDiskAddressList (0, 1); - byte[] buffer = disk.readSectors (blocks); - this.bootSector = new BootSector (disk, buffer, "Pascal", blocks); + this.bootSector = new BootSector (disk, disk.readSectors (blocks), "Pascal");//, blocks); - buffer = disk.readSector (2); + byte[] buffer = disk.readSector (2); byte[] data = new byte[CATALOG_ENTRY_SIZE]; System.arraycopy (buffer, 0, data, 0, CATALOG_ENTRY_SIZE); @@ -81,8 +80,8 @@ public class PascalDisk extends AbstractFormattedDisk freeBlocks.set (i, false); } - buffer = disk.readSectors (sectors); - diskCatalogSector = new PascalCatalogSector (disk, buffer, sectors); + diskCatalogSector = + new PascalCatalogSector (disk, disk.readSectors (sectors), sectors); DefaultMutableTreeNode root = getCatalogTreeRoot (); DefaultMutableTreeNode volumeNode = new DefaultMutableTreeNode (volumeEntry);