public void AddCode(CodeContent content, string name)
        {
            ListViewItem addCode = codeOutput.Items.Add(name);

            addCode.Tag = content;
            SendModified();
        }
        public void AddCode(string name)
        {
            CodeContent  newCode = new CodeContent();
            ListViewItem addCode = codeOutput.Items.Add(name);

            addCode.Tag = newCode;
            SendModified();
        }
Exemplo n.º 3
0
        private void codeOutput_SelectedIndexChanged(object sender, EventArgs e)
        {
            int newIndex;

            if (codeOutput.SelectedIndices.Count == 0)
            {
                newIndex = -1;
            }
            else
            {
                newIndex = codeOutput.SelectedIndices[0];
            }

            if (newIndex == PSelectedIndex)
            {
                return;
            }

            if (!UpdateCode())
            {
                codeOutput.Items[PSelectedIndex].Selected = true;
                return;
            }

            codeValues.Clear();
            if (newIndex == -1 || newIndex >= codeOutput.Items.Count)
            {
                PSelectedIndex     = -1;
                codeValues.Enabled = false;
            }
            else
            {
                PSelectedIndex = newIndex;
                CodeContent codeData;
                if (codeOutput.Items[newIndex].Tag == null)
                {
                    codeData = new CodeContent();
                }
                else
                {
                    codeData = (CodeContent)codeOutput.Items[newIndex].Tag;
                }
                codeValues.Enabled = true;
                //String output = "";
                //for (int i = 0; i < codeData.lines.Count; i++)
                //{
                //    if (!codeData.lines[i].enabled)
                //        output += "--";
                //    output += String.Format("{0:X8} ", codeData.lines[i].left);
                //    output += String.Format("{0:X8}\r\n", codeData.lines[i].right);
                //}
                codeValues.Text = CodeContentToCodeTextBox(codeData);
            }
        }
Exemplo n.º 4
0
        private void StandardCodeAddressStuff(UInt32 address, UInt32 value, UInt32 add)
        {
            CodeContent nCode = CodeController.CodeTextBoxToCodeContent(textBoxCodeEntries.Text);
            //UInt32 cAddressR = 0x80000000;
            UInt32 rAddressR;
            UInt32 offset;

            // base address is masked differently than pointer offset
            if (radioButtonBA.Checked)
            {
                rAddressR = address & 0xFE000000;
            }
            else
            {
                // TODO the po doesn't actually have this restriction
                // but for now we keep it like the ba
                //rAddressR = address & 0xFEFFFFFF;
                rAddressR = address & 0xFE000000;
                add      += 0x10000000;
            }

            // Do we need to change the ba or po?
            bool changeBAorPO = false;

            if ((address & 0xFE000000) != 0x80000000)
            {
                changeBAorPO = true;
            }

            if (changeBAorPO)
            {
                if (radioButtonBA.Checked)
                {
                    nCode.addLine(0x42000000, rAddressR);
                }
                else
                {
                    nCode.addLine(0x4A000000, rAddressR);
                }
            }

            // Add the actual code
            offset = address - rAddressR + add;
            nCode.addLine(offset, value);

            // Add terminator if necessary
            if (changeBAorPO)
            {
                nCode.addLine(0xE0000000, 0x80008000);
            }

            textBoxCodeEntries.Text = CodeController.CodeContentToCodeTextBox(nCode);
        }
 public void AddCode(CodeContent content, int index)
 {
     if (index > -1 && index < codeOutput.Items.Count)
     {
         CodeContent newCode = new CodeContent();
         foreach (CodeLine line in content.lines)
         {
             newCode.addLine(line.left, line.right);
         }
         codeOutput.Items[index].Tag = newCode;
     }
     SendModified();
 }
        public static string CodeContentToCodeTextBox(CodeContent codeData)
        {
            string output = string.Empty;

            for (int i = 0; i < codeData.lines.Count; i++)
            {
                if (!codeData.lines[i].enabled)
                {
                    output += "--";
                }
                output += string.Format("{0:X8} ", codeData.lines[i].left);
                output += string.Format("{0:X8}\r\n", codeData.lines[i].right);
            }
            return(output);
        }
        private void codeOutput_SelectedIndexChanged(object sender, EventArgs e)
        {
            int newIndex;

            if (codeOutput.SelectedIndices.Count == 0)
            {
                newIndex = -1;
            }
            else
            {
                newIndex = codeOutput.SelectedIndices[0];
            }

            if (newIndex == SelectedIndex)
            {
                return;
            }

            if (!UpdateCode())
            {
                codeOutput.Items[SelectedIndex].Selected = true;
                return;
            }

            codeValues.Clear();
            if (newIndex == -1 || newIndex >= codeOutput.Items.Count)
            {
                SelectedIndex      = -1;
                codeValues.Enabled = false;
            }
            else
            {
                SelectedIndex = newIndex;
                CodeContent codeData;
                if (codeOutput.Items[newIndex].Tag == null)
                {
                    codeData = new CodeContent();
                }
                else
                {
                    codeData = (CodeContent)codeOutput.Items[newIndex].Tag;
                }
                codeValues.Enabled = true;
                codeValues.Text    = CodeContentToCodeTextBox(codeData);
            }
        }
