using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static Mesen.GUI.Debugger.TblLoader; namespace Be.Windows.Forms { /// /// The default implementation. /// class TblByteCharConverter : IByteCharConverter { Dictionary _tblRules; public TblByteCharConverter(Dictionary tblRules) { this._tblRules = tblRules; } /// /// Returns the character to display for the byte passed across. /// /// /// public virtual string ToChar(UInt64 value, out int keyLength) { int byteCount = 8; string result; while(!_tblRules.TryGetValue(new TblKey() { Key = value, Length = byteCount }, out result) && byteCount > 0) { value &= ~(((UInt64)0xFF) << (8 * (byteCount - 1))); byteCount--; } if(result != null) { keyLength = byteCount; return result; } else { keyLength = 1; return "."; } } /// /// Returns the byte to use for the character passed across. /// /// /// public virtual byte ToByte(char c) { return (byte)c; } /// /// Returns a description of the byte char provider. /// /// public override string ToString() { return "TBL"; } } }