using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; 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); /// /// Writes a word to the specified address. /// /// /// void Load(int address, ushort data); /// /// Specifies the range (or ranges) of addresses decoded by this device. /// MemoryRange[] Addresses { get; } } }