Debugger: Text Hooker - Improved dakuten processing

This commit is contained in:
Sour 2018-07-23 20:55:56 -04:00
parent bfac410cb5
commit fbba774275
4 changed files with 32 additions and 89 deletions

View file

@ -334,7 +334,6 @@ namespace Mesen.GUI.Config
public int TextHookerDisplayCycle = 0;
public int TextHookerDisplayScanline = 241;
public List<CharMap> TextHookerCharMappings = new List<CharMap>();
public DakutenMode TextHookerDakutenMode = DakutenMode.OnTop;
public bool TextHookerAdjustViewportScrolling = true;
public bool TextHookerIgnoreMirroredNametables = true;
public bool TextHookerAutoCopyToClipboard = false;
@ -463,11 +462,4 @@ namespace Mesen.GUI.Config
[XmlAttribute]
public string Value;
}
public enum DakutenMode
{
Ignore,
OnTheRight,
OnTop
}
}

View file

@ -36,14 +36,10 @@
this.btnClearSelection = new System.Windows.Forms.Button();
this.txtSelectedText = new System.Windows.Forms.TextBox();
this.chkUseScrollOffsets = new System.Windows.Forms.CheckBox();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.lblDakutenMode = new System.Windows.Forms.Label();
this.cboDakutenMode = new System.Windows.Forms.ComboBox();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picNametable)).BeginInit();
this.grpText.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
@ -94,21 +90,20 @@
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Controls.Add(this.chkAutoCopyToClipboard, 0, 1);
this.tableLayoutPanel2.Controls.Add(this.chkIgnoreMirroredNametables, 0, 2);
this.tableLayoutPanel2.Controls.Add(this.btnClearSelection, 0, 5);
this.tableLayoutPanel2.Controls.Add(this.btnClearSelection, 0, 4);
this.tableLayoutPanel2.Controls.Add(this.txtSelectedText, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.chkUseScrollOffsets, 0, 3);
this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel3, 0, 4);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 16);
this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 6;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowCount = 5;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(389, 465);
this.tableLayoutPanel2.TabIndex = 0;
//
@ -134,7 +129,7 @@
//
// btnClearSelection
//
this.btnClearSelection.Location = new System.Drawing.Point(3, 437);
this.btnClearSelection.Location = new System.Drawing.Point(3, 411);
this.btnClearSelection.Name = "btnClearSelection";
this.btnClearSelection.Size = new System.Drawing.Size(92, 23);
this.btnClearSelection.TabIndex = 0;
@ -165,41 +160,6 @@
this.chkUseScrollOffsets.Text = "Adjust viewport by scrolling offsets";
this.chkUseScrollOffsets.UseVisualStyleBackColor = true;
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.ColumnCount = 2;
this.tableLayoutPanel2.SetColumnSpan(this.tableLayoutPanel3, 2);
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Controls.Add(this.lblDakutenMode, 0, 0);
this.tableLayoutPanel3.Controls.Add(this.cboDakutenMode, 1, 0);
this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 408);
this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 1;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(219, 26);
this.tableLayoutPanel3.TabIndex = 5;
//
// lblDakutenMode
//
this.lblDakutenMode.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblDakutenMode.AutoSize = true;
this.lblDakutenMode.Location = new System.Drawing.Point(3, 6);
this.lblDakutenMode.Name = "lblDakutenMode";
this.lblDakutenMode.Size = new System.Drawing.Size(81, 13);
this.lblDakutenMode.TabIndex = 4;
this.lblDakutenMode.Text = "Dakuten Mode:";
//
// cboDakutenMode
//
this.cboDakutenMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboDakutenMode.FormattingEnabled = true;
this.cboDakutenMode.Location = new System.Drawing.Point(90, 3);
this.cboDakutenMode.Name = "cboDakutenMode";
this.cboDakutenMode.Size = new System.Drawing.Size(121, 21);
this.cboDakutenMode.TabIndex = 5;
//
// ctrlTextHooker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -212,8 +172,6 @@
this.grpText.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
this.tableLayoutPanel3.ResumeLayout(false);
this.tableLayoutPanel3.PerformLayout();
this.ResumeLayout(false);
}
@ -226,11 +184,8 @@
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.Button btnClearSelection;
private System.Windows.Forms.TextBox txtSelectedText;
private System.Windows.Forms.CheckBox chkUseScrollOffsets;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.Label lblDakutenMode;
private System.Windows.Forms.ComboBox cboDakutenMode;
private System.Windows.Forms.CheckBox chkAutoCopyToClipboard;
private System.Windows.Forms.CheckBox chkIgnoreMirroredNametables;
private System.Windows.Forms.CheckBox chkUseScrollOffsets;
}
}

View file