Exemplo n.º 8
0
        private void StandardCodeAddressStuff(uint address, uint value, uint add)
        {
            CodeContent nCode = CodeController.CodeTextBoxToCodeContent(textBoxCodeEntries.Text);
            uint        rAddressR;
            uint        offset;

            if (radioButtonBA.Checked)
            {
                rAddressR = address & 0xFE000000;
            }
            else
            {
                rAddressR = address & 0xFE000000;
                add      += 0x10000000;
            }

            bool changeBAorPO = false;

            if ((address & 0xFE000000) != 0x80000000)
            {
                changeBAorPO = true;
            }

            if (changeBAorPO)
            {
                if (radioButtonBA.Checked)
                {
                    nCode.addLine(0x42000000, rAddressR);
                }
                else
                {
                    nCode.addLine(0x4A000000, rAddressR);
                }
            }

            offset = address - rAddressR + add;
            nCode.addLine(offset, value);

            if (changeBAorPO)
            {
                nCode.addLine(0xE0000000, 0x80008000);
            }

            textBoxCodeEntries.Text = CodeController.CodeContentToCodeTextBox(nCode);
        }
        public bool UpdateCode(int index, string codeInput)
        {
            if (index == -1)
            {
                return(true);
            }

            CodeContent ncode = CodeTextBoxToCodeContent(codeInput);

            CodeContent oldContent = (CodeContent)codeOutput.Items[index].Tag;

            if (ncode.lines.Count != 0)
            {
                codeOutput.Items[index].Tag = ncode;
                SendModified();
            }

            return(true);
        }
Exemplo n.º 10
0
        public void GenerateCheatStream(Stream output)
        {
            if (output.CanWrite)
            {
                output.SetLength(0);
                output.Seek(0, SeekOrigin.Begin);
                output.Write(toStream(0x00D0C0DE), 0, 4);
                output.Write(toStream(0x00D0C0DE), 0, 4);

                CodeContent cCode;
                foreach (ListViewItem li in codeOutput.Items)
                {
                    if (li.Checked)
                    {
                        if (li.Tag == null)
                        {
                            cCode = new CodeContent();
                        }
                        else
                        {
                            cCode = (CodeContent)li.Tag;
                        }
                        foreach (CodeLine line in cCode.lines)
                        {
                            if (line.enabled)
                            {
                                output.Write(toStream(line.left), 0, 4);
                                output.Write(toStream(line.right), 0, 4);
                            }
                        }
                    }
                }

                //output.Write(toStream(0xF0000000), 0, 4);
                //output.Write(toStream(0x00000000), 0, 4);
                // Testing!  WiiRD uses all F's instead of F0
                output.Write(toStream(0xFFFFFFFF), 0, 4);
                output.Write(toStream(0xFFFFFFFF), 0, 4);
            }
        }
