Example #1
0
        private void calcRTC(uint initialSeed, uint targetSeed, int minFrame, int maxFrame)
        {
            isSearching = true;

            var back = new XdRngR(targetSeed);

            back.GetNext32BitNumber(minFrame);
            targetSeed = back.Seed;

            var rng = new XdRng(initialSeed);

            int  seconds      = 0;
            int  secoundCount = 0;
            bool targetHit    = false;
            int  minutes      = 0;

            while (!targetHit)
            {
                searchText.Invoke((MethodInvoker)(() => searchText.Text = "Minutes added to RTC: " + minutes.ToString()));
                rng.Seed = initialSeed;

                for (int x = 0; x < maxFrame; x++)
                {
                    if (rng.GetNext32BitNumber() == targetSeed)
                    {
                        DateTime finalTime = date + new TimeSpan(0, 0, 0, seconds);
                        seedTime.Add(new RTCTime {
                            Time = finalTime.ToString(), Frame = x + 2 + minFrame, Seed = initialSeed.ToString("X8")
                        });
                        isSearching = false;

                        searchText.Invoke((MethodInvoker)(() => searchText.Text = "Finish. Awaiting command"));
                        dataGridViewValues.Invoke((MethodInvoker)(() => dataGridViewValues.DataSource = seedTime));
                        dataGridViewValues.Invoke((MethodInvoker)(() => dataGridViewValues.AutoResizeColumns()));
                        return;
                    }
                }

                initialSeed  += 40500000;
                seconds      += 1;
                secoundCount += 1;

                if (secoundCount == 60)
                {
                    minutes     += 1;
                    secoundCount = 0;
                }
            }
        }
