1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-01-14 07:29:44 +00:00

Improve CPU instruction chart

Added "show undocumented opcodes" checkbox, so you can choose
whether or not to see them at all.  (Issue #60)

Added formatter call for the instruction mnemonics so they get
capitalized when the app is configured for upper-case opcodes.
(Issue #59)

Fix a bug where the instruction chart and ASCII chart were writing
their modes to the same setting, stomping each other.

Also, pluralized a button in the file concatenator.
This commit is contained in:
Andy McFadden 2020-02-18 13:25:20 -08:00
parent ecbb01db1f
commit 0ab76ea1f7
5 changed files with 31 additions and 9 deletions

View File

@ -111,6 +111,10 @@ namespace SourceGen {
// ASCII chart viewer settings.
public const string ASCCH_MODE = "ascch-mode1";
// Instruction chart settings.
public const string INSTCH_MODE = "instch-mode";
public const string INSTCH_SHOW_UNDOC = "instch-show-undoc";
// Source generation settings.
public const string SRCGEN_DEFAULT_ASM = "srcgen-default-asm";
public const string SRCGEN_ADD_IDENT_COMMENT = "srcgen-add-ident-comment";

View File

@ -14,8 +14,9 @@
<h2><a name="instruction-chart">Instruction Chart</a></h2>
<p>This opens a window with a summary of all 256 opcodes. The CPU can
be chosen from the pop-up list at the bottom. Undocumented opcodes are
shown in italics.</p>
be chosen from the pop-up list at the bottom. Undocumented opcodes for
6502/65C02 are shown in italics, and can be excluded from the list
by unchecking the box at the bottom.</p>
<p>The status flags affected by each instruction reflect their behavior
on the 65816. The only significant difference between 65816 and
6502/65C02 is the way the BRK instruction affects the D and B/X flags.</p>

View File

@ -81,7 +81,7 @@ limitations under the License.
</DataGrid>
<StackPanel Grid.Row="1" Grid.Column="1" Margin="4,0,0,0">
<Button Width="90" Content="Add File..." Click="AddButton_Click"/>
<Button Width="90" Content="Add Files..." Click="AddButton_Click"/>
<Button Width="90" Margin="0,4,0,0" Content="Remove File"
IsEnabled="{Binding IsRemoveEnabled}" Click="RemoveButton_Click"/>
<Button Width="90" Margin="0,12,0,0" Content="Up"

View File

@ -41,6 +41,9 @@ limitations under the License.
HorizontalAlignment="Left"
ItemsSource="{Binding CpuItems}" DisplayMemberPath="Name"
SelectionChanged="CpuSelectionComboBox_SelectionChanged"/>
<CheckBox Margin="32,4,0,0" Content="Show undocumented instructions"
IsChecked="{Binding ShowUndocumented}"/>
</StackPanel>
<DataGrid DockPanel.Dock="Top" Name="instructionGrid"
@ -57,8 +60,9 @@ limitations under the License.
SelectionMode="Extended"
VerticalScrollBarVisibility="Visible">
<DataGrid.Resources>
<Style x:Key="undocCellStyle" TargetType="{x:Type DataGridCell}">
<Style x:Key="cellStyle" TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<!-- show undocumented opcodes differently -->
<DataTrigger Binding="{Binding Path=IsUndocumented}" Value="True">
<Setter Property="FontStyle" Value="Italic"/>
<Setter Property="Foreground"
@ -70,7 +74,7 @@ limitations under the License.
<DataGrid.Columns>
<DataGridTextColumn Header="Opc" Binding="{Binding Opcode}"/>
<DataGridTextColumn Header="Instruction" Binding="{Binding Sample}"
CellStyle="{StaticResource undocCellStyle}"/>
CellStyle="{StaticResource cellStyle}"/>
<DataGridTextColumn Header="Flags" Binding="{Binding Flags}"/>
<DataGridTextColumn Header="Cyc" Binding="{Binding Cycles}"/>
<DataGridTextColumn Header="Description" Binding="{Binding ShortDesc}"

View File

@ -45,6 +45,12 @@ namespace SourceGen.Tools.WpfGui {
}
public CpuItem[] CpuItems { get; private set; }
public bool ShowUndocumented {
get { return mShowUndocumented; }
set { mShowUndocumented = value; OnPropertyChanged(); UpdateControls(); }
}
private bool mShowUndocumented;
/// <summary>
/// Item for main list.
/// </summary>
@ -104,9 +110,11 @@ namespace SourceGen.Tools.WpfGui {
}
public void Window_Loaded(object sender, RoutedEventArgs e) {
// Restore chart mode setting.
// Restore chart settings.
CpuDef.CpuType type = (CpuDef.CpuType)AppSettings.Global.GetEnum(
AppSettings.ASCCH_MODE, typeof(CpuDef.CpuType), (int)CpuDef.CpuType.Cpu6502);
AppSettings.INSTCH_MODE, typeof(CpuDef.CpuType), (int)CpuDef.CpuType.Cpu6502);
ShowUndocumented = AppSettings.Global.GetBool(AppSettings.INSTCH_SHOW_UNDOC, true);
int index = 0;
for (int i = 0; i < CpuItems.Length; i++) {
if (CpuItems[i].Type == type) {
@ -137,14 +145,18 @@ namespace SourceGen.Tools.WpfGui {
}
// Push current choice to settings.
AppSettings.Global.SetEnum(AppSettings.ASCCH_MODE, typeof(CpuDef.CpuType),
AppSettings.Global.SetEnum(AppSettings.INSTCH_MODE, typeof(CpuDef.CpuType),
(int)item.Type);
AppSettings.Global.SetBool(AppSettings.INSTCH_SHOW_UNDOC, mShowUndocumented);
// Populate the items source.
InstructionItems.Clear();
CpuDef cpuDef = CpuDef.GetBestMatch(item.Type, true, false);
for (int opc = 0; opc < 256; opc++) {
OpDef op = cpuDef[opc];
if (!mShowUndocumented && op.IsUndocumented) {
continue;
}
int opLen = op.GetLength(StatusFlags.AllIndeterminate);
string sampleValue = "$12";
@ -155,7 +167,8 @@ namespace SourceGen.Tools.WpfGui {
} else if (opLen == 4) {
sampleValue = "$123456";
}
string instrSample = op.Mnemonic + " " +
string instrSample = mFormatter.FormatMnemonic(op.Mnemonic,
OpDef.WidthDisambiguation.None) + " " +
mFormatter.FormatOperand(op, sampleValue, OpDef.WidthDisambiguation.None);