Exemplo n.º 11
0
        public void toWGCFile(string output)
        {
            StreamWriter textFile;

            textFile = new StreamWriter(output, false, Encoding.UTF8);
            string prepend;

            for (int i = 0; i < codeOutput.Items.Count; i++)
            {
                CodeContent cCode;
                if (codeOutput.Items[i].Tag == null)
                {
                    cCode = new CodeContent();
                }
                else
                {
                    cCode = (CodeContent)codeOutput.Items[i].Tag;
                }

                textFile.WriteLine("[" + codeOutput.Items[i].Text + "]");
                prepend = (codeOutput.Items[i].Checked ? "* " : "  ");
                foreach (CodeLine line in cCode.lines)
                {
                    if (line.enabled)
                    {
                        textFile.Write(prepend);
                    }
                    else
                    {
                        textFile.Write("- ");
                    }
                    textFile.Write(string.Format("{0:X8} ", line.left));
                    textFile.WriteLine(string.Format("{0:X8}", line.right));
                }
                textFile.WriteLine(string.Empty);
            }

            textFile.Close();
        }
Exemplo n.º 12
0
        public bool UpdateCode(int index, String codeInput)
        {
            // If there aren't any codes, index will be -1
            // so don't do anything
            if (index == -1)
            {
                return(true);
            }

            // Turn the text box into a code content
            CodeContent ncode = CodeTextBoxToCodeContent(codeInput);

            CodeContent oldContent = (CodeContent)codeOutput.Items[index].Tag;

            // No codes = must have been invalid!
            if (ncode.lines.Count != 0)
            {
                codeOutput.Items[index].Tag = ncode;
                SendModified();
            }

            return(true);
        }
Exemplo n.º 13
0
        private void makeCode_Click(object sender, EventArgs e)
        {
            if (SearchResults.SelectedRows.Count == 0)
                return;
            List<UInt32> addresses = new List<UInt32>();
            UInt32 address;
            int i;
            for (i = 0; i < SearchResults.SelectedRows.Count; i++)
            {
                address = search.GetAddress(SearchResults.SelectedRows[i].Index);
                addresses.Add(address);
            }

            addresses.Sort();

            CodeContent nCode = new CodeContent();
            UInt32 cAddressR = 0x80000000;
            UInt32 rAddressR;
            UInt32 offset;
            bool firstLine = false;
            UInt32 add;
            switch (search.searchSize)
            {
                case SearchSize.Bit8:
                    add = 0;
                    break;
                case SearchSize.Bit16:
                    add = 0x02000000;
                    break;
                default:
                    add = 0x04000000;
                    break;
            }

            int nCodeId = GCTCodeContents.Count;
            //nCode.name = "New code " + (nCodeId + 1).ToString();
            String name;
            if (!InputBox.Show("Code name", "Insert code name", "New code", out name))
            {
                name = "New code " + (nCodeId + 1).ToString();
            }
            for (i = 0; i < addresses.Count; i++)
            {
                rAddressR = addresses[i] & 0xFE000000;
                if (firstLine && cAddressR != rAddressR && cAddressR != 0x80000000)
                    nCode.addLine(0xE0000000, 0x80008000);
                if (cAddressR != rAddressR)
                    if (rAddressR != 0x80000000)
                        nCode.addLine(0x42000000, rAddressR);
                cAddressR = rAddressR;

                offset = addresses[i] + add - rAddressR;
                nCode.addLine(offset, search.GetNewValueFromAddress(addresses[i]));

                firstLine = true;
            }
            if (cAddressR != 0x80000000)
                nCode.addLine(0xE0000000, 0x80008000);
            GCTCodeContents.AddCode(nCode, name);

            GCTCodeList.Items[nCodeId].Selected = true;
            MainControl.SelectedTab = GCTPage;
        }
Exemplo n.º 14
0
 public void AddCode(String name)
 {
     CodeContent newCode = new CodeContent();
     //newCode.name = name;
     ListViewItem addCode = codeOutput.Items.Add(name);
     addCode.Tag = newCode;
     SendModified();
 }
Exemplo n.º 15
0
 public void AddCode(CodeContent content,String name)
 {
     ListViewItem addCode = codeOutput.Items.Add(name);
     addCode.Tag = content;
     SendModified();
 }
