示例#1
0
        // Load/Save Actions
        private void loadFields()
        {
            // Load the region/country values.
            v1cb(CB_Country0, 0x95); v1cb(CB_Region0, 0x94);
            v1cb(CB_Country1, 0x97); v1cb(CB_Region1, 0x96);
            v1cb(CB_Country2, 0x99); v1cb(CB_Region2, 0x98);
            v1cb(CB_Country3, 0x9B); v1cb(CB_Region3, 0x9A);
            v1cb(CB_Country4, 0x9D); v1cb(CB_Region4, 0x9C);

            // Load the Fullness, and Enjoyment
            v1s(M_Fullness, 0xAE); v1s(M_Enjoyment, 0xAF);

            // Load the CT Memories
            v1s(M_CT_Friendship, 0xA2); v1s(M_CT_Affection, 0xA3);
            CB_CTQual.SelectedIndex = Math.Max(0, h[0xA4] - 1);
            v1cb(CB_CTMemory, 0xA5); v2cb(CB_CTVar, 0xA8); i1cb(CB_CTFeel, 0xA6);

            // Load the OT Memories
            v1s(M_OT_Friendship, 0xCA); v1s(M_OT_Affection, 0xCB);
            CB_OTQual.SelectedIndex = Math.Max(0, h[0xCC] - 1);
            v1cb(CB_OTMemory, 0xCD); v2cb(CB_OTVar, 0xCE); i1cb(CB_OTFeel, 0xD0);

            CB_Handler.Items.Clear();
            CB_Handler.Items.AddRange(new object[] { m_parent.TB_OT.Text + " (" + ot + ")" });

            if (Util.TrimFromZero(m_parent.TB_OTt2.Text) != "")
            {
                CB_Handler.Items.AddRange(new object[] { m_parent.TB_OTt2.Text });
            }
            else
            {
                m_parent.buff[0x93] = 0;
            }

            tabControl1.SelectedIndex = CB_Handler.SelectedIndex = m_parent.buff[0x93];

            if (m_parent.CHK_IsEgg.Checked)
            {
                L_OT_Friendship.Text = m_parent.Label_HatchCounter.Text;
                GB_M_OT.Enabled      = GB_M_CT.Enabled = GB_Residence.Enabled = false;

                BTN_Save.Enabled   = M_Fullness.Enabled = M_Enjoyment.Enabled = false;
                L_Fullness.Enabled = L_Enjoyment.Enabled = false;

                GB_M_OT.Text = "N/A: " + Form1.eggname;
                GB_M_CT.Text = "N/A: " + Form1.eggname;
            }
            else
            {
                L_OT_Friendship.Text = m_parent.Label_Friendship.Text;
                GB_M_OT.Enabled      = GB_M_CT.Enabled = true;
                GB_Residence.Enabled = true;

                BTN_Save.Enabled   = M_Fullness.Enabled = M_Enjoyment.Enabled = true;
                L_Fullness.Enabled = L_Enjoyment.Enabled = true;

                GB_M_OT.Text = String.Format(withOT + " (" + ot + ")", m_parent.TB_OT.Text);
                GB_M_CT.Text = String.Format(withOT, m_parent.TB_OTt2.Text);
            }

            GB_M_CT.Enabled      = true;
            GB_Residence.Enabled = true;

            if ((!m_parent.CHK_IsEgg.Checked))
            {
                bool enable;
                int  game = Util.getIndex(m_parent.CB_GameOrigin);
                if ((game < 24) && (game != 0))
                {
                    // Banked Mon
                    GB_M_CT.Text = withOT + " " + m_parent.TB_OTt2.Text;
                    GB_M_OT.Text = past + " " + ot + ": " + m_parent.TB_OT.Text;
                    enable       = false;
                }
                else
                {
                    enable       = true;
                    GB_M_OT.Text = withOT + " " + m_parent.TB_OT.Text + " (" + ot + ")";
                    GB_M_CT.Text = withOT + m_parent.TB_OTt2.Text;
                    if ((m_parent.TB_OTt2.Text == ""))
                    {
                        GB_M_CT.Enabled = GB_Residence.Enabled = false;
                        GB_M_CT.Text    = notleft + " " + ot + " - " + disabled;
                    }
                    else
                    {
                        GB_M_CT.Text = withOT + " " + m_parent.TB_OTt2.Text;
                    }
                }
                RTB_OT.Visible = CB_OTQual.Enabled = CB_OTMemory.Enabled = CB_OTFeel.Enabled = CB_OTVar.Enabled = M_OT_Affection.Enabled = enable;
            }
            init = true;

            // Manually load the Memory Parse
            RTB_CT.Text = getMemoryString(CB_CTMemory, CB_CTVar, CB_CTQual, CB_CTFeel, m_parent.TB_OTt2.Text);
            RTB_OT.Text = getMemoryString(CB_OTMemory, CB_OTVar, CB_OTQual, CB_OTFeel, m_parent.TB_OT.Text);
        }
