diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index fa23efa..a70b2e9 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -3952,6 +3952,49 @@ namespace SourceGen { showTextDlg.ShowDialog(); } + public void Debug_ApplyPlatformSymbols() { + ChangeSet cs = new ChangeSet(1); + + foreach (Symbol sym in mProject.SymbolTable) { + if (sym.SymbolSource != Symbol.Source.Platform) { + continue; + } + DefSymbol defSym = (DefSymbol)sym; + if (defSym.MultiMask != null) { + // These would require additional work... probably. + continue; + } + + int offset = mProject.AddrMap.AddressToOffset(0, sym.Value); + if (offset < 0) { + continue; + } + + // Make sure this is the start of an instruction or data item. (If you + // haven't finished hinting code, it's best to disable the string/fill finder.) + Anattrib attr = mProject.GetAnattrib(offset); + if (!attr.IsStart) { + Debug.WriteLine("Found match at non-start +" + offset.ToString("x6") + + ": " + defSym); + continue; + } + + // Check for user label. Okay to overwrite auto label. + if (mProject.UserLabels.ContainsKey(offset)) { + Debug.WriteLine("User label already exists at +" + offset.ToString("x6")); + continue; + } + + // Create a new user label symbol. + Symbol newSym = new Symbol(sym.Label, sym.Value, Symbol.Source.User, + Symbol.Type.GlobalAddr, Symbol.LabelAnnotation.None); + UndoableChange uc = UndoableChange.CreateLabelChange(offset, null, newSym); + cs.Add(uc); + } + + ApplyUndoableChanges(cs); + } + #endregion Debug features } } diff --git a/SourceGen/RuntimeData/Help/advanced.html b/SourceGen/RuntimeData/Help/advanced.html index 6861c3a..736ab3b 100644 --- a/SourceGen/RuntimeData/Help/advanced.html +++ b/SourceGen/RuntimeData/Help/advanced.html @@ -306,10 +306,10 @@ not help you debug 6502 projects.

diff --git a/SourceGen/WpfGui/MainWindow.xaml b/SourceGen/WpfGui/MainWindow.xaml index 591b7aa..8ad6e77 100644 --- a/SourceGen/WpfGui/MainWindow.xaml +++ b/SourceGen/WpfGui/MainWindow.xaml @@ -176,6 +176,7 @@ limitations under the License. + @@ -296,6 +297,8 @@ limitations under the License. CanExecute="IsProjectOpen" Executed="Debug_RefreshCmd_Executed"/> + + diff --git a/SourceGen/WpfGui/MainWindow.xaml.cs b/SourceGen/WpfGui/MainWindow.xaml.cs index cbdb702..dd64af1 100644 --- a/SourceGen/WpfGui/MainWindow.xaml.cs +++ b/SourceGen/WpfGui/MainWindow.xaml.cs @@ -1333,6 +1333,11 @@ namespace SourceGen.WpfGui { mMainCtrl.Debug_ApplesoftToHtml(); } + private void Debug_ApplyPlatformSymbolsCmd_Executed(object sender, + ExecutedRoutedEventArgs e) { + mMainCtrl.Debug_ApplyPlatformSymbols(); + } + private void Debug_ExtensionScriptInfoCmd_Executed(object sender, ExecutedRoutedEventArgs e) { mMainCtrl.Debug_ExtensionScriptInfo();