Ejemplo n.º 1
0
        public void FirstSyncPulseGenerationWorksAsExpected()
        {
            // --- Arrange
            const int  PILOT_PL           = TapeDataBlockPlayer.PILOT_PL;
            const int  HEADER_PILOT_COUNT = TapeDataBlockPlayer.HEADER_PILOT_COUNT;
            const int  SYNC_1_PL          = TapeDataBlockPlayer.SYNC_1_PL;
            const long PILOT_END          = PILOT_PL * HEADER_PILOT_COUNT;
            const long START = 123456789L;

            var player = TapPlayerHelper.CreatePlayer(TAPESET);

            player.InitPlay(START);

            // --- This is a standard ROM header data block
            var block = player.CurrentBlock as TapDataBlock;

            // --- Skip all pilot pulses
            for (long pos = 0; pos < PILOT_END; pos += 50)
            {
                block.GetEarBit(START + pos);
            }

            // --- Act/Assert
            for (var pos = PILOT_END + 50; pos < PILOT_END + SYNC_1_PL; pos += 50)
            {
                var earBit = block.GetEarBit(START + pos);
                earBit.ShouldBeFalse();
                block.PlayPhase.ShouldBe(PlayPhase.Sync);
            }
        }
Ejemplo n.º 2
0
        public void PlayMovesToNextBlock()
        {
            // --- Arrange
            var player = TapPlayerHelper.CreatePlayer(TAPESET);

            player.InitPlay(100);
            var currentBlock = player.CurrentBlock as TapDataBlock;

            // --- Act
            var indexBefore = player.CurrentBlockIndex;

            currentBlock.CompleteBlock();
            var lastTact = currentBlock.LastTact;

            player.GetEarBit(lastTact);
            var indexAfter = player.CurrentBlockIndex;

            // --- Assert
            indexBefore.ShouldBe(0);
            indexAfter.ShouldBe(1);
            currentBlock = player.CurrentBlock as TapDataBlock;
            currentBlock.ShouldNotBeNull();
            currentBlock.PlayPhase.ShouldBe(PlayPhase.Pilot);
            currentBlock.StartTact.ShouldBe(lastTact);
            currentBlock.ByteIndex.ShouldBe(0);
            currentBlock.BitMask.ShouldBe((byte)0x80);
        }