Exemplo n.º 16
0
        public void fromWGCFile(string input)
        {
            if (!File.Exists(input))
            {
                return;
            }

            StreamReader reader = new StreamReader(input, true);
            string       line, cName;
            CodeContent  nCode = null;
            ListViewItem nLI   = null;
            string       parsedCode;
            uint         left, right;
            bool         lEnabled = true;

            int  i;
            bool cCEnabled = false;

            codeOutput.ItemChecked -= codeOutput_ItemChecked;
            while (!reader.EndOfStream)
            {
                line = reader.ReadLine();
                if (line.Length == 0)
                {
                    continue;
                }

                if (line[0] == '[')
                {
                    cName = line.Substring(1, line.Length - 2);
                    if (nCode != null)
                    {
                        nLI.Checked = cCEnabled;
                    }
                    nCode     = new CodeContent();
                    nLI       = codeOutput.Items.Add(cName);
                    nLI.Tag   = nCode;
                    cCEnabled = false;
                    continue;
                }
                lEnabled = true;
                if (nCode == null)
                {
                    continue;
                }
                if (line[0] == '*')
                {
                    cCEnabled = true;
                }
                else if (line[0] == '-')
                {
                    lEnabled = false;
                }
                parsedCode = string.Empty;

                for (i = 0; i < line.Length; i++)
                {
                    char analyze = line.ToUpper()[i];

                    if (char.IsDigit(analyze) || ((analyze >= 'A') && (analyze <= 'F')))
                    {
                        parsedCode += analyze;
                    }
                }
                if (parsedCode.Length != 16)
                {
                    continue;
                }

                left  = Convert.ToUInt32(parsedCode.Substring(0, 8), 16);
                right = Convert.ToUInt32(parsedCode.Substring(8, 8), 16);
                nCode.addLine(left, right, lEnabled);
            }
            reader.Close();
            if (cCEnabled && nCode != null)
            {
                nLI.Checked = cCEnabled;
            }
            codeOutput.Update();
            codeOutput.ItemChecked += codeOutput_ItemChecked;
        }
Exemplo n.º 17
0
 //codeOutput.Items[i].Tag = value;
 // Adds a Code to the indexed code
 public void AddCode(CodeContent content, int index)
 {
     if (index > -1 && index < codeOutput.Items.Count)
     {
         //CodeContent oldCode = (CodeContent)(codeOutput.Items[index].Tag);
         CodeContent newCode = new CodeContent();
         //foreach (CodeLine line in oldCode.lines)
         //{
         //    newCode.addLine(line.left, line.right);
         //}
         foreach (CodeLine line in content.lines)
         {
             newCode.addLine(line.left, line.right);
         }
         codeOutput.Items[index].Tag = newCode;
     }
     SendModified();
 }
Exemplo n.º 18
0
        private void codeOutput_SelectedIndexChanged(object sender, EventArgs e)
        {
            int newIndex;
            if (codeOutput.SelectedIndices.Count == 0)
                newIndex = -1;
            else
                newIndex = codeOutput.SelectedIndices[0];

            if (newIndex == PSelectedIndex)
                return;

            if (!UpdateCode())
            {
                codeOutput.Items[PSelectedIndex].Selected = true;
                return;
            }

            codeValues.Clear();
            if (newIndex == -1 || newIndex >= codeOutput.Items.Count)
            {
                PSelectedIndex = -1;
                codeValues.Enabled = false;
            }
            else
            {
                PSelectedIndex = newIndex;
                CodeContent codeData;
                if (codeOutput.Items[newIndex].Tag == null)
                    codeData = new CodeContent();
                else
                    codeData = (CodeContent)codeOutput.Items[newIndex].Tag;
                codeValues.Enabled = true;
                //String output = "";
                //for (int i = 0; i < codeData.lines.Count; i++)
                //{
                //    if (!codeData.lines[i].enabled)
                //        output += "--";
                //    output += String.Format("{0:X8} ", codeData.lines[i].left);
                //    output += String.Format("{0:X8}\r\n", codeData.lines[i].right);
                //}
                codeValues.Text = CodeContentToCodeTextBox(codeData);
            }
        }
