diff --git a/SourceGen/DataAnalysis.cs b/SourceGen/DataAnalysis.cs
index e36e42b..e001d27 100644
--- a/SourceGen/DataAnalysis.cs
+++ b/SourceGen/DataAnalysis.cs
@@ -1036,7 +1036,7 @@ namespace SourceGen {
///
/// Counts the number of null-terminated strings in the buffer.
///
- /// Zero-length strings are allowed but not included in the count.
+ /// Zero-length strings are allowed.
///
/// Raw data.
/// Offset of first byte in range.
@@ -1058,10 +1058,8 @@ namespace SourceGen {
for (int i = start; i <= end; i++) {
byte val = fileData[i];
if (val == 0x00) {
- // End of string. Only update count if string wasn't empty.
- if (stringLen != 0) {
- stringCount++;
- }
+ // End of string.
+ stringCount++;
stringLen = 0;
expectedHiBit = -1;
} else {
@@ -1088,7 +1086,7 @@ namespace SourceGen {
///
/// Counts strings prefixed with an 8-bit length.
///
- /// Zero-length strings are allowed but not counted.
+ /// Zero-length strings are allowed.
///
/// Raw data.
/// Offset of first byte in range.
@@ -1110,10 +1108,10 @@ namespace SourceGen {
return -1;
}
+ stringCount++;
if (strLen == 0) {
continue;
}
- stringCount++;
remaining -= strLen;
int expectedHiBit = fileData[posn] & 0x80;
@@ -1137,7 +1135,7 @@ namespace SourceGen {
///
/// Counts strings prefixed with a 16-bit length.
///
- /// Zero-length strings are allowed but not counted.
+ /// Zero-length strings are allowed.
///
/// Raw data.
/// Offset of first byte in range.
@@ -1165,10 +1163,10 @@ namespace SourceGen {
return -1;
}
+ stringCount++;
if (strLen == 0) {
continue;
}
- stringCount++;
remaining -= strLen;
int expectedHiBit = fileData[posn] & 0x80;
diff --git a/SourceGen/RuntimeData/Help/editors.html b/SourceGen/RuntimeData/Help/editors.html
index 9c86ed3..4fe867b 100644
--- a/SourceGen/RuntimeData/Help/editors.html
+++ b/SourceGen/RuntimeData/Help/editors.html
@@ -210,7 +210,7 @@ work for all regions will be shown.
data you have selected is in the appropriate format. For example,
"Null-terminated strings" is only enabled if the data regions are
composed entirely of characters followed by $00. Zero-length strings
-are allowed, but only if some non-zero-length strings are present.
+are allowed.
DCI (Dextral Character Inverted) strings have the high bit on the last
byte flipped; for PETSCII this will usually look like a series of
lower-case letters followed by a capital letter, but may look odd if the
diff --git a/SourceGen/WpfGui/EditDataOperand.xaml.cs b/SourceGen/WpfGui/EditDataOperand.xaml.cs
index 55148e2..fb14e81 100644
--- a/SourceGen/WpfGui/EditDataOperand.xaml.cs
+++ b/SourceGen/WpfGui/EditDataOperand.xaml.cs
@@ -565,6 +565,8 @@ namespace SourceGen.WpfGui {
radioStringLen16.IsEnabled = true;
radioStringDci.IsEnabled = true;
+ // This will disable a string type if we don't find at least one in every region.
+
IEnumerator iter = mSelection.RangeListIterator;
while (iter.MoveNext()) {
TypedRangeSet.TypedRange rng = iter.Current;
@@ -1367,15 +1369,26 @@ namespace SourceGen.WpfGui {
int i;
for (i = low; i <= high;) {
int length = mFileData[i];
+ int lenLen;
if (type == FormatDescriptor.Type.StringL16) {
length |= mFileData[i + 1] << 8;
- length += 2;
+ lenLen = 2;
} else {
- length++;
+ lenLen = 1;
}
+ length += lenLen;
+
// Zero-length strings are allowed.
- FormatDescriptor dfd = FormatDescriptor.Create(length, type,
- ResolveAsciiGeneric(i, subType));
+ FormatDescriptor.SubType actualSubType = subType;
+ if (subType == FormatDescriptor.SubType.ASCII_GENERIC) {
+ if (length > lenLen) {
+ actualSubType = ResolveAsciiGeneric(i + lenLen, subType);
+ } else {
+ // Zero-length string, just pick a format.
+ actualSubType = FormatDescriptor.SubType.Ascii;
+ }
+ }
+ FormatDescriptor dfd = FormatDescriptor.Create(length, type, actualSubType);
Results.Add(i, dfd);
i += length;
}