Example #2
0
        private void buttonGenerate_Click(object sender, EventArgs e)
        {
            //  Initial seed that we are going to used for our frame generation
            ulong seed = 0;

            if (textBoxSeed.Text != "")
            {
                seed = ulong.Parse(textBoxSeed.Text, NumberStyles.HexNumber);
            }

            uint maxFrames = 1000;

            if (maskedTextBoxMaxFrames.Text != "")
            {
                maxFrames = uint.Parse(maskedTextBoxMaxFrames.Text);
            }

            //  Generic RNG Interface
            IRNG   rng   = null;
            IRNG64 rng64 = null;

            //  Instantiate based on the type that
            //  the user has selected ------------
            if (radioButtonCommon.Checked)
            {
                switch (comboBoxRNG.SelectedIndex)
                {
                case 0:
                    rng = new PokeRng((uint)seed);
                    break;

                case 1:
                    rng = new PokeRngR((uint)seed);
                    break;

                case 2:
                    // if the given seed is 64 bit, remove the lower 32 bits.
                    if (seed >= 0x100000000)
                    {
                        seed >>= 32;
                    }
                    rng = new MersenneTwister((uint)seed);
                    break;

                case 3:
                    rng64 = new BWRng(seed);
                    break;

                case 4:
                    rng64 = new BWRngR(seed);
                    break;

                case 5:
                    rng = new XdRng((uint)seed);
                    break;

                case 6:
                    rng = new XdRngR((uint)seed);
                    break;

                case 7:
                    rng = new ARng((uint)seed);
                    break;

                case 8:
                    rng = new ARngR((uint)seed);
                    break;

                case 9:
                    rng = new GRng((uint)seed);
                    break;

                case 10:
                    rng = new GRngR((uint)seed);
                    break;

                case 11:
                    rng = new EncounterRng((uint)seed);
                    break;

                case 12:
                    rng = new EncounterRngR((uint)seed);
                    break;

                case 13:
                    rng = new MersenneTwisterUntempered((int)seed);
                    break;

                case 14:
                    rng = new MersenneTwisterFast((uint)seed, (int)maxFrames);
                    break;

                case 15:
                    rng = new MersenneTwisterTable((uint)seed);
                    break;
                }
            }

            if (radioButtonCustom.Checked)
            {
                //  Check to see if we had valid values in the entry fields, and if so
                //  covert them over to the adding and multiplier so we can instantiate
                //  a generic LCRNG.

                ulong mult = 0;
                ulong add  = 0;

                if (textBoxMult.Text != "")
                {
                    mult = ulong.Parse(textBoxMult.Text, NumberStyles.HexNumber);
                }

                if (textBoxAdd.Text != "")
                {
                    add = ulong.Parse(textBoxAdd.Text, NumberStyles.HexNumber);
                }

                if (checkBox64bit.Checked)
                {
                    rng64 = new GenericRng64(seed, mult, add);
                }
                else
                {
                    rng = new GenericRng((uint)seed, (uint)mult, (uint)add);
                }
            }

            //  This is our collection of operators. At some point, if this gets
            //  fancy, we may want to break it off and have it in it's own class
            var calculators = new Dictionary <string, Calculator>();

            calculators["%"]  = (x, y) => x % y;
            calculators["*"]  = (x, y) => x * y;
            calculators["/"]  = (x, y) => y == 0 ? 0 : x / y;
            calculators["&"]  = (x, y) => x & y;
            calculators["^"]  = (x, y) => x ^ y;
            calculators["|"]  = (x, y) => x | y;
            calculators["+"]  = (x, y) => x + y;
            calculators["-"]  = (x, y) => x - y;
            calculators[">>"] = (x, y) => x >> (int)y;
            calculators["<<"] = (x, y) => x << (int)y;

            bool calcCustom1 =
                textBoxRValue1.Text != "" &&
                (string)comboBoxOperator1.SelectedItem != null &&
                (string)comboBoxLValue1.SelectedItem != null;
            bool calcCustom2 =
                (textBoxRValue2.Text != "" || comboBoxRValue2.SelectedIndex != 0) &&
                (string)comboBoxOperator2.SelectedItem != null &&
                (string)comboBoxLValue2.SelectedItem != null;
            bool calcCustom3 =
                (textBoxRValue3.Text != "" || comboBoxRValue3.SelectedIndex != 0) &&
                (string)comboBoxOperator3.SelectedItem != null &&
                (string)comboBoxLValue3.SelectedItem != null;
            bool calcCustom4 =
                (textBoxRValue4.Text != "" || comboBoxRValue4.SelectedIndex != 0) &&
                (string)comboBoxOperator4.SelectedItem != null &&
                (string)comboBoxLValue4.SelectedItem != null;
            bool calcCustom5 =
                (textBoxRValue5.Text != "" || comboBoxRValue5.SelectedIndex != 0) &&
                (string)comboBoxOperator5.SelectedItem != null &&
                (string)comboBoxLValue5.SelectedItem != null;
            bool calcCustom6 =
                (textBoxRValue6.Text != "" || comboBoxRValue6.SelectedIndex != 0) &&
                (string)comboBoxOperator6.SelectedItem != null &&
                (string)comboBoxLValue6.SelectedItem != null;
            bool calcCustom7 =
                (textBoxRValue7.Text != "" || comboBoxRValue7.SelectedIndex != 0) &&
                (string)comboBoxOperator7.SelectedItem != null &&
                (string)comboBoxLValue7.SelectedItem != null;

            //  Build our custom item transform classes so that we can use them in
            //  the future without having to do a parse of all of the items.

            ulong customRValue1;
            ulong customRValue2;
            ulong customRValue3;
            ulong customRValue4;
            ulong customRValue5;
            ulong customRValue6;
            ulong customRValue7;

            try
            {
                customRValue1 = (textBoxRValue1.Text == ""
                                     ? 0
                                     : (checkBoxCustom1Hex.Checked
                                            ? ulong.Parse(textBoxRValue1.Text, NumberStyles.HexNumber)
                                            : ulong.Parse(textBoxRValue1.Text)));
                customRValue2 = (textBoxRValue2.Text == ""
                                     ? 0
                                     : (checkBoxCustom2Hex.Checked
                                            ? ulong.Parse(textBoxRValue2.Text, NumberStyles.HexNumber)
                                            : ulong.Parse(textBoxRValue2.Text)));
                customRValue3 = (textBoxRValue3.Text == ""
                                     ? 0
                                     : (checkBoxCustom3Hex.Checked
                                            ? ulong.Parse(textBoxRValue3.Text, NumberStyles.HexNumber)
                                            : ulong.Parse(textBoxRValue3.Text)));
                customRValue4 = (textBoxRValue4.Text == ""
                                     ? 0
                                     : (checkBoxCustom4Hex.Checked
                                            ? ulong.Parse(textBoxRValue4.Text, NumberStyles.HexNumber)
                                            : ulong.Parse(textBoxRValue4.Text)));
                customRValue5 = (textBoxRValue5.Text == ""
                                     ? 0
                                     : (checkBoxCustom5Hex.Checked
                                            ? ulong.Parse(textBoxRValue5.Text, NumberStyles.HexNumber)
                                            : ulong.Parse(textBoxRValue5.Text)));
                customRValue6 = (textBoxRValue6.Text == ""
                                     ? 0
                                     : (checkBoxCustom6Hex.Checked
                                            ? ulong.Parse(textBoxRValue6.Text, NumberStyles.HexNumber)
                                            : ulong.Parse(textBoxRValue6.Text)));
                customRValue7 = (textBoxRValue7.Text == ""
                                     ? 0
                                     : (checkBoxCustom7Hex.Checked
                                            ? ulong.Parse(textBoxRValue7.Text, NumberStyles.HexNumber)
                                            : ulong.Parse(textBoxRValue7.Text)));
            }
            catch (Exception ex)
            {
                MessageBox.Show("You must check off the Hex box in order to calculate using hex values.", ex.Message);
                return;
            }

            Calculator custom1Calc = ((string)comboBoxOperator1.SelectedItem == null
                                          ? null
                                          : calculators[(string)comboBoxOperator1.SelectedItem]);
            Calculator custom2Calc = ((string)comboBoxOperator2.SelectedItem == null
                                          ? null
                                          : calculators[(string)comboBoxOperator2.SelectedItem]);
            Calculator custom3Calc = ((string)comboBoxOperator3.SelectedItem == null
                                          ? null
                                          : calculators[(string)comboBoxOperator3.SelectedItem]);
            Calculator custom4Calc = ((string)comboBoxOperator4.SelectedItem == null
                                          ? null
                                          : calculators[(string)comboBoxOperator4.SelectedItem]);
            Calculator custom5Calc = ((string)comboBoxOperator5.SelectedItem == null
                                          ? null
                                          : calculators[(string)comboBoxOperator5.SelectedItem]);
            Calculator custom6Calc = ((string)comboBoxOperator6.SelectedItem == null
                                          ? null
                                          : calculators[(string)comboBoxOperator6.SelectedItem]);
            Calculator custom7Calc = ((string)comboBoxOperator7.SelectedItem == null
                                          ? null
                                          : calculators[(string)comboBoxOperator7.SelectedItem]);

            //  Decide on whether we are going to display each of these items as
            //  decimal or hex. Can be very useful either way, so it is an option.
            Custom1.DefaultCellStyle.Format = checkBoxCustom1Hex.Checked ? "X8" : "";

            Custom2.DefaultCellStyle.Format = checkBoxCustom2Hex.Checked ? "X8" : "";

            Custom3.DefaultCellStyle.Format = checkBoxCustom3Hex.Checked ? "X8" : "";

            Custom4.DefaultCellStyle.Format = checkBoxCustom4Hex.Checked ? "X8" : "";
            Custom5.DefaultCellStyle.Format = checkBoxCustom5Hex.Checked ? "X8" : "";
            Custom6.DefaultCellStyle.Format = checkBoxCustom6Hex.Checked ? "X8" : "";
            Custom7.DefaultCellStyle.Format = checkBoxCustom7Hex.Checked ? "X8" : "";

            var frames = new List <FrameResearch>();

            bool rngIs64Bit = (comboBoxRNG.SelectedIndex == 3 || comboBoxRNG.SelectedIndex == 4 ||
                               checkBox64bit.Checked && radioButtonCustom.Checked);

            //  Loop through X times and create our research frames.
            for (uint cnt = 0; cnt < maxFrames; cnt++)
            {
                FrameResearch frame;
                if (!rngIs64Bit)
                {
                    Column64Bit.Visible     = false;
                    Column32Bit.Visible     = true;
                    Column32BitHigh.Visible = false;
                    Column32BitLow.Visible  = false;

                    uint rngResult = rng.Next();

                    //  Start building the research frame that we are going to use
                    frame = new FrameResearch {
                        RNG64bit = rngIs64Bit, FrameNumber = cnt + 1, Full32 = rngResult
                    };
                }
                else
                {
                    Column64Bit.Visible     = true;
                    Column32Bit.Visible     = false;
                    Column32BitHigh.Visible = true;
                    Column32BitLow.Visible  = true;

                    ulong rngResult = rng64.Next();

                    //  Start building the research frame that we are going to use
                    frame = new FrameResearch {
                        RNG64bit = rngIs64Bit, FrameNumber = cnt + 1, Full64 = rngResult
                    };
                }

                //  Call Custom 1 ////////////////////////////////////////////////////////////////
                if (calcCustom1)
                {
                    ulong customLValue1 = CustomCalcs(comboBoxLValue1, frame, frames);

                    if (!rngIs64Bit)
                    {
                        customLValue1 = (uint)customLValue1;
                    }

                    frame.Custom1 = custom1Calc(customLValue1, customRValue1);
                }
                //////////////////////////////////////////////////////////////////////////////////

                //  Call Custom 2 ////////////////////////////////////////////////////////////////
                if (calcCustom2)
                {
                    ulong customLValue2 = CustomCalcs(comboBoxLValue2, frame, frames);
                    if ((string)comboBoxRValue2.SelectedItem != "None")
                    {
                        customRValue2 = CustomCalcs(comboBoxRValue2, frame, frames);
                    }

                    if (!rngIs64Bit)
                    {
                        customLValue2 = (uint)customLValue2;
                    }

                    frame.Custom2 = custom2Calc(customLValue2, customRValue2);
                }
                //////////////////////////////////////////////////////////////////////////////////

                //  Call Custom 3 ////////////////////////////////////////////////////////////////
                if (calcCustom3)
                {
                    ulong customLValue3 = CustomCalcs(comboBoxLValue3, frame, frames);
                    if ((string)comboBoxRValue3.SelectedItem != "None")
                    {
                        customRValue3 = CustomCalcs(comboBoxRValue3, frame, frames);
                    }

                    if (!rngIs64Bit)
                    {
                        customLValue3 = (uint)customLValue3;
                    }

                    frame.Custom3 = custom3Calc(customLValue3, customRValue3);
                }
                //////////////////////////////////////////////////////////////////////////////////

                //  Call Custom 4 ////////////////////////////////////////////////////////////////
                if (calcCustom4)
                {
                    ulong customLValue4 = CustomCalcs(comboBoxLValue4, frame, frames);
                    if ((string)comboBoxRValue4.SelectedItem != "None")
                    {
                        customRValue4 = CustomCalcs(comboBoxRValue4, frame, frames);
                    }

                    if (!rngIs64Bit)
                    {
                        customLValue4 = (uint)customLValue4;
                    }

                    frame.Custom4 = custom4Calc(customLValue4, customRValue4);
                }
                //////////////////////////////////////////////////////////////////////////////////

                //  Call Custom 5 ////////////////////////////////////////////////////////////////
                if (calcCustom5)
                {
                    ulong customLValue5 = CustomCalcs(comboBoxLValue5, frame, frames);
                    if ((string)comboBoxRValue5.SelectedItem != "None")
                    {
                        customRValue5 = CustomCalcs(comboBoxRValue5, frame, frames);
                    }

                    if (!rngIs64Bit)
                    {
                        customLValue5 = (uint)customLValue5;
                    }

                    frame.Custom5 = custom5Calc(customLValue5, customRValue5);
                }
                //////////////////////////////////////////////////////////////////////////////////

                //  Call Custom 6 ////////////////////////////////////////////////////////////////
                if (calcCustom6)
                {
                    ulong customLValue6 = CustomCalcs(comboBoxLValue6, frame, frames);
                    if ((string)comboBoxRValue6.SelectedItem != "None")
                    {
                        customRValue6 = CustomCalcs(comboBoxRValue6, frame, frames);
                    }

                    if (!rngIs64Bit)
                    {
                        customLValue6 = (uint)customLValue6;
                    }

                    frame.Custom6 = custom6Calc(customLValue6, customRValue6);
                }
                //////////////////////////////////////////////////////////////////////////////////

                //  Call Custom 7 ////////////////////////////////////////////////////////////////
                if (calcCustom7)
                {
                    ulong customLValue7 = CustomCalcs(comboBoxLValue7, frame, frames);
                    if ((string)comboBoxRValue7.SelectedItem != "None")
                    {
                        customRValue7 = CustomCalcs(comboBoxRValue7, frame, frames);
                    }

                    if (!rngIs64Bit)
                    {
                        customLValue7 = (uint)customLValue7;
                    }

                    frame.Custom7 = custom7Calc(customLValue7, customRValue7);
                }
                //////////////////////////////////////////////////////////////////////////////////

                frames.Add(frame);
            }

            //  Bind to the grid
            dataGridViewValues.DataSource = frames;
            dataGridViewValues.Focus();
        }
