/// <summary> /// Leaves the load mode. Stops the device that playes EAR pulses /// </summary> private void LeaveLoadMode() { _currentMode = TapeOperationMode.Passive; _tapePlayer = null; ContentProvider?.Reset(); HostVm.BeeperDevice.SetTapeOverride(false); }
/// <summary> /// Leaves the load mode. Stops the device that playes EAR pulses /// </summary> private void LeaveLoadMode() { _currentMode = TapeOperationMode.Passive; _tapePlayer = null; TapeProvider?.Reset(); HostVm.BeeperDevice.SetTapeOverride(false); LeftLoadMode?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Resets the tape device /// </summary> public void Reset() { TapeProvider?.Reset(); _tapePlayer = null; _currentMode = TapeOperationMode.Passive; _savePhase = SavePhase.None; _micBitState = true; }
/// <summary> /// Puts the device in load mode. From now on, EAR pulses are played by a device /// </summary> private void EnterLoadMode() { _currentMode = TapeOperationMode.Load; var contentReader = ContentProvider?.GetTapeContent(); if (contentReader == null) { return; } // --- Play the content _tapePlayer = new CommonTapeFilePlayer(contentReader); _tapePlayer.ReadContent(); _tapePlayer.InitPlay(_cpu.Tacts); HostVm.BeeperDevice.SetTapeOverride(true); }
/// <summary> /// Puts the device in load mode. From now on, EAR pulses are played by a device /// </summary> private void EnterLoadMode() { _currentMode = TapeOperationMode.Load; EnteredLoadMode?.Invoke(this, EventArgs.Empty); var contentReader = TapeLoadLoadProvider?.GetTapeContent(); if (contentReader == null) { return; } // --- Play the content _tapePlayer = new CommonTapeFilePlayer(contentReader); _tapePlayer.ReadContent(); contentReader.Dispose(); _tapePlayer.InitPlay(_cpu.Tacts); HostVm.BeeperDevice.SetTapeOverride(true); }
/// <summary> /// Tests if the specified file is a valid ZX Spectrum screen file /// </summary> /// <param name="filename">File name to check</param> /// <returns></returns> public static bool CheckScreenFile(string filename) { try { using (var reader = new BinaryReader(File.OpenRead(filename))) { var player = new CommonTapeFilePlayer(reader); player.ReadContent(); // --- Test if file is a screen file // --- Two data blocks if (player.DataBlocks.Count != 2) { return(false); } // --- Block lenghts should be 19 and 6914 var header = ((ITapeData)player.DataBlocks[0]).Data; if (header.Length != 19 || ((ITapeData)player.DataBlocks[1]).Data.Length != 6914) { return(false); } // --- Test header bytes return(header[0] == 0x00 && header[1] == 0x03 && // --- Code header header[12] == 0x00 && header[13] == 0x1B && // --- Length: 0x1B00 header[14] == 0x00 && header[15] == 0x40 && // --- Address: 0x4000 header[16] == 0x00 && header[17] == 0x80); // --- Param2: 0x8000 } } catch (Exception) { // --- If we cannot read the file, we consider it an invalid screen file. return(false); } }