示例#2
0
        // Load/Save Actions
        private void loadFields()
        {
            // Load the region/country values.
            CB_Country0.SelectedValue = Main.pk6.Geo1_Country;
            CB_Country1.SelectedValue = Main.pk6.Geo2_Country;
            CB_Country2.SelectedValue = Main.pk6.Geo3_Country;
            CB_Country3.SelectedValue = Main.pk6.Geo4_Country;
            CB_Country4.SelectedValue = Main.pk6.Geo5_Country;
            CB_Region0.SelectedValue  = Main.pk6.Geo1_Region;
            CB_Region1.SelectedValue  = Main.pk6.Geo2_Region;
            CB_Region2.SelectedValue  = Main.pk6.Geo3_Region;
            CB_Region3.SelectedValue  = Main.pk6.Geo4_Region;
            CB_Region4.SelectedValue  = Main.pk6.Geo5_Region;

            // Load the Fullness, and Enjoyment
            M_Fullness.Text  = Main.pk6.Fullness.ToString();
            M_Enjoyment.Text = Main.pk6.Enjoyment.ToString();

            // Load the CT Memories
            M_CT_Friendship.Text      = Main.pk6.HT_Friendship.ToString();
            M_CT_Affection.Text       = Main.pk6.HT_Affection.ToString();
            CB_CTQual.SelectedIndex   = Math.Max(0, Main.pk6.HT_Intensity - 1);
            CB_CTMemory.SelectedValue = Main.pk6.HT_Memory;
            CB_CTVar.SelectedValue    = Main.pk6.HT_TextVar;
            CB_CTFeel.SelectedIndex   = Main.pk6.HT_Feeling;

            // Load the OT Memories
            M_OT_Friendship.Text      = Main.pk6.OT_Friendship.ToString();
            M_OT_Affection.Text       = Main.pk6.OT_Affection.ToString();
            CB_OTQual.SelectedIndex   = Math.Max(0, Main.pk6.OT_Intensity - 1);
            CB_OTMemory.SelectedValue = Main.pk6.OT_Memory;
            CB_OTVar.SelectedValue    = Main.pk6.OT_TextVar;
            CB_OTFeel.SelectedIndex   = Main.pk6.OT_Feeling;

            CB_Handler.Items.Clear();
            CB_Handler.Items.AddRange(new object[] { $"{Main.pk6.OT_Name} ({args[2]})" }); // OTNAME : OT

            if (Util.TrimFromZero(Main.pk6.HT_Name) != "")
            {
                CB_Handler.Items.AddRange(new object[] { Main.pk6.HT_Name });
            }
            else
            {
                Main.pk6.CurrentHandler = 0;
            }

            tabControl1.SelectedIndex = CB_Handler.SelectedIndex = Main.pk6.CurrentHandler;

            GB_M_OT.Enabled            = GB_M_CT.Enabled = GB_Residence.Enabled =
                BTN_Save.Enabled       = M_Fullness.Enabled = M_Enjoyment.Enabled =
                    L_Fullness.Enabled = L_Enjoyment.Enabled = !Main.pk6.IsEgg;

            if (!Main.pk6.IsEgg)
            {
                bool enable;
                if (!Main.pk6.Gen6)
                {
                    // Previous Generation Mon
                    GB_M_OT.Text = $"{args[3]} {Main.pk6.OT_Name}: {args[2]}"; // Past Gen OT : OTNAME
                    GB_M_CT.Text = $"{args[4]} {Main.pk6.HT_Name}";            // Memories with : HTNAME
                    enable       = false;
                    // Reset to no memory
                    M_OT_Affection.Text     = "0";
                    CB_OTQual.SelectedIndex = CB_OTFeel.SelectedIndex = 0;
                    CB_OTVar.SelectedValue  = CB_OTMemory.SelectedValue = 0;
                }
                else
                {
                    enable       = true;
                    GB_M_OT.Text = $"{args[4]} {Main.pk6.OT_Name} ({args[2]})"; // Memories with : OTNAME
                    GB_M_CT.Text = $"{args[4]} {Main.pk6.HT_Name}";             // Memories with : HTNAME
                    if (Main.pk6.HT_Name == "")
                    {
                        CB_Country1.Enabled     = CB_Country2.Enabled = CB_Country3.Enabled = CB_Country4.Enabled =
                            CB_Region1.Enabled  = CB_Region2.Enabled = CB_Region3.Enabled = CB_Region4.Enabled =
                                GB_M_CT.Enabled = false;
                        GB_M_CT.Text            = $"{args[1]} {args[2]} - {args[0]}"; // Never Left : OT : Disabled
                    }
                    else
                    {
                        GB_M_CT.Text = args[4] + " " + Main.pk6.HT_Name;
                    }
                }
                RTB_OT.Visible = CB_OTQual.Enabled = CB_OTMemory.Enabled = CB_OTFeel.Enabled = CB_OTVar.Enabled = M_OT_Affection.Enabled = enable;
            }
            else
            {
                GB_M_OT.Text = GB_M_CT.Text = $"N/A: {Main.eggname}";
            }

            init = true;

            // Manually load the Memory Parse
            RTB_CT.Text = getMemoryString(CB_CTMemory, CB_CTVar, CB_CTQual, CB_CTFeel, Main.pk6.HT_Name);
            RTB_OT.Text = getMemoryString(CB_OTMemory, CB_OTVar, CB_OTQual, CB_OTFeel, Main.pk6.OT_Name);
        }
