private void button20_Click_1(object sender, EventArgs e)
        {
            //int i;
            StringBuilder tbt = new StringBuilder();
            StringBuilder txt = new StringBuilder();

            // Convert string of hex encoded ascii to byte array
            byte[] bytes = FDDProcessing.HexToBytes(tbBIN.Text);

            byte[] mfmbytes;

            // Convert bytes to Amiga mfm
            mfmbytes = processing.amigamfmencodebytes(bytes, 0, bytes.Length);

            byte[] checksum;

            checksum = processing.amigachecksum(mfmbytes, 0, mfmbytes.Length);

            tbt.Append("Checksum:" + checksum[0].ToString("X2") + checksum[1].ToString("X2") + checksum[2].ToString("X2") + checksum[3].ToString("X2"));

            tbTest.Clear();
            AntxtBox.Clear();
            tbTest.AppendText(tbt.ToString());
            AntxtBox.AppendText(txt.ToString());
        }
예제 #2
0
 public WaveformEdit(PictureBox GraphPictureBox, FileIO fio, FDDProcessing proc)
 {
     fileio                     = fio;
     processing                 = proc;
     graphset                   = new Graphset(GraphPictureBox, Color.Black);
     graphset.UpdateGUI        += updateGraphCallback;
     graphset.GetControlValues += GraphsetGetControlValuesCallback;
     graphset.tbreceived        = fileio.tbreceived;
 }
        private void button25_Click(object sender, EventArgs e)
        {
            byte[]     bytes = FDDProcessing.HexToBytes(tbBIN.Text);
            ushort     datacrcchk;
            Crc16Ccitt crc = new Crc16Ccitt(InitialCrcValue.NonZero3);

            datacrcchk = crc.ComputeGoodChecksum(bytes);
            tbTest.AppendText("CRC: " + datacrcchk.ToString("X4") + "\r\n");
        }
예제 #4
0
        public void TestProcessPCData()
        {
            //Arrange
            FileIO fileio = new FileIO();

            FDDProcessing processing = new FDDProcessing();

            processing            = new FDDProcessing();
            processing.indexrxbuf = 0;
            processing.tbreceived = new System.Text.StringBuilder();
            processing.GetProcSettingsCallback += GetProcSettingsCallback;

            fileio.processing         = processing;
            fileio.textBoxFilesLoaded = new TextBox();
            string[] file = new string[1];

            // This will get the current WORKING directory (i.e. \bin\Debug)
            string workingDirectory = Environment.CurrentDirectory;
            // or: Directory.GetCurrentDirectory() gives the same result

            // This will get the current PROJECT directory
            string projectDirectory = Directory.GetParent(workingDirectory).Parent.FullName;

            file[0] = projectDirectory + @"\TestData\A005 Modules5_T000_T159_000.bin";
            fileio.OpenFilesPaths = file;

            fileio.openfiles();


            processing.procsettings.NumberOfDups = 1;
            processing.procsettings.pattern      = 0;
            //tbreceived.Append("Combobox:" + PeriodBeyond8uscomboBox.SelectedIndex + "\r\n");

            processing.procsettings.offset               = 0;
            processing.procsettings.min                  = 0;
            processing.procsettings.four                 = 66;
            processing.procsettings.six                  = 102;
            processing.procsettings.max                  = 140;
            processing.procsettings.SkipPeriodData       = false;
            processing.procsettings.AutoRefreshSectormap = false;
            processing.procsettings.start                = 0;
            processing.procsettings.end                  = processing.rxbuf.Length - 1;
            processing.procsettings.finddupes            = true;

            //processing.procsettings.platform = platform; // 1 = Amiga
            processing.procsettings.UseErrorCorrection = true;
            processing.procsettings.OnlyBadSectors     = false;
            processing.procsettings.AddNoise           = false;

            processing.procsettings.limittotrack  = 0;
            processing.procsettings.limittosector = 0;

            processing.procsettings.LimitTSOn         = false;
            processing.procsettings.IgnoreHeaderError = false;

            processing.procsettings.rateofchange  = 1.0f; // Adapt rate
            processing.procsettings.AdaptOffset2  = 1.0f; // Adapt rate 2 (not labelled in gui)
            processing.procsettings.rateofchange2 = 128;  // Adapt track

            processing.procsettings.addnoiselimitstart = 0;
            processing.procsettings.addnoiselimitend   = processing.indexrxbuf;

            processing.procsettings.addnoiserndamount = 12;

            //Act
            processing.StartProcessing(Platform.PC);

            int sectorcount = 0;
            var sectorok    = processing.sectormap.sectorok;

            //Count good sectors
            for (int t = 0; t < 255; t++)
            {
                for (int s = 0; s < 255; s++)
                {
                    if (sectorok[t, s] == SectorMapStatus.CrcOk)
                    {
                        sectorcount++;
                    }
                }
            }

            //Assert
            Assert.AreEqual(1440, sectorcount);
        }
