Esempio n. 1
0
        private void B_Add_Click(object sender, EventArgs e)
        {
            // Add the new code to the textbox.
            if (!loaddata())
            {
                return;
            }
            uint writeoffset = Util.getHEXval(TB_Write.Text);

            for (int i = 0; i < newdata.Length / 4; i++)
            {
                RTB_Code.AppendText((writeoffset + i * 4 + 0x20000000).ToString("X8") + " ");
                RTB_Code.AppendText(BitConverter.ToUInt32(newdata, i * 4).ToString("X8") + Environment.NewLine);
            }

            // Mat's Code - Unfinished
            //for (int i = 0; i < newdata.Length / (4); i++)
            //{
            //    // Add Operator

            //    RTB_Code.AppendText("00000001 ");   // 01 00 00 00
            //    RTB_Code.AppendText((writeoffset + i * 4).ToString("X8") + " ");
            //    RTB_Code.AppendText(BitConverter.ToUInt32(newdata,i*4).ToString("X8") + Environment.NewLine);
            //}
        }
Esempio n. 2
0
        private void B_Load_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog {
                Filter = "Code File|*.bin"
            };

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string path = ofd.FileName;

            byte[] ncf    = File.ReadAllBytes(path);
            uint   length = BitConverter.ToUInt32(ncf, 0);

            if (ncf.Length != length + 4)
            {
                Util.Error("Not a valid code file.");
                return;
            }
            if (RTB_Code.Text.Length > 0)
            {
                DialogResult ld = Util.Prompt(MessageBoxButtons.YesNo, "Replace current code?");
                if (ld == DialogResult.Yes)
                {
                    RTB_Code.Clear();
                }
                else if (ld != DialogResult.No)
                {
                    return;
                }
            }
            for (int i = 4; i <= ncf.Length - 12; i += 12)
            {
                RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 0 * 4).ToString("X8") + " ");
                RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 1 * 4).ToString("X8") + " ");
                RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 2 * 4).ToString("X8") + Environment.NewLine);
            }
        }