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.
|
||||
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
|
||||
// Data scan results.
|
||||
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,
|
||||
null, false, false);
|
||||
|
||||
@ -1518,9 +1532,18 @@ namespace SourceGen {
|
||||
if (attr.IsDataStart) {
|
||||
// There shouldn't be data items inside of other data items.
|
||||
offset += attr.Length;
|
||||
|
||||
if (attr.DataDescriptor != null &&
|
||||
attr.DataDescriptor.FormatType == FormatDescriptor.Type.Junk) {
|
||||
ByteCounts.JunkByteCount += attr.Length;
|
||||
} else {
|
||||
ByteCounts.DataByteCount += attr.Length;
|
||||
}
|
||||
} else {
|
||||
// Advance by one, not attr.Length, so we don't miss embedded instructions.
|
||||
offset++;
|
||||
|
||||
ByteCounts.CodeByteCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1553,6 +1576,7 @@ namespace SourceGen {
|
||||
AutoLabel.Style style = ProjectProps.AutoLabelStyle;
|
||||
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++) {
|
||||
Anattrib attr = mAnattribs[offset];
|
||||
if (attr.Symbol != null && attr.Symbol.SymbolSource == Symbol.Source.Auto) {
|
||||
|
@ -651,6 +651,28 @@ namespace SourceGen {
|
||||
sb.Append(Res.Strings.TITLE_MODIFIED);
|
||||
}
|
||||
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
|
||||
|
@ -156,6 +156,7 @@ limitations under the License.
|
||||
<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_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_StrVfyDciMixedData">DCI string has mixed data</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");
|
||||
public static string SHOW_COL =
|
||||
(string)Application.Current.FindResource("str_ShowCol");
|
||||
public static string STATUS_BYTE_COUNT_FMT =
|
||||
(string)Application.Current.FindResource("str_StatusByteCountFmt");
|
||||
public static string STATUS_READY =
|
||||
(string)Application.Current.FindResource("str_StatusReady");
|
||||
public static string STR_VFY_DCI_MIXED_DATA =
|
||||
|
@ -451,15 +451,21 @@ limitations under the License.
|
||||
</ToolBarTray>
|
||||
|
||||
<StatusBar Name="mainStatusBar" DockPanel.Dock="Bottom">
|
||||
<DockPanel LastChildFill="False"
|
||||
Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor,
|
||||
AncestorType={x:Type StatusBar}}}">
|
||||
<TextBlock DockPanel.Dock="Left" Text="{Binding StatusBarText, FallbackValue=Ready}"/>
|
||||
<Button DockPanel.Dock="Right" Margin="4,0,6,0" Padding="4,0,4,0"
|
||||
<Grid Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor,
|
||||
AncestorType={x:Type StatusBar}}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<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)}"
|
||||
Visibility="{Binding Path=CodeListVisibility}"
|
||||
Click="MessageStatusButton_Click"/>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</StatusBar>
|
||||
|
||||
<!-- 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;
|
||||
|
||||
/// <summary>
|
||||
/// Text for code/data breakdown string.
|
||||
/// </summary>
|
||||
public string ByteCountText {
|
||||
get { return mByteCountText; }
|
||||
set { mByteCountText = value; OnPropertyChanged(); }
|
||||
}
|
||||
private string mByteCountText;
|
||||
|
||||
/// <summary>
|
||||
/// Width of long comment fields.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user