Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        /// <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);
            }
        }