/// <summary> /// Loads the content of the ROM through the specified provider /// </summary> /// <param name="romDevice">ROM device instance</param> /// <param name="romConfig">ROM configuration</param> /// <remarks> /// The content of the ROM is copied into the memory /// </remarks> public void InitRom(IRomDevice romDevice, IRomConfiguration romConfig) { for (var i = 0; i < romConfig.NumberOfRoms; i++) { MemoryDevice.SelectRom(i); MemoryDevice.CopyRom(romDevice.GetRomBytes(i)); } MemoryDevice.SelectRom(0); }
/// <summary> /// Signs that the device has been attached to the Spectrum virtual machine /// </summary> public override void OnAttachedToVm(ISpectrumVm hostVm) { base.OnAttachedToVm(hostVm); _romConfig = hostVm.RomConfiguration; _nextDevice = hostVm.NextDevice; _divIdeDevice = hostVm.DivIdeDevice; // --- Create space for ROM pages (use 10 x 8K pages) var romCount = _romConfig.NumberOfRoms * 2; _romPages = new byte[romCount][]; for (var i = 0; i < romCount; i++) { _romPages[i] = new byte[0x2000]; } // --- Obtain Next memory size var memSize = HostVm.MemoryConfiguration.NextMemorySize; if (memSize < 1024) { memSize = 512; } else if (memSize >= 1024 && memSize < 1536) { memSize = 1024; } else if (memSize >= 1536 && memSize < 2048) { memSize = 1536; } else { memSize = 2048; } // --- Calculate number of RAM pages RamPageCount = 16 + 64 * (memSize - 512) / 512; // --- Allocate RAM _ramPages = new byte[RamPageCount][]; for (var i = 0; i < RamPageCount; i++) { _ramPages[i] = new byte[0x2000]; } Reset(); }