using System; using System.Collections.Generic; namespace Core.Io { // The base class all future TZX blocks will inherit from public abstract class TzxBlock { public abstract int BlockId { get; } } // ID 0x10: Standard Speed Data Block public class StandardSpeedBlock : TzxBlock { public override int BlockId => 0x10; // How long to pause the tape in milliseconds after this block loads public ushort PauseAfterMs { get; set; } public ushort DataLength { get; set; } // The actual tape bytes public byte[] Data { get; set; } = Array.Empty(); } // ID 0x32: Archive Info Block (Metadata) public class ArchiveInfoBlock : TzxBlock { public override int BlockId => 0x32; // Key: Text ID (e.g., 0 = Full Title, 1 = Software House, 2 = Publisher, 4 = Year) // Value: The actual text string public Dictionary Metadata { get; set; } = new Dictionary(); } // ID 0x11: Turbo Speed Data Block public class TurboSpeedBlock : TzxBlock { public override int BlockId => 0x11; public ushort PilotPulseLength { get; set; } public ushort SyncFirstPulseLength { get; set; } public ushort SyncSecondPulseLength { get; set; } public ushort ZeroBitPulseLength { get; set; } public ushort OneBitPulseLength { get; set; } public ushort PilotToneLength { get; set; } public byte UsedBitsInLastByte { get; set; } public ushort PauseAfterMs { get; set; } // This is a 24-bit integer in the file, so we store it in a standard 32-bit int public int DataLength { get; set; } public byte[] Data { get; set; } = Array.Empty(); // ID 0x30: Text Description public class TextDescriptionBlock : TzxBlock { public override int BlockId => 0x30; public string Description { get; set; } = string.Empty; } // ID 0x20: Pause / Stop the Tape public class PauseBlock : TzxBlock { public override int BlockId => 0x20; public ushort PauseDurationMs { get; set; } // 0 means "Stop the tape" } // ID 0x21: Group Start (Used to group blocks in UI tape browsers) public class GroupStartBlock : TzxBlock { public override int BlockId => 0x21; public string GroupName { get; set; } = string.Empty; } // ID 0x22: Group End public class GroupEndBlock : TzxBlock { public override int BlockId => 0x22; } // ID 0x12: Pure Tone Block public class PureToneBlock : TzxBlock { public override int BlockId => 0x12; public ushort PulseLength { get; set; } public ushort PulseCount { get; set; } } // ID 0x13: Pulse Sequence Block public class PulseSequenceBlock : TzxBlock { public override int BlockId => 0x13; // Number of pulses (1 to 255) public int PulseCount { get; set; } // The exact T-State lengths of each pulse public ushort[] Pulses { get; set; } = Array.Empty(); } // ID 0x14: Pure Data Block public class PureDataBlock : TzxBlock { public override int BlockId => 0x14; public ushort ZeroBitPulseLength { get; set; } public ushort OneBitPulseLength { get; set; } public byte UsedBitsInLastByte { get; set; } public ushort PauseAfterMs { get; set; } // The return of the 24-bit integer! public int DataLength { get; set; } public byte[] Data { get; set; } = Array.Empty(); } } }