/// <summary> /// ヘッダ出力 /// </summary> /// <param name="fs"></param> private void WriteHeader(FileStream fs) { byte[] header = new byte[DefaultHeaderSize]; ImageSize = header.Length; int t = 0; foreach (SectorData s in Sectors) { if (s.Sector == 0x01) { TrackAddress[t++] = ImageSize; } ImageSize += s.GetLength(); } var dc = new DataController(header); dc.SetCopy(0, TextEncoding.GetBytes(this.DiskName), 0x10); dc.SetByte(0x1a, IsWriteProtect ? 0x10 : 0x00); dc.SetByte(0x1b, DiskType.ImageTypeByte); dc.SetLong(0x1c, (ulong)ImageSize); // トラック分のアドレスを出力する for (var i = 0; i < MaxTrack; i++) { var a = TrackAddress[i]; if (a == 0x00) { break; } dc.SetLong(0x20 + (i * 4), (ulong)a); } fs.Write(header, 0, header.Length); }
private void WriteEntry(DataController dc, HuFileEntry fe, int pos, int start, bool ipl) { dc.Fill(0x20, pos + 0x01, HuFileEntry.MaxNameLength); dc.Fill(0x20, pos + 0x0e, HuFileEntry.MaxExtensionLength); if (ipl) { WriteIplName(dc, pos); } else { WriteEntryName(dc, fe, pos); } dc.SetByte(pos + 0x11, fe.Password); dc.SetWord(pos + 0x12, fe.Size); dc.SetWord(pos + 0x14, fe.LoadAddress); dc.SetWord(pos + 0x16, fe.ExecuteAddress); dc.SetCopy(pos + 0x18, fe.DateTimeData); // 最上位は未調査 dc.SetByte(pos + 0x1d, (start >> 14) & 0x7f); dc.SetByte(pos + 0x1e, start & 0x7f); dc.SetByte(pos + 0x1f, (start >> 7) & 0x7f); }
private void WriteIplName(DataController dc, int pos) { dc.SetByte(pos, 0x01); dc.SetCopy(pos + 0x01, TextEncoding.GetBytes(Setting.IplName)); dc.SetCopy(pos + 0x0e, TextEncoding.GetBytes("Sys")); }
private void WriteEntryName(DataController dc, HuFileEntry fe, int pos) { dc.SetByte(pos, fe.FileMode); dc.SetCopy(pos + 0x01, TextEncoding.GetBytes(fe.Name)); dc.SetCopy(pos + 0x0e, TextEncoding.GetBytes(fe.Extension)); }