private void BadMFMSectorDraw() { //decimal posx; int indexS1 = -1, indexS2 = -1; int offset = 4, diskoffset; int track, sector; int offsetmfm; int offsetmfm2; int lengthmfm = 0; byte[] sectors = new byte[1050]; byte[] sectors2 = new byte[1050]; //int qq; int sectorlength = 512; int threadid = 0; switch (processing.diskformat) { case DiskFormat.unknown: textBoxReceived.AppendText("\r\nMissing disk format definition, can't draw map. See method BadMFMSectorDraw().\r\n"); return; case DiskFormat.amigados: //AmigaDos offset = 0; lengthmfm = 8704; break; case DiskFormat.diskspare: //diskspare offset = 0; lengthmfm = 8320; break; case DiskFormat.pcdd: //pc2m case DiskFormat.pc360kb525in: // PC360KB 5.25" offset = -704; lengthmfm = 10464; break; case DiskFormat.pchd: //pcdd offset = -704; lengthmfm = 10464; break; case DiskFormat.pc2m: //pchd offset = -704; lengthmfm = 10464; break; } badsectorkeyval badsector1; //textBoxReceived.Text += ""; foreach (int q in BadSectorListBox.SelectedIndices) { badsector1 = (badsectorkeyval)BadSectorListBox.Items[q]; } if (BadSectorListBox.SelectedIndices.Count == 1) { indexS1 = ((badsectorkeyval)BadSectorListBox.Items[BadSectorListBox.SelectedIndices[0]]).id; threadid = ((badsectorkeyval)BadSectorListBox.Items[BadSectorListBox.SelectedIndices[0]]).threadid; indexS2 = -1; if (BSBlueSectormapRadio.Checked) { track = processing.sectordata2[indexS1].track; sector = processing.sectordata2[indexS1].sector; diskoffset = track * sectorlength * processing.sectorspertrack + sector * sectorlength; Array.Copy(processing.disk, diskoffset, sectors, 0, sectorlength); offset = 0; } if (BSBlueFromListRadio.Checked) { threadid = processing.sectordata2[indexS1].threadid; sectorlength = processing.sectordata2[indexS1].sectorlength; //Array.Copy(processing.sectordata2[indexS1].sectorbytes, 0, sectors, 0, sectorlength); offsetmfm = processing.sectordata2[indexS1].MarkerPositions; sectors = processing.MFM2ByteArray(processing.mfms[threadid], offsetmfm + offset, lengthmfm); //offset = 4; } if (BlueTempRadio.Checked) { Array.Copy(TempSector, 0, sectors, 0, sectorlength + 6); //offset = 4; } BlueCrcCheckLabel.Text = "Crc: " + processing.sectordata2[indexS1].crc.ToString("X2"); if (indexS2 != -1) { RedCrcCheckLabel.Text = "Crc: " + processing.sectordata2[indexS2].crc.ToString("X2"); } else { RedCrcCheckLabel.Text = "Crc:"; } } else if (BadSectorListBox.SelectedIndices.Count >= 2) { indexS1 = ((badsectorkeyval)BadSectorListBox.Items[BadSectorListBox.SelectedIndices[0]]).id; indexS2 = ((badsectorkeyval)BadSectorListBox.Items[BadSectorListBox.SelectedIndices[1]]).id; //threadid = ((badsectorkeyval)BadSectorListBox.Items[BadSectorListBox.SelectedIndices[0]]).threadid; threadid = processing.sectordata2[indexS1].threadid; sectorlength = processing.sectordata2[indexS1].sectorlength; offsetmfm = processing.sectordata2[indexS1].MarkerPositions; sectors = processing.MFM2ByteArray(processing.mfms[threadid], offsetmfm + offset, lengthmfm); threadid = processing.sectordata2[indexS2].threadid; offsetmfm2 = processing.sectordata2[indexS2].MarkerPositions; sectors2 = processing.MFM2ByteArray(processing.mfms[threadid], offsetmfm2 + offset, lengthmfm); BlueCrcCheckLabel.Text = "Crc: " + processing.sectordata2[indexS1].crc.ToString("X2"); if (indexS2 != -1) { RedCrcCheckLabel.Text = "Crc: " + processing.sectordata2[indexS2].crc.ToString("X2"); } else { RedCrcCheckLabel.Text = "Crc:"; } } else if (BSBlueSectormapRadio.Checked) { track = (int)Track1UpDown.Value; sector = (int)Sector1UpDown.Value; diskoffset = track * sectorlength * processing.sectorspertrack + sector * sectorlength; Array.Copy(processing.disk, diskoffset, sectors, 0, sectorlength); offset = 0; } else { return; // nothing selected, nothing to do } System.Drawing.Graphics formGraphics = BadSectorPanel.CreateGraphics(); //ECHisto.DoHistogram(sectors, offset, sectorlength); //HistScalingLabel.Text = "Scale: " + ECHisto.getScaling().ToString(); ; if (!BSBlueSectormapRadio.Checked) // there's no relevant data when this radio button is checked { int scatoffset = processing.sectordata2[indexS1].rxbufMarkerPositions + (int)ScatterMinTrackBar.Value + (int)ScatterOffsetTrackBar.Value; int scatlength = processing.sectordata2[indexS1].rxbufMarkerPositions + (int)ScatterMaxTrackBar.Value + (int)ScatterOffsetTrackBar.Value - scatoffset; scatterplot.AnScatViewlargeoffset = scatoffset; scatterplot.AnScatViewoffset = 0; scatterplot.AnScatViewlength = scatlength; scatterplot.UpdateScatterPlot(); } //StringBuilder mfmbyteEnc = new StringBuilder(); using (var bmp1 = new System.Drawing.Bitmap(520, 256)) { LockBitmap lockBitmap = new LockBitmap(bmp1); lockBitmap.LockBits(); //lockBitmap.filledsquare(10, 10, 16, 16, Color.FromArgb(255, 0, 0, 255)); byte value1 = 0, value2 = 0, colorR = 0, colorB = 0; //int y2; //int width = 40; int height = 32; //sectors.Length / width; int sectorsindex = 0; int w, h, x, y; w = 13; h = (256 / height); float f = 512.0f / sectorlength; //if (f == 0.5f) //{ // int qq = 2; //} if (sectors.Length > 0) { for (y = 0; y < 256; y += h) { for (x = 0; x < 520; x += w) { //Thread.Sleep(250); //lockBitmap.UnlockBits(); //formGraphics.DrawImage(bmp1, 0, 0); //lockBitmap.LockBits(); value1 = sectors[sectorsindex]; mfmbyteenc[value1]++; //mfmbyteEnc.Append(value1.ToString("X2")+" "); if (indexS2 == -1) { colorB = value1; value2 = 0; colorR = 0; } else { value2 = sectors2[sectorsindex]; if (value1 == value2) { colorR = 0; colorB = value1; } else { colorR = (byte)(128 + (value2 / 2)); colorB = value1; } } sectorsindex++; if (sectorsindex >= sectors.Length) { break; } lockBitmap.filledsquare(x, y, w, h, Color.FromArgb(255, colorR, 0, colorB)); } if (sectorsindex >= sectors.Length) { break; } } } lockBitmap.UnlockBits(); formGraphics.DrawImage(bmp1, 0, 0); } formGraphics.Dispose(); //tbSectorMap.AppendText(mfmbyteEnc.ToString()); }
private void BadSectorByteDraw() { int i; //, datapoints, start, end, scrollbarcurrentpos; //decimal posx; int indexS1 = -1, indexS2 = -1; int offset = 4, diskoffset; int track, sector; byte[] sectors = new byte[1050]; //int qq; int sectorlength = 512; int threadid = 0; switch ((int)processing.diskformat) { case 0: return; case 1: offset = 0; break; case 2: offset = 0; break; case 3: offset = 4; break; case 4: offset = 4; break; case 5: offset = 4; break; } badsectorkeyval badsector1; //textBoxReceived.Text += ""; foreach (int q in BadSectorListBox.SelectedIndices) { badsector1 = (badsectorkeyval)BadSectorListBox.Items[q]; } if (BadSectorListBox.SelectedIndices.Count == 1) { indexS1 = ((badsectorkeyval)BadSectorListBox.Items[BadSectorListBox.SelectedIndices[0]]).id; threadid = ((badsectorkeyval)BadSectorListBox.Items[BadSectorListBox.SelectedIndices[0]]).threadid; indexS2 = -1; if (BSBlueSectormapRadio.Checked) { track = processing.sectordata2[indexS1].track; sector = processing.sectordata2[indexS1].sector; diskoffset = track * sectorlength * processing.sectorspertrack + sector * sectorlength; Array.Copy(processing.disk, diskoffset, sectors, 0, sectorlength); offset = 0; } if (BSBlueFromListRadio.Checked) { sectorlength = processing.sectordata2[indexS1].sectorlength; Array.Copy(processing.sectordata2[indexS1].sectorbytes, 0, sectors, 0, sectorlength); //offset = 4; } if (BlueTempRadio.Checked) { Array.Copy(TempSector, 0, sectors, 0, sectorlength + 6); //offset = 4; } BlueCrcCheckLabel.Text = "Crc: " + processing.sectordata2[indexS1].crc.ToString("X2"); if (indexS2 != -1) { RedCrcCheckLabel.Text = "Crc: " + processing.sectordata2[indexS2].crc.ToString("X2"); } else { RedCrcCheckLabel.Text = "Crc:"; } } else if (BadSectorListBox.SelectedIndices.Count >= 2) { indexS1 = ((badsectorkeyval)BadSectorListBox.Items[BadSectorListBox.SelectedIndices[0]]).id; indexS2 = ((badsectorkeyval)BadSectorListBox.Items[BadSectorListBox.SelectedIndices[1]]).id; threadid = ((badsectorkeyval)BadSectorListBox.Items[BadSectorListBox.SelectedIndices[0]]).threadid; sectorlength = processing.sectordata2[indexS1].sectorlength; if (BSBlueFromListRadio.Checked) { Array.Copy(processing.sectordata2[indexS1].sectorbytes, 0, sectors, 0, processing.sectordata2[indexS1].sectorbytes.Length); //offset = 4; } BlueCrcCheckLabel.Text = "Crc: " + processing.sectordata2[indexS1].crc.ToString("X2"); if (indexS2 != -1) { RedCrcCheckLabel.Text = "Crc: " + processing.sectordata2[indexS2].crc.ToString("X2"); } else { RedCrcCheckLabel.Text = "Crc:"; } } else if (BSBlueSectormapRadio.Checked) { track = (int)Track1UpDown.Value; sector = (int)Sector1UpDown.Value; diskoffset = track * sectorlength * processing.sectorspertrack + sector * sectorlength; Array.Copy(processing.disk, diskoffset, sectors, 0, sectorlength); offset = 0; } else { return; // nothing selected, nothing to do } System.Drawing.Pen BlackPen; BlackPen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(255, 128, 128, 128)); System.Drawing.Graphics formGraphics = BadSectorPanel.CreateGraphics(); System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(Color.White); ECHisto.DoHistogram(sectors, offset, sectorlength); HistScalingLabel.Text = "Scale: " + ECHisto.getScaling().ToString();; if (!BSBlueSectormapRadio.Checked) // there's no relevant data when this radio button is checked { int scatoffset = processing.sectordata2[indexS1].rxbufMarkerPositions + (int)ScatterMinTrackBar.Value + (int)ScatterOffsetTrackBar.Value; int scatlength = processing.sectordata2[indexS1].rxbufMarkerPositions + (int)ScatterMaxTrackBar.Value + (int)ScatterOffsetTrackBar.Value - scatoffset; scatterplot.AnScatViewlargeoffset = scatoffset; scatterplot.AnScatViewoffset = 0; scatterplot.AnScatViewlength = scatlength; scatterplot.UpdateScatterPlot(); } using (var bmp1 = new System.Drawing.Bitmap(512, 256)) { LockBitmap lockBitmap = new LockBitmap(bmp1); lockBitmap.LockBits(); byte value1 = 0, value2 = 0, colorR = 0, colorB = 0; int y = 0; int y2, q; float f = 512.0f / sectorlength; //if (f == 0.5f) //{ // int qq = 2; //} for (i = 0; i < sectorlength; i++) { value1 = sectors[i + offset]; if (indexS2 == -1) { colorB = value1; value2 = 0; colorR = 0; } else { value2 = processing.sectordata2[indexS2].sectorbytes[i + offset]; if (value1 == value2) { colorR = 0; colorB = value1; } else { colorR = (byte)(128 + (value2 / 2)); colorB = value1; } } y2 = 0; for (q = 0; q < 256; q++) { lockBitmap.SetPixel((i % 32) * 16 + (q % 16), (int)(y * 16 * f + (y2 * f)), Color.FromArgb(255, colorR, 0, colorB)); if (q % 16 == 15) { y2++; } } if (i % 32 == 31) { y++; } } lockBitmap.UnlockBits(); formGraphics.DrawImage(bmp1, 0, 0); } BlackPen.Dispose(); formGraphics.Dispose(); myBrush.Dispose(); }