adjusted hybrid disks, added basic preference

This commit is contained in:
Denis Molony 2020-12-21 07:50:51 +10:00
parent 0b13adbee9
commit 77276ab156
14 changed files with 146 additions and 97 deletions

View File

@ -21,6 +21,7 @@ public class ApplesoftBasicProgram extends BasicProgram
private static final byte TOKEN_GOTO = (byte) 0xAB;
private static final byte TOKEN_IF = (byte) 0xAD;
private static final byte TOKEN_GOSUB = (byte) 0xB0;
private static final byte TOKEN_RETURN = (byte) 0xB1;
private static final byte TOKEN_REM = (byte) 0xB2;
private static final byte TOKEN_PRINT = (byte) 0xBA;
private static final byte TOKEN_THEN = (byte) 0xC4;
@ -67,6 +68,9 @@ public class ApplesoftBasicProgram extends BasicProgram
private String getProgramText ()
// ---------------------------------------------------------------------------------//
{
int indentSize = 2;
boolean blankLine = false;
StringBuilder fullText = new StringBuilder ();
Stack<String> loopVariables = new Stack<> ();
if (basicPreferences.showHeader)
@ -136,7 +140,7 @@ public class ApplesoftBasicProgram extends BasicProgram
if (basicPreferences.alignAssign)
alignPos = alignEqualsPosition (subline, alignPos);
int column = indent * 2 + baseOffset;
int column = indent * indentSize + baseOffset;
while (text.length () < column)
text.append (" ");
}
@ -219,6 +223,14 @@ public class ApplesoftBasicProgram extends BasicProgram
loopVariables.push (subline.forVariable);
++indent;
}
else if (basicPreferences.blankAfterReturn && subline.is (TOKEN_RETURN))
blankLine = true;
}
if (blankLine)
{
fullText.append ("\n");
blankLine = false;
}
// Reset alignment value if we just left an IF - the indentation will be different now
@ -237,7 +249,8 @@ public class ApplesoftBasicProgram extends BasicProgram
}
if (fullText.length () > 0)
fullText.deleteCharAt (fullText.length () - 1); // remove last newline
while (fullText.charAt (fullText.length () - 1) == '\n')
fullText.deleteCharAt (fullText.length () - 1); // remove last newline
return fullText.toString ();
}

View File

@ -77,6 +77,9 @@ class DirectoryEntry implements AppleFileSource
for (int i = 0; i < 4; i++)
blocks.add (new AppleDiskAddress (disk, blockNumber + i));
}
// if (name.equals ("cp/m"))
// for (DiskAddress da : blocks)
// System.out.println (da);
}
// ---------------------------------------------------------------------------------//

View File

@ -20,7 +20,6 @@ public abstract class AbstractSector implements DataSource
protected Disk disk;
protected DiskAddress diskAddress;
AssemblerProgram assembler;
String description;
// ---------------------------------------------------------------------------------//
public AbstractSector (Disk disk, byte[] buffer, DiskAddress diskAddress)
@ -70,9 +69,7 @@ public abstract class AbstractSector implements DataSource
public String getText ()
// ---------------------------------------------------------------------------------//
{
if (description == null)
description = createText ();
return description;
return createText ();
}
// ---------------------------------------------------------------------------------//

View File

