mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-03 13:31:44 +00:00
Assembler preferences
This commit is contained in:
parent
18493d3290
commit
6c6adcce08
@ -10,6 +10,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.bytezone.common.Utility;
|
||||
import com.bytezone.diskbrowser.gui.AssemblerPreferences;
|
||||
import com.bytezone.diskbrowser.gui.DiskBrowser;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
@ -22,6 +24,8 @@ public class AssemblerProgram extends AbstractFile
|
||||
|
||||
private byte[] extraBuffer = new byte[0];
|
||||
|
||||
static AssemblerPreferences assemblerPreferences;
|
||||
|
||||
public AssemblerProgram (String name, byte[] buffer, int address)
|
||||
{
|
||||
super (name, buffer);
|
||||
@ -37,6 +41,11 @@ public class AssemblerProgram extends AbstractFile
|
||||
this.executeOffset = executeOffset;
|
||||
}
|
||||
|
||||
public static void setAssemblerPreferences (AssemblerPreferences assemblerPreferences)
|
||||
{
|
||||
AssemblerProgram.assemblerPreferences = assemblerPreferences;
|
||||
}
|
||||
|
||||
public void setExtraBuffer (byte[] fullBuffer, int offset, int length)
|
||||
{
|
||||
if (length >= 0)
|
||||
@ -66,12 +75,10 @@ public class AssemblerProgram extends AbstractFile
|
||||
@Override
|
||||
public String getAssembler ()
|
||||
{
|
||||
// String text = super.getAssembler ();
|
||||
if (buffer == null)
|
||||
return "No buffer";
|
||||
if (assembler == null)
|
||||
this.assembler = new AssemblerProgram (name, buffer, loadAddress);
|
||||
// return assembler.getText ();
|
||||
|
||||
if (extraBuffer.length == 0)
|
||||
return assembler.getText ();
|
||||
@ -94,82 +101,17 @@ public class AssemblerProgram extends AbstractFile
|
||||
|
||||
if (executeOffset > 0)
|
||||
pgm.append (String.format ("Entry : $%04X%n", (loadAddress + executeOffset)));
|
||||
pgm.append (String.format ("%n"));
|
||||
|
||||
String stringText = getStringsText ();
|
||||
pgm.append ("\n");
|
||||
pgm.append (getListing ());
|
||||
|
||||
return pgm.append (getStringBuilder2 ()).toString () + stringText;
|
||||
if (assemblerPreferences.showStrings)
|
||||
pgm.append (getStringsText ());
|
||||
|
||||
return pgm.toString ();
|
||||
}
|
||||
|
||||
// private StringBuilder getStringBuilder ()
|
||||
// {
|
||||
// if (true)
|
||||
// return getStringBuilder2 ();
|
||||
//
|
||||
// StringBuilder pgm = new StringBuilder ();
|
||||
//
|
||||
// int ptr = executeOffset;
|
||||
// int address = loadAddress + executeOffset;
|
||||
//
|
||||
// // if the assembly doesn't start at the beginning, just dump the bytes that
|
||||
// // are skipped
|
||||
// for (int i = 0; i < executeOffset; i++)
|
||||
// pgm.append (String.format ("%04X: %02X%n", (loadAddress + i), buffer[i]));
|
||||
//
|
||||
// while (ptr < buffer.length)
|
||||
// {
|
||||
// StringBuilder line = new StringBuilder ();
|
||||
//
|
||||
// AssemblerStatement cmd = new AssemblerStatement (buffer[ptr]);
|
||||
//
|
||||
// if (cmd.size == 2 && ptr < buffer.length - 1)
|
||||
// cmd.addData (buffer[ptr + 1]);
|
||||
// else if (cmd.size == 3 && ptr < buffer.length - 2)
|
||||
// cmd.addData (buffer[ptr + 1], buffer[ptr + 2]);
|
||||
// else
|
||||
// cmd.size = 1;
|
||||
//
|
||||
// line.append (String.format ("%04X: ", address));
|
||||
// for (int i = 0; i < cmd.size; i++)
|
||||
// line.append (String.format ("%02X ", buffer[ptr + i]));
|
||||
// while (line.length () < 20)
|
||||
// line.append (" ");
|
||||
// line.append (cmd.mnemonic + " " + cmd.operand);
|
||||
// if (cmd.offset != 0)
|
||||
// {
|
||||
// int branch = address + cmd.offset + 2;
|
||||
// line.append (String.format ("$%04X", branch < 0 ? branch += 0xFFFF : branch));
|
||||
// }
|
||||
//
|
||||
// if (cmd.target > 0
|
||||
// && (cmd.target < loadAddress - 1 || cmd.target > (loadAddress + buffer.length)))
|
||||
// {
|
||||
// while (line.length () < 40)
|
||||
// line.append (" ");
|
||||
//
|
||||
// String text = equates.get (cmd.target);
|
||||
// if (text != null)
|
||||
// line.append ("; " + text);
|
||||
// else
|
||||
// for (int i = 0, max = ApplesoftConstants.tokenAddresses.length; i < max; i++)
|
||||
// if (cmd.target == ApplesoftConstants.tokenAddresses[i])
|
||||
// {
|
||||
// line.append ("; Applesoft - " + ApplesoftConstants.tokens[i]);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// pgm.append (line.toString () + "\n");
|
||||
// address += cmd.size;
|
||||
// ptr += cmd.size;
|
||||
// }
|
||||
//
|
||||
// if (pgm.length () > 0)
|
||||
// pgm.deleteCharAt (pgm.length () - 1);
|
||||
//
|
||||
// return pgm;
|
||||
// }
|
||||
|
||||
private StringBuilder getStringBuilder2 ()
|
||||
private String getListing ()
|
||||
{
|
||||
StringBuilder pgm = new StringBuilder ();
|
||||
List<AssemblerStatement> lines = getLines ();
|
||||
@ -183,8 +125,9 @@ public class AssemblerProgram extends AbstractFile
|
||||
{
|
||||
StringBuilder line = new StringBuilder ();
|
||||
|
||||
String arrowText = assemblerPreferences.showTargets ? getArrow (cmd) : "";
|
||||
line.append (
|
||||
String.format ("%3.3s %04X: %02X ", getArrow (cmd), cmd.address, cmd.value));
|
||||
String.format ("%3.3s %04X: %02X ", arrowText, cmd.address, cmd.value));
|
||||
|
||||
if (cmd.size > 1)
|
||||
line.append (String.format ("%02X ", cmd.operand1));
|
||||
@ -223,7 +166,7 @@ public class AssemblerProgram extends AbstractFile
|
||||
if (pgm.length () > 0)
|
||||
pgm.deleteCharAt (pgm.length () - 1);
|
||||
|
||||
return pgm;
|
||||
return pgm.toString ();
|
||||
}
|
||||
|
||||
private List<AssemblerStatement> getLines ()
|
||||
@ -270,36 +213,20 @@ public class AssemblerProgram extends AbstractFile
|
||||
return lines;
|
||||
}
|
||||
|
||||
private Map<Integer, String> getStrings ()
|
||||
{
|
||||
TreeMap<Integer, String> strings = new TreeMap<> ();
|
||||
|
||||
int start = 0;
|
||||
for (int ptr = 0; ptr < buffer.length; ptr++)
|
||||
{
|
||||
if ((buffer[ptr] & 0x80) != 0) // high bit set
|
||||
continue;
|
||||
|
||||
if (buffer[ptr] == 0 && ptr - start > 5) // possible end of string
|
||||
strings.put (start, HexFormatter.getString (buffer, start, ptr - start));
|
||||
|
||||
start = ptr + 1;
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
private String getStringsText ()
|
||||
{
|
||||
Map<Integer, String> strings = getStrings ();
|
||||
if (strings.size () == 0)
|
||||
return "";
|
||||
List<Integer> entryPoints = getEntryPoints ();
|
||||
|
||||
StringBuilder text = new StringBuilder ("\n\nPossible strings:\n\n");
|
||||
for (Integer key : strings.keySet ())
|
||||
{
|
||||
String s = strings.get (key);
|
||||
int start = key + loadAddress;
|
||||
text.append (String.format ("%04X - %04X %s %n", start, start + s.length (), s));
|
||||
text.append (String.format ("%s %04X - %04X %s %n",
|
||||
entryPoints.contains (start) ? "*" : " ", start, start + s.length (), s));
|
||||
}
|
||||
|
||||
if (text.length () > 0)
|
||||
@ -308,18 +235,57 @@ public class AssemblerProgram extends AbstractFile
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
private Map<Integer, String> getStrings ()
|
||||
{
|
||||
TreeMap<Integer, String> strings = new TreeMap<> ();
|
||||
|
||||
int start = 0;
|
||||
for (int ptr = 0; ptr < buffer.length; ptr++)
|
||||
{
|
||||
if ((buffer[ptr] & 0x80) != 0) // high bit set
|
||||
continue;
|
||||
|
||||
if (buffer[ptr] == 0 // possible end of string
|
||||
&& ptr - start > 5)
|
||||
strings.put (start, HexFormatter.getString (buffer, start, ptr - start));
|
||||
|
||||
start = ptr + 1;
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
private List<Integer> getEntryPoints ()
|
||||
{
|
||||
List<Integer> entryPoints = new ArrayList<> ();
|
||||
|
||||
for (int ptr = 0; ptr < buffer.length; ptr++)
|
||||
if ((buffer[ptr] == (byte) 0xBD || buffer[ptr] == (byte) 0xB9)
|
||||
&& (ptr + 2 < buffer.length))
|
||||
{
|
||||
int address = Utility.getWord (buffer, ptr + 1);
|
||||
if (address > loadAddress && address < loadAddress + buffer.length)
|
||||
entryPoints.add (address);
|
||||
}
|
||||
|
||||
return entryPoints;
|
||||
}
|
||||
|
||||
private String getArrow (AssemblerStatement cmd)
|
||||
{
|
||||
String arrow = "";
|
||||
|
||||
if (cmd.value == 0x4C || cmd.value == 0x6C || cmd.value == 0x60 || cmd.offset != 0)
|
||||
arrow = "<--";
|
||||
|
||||
if (cmd.value == 0x20 && isLocal (cmd.target)) // JSR
|
||||
arrow = "<--";
|
||||
|
||||
if (cmd.isTarget)
|
||||
if (arrow.isEmpty ())
|
||||
arrow = "-->";
|
||||
else
|
||||
arrow = "<->";
|
||||
|
||||
return arrow;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ public class AssemblerStatement
|
||||
public int address;
|
||||
public boolean isTarget;
|
||||
public byte operand1, operand2;
|
||||
String ascii = "";
|
||||
|
||||
public static void print ()
|
||||
{
|
||||
@ -73,6 +74,23 @@ public class AssemblerStatement
|
||||
this.mnemonic = AssemblerConstants.mnemonics[this.opcode];
|
||||
this.size = AssemblerConstants.sizes2[this.opcode];
|
||||
this.operand = "";
|
||||
ascii = getChar (opcode);
|
||||
}
|
||||
|
||||
String getChar (byte val)
|
||||
{
|
||||
int c = val & 0xFF;
|
||||
if (c > 127)
|
||||
{
|
||||
if (c < 160)
|
||||
c -= 64;
|
||||
else
|
||||
c -= 128;
|
||||
}
|
||||
if (c < 32 || c == 127) // non-printable
|
||||
return ".";
|
||||
else // standard ascii
|
||||
return (char) c + "";
|
||||
}
|
||||
|
||||
public void addData ()
|
||||
@ -131,6 +149,7 @@ public class AssemblerStatement
|
||||
String address = "$" + HexFormatter.format2 (b);
|
||||
// if (this.mnemonic.equals ("JSR"))
|
||||
// this.target = HexFormatter.intValue (b);
|
||||
ascii += getChar (b);
|
||||
|
||||
switch (this.opcode)
|
||||
{
|
||||
@ -271,6 +290,7 @@ public class AssemblerStatement
|
||||
// || this.mnemonic.equals ("BIT") || this.mnemonic.equals ("STA")
|
||||
// || this.mnemonic.equals ("LDA"))
|
||||
// this.target = HexFormatter.intValue (b1, b2);
|
||||
ascii += getChar (b1) + getChar (b2);
|
||||
|
||||
switch (this.opcode)
|
||||
{
|
||||
|
@ -285,6 +285,7 @@ public abstract class HiResImage extends AbstractFile
|
||||
switch (type)
|
||||
{
|
||||
case 0: // copy next 1-64 bytes as is
|
||||
count = Math.min (count, buffer.length - ptr);
|
||||
while (count-- != 0)
|
||||
newBuf[newPtr++] = buffer[ptr++];
|
||||
break;
|
||||
|
@ -2,6 +2,7 @@ package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
public class SimpleText extends AbstractFile
|
||||
{
|
||||
// LISA text file
|
||||
|
||||
public SimpleText (String name, byte[] buffer)
|
||||
{
|
||||
|
@ -40,12 +40,12 @@ class DosVTOCSector extends AbstractSector
|
||||
@Override
|
||||
public String createText ()
|
||||
{
|
||||
return dosVersion <= 3 ? createDosText () : createOtherText ();
|
||||
return dosVersion <= 3 ? createDosText () : createDos4Text ();
|
||||
}
|
||||
|
||||
private String createOtherText ()
|
||||
private String createDos4Text ()
|
||||
{
|
||||
StringBuilder text = getHeader ("DOS 4.1 VTOC Sector");
|
||||
StringBuilder text = getHeader ("DOS 4 VTOC Sector");
|
||||
addText (text, buffer, 0, 1, "Not used");
|
||||
addText (text, buffer, 1, 2, "First directory track/sector");
|
||||
addText (text, buffer, 3, 1, "DOS release number");
|
||||
@ -81,17 +81,17 @@ class DosVTOCSector extends AbstractSector
|
||||
addTextAndDecimal (text, buffer, 0x36, 2, "Bytes per sector");
|
||||
|
||||
boolean bootSectorEmpty = parentDisk.getDisk ().isSectorEmpty (0);
|
||||
int base = 0x38;
|
||||
int max = maxTracks * 4 + base;
|
||||
for (int i = base; i < max; i += 4)
|
||||
int firstSector = 0x38;
|
||||
int max = maxTracks * 4 + firstSector;
|
||||
for (int i = firstSector; i < max; i += 4)
|
||||
{
|
||||
String extra = "";
|
||||
if (i == base && bootSectorEmpty)
|
||||
if (i == firstSector && bootSectorEmpty)
|
||||
extra = "(unusable)";
|
||||
else if (i == 124)
|
||||
extra = "(VTOC and Catalog)";
|
||||
addText (text, buffer, i, 4, String.format ("Track %02X %s %s", (i - base) / 4,
|
||||
getBitmap (buffer[i], buffer[i + 1]), extra));
|
||||
addText (text, buffer, i, 4, String.format ("Track %02X %s %s",
|
||||
(i - firstSector) / 4, getBitmap (buffer[i], buffer[i + 1]), extra));
|
||||
}
|
||||
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
@ -126,17 +126,19 @@ class DosVTOCSector extends AbstractSector
|
||||
addTextAndDecimal (text, buffer, 54, 2, "Bytes per sector");
|
||||
|
||||
boolean bootSectorEmpty = parentDisk.getDisk ().isSectorEmpty (0);
|
||||
for (int i = 56; i <= 0xC3; i += 4)
|
||||
int firstSector = 0x38;
|
||||
int max = maxTracks * 4 + firstSector;
|
||||
for (int i = firstSector; i < max; i += 4)
|
||||
{
|
||||
String extra = "";
|
||||
if (i == 56 && bootSectorEmpty)
|
||||
if (i == firstSector && bootSectorEmpty)
|
||||
extra = "(unusable)";
|
||||
// else if (i <= 64 && !bootSectorEmpty)
|
||||
// extra = "(reserved for DOS)";
|
||||
// else if (i == 124)
|
||||
// extra = "(VTOC and Catalog)";
|
||||
addText (text, buffer, i, 4, String.format ("Track %02X %s %s", (i - 56) / 4,
|
||||
getBitmap (buffer[i], buffer[i + 1]), extra));
|
||||
addText (text, buffer, i, 4, String.format ("Track %02X %s %s",
|
||||
(i - firstSector) / 4, getBitmap (buffer[i], buffer[i + 1]), extra));
|
||||
}
|
||||
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
@ -172,9 +174,9 @@ class DosVTOCSector extends AbstractSector
|
||||
{
|
||||
int block = 0;
|
||||
int base = maxSectors == 13 ? 3 : 0;
|
||||
int first = 0x38;
|
||||
int max = maxTracks * 4 + first;
|
||||
for (int i = first; i < max; i += 4)
|
||||
int firstSector = 0x38;
|
||||
int max = maxTracks * 4 + firstSector;
|
||||
for (int i = firstSector; i < max; i += 4)
|
||||
{
|
||||
block = check (buffer[i + 1], block, base);
|
||||
block = check (buffer[i], block, 0);
|
||||
|
20
src/com/bytezone/diskbrowser/gui/AssemblerPreferences.java
Normal file
20
src/com/bytezone/diskbrowser/gui/AssemblerPreferences.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
public class AssemblerPreferences
|
||||
{
|
||||
public boolean showTargets = true;
|
||||
public boolean showStrings = true;
|
||||
public boolean offsetFromZero = false;
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
text.append (String.format ("Show targets .......... %s%n", showTargets));
|
||||
text.append (String.format ("Show strings .......... %s%n", showStrings));
|
||||
text.append (String.format ("Offset from zero ...... %s%n", offsetFromZero));
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
public interface AssemblerPreferencesListener
|
||||
{
|
||||
public void setAssemblerPreferences (AssemblerPreferences assemblerPreferences);
|
||||
}
|
@ -13,18 +13,15 @@ import javax.swing.event.ChangeListener;
|
||||
|
||||
import com.bytezone.common.FontAction.FontChangeEvent;
|
||||
import com.bytezone.common.FontAction.FontChangeListener;
|
||||
import com.bytezone.diskbrowser.applefile.ApplesoftBasicProgram;
|
||||
import com.bytezone.diskbrowser.applefile.HiResImage;
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
import com.bytezone.diskbrowser.applefile.*;
|
||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||
import com.bytezone.diskbrowser.applefile.QuickDrawFont;
|
||||
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.SectorList;
|
||||
|
||||
class DataPanel extends JTabbedPane
|
||||
implements DiskSelectionListener, FileSelectionListener, SectorSelectionListener,
|
||||
FileNodeSelectionListener, FontChangeListener, BasicPreferencesListener
|
||||
FileNodeSelectionListener, FontChangeListener, BasicPreferencesListener,
|
||||
AssemblerPreferencesListener
|
||||
{
|
||||
private static final int TEXT_WIDTH = 65;
|
||||
|
||||
@ -427,4 +424,11 @@ class DataPanel extends JTabbedPane
|
||||
if (currentDataSource instanceof ApplesoftBasicProgram)
|
||||
setDataSource (currentDataSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAssemblerPreferences (AssemblerPreferences assemblerPreferences)
|
||||
{
|
||||
if (currentDataSource instanceof AssemblerProgram)
|
||||
setDataSource (currentDataSource);
|
||||
}
|
||||
}
|
@ -168,6 +168,7 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
hideCatalogAction.set (false);
|
||||
|
||||
menuHandler.addBasicPreferencesListener (dataPanel);
|
||||
menuHandler.addAssemblerPreferencesListener (dataPanel);
|
||||
|
||||
// activate the highest panel now that the listeners are ready
|
||||
catalogPanel.activate ();
|
||||
|
@ -12,11 +12,7 @@ import javax.swing.*;
|
||||
|
||||
import com.bytezone.common.EnvironmentAction;
|
||||
import com.bytezone.common.FontAction;
|
||||
import com.bytezone.diskbrowser.applefile.BasicProgram;
|
||||
import com.bytezone.diskbrowser.applefile.HiResImage;
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
import com.bytezone.diskbrowser.applefile.PaletteFactory;
|
||||
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
||||
import com.bytezone.diskbrowser.applefile.*;
|
||||
import com.bytezone.diskbrowser.disk.DataDisk;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
@ -37,20 +33,29 @@ public class MenuHandler
|
||||
private static final String PREFS_SHOW_HEADER = "showHeader";
|
||||
private static final String PREFS_SHOW_CARET = "showCaret";
|
||||
|
||||
private static final String PREFS_SHOW_ASSEMBLER_TARGETS = "showAssemblerTargets";
|
||||
private static final String PREFS_SHOW_ASSEMBLER_STRINGS = "showAssemblerStrings";
|
||||
|
||||
// private static final String PREFS_DEBUGGING = "debugging";
|
||||
private static final String PREFS_PALETTE = "palette";
|
||||
|
||||
FormattedDisk currentDisk;
|
||||
private final SaveTempFileAction saveTempFileAction = new SaveTempFileAction ();
|
||||
|
||||
private final BasicPreferences basicPreferences = new BasicPreferences ();
|
||||
private final List<BasicPreferencesListener> basicPreferencesListeners =
|
||||
new ArrayList<> ();
|
||||
|
||||
private final AssemblerPreferences assemblerPreferences = new AssemblerPreferences ();
|
||||
private final List<AssemblerPreferencesListener> assemblerPreferencesListeners =
|
||||
new ArrayList<> ();
|
||||
|
||||
JMenuBar menuBar = new JMenuBar ();
|
||||
JMenu fileMenu = new JMenu ("File");
|
||||
JMenu formatMenu = new JMenu ("Format");
|
||||
JMenu colourMenu = new JMenu ("Colours");
|
||||
JMenu applesoftMenu = new JMenu ("Applesoft");
|
||||
JMenu assemblerMenu = new JMenu ("Assembler");
|
||||
JMenu helpMenu = new JMenu ("Help");
|
||||
|
||||
// File menu items
|
||||
@ -82,14 +87,19 @@ public class MenuHandler
|
||||
final JMenuItem nextPaletteItem = new JMenuItem ("Next Palette");
|
||||
final JMenuItem prevPaletteItem = new JMenuItem ("Previous Palette");
|
||||
|
||||
// Applesoft menu items
|
||||
final JMenuItem splitRemarkItem = new JCheckBoxMenuItem ("Split remarks");
|
||||
final JMenuItem alignAssignItem = new JCheckBoxMenuItem ("Align assign");
|
||||
final JMenuItem showTargetsItem = new JCheckBoxMenuItem ("Show targets");
|
||||
final JMenuItem showBasicTargetsItem = new JCheckBoxMenuItem ("Show targets");
|
||||
final JMenuItem onlyShowTargetLinesItem =
|
||||
new JCheckBoxMenuItem ("Only show target lines");
|
||||
final JMenuItem showHeaderItem = new JCheckBoxMenuItem ("Show header");
|
||||
final JMenuItem showCaretItem = new JCheckBoxMenuItem ("Show caret");
|
||||
|
||||
// Assembler menu items
|
||||
final JMenuItem showAssemblerTargetsItem = new JCheckBoxMenuItem ("Show targets");
|
||||
final JMenuItem showAssemblerStringsItem = new JCheckBoxMenuItem ("Show strings");
|
||||
|
||||
ButtonGroup paletteGroup = new ButtonGroup ();
|
||||
|
||||
public MenuHandler ()
|
||||
@ -98,6 +108,7 @@ public class MenuHandler
|
||||
menuBar.add (formatMenu);
|
||||
menuBar.add (colourMenu);
|
||||
menuBar.add (applesoftMenu);
|
||||
menuBar.add (assemblerMenu);
|
||||
menuBar.add (helpMenu);
|
||||
|
||||
fileMenu.add (rootItem);
|
||||
@ -156,11 +167,14 @@ public class MenuHandler
|
||||
|
||||
applesoftMenu.add (splitRemarkItem);
|
||||
applesoftMenu.add (alignAssignItem);
|
||||
applesoftMenu.add (showTargetsItem);
|
||||
applesoftMenu.add (showBasicTargetsItem);
|
||||
applesoftMenu.add (onlyShowTargetLinesItem);
|
||||
applesoftMenu.add (showHeaderItem);
|
||||
applesoftMenu.add (showCaretItem);
|
||||
|
||||
assemblerMenu.add (showAssemblerTargetsItem);
|
||||
assemblerMenu.add (showAssemblerStringsItem);
|
||||
|
||||
ActionListener basicPreferencesAction = new ActionListener ()
|
||||
{
|
||||
@Override
|
||||
@ -171,13 +185,26 @@ public class MenuHandler
|
||||
}
|
||||
};
|
||||
|
||||
ActionListener assemblerPreferencesAction = new ActionListener ()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
setAssemblerPreferences ();
|
||||
notifyAssemblerPreferencesListeners ();
|
||||
}
|
||||
};
|
||||
|
||||
splitRemarkItem.addActionListener (basicPreferencesAction);
|
||||
alignAssignItem.addActionListener (basicPreferencesAction);
|
||||
showTargetsItem.addActionListener (basicPreferencesAction);
|
||||
showBasicTargetsItem.addActionListener (basicPreferencesAction);
|
||||
onlyShowTargetLinesItem.addActionListener (basicPreferencesAction);
|
||||
showHeaderItem.addActionListener (basicPreferencesAction);
|
||||
showCaretItem.addActionListener (basicPreferencesAction);
|
||||
|
||||
showAssemblerTargetsItem.addActionListener (assemblerPreferencesAction);
|
||||
showAssemblerStringsItem.addActionListener (assemblerPreferencesAction);
|
||||
|
||||
helpMenu.add (new JMenuItem (new EnvironmentAction ()));
|
||||
|
||||
sector256Item.setActionCommand ("256");
|
||||
@ -204,7 +231,7 @@ public class MenuHandler
|
||||
basicPreferences.alignAssign = alignAssignItem.isSelected ();
|
||||
basicPreferences.showCaret = showCaretItem.isSelected ();
|
||||
basicPreferences.showHeader = showHeaderItem.isSelected ();
|
||||
basicPreferences.showTargets = showTargetsItem.isSelected ();
|
||||
basicPreferences.showTargets = showBasicTargetsItem.isSelected ();
|
||||
basicPreferences.onlyShowTargetLineNumbers = onlyShowTargetLinesItem.isSelected ();
|
||||
BasicProgram.setBasicPreferences (basicPreferences);
|
||||
}
|
||||
@ -224,6 +251,28 @@ public class MenuHandler
|
||||
listener.setBasicPreferences (basicPreferences);
|
||||
}
|
||||
|
||||
private void setAssemblerPreferences ()
|
||||
{
|
||||
assemblerPreferences.showTargets = showAssemblerTargetsItem.isSelected ();
|
||||
assemblerPreferences.showStrings = showAssemblerStringsItem.isSelected ();
|
||||
AssemblerProgram.setAssemblerPreferences (assemblerPreferences);
|
||||
}
|
||||
|
||||
void addAssemblerPreferencesListener (AssemblerPreferencesListener listener)
|
||||
{
|
||||
if (!assemblerPreferencesListeners.contains (listener))
|
||||
{
|
||||
assemblerPreferencesListeners.add (listener);
|
||||
listener.setAssemblerPreferences (assemblerPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
void notifyAssemblerPreferencesListeners ()
|
||||
{
|
||||
for (AssemblerPreferencesListener listener : assemblerPreferencesListeners)
|
||||
listener.setAssemblerPreferences (assemblerPreferences);
|
||||
}
|
||||
|
||||
void addHelpMenuAction (Action action, String functionName)
|
||||
{
|
||||
helpMenu.add (new JMenuItem (action));
|
||||
@ -267,8 +316,13 @@ public class MenuHandler
|
||||
prefs.putBoolean (PREFS_ALIGN_ASSIGN, alignAssignItem.isSelected ());
|
||||
prefs.putBoolean (PREFS_SHOW_CARET, showCaretItem.isSelected ());
|
||||
prefs.putBoolean (PREFS_SHOW_HEADER, showHeaderItem.isSelected ());
|
||||
prefs.putBoolean (PREFS_SHOW_TARGETS, showTargetsItem.isSelected ());
|
||||
prefs.putBoolean (PREFS_SHOW_TARGETS, showBasicTargetsItem.isSelected ());
|
||||
prefs.putBoolean (PREFS_ONLY_SHOW_TARGETS, onlyShowTargetLinesItem.isSelected ());
|
||||
|
||||
prefs.putBoolean (PREFS_SHOW_ASSEMBLER_TARGETS,
|
||||
showAssemblerTargetsItem.isSelected ());
|
||||
prefs.putBoolean (PREFS_SHOW_ASSEMBLER_STRINGS,
|
||||
showAssemblerStringsItem.isSelected ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -286,11 +340,17 @@ public class MenuHandler
|
||||
alignAssignItem.setSelected (prefs.getBoolean (PREFS_ALIGN_ASSIGN, true));
|
||||
showCaretItem.setSelected (prefs.getBoolean (PREFS_SHOW_CARET, false));
|
||||
showHeaderItem.setSelected (prefs.getBoolean (PREFS_SHOW_HEADER, true));
|
||||
showTargetsItem.setSelected (prefs.getBoolean (PREFS_SHOW_TARGETS, false));
|
||||
showBasicTargetsItem.setSelected (prefs.getBoolean (PREFS_SHOW_TARGETS, false));
|
||||
onlyShowTargetLinesItem
|
||||
.setSelected (prefs.getBoolean (PREFS_ONLY_SHOW_TARGETS, false));
|
||||
|
||||
showAssemblerTargetsItem
|
||||
.setSelected (prefs.getBoolean (PREFS_SHOW_ASSEMBLER_TARGETS, true));
|
||||
showAssemblerStringsItem
|
||||
.setSelected (prefs.getBoolean (PREFS_SHOW_ASSEMBLER_STRINGS, true));
|
||||
|
||||
setBasicPreferences ();
|
||||
setAssemblerPreferences ();
|
||||
|
||||
int paletteIndex = prefs.getInt (PREFS_PALETTE, 0);
|
||||
PaletteFactory paletteFactory = HiResImage.getPaletteFactory ();
|
||||
|
@ -24,7 +24,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
private final int endOfFile;
|
||||
private final int auxType;
|
||||
private final GregorianCalendar modified;
|
||||
// private final int headerPointer;
|
||||
private final int headerPointer;
|
||||
private DataSource file;
|
||||
private final DiskAddress catalogBlock;
|
||||
|
||||
@ -50,7 +50,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
|
||||
auxType = HexFormatter.unsignedShort (entryBuffer, 0x1F);
|
||||
modified = HexFormatter.getAppleDate (entryBuffer, 0x21);
|
||||
// headerPointer = HexFormatter.unsignedShort (entryBuffer, 0x25);
|
||||
headerPointer = HexFormatter.unsignedShort (entryBuffer, 0x25);
|
||||
|
||||
switch (storageType)
|
||||
{
|
||||
@ -287,6 +287,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
assert auxType == 0; // auxType > 0 handled above
|
||||
if (name.endsWith (".S"))
|
||||
file = new MerlinSource (name, exactBuffer, auxType, endOfFile);
|
||||
else if (name.endsWith ("PLA"))
|
||||
file = new SimpleText (name, exactBuffer);
|
||||
else if (name.endsWith (".GIF") && HiResImage.isGif (exactBuffer))
|
||||
file = new OriginalHiResImage (name, exactBuffer, auxType);
|
||||
else
|
||||
@ -400,6 +402,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
case FILE_TYPE_LDF:
|
||||
case FILE_TYPE_ANI:
|
||||
case FILE_TYPE_PAL:
|
||||
case FILE_TYPE_IIGS_OBJECT:
|
||||
file = new DefaultAppleFile (name, exactBuffer);
|
||||
break;
|
||||
|
||||
@ -411,7 +414,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.format ("%s - Unknown Prodos file type : %02X%n", name, fileType);
|
||||
// System.out.format ("%02X %s %s - Unknown Prodos file type%n",
|
||||
// fileType, fileTypes[fileType], name);
|
||||
file = new DefaultAppleFile (name, exactBuffer);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user