mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-14 07:30:01 +00:00
Added debug output to Applesoft
This commit is contained in:
parent
0fb9abf6c7
commit
fe648c7e2c
@ -26,6 +26,8 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||
private static final byte TOKEN_THEN = (byte) 0xC4;
|
||||
private static final byte TOKEN_EQUALS = (byte) 0xD0;
|
||||
|
||||
private static boolean debug;
|
||||
|
||||
private final List<SourceLine> sourceLines = new ArrayList<> ();
|
||||
private final int endPtr;
|
||||
private final Set<Integer> gotoLines = new HashSet<> ();
|
||||
@ -55,13 +57,34 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||
endPtr = ptr;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static void setDefaultDebug (boolean value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
debug = value;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static void setDebug (boolean value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
debug = value;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return debug ? getHexText () : getProgramText ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private String getProgramText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder fullText = new StringBuilder ();
|
||||
Stack<String> loopVariables = new Stack<String> ();
|
||||
Stack<String> loopVariables = new Stack<> ();
|
||||
if (basicPreferences.showHeader)
|
||||
addHeader (fullText);
|
||||
int alignPos = 0;
|
||||
@ -422,8 +445,7 @@ public class ApplesoftBasicProgram extends BasicProgram
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getHexDump ()
|
||||
private String getHexText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (buffer.length < 2)
|
||||
|
@ -27,12 +27,12 @@ import javax.swing.event.ChangeListener;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.ApplesoftBasicProgram;
|
||||
import com.bytezone.diskbrowser.applefile.AssemblerProgram;
|
||||
import com.bytezone.diskbrowser.applefile.BasicTextFile;
|
||||
import com.bytezone.diskbrowser.applefile.HiResImage;
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||
import com.bytezone.diskbrowser.applefile.QuickDrawFont;
|
||||
import com.bytezone.diskbrowser.applefile.SHRPictureFile2;
|
||||
import com.bytezone.diskbrowser.applefile.BasicTextFile;
|
||||
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.SectorList;
|
||||
@ -110,7 +110,7 @@ public class DataPanel extends JTabbedPane
|
||||
{
|
||||
switch (getSelectedIndex ())
|
||||
{
|
||||
case 0:
|
||||
case 0: // Formatted
|
||||
if (!formattedTextValid)
|
||||
{
|
||||
if (currentDataSource == null)
|
||||
@ -120,7 +120,7 @@ public class DataPanel extends JTabbedPane
|
||||
formattedTextValid = true;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case 1: // Hex
|
||||
if (!hexTextValid)
|
||||
{
|
||||
if (currentDataSource == null)
|
||||
@ -130,7 +130,7 @@ public class DataPanel extends JTabbedPane
|
||||
hexTextValid = true;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 2: // Assembler
|
||||
if (!assemblerTextValid)
|
||||
{
|
||||
if (currentDataSource == null)
|
||||
@ -261,6 +261,12 @@ public class DataPanel extends JTabbedPane
|
||||
VisicalcFile.setDebug (value);
|
||||
setText (formattedText, visicalcFile.getText ());
|
||||
}
|
||||
else if (currentDataSource instanceof ApplesoftBasicProgram)
|
||||
{
|
||||
ApplesoftBasicProgram basicProgram = (ApplesoftBasicProgram) currentDataSource;
|
||||
ApplesoftBasicProgram.setDebug (value);
|
||||
setText (formattedText, basicProgram.getText ());
|
||||
}
|
||||
// should implement an interface for this
|
||||
else if (currentDataSource instanceof HiResImage
|
||||
|| currentDataSource instanceof QuickDrawFont)
|
||||
@ -284,8 +290,8 @@ public class DataPanel extends JTabbedPane
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int index = getSelectedIndex ();
|
||||
return index == 0 ? formattedText.getText () : index == 1 ? hexText.getText ()
|
||||
: disassemblyText.getText ();
|
||||
return index == 0 ? formattedText.getText ()
|
||||
: index == 1 ? hexText.getText () : disassemblyText.getText ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -17,6 +17,7 @@ import javax.swing.JMenuItem;
|
||||
import javax.swing.JRadioButtonMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.ApplesoftBasicProgram;
|
||||
import com.bytezone.diskbrowser.applefile.AssemblerProgram;
|
||||
import com.bytezone.diskbrowser.applefile.BasicProgram;
|
||||
import com.bytezone.diskbrowser.applefile.BasicTextFile;
|
||||
@ -101,6 +102,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
final JMenuItem closeTabItem = new JMenuItem ();
|
||||
final JMenuItem duplicateItem = new JMenuItem ();
|
||||
final FontAction fontAction = new FontAction ();
|
||||
final JMenuItem debuggingItem = new JCheckBoxMenuItem ("Debugging");
|
||||
|
||||
// Format menu items
|
||||
final JMenuItem lineWrapItem = new JCheckBoxMenuItem ("Line wrap");
|
||||
@ -117,7 +119,6 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
|
||||
final JMenuItem colourQuirksItem = new JCheckBoxMenuItem ("Colour quirks");
|
||||
final JMenuItem monochromeItem = new JCheckBoxMenuItem ("Monochrome");
|
||||
final JMenuItem debuggingItem = new JCheckBoxMenuItem ("Debugging");
|
||||
final JMenuItem nextPaletteItem = new JMenuItem ("Next Palette");
|
||||
final JMenuItem prevPaletteItem = new JMenuItem ("Previous Palette");
|
||||
final JMenuItem scale1Item = new JRadioButtonMenuItem ("Scale 1");
|
||||
@ -571,6 +572,7 @@ class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitL
|
||||
HiResImage.setDefaultColourQuirks (colourQuirksItem.isSelected ());
|
||||
HiResImage.setDefaultMonochrome (monochromeItem.isSelected ());
|
||||
VisicalcFile.setDefaultDebug (debuggingItem.isSelected ());
|
||||
ApplesoftBasicProgram.setDefaultDebug (debuggingItem.isSelected ());
|
||||
|
||||
fontAction.restore (prefs);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user