Beispiel #1
0
        private void GenerateButton_Click(object sender, EventArgs e)
        {
            Status.StopVisualFeedback();
            if (Status.CanGenerate())
            {
                Util.UpdateSettings();

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                //try
                {
                    // create directory if it doesn't exist
                    Directory.CreateDirectory(Util.OutputDir);

                    rom = new NDS.ROM();
                    if (rom.IsValid())
                    {
                        rom.Init();

                        //MemorySection[] binaries = rom.GetBinarySections();
                        MemorySection[] arm9     = rom.GetARM9BinarySection();
                        MemorySection[] arm7     = rom.GetARM7BinarySection();
                        MemorySection[] overlays = rom.GetOverlaySections();

                        maker.CreateXmlDocument();

                        // maker.CreateStandardMemorySections(binaries);

                        maker.CreateStandardMemorySections(arm9);
                        // arm7 likes to overwrite other things so
                        // I'll just make it an overlay
                        maker.CreateARM7MemorySections(arm7);
                        maker.CreateOverlayMemorySections(overlays);
                        maker.FillMemoryGaps();
                        maker.CreateSectionManual("shared_wram", 0x3000000, 0x1000000);

                        maker.CreateSectionManual("io_ports", 0x4000000, 0x1000000);
                        maker.CreateSectionManual("palette", 0x5000000, 0x1000000);
                        maker.CreateSectionManual("vram", 0x6000000, 0x1000000);
                        maker.CreateSectionManual("oam", 0x7000000, 0x1000000);

                        maker.DefineCommonDatatypes();
                        maker.DefineCommonData();
                        maker.DefineCommonSymbols();
                        maker.DefineCommonFunctions();
                        maker.DefineFunctionsFromFile(Util.SymbolsPath);

                        maker.Save();
                        rom.Close();

                        stopwatch.Stop();
                        long elapsedTime = stopwatch.ElapsedMilliseconds;
                        Status.SetStatusText(string.Format("Done! [{0:d} ms]", elapsedTime));
                    }
                    else
                    {
                        Status.SetStatusText("Invalid ROM! (bad nintendo logo)");
                        Status.StartVisualFeedback();
                    }
                }
                //catch (Exception ex)
                //{
                //	Status.SetStatusText(ex.Message);
                //	Status.StartVisualFeedback();
                //}
            }
            else
            {
                Status.StartVisualFeedback();
            }
        }