diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index cff8c0a..f005e1c 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -4187,7 +4187,7 @@ namespace SourceGen { string basPathName = Path.GetFullPath(fileDlg.FileName); try { data = File.ReadAllBytes(basPathName); - } catch (Exception ex) { + } catch (IOException ex) { // not expecting this to happen MessageBox.Show(ex.Message); return; @@ -4201,6 +4201,66 @@ namespace SourceGen { showTextDlg.ShowDialog(); } + public void Debug_ApplyEditCommands() { + OpenFileDialog fileDlg = new OpenFileDialog() { + Filter = Res.Strings.FILE_FILTER_SGEC + "|" + Res.Strings.FILE_FILTER_ALL, + FilterIndex = 1 + }; + if (fileDlg.ShowDialog() != true) { + return; + } + + string sgecPathName = Path.GetFullPath(fileDlg.FileName); + string[] lines; + try { + lines = File.ReadAllLines(sgecPathName); + } catch (IOException ex) { + // not expecting this to happen + MessageBox.Show(ex.Message); + return; + } + + ChangeSet cs = new ChangeSet(1); + + List changed = new List(lines.Length); + + string setComment = "set-comment +"; + foreach (string line in lines) { + if (!line.StartsWith(setComment)) { + Debug.WriteLine("Ignoring " + line); + continue; + } + + int offset; + try { + offset = Convert.ToInt32(line.Substring(setComment.Length, 6), 16); + } catch (Exception ex) { + Debug.WriteLine("Failed on " + line); + MessageBox.Show(ex.Message); + return; + } + + if (changed.Contains(offset)) { + Debug.WriteLine("Skipping repeated entry +" + offset.ToString("X6")); + continue; + } + + string oldComment = mProject.Comments[offset]; + string newComment = line.Substring(setComment.Length + 7); + if (!string.IsNullOrEmpty(oldComment)) { + Debug.WriteLine("Replacing comment +" + offset.ToString("x6") + + " '" + oldComment + "'"); + } + + UndoableChange uc = UndoableChange.CreateCommentChange(offset, + oldComment, newComment); + cs.Add(uc); + changed.Add(offset); + } + + ApplyUndoableChanges(cs); + } + public void Debug_ApplyPlatformSymbols() { ChangeSet cs = new ChangeSet(1); diff --git a/SourceGen/Res/Strings.xaml b/SourceGen/Res/Strings.xaml index a75d4ce..8fd9a64 100644 --- a/SourceGen/Res/Strings.xaml +++ b/SourceGen/Res/Strings.xaml @@ -90,6 +90,7 @@ limitations under the License. CSV files (*.csv)|*.csv SourceGen projects (*.dis65)|*.dis65 HTML files (*.html)|*.html + SGEC files (*.sgec)|*.sgec SourceGen symbols (*.sym65)|*.sym65 Text files (*.txt)|*.txt File is {0:N1} KB of raw data. diff --git a/SourceGen/Res/Strings.xaml.cs b/SourceGen/Res/Strings.xaml.cs index 7ad3343..b4be3ce 100644 --- a/SourceGen/Res/Strings.xaml.cs +++ b/SourceGen/Res/Strings.xaml.cs @@ -161,6 +161,8 @@ namespace SourceGen.Res { (string)Application.Current.FindResource("str_FileFilterDis65"); public static string FILE_FILTER_HTML = (string)Application.Current.FindResource("str_FileFilterHtml"); + public static string FILE_FILTER_SGEC = + (string)Application.Current.FindResource("str_FileFilterSgec"); public static string FILE_FILTER_SYM65 = (string)Application.Current.FindResource("str_FileFilterSym65"); public static string FILE_FILTER_TEXT = diff --git a/SourceGen/RuntimeData/Atari/VisAVG.cs b/SourceGen/RuntimeData/Atari/VisAVG.cs index 3323708..541a657 100644 --- a/SourceGen/RuntimeData/Atari/VisAVG.cs +++ b/SourceGen/RuntimeData/Atari/VisAVG.cs @@ -41,7 +41,7 @@ namespace RuntimeData.Atari { private AddressTranslate mAddrTrans; // Visualization identifiers; DO NOT change or projects that use them will break. - private const string VIS_GEN_AVG = "atari-avg"; + private const string VIS_GEN_AVG = "atari-avg-bz"; // Battlezone, Red Baron private const string P_OFFSET = "offset"; private const string P_BASE_ADDR = "baseAddr"; @@ -55,7 +55,7 @@ namespace RuntimeData.Atari { new VisParamDescr("Base address", P_BASE_ADDR, typeof(int), 0x0000, 0xffff, 0, 0x2000), - VisWireframe.Param_IsRecentered("Re-center", true), + VisWireframe.Param_IsRecentered("Centered", true), }), }; @@ -274,6 +274,13 @@ namespace RuntimeData.Atari { return (short)val13 >> 3; } + /// + /// Converts a JSR/JMP operand to a file offset. + /// + /// AVG address operand. + /// Base address of vector memory. + /// File offset of instruction. + /// False if the target address is outside the file bounds. private bool Branch(int vaddr, int baseAddr, ref int offset) { int fileAddr = baseAddr + vaddr * 2; int fileOffset = mAddrTrans.AddressToOffset(offset, fileAddr); diff --git a/SourceGen/WireframeObject.cs b/SourceGen/WireframeObject.cs index 8739bcb..453fb07 100644 --- a/SourceGen/WireframeObject.cs +++ b/SourceGen/WireframeObject.cs @@ -86,6 +86,8 @@ namespace SourceGen { } } + public bool VerboseDebug { get; set; } + private bool mIs2d = false; private List mVertices = new List(); private List mPoints = new List(); @@ -257,12 +259,14 @@ namespace SourceGen { ref double ymin, ref double ymax) { if (vert.Vec.X < xmin) { xmin = vert.Vec.X; - } else if (vert.Vec.X > xmax) { + } + if (vert.Vec.X > xmax) { xmax = vert.Vec.X; } if (vert.Vec.Y < ymin) { ymin = vert.Vec.Y; - } else if (vert.Vec.Y > ymax) { + } + if (vert.Vec.Y > ymax) { ymax = vert.Vec.Y; } } @@ -291,6 +295,11 @@ namespace SourceGen { /// [-1,1]. public List Generate(int eulerX, int eulerY, int eulerZ, bool doPersp, bool doBfc, bool doRecenter) { + if (VerboseDebug) { + Debug.WriteLine("Found center=" + mCenterAdjX + "," + mCenterAdjY); + Debug.WriteLine(" bigMag=" + mBigMag + " / " + mBigMagRc); + } + // overrule flags that don't make sense if (mIs2d) { doPersp = doBfc = false; diff --git a/SourceGen/WpfGui/MainWindow.xaml b/SourceGen/WpfGui/MainWindow.xaml index 96268f3..fead078 100644 --- a/SourceGen/WpfGui/MainWindow.xaml +++ b/SourceGen/WpfGui/MainWindow.xaml @@ -192,6 +192,7 @@ limitations under the License. + @@ -323,6 +324,8 @@ limitations under the License. Executed="Debug_ApplesoftToHtmlCmd_Executed"/> + + diff --git a/SourceGen/WpfGui/MainWindow.xaml.cs b/SourceGen/WpfGui/MainWindow.xaml.cs index 834e046..7b540f8 100644 --- a/SourceGen/WpfGui/MainWindow.xaml.cs +++ b/SourceGen/WpfGui/MainWindow.xaml.cs @@ -1362,6 +1362,11 @@ namespace SourceGen.WpfGui { mMainCtrl.Debug_ApplesoftToHtml(); } + private void Debug_ApplyEditCommandsCmd_Executed(object sender, + ExecutedRoutedEventArgs e) { + mMainCtrl.Debug_ApplyEditCommands(); + } + private void Debug_ApplyPlatformSymbolsCmd_Executed(object sender, ExecutedRoutedEventArgs e) { mMainCtrl.Debug_ApplyPlatformSymbols();