public void ListOffsets(string structname, Options opt)
        {
            RomEditor romeditor = new RomEditor(opt.ArgRomFile, opt.ArgXmlFile);

            List <string> list = romeditor.GetOffsetList(structname);

            Console.WriteLine("Offsets in: {0}", structname);
            Console.WriteLine();
            foreach (string str in list)
            {
                Console.WriteLine(str);
            }
        }
        public void ListStruct(Options opt)
        {
            RomEditor romeditor = new RomEditor(opt.ArgRomFile, opt.ArgXmlFile);

            List <string> list = romeditor.GetStructList();

            Console.WriteLine("Structures: ");
            Console.WriteLine();

            foreach (string str in list)
            {
                Console.WriteLine(str);
            }
        }
        static int Main(string[] args)
        {
            Options        opt  = new Options();
            Parser         p    = new Parser();
            gen3dataeditor main = new gen3dataeditor();



            if (!p.ParseArguments(args, opt))
            {
                Console.WriteLine(opt.GetUsage());
                return(0);
            }


            if (!File.Exists(opt.ArgRomFile))
            {
                Console.WriteLine("Invalid GBA ROM path.");
                return(0);
            }

            if (!File.Exists(opt.ArgXmlFile))
            {
                Console.WriteLine("Invalid data XML path.");
                return(0);
            }

            if (opt.ArgListStruct)
            {
                main.ListStruct(opt);
                return(0);
            }

            if (!string.IsNullOrWhiteSpace(opt.ArgListOffsets))
            {
                main.ListOffsets(opt.ArgListOffsets, opt);
                return(0);
            }

            string    game      = "";
            RomEditor gamecoder = new RomEditor(opt.ArgRomFile, opt.ArgXmlFile);



            game = gamecoder.GetGameName();



            gamecoder = null;

            if (string.IsNullOrEmpty(game))
            {
                Console.WriteLine("Game not supported!");

                return(0);
            }
            Console.WriteLine("Game: {0}", game);



            gamecoder = null;


            if (opt.ArgGetValueString)
            {
                RomEditor romeditor = new RomEditor(opt.ArgRomFile, opt.ArgXmlFile);
                string    line      = romeditor.ConvertByteArrayToString(romeditor.GetValueByteArray(opt.ArgStruct, opt.ArgName, opt.ArgIndex));
                Console.WriteLine("Struct: {0}, Offset: {1}, Index: {2}", opt.ArgStruct, opt.ArgName, opt.ArgIndex);
                Console.Write("Value: ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(line);
                Console.ResetColor();
                romeditor = null;
                return(0);
            }
            else if (opt.ArgGetValueInt)
            {
                RomEditor romeditor = new RomEditor(opt.ArgRomFile, opt.ArgXmlFile);

                Int32 write32   = 0;
                Int16 write16   = 0;
                byte  writebyte = 0;

                if (!romeditor.ConvertByteArrayToInt32(romeditor.GetValueByteArray(opt.ArgStruct, opt.ArgName, opt.ArgIndex), out write32))
                {
                }
                else
                {
                    Console.WriteLine("Struct: {0}, Offset: {1}, Index: {2}", opt.ArgStruct, opt.ArgName, opt.ArgIndex);
                    if (opt.ArgPrintHex)
                    {
                        Console.Write("Value: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("0x{0:X}", write32);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write("Value: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("{0}", write32);
                        Console.ResetColor();
                    }

                    romeditor = null;
                    return(0);
                }
                if (!romeditor.ConvertByteArrayToInt16(romeditor.GetValueByteArray(opt.ArgStruct, opt.ArgName, opt.ArgIndex), out write16))
                {
                }
                else
                {
                    Console.WriteLine("Struct: {0}, Offset: {1}, Index: {2}", opt.ArgStruct, opt.ArgName, opt.ArgIndex);
                    if (opt.ArgPrintHex)
                    {
                        Console.Write("Value: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("0x{0:X}", write16);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write("Value: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("{0}", write16);
                        Console.ResetColor();
                    }
                    romeditor = null;
                    return(0);
                }
                if (!romeditor.ConvertByteArrayToByte(romeditor.GetValueByteArray(opt.ArgStruct, opt.ArgName, opt.ArgIndex), out writebyte))
                {
                    Console.WriteLine("Failed!");
                }
                else
                {
                    Console.WriteLine("Struct: {0}, Offset: {1}, Index: {2}", opt.ArgStruct, opt.ArgName, opt.ArgIndex);
                    if (opt.ArgPrintHex)
                    {
                        Console.Write("Value: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("0x{0:X}", writebyte);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write("Value: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("{0}", writebyte);
                        Console.ResetColor();
                    }
                    romeditor = null;
                    return(0);
                }
            }

            else if (!string.IsNullOrWhiteSpace(opt.ArgSetValueString))
            {
                RomEditor romeditor = new RomEditor(opt.ArgRomFile, opt.ArgXmlFile);

                Console.WriteLine("Struct: {0}, Offset: {1}, Index: {2}", opt.ArgStruct, opt.ArgName, opt.ArgIndex);

                Console.Write("Value before: ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("{0}", romeditor.ConvertByteArrayToString(romeditor.GetValueByteArray(opt.ArgStruct, opt.ArgName, opt.ArgIndex)));
                Console.ResetColor();

                romeditor.SetValueByteArray(opt.ArgStruct, opt.ArgName, opt.ArgIndex, romeditor.ConvertStringToByteArray(opt.ArgSetValueString), true);

                Console.Write("Value after: ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("{0}", romeditor.ConvertByteArrayToString(romeditor.GetValueByteArray(opt.ArgStruct, opt.ArgName, opt.ArgIndex)));
                Console.ResetColor();

                romeditor = null;
                return(0);
            }
            else if (opt.ArgSetValueInt > 0)
            {
                RomEditor romeditor = new RomEditor(opt.ArgRomFile, opt.ArgXmlFile);

                Int16 write16   = 0;
                Int32 write32   = 0;
                byte  writebyte = 0;

                byte[] array = romeditor.GetValueByteArray(opt.ArgStruct, opt.ArgName, opt.ArgIndex);

                Console.WriteLine("Struct: {0}, Offset: {1}, Index: {2}", opt.ArgStruct, opt.ArgName, opt.ArgIndex);
                if (!romeditor.ConvertByteArrayToInt32(array, out write32))
                {
                }
                else
                {
                    if (opt.ArgPrintHex)
                    {
                        Console.Write("Value before: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("0x{0:X}", write32);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write("Value before: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("{0}", write32);
                        Console.ResetColor();
                    }
                }
                if (!romeditor.ConvertByteArrayToInt16(array, out write16))
                {
                }
                else
                {
                    if (opt.ArgPrintHex)
                    {
                        Console.Write("Value: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("0x{0:X}", write16);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write("Value before: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("{0}", write16);
                        Console.ResetColor();
                    }
                }
                if (!romeditor.ConvertByteArrayToByte(array, out writebyte))
                {
                }
                else
                {
                    if (opt.ArgPrintHex)
                    {
                        Console.Write("Value before: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("0x{0:X}", writebyte);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write("Value before: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("{0}", writebyte);
                        Console.ResetColor();
                    }
                }

                romeditor.SetValueByteArray(opt.ArgStruct, opt.ArgName, opt.ArgIndex, romeditor.ConvertIntToByteArray(opt.ArgSetValueInt), false);

                array = romeditor.GetValueByteArray(opt.ArgStruct, opt.ArgName, opt.ArgIndex);
                Int16 afterwrite16   = 0;
                Int32 afterwrite32   = 0;
                byte  afterwritebyte = 0;

                if (!romeditor.ConvertByteArrayToInt32(array, out afterwrite32))
                {
                }
                else
                {
                    if (opt.ArgPrintHex)
                    {
                        Console.Write("Value after: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("0x{0:X}", afterwrite32);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write("Value after: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("{0}", afterwrite32);
                        Console.ResetColor();
                    }
                }
                if (!romeditor.ConvertByteArrayToInt16(array, out afterwrite16))
                {
                }
                else
                {
                    if (opt.ArgPrintHex)
                    {
                        Console.Write("Value after: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("0x{0:X}", afterwrite16);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write("Value after: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("{0}", afterwrite16);
                        Console.ResetColor();
                    }
                }
                if (!romeditor.ConvertByteArrayToByte(array, out afterwritebyte))
                {
                }
                else
                {
                    if (opt.ArgPrintHex)
                    {
                        Console.Write("Value after: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("0x{0:X}", afterwritebyte);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write("Value after: ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("{0}", afterwritebyte);
                        Console.ResetColor();
                    }
                }



                return(0);
            }



            Console.WriteLine("Nothing done!");
            return(0);
        }