Example #3
0
        // by declaring these only once you get a huge performance boost

        // This method ensures that an RNG is only created once,
        // and not every time a Generate function is called

        public List <Frame> Generate(
            FrameCompare frameCompare,
            uint id,
            uint sid)
        {
            frames = new List <Frame>();

            if (FrameType == FrameType.ColoXD)
            {
                var rng = new XdRng((uint)InitialSeed);
                rngList = new List <uint>();

                for (uint cnt = 1; cnt < InitialFrame; cnt++)
                {
                    rng.GetNext32BitNumber();
                }

                for (uint cnt = 0; cnt < 12; cnt++)
                {
                    rngList.Add(rng.GetNext16BitNumber());
                }

                for (uint cnt = 0; cnt < maxResults; cnt++, rngList.RemoveAt(0), rngList.Add(rng.GetNext16BitNumber()))
                {
                    switch (FrameType)
                    {
                    case FrameType.ColoXD:
                        frame = Frame.GenerateFrame(
                            0,
                            FrameType.ColoXD,
                            cnt + InitialFrame,
                            rngList[0],
                            rngList[4],
                            rngList[3],
                            rngList[0],
                            rngList[1],
                            id, sid);

                        break;

                    case FrameType.Channel:
                        frame = Frame.GenerateFrame(
                            0,
                            FrameType.Channel,
                            cnt + InitialFrame,
                            rngList[0],
                            rngList[1],
                            rngList[2],
                            (rngList[6]) >> 11,
                            (rngList[7]) >> 11,
                            (rngList[8]) >> 11,
                            (rngList[10]) >> 11,
                            (rngList[11]) >> 11,
                            (rngList[9]) >> 11,
                            40122, rngList[0]);

                        break;
                    }

                    if (frameCompare.Compare(frame))
                    {
                        frames.Add(frame); break;
                    }
                }
            }
            else
            {
                //  We are going to grab our initial set of rngs here and
                //  then start our loop so that we can iterate as many
                //  times as we have to.
                var rng = new PokeRng((uint)InitialSeed);
                rngList = new List <uint>();

                for (uint cnt = 1; cnt < InitialFrame; cnt++)
                {
                    rng.GetNext32BitNumber();
                }

                for (uint cnt = 0; cnt < 20; cnt++)
                {
                    rngList.Add(rng.GetNext16BitNumber());
                }

                lastseed = rng.Seed;

                for (uint cnt = 0; cnt < maxResults; cnt++, rngList.RemoveAt(0), rngList.Add(rng.GetNext16BitNumber()))
                {
                    switch (FrameType)
                    {
                    case FrameType.Method1:
                        frame =
                            Frame.GenerateFrame(
                                0,
                                FrameType.Method1,
                                cnt + InitialFrame,
                                rngList[0],
                                rngList[0],
                                rngList[1],
                                rngList[2],
                                rngList[3],
                                id, sid, cnt);

                        break;

                    case FrameType.Method1Reverse:
                        frame =
                            Frame.GenerateFrame(
                                0,
                                FrameType.Method1Reverse,
                                cnt + InitialFrame,
                                rngList[0],
                                rngList[1],
                                rngList[0],
                                rngList[2],
                                rngList[3],
                                id, sid, cnt);

                        break;

                    case FrameType.Method2:
                        frame =
                            Frame.GenerateFrame(
                                0,
                                FrameType.Method2,
                                cnt + InitialFrame,
                                rngList[0],
                                rngList[0],
                                rngList[1],
                                rngList[3],
                                rngList[4],
                                id, sid, cnt);

                        break;

                    case FrameType.Method4:
                        frame =
                            Frame.GenerateFrame(
                                0,
                                FrameType.Method4,
                                cnt + InitialFrame,
                                rngList[0],
                                rngList[0],
                                rngList[1],
                                rngList[2],
                                rngList[4],
                                id, sid, cnt);

                        break;
                    }

                    //  Now we need to filter and decide if we are going
                    //  to add this to our collection for display to the
                    //  user.

                    if (frameCompare.Compare(frame))
                    {
                        frames.Add(frame); break;
                    }
                }
            }

            return(frames);
        }