예제 #5
0
 public SectorMap(RichTextBox richtextbox, FDDProcessing proc)
 {
     rtbSectorMap = richtextbox;
     processing   = proc;
 }
        private void ConvertToMFMBtn_Click(object sender, EventArgs e)
        {
            int           i;
            StringBuilder tbt = new StringBuilder();
            StringBuilder txt = new StringBuilder();

            // Convert string of hex encoded ascii to byte array
            byte[] bytes = FDDProcessing.HexToBytes(tbBIN.Text);

            if (ANPCRadio.Checked)
            {
                // Convert byte array to MFM
                byte[] mfmbytes = processing.BIN2MFMbits(ref bytes, bytes.Count(), 0, false);
                byte[] bytebuf  = new byte[tbBIN.Text.Length];

                // Convert mfm to string
                tbMFM.Text = Encoding.ASCII.GetString(processing.BIN2MFMbits(ref bytes, bytes.Count(), 0, true));

                for (i = 0; i < mfmbytes.Length / 16; i++)
                {
                    bytebuf[i] = processing.MFMBits2BINbyte(ref mfmbytes, (i * 16));
                    tbt.Append(bytebuf[i].ToString("X2") + " ");
                    if (bytebuf[i] > ' ' && bytebuf[i] < 127)
                    {
                        txt.Append((char)bytebuf[i]);
                    }
                    else
                    {
                        txt.Append(".");
                    }
                }
            }
            else
            if (ANAmigaRadio.Checked)
            {
                byte[] mfmbytes = new byte[bytes.Length * 8];
                int    j;

                // Convert byte array to MFM
                for (i = 0; i < bytes.Length; i++)
                {
                    for (j = 0; j < 8; j++)
                    {
                        mfmbytes[i * 8 + j] = (byte)(bytes[i] >> (7 - j) & 1);
                    }
                }
                //byte[] mfmbytes = BIN2MFMbits(ref bytes, bytes.Count(), 0, false);
                byte[] bytebuf = new byte[tbBIN.Text.Length];

                // Convert mfm to string
                tbMFM.Text = Encoding.ASCII.GetString(processing.BIN2MFMbits(ref bytes, bytes.Count(), 0, true));

                bytebuf = processing.amigamfmdecodebytes(mfmbytes, 0, mfmbytes.Length); // This doesn't convert sector properly yet

                // Convert mfm back to bytes
                for (i = 0; i < bytebuf.Length; i++)
                {
                    //bytebuf[i] = MFMBits2BINbyte(ref mfmbytes, (i * 16));
                    tbt.Append(bytebuf[i].ToString("X2") + " ");
                    if (bytebuf[i] > 31 && bytebuf[i] < 127)
                    {
                        txt.Append((char)bytebuf[i]);
                    }
                    else
                    {
                        txt.Append(".");
                    }
                    if (i % 16 == 15)
                    {
                        tbt.Append("\r\n");
                    }
                    if (i % 32 == 31)
                    {
                        txt.Append("\r\n");
                    }
                }
            }
            else
            if (AmigaMFMRadio.Checked)
            {
                byte[] mfmbytes;

                // Convert bytes to Amiga mfm
                mfmbytes = processing.amigamfmencodebytes(bytes, 0, bytes.Length);
                byte[] bytebuf = new byte[tbBIN.Text.Length];

                // Convert mfm to string
                tbMFM.Text = Encoding.ASCII.GetString(processing.BIN2MFMbits(ref bytes, bytes.Count(), 0, true));

                bytebuf = processing.amigamfmdecodebytes(mfmbytes, 0, mfmbytes.Length); // This doesn't convert sector properly yet

                // Convert mfm back to bytes
                for (i = 0; i < bytebuf.Length; i++)
                {
                    //bytebuf[i] = MFMBits2BINbyte(ref mfmbytes, (i * 16));
                    tbt.Append(bytebuf[i].ToString("X2") + " ");
                    if (bytebuf[i] > 31 && bytebuf[i] < 127)
                    {
                        txt.Append((char)bytebuf[i]);
                    }
                    else
                    {
                        txt.Append(".");
                    }
                    if (i % 16 == 15)
                    {
                        tbt.Append("\r\n");
                    }
                    if (i % 32 == 31)
                    {
                        txt.Append("\r\n");
                    }
                }
            }

            tbTest.Clear();
            AntxtBox.Clear();
            tbTest.AppendText(tbt.ToString());
            AntxtBox.AppendText(txt.ToString());
        }