/// <summary>
/// Returns the byte array of memory attached to the device. Accepts values from 0 - 16. Device 0 is ROM.
/// </summary>
internal void GetDeviceMemoryReference(Segment segment, ushort deviceIndex)
{
if (deviceIndex == 0)
{
// request memory from ycpu
GetROMReference(segment);
}
else if (deviceIndex > 16)
{
// this should never happen - requested memory from device index that cannot exist.
segment.SetMemoryReference(null);
segment.Reference = MemoryReferenceInfo.None;
AddSegmentToReferences(segment);
}
else
{
// request memory from device in slot index.
if (m_Devices[deviceIndex - 1] == null)
{
segment.SetMemoryReference(null);
segment.Reference = MemoryReferenceInfo.None;
}
else
{
segment.SetMemoryReference(m_Devices[deviceIndex - 1].GetMemoryInterface());
segment.Reference = MemoryReferenceInfo.Device | (MemoryReferenceInfo)deviceIndex;
}
AddSegmentToReferences(segment);
}
}