Example #4
0
        private void SearchGales(uint pid, uint ivs, uint initseed, uint minframes, uint maxframes)
        {
            uint pidl = pid & 0xFFFF;
            uint pidh = pid >> 16;
            uint ivsh = ivs >> 16;
            uint ivsl = ivs & 0xFFFF;

            uint[] seeds = new uint[5];
            var    rng   = new XdRng(initseed);

            rng.GetNext32BitNumber((int)minframes);

            for (int x = 0; x < 5; x++)
            {
                seeds[x] = rng.GetNext16BitNumber();
            }

            int j = 4;
            int k;

            for (uint i = 1 + minframes; i < maxframes; i++, seeds[j] = rng.GetNext16BitNumber())
            {
                if (++j > 4)
                {
                    j = 0;
                }

                if ((seeds[j] & 0x7FFF) != ivsl)
                {
                    continue;
                }

                if ((seeds[j >= 4 ? 0 : j + 1] & 0x7FFF) != ivsh)
                {
                    continue;
                }

                k = j + 3;
                if (k > 4)
                {
                    k -= 5;
                }

                if (seeds[k] != pidh)
                {
                    continue;
                }

                k = j + 4;
                if (k > 4)
                {
                    k -= 5;
                }

                if (seeds[k] != pidl)
                {
                    continue;
                }

                string[] row = new string[] { i.ToString() };
                dataGridView1.Rows.Add(row);
                dataGridView1.Refresh();
                break;
            }
        }