示例#3
0
        // Load/Save Actions
        private void loadFields()
        {
            // Load the region/country values.
            CB_Country0.SelectedValue = Main.pk6.Geo1_Country;
            CB_Country1.SelectedValue = Main.pk6.Geo2_Country;
            CB_Country2.SelectedValue = Main.pk6.Geo3_Country;
            CB_Country3.SelectedValue = Main.pk6.Geo4_Country;
            CB_Country4.SelectedValue = Main.pk6.Geo5_Country;
            CB_Region0.SelectedValue  = Main.pk6.Geo1_Region;
            CB_Region1.SelectedValue  = Main.pk6.Geo2_Region;
            CB_Region2.SelectedValue  = Main.pk6.Geo3_Region;
            CB_Region3.SelectedValue  = Main.pk6.Geo4_Region;
            CB_Region4.SelectedValue  = Main.pk6.Geo5_Region;

            // Load the Fullness, and Enjoyment
            M_Fullness.Text  = Main.pk6.Fullness.ToString();
            M_Enjoyment.Text = Main.pk6.Enjoyment.ToString();

            // Load the CT Memories
            M_CT_Friendship.Text      = Main.pk6.HT_Friendship.ToString();
            M_CT_Affection.Text       = Main.pk6.HT_Affection.ToString();
            CB_CTQual.SelectedIndex   = Math.Max(0, Main.pk6.HT_Intensity - 1);
            CB_CTMemory.SelectedValue = Main.pk6.HT_Memory;
            CB_CTVar.SelectedValue    = Main.pk6.HT_TextVar;
            CB_CTFeel.SelectedIndex   = Main.pk6.HT_Feeling;

            // Load the OT Memories
            M_OT_Friendship.Text      = Main.pk6.OT_Friendship.ToString();
            M_OT_Affection.Text       = Main.pk6.OT_Affection.ToString();
            CB_OTQual.SelectedIndex   = Math.Max(0, Main.pk6.OT_Intensity - 1);
            CB_OTMemory.SelectedValue = Main.pk6.OT_Memory;
            CB_OTVar.SelectedValue    = Main.pk6.OT_TextVar;
            CB_OTFeel.SelectedIndex   = Main.pk6.OT_Feeling;

            CB_Handler.Items.Clear();
            CB_Handler.Items.AddRange(new object[] { Main.pk6.OT_Name + " (" + ot + ")" });

            if (Util.TrimFromZero(Main.pk6.HT_Name) != "")
            {
                CB_Handler.Items.AddRange(new object[] { Main.pk6.HT_Name });
            }
            else
            {
                Main.pk6.CurrentHandler = 0;
            }

            tabControl1.SelectedIndex = CB_Handler.SelectedIndex = Main.pk6.CurrentHandler;

            GB_M_OT.Enabled            = GB_M_CT.Enabled = GB_Residence.Enabled =
                BTN_Save.Enabled       = M_Fullness.Enabled = M_Enjoyment.Enabled =
                    L_Fullness.Enabled = L_Enjoyment.Enabled = (!Main.pk6.IsEgg);

            GB_M_OT.Text = (Main.pk6.IsEgg) ? "N/A: " + Main.eggname : String.Format(withOT + " (" + ot + ")", Main.pk6.OT_Name);
            GB_M_CT.Text = (Main.pk6.IsEgg) ? "N/A: " + Main.eggname : GB_M_CT.Text = String.Format(withOT, Main.pk6.HT_Name);

            if ((!Main.pk6.IsEgg))
            {
                bool enable;
                int  game = Main.pk6.Version;
                if ((game < 24) && (game != 0))
                {
                    // Banked Mon
                    GB_M_CT.Text = withOT + " " + Main.pk6.HT_Name;
                    GB_M_OT.Text = past + " " + ot + ": " + Main.pk6.OT_Name;
                    enable       = false;
                }
                else
                {
                    enable       = true;
                    GB_M_OT.Text = withOT + " " + Main.pk6.OT_Name + " (" + ot + ")";
                    GB_M_CT.Text = withOT + Main.pk6.HT_Name;
                    if ((Main.pk6.HT_Name == ""))
                    {
                        CB_Country1.Enabled     = CB_Country2.Enabled = CB_Country3.Enabled = CB_Country4.Enabled =
                            CB_Region1.Enabled  = CB_Region2.Enabled = CB_Region3.Enabled = CB_Region4.Enabled =
                                GB_M_CT.Enabled = false;
                        GB_M_CT.Text            = notleft + " " + ot + " - " + disabled;
                    }
                    else
                    {
                        GB_M_CT.Text = withOT + " " + Main.pk6.HT_Name;
                    }
                }
                RTB_OT.Visible = CB_OTQual.Enabled = CB_OTMemory.Enabled = CB_OTFeel.Enabled = CB_OTVar.Enabled = M_OT_Affection.Enabled = enable;
            }
            init = true;

            // Manually load the Memory Parse
            RTB_CT.Text = getMemoryString(CB_CTMemory, CB_CTVar, CB_CTQual, CB_CTFeel, Main.pk6.HT_Name);
            RTB_OT.Text = getMemoryString(CB_OTMemory, CB_OTVar, CB_OTQual, CB_OTFeel, Main.pk6.OT_Name);
        }
