Ejemplo n.º 1
0
        public void MakeROM(string InFile, string FileName, BackgroundWorker worker)
        {
            using (BinaryReader OldROM = new BinaryReader(File.Open(InFile, FileMode.Open, FileAccess.Read)))
            {
                RomUtils.ReadFileTable(OldROM);
                _messageTable.InitializeTable();
            }

            List <MMFile> originalMMFileList = null;

            if (_settings.GeneratePatch)
            {
                originalMMFileList = RomData.MMFileList.Select(file => file.Clone()).ToList();
            }

            if (!string.IsNullOrWhiteSpace(_settings.InputPatchFilename))
            {
                worker.ReportProgress(50, "Applying patch...");
                RomUtils.ApplyPatch(_settings.InputPatchFilename);
            }
            else
            {
                // todo music randomizer doesn't work if this is called after WriteItems(); because the reloc-audio hack is hardcoded
                worker.ReportProgress(50, "Writing audio...");
                WriteAudioSeq();

                worker.ReportProgress(55, "Writing player model...");
                WritePlayerModel();

                if (_settings.LogicMode != LogicMode.Vanilla)
                {
                    worker.ReportProgress(60, "Applying hacks...");
                    ResourceUtils.ApplyHack(Values.ModsDirectory + "title-screen");
                    ResourceUtils.ApplyHack(Values.ModsDirectory + "misc-changes");
                    ResourceUtils.ApplyHack(Values.ModsDirectory + "cm-cs");
                    ResourceUtils.ApplyHack(Values.ModsDirectory + "fix-song-of-healing");
                    WriteFileSelect();
                }
                ResourceUtils.ApplyHack(Values.ModsDirectory + "init-file");
                ResourceUtils.ApplyHack(Values.ModsDirectory + "fierce-deity-anywhere");

                worker.ReportProgress(61, "Writing quick text...");
                WriteQuickText();

                worker.ReportProgress(62, "Writing cutscenes...");
                WriteCutscenes();

                worker.ReportProgress(63, "Writing dungeons...");
                WriteDungeons();

                worker.ReportProgress(64, "Writing gimmicks...");
                WriteGimmicks();

                worker.ReportProgress(65, "Writing enemies...");
                WriteEnemies();

                worker.ReportProgress(66, "Writing items...");
                WriteItems();

                worker.ReportProgress(67, "Writing messages...");
                WriteGossipQuotes();
                MessageTable.WriteMessageTable(_messageTable);

                worker.ReportProgress(68, "Writing startup...");
                WriteStartupStrings();

                if (_settings.GeneratePatch)
                {
                    worker.ReportProgress(70, "Generating patch...");
                    RomUtils.CreatePatch(FileName, originalMMFileList);
                }
            }

            worker.ReportProgress(72, "Writing Tatl color...");
            WriteTatlColour();

            worker.ReportProgress(73, "Writing tunic color...");
            WriteTunicColor();

            if (_settings.GenerateROM)
            {
                worker.ReportProgress(75, "Building ROM...");

                byte[] ROM = RomUtils.BuildROM(FileName);
                if (_settings.OutputVC)
                {
                    worker.ReportProgress(90, "Building VC...");
                    VCInjectionUtils.BuildVC(ROM, Values.VCDirectory, Path.ChangeExtension(FileName, "wad"));
                }
            }
            worker.ReportProgress(100, "Done!");
        }
Ejemplo n.º 2
0
        public void MakeROM(string InFile, string FileName, BackgroundWorker worker)
        {
            using (BinaryReader OldROM = new BinaryReader(File.Open(InFile, FileMode.Open, FileAccess.Read)))
            {
                RomUtils.ReadFileTable(OldROM);
                _messageTable.InitializeTable();
            }

            var originalMMFileList = RomData.MMFileList.Select(file => file.Clone()).ToList();

            byte[] hash;
            if (!string.IsNullOrWhiteSpace(_settings.InputPatchFilename))
            {
                worker.ReportProgress(50, "Applying patch...");
                hash = RomUtils.ApplyPatch(_settings.InputPatchFilename);

                // Apply Asm configuration post-patch
                WriteAsmConfigPostPatch();
            }
            else
            {
                worker.ReportProgress(55, "Writing player model...");
                WritePlayerModel();

                if (_settings.LogicMode != LogicMode.Vanilla)
                {
                    worker.ReportProgress(60, "Applying hacks...");
                    ResourceUtils.ApplyHack(Values.ModsDirectory + "title-screen");
                    ResourceUtils.ApplyHack(Values.ModsDirectory + "misc-changes");
                    ResourceUtils.ApplyHack(Values.ModsDirectory + "cm-cs");
                    ResourceUtils.ApplyHack(Values.ModsDirectory + "fix-song-of-healing");
                    WriteFileSelect();
                }
                ResourceUtils.ApplyHack(Values.ModsDirectory + "init-file");
                ResourceUtils.ApplyHack(Values.ModsDirectory + "fierce-deity-anywhere");

                worker.ReportProgress(61, "Writing quick text...");
                WriteQuickText();

                worker.ReportProgress(62, "Writing cutscenes...");
                WriteCutscenes();

                worker.ReportProgress(63, "Writing dungeons...");
                WriteDungeons();

                worker.ReportProgress(64, "Writing gimmicks...");
                WriteGimmicks();

                worker.ReportProgress(65, "Writing speedups...");
                WriteSpeedUps();

                worker.ReportProgress(66, "Writing enemies...");
                WriteEnemies();

                // if shop should match given items
                {
                    WriteShopObjects();
                }

                worker.ReportProgress(67, "Writing items...");
                WriteItems();

                worker.ReportProgress(68, "Writing messages...");
                WriteGossipQuotes();

                MessageTable.WriteMessageTable(_messageTable, _settings.QuickTextEnabled);

                worker.ReportProgress(69, "Writing startup...");
                WriteStartupStrings();

                worker.ReportProgress(70, "Writing ASM patch...");
                WriteAsmPatch();

                worker.ReportProgress(71, _settings.GeneratePatch ? "Generating patch..." : "Computing hash...");
                hash = RomUtils.CreatePatch(_settings.GeneratePatch ? FileName : null, originalMMFileList);
            }

            worker.ReportProgress(72, "Writing cosmetics...");
            WriteTatlColour();
            WriteTunicColor();

            worker.ReportProgress(73, "Writing music...");
            WriteAudioSeq(new Random(BitConverter.ToInt32(hash, 0)));
            WriteMuteMusic();

            worker.ReportProgress(74, "Writing sound effects...");
            WriteSoundEffects(new Random(BitConverter.ToInt32(hash, 0)));

            if (_settings.GenerateROM)
            {
                worker.ReportProgress(75, "Building ROM...");

                byte[] ROM = RomUtils.BuildROM(FileName);
                if (_settings.OutputVC)
                {
                    worker.ReportProgress(90, "Building VC...");
                    VCInjectionUtils.BuildVC(ROM, _settings.PatcherOptions, Values.VCDirectory, Path.ChangeExtension(FileName, "wad"));
                }
            }
            worker.ReportProgress(100, "Done!");
        }