public static void LoadOrganicListing(string file)
{
if (KnownCode == null)
KnownCode = new Dictionary<ushort, string>();
if (KnownLabels == null)
KnownLabels = new Dictionary<ushort, string>();
StreamReader reader = new StreamReader(file);
string listing = reader.ReadToEnd();
Program.lastlistingFilepath = file;
reader.Close();
string[] lines = listing.Replace("\r", "").Split('\n');
foreach (var _line in lines)
{
string line = _line;
if (line.Trim().Length == 0)
continue;
line = line.Substring(line.IndexOf(')')).Trim();
line = line.Substring(line.IndexOf(' ')).Trim();
string addressText = line.Remove(line.IndexOf(']'));
addressText = addressText.Substring(line.IndexOf('[') + 3).Trim();
ushort address = 0;
if (addressText != "NOLIST")
address = ushort.Parse(addressText, NumberStyles.HexNumber);
if (line.Substring(line.IndexOf(" ")).Trim().StartsWith("ERROR"))
continue;
if (line.Substring(line.IndexOf(" ")).Trim().StartsWith("WARNING"))
continue;
line = line.Substring(line.IndexOf(" ")).Trim();
if (line.SafeContains(':'))
{
if (line.Contains(' '))
line = line.Remove(line.IndexOf(" ")).Trim();
line = line.Replace(":", "");
if (!KnownLabels.ContainsKey(address))
KnownLabels.Add(address, line);
}
else
{
if (!_line.Contains(" ") && !line.ToLower().StartsWith(".")) // .dat directive stuff
{
if (!KnownCode.ContainsKey(address))
KnownCode.Add(address, line);
}
}
}
}