/// <summary> /// Creates an instance of the virtual machine /// </summary> /// <param name="modelKey">The model key of the virtual machine</param> /// <param name="editionKey">The edition key of the virtual machine</param> /// <param name="devices">Devices to create the machine</param> private SpectrumMachine(string modelKey, string editionKey, DeviceInfoCollection devices) { // --- Store model information ModelKey = modelKey; EditionKey = editionKey; // --- Create the engine and set up properties SpectrumVm = new SpectrumEngine(devices); Cpu = new CpuZ80(SpectrumVm.Cpu); var roms = new List <ReadOnlyMemorySlice>(); for (var i = 0; i < SpectrumVm.RomConfiguration.NumberOfRoms; i++) { roms.Add(new ReadOnlyMemorySlice(SpectrumVm.RomDevice.GetRomBytes(i))); } Roms = new ReadOnlyCollection <ReadOnlyMemorySlice>(roms); PagingInfo = new MemoryPagingInfo(SpectrumVm.MemoryDevice); Memory = new SpectrumMemoryContents(SpectrumVm.MemoryDevice, SpectrumVm.Cpu); var ramBanks = new List <MemorySlice>(); if (SpectrumVm.MemoryConfiguration.RamBanks != null) { for (var i = 0; i < SpectrumVm.MemoryConfiguration.RamBanks; i++) { ramBanks.Add(new MemorySlice(SpectrumVm.MemoryDevice.GetRamBank(i))); } } RamBanks = new ReadOnlyCollection <MemorySlice>(ramBanks); Keyboard = new KeyboardEmulator(SpectrumVm); ScreenConfiguration = SpectrumVm.ScreenConfiguration; ScreenRenderingTable = new ScreenRenderingTable(SpectrumVm.ScreenDevice); ScreenBitmap = new ScreenBitmap(SpectrumVm.ScreenDevice); ScreenRenderingStatus = new ScreenRenderingStatus(SpectrumVm); BeeperConfiguration = SpectrumVm.AudioConfiguration; BeeperSamples = new AudioSamples(SpectrumVm.BeeperDevice); BeeperProvider = SpectrumVm.BeeperProvider; SoundConfiguration = SpectrumVm.SoundConfiguration; SoundProvider = SpectrumVm.SoundProvider; AudioSamples = new AudioSamples(SpectrumVm.SoundDevice); Breakpoints = new CodeBreakpoints(SpectrumVm.DebugInfoProvider); // --- Hook device events SpectrumVm.TapeLoadDevice.LoadCompleted += (s, e) => FastLoadCompleted?.Invoke(s, e); SpectrumVm.TapeSaveDevice.LeftSaveMode += (s, e) => LeftSaveMode?.Invoke(s, e); // --- Initialize machine state _clockProvider = GetProvider <IClockProvider>(); _physicalFrameClockCount = _clockProvider.GetFrequency() / (double)SpectrumVm.BaseClockFrequency * ScreenConfiguration.ScreenRenderingFrameTactCount; MachineState = VmState.None; ExecutionCompletionReason = ExecutionCompletionReason.None; }
/// <summary> /// Leaves the save mode. Stops recording MIC pulses /// </summary> private void LeaveSaveMode() { _currentMode = TapeOperationMode.Passive; TapeProvider?.FinalizeTapeFile(); LeftSaveMode?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Leaves the save mode. Stops recording MIC pulses /// </summary> private void LeaveSaveMode() { _currentMode = TapeOperationMode.Passive; LeftSaveMode?.Invoke(this, new SaveModeEventArgs(TapeSaveProvider?.GetFullFileName())); }