public void LoadTapFileTest() { var filename = @"Binaries\froggers.tap"; var tf = new TapFormat(); var bytes = File.ReadAllBytes(filename); tf.ReadFile(bytes); Assert.AreEqual(tf.Blocks.Count, 2); }
public void LoadTape(byte[] data) { tf.ReadFile(data); bool ear = false; long tstate = 0; long b = 0; int bitmask; bool signal; foreach (var block in tf.Blocks) { for (int pilotcount = 0; pilotcount < (block.Data[0] < 128 ? 8063 : 3223); pilotcount++) { ear = !ear; tstate += 2168; EarValues.Add(new EarValue() { Ear = ear, TState = tstate, Pulse = PulseTypeEnum.Pilot }); } //Add sync1 ear = !ear; tstate += 667; EarValues.Add(new EarValue() { Ear = ear, TState = tstate, Pulse = PulseTypeEnum.Sync1 }); //Add sync2 ear = !ear; tstate += 735; EarValues.Add(new EarValue() { Ear = ear, TState = tstate, Pulse = PulseTypeEnum.Sync2 }); b = 0; for (; b < block.Data.Length; b++) { for (bitmask = 0x80; bitmask > 0; bitmask = bitmask >> 1) { signal = (block.Data[b] & bitmask) == bitmask; //Add two pulses ear = !ear; tstate += signal ? 1710 : 855; EarValues.Add(new() { Ear = ear, TState = tstate, Pulse = PulseTypeEnum.Data }); ear = !ear; tstate += signal ? 1710 : 855; EarValues.Add(new() { Ear = ear, TState = tstate, Pulse = PulseTypeEnum.Data }); } } ear = !ear; tstate += 3500; EarValues.Add(new() { Ear = ear, TState = tstate, Pulse = PulseTypeEnum.Pause }); //Pause ear = false; tstate += 3500 * 1000; //1second; EarValues.Add(new() { Ear = ear, TState = tstate, Pulse = PulseTypeEnum.Pause }); } //Add Termination ear = !ear; tstate += 947; EarValues.Add(new() { Ear = ear, TState = tstate, Pulse = PulseTypeEnum.Termination }); EarValues.Add(new() { Ear = false, TState = tstate, Pulse = PulseTypeEnum.Stop }); }