1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-05-31 22:41:37 +00:00

Fix hex format string initialization

For some reason FormatHexValue was creating format strings on
demand.  In a recent change, FormatAdjustment started using them.
So if the first 4-digit hex value printed by the program was a
large adjustment, you could end up with a default-formatted adjustment
pretending to be hex.

Now we just create the 4 format strings in the Formatter constructor.
This commit is contained in:
Andy McFadden 2020-02-11 16:38:51 -08:00
parent d7593181f5
commit 8209753cbc

View File

@ -449,6 +449,11 @@ namespace Asm65 {
mSregChar = 's';
}
for (int index = 0; index < 4; index++) {
int width = (index + 1) * 2;
mHexValueFormats[index] = mHexFmtChar + width.ToString();
}
// process the delimiter patterns
DelimiterSet chrDelim = mFormatConfig.mCharDelimiters;
if (chrDelim == null) {
@ -506,9 +511,6 @@ namespace Asm65 {
width = 4;
}
int index = (width / 2) - 1;
if (mHexValueFormats[index] == null) {
mHexValueFormats[index] = mHexFmtChar + width.ToString();
}
return mHexPrefix + value.ToString(mHexValueFormats[index]);
}