Exemplo n.º 19
0
        public void GenerateCheatStream(Stream output)
        {
            if (output.CanWrite)
            {
                output.SetLength(0);
                output.Seek(0, SeekOrigin.Begin);
                output.Write(toStream(0x00D0C0DE),0,4);
                output.Write(toStream(0x00D0C0DE),0,4);

                CodeContent cCode;
                foreach (ListViewItem li in codeOutput.Items)
                    if (li.Checked)
                    {
                        if (li.Tag == null)
                            cCode = new CodeContent();
                        else
                            cCode = (CodeContent)li.Tag;
                        foreach (CodeLine line in cCode.lines)
                        {
                            if (line.enabled)
                            {
                                output.Write(toStream(line.left), 0, 4);
                                output.Write(toStream(line.right), 0, 4);
                            }
                        }
                    }

                //output.Write(toStream(0xF0000000), 0, 4);
                //output.Write(toStream(0x00000000), 0, 4);
                // Testing!  WiiRD uses all F's instead of F0
                output.Write(toStream(0xFFFFFFFF), 0, 4);
                output.Write(toStream(0xFFFFFFFF), 0, 4);
            }
        }
Exemplo n.º 20
0
        public void toWGCFile(String output)
        {
            StreamWriter textFile;
            textFile = new StreamWriter(output, false, Encoding.UTF8);
            String prepend;

            for(int i = 0;i<codeOutput.Items.Count;i++)
            {
                CodeContent cCode;
                if (codeOutput.Items[i].Tag == null)
                    cCode = new CodeContent();
                else
                    cCode = (CodeContent)codeOutput.Items[i].Tag;

                textFile.WriteLine("[" + codeOutput.Items[i].Text + "]");
                prepend = (codeOutput.Items[i].Checked ? "* ":"  ");
                foreach(CodeLine line in cCode.lines) {
                    if (line.enabled)
                        textFile.Write(prepend);
                    else
                        textFile.Write("- ");
                    textFile.Write(String.Format("{0:X8} ",line.left));
                    textFile.WriteLine(String.Format("{0:X8}",line.right));
                }
                textFile.WriteLine("");
            }

            textFile.Close();
        }
Exemplo n.º 21
0
        public static CodeContent CodeTextBoxToCodeContent(String codeInput)
        {
            String parsedCode = "";
            String stripedUnknown = "";
            int i;

            // Check the text for a valid code
            for (i = 0; i < codeInput.Length; i++)
            {
                Char analyze = codeInput.ToUpper()[i];

                if (Char.IsDigit(analyze) || (analyze == '-' || analyze == '/') || ((analyze >= 'A') && (analyze <= 'F')))
                    stripedUnknown += analyze;
            }

            // Deactivating codes?
            int deactSigns = 0;
            List<int> deactCodes = new List<int>();
            for (i = 0; i < stripedUnknown.Length; i++)
            {
                Char analyze = stripedUnknown[i];

                if (analyze == '-' || analyze == '/')
                {
                    int pos = (i - deactSigns) / 16;
                    if (!deactCodes.Contains(pos))
                        deactCodes.Add(pos);
                    deactSigns++;
                }
                else
                    parsedCode += analyze;
            }

             CodeContent ncode = new CodeContent();

            // Make sure it's the right size too
            if (parsedCode.Length % 16 != 0)
            {
                MessageBox.Show("Adding 0s to fill up the code");
                int loopCount = 16 - parsedCode.Length % 16;
                for (int j = 0; j < loopCount; j++) parsedCode += "0";
            }

            String hexString;
            UInt32 left, right;
            bool enabled;

            for (i = 0; i < parsedCode.Length / 16; i++)
            {
                hexString = parsedCode.Substring(i * 16, 8);
                left = Convert.ToUInt32(hexString, 16);

                hexString = parsedCode.Substring(i * 16 + 8, 8);
                right = Convert.ToUInt32(hexString, 16);

                enabled = !deactCodes.Contains(i);

                ncode.addLine(left, right, enabled);
            }

            return ncode;
        }