示例#4
0
 public string getBoxName(int box)
 {
     return(Util.TrimFromZero(Encoding.Unicode.GetString(Data, PCLayout + 0x22 * box, 0x22)));
 }
示例#5
0
        private void B_SAV2FAV(object sender, EventArgs e)
        {
            loading = true;
            int index = LB_Favorite.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            int offset = Main.SAV.SecretBase + 0x25A;

            // Base Offset Changing
            if (index == 0)
            {
                offset = Main.SAV.SecretBase + 0x326;
            }
            else
            {
                offset += 0x3E0 * index;
            }

            string TrainerName = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x218, 0x1A));

            TB_FOT.Text = TrainerName;

            TB_FT1.Text = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x232 + 0x22 * 0, 0x22));
            TB_FT2.Text = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x232 + 0x22 * 1, 0x22));

            string saying1 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 0, 0x22));
            string saying2 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 1, 0x22));
            string saying3 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 2, 0x22));
            string saying4 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 3, 0x22));

            int baseloc = BitConverter.ToInt16(sav, offset);

            NUD_FBaseLocation.Value = baseloc;

            TB_FSay1.Text = saying1; TB_FSay2.Text = saying2; TB_FSay3.Text = saying3; TB_FSay4.Text = saying4;

            // Gather data for Object Array
            objdata = new byte[25, 12];
            for (int i = 0; i < 25; i++)
            {
                for (int z = 0; z < 12; z++)
                {
                    objdata[i, z] = sav[offset + 2 + 12 * i + z];
                }
            }
            NUD_FObject.Value = 1; // Trigger Update
            changeObjectIndex(null, null);

            GB_PKM.Enabled = (index > 0);

            // Trainer Pokemon
            pkmdata = new byte[3, 0x34];
            if (index > 0)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int z = 0; z < 0x34; z++)
                    {
                        pkmdata[i, z] = sav[offset + 0x32E + 0x34 * i + z];
                    }
                }
            }

            NUD_FPKM.Value = 1;
            changeFavPKM(null, null); // Trigger Update

            loading = false;
        }
