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 = TzxPlayerHelper.CreatePlayer("JetSetWilly.tzx"); player.InitPlay(START); // --- This is a standard ROM header data block var block = player.CurrentBlock as TzxStandardSpeedDataBlock; // --- 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); } }
public void PlayMovesToNextBlock() { // --- Arrange var player = TzxPlayerHelper.CreatePlayer(TAPESET); player.InitPlay(100); var currentBlock = player.CurrentBlock as TzxStandardSpeedDataBlock; // --- 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 TzxStandardSpeedDataBlock; currentBlock.ShouldNotBeNull(); currentBlock.PlayPhase.ShouldBe(PlayPhase.Pilot); currentBlock.StartTact.ShouldBe(lastTact); currentBlock.ByteIndex.ShouldBe(0); currentBlock.BitMask.ShouldBe((byte)0x80); }
public void SecondPilotPulseGenerationWorks() { // --- Arrange const int PILOT_PL = TapeDataBlockPlayer.PILOT_PL; const long START = 123456789L; var player = TzxPlayerHelper.CreatePlayer("JetSetWilly.tzx"); player.InitPlay(START); // --- This is a standard ROM header data block var block = player.CurrentBlock as TzxStandardSpeedDataBlock; // --- 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); } }
/// <summary> /// Reads nad positions a standard speed data block to its data area /// </summary> /// <returns>Standard speed data block</returns> private static TzxStandardSpeedDataBlock 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 = TzxPlayerHelper.CreatePlayer("JetSetWilly.tzx"); player.InitPlay(START); // --- This is a standard ROM header data block var block = player.CurrentBlock as TzxStandardSpeedDataBlock; // --- 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); }
/// <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 = TzxPlayerHelper.CreatePlayer("JetSetWilly.tzx"); player.InitPlay(START); // --- This is a standard ROM header data block var block = player.CurrentBlock as TzxStandardSpeedDataBlock; 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); } }
public void InitPlayWorksAsExpected() { // --- Arrange var player = TzxPlayerHelper.CreatePlayer(TAPESET); // --- Act player.InitPlay(100); // --- Assert player.PlayPhase.ShouldBe(PlayPhase.None); player.StartTact.ShouldBe(100); player.CurrentBlockIndex.ShouldBe(0); player.CurrentBlock.ShouldBeOfType <TzxStandardSpeedDataBlock>(); }
public void TzxFileCanBeReadSuccessfully() { // --- Act var player = TzxPlayerHelper.CreatePlayer(TAPESET); // --- Assert player.DataBlocks.Count.ShouldBe(9); player.DataBlocks[0].ShouldBeOfType <TzxTextDescriptionDataBlock>(); for (var i = 1; i < 9; i++) { player.DataBlocks[i].ShouldBeOfType <TzxStandardSpeedDataBlock>(); } player.Eof.ShouldBeFalse(); }
public void InitPlayInitializesTheFirstDataBlock() { // --- Arrange var player = TzxPlayerHelper.CreatePlayer(TAPESET); // --- Act player.InitPlay(100); // --- Assert var currentBlock = player.CurrentBlock as TzxStandardSpeedDataBlock; currentBlock.ShouldNotBeNull(); currentBlock.PlayPhase.ShouldBe(PlayPhase.Pilot); currentBlock.StartTact.ShouldBe(player.StartTact); currentBlock.ByteIndex.ShouldBe(0); currentBlock.BitMask.ShouldBe((byte)0x80); }
public void PlayDoesNotSetEofUntilEnd() { // --- Arrange var player = TzxPlayerHelper.CreatePlayer(TAPESET); player.InitPlay(100); while (player.CurrentBlockIndex < 6) // Block 6 is a middle block { var currentBlock = player.CurrentBlock as TzxStandardSpeedDataBlock; currentBlock.CompleteBlock(); var lastTact = currentBlock.LastTact; player.GetEarBit(lastTact); } // --- Act var lastBlock = player.CurrentBlock as TzxStandardSpeedDataBlock; lastBlock.ReadUntilPause(); // --- Assert player.Eof.ShouldBeFalse(); }
public void PlaySetsEofAtTheLastPlayableBlock() { // --- Arrange var player = TzxPlayerHelper.CreatePlayer(TAPESET); player.InitPlay(100); for (var i = 0; i < 8; i++) // Block 7 is the last { var currentBlock = player.CurrentBlock as TzxStandardSpeedDataBlock; currentBlock.CompleteBlock(); var lastTact = currentBlock.LastTact; player.GetEarBit(lastTact); } // --- Act var lastBlock = player.CurrentBlock as TzxStandardSpeedDataBlock; var lastPos = lastBlock.ReadUntilPause(); player.GetEarBit(lastPos); // --- Assert player.Eof.ShouldBeTrue(); }