public void ScanRange(byte[] rom, int startAddress, int endAddress) { if (rom == null) { throw new ArgumentNullException(); } int address = startAddress; while (address < endAddress) { if (ControlCodePredicate(rom, address)) { IControlCode code = ControlCodes.FirstOrDefault(c => c.IsMatch(rom, address)); if (code == null) { throw new Exception("Control code not found"); } IList <int> references = code.GetReferences(rom, address); if (references != null) { LabelMap.AddRange(references); } address += code.ComputeLength(rom, address); } else { address++; } } }
public string DecompileRange(byte[] rom, int startAddress, int endAddress, bool newLines) { if (rom == null) { throw new ArgumentNullException(); } var builder = new StringBuilder(); bool readUntilEnd = (endAddress == -1); bool ended = false; bool suppressNextEnd = false; int address = startAddress; while (!ended) { if (LabelMap.Labels.ContainsKey(address)) { builder.Append('^'); builder.Append(LabelMap.Labels[address]); builder.Append('^'); } if (ControlCodePredicate(rom, address)) { IControlCode code = ControlCodes.FirstOrDefault(c => c.IsMatch(rom, address)); if (code == null) { throw new Exception("Control code not found"); } // Check if it's compressed text if (code.IsCompressedString) { builder.Append(code.GetCompressedString(rom, address)); } else { IList <CodeString> codeStrings = code.GetCodeStrings(rom, address); var filtered = codeStrings.Select(cs => FilterCodeString(cs)).ToArray(); builder.Append(String.Format("[{0}]", String.Join(" ", filtered))); if (newLines && code.IsEnd && !suppressNextEnd) { builder.AppendLine(); } } address += code.ComputeLength(rom, address); /*if (newLines && code.IsEnd && !suppressNextEnd) * { * builder.Append("(" + address.ToString("X") + ")"); * }*/ if (readUntilEnd && code.IsEnd) { ended = true; } if (code.IsEnd) { suppressNextEnd = false; } else if (code.SuppressNextEnd == true) { suppressNextEnd = true; } } else { string str = GetChar(rom, address++); builder.Append(str); } if (!readUntilEnd && address >= endAddress) { ended = true; } } return(builder.ToString()); }