示例#6
0
        private void displayEntry(object sender, EventArgs e)
        {
            editing            = false;
            RTB.Font           = new Font("Courier New", 8);
            RTB.LanguageOption = RichTextBoxLanguageOptions.DualFont;
            int index  = LB_DataEntry.SelectedIndex;
            int offset = index * 0x1B4;

            uint vnd = BitConverter.ToUInt32(data, offset + 0x1B0);
            uint vn  = vnd & 0xFF;

            TB_VN.Text = vn.ToString("000");
            string s     = "Entry #" + vn + Environment.NewLine;
            uint   date  = vnd >> 14 & 0x1FFFF;
            uint   year  = (date & 0xFF) + 2000;
            uint   month = date >> 8 & 0xF;
            uint   day   = date >> 12;

            if (day == 0)
            {
                s += "No records in this slot.";
                foreach (Control t in editor_spec)
                {
                    t.Enabled = false;
                }

                editing = false;
                NUP_PartyIndex_ValueChanged(sender, e);
                goto end;
            }
            foreach (Control t in editor_spec)
            {
                t.Enabled = true;
            }

            s += "Date: " + year + "/" + month + "/" + day + "" + Environment.NewLine + Environment.NewLine;
            CAL_MetDate.Value = new DateTime((int)year, (int)month, (int)day);
            int moncount = 0;

            for (int i = 0; i < 6; i++)
            {
                int species  = BitConverter.ToUInt16(data, offset + 0x00);
                int helditem = BitConverter.ToUInt16(data, offset + 0x02);
                int move1    = BitConverter.ToUInt16(data, offset + 0x04);
                int move2    = BitConverter.ToUInt16(data, offset + 0x06);
                int move3    = BitConverter.ToUInt16(data, offset + 0x08);
                int move4    = BitConverter.ToUInt16(data, offset + 0x0A);

                int TID = BitConverter.ToUInt16(data, offset + 0x10);
                int SID = BitConverter.ToUInt16(data, offset + 0x12);

                uint slgf = BitConverter.ToUInt32(data, offset + 0x14);
                // uint form = slgf & 0x1F;
                uint gender = slgf >> 5 & 3; // 0 M; 1 F; 2 G
                uint level  = slgf >> 7 & 0x7F;
                uint shiny  = slgf >> 14 & 0x1;
                // uint unkn = slgf >> 15;

                string nickname = Util.TrimFromZero(Encoding.Unicode.GetString(data, offset + 0x18, 22));
                string OTname   = Util.TrimFromZero(Encoding.Unicode.GetString(data, offset + 0x30, 22));

                if (species == 0)
                {
                    continue;
                }

                moncount++;
                string genderstr = gendersymbols[gender];
                string shinystr  = shiny == 1 ? "Yes" : "No";

                s += "Name: " + nickname;
                s += " (" + Main.specieslist[species] + " - " + genderstr + ")" + Environment.NewLine;
                s += "Level: " + level + Environment.NewLine;
                s += "Shiny: " + shinystr + Environment.NewLine;
                s += "Held Item: " + Main.itemlist[helditem] + Environment.NewLine;
                s += "Move 1: " + Main.movelist[move1] + Environment.NewLine;
                s += "Move 2: " + Main.movelist[move2] + Environment.NewLine;
                s += "Move 3: " + Main.movelist[move3] + Environment.NewLine;
                s += "Move 4: " + Main.movelist[move4] + Environment.NewLine;
                s += "OT: " + OTname + " (" + TID + "/" + SID + ")" + Environment.NewLine;
                s += Environment.NewLine;

                offset += 0x48;
            }

            if (sender != null)
            {
                NUP_PartyIndex.Maximum = moncount == 0 ? 1 : moncount;
                NUP_PartyIndex.Value   = 1;
                NUP_PartyIndex_ValueChanged(sender, e);
            }
            else
            {
                editing = true;
            }
end:
            RTB.Text = s;
            RTB.Font = new Font("Courier New", 8);
        }
