mirror of
https://github.com/fadden/6502bench.git
synced 2024-12-01 07:50:37 +00:00
Show code/data/junk percentages in status bar
Not necessarily useful, but sort of interesting.
This commit is contained in:
parent
e43b7233d9
commit
d8170c50d3
@ -176,6 +176,17 @@ namespace SourceGen {
|
|||||||
// List of messages, mostly problems detected during analysis.
|
// List of messages, mostly problems detected during analysis.
|
||||||
public MessageList Messages { get; private set; }
|
public MessageList Messages { get; private set; }
|
||||||
|
|
||||||
|
public class CodeDataCounts {
|
||||||
|
public int CodeByteCount { get; set; }
|
||||||
|
public int DataByteCount { get; set; }
|
||||||
|
public int JunkByteCount { get; set; }
|
||||||
|
|
||||||
|
public void Reset() {
|
||||||
|
CodeByteCount = DataByteCount = JunkByteCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public CodeDataCounts ByteCounts { get; private set; } = new CodeDataCounts();
|
||||||
|
|
||||||
#if DATA_PRESCAN
|
#if DATA_PRESCAN
|
||||||
// Data scan results.
|
// Data scan results.
|
||||||
public TypedRangeSet RepeatedBytes { get; private set; }
|
public TypedRangeSet RepeatedBytes { get; private set; }
|
||||||
@ -1409,6 +1420,9 @@ namespace SourceGen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No particular reason to do this here, but it's convenient.
|
||||||
|
ByteCounts.Reset();
|
||||||
|
|
||||||
LocalVariableLookup lvLookup = new LocalVariableLookup(LvTables, this,
|
LocalVariableLookup lvLookup = new LocalVariableLookup(LvTables, this,
|
||||||
null, false, false);
|
null, false, false);
|
||||||
|
|
||||||
@ -1518,9 +1532,18 @@ namespace SourceGen {
|
|||||||
if (attr.IsDataStart) {
|
if (attr.IsDataStart) {
|
||||||
// There shouldn't be data items inside of other data items.
|
// There shouldn't be data items inside of other data items.
|
||||||
offset += attr.Length;
|
offset += attr.Length;
|
||||||
|
|
||||||
|
if (attr.DataDescriptor != null &&
|
||||||
|
attr.DataDescriptor.FormatType == FormatDescriptor.Type.Junk) {
|
||||||
|
ByteCounts.JunkByteCount += attr.Length;
|
||||||
|
} else {
|
||||||
|
ByteCounts.DataByteCount += attr.Length;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Advance by one, not attr.Length, so we don't miss embedded instructions.
|
// Advance by one, not attr.Length, so we don't miss embedded instructions.
|
||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
|
ByteCounts.CodeByteCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1553,6 +1576,7 @@ namespace SourceGen {
|
|||||||
AutoLabel.Style style = ProjectProps.AutoLabelStyle;
|
AutoLabel.Style style = ProjectProps.AutoLabelStyle;
|
||||||
Debug.Assert(style != AutoLabel.Style.Simple);
|
Debug.Assert(style != AutoLabel.Style.Simple);
|
||||||
|
|
||||||
|
// We don't have a list of auto labels, so just pick them out of anattribs.
|
||||||
for (int offset = 0; offset < mAnattribs.Length; offset++) {
|
for (int offset = 0; offset < mAnattribs.Length; offset++) {
|
||||||
Anattrib attr = mAnattribs[offset];
|
Anattrib attr = mAnattribs[offset];
|
||||||
if (attr.Symbol != null && attr.Symbol.SymbolSource == Symbol.Source.Auto) {
|
if (attr.Symbol != null && attr.Symbol.SymbolSource == Symbol.Source.Auto) {
|
||||||
|
@ -651,6 +651,28 @@ namespace SourceGen {
|
|||||||
sb.Append(Res.Strings.TITLE_MODIFIED);
|
sb.Append(Res.Strings.TITLE_MODIFIED);
|
||||||
}
|
}
|
||||||
mMainWin.Title = sb.ToString();
|
mMainWin.Title = sb.ToString();
|
||||||
|
|
||||||
|
UpdateByteCounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the code/data/junk percentages in the status bar.
|
||||||
|
/// </summary>
|
||||||
|
private void UpdateByteCounts() {
|
||||||
|
if (mProject == null) {
|
||||||
|
mMainWin.ByteCountText = string.Empty;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Assert(mProject.ByteCounts.CodeByteCount + mProject.ByteCounts.DataByteCount +
|
||||||
|
mProject.ByteCounts.JunkByteCount == mProject.FileData.Length);
|
||||||
|
|
||||||
|
int total = mProject.FileData.Length;
|
||||||
|
float codePerc = (mProject.ByteCounts.CodeByteCount * 100.0f) / total;
|
||||||
|
float dataPerc = (mProject.ByteCounts.DataByteCount * 100.0f) / total;
|
||||||
|
float junkPerc = (mProject.ByteCounts.JunkByteCount * 100.0f) / total;
|
||||||
|
mMainWin.ByteCountText = string.Format(Res.Strings.STATUS_BYTE_COUNT_FMT,
|
||||||
|
codePerc, dataPerc, junkPerc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Init and settings
|
#endregion Init and settings
|
||||||
|
@ -156,6 +156,7 @@ limitations under the License.
|
|||||||
<system:String x:Key="str_ScanC64ScreenCode">C64 Screen Code</system:String>
|
<system:String x:Key="str_ScanC64ScreenCode">C64 Screen Code</system:String>
|
||||||
<system:String x:Key="str_SetupSystemSummaryFmt">{1} CPU @ {2} MHz</system:String>
|
<system:String x:Key="str_SetupSystemSummaryFmt">{1} CPU @ {2} MHz</system:String>
|
||||||
<system:String x:Key="str_ShowCol">Show</system:String>
|
<system:String x:Key="str_ShowCol">Show</system:String>
|
||||||
|
<system:String x:Key="str_StatusByteCountFmt">{0:F1}% code, {1:F1}% data, {2:F1}% junk</system:String>
|
||||||
<system:String x:Key="str_StatusReady">Ready</system:String>
|
<system:String x:Key="str_StatusReady">Ready</system:String>
|
||||||
<system:String x:Key="str_StrVfyDciMixedData">DCI string has mixed data</system:String>
|
<system:String x:Key="str_StrVfyDciMixedData">DCI string has mixed data</system:String>
|
||||||
<system:String x:Key="str_StrVfyDciNotTerminated">DCI string not terminated</system:String>
|
<system:String x:Key="str_StrVfyDciNotTerminated">DCI string not terminated</system:String>
|
||||||
|
@ -293,6 +293,8 @@ namespace SourceGen.Res {
|
|||||||
(string)Application.Current.FindResource("str_SetupSystemSummaryFmt");
|
(string)Application.Current.FindResource("str_SetupSystemSummaryFmt");
|
||||||
public static string SHOW_COL =
|
public static string SHOW_COL =
|
||||||
(string)Application.Current.FindResource("str_ShowCol");
|
(string)Application.Current.FindResource("str_ShowCol");
|
||||||
|
public static string STATUS_BYTE_COUNT_FMT =
|
||||||
|
(string)Application.Current.FindResource("str_StatusByteCountFmt");
|
||||||
public static string STATUS_READY =
|
public static string STATUS_READY =
|
||||||
(string)Application.Current.FindResource("str_StatusReady");
|
(string)Application.Current.FindResource("str_StatusReady");
|
||||||
public static string STR_VFY_DCI_MIXED_DATA =
|
public static string STR_VFY_DCI_MIXED_DATA =
|
||||||
|
@ -451,15 +451,21 @@ limitations under the License.
|
|||||||
</ToolBarTray>
|
</ToolBarTray>
|
||||||
|
|
||||||
<StatusBar Name="mainStatusBar" DockPanel.Dock="Bottom">
|
<StatusBar Name="mainStatusBar" DockPanel.Dock="Bottom">
|
||||||
<DockPanel LastChildFill="False"
|
<Grid Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor,
|
||||||
Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor,
|
AncestorType={x:Type StatusBar}}}">
|
||||||
AncestorType={x:Type StatusBar}}}">
|
<Grid.ColumnDefinitions>
|
||||||
<TextBlock DockPanel.Dock="Left" Text="{Binding StatusBarText, FallbackValue=Ready}"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
<Button DockPanel.Dock="Right" Margin="4,0,6,0" Padding="4,0,4,0"
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Grid.Column="0" Text="{Binding StatusBarText, FallbackValue=Ready}"/>
|
||||||
|
<TextBlock Grid.Column="1" HorizontalAlignment="Center"
|
||||||
|
Text="{Binding ByteCountText, FallbackValue=30% code; 60% data; 10% junk}"/>
|
||||||
|
<Button Grid.Column="2" Margin="4,0,6,0" Padding="4,0,4,0"
|
||||||
Content="{Binding MessageStatusText, FallbackValue=3 messages (1 warning/error)}"
|
Content="{Binding MessageStatusText, FallbackValue=3 messages (1 warning/error)}"
|
||||||
Visibility="{Binding Path=CodeListVisibility}"
|
Visibility="{Binding Path=CodeListVisibility}"
|
||||||
Click="MessageStatusButton_Click"/>
|
Click="MessageStatusButton_Click"/>
|
||||||
</DockPanel>
|
</Grid>
|
||||||
</StatusBar>
|
</StatusBar>
|
||||||
|
|
||||||
<!-- Main part of the window. Three side-by-side panels, only the middle of which changes
|
<!-- Main part of the window. Three side-by-side panels, only the middle of which changes
|
||||||
|
@ -58,6 +58,15 @@ namespace SourceGen.WpfGui {
|
|||||||
}
|
}
|
||||||
private string mStatusBarText;
|
private string mStatusBarText;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Text for code/data breakdown string.
|
||||||
|
/// </summary>
|
||||||
|
public string ByteCountText {
|
||||||
|
get { return mByteCountText; }
|
||||||
|
set { mByteCountText = value; OnPropertyChanged(); }
|
||||||
|
}
|
||||||
|
private string mByteCountText;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Width of long comment fields.
|
/// Width of long comment fields.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user