public void WriteSeedAndFlags(string version, string seed, string flags)
        {
            // Replace most of the old copyright string printing with a JSR to a LongJump
            Put(0x38486, Blob.FromHex("20FCFE60"));

            // DrawSeedAndFlags LongJump
            PutInBank(0x1F, 0xFEFC, CreateLongJumpTableEntry(0x0F, 0x8980));

            var  sha = File.Exists("version.txt") ? File.ReadAllText("version.txt").Trim() : "development";
            Blob hash;
            var  hasher = SHA256.Create();

            hash = hasher.ComputeHash(Encoding.ASCII.GetBytes($"{seed}_{flags}_{sha}"));

            var hashpart = BitConverter.ToUInt64(hash, 0);

            hash = Blob.FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
            for (int i = 8; i < 24; i += 2)
            {
                // 0xD4 through 0xDF are good symbols to use.
                hash[i]   = (byte)(0xD4 + hashpart % 12);
                hashpart /= 12;
            }

            // Put the new string data in a known location.
            PutInBank(0x0F, 0x8900, Blob.Concat(
                          FF1Text.TextToCopyrightLine("Final Fantasy Randomizer " + version),
                          FF1Text.TextToCopyrightLine((sha == "development" ? "DEVELOPMENT BUILD " : "Seed  ") + seed),
                          hash));
        }
Exemple #2
0
        public void WriteSeedAndFlags(string seed, string flags)
        {
            // Replace most of the old copyright string printing with a JSR to a LongJump
            Put(0x38486, Blob.FromHex("20B9FF60"));

            // DrawSeedAndFlags LongJump
            PutInBank(0x1F, 0xFFB9, CreateLongJumpTableEntry(0x0F, 0x8980));

            Blob hash;
            var  hasher = SHA256.Create();

            hash = hasher.ComputeHash(Encoding.ASCII.GetBytes($"{seed}_{flags}_{FFRVersion.Sha}"));

            var hashpart = BitConverter.ToUInt64(hash, 0);

            hash = Blob.FromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
            for (int i = 8; i < 24; i += 2)
            {
                // 0xD4 through 0xDF are good symbols to use.
                hash[i]   = (byte)(0xD4 + hashpart % 12);
                hashpart /= 12;
            }

            Regex rgx = new Regex("[^a-zA-Z0-9]");

            // Put the new string data in a known location.
            PutInBank(0x0F, 0x8900, Blob.Concat(
                          FF1Text.TextToCopyrightLine("Final Fantasy Randomizer " + FFRVersion.Version),
                          FF1Text.TextToCopyrightLine((FFRVersion.Branch == "master" ? "Seed " : rgx.Replace(FFRVersion.Branch, "") + " BUILD ") + seed),
                          hash));
        }
Exemple #3
0
        public void WriteSeedAndFlags(string version, string seed, string flags)
        {
            // Replace most of the old copyright string printing with a JSR to a LongJump
            Put(0x38486, Blob.FromHex("20FCFE60"));

            // DrawSeedAndFlags LongJump
            PutInBank(0x1F, 0xFEFC, CreateLongJumpTableEntry(0x0F, 0x8960));

            // Put the new string data in a known location.
            PutInBank(0x0F, 0x8900, Blob.Concat(new Blob[]
            {
                FF1Text.TextToCopyrightLine("Final Fantasy Randomizer " + version),
                FF1Text.TextToCopyrightLine("Seed  " + seed),
                FF1Text.TextToCopyrightLine(flags),
            }));
        }