@ -252,7 +252,7 @@ public class DiskFactory
disk = checkUnidos (appleDisk1, 1);
disk2 = checkUnidos (appleDisk2, 2);
if (disk != null && disk2 != null)
return new DualDosDisk (disk, disk2);
return new HybridDisk (disk, disk2);
}
if (debug)
@ -403,7 +403,7 @@ public class DiskFactory
if (debug)
System.out.println (" --> Dual dos/prodos 1");
System.out.println ("** impossible **");
disk = new DualDosDisk (disk, disk2);
disk = new HybridDisk (disk, disk2);
}
}
else if (checksum == 1737448647L //
@ -418,7 +418,7 @@ public class DiskFactory
{
if (debug)
System.out.println (" --> Dual prodos/dos 2");
disk = new DualDosDisk (disk, disk2);
disk = new HybridDisk (disk, disk2);
}
}
else if (checksum == 2803644711L // Apple Pascal disk 0
@ -431,7 +431,7 @@ public class DiskFactory
disk = checkPascalDisk (appleDisk512);
disk2 = checkDos (appleDisk256);
if (disk2 != null)
disk = new DualDosDisk (disk, disk2);
disk = new HybridDisk (disk, disk2);
}
else if (checksum == 3028642627L //
|| checksum == 2070151659L) // Enchanter
@ -479,7 +479,7 @@ public class DiskFactory
disk2 = checkProdos (appleDisk512);
if (disk2 != null)
{
disk = new DualDosDisk (disk, disk2);
disk = new HybridDisk (disk, disk2);
return disk;
}
@ -487,14 +487,14 @@ public class DiskFactory
disk2 = checkCPMDisk (appleDisk);
if (disk2 != null)
{
disk = new DualDosDisk (disk, disk2);
disk = new HybridDisk (disk, disk2);
return disk;
}
disk2 = checkPascalDisk (appleDisk512);
if (disk2 != null)
{
disk = new DualDosDisk (disk, disk2);
disk = new HybridDisk (disk, disk2);
return disk;
}
}

View File