Example #5
0
        //  We need a function to return a list of monster seeds,
        //  which will be updated to include a method.

        public static List <Seed> GetSeeds(
            uint hp,
            uint atk,
            uint def,
            uint spa,
            uint spd,
            uint spe,
            uint nature,
            uint tid,
            FrameType type)
        {
            var seeds = new List <Seed>();
            Dictionary <uint, uint> keys;
            var rng     = new PokeRngR(0);
            var forward = new XdRng(0);
            var back    = new XdRngR(0);

            uint first  = (hp | (atk << 5) | (def << 10)) << 16;
            uint second = (spe | (spa << 5) | (spd << 10)) << 16;

            uint pid1, pid2, pid, seed;

            uint search1, search2;

            ulong t, kmax;

            switch (type)
            {
            case FrameType.Method1:
                keys = new Dictionary <uint, uint>();
                for (uint i = 0; i < 256; i++)
                {
                    uint   right = (0x41c64e6d * i) + 0x6073;
                    ushort val   = (ushort)(right >> 16);

                    keys[val]   = i;
                    keys[--val] = i;
                }

                search1 = second - (first * 0x41c64e6d);
                search2 = second - ((first ^ 0x80000000) * 0x41c64e6d);
                for (uint cnt = 0; cnt < 256; ++cnt, search1 -= 0xc64e6d00, search2 -= 0xc64e6d00)
                {
                    uint test = search1 >> 16;

                    if (keys.ContainsKey(test))
                    {
                        rng.Seed = (first | (cnt << 8) | keys[test]);
                        if ((((rng.Seed * 0x41c64e6d) + 0x6073) & 0x7FFF0000) == second)
                        {
                            pid2 = rng.GetNext16BitNumber();
                            pid1 = rng.GetNext16BitNumber();
                            pid  = (pid1 << 16) | pid2;
                            seed = rng.GetNext32BitNumber();
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 1",
                                    Pid         = pid,
                                    MonsterSeed = seed,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }

                            pid ^= 0x80000000;
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 1",
                                    Pid         = pid,
                                    MonsterSeed = seed ^ 0x80000000,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }
                        }
                    }

                    test = search2 >> 16;

                    if (keys.ContainsKey(test))
                    {
                        rng.Seed = (first | (cnt << 8) | keys[test]);
                        if ((((rng.Seed * 0x41c64e6d) + 0x6073) & 0x7FFF0000) == second)
                        {
                            pid2 = rng.GetNext16BitNumber();
                            pid1 = rng.GetNext16BitNumber();
                            pid  = (pid1 << 16) | pid2;
                            seed = rng.GetNext32BitNumber();
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 1",
                                    Pid         = pid,
                                    MonsterSeed = seed,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }

                            pid ^= 0x80000000;
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 1",
                                    Pid         = pid,
                                    MonsterSeed = seed ^ 0x80000000,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }
                        }
                    }
                }

                break;

            case FrameType.Method2:
                keys = new Dictionary <uint, uint>();
                for (uint i = 0; i < 256; i++)
                {
                    uint   right = (0x41c64e6d * i) + 0x6073;
                    ushort val   = (ushort)(right >> 16);

                    keys[val]   = i;
                    keys[--val] = i;
                }

                search1 = second - (first * 0x41c64e6d);
                search2 = second - ((first ^ 0x80000000) * 0x41c64e6d);
                for (uint cnt = 0; cnt < 256; ++cnt, search1 -= 0xc64e6d00, search2 -= 0xc64e6d00)
                {
                    uint test = search1 >> 16;

                    if (keys.ContainsKey(test))
                    {
                        rng.Seed = (first | (cnt << 8) | keys[test]);
                        if ((((rng.Seed * 0x41c64e6d) + 0x6073) & 0x7FFF0000) == second)
                        {
                            rng.GetNext32BitNumber();
                            pid2 = rng.GetNext16BitNumber();
                            pid1 = rng.GetNext16BitNumber();
                            pid  = (pid1 << 16) | pid2;
                            seed = rng.GetNext32BitNumber();
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 2",
                                    Pid         = pid,
                                    MonsterSeed = seed,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }

                            pid ^= 0x80000000;
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 2",
                                    Pid         = pid,
                                    MonsterSeed = seed ^ 0x80000000,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }
                        }
                    }

                    test = search2 >> 16;

                    if (keys.ContainsKey(test))
                    {
                        rng.Seed = (first | (cnt << 8) | keys[test]);
                        if ((((rng.Seed * 0x41c64e6d) + 0x6073) & 0x7FFF0000) == second)
                        {
                            pid2 = rng.GetNext16BitNumber();
                            pid1 = rng.GetNext16BitNumber();
                            pid  = (pid1 << 16) | pid2;
                            seed = rng.GetNext32BitNumber();
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 2",
                                    Pid         = pid,
                                    MonsterSeed = seed,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }

                            pid ^= 0x80000000;
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 2",
                                    Pid         = pid,
                                    MonsterSeed = seed ^ 0x80000000,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }
                        }
                    }
                }

                break;

            case FrameType.Method4:
                keys = new Dictionary <uint, uint>();
                for (uint i = 0; i < 256; i++)
                {
                    uint   right = (0xc2a29a69 * i) + 0xe97e7b6a;
                    ushort val   = (ushort)(right >> 16);

                    keys[val]   = i;
                    keys[--val] = i;
                }

                search1 = second - (first * 0x41c64e6d);
                search2 = second - ((first ^ 0x80000000) * 0x41c64e6d);
                for (uint cnt = 0; cnt < 256; ++cnt, search1 -= 0xc64e6d00, search2 -= 0xc64e6d00)
                {
                    uint test = search1 >> 16;

                    if (keys.ContainsKey(test))
                    {
                        rng.Seed = (first | (cnt << 8) | keys[test]);
                        if ((((rng.Seed * 0x41c64e6d) + 0x6073) & 0x7FFF0000) == second)
                        {
                            pid2 = rng.GetNext16BitNumber();
                            pid1 = rng.GetNext16BitNumber();
                            pid  = (pid1 << 16) | pid2;
                            seed = rng.GetNext32BitNumber();
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 4",
                                    Pid         = pid,
                                    MonsterSeed = seed,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }

                            pid ^= 0x80000000;
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 4",
                                    Pid         = pid,
                                    MonsterSeed = seed ^ 0x80000000,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }
                        }
                    }

                    test = search2 >> 16;

                    if (keys.ContainsKey(test))
                    {
                        rng.Seed = (first | (cnt << 8) | keys[test]);
                        if ((((rng.Seed * 0x41c64e6d) + 0x6073) & 0x7FFF0000) == second)
                        {
                            pid2 = rng.GetNext16BitNumber();
                            pid1 = rng.GetNext16BitNumber();
                            pid  = (pid1 << 16) | pid2;
                            seed = rng.GetNext32BitNumber();
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 4",
                                    Pid         = pid,
                                    MonsterSeed = seed,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }

                            pid ^= 0x80000000;
                            if (pid % 25 == nature)
                            {
                                var newSeed = new Seed
                                {
                                    Method      = "Method 4",
                                    Pid         = pid,
                                    MonsterSeed = seed ^ 0x80000000,
                                    Sid         = (tid ^ pid1 ^ pid2)
                                };
                                seeds.Add(newSeed);
                            }
                        }
                    }
                }

                break;

            case FrameType.ColoXD:

                t    = (second - (0x343fd * first) - 0x259ec4) & 0xFFFFFFFF;
                kmax = (0x343fabc02 - t) / 0x80000000;

                for (ulong k = 0; k <= kmax; k++, t += 0x80000000)
                {
                    if ((t % 0x343fd) < 0x10000)
                    {
                        forward.Seed = back.Seed = (uint)(first | (t / 0x343fd));
                        forward.GetNext32BitNumber(2);
                        pid1 = forward.GetNext16BitNumber();
                        pid2 = forward.GetNext16BitNumber();
                        pid  = (pid1 << 16) | pid2;
                        seed = back.GetNext32BitNumber();
                        if (pid % 25 == nature)
                        {
                            var newSeed = new Seed
                            {
                                Method      = "Colosseum/XD",
                                Pid         = pid,
                                MonsterSeed = seed,
                                Sid         = (tid ^ pid1 ^ pid2)
                            };
                            seeds.Add(newSeed);
                        }

                        pid ^= 0x80008000;
                        if (pid % 25 == nature)
                        {
                            var newSeed = new Seed
                            {
                                Method      = "Colosseum/XD",
                                Pid         = pid,
                                MonsterSeed = seed ^ 0x80000000,
                                Sid         = (tid ^ pid1 ^ pid2)
                            };
                            seeds.Add(newSeed);
                        }
                    }
                }

                break;

            case FrameType.Channel:
                first = hp << 27;

                t    = ((spd << 27) - (0x284A930D * first) - 0x9A974C78) & 0xFFFFFFFF;
                kmax = ((0x142549847b56cf2 - t) / 0x100000000);

                for (uint k = 0; k <= kmax; k++, t += 0x100000000)
                {
                    if ((t % 0x284A930D) >= 0x8000000)
                    {
                        continue;
                    }

                    forward.Seed = back.Seed = first | (uint)(t / 0x284A930D);
                    if (forward.GetNext32BitNumber() >> 27 != atk)
                    {
                        continue;
                    }

                    if (forward.GetNext32BitNumber() >> 27 != def)
                    {
                        continue;
                    }

                    if (forward.GetNext32BitNumber() >> 27 != spe)
                    {
                        continue;
                    }

                    if (forward.GetNext32BitNumber() >> 27 != spa)
                    {
                        continue;
                    }

                    back.GetNext32BitNumber(3);
                    pid2 = back.GetNext16BitNumber();
                    pid1 = back.GetNext16BitNumber();
                    uint sid = back.GetNext16BitNumber();
                    pid = (pid1 << 16) | pid2;
                    if ((pid2 > 7 ? 0 : 1) != (pid1 ^ sid ^ 40122))
                    {
                        pid ^= 0x80000000;
                    }
                    if (pid % 25 == nature)
                    {
                        var newSeed = new Seed
                        {
                            Method      = "Channel",
                            Pid         = pid,
                            MonsterSeed = back.GetNext32BitNumber(),
                            Sid         = (tid ^ pid1 ^ pid2)
                        };
                        seeds.Add(newSeed);
                    }
                }

                break;
            }

            return(seeds);
        }