From d4726dac7e7713a598517984239be874ff37ebb1 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Fri, 5 Oct 2018 22:14:38 -0700 Subject: [PATCH] Rough prototype of split-address table formatter --- Asm65/CpuDef.cs | 2 +- .../AppForms/FormatSplitAddress.Designer.cs | 422 ++++++++++++++++++ SourceGen/AppForms/FormatSplitAddress.cs | 73 +++ SourceGen/AppForms/FormatSplitAddress.resx | 120 +++++ SourceGen/AppForms/ProjectView.Designer.cs | 10 + SourceGen/AppForms/ProjectView.cs | 31 ++ SourceGen/SourceGen.csproj | 9 + 7 files changed, 666 insertions(+), 1 deletion(-) create mode 100644 SourceGen/AppForms/FormatSplitAddress.Designer.cs create mode 100644 SourceGen/AppForms/FormatSplitAddress.cs create mode 100644 SourceGen/AppForms/FormatSplitAddress.resx diff --git a/Asm65/CpuDef.cs b/Asm65/CpuDef.cs index acfc3bb..200f3d3 100644 --- a/Asm65/CpuDef.cs +++ b/Asm65/CpuDef.cs @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - using System; +using System; using System.Diagnostics; namespace Asm65 { diff --git a/SourceGen/AppForms/FormatSplitAddress.Designer.cs b/SourceGen/AppForms/FormatSplitAddress.Designer.cs new file mode 100644 index 0000000..277878d --- /dev/null +++ b/SourceGen/AppForms/FormatSplitAddress.Designer.cs @@ -0,0 +1,422 @@ +namespace SourceGen.AppForms { + partial class FormatSplitAddress { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem(new string[] { + "123456", + "(+) T_123456"}, -1); + this.cancelButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.selectionInfoLabel = new System.Windows.Forms.Label(); + this.addressCharacteristicsGroup = new System.Windows.Forms.GroupBox(); + this.returnAddrCheckBox = new System.Windows.Forms.CheckBox(); + this.width24Button = new System.Windows.Forms.RadioButton(); + this.width16Radio = new System.Windows.Forms.RadioButton(); + this.lowByteGroupBox = new System.Windows.Forms.GroupBox(); + this.lowThirdPartRadio = new System.Windows.Forms.RadioButton(); + this.lowSecondPartRadio = new System.Windows.Forms.RadioButton(); + this.lowFirstPartRadio = new System.Windows.Forms.RadioButton(); + this.highByteGroupBox = new System.Windows.Forms.GroupBox(); + this.highConstantTextBox = new System.Windows.Forms.TextBox(); + this.highConstantRadio = new System.Windows.Forms.RadioButton(); + this.highThirdPartRadio = new System.Windows.Forms.RadioButton(); + this.highSecondPartRadio = new System.Windows.Forms.RadioButton(); + this.highFirstPartRadio = new System.Windows.Forms.RadioButton(); + this.bankByteGroupBox = new System.Windows.Forms.GroupBox(); + this.bankConstantTextBox = new System.Windows.Forms.TextBox(); + this.bankNthPartRadio = new System.Windows.Forms.RadioButton(); + this.bankConstantRadio = new System.Windows.Forms.RadioButton(); + this.outputPreviewListView = new System.Windows.Forms.ListView(); + this.addrColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.symbolColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.outputPreviewGroupBox = new System.Windows.Forms.GroupBox(); + this.addCodeHintCheckBox = new System.Windows.Forms.CheckBox(); + this.optionsGroupBox = new System.Windows.Forms.GroupBox(); + this.addressCharacteristicsGroup.SuspendLayout(); + this.lowByteGroupBox.SuspendLayout(); + this.highByteGroupBox.SuspendLayout(); + this.bankByteGroupBox.SuspendLayout(); + this.outputPreviewGroupBox.SuspendLayout(); + this.optionsGroupBox.SuspendLayout(); + this.SuspendLayout(); + // + // cancelButton + // + this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(479, 465); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 0; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(398, 465); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 1; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // selectionInfoLabel + // + this.selectionInfoLabel.AutoSize = true; + this.selectionInfoLabel.Location = new System.Drawing.Point(13, 13); + this.selectionInfoLabel.Name = "selectionInfoLabel"; + this.selectionInfoLabel.Size = new System.Drawing.Size(207, 13); + this.selectionInfoLabel.TabIndex = 2; + this.selectionInfoLabel.Text = "There are {0} bytes selected in {1} groups."; + // + // addressCharacteristicsGroup + // + this.addressCharacteristicsGroup.Controls.Add(this.returnAddrCheckBox); + this.addressCharacteristicsGroup.Controls.Add(this.width24Button); + this.addressCharacteristicsGroup.Controls.Add(this.width16Radio); + this.addressCharacteristicsGroup.Location = new System.Drawing.Point(16, 44); + this.addressCharacteristicsGroup.Name = "addressCharacteristicsGroup"; + this.addressCharacteristicsGroup.Size = new System.Drawing.Size(222, 90); + this.addressCharacteristicsGroup.TabIndex = 3; + this.addressCharacteristicsGroup.TabStop = false; + this.addressCharacteristicsGroup.Text = "Address Characteristics"; + // + // returnAddrCheckBox + // + this.returnAddrCheckBox.AutoSize = true; + this.returnAddrCheckBox.Location = new System.Drawing.Point(7, 68); + this.returnAddrCheckBox.Name = "returnAddrCheckBox"; + this.returnAddrCheckBox.Size = new System.Drawing.Size(170, 17); + this.returnAddrCheckBox.TabIndex = 2; + this.returnAddrCheckBox.Text = "Return addresses (address - 1)"; + this.returnAddrCheckBox.UseVisualStyleBackColor = true; + // + // width24Button + // + this.width24Button.AutoSize = true; + this.width24Button.Location = new System.Drawing.Point(7, 44); + this.width24Button.Name = "width24Button"; + this.width24Button.Size = new System.Drawing.Size(51, 17); + this.width24Button.TabIndex = 1; + this.width24Button.TabStop = true; + this.width24Button.Text = "24-bit"; + this.width24Button.UseVisualStyleBackColor = true; + // + // width16Radio + // + this.width16Radio.AutoSize = true; + this.width16Radio.Location = new System.Drawing.Point(7, 20); + this.width16Radio.Name = "width16Radio"; + this.width16Radio.Size = new System.Drawing.Size(51, 17); + this.width16Radio.TabIndex = 0; + this.width16Radio.TabStop = true; + this.width16Radio.Text = "16-bit"; + this.width16Radio.UseVisualStyleBackColor = true; + // + // lowByteGroupBox + // + this.lowByteGroupBox.Controls.Add(this.lowThirdPartRadio); + this.lowByteGroupBox.Controls.Add(this.lowSecondPartRadio); + this.lowByteGroupBox.Controls.Add(this.lowFirstPartRadio); + this.lowByteGroupBox.Location = new System.Drawing.Point(13, 140); + this.lowByteGroupBox.Name = "lowByteGroupBox"; + this.lowByteGroupBox.Size = new System.Drawing.Size(225, 94); + this.lowByteGroupBox.TabIndex = 4; + this.lowByteGroupBox.TabStop = false; + this.lowByteGroupBox.Text = "Low Byte"; + // + // lowThirdPartRadio + // + this.lowThirdPartRadio.AutoSize = true; + this.lowThirdPartRadio.Location = new System.Drawing.Point(10, 68); + this.lowThirdPartRadio.Name = "lowThirdPartRadio"; + this.lowThirdPartRadio.Size = new System.Drawing.Size(127, 17); + this.lowThirdPartRadio.TabIndex = 2; + this.lowThirdPartRadio.TabStop = true; + this.lowThirdPartRadio.Text = "Third part of selection"; + this.lowThirdPartRadio.UseVisualStyleBackColor = true; + // + // lowSecondPartRadio + // + this.lowSecondPartRadio.AutoSize = true; + this.lowSecondPartRadio.Location = new System.Drawing.Point(10, 44); + this.lowSecondPartRadio.Name = "lowSecondPartRadio"; + this.lowSecondPartRadio.Size = new System.Drawing.Size(140, 17); + this.lowSecondPartRadio.TabIndex = 1; + this.lowSecondPartRadio.TabStop = true; + this.lowSecondPartRadio.Text = "Second part of selection"; + this.lowSecondPartRadio.UseVisualStyleBackColor = true; + // + // lowFirstPartRadio + // + this.lowFirstPartRadio.AutoSize = true; + this.lowFirstPartRadio.Location = new System.Drawing.Point(10, 20); + this.lowFirstPartRadio.Name = "lowFirstPartRadio"; + this.lowFirstPartRadio.Size = new System.Drawing.Size(122, 17); + this.lowFirstPartRadio.TabIndex = 0; + this.lowFirstPartRadio.TabStop = true; + this.lowFirstPartRadio.Text = "First part of selection"; + this.lowFirstPartRadio.UseVisualStyleBackColor = true; + // + // highByteGroupBox + // + this.highByteGroupBox.Controls.Add(this.highConstantTextBox); + this.highByteGroupBox.Controls.Add(this.highConstantRadio); + this.highByteGroupBox.Controls.Add(this.highThirdPartRadio); + this.highByteGroupBox.Controls.Add(this.highSecondPartRadio); + this.highByteGroupBox.Controls.Add(this.highFirstPartRadio); + this.highByteGroupBox.Location = new System.Drawing.Point(13, 240); + this.highByteGroupBox.Name = "highByteGroupBox"; + this.highByteGroupBox.Size = new System.Drawing.Size(225, 120); + this.highByteGroupBox.TabIndex = 5; + this.highByteGroupBox.TabStop = false; + this.highByteGroupBox.Text = "High Byte"; + // + // highConstantTextBox + // + this.highConstantTextBox.Location = new System.Drawing.Point(87, 91); + this.highConstantTextBox.MaxLength = 10; + this.highConstantTextBox.Name = "highConstantTextBox"; + this.highConstantTextBox.Size = new System.Drawing.Size(93, 20); + this.highConstantTextBox.TabIndex = 4; + // + // highConstantRadio + // + this.highConstantRadio.AutoSize = true; + this.highConstantRadio.Location = new System.Drawing.Point(10, 92); + this.highConstantRadio.Name = "highConstantRadio"; + this.highConstantRadio.Size = new System.Drawing.Size(70, 17); + this.highConstantRadio.TabIndex = 3; + this.highConstantRadio.TabStop = true; + this.highConstantRadio.Text = "Constant:"; + this.highConstantRadio.UseVisualStyleBackColor = true; + // + // highThirdPartRadio + // + this.highThirdPartRadio.AutoSize = true; + this.highThirdPartRadio.Location = new System.Drawing.Point(10, 68); + this.highThirdPartRadio.Name = "highThirdPartRadio"; + this.highThirdPartRadio.Size = new System.Drawing.Size(127, 17); + this.highThirdPartRadio.TabIndex = 2; + this.highThirdPartRadio.TabStop = true; + this.highThirdPartRadio.Text = "Third part of selection"; + this.highThirdPartRadio.UseVisualStyleBackColor = true; + // + // highSecondPartRadio + // + this.highSecondPartRadio.AutoSize = true; + this.highSecondPartRadio.Location = new System.Drawing.Point(10, 44); + this.highSecondPartRadio.Name = "highSecondPartRadio"; + this.highSecondPartRadio.Size = new System.Drawing.Size(140, 17); + this.highSecondPartRadio.TabIndex = 1; + this.highSecondPartRadio.TabStop = true; + this.highSecondPartRadio.Text = "Second part of selection"; + this.highSecondPartRadio.UseVisualStyleBackColor = true; + // + // highFirstPartRadio + // + this.highFirstPartRadio.AutoSize = true; + this.highFirstPartRadio.Location = new System.Drawing.Point(10, 20); + this.highFirstPartRadio.Name = "highFirstPartRadio"; + this.highFirstPartRadio.Size = new System.Drawing.Size(122, 17); + this.highFirstPartRadio.TabIndex = 0; + this.highFirstPartRadio.TabStop = true; + this.highFirstPartRadio.Text = "First part of selection"; + this.highFirstPartRadio.UseVisualStyleBackColor = true; + // + // bankByteGroupBox + // + this.bankByteGroupBox.Controls.Add(this.bankConstantTextBox); + this.bankByteGroupBox.Controls.Add(this.bankNthPartRadio); + this.bankByteGroupBox.Controls.Add(this.bankConstantRadio); + this.bankByteGroupBox.Location = new System.Drawing.Point(13, 367); + this.bankByteGroupBox.Name = "bankByteGroupBox"; + this.bankByteGroupBox.Size = new System.Drawing.Size(225, 70); + this.bankByteGroupBox.TabIndex = 6; + this.bankByteGroupBox.TabStop = false; + this.bankByteGroupBox.Text = "Bank Byte"; + // + // bankConstantTextBox + // + this.bankConstantTextBox.Location = new System.Drawing.Point(87, 41); + this.bankConstantTextBox.MaxLength = 10; + this.bankConstantTextBox.Name = "bankConstantTextBox"; + this.bankConstantTextBox.Size = new System.Drawing.Size(93, 20); + this.bankConstantTextBox.TabIndex = 5; + // + // bankNthPartRadio + // + this.bankNthPartRadio.AutoSize = true; + this.bankNthPartRadio.Location = new System.Drawing.Point(10, 19); + this.bankNthPartRadio.Name = "bankNthPartRadio"; + this.bankNthPartRadio.Size = new System.Drawing.Size(120, 17); + this.bankNthPartRadio.TabIndex = 2; + this.bankNthPartRadio.TabStop = true; + this.bankNthPartRadio.Text = "Nth part of selection"; + this.bankNthPartRadio.UseVisualStyleBackColor = true; + // + // bankConstantRadio + // + this.bankConstantRadio.AutoSize = true; + this.bankConstantRadio.Location = new System.Drawing.Point(10, 42); + this.bankConstantRadio.Name = "bankConstantRadio"; + this.bankConstantRadio.Size = new System.Drawing.Size(70, 17); + this.bankConstantRadio.TabIndex = 1; + this.bankConstantRadio.TabStop = true; + this.bankConstantRadio.Text = "Constant:"; + this.bankConstantRadio.UseVisualStyleBackColor = true; + // + // outputPreviewListView + // + this.outputPreviewListView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.outputPreviewListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.addrColumnHeader, + this.symbolColumnHeader}); + this.outputPreviewListView.FullRowSelect = true; + this.outputPreviewListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.outputPreviewListView.Items.AddRange(new System.Windows.Forms.ListViewItem[] { + listViewItem2}); + this.outputPreviewListView.Location = new System.Drawing.Point(6, 19); + this.outputPreviewListView.MultiSelect = false; + this.outputPreviewListView.Name = "outputPreviewListView"; + this.outputPreviewListView.Size = new System.Drawing.Size(290, 369); + this.outputPreviewListView.TabIndex = 7; + this.outputPreviewListView.UseCompatibleStateImageBehavior = false; + this.outputPreviewListView.View = System.Windows.Forms.View.Details; + // + // addrColumnHeader + // + this.addrColumnHeader.Text = "Addr"; + // + // symbolColumnHeader + // + this.symbolColumnHeader.Text = "Symbol"; + this.symbolColumnHeader.Width = 200; + // + // outputPreviewGroupBox + // + this.outputPreviewGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.outputPreviewGroupBox.Controls.Add(this.outputPreviewListView); + this.outputPreviewGroupBox.Location = new System.Drawing.Point(252, 44); + this.outputPreviewGroupBox.Name = "outputPreviewGroupBox"; + this.outputPreviewGroupBox.Size = new System.Drawing.Size(302, 394); + this.outputPreviewGroupBox.TabIndex = 8; + this.outputPreviewGroupBox.TabStop = false; + this.outputPreviewGroupBox.Text = "Output Preview"; + // + // addCodeHintCheckBox + // + this.addCodeHintCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.addCodeHintCheckBox.AutoSize = true; + this.addCodeHintCheckBox.Location = new System.Drawing.Point(10, 19); + this.addCodeHintCheckBox.Name = "addCodeHintCheckBox"; + this.addCodeHintCheckBox.Size = new System.Drawing.Size(123, 17); + this.addCodeHintCheckBox.TabIndex = 8; + this.addCodeHintCheckBox.Text = "Add code entry hints"; + this.addCodeHintCheckBox.UseVisualStyleBackColor = true; + // + // optionsGroupBox + // + this.optionsGroupBox.Controls.Add(this.addCodeHintCheckBox); + this.optionsGroupBox.Location = new System.Drawing.Point(13, 444); + this.optionsGroupBox.Name = "optionsGroupBox"; + this.optionsGroupBox.Size = new System.Drawing.Size(225, 43); + this.optionsGroupBox.TabIndex = 9; + this.optionsGroupBox.TabStop = false; + this.optionsGroupBox.Text = "Options"; + // + // FormatSplitAddress + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(566, 500); + this.Controls.Add(this.optionsGroupBox); + this.Controls.Add(this.outputPreviewGroupBox); + this.Controls.Add(this.bankByteGroupBox); + this.Controls.Add(this.highByteGroupBox); + this.Controls.Add(this.lowByteGroupBox); + this.Controls.Add(this.addressCharacteristicsGroup); + this.Controls.Add(this.selectionInfoLabel); + this.Controls.Add(this.okButton); + this.Controls.Add(this.cancelButton); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FormatSplitAddress"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Format Split-Address Table"; + this.Load += new System.EventHandler(this.FormatSplitAddress_Load); + this.addressCharacteristicsGroup.ResumeLayout(false); + this.addressCharacteristicsGroup.PerformLayout(); + this.lowByteGroupBox.ResumeLayout(false); + this.lowByteGroupBox.PerformLayout(); + this.highByteGroupBox.ResumeLayout(false); + this.highByteGroupBox.PerformLayout(); + this.bankByteGroupBox.ResumeLayout(false); + this.bankByteGroupBox.PerformLayout(); + this.outputPreviewGroupBox.ResumeLayout(false); + this.optionsGroupBox.ResumeLayout(false); + this.optionsGroupBox.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Label selectionInfoLabel; + private System.Windows.Forms.GroupBox addressCharacteristicsGroup; + private System.Windows.Forms.RadioButton width16Radio; + private System.Windows.Forms.RadioButton width24Button; + private System.Windows.Forms.CheckBox returnAddrCheckBox; + private System.Windows.Forms.GroupBox lowByteGroupBox; + private System.Windows.Forms.RadioButton lowFirstPartRadio; + private System.Windows.Forms.RadioButton lowSecondPartRadio; + private System.Windows.Forms.RadioButton lowThirdPartRadio; + private System.Windows.Forms.GroupBox highByteGroupBox; + private System.Windows.Forms.RadioButton highFirstPartRadio; + private System.Windows.Forms.RadioButton highSecondPartRadio; + private System.Windows.Forms.RadioButton highThirdPartRadio; + private System.Windows.Forms.RadioButton highConstantRadio; + private System.Windows.Forms.TextBox highConstantTextBox; + private System.Windows.Forms.GroupBox bankByteGroupBox; + private System.Windows.Forms.ListView outputPreviewListView; + private System.Windows.Forms.ColumnHeader addrColumnHeader; + private System.Windows.Forms.ColumnHeader symbolColumnHeader; + private System.Windows.Forms.RadioButton bankConstantRadio; + private System.Windows.Forms.RadioButton bankNthPartRadio; + private System.Windows.Forms.TextBox bankConstantTextBox; + private System.Windows.Forms.GroupBox outputPreviewGroupBox; + private System.Windows.Forms.CheckBox addCodeHintCheckBox; + private System.Windows.Forms.GroupBox optionsGroupBox; + } +} \ No newline at end of file diff --git a/SourceGen/AppForms/FormatSplitAddress.cs b/SourceGen/AppForms/FormatSplitAddress.cs new file mode 100644 index 0000000..75edcd6 --- /dev/null +++ b/SourceGen/AppForms/FormatSplitAddress.cs @@ -0,0 +1,73 @@ +/* + * Copyright 2018 faddenSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Windows.Forms; + +using Asm65; +using CommonUtil; + +namespace SourceGen.AppForms { + public partial class FormatSplitAddress : Form { + /// + /// Result set that describes the formatting to perform. Not all regions will have + /// the same format, e.g. the "mixed ASCII" mode will alternate strings and bytes + /// (rather than a dedicated "mixed ASCII" format type). + /// + public SortedList Results { get; private set; } + + /// + /// Selected offsets. An otherwise contiguous range of offsets can be broken up + /// by user-specified labels and address discontinuities, so this needs to be + /// processed by range. + /// + public TypedRangeSet Selection { private get; set; } + + /// + /// Raw file data. + /// + private byte[] mFileData; + + /// + /// Symbol table to use when resolving symbolic values. + /// + private SymbolTable mSymbolTable; + + /// + /// Formatter to use when displaying addresses and hex values. + /// + private Asm65.Formatter mFormatter; + + + public FormatSplitAddress(byte[] fileData, SymbolTable symbolTable, + Formatter formatter) { + InitializeComponent(); + + mFileData = fileData; + mSymbolTable = symbolTable; + mFormatter = formatter; + } + + private void FormatSplitAddress_Load(object sender, EventArgs e) { + + } + + private void okButton_Click(object sender, EventArgs e) { + Results = new SortedList(); + } + } +} diff --git a/SourceGen/AppForms/FormatSplitAddress.resx b/SourceGen/AppForms/FormatSplitAddress.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SourceGen/AppForms/FormatSplitAddress.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SourceGen/AppForms/ProjectView.Designer.cs b/SourceGen/AppForms/ProjectView.Designer.cs index 949677b..60f3ea1 100644 --- a/SourceGen/AppForms/ProjectView.Designer.cs +++ b/SourceGen/AppForms/ProjectView.Designer.cs @@ -174,6 +174,7 @@ namespace SourceGen.AppForms this.symbolNameColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.infoGroupBox = new System.Windows.Forms.GroupBox(); this.infoTextBox = new System.Windows.Forms.TextBox(); + this.formatSplitAddressTableToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mainMenuStrip.SuspendLayout(); this.mainStatusStrip.SuspendLayout(); this.mainToolStrip.SuspendLayout(); @@ -463,6 +464,7 @@ namespace SourceGen.AppForms this.hintAsInlineDataToolStripMenuItem, this.removeHintToolStripMenuItem, this.toolStripMenuItem11, + this.formatSplitAddressTableToolStripMenuItem, this.toggleSingleBytesToolStripMenuItem, this.deleteNoteCommentToolStripMenuItem, this.toolStripMenuItem9, @@ -1433,6 +1435,13 @@ namespace SourceGen.AppForms this.infoTextBox.Size = new System.Drawing.Size(177, 120); this.infoTextBox.TabIndex = 0; // + // formatSplitAddressTableToolStripMenuItem + // + this.formatSplitAddressTableToolStripMenuItem.Name = "formatSplitAddressTableToolStripMenuItem"; + this.formatSplitAddressTableToolStripMenuItem.Size = new System.Drawing.Size(255, 22); + this.formatSplitAddressTableToolStripMenuItem.Text = "Format Split-Address Table"; + this.formatSplitAddressTableToolStripMenuItem.Click += new System.EventHandler(this.FormatSplitAddressTable_Click); + // // ProjectView // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1617,6 +1626,7 @@ namespace SourceGen.AppForms private System.Windows.Forms.ToolStripMenuItem toggleSingleBytesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem editProjectSymbolToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem deleteNoteCommentToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem formatSplitAddressTableToolStripMenuItem; } } diff --git a/SourceGen/AppForms/ProjectView.cs b/SourceGen/AppForms/ProjectView.cs index ecc646b..f1b731d 100644 --- a/SourceGen/AppForms/ProjectView.cs +++ b/SourceGen/AppForms/ProjectView.cs @@ -2224,9 +2224,12 @@ namespace SourceGen.AppForms { } } + formatSplitAddressTableToolStripMenuItem.Enabled = + (entityCounts.mDataLines > 1 && entityCounts.mCodeLines == 0); toggleSingleBytesToolStripMenuItem.Enabled = (entityCounts.mDataLines > 0 && entityCounts.mCodeLines == 0); + // So long as some code or data is highlighted, allow these. Don't worry about // control lines. Disable options that would have no effect. bool enableHints = (entityCounts.mDataLines > 0 || entityCounts.mCodeLines > 0); @@ -2614,6 +2617,34 @@ namespace SourceGen.AppForms { dlg.Dispose(); } + private void FormatSplitAddressTable_Click(object sender, EventArgs e) { + FormatSplitAddress dlg = new FormatSplitAddress(mProject.FileData, + mProject.SymbolTable, mOutputFormatter); + + TypedRangeSet trs = dlg.Selection = GroupedOffsetSetFromSelected(); + if (trs.Count == 0) { + // shouldn't happen + Debug.Assert(false, "FormatSplitAddressTable found nothing to edit"); + dlg.Dispose(); + return; + } + + // TODO: check to see if the selection is eligible for treatment as a + // split-address table. If not, show a dialog explaining why. + + dlg.ShowDialog(); + if (dlg.DialogResult == DialogResult.OK) { + ChangeSet cs = mProject.GenerateFormatMergeSet(dlg.Results); + if (cs.Count != 0) { + ApplyUndoableChanges(cs); + } else { + Debug.WriteLine("No change to data formats"); + } + } + + dlg.Dispose(); + } + private void ToggleSingleBytes_Click(object sender, EventArgs e) { TypedRangeSet trs = GroupedOffsetSetFromSelected(); if (trs.Count == 0) { diff --git a/SourceGen/SourceGen.csproj b/SourceGen/SourceGen.csproj index bab598f..55edcde 100644 --- a/SourceGen/SourceGen.csproj +++ b/SourceGen/SourceGen.csproj @@ -83,6 +83,12 @@ FindBox.cs + + Form + + + FormatSplitAddress.cs + Form @@ -269,6 +275,9 @@ FindBox.cs + + FormatSplitAddress.cs + GotoBox.cs