@ -43,9 +43,6 @@ namespace Mesen.GUI.Debugger.Controls
chkIgnoreMirroredNametables.Checked = debugInfo.TextHookerIgnoreMirroredNametables;
chkUseScrollOffsets.Checked = debugInfo.TextHookerAdjustViewportScrolling;
chkAutoCopyToClipboard.Checked = debugInfo.TextHookerAutoCopyToClipboard;
BaseConfigForm.InitializeComboBox(cboDakutenMode, typeof(DakutenMode));
cboDakutenMode.SetEnumValue(debugInfo.TextHookerDakutenMode);
}
}
@ -58,7 +55,6 @@ namespace Mesen.GUI.Debugger.Controls
debugInfo.TextHookerIgnoreMirroredNametables = chkIgnoreMirroredNametables.Checked;
debugInfo.TextHookerAdjustViewportScrolling = chkUseScrollOffsets.Checked;
debugInfo.TextHookerAutoCopyToClipboard = chkAutoCopyToClipboard.Checked;
debugInfo.TextHookerDakutenMode = cboDakutenMode.GetEnumValue<DakutenMode>();
}
}
@ -76,6 +72,18 @@ namespace Mesen.GUI.Debugger.Controls
_yScroll &= 0xFFF8;
}
private string GetCharacter(int nt, int y, int x)
{
int outNt, outY, outX;
GetIndexes(nt, y, x, out outNt, out outY, out outX);
if(IgnoreTile(outNt)) {
return " ";
}
string key = GetTileKey(outNt, (outY << 5) + outX);
return GetMappedCharacter(key);
}
public void RefreshViewer()
{
using(Graphics gNametable = Graphics.FromImage(_nametableImage)) {
@ -102,41 +110,33 @@ namespace Mesen.GUI.Debugger.Controls
}
picNametable.Image = _outputImage;
DakutenMode dakutenMode = cboDakutenMode.GetEnumValue<DakutenMode>();
StringBuilder output = new StringBuilder();
DakutenType[] previousLineDakutenType = new DakutenType[32];
for(int nt = 0; nt < 4; nt++) {
for(int y = 0; y < 30; y++) {
StringBuilder lineOutput = new StringBuilder();
for(int x = 0; x < 32; x++) {
int outNt, outY, outX;
GetIndexes(nt, y, x, out outNt, out outY, out outX);
if(IgnoreTile(outNt)) {
continue;
}
string key = GetTileKey(outNt, (outY << 5) + outX);
string value = GetMappedCharacter(key);
string value = GetCharacter(nt, y, x);
DakutenType dakutenType = GetDakutenType(value);
if(dakutenType != DakutenType.None) {
previousLineDakutenType[x] = dakutenType;
} else {
DakutenType effectiveDakuten = dakutenMode == DakutenMode.OnTop ? previousLineDakutenType[x] : DakutenType.None;
previousLineDakutenType[x] = DakutenType.None;
if(effectiveDakuten == DakutenType.None && dakutenMode == DakutenMode.OnTheRight) {
GetIndexes(nt, y, x + 1, out outNt, out outY, out outX);
string nextTileKey = GetTileKey(outNt, (outY << 5) + outX);
string nextTileValue = GetMappedCharacter(nextTileKey);
effectiveDakuten = GetDakutenType(nextTileValue);
}
if(dakutenType == DakutenType.None) {
bool isKana = (
(value[0] >= '\x3041' && value[0] <= '\x3096') || //hiragana
(value[0] >= '\x30A1' && value[0] <= '\x30FA') //katakana
);
DakutenType effectiveDakuten = DakutenType.None;
if(previousLineDakutenType[x] != DakutenType.None) {
effectiveDakuten = previousLineDakutenType[x];
} else if(isKana) {
effectiveDakuten = GetDakutenType(GetCharacter(nt, y, x + 1));
if(effectiveDakuten != DakutenType.None && x < 31) {
//Skip next character, to avoid using it for the line below
previousLineDakutenType[x + 1] = DakutenType.None;
x++;
}
}
if(isKana && effectiveDakuten == DakutenType.Dakuten) {
lineOutput.Append((char)(value[0] + 1));
} else if(isKana && effectiveDakuten == DakutenType.Handakuten) {
@ -145,6 +145,7 @@ namespace Mesen.GUI.Debugger.Controls
lineOutput.Append(value);
}
}
previousLineDakutenType[x] = dakutenType;
}
string rowString = lineOutput.ToString().Trim();

View file

@ -1247,10 +1247,5 @@
<Value ID="GenericMulticart">Generic Multicart</Value>
<Value ID="SnesControllers">SNES Controllers</Value>
</Enum>
<Enum ID="DakutenMode">
<Value ID="Ignore">Ignore</Value>
<Value ID="OnTheRight">On the right</Value>
<Value ID="OnTop">On top</Value>
</Enum>
</Enums>
</Resources>