@ -2,6 +2,7 @@ package com.bytezone.diskbrowser.disk;
import java.awt.Dimension;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JTree;
@ -16,21 +17,21 @@ import com.bytezone.diskbrowser.gui.DataSource;
// Should be renamed MultiVolumeDisk (and allow >2 volumes)
// -----------------------------------------------------------------------------------//
public class DualDosDisk implements FormattedDisk
public class HybridDisk implements FormattedDisk
// -----------------------------------------------------------------------------------//
{
private final FormattedDisk[] disks = new FormattedDisk[2];
private final List<FormattedDisk> disks = new ArrayList<> (2);
private int currentDisk;
private final JTree tree;
// ---------------------------------------------------------------------------------//
public DualDosDisk (FormattedDisk disk0, FormattedDisk disk1)
public HybridDisk (FormattedDisk disk0, FormattedDisk disk1)
// ---------------------------------------------------------------------------------//
{
assert disk0 != disk1;
String diskName = disk0.getDisk ().getFile ().getName ();
String text = "This disk contains files from DOS and another OS\n\n"
+ disk0.getDisk () + "\n\n" + disk1.getDisk ();
String text = "This disk is a hybrid of two or more OS\n\n" + disk0.getDisk ()
+ "\n\n" + disk1.getDisk ();
DefaultAppleFileSource dafs = new DefaultAppleFileSource (diskName, text, this);
DefaultMutableTreeNode root = new DefaultMutableTreeNode (dafs);
@ -41,8 +42,8 @@ public class DualDosDisk implements FormattedDisk
// allow empty nodes to appear as folders
treeModel.setAsksAllowsChildren (true);
disks[0] = disk0;
disks[1] = disk1;
disks.add (disk0);
disks.add (disk1);
disk0.setParent (this);
disk1.setParent (this);
@ -69,7 +70,7 @@ public class DualDosDisk implements FormattedDisk
public List<DiskAddress> getFileSectors (int fileNo)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getFileSectors (fileNo);
return disks.get (currentDisk).getFileSectors (fileNo);
}
// ---------------------------------------------------------------------------------//
@ -77,7 +78,7 @@ public class DualDosDisk implements FormattedDisk
public List<AppleFileSource> getCatalogList ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getCatalogList ();
return disks.get (currentDisk).getCatalogList ();
}
// ---------------------------------------------------------------------------------//
@ -85,7 +86,7 @@ public class DualDosDisk implements FormattedDisk
public DataSource getFormattedSector (DiskAddress da)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getFormattedSector (da);
return disks.get (currentDisk).getFormattedSector (da);
}
// ---------------------------------------------------------------------------------//
@ -93,7 +94,7 @@ public class DualDosDisk implements FormattedDisk
public SectorType getSectorType (DiskAddress da)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getSectorType (da);
return disks.get (currentDisk).getSectorType (da);
}
// ---------------------------------------------------------------------------------//
@ -101,7 +102,7 @@ public class DualDosDisk implements FormattedDisk
public SectorType getSectorType (int track, int sector)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getSectorType (track, sector);
return disks.get (currentDisk).getSectorType (track, sector);
}
// ---------------------------------------------------------------------------------//
@ -109,7 +110,7 @@ public class DualDosDisk implements FormattedDisk
public SectorType getSectorType (int block)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getSectorType (block);
return disks.get (currentDisk).getSectorType (block);
}
// ---------------------------------------------------------------------------------//
@ -117,7 +118,7 @@ public class DualDosDisk implements FormattedDisk
public List<SectorType> getSectorTypeList ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getSectorTypeList ();
return disks.get (currentDisk).getSectorTypeList ();
}
// ---------------------------------------------------------------------------------//
@ -125,23 +126,30 @@ public class DualDosDisk implements FormattedDisk
public Disk getDisk ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getDisk ();
return disks.get (currentDisk).getDisk ();
}
// ---------------------------------------------------------------------------------//
public void setCurrentDisk (FormattedDisk fd)
// ---------------------------------------------------------------------------------//
{
if (disks[0] == fd)
currentDisk = 0;
else if (disks[1] == fd)
currentDisk = 1;
else
{
// this happens when the top-level folder is selected (i.e. neither disk)
System.out.println ("Disk not found: " + fd);
// Utility.printStackTrace ();
}
for (int i = 0; i < disks.size (); i++)
if (disks.get (i) == fd)
{
currentDisk = i;
break;
}
// if (disks[0] == fd)
// currentDisk = 0;
// else if (disks[1] == fd)
// currentDisk = 1;
// else
// {
// // this happens when the top-level folder is selected (i.e. neither disk)
// System.out.println ("Disk not found: " + fd);
// // Utility.printStackTrace ();
// }
}
// ---------------------------------------------------------------------------------//
@ -162,7 +170,7 @@ public class DualDosDisk implements FormattedDisk
public FormattedDisk getCurrentDisk ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk];
return disks.get (currentDisk);
}
// ---------------------------------------------------------------------------------//
@ -170,7 +178,7 @@ public class DualDosDisk implements FormattedDisk
public void writeFile (AbstractFile file)
// ---------------------------------------------------------------------------------//
{
disks[currentDisk].writeFile (file);
disks.get (currentDisk).writeFile (file);
}
// ---------------------------------------------------------------------------------//
@ -178,10 +186,18 @@ public class DualDosDisk implements FormattedDisk
public AppleFileSource getCatalog ()
// ---------------------------------------------------------------------------------//
{
return new DefaultAppleFileSource ("text",
disks[0].getCatalog ().getDataSource ().getText () + "\n\n"
+ disks[1].getCatalog ().getDataSource ().getText (),
this);
StringBuilder text = new StringBuilder ();
for (FormattedDisk disk : disks)
{
text.append (disk.getCatalog ().getDataSource ().getText ());
text.append ("\n\n");
}
text.deleteCharAt (text.length () - 1);
text.deleteCharAt (text.length () - 1);
return new DefaultAppleFileSource ("text", text.toString (), this);
}
// ---------------------------------------------------------------------------------//
@ -189,7 +205,7 @@ public class DualDosDisk implements FormattedDisk
public AppleFileSource getFile (String uniqueName)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getFile (uniqueName);
return disks.get (currentDisk).getFile (uniqueName);
}
// ---------------------------------------------------------------------------------//
@ -197,7 +213,7 @@ public class DualDosDisk implements FormattedDisk
public int clearOrphans ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].clearOrphans ();
return disks.get (currentDisk).clearOrphans ();
}
// ---------------------------------------------------------------------------------//
@ -205,7 +221,7 @@ public class DualDosDisk implements FormattedDisk
public boolean isSectorFree (DiskAddress da)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].isSectorFree (da);
return disks.get (currentDisk).isSectorFree (da);
}
// ---------------------------------------------------------------------------------//
@ -213,7 +229,7 @@ public class DualDosDisk implements FormattedDisk
public void verify ()
// ---------------------------------------------------------------------------------//
{
disks[currentDisk].verify ();
disks.get (currentDisk).verify ();
}
// ---------------------------------------------------------------------------------//
@ -221,7 +237,7 @@ public class DualDosDisk implements FormattedDisk
public boolean stillAvailable (DiskAddress da)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].stillAvailable (da);
return disks.get (currentDisk).stillAvailable (da);
}
// ---------------------------------------------------------------------------------//
@ -229,7 +245,7 @@ public class DualDosDisk implements FormattedDisk
public void setSectorType (int block, SectorType type)
// ---------------------------------------------------------------------------------//
{
disks[currentDisk].setSectorType (block, type);
disks.get (currentDisk).setSectorType (block, type);
}
// ---------------------------------------------------------------------------------//
@ -237,7 +253,7 @@ public class DualDosDisk implements FormattedDisk
public void setSectorFree (int block, boolean free)
// ---------------------------------------------------------------------------------//
{
disks[currentDisk].setSectorFree (block, free);
disks.get (currentDisk).setSectorFree (block, free);
}
// ---------------------------------------------------------------------------------//
@ -245,7 +261,7 @@ public class DualDosDisk implements FormattedDisk
public int falseNegativeBlocks ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].falseNegativeBlocks ();
return disks.get (currentDisk).falseNegativeBlocks ();
}
// ---------------------------------------------------------------------------------//
@ -253,7 +269,7 @@ public class DualDosDisk implements FormattedDisk
public int falsePositiveBlocks ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].falsePositiveBlocks ();
return disks.get (currentDisk).falsePositiveBlocks ();
}
// ---------------------------------------------------------------------------------//
@ -261,7 +277,7 @@ public class DualDosDisk implements FormattedDisk
public Dimension getGridLayout ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getGridLayout ();
return disks.get (currentDisk).getGridLayout ();
}
// ---------------------------------------------------------------------------------//
@ -269,7 +285,7 @@ public class DualDosDisk implements FormattedDisk
public boolean isSectorFree (int block)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].isSectorFree (block);
return disks.get (currentDisk).isSectorFree (block);
}
// ---------------------------------------------------------------------------------//
@ -277,7 +293,7 @@ public class DualDosDisk implements FormattedDisk
public boolean stillAvailable (int block)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].stillAvailable (block);
return disks.get (currentDisk).stillAvailable (block);
}
// ---------------------------------------------------------------------------------//
@ -285,7 +301,7 @@ public class DualDosDisk implements FormattedDisk
public void setOriginalPath (Path path)
// ---------------------------------------------------------------------------------//
{
disks[currentDisk].setOriginalPath (path);
disks.get (currentDisk).setOriginalPath (path);
}
// ---------------------------------------------------------------------------------//
@ -293,7 +309,7 @@ public class DualDosDisk implements FormattedDisk
public String getAbsolutePath ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getAbsolutePath ();
return disks.get (currentDisk).getAbsolutePath ();
}
// ---------------------------------------------------------------------------------//
@ -301,7 +317,7 @@ public class DualDosDisk implements FormattedDisk
public String getDisplayPath ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getDisplayPath ();
return disks.get (currentDisk).getDisplayPath ();
}
// ---------------------------------------------------------------------------------//
@ -309,7 +325,7 @@ public class DualDosDisk implements FormattedDisk
public FormattedDisk getParent ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getParent ();
return disks.get (currentDisk).getParent ();
}
// ---------------------------------------------------------------------------------//
@ -317,7 +333,7 @@ public class DualDosDisk implements FormattedDisk
public void setParent (FormattedDisk disk)
// ---------------------------------------------------------------------------------//
{
disks[currentDisk].setParent (disk);
disks.get (currentDisk).setParent (disk);
}
// ---------------------------------------------------------------------------------//
@ -325,7 +341,7 @@ public class DualDosDisk implements FormattedDisk
public String getSectorFilename (DiskAddress da)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getSectorFilename (da);
return disks.get (currentDisk).getSectorFilename (da);
}
// ---------------------------------------------------------------------------------//
@ -333,7 +349,7 @@ public class DualDosDisk implements FormattedDisk
public String getName ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getName ();
return disks.get (currentDisk).getName ();
}
// ---------------------------------------------------------------------------------//
@ -341,7 +357,7 @@ public class DualDosDisk implements FormattedDisk
public boolean isTempDisk ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].isTempDisk ();
return disks.get (currentDisk).isTempDisk ();
}
// ---------------------------------------------------------------------------------//
@ -349,6 +365,6 @@ public class DualDosDisk implements FormattedDisk
public Path getOriginalPath ()
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getOriginalPath ();
return disks.get (currentDisk).getOriginalPath ();
}
}

