예제 #1
0
        /// <summary>
        /// Parsing method for map input
        /// </summary>
        /// <param name="opts"></param>
        /// <returns></returns>
        public static int ParseMap(Options opts)
        {
            String        outPath          = opts.OutputPath;
            List <string> inputFiles       = opts.InputFiles;
            MapHeader     mapHeaderBuilder = new MapHeader();

            try {
                //Append all maps into this single StringBuilder's String
                StringBuilder b = new StringBuilder();
                foreach (String inputFile in inputFiles)
                {
                    MapHeader mapHeader;
                    // First try to import
                    try {
                        mapHeader = mapHeaderBuilder.ImportFromFile(inputFile);
                    }
                    catch (IOException ioex)
                    {
                        Console.Error.WriteLine("IOError for file '" + inputFile + "'");
                        throw ioex;
                    }catch (Exception ex)
                    {
                        Console.Error.WriteLine("Error at parsing map input file '" + inputFile + "'");
                        throw ex;
                    }

                    try
                    {
                        // Try to convert
                        String baseSymbol = opts.baseSymbol;
                        if (baseSymbol == null)
                        {
                            baseSymbol = Path.GetFileNameWithoutExtension(inputFile);
                        }

                        b.Append(MapCompiler.MapToString(mapHeader, baseSymbol));
                    }
                    catch (Exception ex)
                    {
                        Console.Error.WriteLine("Error at converting map '" + inputFile + "':");
                        throw ex;
                    }
                }
                try
                {
                    // Export all files
                    File.WriteAllText(outPath, b.ToString());
                }catch (Exception ex)
                {
                    Console.Error.WriteLine("Error at exporting file '" + outPath + "':");
                    throw ex;
                }
                return(0);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                return(1);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            BinaryReader reader = new BinaryReader(new FileStream(@"D:\onedrive\Hacking\Romhacking\Ressources\Feuerrot\Pokemon Feuerrot (D).gba", FileMode.Open, FileAccess.Read));
            MapHeader    header = AgbImport.HeaderFromStream(reader, 0x3525CC, 3, 0);

            header.ExportToFile(header, "test.header");
            MapHeader importedHeader = header.ImportFromFile("test.header");
        }