using System; using Contralto.CPU; namespace Contralto.Memory { /// /// Specifies a range of memory from Start to End, inclusive. /// public struct MemoryRange { public MemoryRange(ushort start, ushort end) { if (!(end > start)) { throw new ArgumentOutOfRangeException("end must be greater than start."); } Start = start; End = end; } public bool Overlaps(MemoryRange other) { return ((other.Start >= this.Start && other.Start <= this.End) || (other.End >= this.Start && other.End <= this.End)); } public ushort Start; public ushort End; } /// /// Specifies an interfaces for devices that appear in mapped memory. This includes /// RAM as well as regular I/O devices. /// public interface IMemoryMappedDevice { /// /// Reads a word from the specified address. /// /// /// /// ushort Read(int address, TaskType task, bool extendedMemory); /// /// Writes a word to the specified address. /// /// /// void Load(int address, ushort data, TaskType task, bool extendedMemory); /// /// Specifies the range (or ranges) of addresses decoded by this device. /// MemoryRange[] Addresses { get; } } }