2 using System.Collections.Generic;
5 using System.Threading.Tasks;
7 using System.Windows.Controls;
9 using System.Windows.Documents;
10 using System.Windows.Input;
11 using System.Windows.Media;
12 using System.Windows.Media.Imaging;
13 using System.Windows.Shapes;
21 InitializeComponent();
31 displayBuffer.FontFamily =
new FontFamily(
"Consolas");
32 displayBuffer.FontSize = 16;
33 displayBuffer.FontStyle = FontStyles.Normal;
34 displayBuffer.FontWeight = FontWeights.Normal;
36 Track t = floppy.tracks[track, side];
37 displayBuffer.AppendText(String.Format(
"Track {0:D2}.{1} has {2} blocks\n", track, side, t.blockCount));
39 uint trackDataSum = 0;
41 for (
int sect = 0; sect < t.blockCount; sect++) {
44 Sector s = t.sectors[sect];
46 gapSum += gap.gapBytes;
47 foreach (
DataElem data
in s.dataElems)
48 dataSum += (data.type ==
DataType.Sync) ? (data.dataBytes / 2) : data.dataBytes;
49 displayBuffer.AppendText(String.Format(
"Sector {0} Total={1} bytes (Gap={2} Data={3}) in Block Descriptor: (Gap={4} Data={5})\n",
50 sect, gapSum + dataSum, gapSum, dataSum, s.gapBits * 8, s.dataBits * 8));
53 displayBuffer.AppendText(String.Format(
" - {0} Gap {1} Value={2:X2}\n",
54 (gap.type ==
GapType.Forward) ?
"Forward" :
"Backward", (gap.gapBytes == 0) ?
"Repeat" : gap.gapBytes.ToString() +
" bytes", gap.value));
56 if (gapSum != (s.gapBits * 8))
57 displayBuffer.AppendText(String.Format(
" = Gap filling required: only {0} bytes specified out of {1}\n", gapSum, s.gapBits * 8));
59 foreach (
DataElem data
in s.dataElems) {
60 displayBuffer.AppendText(String.Format(
" + {0} {1} bytes\n",
61 data.type.ToString(), (data.type ==
DataType.Sync) ? (data.dataBytes / 2) : data.dataBytes));
64 trackDataSum += dataSum;
65 trackGapSum += gapSum;
67 displayBuffer.AppendText(String.Format(
"Track {0:D2}.{1} Specified Bytes={2} ({3}) Data={4} ({5}) Gap={6} ({7})\n", track, side,
68 trackDataSum + trackGapSum, (trackDataSum+trackGapSum)*8, trackDataSum, trackDataSum*8, trackGapSum, trackGapSum*8));
79 displayBuffer.FontFamily =
new FontFamily(
"Consolas");
80 displayBuffer.FontSize = 16;
81 displayBuffer.FontStyle = FontStyles.Normal;
82 displayBuffer.FontWeight = FontWeights.Normal;
84 for (
int i = 0; i < buffer.Count(); i += 16) {
85 displayBuffer.AppendText(String.Format(
" {0:D4} ", i));
88 for (
int j = 0; j < 16; j++) {
89 if ((i + j) < buffer.Count()) {
90 displayBuffer.AppendText(String.Format(
"{0:X2}{1}", buffer[i + j], (sync && (j % 2 == 0)) ?
"" :
" "));
91 char ch = Convert.ToChar(buffer[i + j]);
92 ascii += Char.IsControl(ch) ?
"." : ch.ToString();
95 displayBuffer.AppendText(String.Format(
" "));
97 displayBuffer.AppendText(ascii);
98 displayBuffer.AppendText(String.Format(
"\n"));
Interaction logic for BufferWindow.xaml
DataType
Type of Data in data element
Store information about all tracks of a FD
void drawBuffer(List< byte > buffer, bool sync)
Display the content of TrackBuffer buffer in the displayBuffer TextBox
Store the sector/bloc information
GapType
Type of a gap element
void displayBlocksBuffer(Floppy floppy, int track, int side)
Draw the content of the buffer
Store the content of a data element.
Store the content of a gap element including the gap value
Store information about one track