Exemplo n.º 22
0
        private void existingGCTCodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // If there is no selected existing code, make a new one
            if (GCTCodeList.SelectedItems.Count == 0)
            {
                makeCode_Click(sender, e);
                return;
            }

            if (SearchResults.SelectedRows.Count == 0)
                return;
            List<UInt32> addresses = new List<UInt32>();
            UInt32 address;
            int i;
            for (i = 0; i < SearchResults.SelectedRows.Count; i++)
            {
                address = search.GetAddress(SearchResults.SelectedRows[i].Index);
                addresses.Add(address);
            }

            addresses.Sort();

            CodeContent nCode = new CodeContent();
            UInt32 cAddressR = 0x80000000;
            UInt32 rAddressR;
            UInt32 offset;
            bool firstLine = false;
            UInt32 add;
            switch (search.searchSize)
            {
                case SearchSize.Bit8:
                    add = 0;
                    break;
                case SearchSize.Bit16:
                    add = 0x02000000;
                    break;
                default:
                    add = 0x04000000;
                    break;
            }

            for (i = 0; i < addresses.Count; i++)
            {
                rAddressR = addresses[i] & 0xFE000000;
                if (firstLine && cAddressR != rAddressR && cAddressR != 0x80000000)
                    nCode.addLine(0xE0000000, 0x80008000);
                if (cAddressR != rAddressR)
                    if (rAddressR != 0x80000000)
                        nCode.addLine(0x42000000, rAddressR);
                cAddressR = rAddressR;

                offset = addresses[i] + add - rAddressR;
                nCode.addLine(offset, 0);

                firstLine = true;
            }
            if (cAddressR != 0x80000000)
                nCode.addLine(0xE0000000, 0x80008000);

            // Must de-select current item before changing it
            int index = GCTCodeList.SelectedItems[0].Index;

            GCTCodeList.Items[index].Selected = false;

            GCTCodeContents.AddCode(nCode, index);

            GCTCodeList.Items[index].Selected = true;

            MainControl.SelectedTab = GCTPage;
        }
Exemplo n.º 23
0
        public static CodeContent CodeTextBoxToCodeContent(string codeInput)
        {
            string parsedCode     = string.Empty;
            string stripedUnknown = string.Empty;
            int    i;

            for (i = 0; i < codeInput.Length; i++)
            {
                char analyze = codeInput.ToUpper()[i];

                if (char.IsDigit(analyze) || (analyze == '-' || analyze == '/') || ((analyze >= 'A') && (analyze <= 'F')))
                {
                    stripedUnknown += analyze;
                }
            }

            int        deactSigns = 0;
            List <int> deactCodes = new List <int>();

            for (i = 0; i < stripedUnknown.Length; i++)
            {
                char analyze = stripedUnknown[i];

                if (analyze == '-' || analyze == '/')
                {
                    int pos = (i - deactSigns) / 16;
                    if (!deactCodes.Contains(pos))
                    {
                        deactCodes.Add(pos);
                    }
                    deactSigns++;
                }
                else
                {
                    parsedCode += analyze;
                }
            }

            CodeContent ncode = new CodeContent();

            if (parsedCode.Length % 16 != 0)
            {
                MessageBox.Show("Adding 0s to fill up the code");
                int loopCount = 16 - parsedCode.Length % 16;
                for (int j = 0; j < loopCount; j++)
                {
                    parsedCode += "0";
                }
            }

            string hexString;
            uint   left, right;
            bool   enabled;

            for (i = 0; i < parsedCode.Length / 16; i++)
            {
                hexString = parsedCode.Substring(i * 16, 8);
                left      = Convert.ToUInt32(hexString, 16);

                hexString = parsedCode.Substring(i * 16 + 8, 8);
                right     = Convert.ToUInt32(hexString, 16);

                enabled = !deactCodes.Contains(i);

                ncode.addLine(left, right, enabled);
            }

            return(ncode);
        }
Exemplo n.º 24
0
        private void memViewAddGCTCode_Click(object sender, EventArgs e)
        {
            try
            {
                UInt32 vAdd = viewer.selectedAddress;
                UInt32 cRegion = vAdd & 0xFE000000;
                UInt32 value = gecko.peek(vAdd);
                vAdd = vAdd - cRegion + 0x04000000;
                int nCodeId = GCTCodeContents.Count;

                String name;
                if (!InputBox.Show("Code name", "Insert code name", "New code", out name))
                {
                    name = "New code " + (nCodeId + 1).ToString();
                }
                CodeContent nCode = new CodeContent();
                bool addlines = false;
                if (cRegion != 0x80000000)
                {
                    addlines = true;
                    nCode.addLine(0x42000000, cRegion);
                }
                nCode.addLine(vAdd, value);
                if (addlines)
                    nCode.addLine(0xE0000000, 0x80008000);

                GCTCodeContents.AddCode(nCode, name);
                MainControl.SelectedTab = GCTPage;
            }
            catch (EUSBGeckoException exc)
            {
                exceptionHandling.HandleException(exc);
            }
        }
