// Try to construct a tape file from file data. Returns null if not a tape file, throws exceptions for bad tape files. // (Note that some error conditions aren't caught right here.) public static Tape Load(byte[] tapeFile) { Tape result = null; if (Encoding.ASCII.GetString(tapeFile, 0, 12) == "C64-TAPE-RAW") { var version = tapeFile[12]; if (version > 1) throw new Exception("This tape has an unsupported version"); var size = BitConverter.ToUInt32(tapeFile, 16); if (size + 20 != tapeFile.Length) { throw new Exception("Tape file header specifies a length that doesn't match the file size"); } result = new Tape(version, tapeFile, 20, tapeFile.Length); } return result; }
public void Insert(Tape tape) { _tape = tape; }
public void RemoveMedia() { _tape = null; }