/// <summary> /// Load BAM data from disk image /// </summary> /// <param name="disk">Disk image to read</param> public override void Load(BaseDisk disk) { LoadHeader(disk, 18, 0); const int tracks = 35; byte[] data = disk.GetSector(18, 0); DoubleSide = (data[3] == 0x80); byte[] table = new byte[tracks * 4]; Array.Copy(data, 4, table, 0, tracks * 4); SectorsMap.Clear(); loadMap(table, 4); for (int j = 0; j < tracks; j++) { table[j * 4] = data[0xDD + j]; } data = disk.GetSector(53, 0); for (int j = 0; j < tracks; j++) { Array.Copy(data, j * 3, table, j * 4, 3); } loadMap(table, 4); }
/// <summary> /// Load BAM data from disk image /// </summary> /// <param name="disk">Disk image to read</param> public override void Load(BaseDisk disk) { LoadHeader(disk, 40, 0); const int tracks = 40; byte[] table = new byte[tracks * 6]; byte[] data = disk.GetSector(40, 1); Array.Copy(data, 0x10, table, 0, tracks * 6); SectorsMap.Clear(); loadMap(table, 6); data = disk.GetSector(40, 2); Array.Copy(data, 0x10, table, 0, tracks * 6); loadMap(table, 6); }
/// <summary> /// Read disk header /// </summary> /// <param name="disk">disk to analyze</param> /// <param name="track">header track</param> /// <param name="sector">header sector</param> protected override void LoadHeader(BaseDisk disk, int track, int sector) { base.LoadHeader(disk, track, sector); byte[] data = disk.GetSector(track, sector); DOStype[0] = (char)data[0xA5]; DOStype[1] = (char)data[0xA6]; }
/// <summary> /// Load partial BAM /// </summary> /// <param name="disk">Disk to read</param> /// <param name="track">BAM track</param> /// <param name="sector">BAM sector</param> protected void loadPartialBAM(BaseDisk disk, int track, int sector) { byte[] data = disk.GetSector(track, sector); int firstTrack = data[4]; int lastTrack = data[5]; int tracks = lastTrack - firstTrack; byte[] table = new byte[tracks * 5]; Array.Copy(data, 6, table, 0, tracks * 5); loadMap(table, 5); }
/// <summary> /// Loads BAM data from disk image /// </summary> /// <param name="disk">Disk image to read</param> public override void Load(BaseDisk disk) { LoadHeader(disk, 18, 0); byte[] data = disk.GetSector(18, 0); byte[] table = new byte[totalTracks * 4]; Array.Copy(data, 4, table, 0, totalTracks * 4); SectorsMap.Clear(); loadMap(table, 4); }
/// <summary> /// Puts directory in disk sectors /// </summary> /// <param name="disk"></param> public void Save(BaseDisk disk) { disk.Header.FreeSectorsOnDirectoryTrack(); List <byte[]> rawData = ToRaw(); byte prevSect = disk.Header.Directory.Sector; if (rawData.Count > 0) { disk.PutSector(disk.Header.Directory.Track, prevSect, rawData[0]); for (int j = 1; j < rawData.Count; ++j) { int sect = disk.Header.GetAFreeSector(disk.Header.Directory.Track); if (sect > 0) { disk.GetSector(disk.Header.Directory.Track, prevSect)[0] = disk.Header.Directory.Track; disk.GetSector(disk.Header.Directory.Track, prevSect)[0] = (byte)sect; prevSect = (byte)sect; disk.PutSector(disk.Header.Directory.Track, sect, rawData[j]); } } } }
/// <summary> /// Load header from disk image /// </summary> /// <param name="disk">Disk image to read</param> /// <param name="track">Track of disk header</param> /// <param name="sector">Secton inside track of disk header</param> protected virtual void LoadHeader(BaseDisk disk, int track, int sector) { byte[] data = disk.GetSector(track, sector); Directory = new SectorId(data[0], data[1]); DOSversion = (char)data[2]; DiskName = string.Empty; for (int j = 0x90; j <= 0x9F; j++) { DiskName += (char)data[j]; } DiskId[0] = (char)data[0xA2]; DiskId[1] = (char)data[0xA3]; DOStype[0] = (char)data[0xA5]; DOStype[1] = (char)data[0xA6]; }
/// <summary> /// Loads directory from disk image database /// </summary> /// <param name="disk">disk image to read</param> /// <param name="id">directory start track/sector</param> public void Load(BaseDisk disk, SectorId id) { byte[] sectorData = disk.GetSector(id); for (byte j = 0; j < EntriesPerSector; j++) { byte[] entryData = new byte[DirectoryEntry.EntrySize]; Array.Copy(sectorData, j * DirectoryEntry.EntrySize, entryData, 0, DirectoryEntry.EntrySize); addEntry(entryData, id, j); } if (sectorData[0] == 0) { return; } Load(disk, new SectorId(sectorData[0], sectorData[1])); }
/// <summary> /// Read disk header /// </summary> /// <param name="disk">disk to analyze</param> /// <param name="track">header track</param> /// <param name="sector">header sector</param> protected override void LoadHeader(BaseDisk disk, int track, int sector) { byte[] data = disk.GetSector(track, sector); BAM = new SectorId(data[0], data[1]); Directory = new SectorId(39, 1); DOSversion = (char)data[2]; DiskName = string.Empty; for (int j = 0x06; j <= 0x16; j++) { DiskName += (char)data[j]; } DiskId[0] = (char)data[0x18]; DiskId[1] = (char)data[0x19]; DOStype[0] = (char)data[0x1B]; DOStype[1] = (char)data[0x1C]; }