View File

@ -248,13 +248,6 @@ public class DosDisk extends AbstractFormattedDisk
makeNodeVisible (volumeNode.getFirstLeaf ());
}
// ---------------------------------------------------------------------------------//
// private int getVolumeNo ()
// // ---------------------------------------------------------------------------------//
// {
// return volumeNo;
// }
// ---------------------------------------------------------------------------------//
@Override
public void setOriginalPath (Path path)
@ -515,13 +508,26 @@ public class DosDisk extends AbstractFormattedDisk
return null;
}
// ---------------------------------------------------------------------------------//
private int countEntries (AppleFileSource catalogEntry)
// ---------------------------------------------------------------------------------//
{
int count = 0;
for (AppleFileSource ce : fileEntries)
{
if (ce.getUniqueName ().equals (catalogEntry.getUniqueName ()))
count++;
}
return count;
}
// ---------------------------------------------------------------------------------//
@Override
public AppleFileSource getCatalog ()
// ---------------------------------------------------------------------------------//
{
String newLine = String.format ("%n");
String line = "- --- --- ------------------------------ ----- -------------"
String underline = "- --- --- ------------------------------ ----- -------------"
+ " -- ---- -------------------" + newLine;
StringBuilder text = new StringBuilder ();
@ -529,12 +535,17 @@ public class DosDisk extends AbstractFormattedDisk
text.append (String.format ("Disk : %s%n%n", getDisplayPath ()));
text.append ("L Typ Len Name Addr"
+ " Length TS Data Comment" + newLine);
text.append (line);
text.append (underline);
for (AppleFileSource fileEntry : fileEntries)
text.append (((CatalogEntry) fileEntry).getDetails () + newLine);
{
String entry = ((CatalogEntry) fileEntry).getDetails ();
if (countEntries (fileEntry) > 1)
entry += "** duplicate **";
text.append (entry + newLine);
}
text.append (line);
text.append (underline);
text.append (String.format (
" Free sectors: %3d " + "Used sectors: %3d Total sectors: %3d",
dosVTOCSector.freeSectors, dosVTOCSector.usedSectors,

View File

@ -17,7 +17,7 @@ import javax.swing.tree.TreeNode;
import com.bytezone.diskbrowser.applefile.AppleFileSource;
import com.bytezone.diskbrowser.disk.DiskFactory;
import com.bytezone.diskbrowser.disk.DualDosDisk;
import com.bytezone.diskbrowser.disk.HybridDisk;
import com.bytezone.diskbrowser.disk.FormattedDisk;
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
@ -145,7 +145,7 @@ class AppleDiskTab extends AbstractTab
FileSelectedEvent fileSelectedEvent = (FileSelectedEvent) event.value;
if (fileSelectedEvent.volumeNo >= 0)
{
DualDosDisk ddd = (DualDosDisk) afs.getFormattedDisk ().getParent ();
HybridDisk ddd = (HybridDisk) afs.getFormattedDisk ().getParent ();
ddd.setCurrentDiskNo (fileSelectedEvent.volumeNo);
}
selectNode (fileSelectedEvent.appleFileSource.getUniqueName ());
@ -159,9 +159,9 @@ class AppleDiskTab extends AbstractTab
// check for multi-volume disk (only search the current branch)
FormattedDisk fd = ((AppleFileSource) rootNode.getUserObject ()).getFormattedDisk ();
if (fd instanceof DualDosDisk)
if (fd instanceof HybridDisk)
{
int volume = ((DualDosDisk) fd).getCurrentDiskNo ();
int volume = ((HybridDisk) fd).getCurrentDiskNo ();
rootNode = (DefaultMutableTreeNode) rootNode.getChildAt (volume);
}

View File

@ -11,6 +11,7 @@ public class BasicPreferences
public boolean onlyShowTargetLineNumbers = true;
public boolean showCaret = false;
public boolean showThen = true;
public boolean blankAfterReturn = false;
public int wrapPrintAt = 0;
public int wrapRemAt = 60;
public int wrapDataAt = 60;
@ -30,6 +31,7 @@ public class BasicPreferences
text.append (String.format ("Show header ........... %s%n", showHeader));
text.append (String.format ("Show caret ............ %s%n", showCaret));
text.append (String.format ("Show THEN ............. %s%n", showThen));
text.append (String.format ("Blank after RETURN .... %s%n", blankAfterReturn));
text.append (String.format ("Wrap PRINT at ......... %d%n", wrapPrintAt));
text.append (String.format ("Wrap REM at .......... %d%n", wrapRemAt));
text.append (String.format ("Wrap DATA at ......... %d", wrapDataAt));

View File

@ -25,7 +25,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import com.bytezone.diskbrowser.applefile.AppleFileSource;
import com.bytezone.diskbrowser.disk.DualDosDisk;
import com.bytezone.diskbrowser.disk.HybridDisk;
import com.bytezone.diskbrowser.disk.FormattedDisk;
import com.bytezone.diskbrowser.duplicates.DiskDetails;
import com.bytezone.diskbrowser.gui.DuplicateAction.DiskTableSelectionListener;
@ -213,8 +213,8 @@ class CatalogPanel extends JTabbedPane
FormattedDisk fd = ((AppleDiskTab) selectedTab).disk;
prefs.put (prefsLastDiskUsed, fd.getAbsolutePath ());
if (fd instanceof DualDosDisk)
prefs.putInt (prefsLastDosUsed, ((DualDosDisk) fd).getCurrentDiskNo ());
if (fd instanceof HybridDisk)
prefs.putInt (prefsLastDosUsed, ((HybridDisk) fd).getCurrentDiskNo ());
else
prefs.putInt (prefsLastDosUsed, -1);
@ -265,8 +265,8 @@ class CatalogPanel extends JTabbedPane
if (diskEvent != null)
{
fd1 = diskEvent.getFormattedDisk ();
if (lastDosUsed >= 0 && fd1 instanceof DualDosDisk)
((DualDosDisk) fd1).setCurrentDiskNo (lastDosUsed);
if (lastDosUsed >= 0 && fd1 instanceof HybridDisk)
((HybridDisk) fd1).setCurrentDiskNo (lastDosUsed);
}
}
else

View File

@ -29,6 +29,7 @@ import com.bytezone.diskbrowser.applefile.AbstractFile;
import com.bytezone.diskbrowser.applefile.ApplesoftBasicProgram;
import com.bytezone.diskbrowser.applefile.AssemblerProgram;
import com.bytezone.diskbrowser.applefile.BasicTextFile;
import com.bytezone.diskbrowser.applefile.BootSector;
import com.bytezone.diskbrowser.applefile.HiResImage;
import com.bytezone.diskbrowser.applefile.Palette;
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
@ -548,7 +549,8 @@ public class DataPanel extends JTabbedPane
public void setAssemblerPreferences (AssemblerPreferences assemblerPreferences)
// ---------------------------------------------------------------------------------//
{
if (currentDataSource instanceof AssemblerProgram)
if (currentDataSource instanceof AssemblerProgram
|| currentDataSource instanceof BootSector)
setDataSource (currentDataSource);
}

View File

@ -19,7 +19,7 @@ import javax.swing.JScrollPane;
import com.bytezone.diskbrowser.disk.Disk;
import com.bytezone.diskbrowser.disk.DiskAddress;
import com.bytezone.diskbrowser.disk.DualDosDisk;
import com.bytezone.diskbrowser.disk.HybridDisk;
import com.bytezone.diskbrowser.disk.FormattedDisk;
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
import com.bytezone.diskbrowser.gui.RedoHandler.RedoListener;
@ -244,8 +244,8 @@ class DiskLayoutPanel extends JPanel
private void checkCorrectDisk (FormattedDisk newDisk)
{
if (newDisk instanceof DualDosDisk)
newDisk = ((DualDosDisk) newDisk).getCurrentDisk (); // never set to a Dual-dos disk
if (newDisk instanceof HybridDisk)
newDisk = ((HybridDisk) newDisk).getCurrentDisk (); // never set to a Dual-dos disk
if (newDisk != diskLayoutImage.getDisk ())
{
LayoutDetails layout = new LayoutDetails (newDisk);

View File

@ -7,7 +7,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import com.bytezone.diskbrowser.disk.AppleDiskAddress;
import com.bytezone.diskbrowser.disk.Disk;
import com.bytezone.diskbrowser.disk.DiskAddress;
import com.bytezone.diskbrowser.disk.FormattedDisk;
@ -90,7 +89,6 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
highlights.clear ();
int totalBlocks = disk.getTotalBlocks ();
// int rowSize = disk.getTrackSize () / disk.getBlockSize ();
Dimension gridLayout = formattedDisk.getGridLayout ();
int rowSize = gridLayout.width;
@ -165,11 +163,12 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
public void setSelection (List<DiskAddress> list)
// ---------------------------------------------------------------------------------//
{
// sparse files contain empty blocks
// sparse files contain empty blocks (represented by null)
highlights.clear ();
if (list != null)
for (DiskAddress da : list)
if (da != null && (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ()))
if (da != null)
// && (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ()))
highlights.add (da);
}
@ -194,8 +193,7 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
lo = da.getBlockNo ();
hi = highlights.get (0).getBlockNo () - 1;
}
else
// No, must be extending at the end
else // No, must be extending at the end
{
lo = highlights.get (highlights.size () - 1).getBlockNo () + 1;
hi = da.getBlockNo ();

View File

@ -3,7 +3,7 @@ package com.bytezone.diskbrowser.gui;
import java.util.EventObject;
import com.bytezone.diskbrowser.applefile.AppleFileSource;
import com.bytezone.diskbrowser.disk.DualDosDisk;
import com.bytezone.diskbrowser.disk.HybridDisk;
import com.bytezone.diskbrowser.disk.FormattedDisk;
// -----------------------------------------------------------------------------------//
@ -24,7 +24,7 @@ class FileSelectedEvent extends EventObject
// If a file is selected from a disk which is contained in a Dual-dos disk, then the DDS
// must be told so that it can ensure its internal currentDisk is set correctly
FormattedDisk fd = appleFileSource.getFormattedDisk ();
DualDosDisk ddd = (DualDosDisk) fd.getParent ();
HybridDisk ddd = (HybridDisk) fd.getParent ();
if (ddd != null)
{
ddd.setCurrentDisk (fd);

View File

@ -49,6 +49,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
private static final String PREFS_SHOW_HEADER = "showHeader";
private static final String PREFS_SHOW_CARET = "showCaret";
private static final String PREFS_SHOW_THEN = "showThen";
private static final String PREFS_BLANK_AFTER_RETURN = "blankAfterReturn";
private static final String PREFS_SHOW_ASSEMBLER_TARGETS = "showAssemblerTargets";
private static final String PREFS_SHOW_ASSEMBLER_STRINGS = "showAssemblerStrings";
@ -133,6 +134,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
final JMenuItem showHeaderItem = new JCheckBoxMenuItem ("Show header");
final JMenuItem showCaretItem = new JCheckBoxMenuItem ("Show caret");
final JMenuItem showThenItem = new JCheckBoxMenuItem ("Show THEN after IF");
final JMenuItem blankAfterReturn = new JCheckBoxMenuItem ("Blank line after RETURN");
// Assembler menu items
final JMenuItem showAssemblerTargetsItem = new JCheckBoxMenuItem ("Show targets");
@ -227,6 +229,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
applesoftMenu.add (onlyShowTargetLinesItem);
applesoftMenu.add (showCaretItem);
applesoftMenu.add (showThenItem);
applesoftMenu.add (blankAfterReturn);
assemblerMenu.add (showAssemblerHeaderItem);
assemblerMenu.add (showAssemblerTargetsItem);
@ -284,6 +287,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
showHeaderItem.addActionListener (basicPreferencesAction);
showCaretItem.addActionListener (basicPreferencesAction);
showThenItem.addActionListener (basicPreferencesAction);
blankAfterReturn.addActionListener (basicPreferencesAction);
showAssemblerTargetsItem.addActionListener (assemblerPreferencesAction);
showAssemblerStringsItem.addActionListener (assemblerPreferencesAction);
@ -327,6 +331,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
basicPreferences.alignAssign = alignAssignItem.isSelected ();
basicPreferences.showCaret = showCaretItem.isSelected ();
basicPreferences.showThen = showThenItem.isSelected ();
basicPreferences.blankAfterReturn = blankAfterReturn.isSelected ();
basicPreferences.showHeader = showHeaderItem.isSelected ();
basicPreferences.showTargets = showBasicTargetsItem.isSelected ();
basicPreferences.onlyShowTargetLineNumbers = onlyShowTargetLinesItem.isSelected ();
@ -484,6 +489,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
prefs.putBoolean (PREFS_SHOW_HEADER, showHeaderItem.isSelected ());
prefs.putBoolean (PREFS_SHOW_TARGETS, showBasicTargetsItem.isSelected ());
prefs.putBoolean (PREFS_ONLY_SHOW_TARGETS, onlyShowTargetLinesItem.isSelected ());
prefs.putBoolean (PREFS_BLANK_AFTER_RETURN, blankAfterReturn.isSelected ());
prefs.putBoolean (PREFS_SHOW_ASSEMBLER_TARGETS,
showAssemblerTargetsItem.isSelected ());
@ -533,6 +539,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
showBasicTargetsItem.setSelected (prefs.getBoolean (PREFS_SHOW_TARGETS, false));
onlyShowTargetLinesItem
.setSelected (prefs.getBoolean (PREFS_ONLY_SHOW_TARGETS, false));
blankAfterReturn.setSelected (prefs.getBoolean (PREFS_BLANK_AFTER_RETURN, false));
showAssemblerTargetsItem
.setSelected (prefs.getBoolean (PREFS_SHOW_ASSEMBLER_TARGETS, true));