Exemple #1
0
        /// <summary>
        /// Inserts a new tape and sets up the tape device accordingly
        /// </summary>
        /// <param name="tapeData"></param>
        public void LoadTape(byte[] tapeData)
        {
            // check TZX first
            TzxConverter tzxSer = new TzxConverter(this);

            if (tzxSer.CheckType(tapeData))
            {
                // this file has a tzx header - attempt serialization
                try
                {
                    tzxSer.Read(tapeData);
                    // reset block index
                    CurrentDataBlockIndex = 0;
                    return;
                }
                catch (Exception ex)
                {
                    // exception during operation
                    var e = ex;
                    throw new Exception(this.GetType().ToString() +
                                        "\n\nTape image file has a valid TZX header, but threw an exception whilst data was being parsed.\n\n" + e.ToString());
                }
            }
            else
            {
                TapConverter tapSer = new TapConverter(this);
                try
                {
                    tapSer.Read(tapeData);
                    // reset block index
                    CurrentDataBlockIndex = 0;
                    return;
                }
                catch (Exception ex)
                {
                    // exception during operation
                    var e = ex;
                    throw new Exception(this.GetType().ToString() +
                                        "\n\nAn exception was thrown whilst data from this tape image was being parsed as TAP.\n\n" + e.ToString());
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Inserts a new tape and sets up the tape device accordingly
        /// </summary>
        public void LoadTape(byte[] tapeData)
        {
            // instantiate converters
            TzxConverter tzxSer = new TzxConverter(this);
            TapConverter tapSer = new TapConverter(this);
            PzxConverter pzxSer = new PzxConverter(this);
            CswConverter cswSer = new CswConverter(this);
            WavConverter wavSer = new WavConverter(this);

            // TZX
            if (tzxSer.CheckType(tapeData))
            {
                // this file has a tzx header - attempt serialization
                try
                {
                    tzxSer.Read(tapeData);
                    // reset block index
                    CurrentDataBlockIndex = 0;
                    return;
                }
                catch (Exception ex)
                {
                    // exception during operation
                    var e = ex;
                    throw new Exception(this.GetType().ToString() +
                                        "\n\nTape image file has a valid TZX header, but threw an exception whilst data was being parsed.\n\n" + e.ToString());
                }
            }

            // PZX
            else if (pzxSer.CheckType(tapeData))
            {
                // this file has a pzx header - attempt serialization
                try
                {
                    pzxSer.Read(tapeData);
                    // reset block index
                    CurrentDataBlockIndex = 0;
                    return;
                }
                catch (Exception ex)
                {
                    // exception during operation
                    var e = ex;
                    throw new Exception(this.GetType().ToString() +
                                        "\n\nTape image file has a valid PZX header, but threw an exception whilst data was being parsed.\n\n" + e.ToString());
                }
            }

            // CSW
            else if (cswSer.CheckType(tapeData))
            {
                // this file has a csw header - attempt serialization
                try
                {
                    cswSer.Read(tapeData);
                    // reset block index
                    CurrentDataBlockIndex = 0;
                    return;
                }
                catch (Exception ex)
                {
                    // exception during operation
                    var e = ex;
                    throw new Exception(this.GetType().ToString() +
                                        "\n\nTape image file has a valid CSW header, but threw an exception whilst data was being parsed.\n\n" + e.ToString());
                }
            }

            // WAV
            else if (wavSer.CheckType(tapeData))
            {
                // this file has a csw header - attempt serialization
                try
                {
                    wavSer.Read(tapeData);
                    // reset block index
                    CurrentDataBlockIndex = 0;
                    return;
                }
                catch (Exception ex)
                {
                    // exception during operation
                    var e = ex;
                    throw new Exception(this.GetType().ToString() +
                                        "\n\nTape image file has a valid WAV header, but threw an exception whilst data was being parsed.\n\n" + e.ToString());
                }
            }

            // Assume TAP
            else
            {
                try
                {
                    tapSer.Read(tapeData);
                    // reset block index
                    CurrentDataBlockIndex = 0;
                    return;
                }
                catch (Exception ex)
                {
                    // exception during operation
                    var e = ex;
                    throw new Exception(this.GetType().ToString() +
                                        "\n\nAn exception was thrown whilst data from this tape image was being parsed as TAP.\n\n" + e.ToString());
                }
            }
        }