Ejemplo n.º 3
0
        public void SecondPilotPulseGenerationWorks()
        {
            // --- Arrange
            const int PILOT_PL = TapeDataBlockPlayer.PILOT_PL;

            const long START  = 123456789L;
            var        player = TapPlayerHelper.CreatePlayer(TAPESET);

            player.InitPlay(START);

            // --- This is a standard ROM header data block
            var block = player.CurrentBlock as TapDataBlock;

            // --- Skip EAR bits of the first pluse
            for (long pos = 0; pos < PILOT_PL; pos += 50)
            {
                block.GetEarBit(START + pos);
            }

            // --- Act/Assert
            for (long pos = PILOT_PL; pos < 2 * PILOT_PL; pos += 50)
            {
                var earBit = block.GetEarBit(START + pos);
                earBit.ShouldBeFalse();
                block.PlayPhase.ShouldBe(PlayPhase.Pilot);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads nad positions a standard speed data block to its data area
        /// </summary>
        /// <returns>Standard speed data block</returns>
        private static TapDataBlock ReadAndPositionToDataSection()
        {
            const int  PILOT_PL           = TapeDataBlockPlayer.PILOT_PL;
            const int  HEADER_PILOT_COUNT = TapeDataBlockPlayer.HEADER_PILOT_COUNT;
            const int  SYNC_1_PL          = TapeDataBlockPlayer.SYNC_1_PL;
            const int  SYNC_2_PL          = TapeDataBlockPlayer.SYNC_2_PL;
            const long PILOT_END          = PILOT_PL * HEADER_PILOT_COUNT;
            const long START = 123456789L;

            var player = TapPlayerHelper.CreatePlayer(TAPESET);

            player.InitPlay(START);

            // --- This is a standard ROM header data block
            var block = player.CurrentBlock as TapDataBlock;

            // --- Skip all pilot pulses + the first sync pulse
            for (long pos = 0; pos < PILOT_END + SYNC_1_PL; pos += 50)
            {
                block.GetEarBit(START + pos);
            }
            // --- Skip the second sync pulse
            for (var pos = PILOT_END + SYNC_1_PL + 50; pos < PILOT_END + SYNC_1_PL + SYNC_2_PL; pos += 50)
            {
                block.GetEarBit(START + pos);
            }
            return(block);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Tests a pilot pulse
        /// </summary>
        /// <param name="pulseIndex">The index of the pilor pulse</param>
        private void TestPilotPulsePlayback(int pulseIndex)
        {
            // --- Arrange
            const int  PILOT_PL = TapeDataBlockPlayer.PILOT_PL;
            const long START    = 123456789L;

            var player = TapPlayerHelper.CreatePlayer(TAPESET);

            player.InitPlay(START);

            // --- This is a standard ROM header data block
            var block        = player.CurrentBlock as TapDataBlock;
            var prevPulseEnd = PILOT_PL * (pulseIndex - 1);

            // --- Skip EAR bits of the previous pulses
            for (long pos = 0; pos < prevPulseEnd; pos += 50)
            {
                block.GetEarBit(START + pos);
            }

            // --- Act/Assert
            for (var pos = prevPulseEnd + 50; pos < prevPulseEnd + PILOT_PL; pos += 50)
            {
                var earBit = block.GetEarBit(START + pos);
                earBit.ShouldBe(pulseIndex % 2 == 1);
                block.PlayPhase.ShouldBe(PlayPhase.Pilot);
            }
        }
Ejemplo n.º 6
0
        public void TapFileCanBeReadSuccessfully()
        {
            // --- Act
            var player = TapPlayerHelper.CreatePlayer(TAPESET);

            // --- Assert
            player.DataBlocks.Count.ShouldBe(4);
            player.Eof.ShouldBeFalse();
        }
Ejemplo n.º 7
0
        public void InitPlayWorksAsExpected()
        {
            // --- Arrange
            var player = TapPlayerHelper.CreatePlayer(TAPESET);

            // --- Act
            player.InitPlay(100);

            // --- Assert
            player.PlayPhase.ShouldBe(PlayPhase.None);
            player.StartTact.ShouldBe(100);
            player.CurrentBlockIndex.ShouldBe(0);
        }
Ejemplo n.º 8
0
        public void InitPlayInitializesTheFirstDataBlock()
        {
            // --- Arrange
            var player = TapPlayerHelper.CreatePlayer(TAPESET);

            // --- Act
            player.InitPlay(100);

            // --- Assert
            var currentBlock = player.CurrentBlock as TapDataBlock;

            currentBlock.ShouldNotBeNull();
            currentBlock.PlayPhase.ShouldBe(PlayPhase.Pilot);
            currentBlock.StartTact.ShouldBe(player.StartTact);
            currentBlock.ByteIndex.ShouldBe(0);
            currentBlock.BitMask.ShouldBe((byte)0x80);
        }
Ejemplo n.º 9
0
        public void PlayDoesNotSetEofUntilEnd()
        {
            // --- Arrange
            var player = TapPlayerHelper.CreatePlayer(TAPESET);

            player.InitPlay(100);
            for (var i = 0; i < 3; i++) // Block 3 is a middle block
            {
                var currentBlock = player.CurrentBlock as TapDataBlock;
                currentBlock.CompleteBlock();
                var lastTact = currentBlock.LastTact;
                player.GetEarBit(lastTact);
            }

            // --- Act
            var lastBlock = player.CurrentBlock as TapDataBlock;

            lastBlock.ReadUntilPause();

            // --- Assert
            player.Eof.ShouldBeFalse();
        }
Ejemplo n.º 10
0
        public void PlaySetsEofAtTheLastPlayableBlock()
        {
            // --- Arrange
            var player = TapPlayerHelper.CreatePlayer(TAPESET);

            player.InitPlay(100);
            for (var i = 0; i < 4; i++) // Block 4 is the last
            {
                var currentBlock = player.CurrentBlock as TapDataBlock;
                currentBlock.CompleteBlock();
                var lastTact = currentBlock.LastTact;
                player.GetEarBit(lastTact);
            }

            // --- Act
            var lastBlock = player.CurrentBlock as TapDataBlock;
            var lastPos   = lastBlock.ReadUntilPause();

            player.GetEarBit(lastPos);

            // --- Assert
            player.Eof.ShouldBeTrue();
        }