示例#7
0
        private void Write_Entry(object sender, EventArgs e)
        {
            if (!editing)
            {
                return; //Don't do writing until loaded
            }
            Validate_TextBoxes();
            byte[]   StringBuffer = new byte[22];      //Mimic in-game behavior of not clearing strings. It's awful, but accuracy > good.
            string[] text_writes  = new string[6 * 2]; //2 strings per mon, 6 mons

            int index = LB_DataEntry.SelectedIndex;

            int offset = index * 0x1B4;

            for (int i = 0; i < text_writes.Length; i++)
            {
                string nickname = Util.TrimFromZero(Encoding.Unicode.GetString(data, offset + 0x18, 22));
                string OTname   = Util.TrimFromZero(Encoding.Unicode.GetString(data, offset + 0x30, 22));
                text_writes[i] = nickname;
                i++;
                text_writes[i] = OTname;
                offset        += 0x48;
            }

            int partymember = Convert.ToInt32(NUP_PartyIndex.Value) - 1;

            text_writes[partymember * 2]     = TB_Nickname.Text;
            text_writes[partymember * 2 + 1] = TB_OT.Text;

            offset = index * 0x1B4 + partymember * 0x48;

            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(CB_Species.SelectedValue)), 0, data, offset + 0x00, 2);
            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(CB_HeldItem.SelectedValue)), 0, data, offset + 0x02, 2);
            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(CB_Move1.SelectedValue)), 0, data, offset + 0x04, 2);
            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(CB_Move2.SelectedValue)), 0, data, offset + 0x06, 2);
            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(CB_Move3.SelectedValue)), 0, data, offset + 0x08, 2);
            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(CB_Move4.SelectedValue)), 0, data, offset + 0x0A, 2);
            Array.Copy(BitConverter.GetBytes(Convert.ToUInt32(TB_EC.Text, 16)), 0, data, offset + 0x0C, 4);

            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(TB_TID.Text)), 0, data, offset + 0x010, 2);
            Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(TB_SID.Text)), 0, data, offset + 0x012, 2);

            #region Write Strings
            {
                int ofs = index * 0x1B4;
                for (int i = 0; i < 6; i++)
                {
                    Array.Copy(Encoding.Unicode.GetBytes(text_writes[i * 2]), StringBuffer, text_writes[i * 2].Length * 2);
                    int pos = text_writes[i * 2].Length * 2;
                    if (pos < StringBuffer.Length)
                    {
                        StringBuffer[pos] = 0;
                    }

                    Array.Copy(StringBuffer, 0, data, ofs + 0x18, 22);
                    Array.Copy(Encoding.Unicode.GetBytes(text_writes[i * 2 + 1]), StringBuffer, text_writes[i * 2 + 1].Length * 2);
                    pos = text_writes[i * 2 + 1].Length * 2;
                    if (pos < StringBuffer.Length)
                    {
                        StringBuffer[pos] = 0;
                    }

                    Array.Copy(StringBuffer, 0, data, ofs + 0x30, 22);
                    ofs += 0x48;
                }
            }
            #endregion

            uint rawslgf = BitConverter.ToUInt32(data, offset + 0x14);
            uint slgf    = 0;
            slgf |= (uint)(CB_Form.SelectedIndex & 0x1F);
            slgf |= (uint)((PKX.getGender(Label_Gender.Text) & 0x3) << 5);
            slgf |= (uint)((Convert.ToUInt16(TB_Level.Text) & 0x7F) << 7);
            if (CHK_Shiny.Checked)
            {
                slgf |= 1 << 14;
            }

            slgf |= rawslgf & 0x8000;
            Array.Copy(BitConverter.GetBytes(slgf), 0, data, offset + 0x014, 2);

            uint nick = 0;
            if (CHK_Nicknamed.Checked)
            {
                nick = 1;
            }
            Array.Copy(BitConverter.GetBytes(nick), 0, data, offset + 0x016, 2);

            offset = index * 0x1B4;

            uint vnd  = 0;
            uint date = 0;
            vnd  |= Convert.ToUInt32(TB_VN.Text) & 0xFF;
            date |= (uint)((CAL_MetDate.Value.Year - 2000) & 0xFF);
            date |= (uint)((CAL_MetDate.Value.Month & 0xF) << 8);
            date |= (uint)((CAL_MetDate.Value.Day & 0x1F) << 12);
            vnd  |= (date & 0x1FFFF) << 14;
            //Fix for top bit
            uint rawvnd = BitConverter.ToUInt32(data, offset + 0x1B0);
            vnd |= rawvnd & 0x80000000;
            Array.Copy(BitConverter.GetBytes(vnd), 0, data, offset + 0x1B0, 4);

            bpkx.Image = PKX.getSprite(Util.getIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.getGender(Label_Gender.Text), Util.getIndex(CB_HeldItem), false, CHK_Shiny.Checked);
            displayEntry(null, null); // refresh text view
        }