using System; using System.Linq; using System.Collections.Generic; namespace BizHawk.Emulation.Common { /// /// This service provides the means to generate disassembly by the core for a given cpu and memory domain /// Tools such the debugger use this, but also lua scripting, and tools like trace logging and code data logging can make use of this tool /// If unavailable the debugger tool will still be available but disable the disassembly window but still be available if the IDebuggable service is available /// public interface IDisassemblable : IEmulatorService { /// /// Gets or sets the Cpu that will be used to disassemble /// Only values returned from AvailableCpus will be supported when Set /// string Cpu { get; set; } /// /// Returns the name of the Program Counter Register for the current Cpu /// string PCRegisterName { get; } /// /// Gets a list of Cpus that can be used when setting the Cpu property /// IEnumerable AvailableCpus { get; } /// /// returns a disassembly starting at addr lasting for length, using the given domain /// string Disassemble(MemoryDomain m, uint addr, out int length); } /// /// does santiy checking on Cpu parameters /// public abstract class VerifiedDisassembler : IDisassemblable { protected string _cpu; public virtual string Cpu { get { return _cpu; } set { if (!AvailableCpus.Contains(value)) { throw new ArgumentException(); } _cpu = value; } } public abstract IEnumerable AvailableCpus { get; } public abstract string PCRegisterName { get; } public abstract string Disassemble(MemoryDomain m, uint addr, out int length); public VerifiedDisassembler() { _cpu = AvailableCpus.First(); } } }