Diamond mining

This commit is contained in:
Denis Molony 2020-02-02 20:17:49 +10:00
parent befdf002f1
commit 644540668c
54 changed files with 279 additions and 237 deletions

View File

@ -470,7 +470,7 @@ public class ApplesoftBasicProgram extends BasicProgram
private class SourceLine private class SourceLine
{ {
List<SubLine> sublines = new ArrayList<SubLine> (); List<SubLine> sublines = new ArrayList<> ();
int lineNumber; int lineNumber;
int linePtr; int linePtr;
int length; int length;

View File

@ -201,10 +201,9 @@ public class AssemblerProgram extends AbstractFile
private List<AssemblerStatement> getLines () private List<AssemblerStatement> getLines ()
{ {
List<AssemblerStatement> lines = new ArrayList<AssemblerStatement> (); List<AssemblerStatement> lines = new ArrayList<> ();
Map<Integer, AssemblerStatement> linesMap = Map<Integer, AssemblerStatement> linesMap = new HashMap<> ();
new HashMap<Integer, AssemblerStatement> (); List<Integer> targets = new ArrayList<> ();
List<Integer> targets = new ArrayList<Integer> ();
int ptr = executeOffset; int ptr = executeOffset;
int address = loadAddress + executeOffset; int address = loadAddress + executeOffset;

View File

@ -15,7 +15,7 @@ public class FileTypeDescriptorTable extends AbstractFile
int indexRecordSize; int indexRecordSize;
int offsetToIdx; int offsetToIdx;
private final List<IndexRecord> indexRecords = new ArrayList<IndexRecord> (); private final List<IndexRecord> indexRecords = new ArrayList<> ();
public FileTypeDescriptorTable (String name, byte[] buffer) public FileTypeDescriptorTable (String name, byte[] buffer)
{ {

View File

@ -10,7 +10,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class PascalCode extends AbstractFile public class PascalCode extends AbstractFile
implements PascalConstants, Iterable<PascalSegment> implements PascalConstants, Iterable<PascalSegment>
{ {
private final List<PascalSegment> segments = new ArrayList<PascalSegment> (16); private final List<PascalSegment> segments = new ArrayList<> (16);
private final String comment; private final String comment;
// private final int blockOffset; // private final int blockOffset;
// private final Relocator relocator; // private final Relocator relocator;

View File

@ -20,7 +20,7 @@ public class PascalCodeStatement implements PascalConstants
int ptr; // temp int ptr; // temp
byte[] buffer; byte[] buffer;
boolean jumpTarget; boolean jumpTarget;
List<Jump> jumps = new ArrayList<Jump> (); List<Jump> jumps = new ArrayList<> ();
public PascalCodeStatement (byte[] buffer, int ptr, int procPtr) public PascalCodeStatement (byte[] buffer, int ptr, int procPtr)
{ {

View File

@ -12,7 +12,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class SHRPictureFile1 extends HiResImage public class SHRPictureFile1 extends HiResImage
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
private final List<Block> blocks = new ArrayList<Block> (); private final List<Block> blocks = new ArrayList<> ();
private Main mainBlock; private Main mainBlock;
private Multipal multipalBlock; private Multipal multipalBlock;
private final boolean debug = false; private final boolean debug = false;

View File

@ -7,7 +7,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class SimpleText2 extends AbstractFile public class SimpleText2 extends AbstractFile
{ {
List<Integer> lineStarts = new ArrayList<Integer> (); List<Integer> lineStarts = new ArrayList<> ();
int loadAddress; int loadAddress;
boolean showByte = false; boolean showByte = false;

View File

@ -38,8 +38,8 @@ public class AppleworksADBFile extends AbstractFile
private final int[] continuation = new int[3]; private final int[] continuation = new int[3];
private final String[] comparison = new String[3]; private final String[] comparison = new String[3];
private final List<Report> reports = new ArrayList<Report> (); private final List<Report> reports = new ArrayList<> ();
final List<Record> records = new ArrayList<Record> (); final List<Record> records = new ArrayList<> ();
private final Record standardRecord; private final Record standardRecord;
public AppleworksADBFile (String name, byte[] buffer) public AppleworksADBFile (String name, byte[] buffer)

View File

@ -9,7 +9,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class AppleworksSSFile extends AbstractFile public class AppleworksSSFile extends AbstractFile
{ {
Header header; Header header;
List<Row> rows = new ArrayList<Row> (); List<Row> rows = new ArrayList<> ();
public AppleworksSSFile (String name, byte[] buffer) public AppleworksSSFile (String name, byte[] buffer)
{ {
@ -248,7 +248,7 @@ public class AppleworksSSFile extends AbstractFile
private class Row private class Row
{ {
private final int rowNumber; private final int rowNumber;
private final List<Cell> cells = new ArrayList<Cell> (); private final List<Cell> cells = new ArrayList<> ();
public Row (int ptr) public Row (int ptr)
{ {

View File

@ -11,7 +11,7 @@ class Record
{ {
AppleworksADBFile parent; AppleworksADBFile parent;
int length; int length;
List<String> items = new ArrayList<String> (); List<String> items = new ArrayList<> ();
Map<Integer, Double> calculatedItems = new HashMap<Integer, Double> ();// move to TableReport Map<Integer, Double> calculatedItems = new HashMap<Integer, Double> ();// move to TableReport
public Record (AppleworksADBFile parent, byte[] buffer, int ptr) public Record (AppleworksADBFile parent, byte[] buffer, int ptr)

View File

@ -29,8 +29,8 @@ public class DirectoryEntry implements AppleFileSource
private final int recordsUsed; // records used in this extent private final int recordsUsed; // records used in this extent
private final byte[] blockList = new byte[16]; // allocation blocks used private final byte[] blockList = new byte[16]; // allocation blocks used
private final List<DirectoryEntry> entries = new ArrayList<DirectoryEntry> (); private final List<DirectoryEntry> entries = new ArrayList<> ();
private final List<DiskAddress> blocks = new ArrayList<DiskAddress> (); private final List<DiskAddress> blocks = new ArrayList<> ();
private final boolean readOnly; private final boolean readOnly;
private final boolean systemFile; private final boolean systemFile;

View File

@ -533,7 +533,7 @@ public class AppleDisk implements Disk
@Override @Override
public List<DiskAddress> getDiskAddressList (int... blocks) public List<DiskAddress> getDiskAddressList (int... blocks)
{ {
List<DiskAddress> addressList = new ArrayList<DiskAddress> (); List<DiskAddress> addressList = new ArrayList<> ();
for (int block : blocks) for (int block : blocks)
{ {
@ -696,7 +696,7 @@ public class AppleDisk implements Disk
{ {
if (blockList == null) if (blockList == null)
{ {
blockList = new ArrayList<DiskAddress> (blocks); blockList = new ArrayList<> (blocks);
for (int block = 0; block < blocks; block++) for (int block = 0; block < blocks; block++)
blockList.add (new AppleDiskAddress (this, block)); blockList.add (new AppleDiskAddress (this, block));
} }

View File

@ -10,7 +10,7 @@ public class SectorListConverter
public SectorListConverter (String text, Disk disk) public SectorListConverter (String text, Disk disk)
{ {
sectors = new ArrayList<DiskAddress> (); sectors = new ArrayList<> ();
sectorText = text; sectorText = text;
String[] blocks = text.split (";"); String[] blocks = text.split (";");

View File

@ -4,7 +4,22 @@ import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.bytezone.diskbrowser.applefile.*; import com.bytezone.diskbrowser.applefile.AppleFileSource;
import com.bytezone.diskbrowser.applefile.ApplesoftBasicProgram;
import com.bytezone.diskbrowser.applefile.AssemblerProgram;
import com.bytezone.diskbrowser.applefile.DefaultAppleFile;
import com.bytezone.diskbrowser.applefile.DoubleHiResImage;
import com.bytezone.diskbrowser.applefile.ErrorMessageFile;
import com.bytezone.diskbrowser.applefile.FontFile;
import com.bytezone.diskbrowser.applefile.HiResImage;
import com.bytezone.diskbrowser.applefile.IntegerBasicProgram;
import com.bytezone.diskbrowser.applefile.MerlinSource;
import com.bytezone.diskbrowser.applefile.OriginalHiResImage;
import com.bytezone.diskbrowser.applefile.PrintShopGraphic;
import com.bytezone.diskbrowser.applefile.ShapeTable;
import com.bytezone.diskbrowser.applefile.SimpleText2;
import com.bytezone.diskbrowser.applefile.TextFile;
import com.bytezone.diskbrowser.applefile.VisicalcFile;
import com.bytezone.diskbrowser.disk.Disk; import com.bytezone.diskbrowser.disk.Disk;
import com.bytezone.diskbrowser.disk.DiskAddress; import com.bytezone.diskbrowser.disk.DiskAddress;
import com.bytezone.diskbrowser.disk.FormattedDisk; import com.bytezone.diskbrowser.disk.FormattedDisk;
@ -27,8 +42,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
protected LocalDateTime lastModified; protected LocalDateTime lastModified;
protected DiskAddress catalogSectorDA; protected DiskAddress catalogSectorDA;
protected final List<DiskAddress> dataSectors = new ArrayList<DiskAddress> (); protected final List<DiskAddress> dataSectors = new ArrayList<> ();
protected final List<DiskAddress> tsSectors = new ArrayList<DiskAddress> (); protected final List<DiskAddress> tsSectors = new ArrayList<> ();
private CatalogEntry link; private CatalogEntry link;
@ -355,7 +370,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
@Override @Override
public List<DiskAddress> getSectors () public List<DiskAddress> getSectors ()
{ {
List<DiskAddress> sectors = new ArrayList<DiskAddress> (); List<DiskAddress> sectors = new ArrayList<> ();
sectors.add (catalogSectorDA); sectors.add (catalogSectorDA);
sectors.addAll (tsSectors); sectors.addAll (tsSectors);
sectors.addAll (dataSectors); sectors.addAll (dataSectors);

View File

@ -9,7 +9,13 @@ import javax.swing.tree.DefaultMutableTreeNode;
import com.bytezone.diskbrowser.applefile.AppleFileSource; import com.bytezone.diskbrowser.applefile.AppleFileSource;
import com.bytezone.diskbrowser.applefile.BootSector; import com.bytezone.diskbrowser.applefile.BootSector;
import com.bytezone.diskbrowser.disk.*; import com.bytezone.diskbrowser.disk.AbstractFormattedDisk;
import com.bytezone.diskbrowser.disk.AppleDisk;
import com.bytezone.diskbrowser.disk.DefaultAppleFileSource;
import com.bytezone.diskbrowser.disk.DefaultSector;
import com.bytezone.diskbrowser.disk.Disk;
import com.bytezone.diskbrowser.disk.DiskAddress;
import com.bytezone.diskbrowser.disk.SectorType;
import com.bytezone.diskbrowser.gui.DataSource; import com.bytezone.diskbrowser.gui.DataSource;
public class DosDisk extends AbstractFormattedDisk public class DosDisk extends AbstractFormattedDisk
@ -32,7 +38,7 @@ public class DosDisk extends AbstractFormattedDisk
public final SectorType dataSector = new SectorType ("Data", Color.red); public final SectorType dataSector = new SectorType ("Data", Color.red);
public final SectorType dosSector = new SectorType ("DOS", Color.lightGray); public final SectorType dosSector = new SectorType ("DOS", Color.lightGray);
protected List<AppleFileSource> deletedFileEntries = new ArrayList<AppleFileSource> (); protected List<AppleFileSource> deletedFileEntries = new ArrayList<> ();
enum FileType enum FileType
{ {
@ -462,10 +468,10 @@ public class DosDisk extends AbstractFormattedDisk
* *
There were actually three versions of DOS 3.3 that Apple released without There were actually three versions of DOS 3.3 that Apple released without
bumping the version number: bumping the version number:
The first version that was released had FPBASIC and INTBASIC files that were 50 The first version that was released had FPBASIC and INTBASIC files that were 50
sectors in size. sectors in size.
The second version of DOS 3.3, often referred to as DOS 3.3e, appeared at the The second version of DOS 3.3, often referred to as DOS 3.3e, appeared at the
time the Apple IIe was released. In this version, the FPBASIC and INTBASIC files time the Apple IIe was released. In this version, the FPBASIC and INTBASIC files
were 42 sectors in size. The changes introduced at that time included code to turn were 42 sectors in size. The changes introduced at that time included code to turn
@ -473,12 +479,12 @@ public class DosDisk extends AbstractFormattedDisk
command. This fix reportedly introduced an even worse bug, but as the command was command. This fix reportedly introduced an even worse bug, but as the command was
not heavily used it did not make much of an impact on most programmers. The APPEND not heavily used it did not make much of an impact on most programmers. The APPEND
fix was applied by utilizing some formerly unused space in the DOS 3.3 code. fix was applied by utilizing some formerly unused space in the DOS 3.3 code.
The third version of DOS 3.3 appeared just before the first release of ProDOS. The third version of DOS 3.3 appeared just before the first release of ProDOS.
The only mention of this in the press was in the DOSTalk column of Softalk magazine. The only mention of this in the press was in the DOSTalk column of Softalk magazine.
This final version of DOS 3.3 included a different fix for the APPEND bug, using This final version of DOS 3.3 included a different fix for the APPEND bug, using
another bit of unused space in DOS 3.3. another bit of unused space in DOS 3.3.
With regard to the FPBASIC and INTBASIC files: There were three differences between With regard to the FPBASIC and INTBASIC files: There were three differences between
the 50 sector and the 42 sector versions of the INTBASIC file. Firstly, the the 50 sector and the 42 sector versions of the INTBASIC file. Firstly, the
$F800-$FFFF section was removed. This area was the code for the Monitor, and with $F800-$FFFF section was removed. This area was the code for the Monitor, and with

View File

@ -9,7 +9,12 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.*; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumnModel; import javax.swing.table.TableColumnModel;
@ -17,7 +22,7 @@ import com.bytezone.diskbrowser.gui.DuplicateAction.DiskTableSelectionListener;
public class DeleteWindow extends JFrame implements DiskTableSelectionListener public class DeleteWindow extends JFrame implements DiskTableSelectionListener
{ {
private List<DiskDetails> lines = new ArrayList<DiskDetails> (); private List<DiskDetails> lines = new ArrayList<> ();
private final JButton btnHide = new JButton ("Close"); private final JButton btnHide = new JButton ("Close");
private final RootFolderData rootFolderData; private final RootFolderData rootFolderData;

View File

@ -16,8 +16,8 @@ public class DiskDetails
private final String type; private final String type;
private final long size; private final long size;
private final List<DiskDetails> duplicateChecksums = new ArrayList<DiskDetails> (); private final List<DiskDetails> duplicateChecksums = new ArrayList<> ();
private final List<DiskDetails> duplicateNames = new ArrayList<DiskDetails> (); private final List<DiskDetails> duplicateNames = new ArrayList<> ();
private boolean isDuplicateName; private boolean isDuplicateName;
private boolean isDuplicateChecksum; private boolean isDuplicateChecksum;

View File

@ -10,7 +10,7 @@ public class DiskTableModel extends AbstractTableModel
static final String[] headers = static final String[] headers =
{ "Path", "Name", "Type", "Size", "# names", "Checksum", "# checksums" }; { "Path", "Name", "Type", "Size", "# names", "Checksum", "# checksums" };
private final List<TableLine> lines = new ArrayList<DiskTableModel.TableLine> (); private final List<TableLine> lines = new ArrayList<> ();
private final RootFolderData rootFolderData; private final RootFolderData rootFolderData;
public DiskTableModel (RootFolderData rootFolderData) public DiskTableModel (RootFolderData rootFolderData)

View File

@ -12,7 +12,15 @@ import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.*; import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.RowFilter;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import javax.swing.table.JTableHeader; import javax.swing.table.JTableHeader;
@ -33,7 +41,7 @@ public class DisksWindow extends JFrame
private final JButton btnTotals = new JButton ("Totals"); private final JButton btnTotals = new JButton ("Totals");
private final JPanel topPanel = new JPanel (); private final JPanel topPanel = new JPanel ();
private final List<JCheckBox> boxes = new ArrayList<JCheckBox> (); private final List<JCheckBox> boxes = new ArrayList<> ();
private TableRowSorter<DiskTableModel> sorter; private TableRowSorter<DiskTableModel> sorter;
private final CheckBoxActionListener checkBoxActionListener = private final CheckBoxActionListener checkBoxActionListener =
new CheckBoxActionListener (); new CheckBoxActionListener ();

View File

@ -1,6 +1,11 @@
package com.bytezone.diskbrowser.duplicates; package com.bytezone.diskbrowser.duplicates;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
@ -33,8 +38,7 @@ public class RootFolderData implements RootDirectoryChangeListener
public DisksWindow disksWindow; public DisksWindow disksWindow;
public final List<DiskTableSelectionListener> listeners = public final List<DiskTableSelectionListener> listeners = new ArrayList<> ();
new ArrayList<DiskTableSelectionListener> ();
public boolean doChecksums; public boolean doChecksums;
@ -196,7 +200,7 @@ public class RootFolderData implements RootDirectoryChangeListener
public List<DiskDetails> listDuplicates (long checksum) public List<DiskDetails> listDuplicates (long checksum)
{ {
List<DiskDetails> list = new ArrayList<DiskDetails> (); List<DiskDetails> list = new ArrayList<> ();
DiskDetails original = checksumMap.get (checksum); DiskDetails original = checksumMap.get (checksum);
if (original != null) if (original != null)
{ {

View File

@ -35,7 +35,7 @@ abstract class AbstractTab extends JPanel implements Tab
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
private final static Cursor handCursor = new Cursor (Cursor.HAND_CURSOR); private final static Cursor handCursor = new Cursor (Cursor.HAND_CURSOR);
private final List<MouseAdapter> adapters = new ArrayList<MouseAdapter> (); private final List<MouseAdapter> adapters = new ArrayList<> ();
private Font font; private Font font;
private final JScrollPane scrollPane; private final JScrollPane scrollPane;
final DiskAndFileSelector eventHandler; final DiskAndFileSelector eventHandler;

View File

@ -18,7 +18,7 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
public DiskLayoutSelection () public DiskLayoutSelection ()
{ {
highlights = new ArrayList<DiskAddress> (); highlights = new ArrayList<> ();
} }
public void doClick (Disk disk, DiskAddress da, boolean extend, boolean append) public void doClick (Disk disk, DiskAddress da, boolean extend, boolean append)
@ -136,7 +136,7 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
// This must return a copy, or the redo function will get very confused // This must return a copy, or the redo function will get very confused
public List<DiskAddress> getHighlights () public List<DiskAddress> getHighlights ()
{ {
return new ArrayList<DiskAddress> (highlights); return new ArrayList<> (highlights);
} }
public boolean isSelected (DiskAddress da) public boolean isSelected (DiskAddress da)

View File

@ -29,7 +29,7 @@ class Abbreviations extends InfocomAbstractFile
private void populate () private void populate ()
{ {
list = new ArrayList<ZString> (); list = new ArrayList<> ();
for (int i = header.abbreviationsTable; i < header.objectTableOffset; i += 2) for (int i = header.abbreviationsTable; i < header.objectTableOffset; i += 2)
list.add (new ZString (header, header.getWord (i) * 2)); list.add (new ZString (header, header.getWord (i) * 2));

View File

@ -50,7 +50,7 @@ class Dictionary extends AbstractFile
List<WordEntry> wordEntryList = synonymList.get (wordEntry.key); List<WordEntry> wordEntryList = synonymList.get (wordEntry.key);
if (wordEntryList == null) if (wordEntryList == null)
{ {
wordEntryList = new ArrayList<WordEntry> (); wordEntryList = new ArrayList<> ();
synonymList.put (wordEntry.key, wordEntryList); synonymList.put (wordEntry.key, wordEntryList);
} }
wordEntryList.add (wordEntry); wordEntryList.add (wordEntry);
@ -143,7 +143,7 @@ class Dictionary extends AbstractFile
public List<String> getVerbs (int value) public List<String> getVerbs (int value)
{ {
List<String> words = new ArrayList<String> (); List<String> words = new ArrayList<> ();
int ptr = dictionaryPtr + totalSeparators + 4; int ptr = dictionaryPtr + totalSeparators + 4;
for (ZString word : dictionary.values ()) for (ZString word : dictionary.values ())
@ -162,7 +162,7 @@ class Dictionary extends AbstractFile
public List<String> getPrepositions (int value) public List<String> getPrepositions (int value)
{ {
List<String> words = new ArrayList<String> (); List<String> words = new ArrayList<> ();
int ptr = dictionaryPtr + totalSeparators + 4; int ptr = dictionaryPtr + totalSeparators + 4;
for (ZString word : dictionary.values ()) for (ZString word : dictionary.values ())

View File

@ -8,7 +8,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class InfocomAbstractFile extends AbstractFile public class InfocomAbstractFile extends AbstractFile
{ {
protected List<HexBlock> hexBlocks = new ArrayList<HexBlock> (); protected List<HexBlock> hexBlocks = new ArrayList<> ();
public InfocomAbstractFile (String name, byte[] buffer) public InfocomAbstractFile (String name, byte[] buffer)
{ {

View File

@ -70,7 +70,7 @@ public class InfocomDisk extends AbstractFormattedDisk
headerNode = addToTree (root, "Header", header, TYPE_LEAF); headerNode = addToTree (root, "Header", header, TYPE_LEAF);
DefaultAppleFileSource dafs = (DefaultAppleFileSource) headerNode.getUserObject (); DefaultAppleFileSource dafs = (DefaultAppleFileSource) headerNode.getUserObject ();
List<DiskAddress> blocks = new ArrayList<DiskAddress> (); List<DiskAddress> blocks = new ArrayList<> ();
blocks.add (disk.getDiskAddress (3, 0)); blocks.add (disk.getDiskAddress (3, 0));
dafs.setSectors (blocks); dafs.setSectors (blocks);
@ -133,7 +133,7 @@ public class InfocomDisk extends AbstractFormattedDisk
DefaultMutableTreeNode node) DefaultMutableTreeNode node)
{ {
DefaultAppleFileSource dafs = (DefaultAppleFileSource) node.getUserObject (); DefaultAppleFileSource dafs = (DefaultAppleFileSource) node.getUserObject ();
List<DiskAddress> blocks = new ArrayList<DiskAddress> (); List<DiskAddress> blocks = new ArrayList<> ();
int blockNo = sectorFrom / disk.getBlockSize () + 48; int blockNo = sectorFrom / disk.getBlockSize () + 48;
int blockTo = sectorTo / disk.getBlockSize () + 48; int blockTo = sectorTo / disk.getBlockSize () + 48;

View File

@ -123,7 +123,7 @@ class ObjectAnalyser
int propertyNumber; int propertyNumber;
int lo; int lo;
int hi; int hi;
List<Integer> offsets = new ArrayList<Integer> (); List<Integer> offsets = new ArrayList<> ();
public Statistics (int propertyNumber) public Statistics (int propertyNumber)
{ {

View File

@ -32,7 +32,7 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
propertySize = header.globalsOffset - propertyPtr; propertySize = header.globalsOffset - propertyPtr;
tableSize = (propertyPtr - tablePtr); tableSize = (propertyPtr - tablePtr);
int totalObjects = tableSize / ZObject.HEADER_SIZE; int totalObjects = tableSize / ZObject.HEADER_SIZE;
list = new ArrayList<ZObject> (tableSize); list = new ArrayList<> (tableSize);
for (int objectNo = 0; objectNo < totalObjects; objectNo++) for (int objectNo = 0; objectNo < totalObjects; objectNo++)
list.add (new ZObject (null, buffer, tablePtr + objectNo * ZObject.HEADER_SIZE, list.add (new ZObject (null, buffer, tablePtr + objectNo * ZObject.HEADER_SIZE,

View File

@ -11,7 +11,7 @@ import com.bytezone.diskbrowser.disk.FormattedDisk;
class PropertyManager extends AbstractFile class PropertyManager extends AbstractFile
{ {
List<Statistic> list = new ArrayList<Statistic> (); List<Statistic> list = new ArrayList<> ();
Header header; Header header;
public PropertyManager (String name, byte[] buffer, Header header) public PropertyManager (String name, byte[] buffer, Header header)
@ -57,7 +57,7 @@ class PropertyManager extends AbstractFile
private class Statistic private class Statistic
{ {
int id; int id;
List<ZObject> list = new ArrayList<ZObject> (); List<ZObject> list = new ArrayList<> ();
public Statistic (int id) public Statistic (int id)
{ {

View File

@ -8,58 +8,58 @@ import com.bytezone.diskbrowser.infocom.ZObject.Property;
class PropertyTester implements Iterable<Integer> class PropertyTester implements Iterable<Integer>
{ {
List<ZObject> objects; List<ZObject> objects;
List<Condition> conditions = new ArrayList<Condition> (); List<Condition> conditions = new ArrayList<> ();
List<Integer> matchedProperties; List<Integer> matchedProperties;
public PropertyTester (List<ZObject> objects) public PropertyTester (List<ZObject> objects)
{ {
this.objects = objects; this.objects = objects;
} }
public void addTest (Condition test) public void addTest (Condition test)
{ {
conditions.add (test); conditions.add (test);
} }
public void doTests () public void doTests ()
{ {
boolean[] propFail = new boolean[32]; boolean[] propFail = new boolean[32];
int[] propTestCount = new int[32]; int[] propTestCount = new int[32];
matchedProperties = new ArrayList<Integer> (); matchedProperties = new ArrayList<> ();
for (ZObject object : objects) for (ZObject object : objects)
propertyLoop: for (Property property : object.properties) propertyLoop: for (Property property : object.properties)
{ {
if (propFail[property.propertyNumber] || property.length == 0) if (propFail[property.propertyNumber] || property.length == 0)
continue; continue;
for (Condition condition : conditions) for (Condition condition : conditions)
if (!condition.test (property)) if (!condition.test (property))
{ {
propFail[property.propertyNumber] = true; propFail[property.propertyNumber] = true;
continue propertyLoop; continue propertyLoop;
} }
++propTestCount[property.propertyNumber]; ++propTestCount[property.propertyNumber];
} }
for (int i = 1; i < propFail.length; i++) for (int i = 1; i < propFail.length; i++)
if (!propFail[i] && propTestCount[i] > 0) if (!propFail[i] && propTestCount[i] > 0)
matchedProperties.add (i); matchedProperties.add (i);
} }
@Override @Override
public Iterator<Integer> iterator () public Iterator<Integer> iterator ()
{ {
return matchedProperties.iterator (); return matchedProperties.iterator ();
} }
public int totalSuccessfulProperties () public int totalSuccessfulProperties ()
{ {
return matchedProperties.size (); return matchedProperties.size ();
} }
} }
abstract class Condition abstract class Condition
{ {
abstract boolean test (Property property); abstract boolean test (Property property);
} }

View File

@ -13,12 +13,12 @@ class Routine extends InfocomAbstractFile
{ {
int startPtr, length, strings, locals; int startPtr, length, strings, locals;
List<Parameter> parameters = new ArrayList<Parameter> (); List<Parameter> parameters = new ArrayList<> ();
List<Instruction> instructions = new ArrayList<Instruction> (); List<Instruction> instructions = new ArrayList<> ();
List<Integer> calls = new ArrayList<Integer> (); List<Integer> calls = new ArrayList<> ();
List<Integer> calledBy = new ArrayList<Integer> (); List<Integer> calledBy = new ArrayList<> ();
List<Integer> actions = new ArrayList<Integer> (); // not used yet List<Integer> actions = new ArrayList<> (); // not used yet
List<Integer> targets = new ArrayList<Integer> (); List<Integer> targets = new ArrayList<> ();
public Routine (int ptr, Header header, int caller) public Routine (int ptr, Header header, int caller)
{ {

View File

@ -19,7 +19,7 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
private final int propertyTableLength; private final int propertyTableLength;
final int parent, sibling, child; final int parent, sibling, child;
final List<Property> properties = new ArrayList<Property> (); final List<Property> properties = new ArrayList<> ();
final BitSet attributes = new BitSet (32); final BitSet attributes = new BitSet (32);
public ZObject (String name, byte[] buffer, int offset, int id, Header header) public ZObject (String name, byte[] buffer, int offset, int id, Header header)

View File

@ -8,7 +8,7 @@ class LZW
static protected final String[] st = new String[0x1000]; static protected final String[] st = new String[0x1000];
static protected final int TRACK_LENGTH = 0x1000; static protected final int TRACK_LENGTH = 0x1000;
protected final List<byte[]> chunks = new ArrayList<byte[]> (); protected final List<byte[]> chunks = new ArrayList<> ();
protected int volume; protected int volume;
protected byte runLengthChar; protected byte runLengthChar;
protected int crc; protected int crc;

View File

@ -17,8 +17,8 @@ public class NuFX
private final byte[] buffer; private final byte[] buffer;
private final boolean debug = false; private final boolean debug = false;
private final List<Record> records = new ArrayList<Record> (); private final List<Record> records = new ArrayList<> ();
private final List<Thread> threads = new ArrayList<Thread> (); private final List<Thread> threads = new ArrayList<> ();
public NuFX (Path path) throws FileFormatException, IOException public NuFX (Path path) throws FileFormatException, IOException
{ {

View File

@ -20,7 +20,7 @@ public abstract class AbstractValue implements Value
protected boolean bool; protected boolean bool;
protected ValueResult valueResult = ValueResult.VALID; protected ValueResult valueResult = ValueResult.VALID;
protected List<Value> values = new ArrayList<Value> (); protected List<Value> values = new ArrayList<> ();
public AbstractValue (Cell cell, String text) public AbstractValue (Cell cell, String text)
{ {

View File

@ -6,7 +6,7 @@ import java.util.List;
public class ConditionList implements Iterable<Value> public class ConditionList implements Iterable<Value>
{ {
private final List<Value> conditions = new ArrayList<Value> (); private final List<Value> conditions = new ArrayList<> ();
public ConditionList (Cell cell, String text) public ConditionList (Cell cell, String text)
{ {

View File

@ -5,8 +5,8 @@ import java.util.List;
class Expression extends AbstractValue class Expression extends AbstractValue
{ {
private final List<String> operators = new ArrayList<String> (); private final List<String> operators = new ArrayList<> ();
private final List<String> signs = new ArrayList<String> (); private final List<String> signs = new ArrayList<> ();
public Expression (Cell cell, String text) public Expression (Cell cell, String text)
{ {

View File

@ -14,7 +14,7 @@ class Range implements Iterable<Address>
// private static final Pattern addressList = Pattern.compile ("\\(([^,]+(,[^,]+)*)\\)"); // private static final Pattern addressList = Pattern.compile ("\\(([^,]+(,[^,]+)*)\\)");
private Address from, to; private Address from, to;
private final List<Address> range = new ArrayList<Address> (); private final List<Address> range = new ArrayList<> ();
private final Cell cell; private final Cell cell;
private boolean isHorizontal; private boolean isHorizontal;

View File

@ -19,7 +19,7 @@ public class Sheet
private final Map<Integer, Cell> rowOrderCells = new TreeMap<Integer, Cell> (); private final Map<Integer, Cell> rowOrderCells = new TreeMap<Integer, Cell> ();
private final Map<Integer, Cell> columnOrderCells = new TreeMap<Integer, Cell> (); private final Map<Integer, Cell> columnOrderCells = new TreeMap<Integer, Cell> ();
private final List<String> lines = new ArrayList<String> (); private final List<String> lines = new ArrayList<> ();
private final Map<Integer, Integer> columnWidths = new TreeMap<Integer, Integer> (); private final Map<Integer, Integer> columnWidths = new TreeMap<Integer, Integer> ();
private int columnWidth = 9; private int columnWidth = 9;
@ -388,7 +388,7 @@ public class Sheet
if (debug) if (debug)
{ {
List<String> counts = new ArrayList<String> (); List<String> counts = new ArrayList<> ();
for (int i = 0; i < functionTotals.length; i++) for (int i = 0; i < functionTotals.length; i++)
if (functionTotals[i] > 0) if (functionTotals[i] > 0)
{ {

View File

@ -6,7 +6,7 @@ import java.util.List;
public class ValueList implements Iterable<Value> public class ValueList implements Iterable<Value>
{ {
private final List<Value> values = new ArrayList<Value> (); private final List<Value> values = new ArrayList<> ();
private boolean hasRange; private boolean hasRange;
public ValueList (Cell cell, String text) public ValueList (Cell cell, String text)

View File

@ -14,8 +14,8 @@ class Character extends AbstractFile
private final Statistics stats; private final Statistics stats;
int scenario; int scenario;
private final Collection<Spell> spellBook = new ArrayList<Spell> (); private final Collection<Spell> spellBook = new ArrayList<> ();
private final Collection<Baggage> baggageList = new ArrayList<Baggage> (); private final Collection<Baggage> baggageList = new ArrayList<> ();
static String[] races = { "No race", "Human", "Elf", "Dwarf", "Gnome", "Hobbit" }; static String[] races = { "No race", "Human", "Elf", "Dwarf", "Gnome", "Hobbit" };
static String[] alignments = { "Unalign", "Good", "Neutral", "Evil" }; static String[] alignments = { "Unalign", "Good", "Neutral", "Evil" };

View File

@ -30,7 +30,7 @@ class Header
String scenarioTitle; String scenarioTitle;
public int scenarioID; public int scenarioID;
List<ScenarioData> data = new ArrayList<ScenarioData> (8); List<ScenarioData> data = new ArrayList<> (8);
FormattedDisk owner; FormattedDisk owner;
public Header (DefaultMutableTreeNode dataNode, FormattedDisk owner) public Header (DefaultMutableTreeNode dataNode, FormattedDisk owner)
@ -100,7 +100,7 @@ class Header
private void linkText (String title, DiskAddress da, DefaultMutableTreeNode headerNode) private void linkText (String title, DiskAddress da, DefaultMutableTreeNode headerNode)
{ {
List<DiskAddress> blocks = new ArrayList<DiskAddress> (); List<DiskAddress> blocks = new ArrayList<> ();
blocks.add (da); blocks.add (da);
StringBuilder text = new StringBuilder (scenarioTitle + "\n\n"); StringBuilder text = new StringBuilder (scenarioTitle + "\n\n");
@ -132,7 +132,7 @@ class Header
private void linkPictures (String title, DiskAddress da, private void linkPictures (String title, DiskAddress da,
DefaultMutableTreeNode headerNode) DefaultMutableTreeNode headerNode)
{ {
List<DiskAddress> blocks = new ArrayList<DiskAddress> (); List<DiskAddress> blocks = new ArrayList<> ();
blocks.add (da); blocks.add (da);
byte[] buffer = owner.getDisk ().readSector (da); byte[] buffer = owner.getDisk ().readSector (da);
@ -148,7 +148,7 @@ class Header
private void linkSpells (String title, DiskAddress da, private void linkSpells (String title, DiskAddress da,
DefaultMutableTreeNode headerNode) DefaultMutableTreeNode headerNode)
{ {
List<DiskAddress> blocks = new ArrayList<DiskAddress> (); List<DiskAddress> blocks = new ArrayList<> ();
blocks.add (da); blocks.add (da);
int level = 1; int level = 1;
@ -223,7 +223,7 @@ class Header
dataOffset = buffer[offset + 48] & 0xFF; dataOffset = buffer[offset + 48] & 0xFF;
type = seq; type = seq;
this.sectors = new ArrayList<DiskAddress> (totalBlocks); this.sectors = new ArrayList<> (totalBlocks);
for (int i = dataOffset, max = dataOffset + totalBlocks; i < max; i++) for (int i = dataOffset, max = dataOffset + totalBlocks; i < max; i++)
if (i < sectors.size ()) if (i < sectors.size ())
this.sectors.add (sectors.get (i)); this.sectors.add (sectors.get (i));

View File

@ -15,7 +15,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class MazeGridV5 extends AbstractFile public class MazeGridV5 extends AbstractFile
{ {
private final MessageBlock messageBlock; private final MessageBlock messageBlock;
List<MazeGrid> grids = new ArrayList<MazeGrid> (); List<MazeGrid> grids = new ArrayList<> ();
int minX = 9999; int minX = 9999;
int minY = 9999; int minY = 9999;
int maxX = 0; int maxX = 0;

View File

@ -71,8 +71,8 @@ class MazeLevel extends AbstractFile
{ "", "Stairs", "Pit", "Chute", "Spinner", "Darkness", "Teleport", "Ouch", { "", "Stairs", "Pit", "Chute", "Spinner", "Darkness", "Teleport", "Ouch",
"Elevator", "Rock/Water", "Fizzle", "Message/Item", "Monster" }; "Elevator", "Rock/Water", "Fizzle", "Message/Item", "Monster" };
List<MazeAddress> messageList = new ArrayList<MazeAddress> (); List<MazeAddress> messageList = new ArrayList<> ();
List<MazeAddress> monsterList = new ArrayList<MazeAddress> (); List<MazeAddress> monsterList = new ArrayList<> ();
text.append ("\n\nValue Index Contains Table\n"); text.append ("\n\nValue Index Contains Table\n");
for (int j = 0; j < 16; j++) for (int j = 0; j < 16; j++)

View File

@ -7,65 +7,65 @@ import com.bytezone.diskbrowser.applefile.AbstractFile;
abstract class Message extends AbstractFile abstract class Message extends AbstractFile
{ {
private static int nextId = 0; private static int nextId = 0;
protected String message; protected String message;
private final int id; private final int id;
private int totalLines; private int totalLines;
List<String> lines = new ArrayList<String> (); List<String> lines = new ArrayList<> ();
public Message (byte[] buffer) public Message (byte[] buffer)
{ {
super ("Message " + nextId, buffer); super ("Message " + nextId, buffer);
this.id = nextId; this.id = nextId;
int recordLength = 42; int recordLength = 42;
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
for (int ptr = 0; ptr < buffer.length; ptr += recordLength) for (int ptr = 0; ptr < buffer.length; ptr += recordLength)
{ {
nextId++; nextId++;
totalLines++; totalLines++;
String line = getLine (ptr); String line = getLine (ptr);
text.append (line + "\n"); text.append (line + "\n");
lines.add (line); lines.add (line);
} }
text.deleteCharAt (text.length () - 1); text.deleteCharAt (text.length () - 1);
message = text.toString (); message = text.toString ();
} }
protected abstract String getLine (int offset); protected abstract String getLine (int offset);
public boolean match (int messageNum) public boolean match (int messageNum)
{ {
if (id == messageNum) if (id == messageNum)
return true; return true;
// this code is to allow for a bug in scenario #1 // this code is to allow for a bug in scenario #1
if (messageNum > id && messageNum < (id + totalLines)) if (messageNum > id && messageNum < (id + totalLines))
return true; return true;
return false; return false;
} }
@Override @Override
public String getText () public String getText ()
{ {
return message; return message;
} }
public String toHTMLString () public String toHTMLString ()
{ {
StringBuilder message = new StringBuilder (); StringBuilder message = new StringBuilder ();
for (String line : lines) for (String line : lines)
message.append ("&nbsp;" + line + "&nbsp;<br>"); message.append ("&nbsp;" + line + "&nbsp;<br>");
if (message.length () > 0) if (message.length () > 0)
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
message.deleteCharAt (message.length () - 1); // remove <br> tag message.deleteCharAt (message.length () - 1); // remove <br> tag
return message.toString (); return message.toString ();
} }
public static void resetMessageId () public static void resetMessageId ()
{ {
nextId = 0; nextId = 0;
} }
} }

View File

@ -13,8 +13,7 @@ public class MessageBlock extends AbstractFile implements Iterable<MessageDataBl
private final int indexLength; private final int indexLength;
private String text; private String text;
private final List<MessageDataBlock> messageDataBlocks = private final List<MessageDataBlock> messageDataBlocks = new ArrayList<> ();
new ArrayList<MessageDataBlock> ();
public MessageBlock (byte[] buffer, Huffman huffman) public MessageBlock (byte[] buffer, Huffman huffman)
{ {
@ -49,7 +48,7 @@ public class MessageBlock extends AbstractFile implements Iterable<MessageDataBl
public List<String> getMessageLines (int messageNo) public List<String> getMessageLines (int messageNo)
{ {
List<String> lines = new ArrayList<String> (); List<String> lines = new ArrayList<> ();
for (MessageDataBlock messageDataBlock : messageDataBlocks) for (MessageDataBlock messageDataBlock : messageDataBlocks)
{ {

View File

@ -12,7 +12,7 @@ public class MessageDataBlock extends AbstractFile
final int lastMessageNo; final int lastMessageNo;
private final int groupCount; private final int groupCount;
private final List<Message> messages = new ArrayList<Message> (); private final List<Message> messages = new ArrayList<> ();
private final Huffman huffman; private final Huffman huffman;

View File

@ -33,7 +33,7 @@ class Monster extends AbstractFile implements Comparable<Monster>
int resistance; int resistance;
int abilities; int abilities;
public final Dice groupSize, hitPoints; public final Dice groupSize, hitPoints;
List<Dice> damage = new ArrayList<Dice> (); List<Dice> damage = new ArrayList<> ();
static int counter = 0; static int counter = 0;
static boolean debug = true; static boolean debug = true;
@ -45,18 +45,25 @@ class Monster extends AbstractFile implements Comparable<Monster>
{ "Fighter", "Mage", "Priest", "Thief", "Midget", "Giant", "Mythical", "Dragon", { "Fighter", "Mage", "Priest", "Thief", "Midget", "Giant", "Mythical", "Dragon",
"Animal", "Were", "Undead", "Demon", "Insect", "Enchanted" }; "Animal", "Were", "Undead", "Demon", "Insect", "Enchanted" };
private static int[] experience = private static int[] experience = { 55, 235, 415, 230, 380, 620, 840, 520, 550, 350, // 00-09
{ 55, 235, 415, 230, 380, 620, 840, 520, 550, 350, // 00-09 475, 515, 920, 600, 735, 520, 795, 780, 990, 795, // 10-19
475, 515, 920, 600, 735, 520, 795, 780, 990, 795, // 10-19 1360, 1320, 1275, 680, 960, 600, 755, 1120, 2075,
1360, 1320, 1275, 680, 960, 600, 755, 1120, 2075, 870, // 20-29 870, // 20-29
960, 1120, 1120, 2435, 1080, 2280, 975, 875, 1135, 1200, // 30-39 960, 1120, 1120, 2435, 1080, 2280, 975, 875, 1135,
620, 740, 1460, 1245, 960, 1405, 1040, 1220, 1520, 1000, // 40-49 1200, // 30-39
960, 2340, 2160, 2395, 790, 1140, 1235, 1790, 1720, 2240, // 50-59 620, 740, 1460, 1245, 960, 1405, 1040, 1220, 1520,
1475, 1540, 1720, 1900, 1240, 1220, 1020, 20435, 5100, 3515, // 60-69 1000, // 40-49
2115, 2920, 2060, 2140, 1400, 1640, 1280, 4450, 42840, 3300, // 70-79 960, 2340, 2160, 2395, 790, 1140, 1235, 1790, 1720,
40875, 5000, 3300, 2395, 1935, 1600, 3330, 44090, 40840, 5200, // 80-89 2240, // 50-59
4155, 3000, 9200, 3160, 7460, 7320, 15880, 1600, 2200, 1000, 1900 // 90-100 1475, 1540, 1720, 1900, 1240, 1220, 1020, 20435,
}; 5100, 3515, // 60-69
2115, 2920, 2060, 2140, 1400, 1640, 1280, 4450,
42840, 3300, // 70-79
40875, 5000, 3300, 2395, 1935, 1600, 3330, 44090,
40840, 5200, // 80-89
4155, 3000, 9200, 3160, 7460, 7320, 15880, 1600,
2200, 1000, 1900 // 90-100
};
public Monster (String name, byte[] buffer, List<Reward> rewards, public Monster (String name, byte[] buffer, List<Reward> rewards,
List<Monster> monsters) List<Monster> monsters)

View File

@ -12,7 +12,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class Relocator extends AbstractFile public class Relocator extends AbstractFile
{ {
private final int checkByte; private final int checkByte;
private final List<DiskRecord> diskRecords = new ArrayList<DiskRecord> (); private final List<DiskRecord> diskRecords = new ArrayList<> ();
private final int[] diskBlocks = new int[0x800]; private final int[] diskBlocks = new int[0x800];
private final int[] diskOffsets = new int[0x800]; private final int[] diskOffsets = new int[0x800];
@ -92,7 +92,7 @@ public class Relocator extends AbstractFile
text.append ("\n"); text.append ("\n");
} }
List<String> lines = new ArrayList<String> (); List<String> lines = new ArrayList<> ();
String heading = " Logical Size Disk Physical"; String heading = " Logical Size Disk Physical";
String underline = "--------- ---- ---- ---------"; String underline = "--------- ---- ---- ---------";
@ -153,7 +153,7 @@ public class Relocator extends AbstractFile
{ {
int diskNumber; int diskNumber;
int totDiskSegments; int totDiskSegments;
List<DiskSegment> diskSegments = new ArrayList<DiskSegment> (); List<DiskSegment> diskSegments = new ArrayList<> ();
public DiskRecord (byte[] buffer, int ptr) public DiskRecord (byte[] buffer, int ptr)
{ {

View File

@ -13,8 +13,8 @@ class Reward extends AbstractFile
int totalElements; int totalElements;
List<RewardElement> elements; List<RewardElement> elements;
List<Item> items; List<Item> items;
List<Monster> goldMonsters = new ArrayList<Monster> (); List<Monster> goldMonsters = new ArrayList<> ();
List<Monster> chestMonsters = new ArrayList<Monster> (); List<Monster> chestMonsters = new ArrayList<> ();
public Reward (String name, byte[] buffer, int id, List<Item> items) public Reward (String name, byte[] buffer, int id, List<Item> items)
{ {
@ -22,7 +22,7 @@ class Reward extends AbstractFile
this.id = id; this.id = id;
this.items = items; this.items = items;
totalElements = buffer[4]; totalElements = buffer[4];
elements = new ArrayList<RewardElement> (totalElements); elements = new ArrayList<> (totalElements);
for (int i = 0; i < totalElements; i++) for (int i = 0; i < totalElements; i++)
{ {
@ -128,8 +128,7 @@ class Reward extends AbstractFile
for (int j = 0; j < lineItem.length; j++) for (int j = 0; j < lineItem.length; j++)
lineItem[j] = i + j <= max ? items.get (i + j).getName () : ""; lineItem[j] = i + j <= max ? items.get (i + j).getName () : "";
text.append (String.format ("%-17s %-16s %-16s %-16s %-16s%n", lineTitle, text.append (String.format ("%-17s %-16s %-16s %-16s %-16s%n", lineTitle,
lineItem[0], lineItem[1], lineItem[2], lineItem[0], lineItem[1], lineItem[2], lineItem[3]));
lineItem[3]));
} }
break; break;
default: default:

View File

@ -8,8 +8,8 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class Wiz4Monsters extends AbstractFile public class Wiz4Monsters extends AbstractFile
{ {
final List<Wiz4Image> images = new ArrayList<Wiz4Image> (); final List<Wiz4Image> images = new ArrayList<> ();
final List<Integer> blocks = new ArrayList<Integer> (); final List<Integer> blocks = new ArrayList<> ();
public Wiz4Monsters (String name, byte[] buffer) public Wiz4Monsters (String name, byte[] buffer)
{ {

View File

@ -11,7 +11,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class Wiz5Monsters extends AbstractFile implements Iterable<Wiz5Monsters.Monster> public class Wiz5Monsters extends AbstractFile implements Iterable<Wiz5Monsters.Monster>
{ {
private static final int BLOCK_SIZE = 512; private static final int BLOCK_SIZE = 512;
private final List<Monster> monsters = new ArrayList<Monster> (); private final List<Monster> monsters = new ArrayList<> ();
public Wiz5Monsters (String name, byte[] buffer) public Wiz5Monsters (String name, byte[] buffer)
{ {
@ -93,7 +93,7 @@ public class Wiz5Monsters extends AbstractFile implements Iterable<Wiz5Monsters.
class Monster class Monster
{ {
private final int id; private final int id;
private final List<DataBuffer> dataBuffers = new ArrayList<DataBuffer> (); private final List<DataBuffer> dataBuffers = new ArrayList<> ();
private Wiz4Image image; private Wiz4Image image;
private byte[] data; private byte[] data;
@ -130,7 +130,7 @@ public class Wiz5Monsters extends AbstractFile implements Iterable<Wiz5Monsters.
List<Integer> getBlocks () List<Integer> getBlocks ()
{ {
List<Integer> blocks = new ArrayList<Integer> (); List<Integer> blocks = new ArrayList<> ();
for (DataBuffer dataBuffer : dataBuffers) for (DataBuffer dataBuffer : dataBuffers)
blocks.add (dataBuffer.block); blocks.add (dataBuffer.block);
return blocks; return blocks;

View File

@ -20,7 +20,7 @@ import com.bytezone.diskbrowser.wizardry.Header.ScenarioData;
public class Wizardry4BootDisk extends PascalDisk public class Wizardry4BootDisk extends PascalDisk
{ {
public Header scenarioHeader; public Header scenarioHeader;
// private final List<AppleDisk> disks = new ArrayList<AppleDisk> (); // private final List<AppleDisk> disks = new ArrayList<> ();
private Relocator relocator; private Relocator relocator;
private MessageBlock messageBlock; private MessageBlock messageBlock;
private Huffman huffman; private Huffman huffman;
@ -78,7 +78,7 @@ public class Wizardry4BootDisk extends PascalDisk
int count = 0; int count = 0;
for (MessageDataBlock mdb : messageBlock) for (MessageDataBlock mdb : messageBlock)
{ {
List<DiskAddress> messageBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> messageBlocks = new ArrayList<> ();
messageBlocks.add (blocks.get (count++)); messageBlocks.add (blocks.get (count++));
addToNode (mdb, messagesNode, messageBlocks); addToNode (mdb, messagesNode, messageBlocks);
} }
@ -145,7 +145,7 @@ public class Wizardry4BootDisk extends PascalDisk
int count = 0; int count = 0;
for (Wiz4Image image : w4monsters.images) for (Wiz4Image image : w4monsters.images)
{ {
List<DiskAddress> monsterBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> monsterBlocks = new ArrayList<> ();
monsterBlocks.add (pictureBlocks.get (w4monsters.blocks.get (count++))); monsterBlocks.add (pictureBlocks.get (w4monsters.blocks.get (count++)));
addToNode (image, monstersNode, monsterBlocks); addToNode (image, monstersNode, monsterBlocks);
} }
@ -162,7 +162,7 @@ public class Wizardry4BootDisk extends PascalDisk
for (Wiz5Monsters.Monster monster : w5monsters) for (Wiz5Monsters.Monster monster : w5monsters)
{ {
List<DiskAddress> monsterBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> monsterBlocks = new ArrayList<> ();
for (Integer blockId : monster.getBlocks ()) for (Integer blockId : monster.getBlocks ())
monsterBlocks.add (pictureBlocks.get (blockId)); monsterBlocks.add (pictureBlocks.get (blockId));
addToNode (monster.getImage (), monstersNode, monsterBlocks); addToNode (monster.getImage (), monstersNode, monsterBlocks);
@ -183,7 +183,7 @@ public class Wizardry4BootDisk extends PascalDisk
int offset = mazeData.dataOffset * 512 + i * 1024; int offset = mazeData.dataOffset * 512 + i * 1024;
System.arraycopy (buffer, offset, level, 0, level.length); System.arraycopy (buffer, offset, level, 0, level.length);
List<DiskAddress> mazeBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> mazeBlocks = new ArrayList<> ();
int ptr = mazeData.dataOffset + i * 2; int ptr = mazeData.dataOffset + i * 2;
mazeBlocks.add (blocks.get (ptr)); mazeBlocks.add (blocks.get (ptr));
mazeBlocks.add (blocks.get (ptr + 1)); mazeBlocks.add (blocks.get (ptr + 1));
@ -197,7 +197,7 @@ public class Wizardry4BootDisk extends PascalDisk
List<DiskAddress> blocks = fileEntry.getSectors (); List<DiskAddress> blocks = fileEntry.getSectors ();
DefaultMutableTreeNode mazeNode = linkNode ("Maze", "Level 5 mazes", scenarioNode); DefaultMutableTreeNode mazeNode = linkNode ("Maze", "Level 5 mazes", scenarioNode);
List<DiskAddress> allMazeBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> allMazeBlocks = new ArrayList<> ();
int dataSize = 0x39A; int dataSize = 0x39A;
int base = 0x1800; int base = 0x1800;
@ -209,7 +209,7 @@ public class Wizardry4BootDisk extends PascalDisk
System.arraycopy (buffer, offset + 0x2000, data, 0x400, dataSize); System.arraycopy (buffer, offset + 0x2000, data, 0x400, dataSize);
MazeGridV5 grid = new MazeGridV5 ("Maze level " + (i + 1), data, messageBlock); MazeGridV5 grid = new MazeGridV5 ("Maze level " + (i + 1), data, messageBlock);
List<DiskAddress> mazeBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> mazeBlocks = new ArrayList<> ();
for (int j = 0; j < 4; j++) for (int j = 0; j < 4; j++)
mazeBlocks.add (blocks.get (12 + i * 4 + j)); mazeBlocks.add (blocks.get (12 + i * 4 + j));
allMazeBlocks.addAll (mazeBlocks); allMazeBlocks.addAll (mazeBlocks);
@ -227,7 +227,7 @@ public class Wizardry4BootDisk extends PascalDisk
List<DiskAddress> blocks = fileEntry.getSectors (); List<DiskAddress> blocks = fileEntry.getSectors ();
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
List<DiskAddress> allBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> allBlocks = new ArrayList<> ();
for (int i = 0; i < 23; i++) for (int i = 0; i < 23; i++)
{ {
allBlocks.add (blocks.get (44 + i)); allBlocks.add (blocks.get (44 + i));
@ -254,7 +254,7 @@ public class Wizardry4BootDisk extends PascalDisk
List<DiskAddress> blocks = fileEntry.getSectors (); List<DiskAddress> blocks = fileEntry.getSectors ();
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
List<DiskAddress> allBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> allBlocks = new ArrayList<> ();
for (int i = 0; i < 19; i++) for (int i = 0; i < 19; i++)
{ {
allBlocks.add (blocks.get (87 + i)); allBlocks.add (blocks.get (87 + i));
@ -296,7 +296,7 @@ public class Wizardry4BootDisk extends PascalDisk
messageBlock.getMessageText (key))); messageBlock.getMessageText (key)));
} }
List<DiskAddress> allOracleBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> allOracleBlocks = new ArrayList<> ();
for (int i = 0; i < 20; i++) for (int i = 0; i < 20; i++)
{ {
allOracleBlocks.add (blocks.get (67 + i)); allOracleBlocks.add (blocks.get (67 + i));

View File

@ -168,9 +168,9 @@ public class WizardryScenarioDisk extends PascalDisk
private void extractRewards (DefaultMutableTreeNode node, List<DiskAddress> sectors) private void extractRewards (DefaultMutableTreeNode node, List<DiskAddress> sectors)
{ {
List<DiskAddress> nodeSectors = new ArrayList<DiskAddress> (); List<DiskAddress> nodeSectors = new ArrayList<> ();
ScenarioData sd = scenarioHeader.data.get (Header.TREASURE_TABLE_AREA); ScenarioData sd = scenarioHeader.data.get (Header.TREASURE_TABLE_AREA);
rewards = new ArrayList<Reward> (sd.total); rewards = new ArrayList<> (sd.total);
int max = sd.totalBlocks / 2; int max = sd.totalBlocks / 2;
int seq = 0; int seq = 0;
@ -210,9 +210,9 @@ public class WizardryScenarioDisk extends PascalDisk
private void extractCharacters (DefaultMutableTreeNode node, List<DiskAddress> sectors) private void extractCharacters (DefaultMutableTreeNode node, List<DiskAddress> sectors)
{ {
List<DiskAddress> nodeSectors = new ArrayList<DiskAddress> (); List<DiskAddress> nodeSectors = new ArrayList<> ();
ScenarioData sd = scenarioHeader.data.get (Header.CHARACTER_AREA); ScenarioData sd = scenarioHeader.data.get (Header.CHARACTER_AREA);
characters = new ArrayList<Character> (sd.total); characters = new ArrayList<> (sd.total);
int max = sd.totalBlocks / 2; int max = sd.totalBlocks / 2;
if (max < sd.total) if (max < sd.total)
System.out.println ("Characters short in Wizardry disk"); System.out.println ("Characters short in Wizardry disk");
@ -271,9 +271,9 @@ public class WizardryScenarioDisk extends PascalDisk
private void extractMonsters (DefaultMutableTreeNode node, List<DiskAddress> sectors) private void extractMonsters (DefaultMutableTreeNode node, List<DiskAddress> sectors)
{ {
List<DiskAddress> nodeSectors = new ArrayList<DiskAddress> (); List<DiskAddress> nodeSectors = new ArrayList<> ();
ScenarioData sd = scenarioHeader.data.get (Header.MONSTER_AREA); ScenarioData sd = scenarioHeader.data.get (Header.MONSTER_AREA);
monsters = new ArrayList<Monster> (sd.total); monsters = new ArrayList<> (sd.total);
int max = sd.totalBlocks / 2; int max = sd.totalBlocks / 2;
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
@ -324,9 +324,9 @@ public class WizardryScenarioDisk extends PascalDisk
private void extractItems (DefaultMutableTreeNode node, List<DiskAddress> sectors) private void extractItems (DefaultMutableTreeNode node, List<DiskAddress> sectors)
{ {
List<DiskAddress> nodeSectors = new ArrayList<DiskAddress> (); List<DiskAddress> nodeSectors = new ArrayList<> ();
ScenarioData sd = scenarioHeader.data.get (Header.ITEM_AREA); ScenarioData sd = scenarioHeader.data.get (Header.ITEM_AREA);
items = new ArrayList<Item> (sd.total); items = new ArrayList<> (sd.total);
int max = sd.totalBlocks / 2; int max = sd.totalBlocks / 2;
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
@ -376,8 +376,8 @@ public class WizardryScenarioDisk extends PascalDisk
private void extractSpells (DefaultMutableTreeNode node, List<DiskAddress> sectors) private void extractSpells (DefaultMutableTreeNode node, List<DiskAddress> sectors)
{ {
spells = new ArrayList<Spell> (); spells = new ArrayList<> ();
ArrayList<DiskAddress> blocks = new ArrayList<DiskAddress> (2); List<DiskAddress> blocks = new ArrayList<> (2);
int offset = scenarioHeader.scenarioID <= 2 ? 4 : 1; int offset = scenarioHeader.scenarioID <= 2 ? 4 : 1;
blocks.add (sectors.get (offset)); blocks.add (sectors.get (offset));
blocks.add (sectors.get (offset + 1)); blocks.add (sectors.get (offset + 1));
@ -413,7 +413,7 @@ public class WizardryScenarioDisk extends PascalDisk
private void extractMessages (DefaultMutableTreeNode node, List<DiskAddress> sectors) private void extractMessages (DefaultMutableTreeNode node, List<DiskAddress> sectors)
{ {
Message.resetMessageId (); Message.resetMessageId ();
messages = new ArrayList<Message> (); messages = new ArrayList<> ();
// Copy first 504 bytes from each sector to a single contiguous buffer // Copy first 504 bytes from each sector to a single contiguous buffer
int recordLength = 42; int recordLength = 42;
@ -450,7 +450,7 @@ public class WizardryScenarioDisk extends PascalDisk
m = new CodedMessage (newBuffer); m = new CodedMessage (newBuffer);
messages.add (m); messages.add (m);
List<DiskAddress> messageBlocks = new ArrayList<DiskAddress> (); List<DiskAddress> messageBlocks = new ArrayList<> ();
int lastBlock = -1; int lastBlock = -1;
for (int p2 = messageStart; p2 < messageEnd; p2 += recordLength) for (int p2 = messageStart; p2 < messageEnd; p2 += recordLength)
{ {
@ -471,9 +471,9 @@ public class WizardryScenarioDisk extends PascalDisk
private void extractLevels (DefaultMutableTreeNode node, List<DiskAddress> sectors) private void extractLevels (DefaultMutableTreeNode node, List<DiskAddress> sectors)
{ {
List<DiskAddress> nodeSectors = new ArrayList<DiskAddress> (); List<DiskAddress> nodeSectors = new ArrayList<> ();
ScenarioData sd = scenarioHeader.data.get (Header.MAZE_AREA); ScenarioData sd = scenarioHeader.data.get (Header.MAZE_AREA);
levels = new ArrayList<MazeLevel> (sd.total); levels = new ArrayList<> (sd.total);
int max = sd.totalBlocks / 2; int max = sd.totalBlocks / 2;
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
@ -505,10 +505,10 @@ public class WizardryScenarioDisk extends PascalDisk
private void extractImages (DefaultMutableTreeNode node, List<DiskAddress> sectors) private void extractImages (DefaultMutableTreeNode node, List<DiskAddress> sectors)
{ {
List<DiskAddress> nodeSectors = new ArrayList<DiskAddress> (); List<DiskAddress> nodeSectors = new ArrayList<> ();
ScenarioData sd = scenarioHeader.data.get (Header.IMAGE_AREA); ScenarioData sd = scenarioHeader.data.get (Header.IMAGE_AREA);
int max = sd.totalBlocks; int max = sd.totalBlocks;
images = new ArrayList<AbstractImage> (); images = new ArrayList<> ();
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
@ -545,9 +545,9 @@ public class WizardryScenarioDisk extends PascalDisk
private void extractExperienceLevels (DefaultMutableTreeNode node, private void extractExperienceLevels (DefaultMutableTreeNode node,
List<DiskAddress> sectors) List<DiskAddress> sectors)
{ {
List<DiskAddress> nodeSectors = new ArrayList<DiskAddress> (); List<DiskAddress> nodeSectors = new ArrayList<> ();
ScenarioData sd = scenarioHeader.data.get (Header.EXPERIENCE_AREA); ScenarioData sd = scenarioHeader.data.get (Header.EXPERIENCE_AREA);
experiences = new ArrayList<ExperienceLevel> (sd.total); experiences = new ArrayList<> (sd.total);
int max = sd.totalBlocks / 2; int max = sd.totalBlocks / 2;
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
@ -576,7 +576,7 @@ public class WizardryScenarioDisk extends PascalDisk
private void addToNode (AbstractFile af, DefaultMutableTreeNode node, DiskAddress block, private void addToNode (AbstractFile af, DefaultMutableTreeNode node, DiskAddress block,
SectorType type) SectorType type)
{ {
ArrayList<DiskAddress> blocks = new ArrayList<DiskAddress> (1); List<DiskAddress> blocks = new ArrayList<> (1);
blocks.add (block); blocks.add (block);
addToNode (af, node, blocks, type); addToNode (af, node, blocks, type);
} }
@ -594,7 +594,7 @@ public class WizardryScenarioDisk extends PascalDisk
private List<DiskAddress> getTwoBlocks (ScenarioData sd, int i, private List<DiskAddress> getTwoBlocks (ScenarioData sd, int i,
List<DiskAddress> sectors) List<DiskAddress> sectors)
{ {
ArrayList<DiskAddress> blocks = new ArrayList<DiskAddress> (2); List<DiskAddress> blocks = new ArrayList<> (2);
blocks.add (sectors.get (sd.dataOffset + i * 2)); blocks.add (sectors.get (sd.dataOffset + i * 2));
blocks.add (sectors.get (sd.dataOffset + i * 2 + 1)); blocks.add (sectors.get (sd.dataOffset + i * 2 + 1));
return blocks; return blocks;