/// <summary> /// Sets the current tape mode according to the current PC register /// and the MIC bit state /// </summary> public void SetTapeMode() { // --- We must use the Spectrum 48K ROM for this mode if (_memoryDevice.GetSelectedRomIndex() != HostVm.RomConfiguration.Spectrum48RomIndex) { return; } switch (_currentMode) { case TapeOperationMode.Passive: if (_cpu.Registers.PC == LoadBytesRoutineAddress) { EnterLoadMode(); } else if (_cpu.Registers.PC == SaveBytesRoutineAddress) { EnterSaveMode(); } return; case TapeOperationMode.Save: if (_cpu.Registers.PC == ERROR_ROM_ADDRESS || (int)(_cpu.Tacts - _lastMicBitActivityTact) > SAVE_STOP_SILENCE) { LeaveSaveMode(); } return; case TapeOperationMode.Load: if ((_tapePlayer?.Eof ?? false) || _cpu.Registers.PC == ERROR_ROM_ADDRESS) { LeaveLoadMode(); LoadCompleted?.Invoke(this, EventArgs.Empty); } return; } }