예제 #1
0
        static void Main(string[] args)
        {
            FileStream fs = new FileStream("zelda.sfc", FileMode.Open, FileAccess.Read);

            byte[] rom_data = new byte[fs.Length];
            fs.Read(rom_data, 0, (int)fs.Length);
            fs.Close();

            Array.Resize(ref rom_data, 4 * 1024 * 1024);

            RomData rom = new RomData(rom_data);

            Patch patch = new Patch("patchData.json");

            patch.PatchRom(rom);

            GeneralPatches.MoveRoomHeaders(rom);

            var patches = rom.GeneratePatch();

            patch.AddPatches(patches);

            var patchJson = patch.ExportJson();

            File.WriteAllText("enemizerBasePatch.json", patchJson);
        }
예제 #2
0
        static List <PatchObject> GenerateSeed(int seed, byte[] rom_data, OptionFlags optionFlags)
        {
            RomData       romData       = new RomData(rom_data);
            Randomization randomize     = new Randomization();
            RomData       randomizedRom = randomize.MakeRandomization("", seed, optionFlags, romData, "");

            return(randomizedRom.GeneratePatch());
        }
예제 #3
0
        string GenerateSeed(int seed, byte[] rom_data, string linkSpriteFilename, string inputFilename, string outputPath)
        {
#if !DEBUG
            try // make sure we don't crash in release build
            {
#endif

            RomData romData         = new RomData(rom_data);
            Randomization randomize = new Randomization();
            RomData randomizedRom   = randomize.MakeRandomization("", seed, config.OptionFlags, romData, linkSpriteFilename);

            string fileNameNoExtension = Path.Combine(outputPath, $"Enemizer {EnemizerLibrary.Version.CurrentVersion} - {Path.GetFileNameWithoutExtension(inputFilename)} (EN{randomizedRom.EnemizerSeed})");

            if (config.OptionFlags.GenerateSpoilers)
            {
                File.WriteAllText($"{fileNameNoExtension}.txt", randomizedRom.Spoiler.ToString());
            }

#if DEBUG
            // build a patch for testing
            var romPatch = randomizedRom.GeneratePatch();
            string patch = JsonConvert.SerializeObject(romPatch);
            File.WriteAllText($"{fileNameNoExtension}.patch", patch);
#endif

            Randomization.SetSwordGfx(randomizedRom, config.OptionFlags.SwordGraphics);
            Randomization.SetShieldGfx(randomizedRom, config.OptionFlags.ShieldGraphics);
            if (config.OptionFlags.RandomizeSpriteOnHit)
            {
                Randomization.BuildRandomLinkSpriteTable(randomizedRom, seed, config.OptionFlags);
            }

            string fileName = $"{fileNameNoExtension}.sfc";
            var fs          = new FileStream(fileName, FileMode.Create, FileAccess.Write);
            randomizedRom.WriteRom(fs);
            fs.Close();


            return(fileName);

#if !DEBUG
        }

        catch (Exception ex)
        {
            logger.Error(ex);
            MessageBox.Show($"{ex.Message}\r\n{ex.StackTrace}", "Enemizer");
        }

        return("Failed");
#endif
        }
예제 #4
0
        private static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Usage: BasePatchGenerator.exe [rom file] [patch data] [output file]");
                return;
            }

            Console.WriteLine($"Reading rom file {args[0]}");
            FileStream fs       = new FileStream(args[0], FileMode.Open, FileAccess.Read);
            var        rom_data = new byte[fs.Length];

            fs.Read(rom_data, 0, (int)fs.Length);
            fs.Close();

            if (rom_data.Length % 1024 == 512)
            {
                Console.WriteLine("Stripping rom header");
                rom_data = rom_data.Skip(512).ToArray();
            }

            using (MD5 md5 = MD5.Create())
            {
                Console.WriteLine("Verifying rom");
                byte[] hash = md5.ComputeHash(rom_data);
                if (!hash.SequenceEqual(new byte[] { 0x03, 0xa6, 0x39, 0x45, 0x39, 0x81, 0x91, 0x33, 0x7e, 0x89, 0x6e, 0x57, 0x71, 0xf7, 0x71, 0x73 }))
                {
                    throw new Exception("Invalid rom file");
                }
            }

            Console.WriteLine("Applying Patch to rom");
            Array.Resize(ref rom_data, 4 * 1024 * 1024);

            RomData rom = new RomData(rom_data);

            Patch patch = new Patch(args[1]);

            patch.PatchRom(rom);

            GeneralPatches.MoveRoomHeaders(rom);

            List <PatchObject> patches = rom.GeneratePatch();

            patch.AddPatches(patches);

            var patchJson = patch.ExportJson();

            Console.WriteLine($"Writing output file {args[2]}");
            File.WriteAllText(args[2], patchJson);
        }
예제 #5
0
파일: Program.cs 프로젝트: Ijwu/Enemizer
        static List <PatchObject> GenerateSeed(int seed, byte[] rom_data, OptionFlags optionFlags)
        {
            RomData randomizedRom = RandomizeRom(seed, rom_data, optionFlags);

            return(randomizedRom.GeneratePatch());
        }