BizHawk/BizHawk.Emulation.Common/Interfaces/Services/IDisassemblable.cs

73 lines
2.0 KiB
C#
Raw Normal View History

2014-12-13 21:49:15 +00:00
using System;
using System.Linq;
using System.Collections.Generic;
namespace BizHawk.Emulation.Common
{
/// <summary>
/// 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 <seealso cref="IDebuggable"/> service is available
/// </summary>
2014-12-13 21:49:15 +00:00
public interface IDisassemblable : IEmulatorService
{
/// <summary>
/// Gets or sets the CPUS that will be used to disassemble
/// Only values returned from <seealso cref="AvailableCpus"/> will be supported when Set
/// </summary>
string Cpu { get; set; }
2014-12-14 17:27:45 +00:00
/// <summary>
/// Gets the name of the Program Counter Register for the current CPU
2014-12-14 17:27:45 +00:00
/// </summary>
string PCRegisterName { get; }
/// <summary>
/// Gets a list of CPUs that can be used when setting the CPU property
/// </summary>
2014-12-13 21:49:15 +00:00
IEnumerable<string> AvailableCpus { get; }
/// <summary>
/// Returns a disassembly starting at address lasting for length, using the given domain
/// </summary>
string Disassemble(MemoryDomain m, uint addr, out int length);
}
2014-12-13 21:49:15 +00:00
/// <summary>
/// does sanity checking on CPU parameters
2014-12-13 21:49:15 +00:00
/// </summary>
public abstract class VerifiedDisassembler : IDisassemblable
{
private string _cpu;
2014-12-13 21:49:15 +00:00
public virtual string Cpu
{
get
{
return _cpu;
}
2017-04-27 16:56:33 +00:00
2014-12-13 21:49:15 +00:00
set
{
if (!AvailableCpus.Contains(value))
2016-02-29 00:03:01 +00:00
{
2014-12-13 21:49:15 +00:00
throw new ArgumentException();
2016-02-29 00:03:01 +00:00
}
2014-12-13 21:49:15 +00:00
_cpu = value;
}
}
public abstract IEnumerable<string> AvailableCpus { get; }
public abstract string PCRegisterName { get; }
2014-12-13 21:49:15 +00:00
public abstract string Disassemble(MemoryDomain m, uint addr, out int length);
protected VerifiedDisassembler()
2014-12-13 21:49:15 +00:00
{
_cpu = AvailableCpus.First();
}
}
}