コード例 #1
0
        private void EncodeBlockLeading()
        {
            ushort periodCount = (ushort)((GenerateFrequenyFromOffset(FreqLeading) * m_LeadingLength + 500) / 1000);

            DirectDigitalSyntheser.GenerateSilence(m_GapLeading, m_OutputWaves);
            DirectDigitalSyntheser.GenerateSignal(GenerateFrequenyFromOffset(FreqLeading), periodCount, m_OutputWaves);
            DirectDigitalSyntheser.GenerateSignal(GenerateFrequenyFromOffset(FreqSync), 1, m_OutputWaves);
        }
コード例 #2
0
        private void GenerateDataBlock(byte[] programbytes)
        {
            byte sectorCount = (byte)((programbytes.Length + 255) / 256);
            byte sectorIndex = 1;

            m_CrcGenerator.GeneratedCrcValue = 0;

            EncodeBlockLeading();

            TapeBlockHeader blockHeader =
                new TapeBlockHeader(m_CopyProtect)
            {
                SectorsInBlock = (byte)((programbytes.Length + 255) / 256)
            };

            m_CrcGenerator.AddBlock(blockHeader.ToByteArray(false));
            EncodeBlock(blockHeader.ToByteArray());

            while (sectorIndex <= sectorCount)
            {
                int sectorSize = programbytes.Length - 256 * (sectorIndex - 1);
                if (sectorSize > 255)
                {
                    sectorSize = 256;
                }

                TapeSectorHeader sectorHeader = new TapeSectorHeader
                {
                    SectorNumber  = sectorIndex,
                    BytesInSector = (byte)(sectorSize > 255 ? 0 : (byte)sectorSize)
                };

                m_CrcGenerator.AddBlock(sectorHeader.ToByteArray());
                EncodeBlock(sectorHeader.ToByteArray());
                byte[] sectorData  = new byte[sectorSize];
                int    sourceIndex = (sectorIndex - 1) * 256;
                Array.Copy(programbytes, sourceIndex, sectorData, 0, sectorSize);

                m_CrcGenerator.AddBlock(sectorData);
                EncodeBlock(sectorData);

                TapeSectorEnd sectorEnd =
                    new TapeSectorEnd {
                    EofFlag = (byte)(sectorIndex == sectorCount ? 0xff : 0x00)
                };

                m_CrcGenerator.AddByte(sectorEnd.EofFlag);
                sectorEnd.Crc = m_CrcGenerator.GeneratedCrcValue;
                EncodeBlock(sectorEnd.ToByteArray());
                m_CrcGenerator.GeneratedCrcValue = 0;
                sectorIndex++;
            }

            DirectDigitalSyntheser.GenerateSignal(GenerateFrequenyFromOffset(FreqLeading), 5, m_OutputWaves);
            DirectDigitalSyntheser.GenerateSilence(50, m_OutputWaves);
        }