Exemplo n.º 25
0
        private void disAssGCTCode_Click(object sender, EventArgs e)
        {
            try
            {
                UInt32 address = disassembler.disAddress;
                UInt32 value = gecko.peek(address);
                CodeContent nCode = new CodeContent();
                UInt32 memReg = address & 0xFE000000;
                bool addDelimiters = false;
                if (memReg != 0x80000000)
                    addDelimiters = true;
                if (addDelimiters)
                    nCode.addLine(0x42000000, memReg);
                address = address - memReg + 0x04000000;
                nCode.addLine(address, value);
                if (addDelimiters)
                    nCode.addLine(0xE0000000, 0x80008000);
                int nCodeId = GCTCodeContents.Count;
                String name;
                if (!InputBox.Show("Code name", "Insert code name", "New code", out name))
                {
                    name = "New code " + (nCodeId + 1).ToString();
                }
                //nCode.name = "New code " + (nCodeId + 1).ToString();
                GCTCodeContents.AddCode(nCode, name);

                GCTCodeList.Items[nCodeId].Selected = true;
                MainControl.SelectedTab = GCTPage;
            }
            catch (EUSBGeckoException exc)
            {
                exceptionHandling.HandleException(exc);
            }
        }
Exemplo n.º 26
0
        public void fromWGCFile(String input)
        {
            if (!File.Exists(input))
                return;

            //codes.Clear();
            //codeOutput.Clear();
            //codeValues.Enabled = false;

            StreamReader reader = new StreamReader(input,true);
            String line, cName;
            CodeContent nCode = null;
            ListViewItem nLI = null;
            String parsedCode;
            UInt32 left, right;
            bool lEnabled = true;

            int i;
            bool cCEnabled = false;

            codeOutput.ItemChecked -= codeOutput_ItemChecked;
            while (!reader.EndOfStream)
            {
                line = reader.ReadLine();
                if (line.Length == 0)
                    continue;

                if (line[0] == '[')
                {
                    cName = line.Substring(1, line.Length - 2);
                    if (nCode != null)
                    {
                        nLI.Checked = cCEnabled;
                    }
                    nCode = new CodeContent();
                    //nCode.name = cName;
                    nLI = codeOutput.Items.Add(cName);
                    nLI.Tag = nCode;
                    cCEnabled = false;
                    continue;
                }
                lEnabled = true;
                if (nCode == null)
                    continue;
                if (line[0] == '*')
                    cCEnabled = true;
                else if (line[0] == '-')
                    lEnabled = false;
                parsedCode = "";

                for (i = 0; i < line.Length; i++)
                {
                    Char analyze = line.ToUpper()[i];

                    if (Char.IsDigit(analyze) || ((analyze >= 'A') && (analyze <= 'F')))
                        parsedCode += analyze;
                }
                if (parsedCode.Length != 16)
                    continue;

                left = Convert.ToUInt32(parsedCode.Substring(0, 8), 16);
                right = Convert.ToUInt32(parsedCode.Substring(8, 8), 16);
                nCode.addLine(left, right, lEnabled);
            }
            reader.Close();
            if (cCEnabled && nCode != null)
            {
                nLI.Checked = cCEnabled;
            }
            codeOutput.Update();
            codeOutput.ItemChecked += codeOutput_ItemChecked;
        }
Exemplo n.º 27
0
        private void enableToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CodeContent code = GCTCodeContents[GCTCodeList.SelectedIndices[0]];
            CodeContent uncommentedCode = new CodeContent();
            for (int i = 0; i < code.lines.Count; i++)
            {
                uncommentedCode.addLine(code.lines[i].left, code.lines[i].right, true);
            }

            GCTCodeValues.Text = CodeController.CodeContentToCodeTextBox(uncommentedCode);
        }
Exemplo n.º 28
0
 public static String CodeContentToCodeTextBox(CodeContent codeData)
 {
     String output = "";
     for (int i = 0; i < codeData.lines.Count; i++)
     {
         if (!codeData.lines[i].enabled)
             output += "--";
         output += String.Format("{0:X8} ", codeData.lines[i].left);
         output += String.Format("{0:X8}\r\n", codeData.lines[i].right);
     }
     return output;
 }