Merge pull request #211 from kwsch/rhydon-merge

Add support for editing Gen I files
This commit is contained in:
SciresM 2016-08-30 21:36:57 -07:00 committed by GitHub
commit 89ed9fb045
25 changed files with 2878 additions and 84 deletions

View file

@ -926,6 +926,7 @@
this.TB_Nickname.Name = "TB_Nickname";
this.TB_Nickname.Size = new System.Drawing.Size(122, 20);
this.TB_Nickname.TabIndex = 5;
this.TB_Nickname.TextChanged += new System.EventHandler(this.updateIsNicknamed);
this.TB_Nickname.MouseDown += new System.Windows.Forms.MouseEventHandler(this.updateNicknameClick);
//
// CB_Species

View file

@ -266,7 +266,7 @@ namespace PKHeX
SaveFileDialog sfd = new SaveFileDialog
{
Filter = $"Decrypted PKM File|*.{pkx}" +
$"|Encrypted PKM File|*.{ekx}" +
(SAV.Generation > 2 ? "" : $"|Encrypted PKM File|*.{ekx}") +
"|Binary File|*.bin" +
"|All Files|*.*",
DefaultExt = pkx,
@ -621,6 +621,8 @@ namespace PKHeX
PKM pk = PKMConverter.convertToFormat(temp, SAV.Generation, out c);
if (pk == null)
Util.Alert("Conversion failed.", c);
else if (SAV.Generation == 1 && ((PK1) pk).Japanese != SAV.GetJapanese)
Util.Alert(string.Format("Cannot load {0} PK1 in {1} save file.", SAV.GetJapanese ? "an International" : "a Japanese", SAV.GetJapanese ? "a Japanese" : "an International"));
else
populateFields(pk);
Console.WriteLine(c);
@ -739,7 +741,7 @@ namespace PKHeX
SaveFile sav = SaveUtil.getVariantSAV(input);
if (sav == null || sav.Version == GameVersion.Invalid)
{ Util.Error("Invalid save file loaded. Aborting.", path); return; }
if (sav.Generation <= 3) // Japanese Save files are different. Get isJapanese
if (sav.Generation == 3) // Japanese Save files are different. Get isJapanese
{
if (sav.Version == GameVersion.Unknown)
{
@ -868,11 +870,77 @@ namespace PKHeX
TB_AbilityNumber.Visible = SAV.Generation >= 6 && DEV_Ability.Enabled;
CB_Ability.Visible = !DEV_Ability.Enabled && SAV.Generation >= 3;
GB_ExtraBytes.Visible = SAV.Generation > 1;
GB_Markings.Visible = SAV.Generation > 2;
Label_HeldItem.Visible = CB_HeldItem.Visible = SAV.Generation > 1;
Label_Total.Visible = TB_IVTotal.Visible = TB_EVTotal.Visible = L_Potential.Visible =
Label_HiddenPowerPrefix.Visible = CB_HPType.Visible = SAV.Generation > 1;
Label_CharacteristicPrefix.Visible = L_Characteristic.Visible = SAV.Generation > 1;
Label_ContestStats.Visible = Label_Cool.Visible = Label_Tough.Visible = Label_Smart.Visible =
Label_Sheen.Visible = Label_Beauty.Visible = Label_Cute.Visible = TB_Cool.Visible = TB_Tough.Visible =
TB_Smart.Visible = TB_Sheen.Visible = TB_Beauty.Visible = TB_Cute.Visible = Label_Nature.Visible =
CB_Nature.Visible = Label_Language.Visible = CB_Language.Visible = Label_Ability.Visible =
Label_Friendship.Visible = Label_HatchCounter.Visible = TB_Friendship.Visible = BTN_RerollPID.Visible =
Label_PID.Visible = TB_PID.Visible = Label_SID.Visible = TB_SID.Visible = SAV.Generation >= 3;
// Met Tab
CHK_Fateful.Visible = Label_OriginGame.Visible = Label_Ball.Visible = Label_MetLevel.Visible =
Label_MetLocation.Visible = CB_GameOrigin.Visible = CB_Ball.Visible = CB_MetLocation.Visible =
TB_MetLevel.Visible = SAV.Generation > 2;
CHK_Infected.Visible = CHK_Cured.Visible = SAV.Generation >= 3;
// Second daycare slot
SlotPictureBoxes[43].Visible = SAV.Generation > 1;
CHK_IsEgg.Visible = Label_Gender.Visible = SAV.Generation > 1;
Label_OTGender.Visible = SAV.Generation > 1;
if (1 <= sav.Generation && sav.Generation <= 2)
{
Label_SPD.Visible = TB_SPDEV.Visible = TB_SPDIV.Visible = Stat_SPD.Visible = false;
Label_SPA.Text = "Spc";
TB_HPIV.ReadOnly = true;
Control[] evControls = { TB_SPAEV, TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPDEV };
foreach (MaskedTextBox ctrl in evControls)
{
ctrl.Mask = "00000";
ctrl.Size = new Size(37, 20);
}
Control[] statControls = {Stat_HP, Stat_ATK, Stat_DEF, Stat_SPA, Stat_SPD, Stat_SPE};
foreach (Control ctrl in statControls)
ctrl.Location = new Point(173, ctrl.Location.Y);
Label_Stats.Location = new Point(168, Label_Stats.Location.Y);
}
else
{
Label_SPD.Visible = TB_SPDEV.Visible = TB_SPDIV.Visible = Stat_SPD.Visible = true;
Label_SPA.Text = "SpA";
TB_HPIV.ReadOnly = false;
Control[] evControls = { TB_SPAEV, TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPDEV };
foreach (MaskedTextBox ctrl in evControls)
{
ctrl.Mask = "000";
ctrl.Size = new Size(31, 20);
}
Control[] statControls = { Stat_HP, Stat_ATK, Stat_DEF, Stat_SPA, Stat_SPD, Stat_SPE };
foreach (Control ctrl in statControls)
ctrl.Location = new Point(167, ctrl.Location.Y);
Label_Stats.Location = new Point(162, Label_Stats.Location.Y);
}
// Recenter PKM SubEditors
FLP_PKMEditors.Location = new Point((tabMain.TabPages[4].Width - FLP_PKMEditors.Width) / 2, FLP_PKMEditors.Location.Y);
switch (SAV.Generation)
{
case 1:
getFieldsfromPKM = populateFieldsPK1;
getPKMfromFields = preparePK1;
extraBytes = new byte[] {};
break;
case 3:
getFieldsfromPKM = populateFieldsPK3;
getPKMfromFields = preparePK3;
@ -902,7 +970,7 @@ namespace PKHeX
bool init = fieldsInitialized;
fieldsInitialized = false;
populateFilteredDataSources();
populateFields(pkm.Format != SAV.Generation ? SAV.BlankPKM : pk);
populateFields((pkm.Format != SAV.Generation || SAV.Generation == 1) ? SAV.BlankPKM : pk);
fieldsInitialized |= init;
// SAV Specific Limits
@ -915,10 +983,13 @@ namespace PKHeX
TB_Level.Visible = !HaX;
// Load Extra Byte List
CB_ExtraBytes.Items.Clear();
foreach (byte b in extraBytes)
CB_ExtraBytes.Items.Add("0x" + b.ToString("X2"));
CB_ExtraBytes.SelectedIndex = 0;
if (GB_ExtraBytes.Visible)
{
CB_ExtraBytes.Items.Clear();
foreach (byte b in extraBytes)
CB_ExtraBytes.Items.Add("0x" + b.ToString("X2"));
CB_ExtraBytes.SelectedIndex = 0;
}
// Refresh PK#->PK6 conversion info
PKMConverter.updateConfig(SAV.SubRegion, SAV.Country, SAV.ConsoleRegion, SAV.OT, SAV.Gender);
@ -1187,12 +1258,15 @@ namespace PKHeX
}
private void populateFilteredDataSources()
{
string[] items = itemlist;
if (SAV.Generation == 3)
items = g3items;
if (SAV.Generation > 1)
{
string[] items = itemlist;
if (SAV.Generation == 3)
items = g3items;
ItemDataSource = Util.getCBList(items, (HaX ? Enumerable.Range(0, SAV.MaxItemID) : SAV.HeldItems.Select(i => (int)i)).ToArray());
CB_HeldItem.DataSource = new BindingSource(ItemDataSource.Where(i => i.Value <= SAV.MaxItemID).ToList(), null);
ItemDataSource = Util.getCBList(items, (HaX ? Enumerable.Range(0, SAV.MaxItemID) : SAV.HeldItems.Select(i => (int)i)).ToArray());
CB_HeldItem.DataSource = new BindingSource(ItemDataSource.Where(i => i.Value <= SAV.MaxItemID).ToList(), null);
}
CB_Ball.DataSource = new BindingSource(BallDataSource.Where(b => b.Value <= SAV.MaxBallID).ToList(), null);
CB_Species.DataSource = new BindingSource(SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID).ToList(), null);
@ -1328,8 +1402,8 @@ namespace PKHeX
bool isShiny = pkm.IsShiny;
// Set the Controls
BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny;
Label_IsShiny.Visible = isShiny;
BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny && SAV.Generation > 2;
Label_IsShiny.Visible = isShiny && SAV.Generation > 1;
// Refresh Markings (for Shiny Star if applicable)
setMarkings();
@ -1575,7 +1649,11 @@ namespace PKHeX
}
changingFields = false;
if (fieldsLoaded)
{
pkm.EXP = Util.ToUInt32(TB_EXP.Text);
if (SAV.Generation < 3)
pkm.Stat_Level = Util.ToInt32(TB_Level.Text);
}
updateStats();
updateLegality();
}
@ -1605,8 +1683,8 @@ namespace PKHeX
private void updateIVs(object sender, EventArgs e)
{
if (changingFields || !fieldsInitialized) return;
if (sender != null && Util.ToInt32(((MaskedTextBox) sender).Text) > 31)
((MaskedTextBox) sender).Text = "31";
if (sender != null && Util.ToInt32(((MaskedTextBox) sender).Text) > SAV.MaxIV)
((MaskedTextBox) sender).Text = SAV.MaxIV.ToString("00");
changingFields = true;
@ -1617,6 +1695,11 @@ namespace PKHeX
pkm.IV_SPE = Util.ToInt32(TB_SPEIV.Text);
pkm.IV_SPA = Util.ToInt32(TB_SPAIV.Text);
pkm.IV_SPD = Util.ToInt32(TB_SPDIV.Text);
if (SAV.Generation < 3)
{
TB_HPIV.Text = pkm.IV_HP.ToString("00");
}
CB_HPType.SelectedValue = pkm.HPType;
changingFields = false;
@ -1672,30 +1755,31 @@ namespace PKHeX
if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift)
{
// Max IVs
TB_HPIV.Text = 31.ToString();
TB_ATKIV.Text = 31.ToString();
TB_DEFIV.Text = 31.ToString();
TB_SPAIV.Text = 31.ToString();
TB_SPDIV.Text = 31.ToString();
TB_SPEIV.Text = 31.ToString();
TB_HPIV.Text = SAV.MaxIV.ToString();
TB_ATKIV.Text = SAV.MaxIV.ToString();
TB_DEFIV.Text = SAV.MaxIV.ToString();
TB_SPAIV.Text = SAV.MaxIV.ToString();
TB_SPDIV.Text = SAV.MaxIV.ToString();
TB_SPEIV.Text = SAV.MaxIV.ToString();
}
else
{
TB_HPIV.Text = (Util.rnd32() & 0x1F).ToString();
TB_ATKIV.Text = (Util.rnd32() & 0x1F).ToString();
TB_DEFIV.Text = (Util.rnd32() & 0x1F).ToString();
TB_SPAIV.Text = (Util.rnd32() & 0x1F).ToString();
TB_SPDIV.Text = (Util.rnd32() & 0x1F).ToString();
TB_SPEIV.Text = (Util.rnd32() & 0x1F).ToString();
TB_HPIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString();
TB_ATKIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString();
TB_DEFIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString();
TB_SPAIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString();
TB_SPDIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString();
TB_SPEIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString();
}
changingFields = false;
updateIVs(null, null);
}
private void updateRandomEVs(object sender, EventArgs e)
{
changingFields = true;
if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift)
{
// Max IVs
// Max EVs
TB_HPEV.Text = 0.ToString();
TB_ATKEV.Text = 0.ToString();
TB_DEFEV.Text = 0.ToString();
@ -1705,7 +1789,7 @@ namespace PKHeX
}
else
{
byte[] evs = PKX.getRandomEVs();
var evs = PKX.getRandomEVs(SAV.Generation);
TB_HPEV.Text = evs[0].ToString();
TB_ATKEV.Text = evs[1].ToString();
TB_DEFEV.Text = evs[2].ToString();
@ -1713,6 +1797,8 @@ namespace PKHeX
TB_SPDEV.Text = evs[4].ToString();
TB_SPEEV.Text = evs[5].ToString();
}
changingFields = false;
updateEVs(null, null);
}
private void updateRandomPID(object sender, EventArgs e)
{
@ -2128,6 +2214,8 @@ namespace PKHeX
if (SAV.Generation < 5) // All caps GenIV and previous
nick = nick.ToUpper();
TB_Nickname.Text = nick;
if (SAV.Generation == 1)
((PK1)pkm).setNotNicknamed();
}
}
private void updateNicknameClick(object sender, MouseEventArgs e)
@ -2182,8 +2270,9 @@ namespace PKHeX
}
}
// Display hatch counter if it is an egg, Display Friendship if it is not.
Label_HatchCounter.Visible = CHK_IsEgg.Checked;
Label_Friendship.Visible = !CHK_IsEgg.Checked;
Label_HatchCounter.Visible = CHK_IsEgg.Checked && SAV.Generation > 1;
Label_Friendship.Visible = !CHK_IsEgg.Checked && SAV.Generation > 2;
// Update image to (not) show egg.
if (!fieldsInitialized) return;
@ -2448,7 +2537,7 @@ namespace PKHeX
for (int i = 0; i < cba.Length; i++)
{
int back = cba[i].BackColor.ToArgb();
if (back == SystemColors.Control.ToArgb() || back == 0 ||
if (!cba[i].Visible || back == SystemColors.Control.ToArgb() || back == 0 ||
!(back != -1 & back != defaultControlWhite.ToArgb())) continue;
if (i < 6) // Main Tab
tabMain.SelectedIndex = 0;
@ -2460,7 +2549,7 @@ namespace PKHeX
}
#endregion
// Further logic checking
if (Convert.ToUInt32(TB_EVTotal.Text) > 510 && !CHK_HackedStats.Checked)
if (SAV.Generation >= 3 && Convert.ToUInt32(TB_EVTotal.Text) > 510 && !CHK_HackedStats.Checked)
{ tabMain.SelectedIndex = 2; goto invalid; }
// If no errors detected...
if (Util.getIndex(CB_Species) != 0) return true;
@ -2475,14 +2564,17 @@ namespace PKHeX
{
// Check if PKM properties are outside of the valid range
List<string> errata = new List<string>();
if (pk.HeldItem > itemlist.Length)
errata.Add($"Item Index beyond range: {pk.HeldItem}");
else
if (SAV.Generation > 1)
{
if (pk.HeldItem > SAV.MaxItemID)
errata.Add($"Game can't obtain item: {itemlist[pk.HeldItem]}");
if (!pk.CanHoldItem(SAV.HeldItems))
errata.Add($"Game can't hold item: {itemlist[pk.HeldItem]}");
if (pk.HeldItem > itemlist.Length)
errata.Add($"Item Index beyond range: {pk.HeldItem}");
else
{
if (pk.HeldItem > SAV.MaxItemID)
errata.Add($"Game can't obtain item: {itemlist[pk.HeldItem]}");
if (!pk.CanHoldItem(SAV.HeldItems))
errata.Add($"Game can't hold item: {itemlist[pk.HeldItem]}");
}
}
if (pk.Species > specieslist.Length)
@ -2929,6 +3021,28 @@ namespace PKHeX
SAV.Edited = true;
}
}
private void updateIsNicknamed(object sender, EventArgs e)
{
if (!CHK_Nicknamed.Checked)
{
int species = Util.getIndex(CB_Species);
if (species < 1 || species > SAV.MaxSpeciesID)
return;
int lang = Util.getIndex(CB_Language);
if (CHK_IsEgg.Checked) species = 0; // Set species to 0 to get the egg name.
string nick = PKX.getSpeciesName(CHK_IsEgg.Checked ? 0 : species, lang);
if (SAV.Generation < 5) // All caps GenIV and previous
nick = nick.ToUpper();
if (TB_Nickname.Text != nick)
{
CHK_Nicknamed.Checked = true;
pkm.Nickname = TB_Nickname.Text;
}
}
}
// Generic Subfunctions //
private void setParty()
{
@ -2986,9 +3100,18 @@ namespace PKHeX
int boxoffset = SAV.getBoxOffset(CB_BoxSelect.SelectedIndex);
int boxbgval = SAV.getBoxWallpaper(CB_BoxSelect.SelectedIndex);
PAN_Box.BackgroundImage = BoxWallpaper.getWallpaper(SAV, boxbgval);
for (int i = 0; i < 30; i++)
getSlotFiller(boxoffset + SAV.SIZE_STORED * i, SlotPictureBoxes[i]);
{
if (i < SAV.BoxSlotCount)
{
getSlotFiller(boxoffset + SAV.SIZE_STORED * i, SlotPictureBoxes[i]);
}
else
{
SlotPictureBoxes[i].Image = null;
SlotPictureBoxes[i].Visible = false;
}
}
}
// Reload Party
@ -3101,6 +3224,7 @@ namespace PKHeX
// 00s present in slot.
pb.Image = null;
pb.BackColor = Color.Transparent;
pb.Visible = true;
return;
}
PKM p = SAV.getStoredSlot(offset);
@ -3109,11 +3233,13 @@ namespace PKHeX
// Bad Egg present in slot.
pb.Image = null;
pb.BackColor = Color.Red;
pb.Visible = true;
return;
}
// Something stored in slot. Only display if species is valid.
pb.Image = p.Species == 0 ? null : p.Sprite;
pb.BackColor = Color.Transparent;
pb.Visible = true;
}
private void getSlotColor(int slot, Image color)
{
@ -3129,6 +3255,7 @@ namespace PKHeX
}
private void getBox(object sender, EventArgs e)
{
SAV.CurrentBox = CB_BoxSelect.SelectedIndex;
setPKXBoxes();
}
private void switchDaycare(object sender, EventArgs e)
@ -3314,6 +3441,8 @@ namespace PKHeX
new SAV_PokedexORAS().ShowDialog();
else if (SAV.XY)
new SAV_PokedexXY().ShowDialog();
else if (SAV.RBY)
new SAV_SimplePokedex().ShowDialog();
}
private void B_OUTPasserby_Click(object sender, EventArgs e)
{

126
PKHeX/MainWindow/MainPK1.cs Normal file
View file

@ -0,0 +1,126 @@
using System;
using System.Linq;
namespace PKHeX
{
public partial class Main
{
private void populateFieldsPK1()
{
PK1 pk1 = pkm as PK1;
if (pk1 == null)
return;
// Do first
pk1.Stat_Level = PKX.getLevel(pk1.Species, pk1.EXP);
if (pk1.Stat_Level == 100)
pk1.EXP = PKX.getEXP(pk1.Stat_Level, pk1.Species);
CB_Species.SelectedValue = pk1.Species;
TB_Level.Text = pk1.Stat_Level.ToString();
TB_EXP.Text = pk1.EXP.ToString();
// Load rest
TB_TID.Text = pk1.TID.ToString("00000");
CHK_Nicknamed.Checked = pk1.IsNicknamed;
TB_Nickname.Text = pk1.Nickname;
TB_OT.Text = pk1.OT_Name;
GB_OT.BackgroundImage = null;
// Reset Label and ComboBox visibility, as well as non-data checked status.
Label_PKRS.Visible = false;
Label_PKRSdays.Visible = false;
TB_HPIV.Text = pk1.IV_HP.ToString();
TB_ATKIV.Text = pk1.IV_ATK.ToString();
TB_DEFIV.Text = pk1.IV_DEF.ToString();
TB_SPEIV.Text = pk1.IV_SPE.ToString();
TB_SPAIV.Text = pk1.IV_SPA.ToString();
TB_HPEV.Text = pk1.EV_HP.ToString();
TB_ATKEV.Text = pk1.EV_ATK.ToString();
TB_DEFEV.Text = pk1.EV_DEF.ToString();
TB_SPEEV.Text = pk1.EV_SPE.ToString();
TB_SPAEV.Text = pk1.EV_SPA.ToString();
CB_Move1.SelectedValue = pk1.Move1;
CB_Move2.SelectedValue = pk1.Move2;
CB_Move3.SelectedValue = pk1.Move3;
CB_Move4.SelectedValue = pk1.Move4;
CB_PPu1.SelectedIndex = pk1.Move1_PPUps;
CB_PPu2.SelectedIndex = pk1.Move2_PPUps;
CB_PPu3.SelectedIndex = pk1.Move3_PPUps;
CB_PPu4.SelectedIndex = pk1.Move4_PPUps;
TB_PP1.Text = pk1.Move1_PP.ToString();
TB_PP2.Text = pk1.Move2_PP.ToString();
TB_PP3.Text = pk1.Move3_PP.ToString();
TB_PP4.Text = pk1.Move4_PP.ToString();
CB_Language.SelectedIndex = pk1.Japanese ? 0 : 1;
updateStats();
TB_EXP.Text = pk1.EXP.ToString();
}
private PKM preparePK1()
{
PK1 pk1 = pkm as PK1;
if (pk1 == null)
return null;
pk1.Species = Util.getIndex(CB_Species);
pk1.TID = Util.ToInt32(TB_TID.Text);
pk1.EXP = Util.ToUInt32(TB_EXP.Text);
pk1.EV_HP = Util.ToInt32(TB_HPEV.Text);
pk1.EV_ATK = Util.ToInt32(TB_ATKEV.Text);
pk1.EV_DEF = Util.ToInt32(TB_DEFEV.Text);
pk1.EV_SPE = Util.ToInt32(TB_SPEEV.Text);
pk1.EV_SPC = Util.ToInt32(TB_SPAEV.Text);
pk1.Nickname = TB_Nickname.Text;
pk1.Move1 = Util.getIndex(CB_Move1);
pk1.Move2 = Util.getIndex(CB_Move2);
pk1.Move3 = Util.getIndex(CB_Move3);
pk1.Move4 = Util.getIndex(CB_Move4);
pk1.Move1_PP = Util.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
pk1.Move2_PP = Util.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
pk1.Move3_PP = Util.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
pk1.Move4_PP = Util.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
pk1.Move1_PPUps = Util.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
pk1.Move2_PPUps = Util.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
pk1.Move3_PPUps = Util.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
pk1.Move4_PPUps = Util.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;
pk1.IV_HP = Util.ToInt32(TB_HPIV.Text);
pk1.IV_ATK = Util.ToInt32(TB_ATKIV.Text);
pk1.IV_DEF = Util.ToInt32(TB_DEFIV.Text);
pk1.IV_SPE = Util.ToInt32(TB_SPEIV.Text);
pk1.IV_SPA = Util.ToInt32(TB_SPAIV.Text);
pk1.OT_Name = TB_OT.Text;
// Toss in Party Stats
Array.Resize(ref pk1.Data, pk1.SIZE_PARTY);
pk1.Stat_Level = Util.ToInt32(TB_Level.Text);
pk1.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text);
pk1.Stat_HPMax = Util.ToInt32(Stat_HP.Text);
pk1.Stat_ATK = Util.ToInt32(Stat_ATK.Text);
pk1.Stat_DEF = Util.ToInt32(Stat_DEF.Text);
pk1.Stat_SPE = Util.ToInt32(Stat_SPE.Text);
pk1.Stat_SPA = Util.ToInt32(Stat_SPA.Text);
pk1.Stat_SPD = Util.ToInt32(Stat_SPD.Text);
if (HaX)
{
pk1.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue);
}
// Fix Moves if a slot is empty
pk1.FixMoves();
pk1.RefreshChecksum();
return pk1;
}
}
}

View file

@ -73,6 +73,9 @@
<Compile Include="Legality\Tables3.cs" />
<Compile Include="Legality\Tables5.cs" />
<Compile Include="Legality\Tables4.cs" />
<Compile Include="MainWindow\MainPK1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainWindow\MainPK6.cs">
<SubType>Form</SubType>
</Compile>
@ -90,11 +93,13 @@
<Compile Include="PersonalInfo\PersonalInfo.cs" />
<Compile Include="PersonalInfo\PersonalInfoB2W2.cs" />
<Compile Include="PersonalInfo\PersonalInfoBW.cs" />
<Compile Include="PersonalInfo\PersonalInfoG1.cs" />
<Compile Include="PersonalInfo\PersonalInfoG3.cs" />
<Compile Include="PersonalInfo\PersonalInfoG4.cs" />
<Compile Include="PersonalInfo\PersonalInfoORAS.cs" />
<Compile Include="PersonalInfo\PersonalInfoXY.cs" />
<Compile Include="PersonalInfo\PersonalTable.cs" />
<Compile Include="PKM\PK1.cs" />
<Compile Include="PKM\PKM.cs" />
<Compile Include="PKM\PKMConverter.cs" />
<Compile Include="PKM\ShowdownSet.cs" />
@ -114,6 +119,7 @@
<Compile Include="Saves\BlockInfo.cs" />
<Compile Include="Saves\BoxWallpaper.cs" />
<Compile Include="Saves\Inventory.cs" />
<Compile Include="Saves\SAV1.cs" />
<Compile Include="Saves\SAV3.cs" />
<Compile Include="Saves\SAV4.cs" />
<Compile Include="Saves\SAV5.cs" />
@ -195,6 +201,12 @@
<Compile Include="Subforms\Save Editors\SAV_BoxViewer.Designer.cs">
<DependentUpon>SAV_BoxViewer.cs</DependentUpon>
</Compile>
<Compile Include="Subforms\Save Editors\SAV_SimplePokedex.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Subforms\Save Editors\SAV_SimplePokedex.Designer.cs">
<DependentUpon>SAV_SimplePokedex.cs</DependentUpon>
</Compile>
<Compile Include="Subforms\SAV_Database.cs">
<SubType>Form</SubType>
</Compile>
@ -300,6 +312,7 @@
<DependentUpon>SplashScreen.cs</DependentUpon>
</Compile>
<Compile Include="Misc\ComboItem.cs" />
<Compile Include="Util\ByteUtil.cs" />
<Compile Include="Util\DataUtil.cs" />
<Compile Include="Util\DateUtil.cs" />
<Compile Include="Util\FormUtil.cs" />
@ -348,6 +361,9 @@
<EmbeddedResource Include="Subforms\Save Editors\SAV_BoxViewer.resx">
<DependentUpon>SAV_BoxViewer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Subforms\Save Editors\SAV_SimplePokedex.resx">
<DependentUpon>SAV_SimplePokedex.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Subforms\SAV_Database.resx">
<DependentUpon>SAV_Database.cs</DependentUpon>
</EmbeddedResource>
@ -406,6 +422,7 @@
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="app.config" />
<None Include="ClassDiagram1.cd" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -461,6 +478,7 @@
<None Include="Resources\byte\personal_hgss" />
<None Include="Resources\byte\personal_lg" />
<None Include="Resources\byte\personal_pt" />
<None Include="Resources\byte\personal_rby" />
<None Include="Resources\byte\personal_rs" />
<None Include="Resources\byte\personal_xy" />
<None Include="Resources\byte\wc6.pkl" />

397
PKHeX/PKM/PK1.cs Normal file
View file

@ -0,0 +1,397 @@
using System;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
namespace PKHeX
{
class PK1 : PKM
{
// Internal use only
protected internal byte[] otname;
protected internal byte[] nick;
public byte[] OT_Name_Raw => (byte[])otname.Clone();
public byte[] Nickname_Raw => (byte[])nick.Clone();
public sealed override int SIZE_PARTY => PKX.SIZE_1PARTY;
public override int SIZE_STORED => PKX.SIZE_1STORED;
internal const int STRLEN_J = 6;
internal const int STRLEN_U = 11;
private int StringLength => Japanese ? STRLEN_J : STRLEN_U;
public override int Format => 1;
public bool Japanese => otname.Length == STRLEN_J;
public override string FileName => $"{Species.ToString("000")} - {Nickname} - {OT_Name}.{Extension}";
public PK1(byte[] decryptedData = null, string ident = null, bool jp = false)
{
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
Identifier = ident;
if (Data.Length != SIZE_PARTY)
Array.Resize(ref Data, SIZE_PARTY);
int strLen = STRLEN_U;
if (jp)
{
strLen = STRLEN_J;
}
otname = Enumerable.Repeat((byte) 0x50, strLen).ToArray();
nick = Enumerable.Repeat((byte) 0x50, strLen).ToArray();
}
public override PKM Clone()
{
PK1 new_pk1 = new PK1(Data, Identifier, Japanese);
Array.Copy(otname, 0, new_pk1.otname, 0, otname.Length);
Array.Copy(nick, 0, new_pk1.nick, 0, nick.Length);
return new_pk1;
}
public override string Nickname
{
get { return PKX.getG1Str(nick, Japanese); }
set
{
byte[] strdata = PKX.setG1Str(value, Japanese);
if (strdata.Length > StringLength)
throw new ArgumentOutOfRangeException($"Nickname {value} too long for given PK1");
if (nick.Any(b => b == 0) && nick[StringLength - 1] == 0x50 && Array.FindIndex(nick, b => b == 0) == strdata.Length - 1) // Handle JP Mew event with grace
{
int firstInd = Array.FindIndex(nick, b => b == 0);
for (int i = firstInd; i < StringLength - 1; i++)
if (nick[i] != 0)
break;
strdata = strdata.Take(strdata.Length - 1).ToArray();
}
strdata.CopyTo(nick, 0);
}
}
public override string OT_Name
{
get { return PKX.getG1Str(otname, Japanese); }
set
{
byte[] strdata = PKX.setG1Str(value, Japanese);
if (strdata.Length > StringLength)
throw new ArgumentOutOfRangeException($"OT Name {value} too long for given PK1");
if (otname.Any(b => b == 0) && otname[StringLength - 1] == 0x50 && Array.FindIndex(otname, b => b == 0) == strdata.Length - 1) // Handle JP Mew event with grace
{
int firstInd = Array.FindIndex(otname, b => b == 0);
for (int i = firstInd; i < StringLength - 1; i++)
if (otname[i] != 0)
break;
strdata = strdata.Take(strdata.Length - 1).ToArray();
}
strdata.CopyTo(otname, 0);
}
}
public override byte[] Encrypt()
{
// Oh god this is such total abuse of what this method is meant to do
// Please forgive me
return new PokemonList1(this).GetBytes();
}
// Please forgive me.
public override byte[] EncryptedPartyData => Encrypt().ToArray();
public override byte[] EncryptedBoxData => Encrypt().ToArray();
public override byte[] DecryptedBoxData => Encrypt().ToArray();
public override byte[] DecryptedPartyData => Encrypt().ToArray();
public override bool IsNicknamed
{
get
{
string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper();
return
!nick.SequenceEqual(
PKX.setG1Str(spName, Japanese)
.Concat(Enumerable.Repeat((byte) 0x50, StringLength - spName.Length - 1)));
}
set { }
}
public void setNotNicknamed()
{
string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper();
nick = PKX.setG1Str(spName, Japanese).Concat(Enumerable.Repeat((byte)0x50, StringLength - spName.Length - 1)).ToArray();
}
#region Stored Attributes
public override int Species
{
get { return PKX.getG1Species(Data[0]); }
set
{
// Before updating catch rate, check if Special Yellow Version Pikachu
if (!(PKX.getG1Species(Data[0]) == 25 && value == 25 && Catch_Rate == 163))
Catch_Rate = PersonalTable.RBY[value].CatchRate;
Data[0] = (byte)PKX.setG1Species(value);
Type_A = PersonalTable.RBY[value].Types[0];
Type_B = PersonalTable.RBY[value].Types[1];
}
}
public override int Stat_HPCurrent { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x1); } }
public int Status_Condition { get { return Data[4]; } set { Data[4] = (byte)value; } }
public int Type_A { get { return Data[5]; } set { Data[5] = (byte)value; } }
public int Type_B { get { return Data[6]; } set { Data[6] = (byte)value; } }
public int Catch_Rate { get { return Data[7]; } set { Data[7] = (byte)value; } }
public override int Move1 { get { return Data[8]; } set { Data[8] = (byte) value; } }
public override int Move2 { get { return Data[9]; } set { Data[9] = (byte)value; } }
public override int Move3 { get { return Data[10]; } set { Data[10] = (byte)value; } }
public override int Move4 { get { return Data[11]; } set { Data[11] = (byte)value; } }
public override int TID { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0xC)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0xC); } }
public override uint EXP
{
get { return (Util.SwapEndianness(BitConverter.ToUInt32(Data, 0xE)) >> 8) & 0x00FFFFFF; }
set { Array.Copy(BitConverter.GetBytes(Util.SwapEndianness((value << 8) & 0xFFFFFF00)), 0, Data, 0xE, 3); }
}
public override int EV_HP { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x11)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x11); } }
public override int EV_ATK { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x13)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x13); } }
public override int EV_DEF { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x15)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x15); } }
public override int EV_SPE { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x17)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x17); } }
public int EV_SPC { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x19)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x19); } }
public override int EV_SPA { get { return EV_SPC; } set { EV_SPC = value; } }
public override int EV_SPD { get { return EV_SPC; } set { } }
public ushort DV16 { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1B)); } set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x1B); } }
public override int IV_HP { get { return ((IV_ATK & 1) << 3) | ((IV_DEF & 1) << 2) | ((IV_SPE & 1) << 1) | ((IV_SPC & 1) << 0); } set { } }
public override int IV_ATK { get { return (DV16 >> 12) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 12)) | (ushort)((value > 0xF ? 0xF : value) << 12)); } }
public override int IV_DEF { get { return (DV16 >> 8) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 8)) | (ushort)((value > 0xF ? 0xF : value) << 8)); } }
public override int IV_SPE { get { return (DV16 >> 4) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 4)) | (ushort)((value > 0xF ? 0xF : value) << 4)); } }
public int IV_SPC { get { return (DV16 >> 0) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 0)) | (ushort)((value > 0xF ? 0xF : value) << 0)); } }
public override int IV_SPA { get { return IV_SPC; } set { IV_SPC = value; } }
public override int IV_SPD { get { return IV_SPC; } set { } }
public override int Move1_PP { get { return Data[0x1D] & 0x3F; } set { Data[0x1D] = (byte)((Data[0x1D] & 0xC0) | (value & 0x3F)); } }
public override int Move2_PP { get { return Data[0x1E] & 0x3F; } set { Data[0x1E] = (byte)((Data[0x1E] & 0xC0) | (value & 0x3F)); } }
public override int Move3_PP { get { return Data[0x1F] & 0x3F; } set { Data[0x1F] = (byte)((Data[0x1F] & 0xC0) | (value & 0x3F)); } }
public override int Move4_PP { get { return Data[0x20] & 0x3F; } set { Data[0x20] = (byte)((Data[0x20] & 0xC0) | (value & 0x3F)); } }
public override int Move1_PPUps { get { return (Data[0x1D] & 0xC0) >> 6; } set { Data[0x1D] = (byte)((Data[0x1D] & 0x3F) | ((value & 0x3) << 6)); } }
public override int Move2_PPUps { get { return (Data[0x1E] & 0xC0) >> 6; } set { Data[0x1E] = (byte)((Data[0x1E] & 0x3F) | ((value & 0x3) << 6)); } }
public override int Move3_PPUps { get { return (Data[0x1F] & 0xC0) >> 6; } set { Data[0x1F] = (byte)((Data[0x1F] & 0x3F) | ((value & 0x3) << 6)); } }
public override int Move4_PPUps { get { return (Data[0x20] & 0xC0) >> 6; } set { Data[0x20] = (byte)((Data[0x20] & 0x3F) | ((value & 0x3) << 6)); } }
#endregion
#region Party Attributes
public override int Stat_Level
{
get { return Data[0x21]; }
set { Data[0x21] = (byte)value; Data[0x3] = (byte)value; }
}
public override int Stat_HPMax { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x22)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x22); } }
public override int Stat_ATK { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x24)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x24); } }
public override int Stat_DEF { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x26)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x26); } }
public override int Stat_SPE { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x28)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x28); } }
public int Stat_SPC { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2A)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x2A); } }
// Leave SPA and SPD as alias for SPC
public override int Stat_SPA { get { return Stat_SPC; } set { Stat_SPC = value; } }
public override int Stat_SPD { get { return Stat_SPC; } set { } }
#endregion
public override ushort[] getStats(PersonalInfo p)
{
ushort[] Stats = new ushort[6];
for (int i = 0; i < Stats.Length; i++)
{
ushort L = (ushort)Stat_Level;
ushort B = (ushort)p.Stats[i];
ushort I = (ushort)IVs[i];
ushort E = // Fixed formula via http://www.smogon.com/ingame/guides/rby_gsc_stats
(ushort)Math.Floor(Math.Min(255, Math.Floor(Math.Sqrt(Math.Max(0, EVs[i] - 1)) + 1)) / 4.0);
Stats[i] = (ushort)Math.Floor((2 * (B + I) + E) * L / 100.0 + 5);
}
Stats[0] += (ushort)(5 + Stat_Level); // HP
return Stats;
}
#region Future, Unused Attributes
public override bool getGenderIsValid()
{
return true;
}
public override uint EncryptionConstant { get { return 0; } set { } }
public override uint PID { get { return 0; } set { } }
public override int Met_Level { get { return 0; } set { } }
public override int Nature { get { return 0; } set { } }
public override int AltForm { get { return 0; } set { } }
public override bool IsEgg { get { return false; } set { } }
public override int Gender { get { return 0; } set { } }
public override int HeldItem { get { return 0; } set { } }
public override bool CanHoldItem(ushort[] ValidArray)
{
return false;
}
public override ushort Sanity { get { return 0; } set { } }
public override bool ChecksumValid => true;
public override ushort Checksum { get { return 0; } set { } }
public override int Language { get { return 0; } set { } }
public override bool FatefulEncounter { get { return false; } set { } }
public override int TSV => 0x0000;
public override int PSV => 0xFFFF;
public override int Characteristic => -1;
public override byte MarkByte { get { return 0; } protected set { } }
public override int CurrentFriendship { get { return 0; } set { } }
public override int Ability { get { return 0; } set { } }
public override int CurrentHandler { get { return 0; } set { } }
public override int Met_Location { get { return 0; } set { } }
public override int Egg_Location { get { return 0; } set { } }
public override int OT_Friendship { get { return 0; } set { } }
public override int OT_Gender { get { return 0; } set { } }
public override int Ball { get { return 0; } set { } }
public override int Version { get { return 0; } set { } }
public override int SID { get { return 0; } set { } }
public override int PKRS_Strain { get { return 0; } set { } }
public override int PKRS_Days { get { return 0; } set { } }
public override int CNT_Cool { get { return 0; } set { } }
public override int CNT_Beauty { get { return 0; } set { } }
public override int CNT_Cute { get { return 0; } set { } }
public override int CNT_Smart { get { return 0; } set { } }
public override int CNT_Tough { get { return 0; } set { } }
public override int CNT_Sheen { get { return 0; } set { } }
#endregion
}
class PokemonList1
{
internal const int CAPACITY_DAYCARE = 1;
internal const int CAPACITY_PARTY = 6;
internal const int CAPACITY_STORED = 20;
internal const int CAPACITY_STORED_JP = 30;
private bool Japanese;
private int StringLength => Japanese ? PK1.STRLEN_J : PK1.STRLEN_U;
internal static readonly byte[] EMPTY_LIST = { 0x01, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50 };
public enum CapacityType
{
Daycare = CAPACITY_DAYCARE,
Party = CAPACITY_PARTY,
Stored = CAPACITY_STORED,
StoredJP = CAPACITY_STORED_JP,
Single
}
public static int getEntrySize(CapacityType c)
{
return c == CapacityType.Single || c == CapacityType.Party
? PKX.SIZE_1PARTY
: PKX.SIZE_1STORED;
}
public static byte getCapacity(CapacityType c)
{
return c == CapacityType.Single ? (byte)1 : (byte)c;
}
private byte[] getEmptyList(CapacityType c, bool is_JP = false)
{
int cap = getCapacity(c);
return new[] { (byte)0 }.Concat(Enumerable.Repeat((byte)0xFF, cap + 1)).Concat(Enumerable.Repeat((byte)0, getEntrySize(c) * cap)).Concat(Enumerable.Repeat((byte)0x50, (is_JP ? PK1.STRLEN_J : PK1.STRLEN_U) * 2 * cap)).ToArray();
}
public PokemonList1(byte[] d, CapacityType c = CapacityType.Single, bool jp = false)
{
Japanese = jp;
Data = d ?? getEmptyList(c, Japanese);
Capacity = getCapacity(c);
Entry_Size = getEntrySize(c);
if (Data.Length != DataSize)
{
Array.Resize(ref Data, DataSize);
}
Pokemon = new PK1[Capacity];
for (int i = 0; i < Capacity; i++)
{
int base_ofs = 2 + Capacity;
byte[] dat = Data.Skip(base_ofs + Entry_Size * i).Take(Entry_Size).ToArray();
Pokemon[i] = new PK1(dat, null, jp);
Pokemon[i].otname = Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * i).Take(StringLength).ToArray();
Pokemon[i].nick = Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * Capacity + StringLength * i).Take(StringLength).ToArray();
}
}
public PokemonList1(CapacityType c = CapacityType.Single, bool jp = false)
: this(null, c, jp)
{
Count = 1;
}
public PokemonList1(PK1 pk)
: this(CapacityType.Single, pk.Japanese)
{
this[0] = pk;
Count = 1;
}
private readonly byte[] Data;
private readonly byte Capacity;
private readonly int Entry_Size;
public byte Count
{
get { return Data[0]; }
set { Data[0] = value > Capacity ? Capacity : value; }
}
public int GetCapacity()
{
return Capacity;
}
public readonly PK1[] Pokemon;
public PK1 this[int i]
{
get
{
if (i > Capacity || i < 0) throw new IndexOutOfRangeException($"Invalid PokemonList Access: {i}");
return Pokemon[i];
}
set
{
if (value == null) return;
Pokemon[i] = (PK1)(((PK1)value).Clone());
}
}
private void Update()
{
if (Pokemon.Any(pk => (pk.Species == 0)))
Count = (byte) Array.FindIndex(Pokemon, pk => (pk.Species == 0));
else
Count = Capacity;
for (int i = 0; i < Count; i++)
{
Data[1 + i] = (byte)PKX.setG1Species(Pokemon[i].Species);
Array.Copy(Pokemon[i].Data, 0, Data, 2 + Capacity + Entry_Size * i, Entry_Size);
Array.Copy(Pokemon[i].OT_Name_Raw, 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * i, StringLength);
Array.Copy(Pokemon[i].Nickname_Raw, 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * Capacity + StringLength * i, StringLength);
}
Data[1 + Count] = byte.MaxValue;
}
public byte[] GetBytes()
{
Update();
return Data;
}
private int DataSize => Capacity * (Entry_Size + 1 + 2 * StringLength) + 2;
public static int GetDataLength(CapacityType c, bool jp = false)
{
return getCapacity(c) * (getEntrySize(c) + 1 + 2 * (jp ? PK1.STRLEN_J : PK1.STRLEN_U)) + 2;
}
}
}

View file

@ -16,10 +16,10 @@ namespace PKHeX
public int Box { get; set; } = -1; // Batch Editor
public int Slot { get; set; } = -1; // Batch Editor
public byte[] EncryptedPartyData => Encrypt().Take(SIZE_PARTY).ToArray();
public byte[] EncryptedBoxData => Encrypt().Take(SIZE_STORED).ToArray();
public byte[] DecryptedPartyData => Write().Take(SIZE_PARTY).ToArray();
public byte[] DecryptedBoxData => Write().Take(SIZE_STORED).ToArray();
public virtual byte[] EncryptedPartyData => Encrypt().Take(SIZE_PARTY).ToArray();
public virtual byte[] EncryptedBoxData => Encrypt().Take(SIZE_STORED).ToArray();
public virtual byte[] DecryptedPartyData => Write().Take(SIZE_PARTY).ToArray();
public virtual byte[] DecryptedBoxData => Write().Take(SIZE_STORED).ToArray();
protected ushort CalculateChecksum()
{
@ -250,7 +250,7 @@ namespace PKHeX
}
public bool PKRS_Infected => PKRS_Strain > 0;
public bool PKRS_Cured => PKRS_Days == 0 && PKRS_Strain > 0;
public bool ChecksumValid => Checksum == CalculateChecksum();
public virtual bool ChecksumValid => Checksum == CalculateChecksum();
public int CurrentLevel => PKX.getLevel(Species, EXP);
public bool MarkCircle { get { return (MarkByte & (1 << 0)) == 1 << 0; } set { MarkByte = (byte)(MarkByte & ~(1 << 0) | (value ? 1 << 0 : 0)); } }
public bool MarkTriangle { get { return (MarkByte & (1 << 1)) == 1 << 1; } set { MarkByte = (byte)(MarkByte & ~(1 << 0) | (value ? 1 << 0 : 0)); } }
@ -261,7 +261,7 @@ namespace PKHeX
public Image Sprite => PKX.getSprite(this);
public string ShowdownText => ShowdownSet.getShowdownText(this);
public string[] QRText => PKX.getQRText(this);
public string FileName => $"{Species.ToString("000")}{(IsShiny ? " " : "")} - {Nickname} - {Checksum.ToString("X4")}{EncryptionConstant.ToString("X8")}.{Extension}";
public virtual string FileName => $"{Species.ToString("000")}{(IsShiny ? " " : "")} - {Nickname} - {Checksum.ToString("X4")}{EncryptionConstant.ToString("X8")}.{Extension}";
public int[] IVs
{
get { return new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; }
@ -402,7 +402,7 @@ namespace PKHeX
}
}
public ushort[] getStats(PersonalInfo p)
public virtual ushort[] getStats(PersonalInfo p)
{
int level = CurrentLevel;
ushort[] Stats = new ushort[6];

View file

@ -31,6 +31,9 @@ namespace PKHeX
switch (data.Length)
{
case PKX.SIZE_1JLIST:
case PKX.SIZE_1ULIST:
return 1;
case PKX.SIZE_3PARTY:
case PKX.SIZE_3STORED:
return 3;
@ -70,6 +73,11 @@ namespace PKHeX
checkEncrypted(ref data);
switch (getPKMDataFormat(data))
{
case 1:
var PL = new PokemonList1(data, PokemonList1.CapacityType.Single, data.Length == PKX.SIZE_1JLIST);
if (ident != null)
PL[0].Identifier = ident;
return PL[0];
case 3:
return new PK3(data, ident);
case 4:
@ -101,6 +109,17 @@ namespace PKHeX
+ "Desired Format: " + Format;
return null;
}
if ((pk.Format == 1 || pk.Format == 2) && 2 < Format && Format < 7)
{
comment = $"Cannot convert a PK{pk.Format} to a PK{Format}.";
return null;
}
if (pk.Format == 1 && Format == 7)
{
comment = "PK1 to PK7 conversion is not yet supported." + Environment.NewLine
+ "Please wait for Sun/Moon to release and documentation to occur.";
return null;
}
string currentFormat = pk.Format.ToString();
PKM pkm = pk.Clone();
if (pkm.IsEgg) // force hatch
@ -130,6 +149,7 @@ namespace PKHeX
ushort chk = 0;
switch (format)
{
case 1:
case 3: // TOneverDO, nobody exports encrypted pk3s
return;
case 4:

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
@ -9,6 +10,11 @@ namespace PKHeX
{
public static class PKX
{
internal const int SIZE_1ULIST = 69;
internal const int SIZE_1JLIST = 59;
internal const int SIZE_1PARTY = 44;
internal const int SIZE_1STORED = 33;
internal const int SIZE_3PARTY = 100;
internal const int SIZE_3STORED = 80;
internal const int SIZE_3BLOCK = 12;
@ -32,7 +38,7 @@ namespace PKHeX
/// <returns>A boolean indicating whether or not the length is valid for a Pokemon file.</returns>
public static bool getIsPKM(long len)
{
return new[] {SIZE_3STORED, SIZE_3PARTY, SIZE_4STORED, SIZE_4PARTY, SIZE_5PARTY, SIZE_6STORED, SIZE_6PARTY}.Contains((int)len);
return new[] {SIZE_1JLIST, SIZE_1ULIST, SIZE_3STORED, SIZE_3PARTY, SIZE_4STORED, SIZE_4PARTY, SIZE_5PARTY, SIZE_6STORED, SIZE_6PARTY}.Contains((int)len);
}
// C# PKX Function Library
@ -188,19 +194,30 @@ namespace PKHeX
public static readonly PersonalTable Personal = PersonalTable.AO;
// Stat Fetching
public static byte[] getRandomEVs()
public static uint[] getRandomEVs(int Generation = 6)
{
byte[] evs = new byte[6];
do {
evs[0] = (byte)Math.Min(Util.rnd32() % 300, 252); // bias two to get maybe 252
evs[1] = (byte)Math.Min(Util.rnd32() % 300, 252);
evs[2] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1]), 252);
evs[3] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2]), 252);
evs[4] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2] - evs[3]), 252);
evs[5] = (byte)Math.Min(510 - evs[0] - evs[1] - evs[2] - evs[3] - evs[4], 252);
} while (evs.Sum(b => b) > 510); // recalculate random EVs...
Util.Shuffle(evs);
return evs;
if (Generation > 2)
{
uint[] evs = new uint[6];
do
{
evs[0] = (byte)Math.Min(Util.rnd32() % 300, 252); // bias two to get maybe 252
evs[1] = (byte)Math.Min(Util.rnd32() % 300, 252);
evs[2] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1]), 252);
evs[3] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2]), 252);
evs[4] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2] - evs[3]), 252);
evs[5] = (byte)Math.Min(510 - evs[0] - evs[1] - evs[2] - evs[3] - evs[4], 252);
} while (evs.Sum(b => b) > 510); // recalculate random EVs...
Util.Shuffle(evs);
return evs;
}
else
{
uint[] evs = new uint[6];
for (int i = 0; i < evs.Length; i++)
evs[i] = Util.rnd32()%0x10000;
return evs;
}
}
public static int getLevel(int species, uint exp)
{
@ -1617,5 +1634,545 @@ namespace PKHeX
return 0xFFFF;
return arr[g3val];
}
#region Gen 1 Character Tables
internal static Dictionary<byte, string> RBY2U_U => new Dictionary<byte, string>{
{0x50, "\0"},
{0x5D, "[TRAINER]"},
{0x7F, " "},
{0x80, "A"},
{0x81, "B"},
{0x82, "C"},
{0x83, "D"},
{0x84, "E"},
{0x85, "F"},
{0x86, "G"},
{0x87, "H"},
{0x88, "I"},
{0x89, "J"},
{0x8A, "K"},
{0x8B, "L"},
{0x8C, "M"},
{0x8D, "N"},
{0x8E, "O"},
{0x8F, "P"},
{0x90, "Q"},
{0x91, "R"},
{0x92, "S"},
{0x93, "T"},
{0x94, "U"},
{0x95, "V"},
{0x96, "W"},
{0x97, "X"},
{0x98, "Y"},
{0x99, "Z"},
{0x9A, "["},
{0x9B, "\\"},
{0x9C, "]"},
{0x9D, "^"},
{0x9E, "_"},
{0x9F, "`"},
{0xA0, "a"},
{0xA1, "b"},
{0xA2, "c"},
{0xA3, "d"},
{0xA4, "e"},
{0xA5, "f"},
{0xA6, "g"},
{0xA7, "h"},
{0xA8, "i"},
{0xA9, "j"},
{0xAA, "k"},
{0xAB, "l"},
{0xAC, "m"},
{0xAD, "n"},
{0xAE, "o"},
{0xAF, "p"},
{0xB0, "q"},
{0xB1, "r"},
{0xB2, "s"},
{0xB3, "t"},
{0xB4, "u"},
{0xB5, "v"},
{0xB6, "w"},
{0xB7, "x"},
{0xB8, "y"},
{0xB9, "z"},
{0xE1, "{"}, /* Pk */
{0xE2, "}"}, /* Mn */
{0xE3, "-"},
{0xE6, "?"},
{0xE7, "!"},
{0xEF, "♂"},
{0xF2, "."},
{0xF3, "/"},
{0xF4, ","},
{0xF5, "♀"},
{0xF6, "0"},
{0xF7, "1"},
{0xF8, "2"},
{0xF9, "3"},
{0xFA, "4"},
{0xFB, "5"},
{0xFC, "6"},
{0xFD, "7"},
{0xFE, "8"},
{0xFF, "9"}
};
internal static Dictionary<string, byte> U2RBY_U => new Dictionary<string, byte> {
{"\0", 0x50},
{"[TRAINER]", 0x5D},
{" ", 0x7F},
{"A", 0x80},
{"B", 0x81},
{"C", 0x82},
{"D", 0x83},
{"E", 0x84},
{"F", 0x85},
{"G", 0x86},
{"H", 0x87},
{"I", 0x88},
{"J", 0x89},
{"K", 0x8A},
{"L", 0x8B},
{"M", 0x8C},
{"N", 0x8D},
{"O", 0x8E},
{"P", 0x8F},
{"Q", 0x90},
{"R", 0x91},
{"S", 0x92},
{"T", 0x93},
{"U", 0x94},
{"V", 0x95},
{"W", 0x96},
{"X", 0x97},
{"Y", 0x98},
{"Z", 0x99},
{"[", 0x9A},
{"\\", 0x9B},
{"]", 0x9C},
{"^", 0x9D},
{"_", 0x9E},
{"`", 0x9F},
{"a", 0xA0},
{"b", 0xA1},
{"c", 0xA2},
{"d", 0xA3},
{"e", 0xA4},
{"f", 0xA5},
{"g", 0xA6},
{"h", 0xA7},
{"i", 0xA8},
{"j", 0xA9},
{"k", 0xAA},
{"l", 0xAB},
{"m", 0xAC},
{"n", 0xAD},
{"o", 0xAE},
{"p", 0xAF},
{"q", 0xB0},
{"r", 0xB1},
{"s", 0xB2},
{"t", 0xB3},
{"u", 0xB4},
{"v", 0xB5},
{"w", 0xB6},
{"x", 0xB7},
{"y", 0xB8},
{"z", 0xB9},
{"{", 0xE1}, /* Pk */
{"}", 0xE2}, /* Mn */
{"-", 0xE3},
{"?", 0xE6},
{"!", 0xE7},
{"♂", 0xEF},
{".", 0xF2},
{"/", 0xF3},
{",", 0xF4},
{"♀", 0xF5},
{"0", 0xF6},
{"1", 0xF7},
{"2", 0xF8},
{"3", 0xF9},
{"4", 0xFA},
{"5", 0xFB},
{"6", 0xFC},
{"7", 0xFD},
{"8", 0xFE},
{"9", 0xFF}
};
internal static Dictionary<string, byte> U2RBY_J => new Dictionary<string, byte> {
{"ガ", 0x05},
{"ギ", 0x06},
{"グ", 0x07},
{"ゲ", 0x08},
{"ゴ", 0x09},
{"ザ", 0x0A},
{"ジ", 0x0B},
{"ズ", 0x0C},
{"ゼ", 0x0D},
{"ゾ", 0x0E},
{"ダ", 0x0F},
{"ヂ", 0x10},
{"ヅ", 0x11},
{"デ", 0x12},
{"ド", 0x13},
{"バ", 0x19},
{"ビ", 0x1A},
{"ブ", 0x1B},
{"ボ", 0x1C},
{"が", 0x26},
{"ぎ", 0x27},
{"ぐ", 0x28},
{"げ", 0x29},
{"ご", 0x2A},
{"ざ", 0x2B},
{"じ", 0x2C},
{"ず", 0x2D},
{"ぜ", 0x2E},
{"ぞ", 0x2F},
{"だ", 0x30},
{"ぢ", 0x31},
{"づ", 0x32},
{"で", 0x33},
{"ど", 0x34},
{"ば", 0x3A},
{"び", 0x3B},
{"ぶ", 0x3C},
{"ベ", 0x3D},
{"べ", 0x3D},
{"ぼ", 0x3E},
{"パ", 0x40},
{"ピ", 0x41},
{"プ", 0x42},
{"ポ", 0x43},
{"ぱ", 0x44},
{"ぴ", 0x45},
{"ぷ", 0x46},
{"ぺ", 0x47},
{"ペ", 0x47},
{"ぽ", 0x48},
{"\0", 0x50},
{"トレーナー", 0x5D},
{"ア", 0x80},
{"イ", 0x81},
{"ウ", 0x82},
{"ェ", 0x83},
{"エ", 0x83},
{"オ", 0x84},
{"ォ", 0x84},
{"カ", 0x85},
{"キ", 0x86},
{"ク", 0x87},
{"ケ", 0x88},
{"コ", 0x89},
{"サ", 0x8A},
{"シ", 0x8B},
{"ス", 0x8C},
{"セ", 0x8D},
{"ソ", 0x8E},
{"タ", 0x8F},
{"チ", 0x90},
{"ツ", 0x91},
{"テ", 0x92},
{"ト", 0x93},
{"ナ", 0x94},
{"ニ", 0x95},
{"ヌ", 0x96},
{"ネ", 0x97},
{"", 0x98},
{"ハ", 0x99},
{"ヒ", 0x9A},
{"フ", 0x9B},
{"ホ", 0x9C},
{"マ", 0x9D},
{"ミ", 0x9E},
{"ム", 0x9F},
{"メ", 0xA0},
{"モ", 0xA1},
{"ヤ", 0xA2},
{"ユ", 0xA3},
{"ヨ", 0xA4},
{"ラ", 0xA5},
{"ル", 0xA6},
{"レ", 0xA7},
{"ロ", 0xA8},
{"ワ", 0xA9},
{"ヲ", 0xAA},
{"ン", 0xAB},
{"ッ", 0xAC},
{"ャ", 0xAD},
{"ュ", 0xAE},
{"ョ", 0xAF},
{"ィ", 0xB0},
{"あ", 0xB1},
{"い", 0xB2},
{"う", 0xB3},
{"え", 0xB4},
{"お", 0xB5},
{"か", 0xB6},
{"き", 0xB7},
{"く", 0xB8},
{"け", 0xB9},
{"こ", 0xBA},
{"さ", 0xBB},
{"し", 0xBC},
{"す", 0xBD},
{"せ", 0xBE},
{"そ", 0xBF},
{"た", 0xC0},
{"ち", 0xC1},
{"つ", 0xC2},
{"て", 0xC3},
{"と", 0xC4},
{"な", 0xC5},
{"に", 0xC6},
{"ぬ", 0xC7},
{"ね", 0xC8},
{"の", 0xC9},
{"は", 0xCA},
{"ひ", 0xCB},
{"ふ", 0xCC},
{"へ", 0xCD},
{"ほ", 0xCE},
{"ま", 0xCF},
{"み", 0xD0},
{"む", 0xD1},
{"め", 0xD2},
{"も", 0xD3},
{"や", 0xD4},
{"ゆ", 0xD5},
{"よ", 0xD6},
{"ら", 0xD7},
{"リ", 0xD8},
{"り", 0xD8},
{"る", 0xD9},
{"れ", 0xDA},
{"ろ", 0xDB},
{"わ", 0xDC},
{"を", 0xDD},
{"ん", 0xDE},
{"っ", 0xDF},
{"ゃ", 0xE0},
{"ゅ", 0xE1},
{"ょ", 0xE2},
{"ー", 0xE3},
{"ァ", 0xE9},
{"♂", 0xEF},
{"♀", 0xF5}
};
static Dictionary<byte, string> RBY2U_J => new Dictionary<byte, string> {
{0x05, "ガ"},
{0x06, "ギ"},
{0x07, "グ"},
{0x08, "ゲ"},
{0x09, "ゴ"},
{0x0A, "ザ"},
{0x0B, "ジ"},
{0x0C, "ズ"},
{0x0D, "ゼ"},
{0x0E, "ゾ"},
{0x0F, "ダ"},
{0x10, "ヂ"},
{0x11, "ヅ"},
{0x12, "デ"},
{0x13, "ド"},
{0x19, "バ"},
{0x1A, "ビ"},
{0x1B, "ブ"},
{0x1C, "ボ"},
{0x26, "が"},
{0x27, "ぎ"},
{0x28, "ぐ"},
{0x29, "げ"},
{0x2A, "ご"},
{0x2B, "ざ"},
{0x2C, "じ"},
{0x2D, "ず"},
{0x2E, "ぜ"},
{0x2F, "ぞ"},
{0x30, "だ"},
{0x31, "ぢ"},
{0x32, "づ"},
{0x33, "で"},
{0x34, "ど"},
{0x3A, "ば"},
{0x3B, "び"},
{0x3C, "ぶ"},
{0x3D, "ベ"},
{0x3E, "ぼ"},
{0x40, "パ"},
{0x41, "ピ"},
{0x42, "プ"},
{0x43, "ポ"},
{0x44, "ぱ"},
{0x45, "ぴ"},
{0x46, "ぷ"},
{0x47, "ペ"},
{0x48, "ぽ"},
{0x50, "\0"},
{0x5D, "トレーナー"},
{0x80, "ア"},
{0x81, "イ"},
{0x82, "ウ"},
{0x83, "ェ"},
{0x84, "オ"},
{0x85, "カ"},
{0x86, "キ"},
{0x87, "ク"},
{0x88, "ケ"},
{0x89, "コ"},
{0x8A, "サ"},
{0x8B, "シ"},
{0x8C, "ス"},
{0x8D, "セ"},
{0x8E, "ソ"},
{0x8F, "タ"},
{0x90, "チ"},
{0x91, "ツ"},
{0x92, "テ"},
{0x93, "ト"},
{0x94, "ナ"},
{0x95, "ニ"},
{0x96, "ヌ"},
{0x97, "ネ"},
{0x98, ""},
{0x99, "ハ"},
{0x9A, "ヒ"},
{0x9B, "フ"},
{0x9C, "ホ"},
{0x9D, "マ"},
{0x9E, "ミ"},
{0x9F, "ム"},
{0xA0, "メ"},
{0xA1, "モ"},
{0xA2, "ヤ"},
{0xA3, "ユ"},
{0xA4, "ヨ"},
{0xA5, "ラ"},
{0xA6, "ル"},
{0xA7, "レ"},
{0xA8, "ロ"},
{0xA9, "ワ"},
{0xAA, "ヲ"},
{0xAB, "ン"},
{0xAC, "ッ"},
{0xAD, "ャ"},
{0xAE, "ュ"},
{0xAF, "ョ"},
{0xB0, "ィ"},
{0xB1, "あ"},
{0xB2, "い"},
{0xB3, "う"},
{0xB4, "え"},
{0xB5, "お"},
{0xB6, "か"},
{0xB7, "き"},
{0xB8, "く"},
{0xB9, "け"},
{0xBA, "こ"},
{0xBB, "さ"},
{0xBC, "し"},
{0xBD, "す"},
{0xBE, "せ"},
{0xBF, "そ"},
{0xC0, "た"},
{0xC1, "ち"},
{0xC2, "つ"},
{0xC3, "て"},
{0xC4, "と"},
{0xC5, "な"},
{0xC6, "に"},
{0xC7, "ぬ"},
{0xC8, "ね"},
{0xC9, "の"},
{0xCA, "は"},
{0xCB, "ひ"},
{0xCC, "ふ"},
{0xCD, "へ"},
{0xCE, "ほ"},
{0xCF, "ま"},
{0xD0, "み"},
{0xD1, "む"},
{0xD2, "め"},
{0xD3, "も"},
{0xD4, "や"},
{0xD5, "ゆ"},
{0xD6, "よ"},
{0xD7, "ら"},
{0xD8, "リ"},
{0xD9, "る"},
{0xDA, "れ"},
{0xDB, "ろ"},
{0xDC, "わ"},
{0xDD, "を"},
{0xDE, "ん"},
{0xDF, "っ"},
{0xE0, "ゃ"},
{0xE1, "ゅ"},
{0xE2, "ょ"},
{0xE3, "ー"},
{0xE9, "ァ"},
{0xEF, "♂"},
{0xF5, "♀"}
};
#endregion
#region Gen 1 Item Table
public static string[] getG1ItemList()
{
return new[] { "(None)", "Master Ball", "Ultra Ball", "Great Ball", "Poké Ball", "Town Map", "Bicycle", "????? (7)", "Safari Ball", "Pokédex", "Moon Stone", "Antidote", "Burn Heal", "Ice Heal", "Awakening", "Parlyz Heal", "Full Restore", "Max Potion", "Hyper Potion", "Super Potion", "Potion", "BoulderBadge", "CascadeBadge", "ThunderBadge", "RainbowBadge", "SoulBadge", "MarshBadge", "VolcanoBadge", "EarthBadge", "Escape Rope", "Repel", "Old Amber", "Fire Stone", "Thunder Stone", "Water Stone", "HP Up", "Protein", "Iron", "Carbos", "Calcium", "Rare Candy", "Dome Fossil", "Helix Fossil", "Secret Key", "????? (44)", "Bike Voucher", "X Accuracy", "Leaf Stone", "Card Key", "Nugget", "PP Up (Unused)", "Poké Doll", "Full Heal", "Revive", "Max Revive", "Guard Spec.", "Super Repel", "Max Repel", "Dire Hit", "Coin", "Fresh Water", "Soda Pop", "Lemonade", "S.S. Ticket", "Gold Teeth", "X Attack", "X Defend", "X Speed", "X Special", "Coin Case", "Oak's Parcel", "Itemfinder", "Silph Scope", "Poké Flute", "Lift Key", "Exp. All", "Old Rod", "Good Rod", "Super Rod", "PP Up", "Ether", "Max Ether", "Elixer", "Max Elixer", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "HM01", "HM02", "HM03", "HM04", "HM05", "TM01", "TM02", "TM03", "TM04", "TM05", "TM06", "TM07", "TM08", "TM09", "TM10", "TM11", "TM12", "TM13", "TM14", "TM15", "TM16", "TM17", "TM18", "TM19", "TM20", "TM21", "TM22", "TM23", "TM24", "TM25", "TM26", "TM27", "TM28", "TM29", "TM30", "TM31", "TM32", "TM33", "TM34", "TM35", "TM36", "TM37", "TM38", "TM39", "TM40", "TM41", "TM42", "TM43", "TM44", "TM45", "TM46", "TM47", "TM48", "TM49", "TM50", "TM51", "TM52", "TM53", "TM54", "TM55" };
}
#endregion
public static int[] getG1LegalItems()
{
return Enumerable.Range(0, 7) // 0-6
.Concat(Enumerable.Range(10, 11)) // 10-20
.Concat(Enumerable.Range(29, 15)) // 29-43
.Concat(Enumerable.Range(45, 5)) // 45-49
.Concat(Enumerable.Range(51, 8)) // 51-58
.Concat(Enumerable.Range(60, 24)) // 60-83
.Concat(Enumerable.Range(196, 54)) // 196-249
.ToArray();
}
public static int getG1Species(int raw_id)
{
int[] table = { 0x00, 0x70, 0x73, 0x20, 0x23, 0x15, 0x64, 0x22, 0x50, 0x02, 0x67, 0x6C, 0x66, 0x58, 0x5E, 0x1D, 0x1F, 0x68, 0x6F, 0x83, 0x3B, 0x97, 0x82, 0x5A, 0x48, 0x5C, 0x7B, 0x78, 0x09, 0x7F, 0x72, 0x00, 0x00, 0x3A, 0x5F, 0x16, 0x10, 0x4F, 0x40, 0x4B, 0x71, 0x43, 0x7A, 0x6A, 0x6B, 0x18, 0x2F, 0x36, 0x60, 0x4C, 0x00, 0x7E, 0x00, 0x7D, 0x52, 0x6D, 0x00, 0x38, 0x56, 0x32, 0x80, 0x00, 0x00, 0x00, 0x53, 0x30, 0x95, 0x00, 0x00, 0x00, 0x54, 0x3C, 0x7C, 0x92, 0x90, 0x91, 0x84, 0x34, 0x62, 0x00, 0x00, 0x00, 0x25, 0x26, 0x19, 0x1A, 0x00, 0x00, 0x93, 0x94, 0x8C, 0x8D, 0x74, 0x75, 0x00, 0x00, 0x1B, 0x1C, 0x8A, 0x8B, 0x27, 0x28, 0x85, 0x88, 0x87, 0x86, 0x42, 0x29, 0x17, 0x2E, 0x3D, 0x3E, 0x0D, 0x0E, 0x0F, 0x00, 0x55, 0x39, 0x33, 0x31, 0x57, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x44, 0x00, 0x37, 0x61, 0x2A, 0x96, 0x8F, 0x81, 0x00, 0x00, 0x59, 0x00, 0x63, 0x5B, 0x00, 0x65, 0x24, 0x6E, 0x35, 0x69, 0x00, 0x5D, 0x3F, 0x41, 0x11, 0x12, 0x79, 0x01, 0x03, 0x49, 0x00, 0x76, 0x77, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4E, 0x13, 0x14, 0x21, 0x1E, 0x4A, 0x89, 0x8E, 0x00, 0x51, 0x00, 0x00, 0x04, 0x07, 0x05, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x2C, 0x2D, 0x45, 0x46, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
return table[raw_id];
}
public static int setG1Species(int dex_id)
{
int[] table = { 0x00, 0x99, 0x09, 0x9A, 0xB0, 0xB2, 0xB4, 0xB1, 0xB3, 0x1C, 0x7B, 0x7C, 0x7D, 0x70, 0x71, 0x72, 0x24, 0x96, 0x97, 0xA5, 0xA6, 0x05, 0x23, 0x6C, 0x2D, 0x54, 0x55, 0x60, 0x61, 0x0F, 0xA8, 0x10, 0x03, 0xA7, 0x07, 0x04, 0x8E, 0x52, 0x53, 0x64, 0x65, 0x6B, 0x82, 0xB9, 0xBA, 0xBB, 0x6D, 0x2E, 0x41, 0x77, 0x3B, 0x76, 0x4D, 0x90, 0x2F, 0x80, 0x39, 0x75, 0x21, 0x14, 0x47, 0x6E, 0x6F, 0x94, 0x26, 0x95, 0x6A, 0x29, 0x7E, 0xBC, 0xBD, 0xBE, 0x18, 0x9B, 0xA9, 0x27, 0x31, 0xA3, 0xA4, 0x25, 0x08, 0xAD, 0x36, 0x40, 0x46, 0x74, 0x3A, 0x78, 0x0D, 0x88, 0x17, 0x8B, 0x19, 0x93, 0x0E, 0x22, 0x30, 0x81, 0x4E, 0x8A, 0x06, 0x8D, 0x0C, 0x0A, 0x11, 0x91, 0x2B, 0x2C, 0x0B, 0x37, 0x8F, 0x12, 0x01, 0x28, 0x1E, 0x02, 0x5C, 0x5D, 0x9D, 0x9E, 0x1B, 0x98, 0x2A, 0x1A, 0x48, 0x35, 0x33, 0x1D, 0x3C, 0x85, 0x16, 0x13, 0x4C, 0x66, 0x69, 0x68, 0x67, 0xAA, 0x62, 0x63, 0x5A, 0x5B, 0xAB, 0x84, 0x4A, 0x4B, 0x49, 0x58, 0x59, 0x42, 0x83, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
return table[dex_id];
}
public static string getG1Str(byte[] strdata, bool jp)
{
Dictionary<byte, string> dict = jp ? RBY2U_J : RBY2U_U;
return strdata
.TakeWhile(b => dict.ContainsKey(b))
.Select(b => dict[b])
.TakeWhile(s => s != "\0")
.Aggregate("", (current, cur) => current + cur);
}
public static byte[] setG1Str(string str, bool jp)
{
Dictionary<string, byte> dict = jp ? U2RBY_J : U2RBY_U;
if (dict.ContainsKey(str)) // Handle "[TRAINER]"
return new[] {dict[str], dict["\0"]};
return str
.TakeWhile(c => dict.ContainsKey(c.ToString()))
.Select(c => dict[c.ToString()])
.Concat(new[] {dict["\0"]})
.ToArray();
}
}
}

View file

@ -10,6 +10,9 @@
public abstract int SPE { get; set; }
public abstract int SPA { get; set; }
public abstract int SPD { get; set; }
public int[] Stats => new[] { HP, ATK, DEF, SPE, SPA, SPD };
public abstract int EV_HP { get; set; }
public abstract int EV_ATK { get; set; }
public abstract int EV_DEF { get; set; }

View file

@ -0,0 +1,69 @@
using System;
using System.Linq;
namespace PKHeX
{
public class PersonalInfoG1 : PersonalInfo
{
protected PersonalInfoG1() { }
public const int SIZE = 0x1C;
public PersonalInfoG1(byte[] data)
{
if (data.Length != SIZE)
return;
Data = data;
TMHM = getBits(Data.Skip(0x14).Take(0x8).ToArray());
}
public override byte[] Write()
{
setBits(TMHM).CopyTo(Data, 0x14);
return Data;
}
public int DEX_ID { get { return Data[0x00]; } set { Data[0x00] = (byte)value; } }
public override int HP { get { return Data[0x01]; } set { Data[0x01] = (byte)value; } }
public override int ATK { get { return Data[0x02]; } set { Data[0x02] = (byte)value; } }
public override int DEF { get { return Data[0x03]; } set { Data[0x03] = (byte)value; } }
public override int SPE { get { return Data[0x04]; } set { Data[0x04] = (byte)value; } }
public int SPC { get { return Data[0x05]; } set { Data[0x05] = (byte)value; } }
public override int SPA { get { return SPC; } set { SPC = value; } }
public override int SPD { get { return SPC; } set { SPC = value; } }
public override int[] Types
{
get { return new int[] { Data[0x06], Data[0x07] }; }
set
{
if (value?.Length != 2) return;
Data[0x06] = (byte)value[0];
Data[0x07] = (byte)value[1];
}
}
public override int CatchRate { get { return Data[0x08]; } set { Data[0x08] = (byte)value; } }
public override int BaseEXP { get { return Data[0x09]; } set { Data[0x09] = (byte)value; } }
public int Move1 { get { return Data[0x0A]; } set { Data[0x0A] = (byte)value; } }
public int Move2 { get { return Data[0x0B]; } set { Data[0x0B] = (byte)value; } }
public int Move3 { get { return Data[0x0C]; } set { Data[0x0C] = (byte)value; } }
public int Move4 { get { return Data[0x0D]; } set { Data[0x0D] = (byte)value; } }
public override int EXPGrowth { get { return Data[0x13]; } set { Data[0x13] = (byte)value; } }
// EV Yields are just aliases for base stats in Gen I
public override int EV_HP { get { return HP; } set { } }
public override int EV_ATK { get { return ATK; } set { } }
public override int EV_DEF { get { return DEF; } set { } }
public override int EV_SPE { get { return SPE; } set { } }
public int EV_SPC { get { return SPC; } set { } }
public override int EV_SPA { get { return EV_SPC; } set { } }
public override int EV_SPD { get { return EV_SPC; } set { } }
// Future game values, unused
public override int[] Items { get { return new[] { 0, 0 }; } set { } }
public override int[] EggGroups { get { return new[] { 0, 0 }; } set { } }
public override int[] Abilities { get { return new[] { 0, 0 }; } set { } }
public override int Gender { get { return 0; } set { } }
public override int HatchCycles { get { return 0; } set { } }
public override int BaseFriendship { get { return 0; } set { } }
public override int EscapeRate { get { return 0; } set { } }
public override int Color { get { return 0; } set { } }
}
}

View file

@ -15,6 +15,7 @@ namespace PKHeX
internal static readonly PersonalTable FR = new PersonalTable(Properties.Resources.personal_fr, GameVersion.FR);
internal static readonly PersonalTable E = new PersonalTable(Properties.Resources.personal_e, GameVersion.E);
internal static readonly PersonalTable RS = new PersonalTable(Properties.Resources.personal_rs, GameVersion.RS);
internal static readonly PersonalTable RBY = new PersonalTable(Properties.Resources.personal_rby, GameVersion.RBY);
private static byte[][] splitBytes(byte[] data, int size)
{
@ -31,6 +32,7 @@ namespace PKHeX
int size = 0;
switch (format)
{
case GameVersion.RBY: size = PersonalInfoG1.SIZE;break;
case GameVersion.RS:
case GameVersion.E:
case GameVersion.FR:
@ -52,6 +54,10 @@ namespace PKHeX
switch (format)
{
case GameVersion.RBY:
for (int i = 0; i < d.Length; i++)
d[i] = new PersonalInfoG1(entries[i]);
break;
case GameVersion.RS:
case GameVersion.E:
case GameVersion.FR:

View file

@ -15555,6 +15555,16 @@ namespace PKHeX.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] personal_rby {
get {
object obj = ResourceManager.GetObject("personal_rby", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>

Binary file not shown.

View file

@ -1,4 +1,5 @@
using System;
using System.Linq;
namespace PKHeX
{
@ -23,7 +24,8 @@ namespace PKHeX
public readonly InventoryType Type;
public readonly ushort[] LegalItems;
public readonly int MaxCount;
private readonly int Offset;
public int Count => Items.Count(it => it.Count > 0);
public readonly int Offset;
private readonly int PouchDataSize;
public uint SecurityKey { private get; set; } // = 0 // Gen3 Only
public InventoryItem[] Items;
@ -61,5 +63,43 @@ namespace PKHeX
BitConverter.GetBytes((ushort)((ushort)Items[i].Count ^ (ushort)SecurityKey)).CopyTo(Data, Offset + i*4 + 2);
}
}
public void getPouchG1(ref byte[] Data)
{
InventoryItem[] items = new InventoryItem[PouchDataSize];
int numStored = Data[Offset];
for (int i = 0; i < numStored; i++)
{
items[i] = new InventoryItem
{
Index = Data[Offset + i * 2 + 1],
Count = Data[Offset + i * 2 + 2]
};
}
for (int i = numStored; i < items.Length; i++)
{
items[i] = new InventoryItem
{
Index = 0,
Count = 0
};
}
Items = items;
}
public void setPouchG1(ref byte[] Data)
{
if (Items.Length != PouchDataSize)
throw new ArgumentException("Item array length does not match original pouch size.");
for (int i = 0; i < Items.Length; i++)
{
Data[Offset + i * 2 + 1] = (byte)Items[i].Index;
Data[Offset + i * 2 + 2] = (byte)Items[i].Count;
}
Data[Offset] = (byte) Count;
Data[Offset + 1 + 2*Count] = 0xFF;
}
}
}

522
PKHeX/Saves/SAV1.cs Normal file
View file

@ -0,0 +1,522 @@
using System;
using System.IO;
using System.Globalization;
using System.Linq;
namespace PKHeX
{
public sealed class SAV1 : SaveFile
{
public override string BAKName => $"{FileName} [{OT} ({Version})" +/* - {LastSavedTime}*/ "].bak";
public override string Filter => "SAV File|*.sav";
public override string Extension => ".sav";
public SAV1(byte[] data = null)
{
Data = data == null ? new byte[SaveUtil.SIZE_G1RAW] : (byte[])data.Clone();
BAK = (byte[])Data.Clone();
Exportable = !Data.SequenceEqual(new byte[Data.Length]);
if (data == null)
Version = GameVersion.RBY;
else Version = SaveUtil.getIsG1SAV(Data);
if (Version == GameVersion.Invalid)
return;
Box = Data.Length;
Array.Resize(ref Data, Data.Length + SIZE_RESERVED);
Party = getPartyOffset(0);
Japanese = SaveUtil.getIsG1SAVJ(data);
Personal = PersonalTable.RBY;
// Stash boxes after the save file's end.
byte[] TempBox = new byte[SIZE_STOREDBOX];
for (int i = 0; i < BoxCount; i++)
{
if (i < BoxCount / 2)
Array.Copy(Data, 0x4000 + i * TempBox.Length, TempBox, 0, TempBox.Length);
else
Array.Copy(Data, 0x6000 + (i - BoxCount / 2) * TempBox.Length, TempBox, 0, TempBox.Length);
PokemonList1 PL1 = new PokemonList1(TempBox, Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese);
for (int j = 0; j < PL1.Pokemon.Length; j++)
{
if (j < PL1.Count)
{
byte[] pkDat = new PokemonList1(PL1[j]).GetBytes();
pkDat.CopyTo(Data, Data.Length - SIZE_RESERVED + i * SIZE_BOX + j * SIZE_STORED);
}
else
{
byte[] pkDat = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Single, Japanese)];
pkDat.CopyTo(Data, Data.Length - SIZE_RESERVED + i * SIZE_BOX + j * SIZE_STORED);
}
}
}
Array.Copy(Data, Japanese ? 0x302D : 0x30C0, TempBox, 0, TempBox.Length);
PokemonList1 curBoxPL = new PokemonList1(TempBox, Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese);
for (int i = 0; i < curBoxPL.Pokemon.Length; i++)
{
if (i < curBoxPL.Count)
{
byte[] pkDat = new PokemonList1(curBoxPL[i]).GetBytes();
pkDat.CopyTo(Data, Data.Length - SIZE_RESERVED + CurrentBox * SIZE_BOX + i * SIZE_STORED);
}
else
{
byte[] pkDat = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Single, Japanese)];
pkDat.CopyTo(Data, Data.Length - SIZE_RESERVED + CurrentBox * SIZE_BOX + i * SIZE_STORED);
}
}
byte[] TempParty = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Party, Japanese)];
Array.Copy(Data, Japanese ? 0x2ED5 : 0x2F2C, TempParty, 0, TempParty.Length);
PokemonList1 partyList = new PokemonList1(TempParty, PokemonList1.CapacityType.Party, Japanese);
for (int i = 0; i < partyList.Pokemon.Length; i++)
{
if (i < partyList.Count)
{
byte[] pkDat = new PokemonList1(partyList[i]).GetBytes();
pkDat.CopyTo(Data, getPartyOffset(i));
}
else
{
byte[] pkDat = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Single, Japanese)];
pkDat.CopyTo(Data, getPartyOffset(i));
}
}
byte[] rawDC = new byte[0x38];
Array.Copy(Data, Japanese ? 0x2CA7 : 0x2CF4, rawDC, 0, rawDC.Length);
byte[] TempDaycare = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Single, Japanese)];
TempDaycare[0] = rawDC[0];
Array.Copy(rawDC, 1, TempDaycare, 2 + 1 + PKX.SIZE_1PARTY + StringLength, StringLength);
Array.Copy(rawDC, 1 + StringLength, TempDaycare, 2 + 1 + PKX.SIZE_1PARTY, StringLength);
Array.Copy(rawDC, 1 + 2 * StringLength, TempDaycare, 2 + 1, PKX.SIZE_1STORED);
PokemonList1 daycareList = new PokemonList1(TempDaycare, PokemonList1.CapacityType.Single, Japanese);
daycareList.GetBytes().CopyTo(Data, getPartyOffset(7));
Daycare = getPartyOffset(7);
// Enable Pokedex editing
PokeDex = 0;
if (!Exportable)
resetBoxes();
}
private const int SIZE_RESERVED = 0x8000; // unpacked box data
public override byte[] Write(bool DSV)
{
for (int i = 0; i < BoxCount; i++)
{
PokemonList1 boxPL = new PokemonList1(Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese);
int slot = 0;
for (int j = 0; j < boxPL.Pokemon.Length; j++)
{
PK1 boxPK = (PK1) getPKM(getData(getBoxOffset(i) + j*SIZE_STORED, SIZE_STORED));
if (boxPK.Species > 0)
boxPL[slot++] = boxPK;
}
if (i < BoxCount / 2)
boxPL.GetBytes().CopyTo(Data, 0x4000 + i * SIZE_STOREDBOX);
else
boxPL.GetBytes().CopyTo(Data, 0x6000 + (i - BoxCount / 2) * SIZE_STOREDBOX);
if (i == CurrentBox)
boxPL.GetBytes().CopyTo(Data, Japanese ? 0x302D : 0x30C0);
}
PokemonList1 partyPL = new PokemonList1(PokemonList1.CapacityType.Party, Japanese);
int pSlot = 0;
for (int i = 0; i < 6; i++)
{
PK1 partyPK = (PK1)getPKM(getData(getPartyOffset(i), SIZE_STORED));
if (partyPK.Species > 0)
partyPL[pSlot++] = partyPK;
}
partyPL.GetBytes().CopyTo(Data, Japanese ? 0x2ED5 : 0x2F2C);
// Daycare is read-only, but in case it ever becomes editable, copy it back in.
byte[] rawDC = getData(getDaycareSlotOffset(), SIZE_STORED);
byte[] dc = new byte[1 + 2*StringLength + PKX.SIZE_1STORED];
dc[0] = rawDC[0];
Array.Copy(rawDC, 2 + 1 + PKX.SIZE_1PARTY + StringLength, dc, 1, StringLength);
Array.Copy(rawDC, 2 + 1 + PKX.SIZE_1PARTY, dc, 1 + StringLength, StringLength);
Array.Copy(rawDC, 2 + 1, dc, 1 + 2*StringLength, PKX.SIZE_1STORED);
dc.CopyTo(Data, Japanese ? 0x2CA7 : 0x2CF4);
setChecksums();
byte[] outData = new byte[Data.Length - SIZE_RESERVED];
Array.Copy(Data, outData, outData.Length);
return outData;
}
// Configuration
public override SaveFile Clone() { return new SAV1(Data.Take(Data.Length - SIZE_RESERVED).ToArray()); }
public override int SIZE_STORED => Japanese ? PKX.SIZE_1JLIST : PKX.SIZE_1ULIST;
public override int SIZE_PARTY => Japanese ? PKX.SIZE_1JLIST : PKX.SIZE_1ULIST;
public int SIZE_BOX => BoxSlotCount*SIZE_STORED;
public int SIZE_STOREDBOX => PokemonList1.GetDataLength(Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese);
public override PKM BlankPKM => new PK1(null, null, Japanese);
protected override Type PKMType => typeof(PK1);
public override int MaxMoveID => 165;
public override int MaxSpeciesID => 151;
public override int MaxAbilityID => 0;
public override int MaxItemID => 255;
public override int MaxBallID => 0;
public override int MaxGameID => 99; // What do I set this to...?
public override int BoxCount => Japanese ? 8 : 12;
public override int MaxEV => 65535;
public override int MaxIV => 15;
public override int Generation => 1;
protected override int GiftCountMax => 0;
public override int OTLength => Japanese ? 5 : 10;
public override int NickLength => Japanese ? 5 : 10;
public override bool HasParty => true;
// Checksums
protected override void setChecksums()
{
int CHECKSUM_OFS = Japanese ? 0x3594 : 0x3523;
Data[CHECKSUM_OFS] = 0;
uint chksum = 0;
for (int i = 0x2598; i < CHECKSUM_OFS; i++)
{
chksum += Data[i];
}
chksum = ~chksum;
chksum &= 0xFF;
Data[CHECKSUM_OFS] = (byte)chksum;
}
public override bool ChecksumsValid
{
get
{
int CHECKSUM_OFS = Japanese ? 0x3594 : 0x3523;
Data[CHECKSUM_OFS] = 0;
uint chksum = 0;
for (int i = 0x2598; i < CHECKSUM_OFS; i++)
{
chksum += Data[i];
}
chksum = ~chksum;
chksum &= 0xFF;
return Data[CHECKSUM_OFS] == (byte)chksum;
}
}
public override string ChecksumInfo
{
get
{
return ChecksumsValid ? "Checksum valid." : "Checksum invalid";
}
}
// Trainer Info
public override GameVersion Version { get; protected set; }
private int StringLength => Japanese ? PK1.STRLEN_J : PK1.STRLEN_U;
public override string OT
{
get { return PKX.getG1Str(Data.Skip(0x2598).Take(StringLength).ToArray(), Japanese); }
set
{
byte[] strdata = PKX.setG1Str(value, Japanese);
if (strdata.Length > StringLength)
throw new ArgumentOutOfRangeException("OT Name too long for given save file.");
strdata.CopyTo(Data, 0x2598);
}
}
public override int Gender
{
get { return 0; }
set { }
}
public override ushort TID
{
get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, Japanese ? 0x25FB : 0x2605)); }
set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, Japanese ? 0x25FB : 0x2605); }
}
public override ushort SID
{
get { return 0; }
set { }
}
public override int PlayedHours
{
get { return BitConverter.ToUInt16(Data, Japanese ? 0x2CA0 : 0x2CED); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, Japanese ? 0x2CA0 : 0x2CED); }
}
public override int PlayedMinutes
{
get { return Data[Japanese ? 0x2CA2 : 0x2CEF]; }
set { Data[Japanese ? 0x2CA2 : 0x2CEF] = (byte)value; }
}
public override int PlayedSeconds
{
get { return Data[Japanese ? 0x2CA3 : 0x2CF0]; }
set { Data[Japanese ? 0x2CA3 : 0x2CF0] = (byte)value; }
}
public int Badges
{
get { return Data[Japanese ? 0x25F8 : 0x2602]; }
set { if (value < 0) return; Data[Japanese ? 0x25F8 : 0x2602] = (byte)value; }
}
private byte Options
{
get { return Data[Japanese ? 0x25F7 : 0x2601]; }
set { Data[Japanese ? 0x25F7 : 0x2601] = value; }
}
public bool BattleEffects
{
get { return (Options & 0x80) == 0; }
set { Options = (byte)((Options & 0x7F) | (value ? 0 : 0x80)); }
}
public bool BattleStyleSwitch
{
get { return (Options & 0x40) == 0; }
set { Options = (byte)((Options & 0xBF) | (value ? 0 : 0x40)); }
}
public int Sound
{
get { return (Options & 0x30) >> 4; }
set
{
var new_sound = value;
if (new_sound > 3)
new_sound = 3;
if (new_sound < 0)
new_sound = 0;
Options = (byte)((Options & 0xCF) | (new_sound << 4));
}
}
public int TextSpeed
{
get { return Options & 0x7; }
set
{
var new_speed = value;
if (new_speed > 7)
new_speed = 7;
if (new_speed < 0)
new_speed = 0;
Options = (byte)((Options & 0xF8) | new_speed);
}
}
public override uint Money
{
get { return uint.Parse((Util.SwapEndianness(BitConverter.ToUInt32(Data, Japanese ? 0x25EE : 0x25F3)) >> 8).ToString("X6")); }
set
{
BitConverter.GetBytes(Util.SwapEndianness(uint.Parse(value.ToString("000000"), NumberStyles.HexNumber))).Skip(1).ToArray().CopyTo(Data, Japanese ? 0x25EE : 0x25F3);
}
}
public uint Coin
{
get
{
return uint.Parse(Util.SwapEndianness(BitConverter.ToUInt16(Data, Japanese ? 0x2846 : 0x2850)).ToString("X4"));
}
set
{
BitConverter.GetBytes(Util.SwapEndianness(ushort.Parse(value.ToString("0000"), NumberStyles.HexNumber))).ToArray().CopyTo(Data, Japanese ? 0x2846 : 0x2850);
}
}
private readonly ushort[] LegalItems = PKX.getG1LegalItems().Select(i => (ushort)i).ToArray();
public override InventoryPouch[] Inventory
{
get
{
ushort[] legalItems = LegalItems;
InventoryPouch[] pouch =
{
new InventoryPouch(InventoryType.Items, legalItems, 99, (Japanese ? 0x25C4 : 0x25C9), 20),
new InventoryPouch(InventoryType.MailItems, legalItems, 99, (Japanese ? 0x27DC : 0x27E6), 50)
};
foreach (var p in pouch)
{
p.getPouchG1(ref Data);
}
return pouch;
}
set
{
foreach (var p in value)
{
int ofs = 0;
for (int i = 0; i < p.Count; i++)
{
while (p.Items[ofs].Count == 0)
ofs++;
p.Items[i] = p.Items[ofs++];
}
while (ofs < p.Items.Length)
p.Items[ofs++] = new InventoryItem { Count = 0, Index = 0 };
p.setPouchG1(ref Data);
}
}
}
public override int getDaycareSlotOffset(int loc = 0, int slot = 0)
{
return Daycare;
}
public override ulong? getDaycareRNGSeed(int loc)
{
return null;
}
public override uint? getDaycareEXP(int loc = 0, int slot = 0)
{
return null;
}
public override bool? getDaycareOccupied(int loc, int slot)
{
return null;
}
public override void setDaycareEXP(int loc, int slot, uint EXP)
{
}
public override void setDaycareOccupied(int loc, int slot, bool occupied)
{
}
// Storage
public override int BoxSlotCount => Japanese ? 30 : 20;
public override int PartyCount
{
get { return Data[Japanese ? 0x2ED5 : 0x2F2C]; }
protected set
{
Data[Japanese ? 0x2ED5 : 0x2F2C] = (byte)value;
}
}
public override int getBoxOffset(int box)
{
return Data.Length - SIZE_RESERVED + box * SIZE_BOX;
}
public override int getPartyOffset(int slot)
{
return Data.Length - SIZE_RESERVED + BoxCount * SIZE_BOX + slot * SIZE_STORED;
}
public override int CurrentBox
{
get { return Data[Japanese ? 0x2842 : 0x284C] & 0x7F; }
set { Data[Japanese ? 0x2842 : 0x284C] = (byte)((Data[Japanese ? 0x2842 : 0x284C] & 0x80) | (value & 0x7F)); }
}
public override int getBoxWallpaper(int box)
{
return 0;
}
public override string getBoxName(int box)
{
return string.Format("Box {0}", box + 1);
}
public override void setBoxName(int box, string value)
{
// Don't allow for custom box names
}
public override PKM getPKM(byte[] data)
{
if (data.Length == SIZE_STORED)
return new PokemonList1(data, PokemonList1.CapacityType.Single, Japanese)[0];
return new PK1(data);
}
public override byte[] decryptPKM(byte[] data)
{
return data;
}
public override bool getSeen(PKM pkm)
{
if (pkm.Species == 0)
return false;
if (pkm.Species > MaxSpeciesID)
return false;
if (Version == GameVersion.Unknown)
return false;
int bit = pkm.Species - 1;
int ofs = bit >> 3;
byte bitval = (byte)(1 << (bit & 7));
// Get the Seen Flag
return (Data[(Japanese ? 0x25B1 : 0x25B6) + ofs] & bitval) != 0;
}
public override bool getCaught(PKM pkm)
{
if (pkm.Species == 0)
return false;
if (pkm.Species > MaxSpeciesID)
return false;
if (Version == GameVersion.Unknown)
return false;
int bit = pkm.Species - 1;
int ofs = bit >> 3;
byte bitval = (byte)(1 << (bit & 7));
// Get the Caught Flag
return (Data[(Japanese ? 0x259E : 0x25A3) + ofs] & bitval) != 0;
}
protected internal override void setSeen(PKM pkm, bool seen)
{
if (pkm.Species == 0)
return;
if (pkm.Species > MaxSpeciesID)
return;
if (Version == GameVersion.Unknown)
return;
int bit = pkm.Species - 1;
int ofs = bit >> 3;
byte bitval = (byte)(1 << (bit & 7));
// Set the Seen Flag
Data[(Japanese ? 0x25B1 : 0x25B6) + ofs] &= (byte)(~bitval);
if (seen)
Data[(Japanese ? 0x25B1 : 0x25B6) + ofs] |= bitval;
}
protected internal override void setCaught(PKM pkm, bool caught)
{
if (pkm.Species == 0)
return;
if (pkm.Species > MaxSpeciesID)
return;
if (Version == GameVersion.Unknown)
return;
int bit = pkm.Species - 1;
int ofs = bit >> 3;
byte bitval = (byte)(1 << (bit & 7));
// Set the Captured Flag
Data[(Japanese ? 0x259E : 0x25A3) + ofs] &= (byte)(~bitval);
if (caught)
Data[(Japanese ? 0x259E : 0x25A3) + ofs] |= bitval;
}
}
}

View file

@ -21,6 +21,8 @@ namespace PKHeX
public byte[] Footer { protected get; set; } = new byte[0]; // .dsv
public bool Japanese { protected get; set; }
public bool GetJapanese => Japanese;
// General PKM Properties
protected abstract Type PKMType { get; }
public abstract PKM getPKM(byte[] data);
@ -29,6 +31,7 @@ namespace PKHeX
public abstract int SIZE_STORED { get; }
public abstract int SIZE_PARTY { get; }
public abstract int MaxEV { get; }
public virtual int MaxIV => 31;
public ushort[] HeldItems { get; protected set; }
// General SAV Properties
@ -58,6 +61,7 @@ namespace PKHeX
public bool E => Version == GameVersion.E;
public bool FRLG => Version == GameVersion.FRLG;
public bool RS => Version == GameVersion.RS;
public bool RBY => Version == GameVersion.RBY;
public virtual int MaxMoveID => int.MaxValue;
public virtual int MaxSpeciesID => int.MaxValue;
@ -127,13 +131,13 @@ namespace PKHeX
{
get
{
PKM[] data = new PKM[BoxCount*30];
PKM[] data = new PKM[BoxCount*BoxSlotCount];
for (int i = 0; i < data.Length; i++)
{
data[i] = getStoredSlot(getBoxOffset(i/30) + SIZE_STORED*(i%30));
data[i].Identifier = $"{getBoxName(i/30)}:{(i%30 + 1).ToString("00")}";
data[i].Box = i/30 + 1;
data[i].Slot = i%30 + 1;
data[i] = getStoredSlot(getBoxOffset(i/BoxSlotCount) + SIZE_STORED*(i%BoxSlotCount));
data[i].Identifier = $"{getBoxName(i/BoxSlotCount)}:{(i%BoxSlotCount + 1).ToString("00")}";
data[i].Box = i/BoxSlotCount + 1;
data[i].Slot = i%BoxSlotCount + 1;
}
return data;
}
@ -141,13 +145,13 @@ namespace PKHeX
{
if (value == null)
throw new ArgumentNullException();
if (value.Length != BoxCount*30)
throw new ArgumentException($"Expected {BoxCount*30}, got {value.Length}");
if (value.Length != BoxCount*BoxSlotCount)
throw new ArgumentException($"Expected {BoxCount*BoxSlotCount}, got {value.Length}");
if (value.Any(pk => PKMType != pk.GetType()))
throw new ArgumentException($"Not {PKMType} array.");
for (int i = 0; i < value.Length; i++)
setStoredSlot(value[i], getBoxOffset(i/30) + SIZE_STORED*(i%30));
setStoredSlot(value[i], getBoxOffset(i/BoxSlotCount) + SIZE_STORED*(i%BoxSlotCount));
}
}
public PKM[] PartyData
@ -260,6 +264,7 @@ namespace PKHeX
protected int OFS_PouchBalls { get; set; } = int.MinValue;
protected int OFS_BattleItems { get; set; } = int.MinValue;
protected int OFS_MailItems { get; set; } = int.MinValue;
protected int OFS_PCItem { get; set; } = int.MinValue;
// Mystery Gift
protected virtual bool[] MysteryGiftReceivedFlags { get { return null; } set { } }
@ -328,6 +333,7 @@ namespace PKHeX
public abstract void setDaycareOccupied(int loc, int slot, bool occupied);
// Storage
public virtual int BoxSlotCount => 30;
public PKM getPartySlot(int offset)
{
return getPKM(decryptPKM(getData(offset, SIZE_PARTY)));
@ -355,7 +361,7 @@ namespace PKHeX
Console.WriteLine("");
Edited = true;
}
public void setStoredSlot(PKM pkm, int offset, bool? trade = null, bool? dex = null)
public virtual void setStoredSlot(PKM pkm, int offset, bool? trade = null, bool? dex = null)
{
if (pkm == null) return;
if (pkm.GetType() != PKMType)
@ -415,9 +421,9 @@ namespace PKHeX
public void sortBoxes(int BoxStart = 0, int BoxEnd = -1)
{
PKM[] BD = BoxData;
var Section = BD.Skip(BoxStart*30);
var Section = BD.Skip(BoxStart*BoxSlotCount);
if (BoxEnd > BoxStart)
Section = Section.Take(30*(BoxEnd - BoxStart));
Section = Section.Take(BoxSlotCount*(BoxEnd - BoxStart));
var Sorted = Section
.OrderBy(p => p.Species == 0) // empty slots at end
@ -425,7 +431,7 @@ namespace PKHeX
.ThenBy(p => p.Species) // species sorted
.ThenBy(p => p.IsNicknamed).ToArray();
Array.Copy(Sorted, 0, BD, BoxStart*30, Sorted.Length);
Array.Copy(Sorted, 0, BD, BoxStart*BoxSlotCount, Sorted.Length);
BoxData = BD;
}
public void resetBoxes(int BoxStart = 0, int BoxEnd = -1)
@ -435,13 +441,13 @@ namespace PKHeX
for (int i = BoxStart; i < BoxEnd; i++)
{
int offset = getBoxOffset(i);
for (int p = 0; p < 30; p++)
for (int p = 0; p < BoxSlotCount; p++)
setStoredSlot(BlankPKM, offset + SIZE_STORED * p);
}
}
public byte[] getPCBin() { return BoxData.SelectMany(pk => pk.EncryptedBoxData).ToArray(); }
public byte[] getBoxBin(int box) { return BoxData.Skip(box*30).Take(30).SelectMany(pk => pk.EncryptedBoxData).ToArray(); }
public byte[] getBoxBin(int box) { return BoxData.Skip(box*BoxSlotCount).Take(BoxSlotCount).SelectMany(pk => pk.EncryptedBoxData).ToArray(); }
public bool setPCBin(byte[] data)
{
if (data.Length != getPCBin().Length)
@ -474,14 +480,23 @@ namespace PKHeX
}
PKM[] pkms = BoxData;
for (int i = 0; i < 30; i++)
pkms[box*30 + i].Data = decryptPKM(pkdata[i]);
for (int i = 0; i < BoxSlotCount; i++)
pkms[box*BoxSlotCount + i].Data = decryptPKM(pkdata[i]);
BoxData = pkms;
return true;
}
protected virtual void setPKM(PKM pkm) { }
protected virtual void setDex(PKM pkm) { }
protected virtual void setDex(PKM pkm)
{
setSeen(pkm);
setCaught(pkm);
}
public virtual bool getSeen(PKM pkm) { throw new NotImplementedException(); }
public virtual bool getCaught(PKM pkm) { throw new NotImplementedException(); }
protected internal virtual void setSeen(PKM pkm, bool seen = true) { }
protected internal virtual void setCaught(PKM pkm, bool caught = true) { }
public byte[] getData(int Offset, int Length)
{

View file

@ -18,6 +18,8 @@ namespace PKHeX
SN = 28, MN = 29,
// Game Groupings (SaveFile type)
RBY = 98,
GSC = 99,
RS = 100,
FRLG = 101,
DP = 102,
@ -43,6 +45,8 @@ namespace PKHeX
internal const int SIZE_G4RAW = 0x80000;
internal const int SIZE_G3RAW = 0x20000;
internal const int SIZE_G3RAWHALF = 0x10000;
internal const int SIZE_G1RAW = 0x8000;
internal const int SIZE_G1BAT = 0x802C;
internal static readonly byte[] FOOTER_DSV = Encoding.ASCII.GetBytes("|-DESMUME SAVE-|");
@ -51,6 +55,8 @@ namespace PKHeX
/// <returns>Version Identifier or Invalid if type cannot be determined.</returns>
public static int getSAVGeneration(byte[] data)
{
if (getIsG1SAV(data) != GameVersion.Invalid)
return 1;
if (getIsG3SAV(data) != GameVersion.Invalid)
return 3;
if (getIsG4SAV(data) != GameVersion.Invalid)
@ -61,6 +67,47 @@ namespace PKHeX
return 6;
return -1;
}
/// <summary>Determines the type of 1st gen save</summary>
/// <param name="data">Save data of which to determine the type</param>
/// <returns>Version Identifier or Invalid if type cannot be determined.</returns>
public static GameVersion getIsG1SAV(byte[] data)
{
if (data.Length != SIZE_G1RAW && data.Length != SIZE_G1BAT)
return GameVersion.Invalid;
// Check if it's not an american save or a japanese save
if (!(getIsG1SAVU(data) || getIsG1SAVJ(data)))
return GameVersion.Invalid;
// I can't actually detect which game version, because it's not stored anywhere.
// If you can think of anything to do here, please implement :)
return GameVersion.RBY;
}
/// <summary>Determines if 1st gen save is non-japanese</summary>
/// <param name="data">Save data of which to determine the region</param>
/// <returns>True if a valid non-japanese save, False otherwise.</returns>
public static bool getIsG1SAVU(byte[] data)
{
foreach (int ofs in new[] { 0x2F2C, 0x30C0 })
{
byte num_entries = data[ofs];
if (num_entries > 20 || data[ofs + 1 + num_entries] != 0xFF)
return false;
}
return true;
}
/// <summary>Determines if 1st gen save is japanese</summary>
/// <param name="data">Save data of which to determine the region</param>
/// <returns>True if a valid japanese save, False otherwise.</returns>
public static bool getIsG1SAVJ(byte[] data)
{
foreach (int ofs in new[] { 0x2ED5, 0x302D })
{
byte num_entries = data[ofs];
if (num_entries > 30 || data[ofs + 1 + num_entries] != 0xFF)
return false;
}
return true;
}
/// <summary>Determines the type of 3th gen save</summary>
/// <param name="data">Save data of which to determine the type</param>
/// <returns>Version Identifier or Invalid if type cannot be determined.</returns>
@ -168,6 +215,9 @@ namespace PKHeX
case GameVersion.CXD:
return GameVersion.CXD;
case GameVersion.RBY:
return GameVersion.RBY;
case GameVersion.R:
case GameVersion.S:
return GameVersion.RS;
@ -218,6 +268,8 @@ namespace PKHeX
{
switch (getSAVGeneration(data))
{
case 1:
return new SAV1(data);
case 3:
return new SAV3(data);
case 4:

View file

@ -10,7 +10,19 @@ namespace PKHeX
{
InitializeComponent();
Util.TranslateInterface(this, Main.curlanguage);
itemlist = SAV.Generation == 3 ? Main.g3items : Main.itemlist;
switch (SAV.Generation)
{
case 1:
itemlist = PKX.getG1ItemList();
B_GiveAll.Visible = false; // Can't give all, not enough room
break;
case 3:
itemlist = Main.g3items;
break;
default:
itemlist = Main.itemlist;
break;
}
Pouches = SAV.Inventory;
getBags();
}
@ -155,6 +167,8 @@ namespace PKHeX
itemcnt++; // No 0 count of items
else if (itemcnt > 995)
itemcnt = 995; // cap out
else if (itemcnt > 99 && SAV.Generation < 3)
itemcnt = 99;
if (itemindex == 0) // Compression of Empty Slots
continue;

View file

@ -0,0 +1,179 @@
namespace PKHeX
{
partial class SAV_SimplePokedex
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SAV_SimplePokedex));
this.B_Save = new System.Windows.Forms.Button();
this.B_Cancel = new System.Windows.Forms.Button();
this.B_CaughtNone = new System.Windows.Forms.Button();
this.B_CaughtAll = new System.Windows.Forms.Button();
this.B_SeenNone = new System.Windows.Forms.Button();
this.B_SeenAll = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.CLB_Caught = new System.Windows.Forms.CheckedListBox();
this.Label_Seen = new System.Windows.Forms.Label();
this.CLB_Seen = new System.Windows.Forms.CheckedListBox();
this.SuspendLayout();
//
// B_Save
//
this.B_Save.Location = new System.Drawing.Point(146, 301);
this.B_Save.Name = "B_Save";
this.B_Save.Size = new System.Drawing.Size(85, 23);
this.B_Save.TabIndex = 19;
this.B_Save.Text = "Save";
this.B_Save.UseVisualStyleBackColor = true;
this.B_Save.Click += new System.EventHandler(this.B_Save_Click);
//
// B_Cancel
//
this.B_Cancel.Location = new System.Drawing.Point(53, 301);
this.B_Cancel.Name = "B_Cancel";
this.B_Cancel.Size = new System.Drawing.Size(85, 23);
this.B_Cancel.TabIndex = 18;
this.B_Cancel.Text = "Cancel";
this.B_Cancel.UseVisualStyleBackColor = true;
this.B_Cancel.Click += new System.EventHandler(this.B_Cancel_Click);
//
// B_CaughtNone
//
this.B_CaughtNone.Location = new System.Drawing.Point(151, 267);
this.B_CaughtNone.Name = "B_CaughtNone";
this.B_CaughtNone.Size = new System.Drawing.Size(120, 23);
this.B_CaughtNone.TabIndex = 17;
this.B_CaughtNone.Text = "Caught None";
this.B_CaughtNone.UseVisualStyleBackColor = true;
this.B_CaughtNone.Click += new System.EventHandler(this.B_CaughtNone_Click);
//
// B_CaughtAll
//
this.B_CaughtAll.Location = new System.Drawing.Point(151, 238);
this.B_CaughtAll.Name = "B_CaughtAll";
this.B_CaughtAll.Size = new System.Drawing.Size(120, 23);
this.B_CaughtAll.TabIndex = 16;
this.B_CaughtAll.Text = "Caught All";
this.B_CaughtAll.UseVisualStyleBackColor = true;
this.B_CaughtAll.Click += new System.EventHandler(this.B_CaughtAll_Click);
//
// B_SeenNone
//
this.B_SeenNone.Location = new System.Drawing.Point(14, 267);
this.B_SeenNone.Name = "B_SeenNone";
this.B_SeenNone.Size = new System.Drawing.Size(120, 23);
this.B_SeenNone.TabIndex = 15;
this.B_SeenNone.Text = "Seen None";
this.B_SeenNone.UseVisualStyleBackColor = true;
this.B_SeenNone.Click += new System.EventHandler(this.B_SeenNone_Click);
//
// B_SeenAll
//
this.B_SeenAll.Location = new System.Drawing.Point(14, 238);
this.B_SeenAll.Name = "B_SeenAll";
this.B_SeenAll.Size = new System.Drawing.Size(120, 23);
this.B_SeenAll.TabIndex = 14;
this.B_SeenAll.Text = "Seen All";
this.B_SeenAll.UseVisualStyleBackColor = true;
this.B_SeenAll.Click += new System.EventHandler(this.B_SeenAll_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(151, 13);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(44, 13);
this.label2.TabIndex = 13;
this.label2.Text = "Caught:";
//
// CLB_Caught
//
this.CLB_Caught.FormattingEnabled = true;
this.CLB_Caught.Location = new System.Drawing.Point(151, 33);
this.CLB_Caught.Name = "CLB_Caught";
this.CLB_Caught.Size = new System.Drawing.Size(120, 199);
this.CLB_Caught.TabIndex = 12;
this.CLB_Caught.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.CLB_Caught_ItemCheck);
//
// Label_Seen
//
this.Label_Seen.AutoSize = true;
this.Label_Seen.Location = new System.Drawing.Point(14, 13);
this.Label_Seen.Name = "Label_Seen";
this.Label_Seen.Size = new System.Drawing.Size(35, 13);
this.Label_Seen.TabIndex = 11;
this.Label_Seen.Text = "Seen:";
//
// CLB_Seen
//
this.CLB_Seen.FormattingEnabled = true;
this.CLB_Seen.Location = new System.Drawing.Point(14, 33);
this.CLB_Seen.Name = "CLB_Seen";
this.CLB_Seen.Size = new System.Drawing.Size(120, 199);
this.CLB_Seen.TabIndex = 10;
this.CLB_Seen.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.CLB_Seen_ItemCheck);
//
// SAV_SimplePokedex
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 336);
this.Controls.Add(this.B_Save);
this.Controls.Add(this.B_Cancel);
this.Controls.Add(this.B_CaughtNone);
this.Controls.Add(this.B_CaughtAll);
this.Controls.Add(this.B_SeenNone);
this.Controls.Add(this.B_SeenAll);
this.Controls.Add(this.label2);
this.Controls.Add(this.CLB_Caught);
this.Controls.Add(this.Label_Seen);
this.Controls.Add(this.CLB_Seen);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximumSize = new System.Drawing.Size(300, 375);
this.MinimumSize = new System.Drawing.Size(300, 375);
this.Name = "SAV_SimplePokedex";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Pokedex Editor";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button B_Save;
private System.Windows.Forms.Button B_Cancel;
private System.Windows.Forms.Button B_CaughtNone;
private System.Windows.Forms.Button B_CaughtAll;
private System.Windows.Forms.Button B_SeenNone;
private System.Windows.Forms.Button B_SeenAll;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.CheckedListBox CLB_Caught;
private System.Windows.Forms.Label Label_Seen;
private System.Windows.Forms.CheckedListBox CLB_Seen;
}
}

View file

@ -0,0 +1,93 @@
using System;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace PKHeX
{
public partial class SAV_SimplePokedex : Form
{
public SAV_SimplePokedex()
{
InitializeComponent();
Util.TranslateInterface(this, Main.curlanguage);
seen = new bool[SAV.MaxSpeciesID];
caught = new bool[SAV.MaxSpeciesID];
string[] spec = Util.getSpeciesList(Main.curlanguage);
for (int i = 0; i < seen.Length; i++)
{
PKM tempPkm = new PK6();
tempPkm.Species = i + 1;
seen[i] = SAV.getSeen(tempPkm);
caught[i] = SAV.getCaught(tempPkm);
CLB_Seen.Items.Add(spec[i + 1]);
CLB_Caught.Items.Add(spec[i + 1]);
CLB_Seen.SetItemChecked(i, seen[i]);
CLB_Caught.SetItemChecked(i, caught[i]);
}
initialized = true;
}
private readonly CheckBox[] cba;
private readonly SaveFile SAV = Main.SAV.Clone();
private bool[] seen;
private bool[] caught;
private bool initialized;
private void B_Save_Click(object sender, EventArgs e)
{
for (int i = 0; i < seen.Length; i++)
{
PKM tempPkm = new PK6();
tempPkm.Species = i + 1;
SAV.setSeen(tempPkm, seen[i]);
SAV.setCaught(tempPkm, caught[i]);
}
SAV.Data.CopyTo(Main.SAV.Data, 0);
Main.SAV.Edited = true;
Close();
}
private void B_Cancel_Click(object sender, EventArgs e)
{
Close();
}
private void B_SeenAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < SAV.MaxSpeciesID; i++)
CLB_Seen.SetItemChecked(i, true);
}
private void B_SeenNone_Click(object sender, EventArgs e)
{
for (int i = 0; i < SAV.MaxSpeciesID; i++)
CLB_Seen.SetItemChecked(i, false);
}
private void B_CaughtAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < SAV.MaxSpeciesID; i++)
CLB_Caught.SetItemChecked(i, true);
}
private void B_CaughtNone_Click(object sender, EventArgs e)
{
for (int i = 0; i < SAV.MaxSpeciesID; i++)
CLB_Caught.SetItemChecked(i, false);
}
private void CLB_Seen_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (!initialized) return;
seen[e.Index] = e.NewValue == CheckState.Checked;
}
private void CLB_Caught_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (!initialized) return;
caught[e.Index] = e.NewValue == CheckState.Checked;
}
}
}

View file

@ -0,0 +1,216 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAIAEBAAAAE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////
</value>
</data>
</root>

View file

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SAV_SimpleTrainer));
this.GB_Adventure = new System.Windows.Forms.GroupBox();
this.L_Started = new System.Windows.Forms.Label();
this.CAL_AdventureStartDate = new System.Windows.Forms.DateTimePicker();
@ -63,6 +64,9 @@
this.B_Save = new System.Windows.Forms.Button();
this.B_Cancel = new System.Windows.Forms.Button();
this.GB_Trainer = new System.Windows.Forms.GroupBox();
this.B_MaxCoins = new System.Windows.Forms.Button();
this.L_Coins = new System.Windows.Forms.Label();
this.MT_Coins = new System.Windows.Forms.MaskedTextBox();
this.GB_Badges = new System.Windows.Forms.GroupBox();
this.CHK_H8 = new System.Windows.Forms.CheckBox();
this.CHK_H7 = new System.Windows.Forms.CheckBox();
@ -80,6 +84,14 @@
this.CHK_3 = new System.Windows.Forms.CheckBox();
this.CHK_2 = new System.Windows.Forms.CheckBox();
this.CHK_1 = new System.Windows.Forms.CheckBox();
this.GB_Options = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.CB_SoundType = new System.Windows.Forms.ComboBox();
this.LBL_TextSpeed = new System.Windows.Forms.Label();
this.CB_TextSpeed = new System.Windows.Forms.ComboBox();
this.LBL_BattleStyle = new System.Windows.Forms.Label();
this.CB_BattleStyle = new System.Windows.Forms.ComboBox();
this.CHK_BattleEffects = new System.Windows.Forms.CheckBox();
this.GB_Adventure.SuspendLayout();
this.GB_Map.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_Z)).BeginInit();
@ -88,6 +100,7 @@
((System.ComponentModel.ISupportInitialize)(this.NUD_X)).BeginInit();
this.GB_Trainer.SuspendLayout();
this.GB_Badges.SuspendLayout();
this.GB_Options.SuspendLayout();
this.SuspendLayout();
//
// GB_Adventure
@ -248,7 +261,7 @@
this.CB_Gender.Items.AddRange(new object[] {
"♂",
"♀"});
this.CB_Gender.Location = new System.Drawing.Point(99, 55);
this.CB_Gender.Location = new System.Drawing.Point(119, 55);
this.CB_Gender.Name = "CB_Gender";
this.CB_Gender.Size = new System.Drawing.Size(40, 21);
this.CB_Gender.TabIndex = 68;
@ -458,6 +471,9 @@
//
// GB_Trainer
//
this.GB_Trainer.Controls.Add(this.B_MaxCoins);
this.GB_Trainer.Controls.Add(this.L_Coins);
this.GB_Trainer.Controls.Add(this.MT_Coins);
this.GB_Trainer.Controls.Add(this.TB_OTName);
this.GB_Trainer.Controls.Add(this.B_MaxCash);
this.GB_Trainer.Controls.Add(this.MT_SID);
@ -475,6 +491,37 @@
this.GB_Trainer.TabStop = false;
this.GB_Trainer.Text = "Trainer";
//
// B_MaxCoins
//
this.B_MaxCoins.Location = new System.Drawing.Point(95, 56);
this.B_MaxCoins.Name = "B_MaxCoins";
this.B_MaxCoins.Size = new System.Drawing.Size(20, 20);
this.B_MaxCoins.TabIndex = 71;
this.B_MaxCoins.Text = "+";
this.B_MaxCoins.UseVisualStyleBackColor = true;
this.B_MaxCoins.Visible = false;
//
// L_Coins
//
this.L_Coins.AutoSize = true;
this.L_Coins.Location = new System.Drawing.Point(11, 59);
this.L_Coins.Name = "L_Coins";
this.L_Coins.Size = new System.Drawing.Size(36, 13);
this.L_Coins.TabIndex = 70;
this.L_Coins.Text = "Coins:";
this.L_Coins.Visible = false;
//
// MT_Coins
//
this.MT_Coins.Location = new System.Drawing.Point(53, 55);
this.MT_Coins.Mask = "00000";
this.MT_Coins.Name = "MT_Coins";
this.MT_Coins.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.MT_Coins.Size = new System.Drawing.Size(39, 20);
this.MT_Coins.TabIndex = 69;
this.MT_Coins.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.MT_Coins.Visible = false;
//
// GB_Badges
//
this.GB_Badges.Controls.Add(this.CHK_H8);
@ -660,17 +707,100 @@
this.CHK_1.UseVisualStyleBackColor = true;
this.CHK_1.Visible = false;
//
// GB_Options
//
this.GB_Options.Controls.Add(this.label1);
this.GB_Options.Controls.Add(this.CB_SoundType);
this.GB_Options.Controls.Add(this.LBL_TextSpeed);
this.GB_Options.Controls.Add(this.CB_TextSpeed);
this.GB_Options.Controls.Add(this.LBL_BattleStyle);
this.GB_Options.Controls.Add(this.CB_BattleStyle);
this.GB_Options.Controls.Add(this.CHK_BattleEffects);
this.GB_Options.Location = new System.Drawing.Point(217, 99);
this.GB_Options.Name = "GB_Options";
this.GB_Options.Size = new System.Drawing.Size(157, 125);
this.GB_Options.TabIndex = 72;
this.GB_Options.TabStop = false;
this.GB_Options.Text = "Options";
this.GB_Options.Visible = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(3, 71);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(68, 13);
this.label1.TabIndex = 25;
this.label1.Text = "Sound Type:";
//
// CB_SoundType
//
this.CB_SoundType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_SoundType.FormattingEnabled = true;
this.CB_SoundType.Location = new System.Drawing.Point(71, 68);
this.CB_SoundType.Name = "CB_SoundType";
this.CB_SoundType.Size = new System.Drawing.Size(80, 21);
this.CB_SoundType.TabIndex = 24;
//
// LBL_TextSpeed
//
this.LBL_TextSpeed.AutoSize = true;
this.LBL_TextSpeed.Location = new System.Drawing.Point(6, 98);
this.LBL_TextSpeed.Name = "LBL_TextSpeed";
this.LBL_TextSpeed.Size = new System.Drawing.Size(65, 13);
this.LBL_TextSpeed.TabIndex = 23;
this.LBL_TextSpeed.Text = "Text Speed:";
//
// CB_TextSpeed
//
this.CB_TextSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_TextSpeed.FormattingEnabled = true;
this.CB_TextSpeed.Location = new System.Drawing.Point(71, 95);
this.CB_TextSpeed.Name = "CB_TextSpeed";
this.CB_TextSpeed.Size = new System.Drawing.Size(80, 21);
this.CB_TextSpeed.TabIndex = 22;
//
// LBL_BattleStyle
//
this.LBL_BattleStyle.AutoSize = true;
this.LBL_BattleStyle.Location = new System.Drawing.Point(8, 44);
this.LBL_BattleStyle.Name = "LBL_BattleStyle";
this.LBL_BattleStyle.Size = new System.Drawing.Size(63, 13);
this.LBL_BattleStyle.TabIndex = 21;
this.LBL_BattleStyle.Text = "Battle Style:";
//
// CB_BattleStyle
//
this.CB_BattleStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_BattleStyle.FormattingEnabled = true;
this.CB_BattleStyle.Location = new System.Drawing.Point(71, 41);
this.CB_BattleStyle.Name = "CB_BattleStyle";
this.CB_BattleStyle.Size = new System.Drawing.Size(80, 21);
this.CB_BattleStyle.TabIndex = 20;
//
// CHK_BattleEffects
//
this.CHK_BattleEffects.AutoSize = true;
this.CHK_BattleEffects.Location = new System.Drawing.Point(26, 18);
this.CHK_BattleEffects.Name = "CHK_BattleEffects";
this.CHK_BattleEffects.Size = new System.Drawing.Size(111, 17);
this.CHK_BattleEffects.TabIndex = 19;
this.CHK_BattleEffects.Text = "Use Battle Effects";
this.CHK_BattleEffects.UseVisualStyleBackColor = true;
//
// SAV_SimpleTrainer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(384, 261);
this.Controls.Add(this.GB_Options);
this.Controls.Add(this.GB_Badges);
this.Controls.Add(this.GB_Trainer);
this.Controls.Add(this.B_Save);
this.Controls.Add(this.B_Cancel);
this.Controls.Add(this.GB_Map);
this.Controls.Add(this.GB_Adventure);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(400, 300);
this.Name = "SAV_SimpleTrainer";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
@ -686,6 +816,8 @@
this.GB_Trainer.PerformLayout();
this.GB_Badges.ResumeLayout(false);
this.GB_Badges.PerformLayout();
this.GB_Options.ResumeLayout(false);
this.GB_Options.PerformLayout();
this.ResumeLayout(false);
}
@ -744,5 +876,16 @@
private System.Windows.Forms.CheckBox CHK_H3;
private System.Windows.Forms.CheckBox CHK_H2;
private System.Windows.Forms.CheckBox CHK_H1;
private System.Windows.Forms.Button B_MaxCoins;
private System.Windows.Forms.Label L_Coins;
private System.Windows.Forms.MaskedTextBox MT_Coins;
private System.Windows.Forms.GroupBox GB_Options;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox CB_SoundType;
private System.Windows.Forms.Label LBL_TextSpeed;
private System.Windows.Forms.ComboBox CB_TextSpeed;
private System.Windows.Forms.Label LBL_BattleStyle;
private System.Windows.Forms.ComboBox CB_BattleStyle;
private System.Windows.Forms.CheckBox CHK_BattleEffects;
}
}

View file

@ -14,10 +14,15 @@ namespace PKHeX
cba = new[] {CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_6, CHK_7, CHK_8};
TB_OTName.MaxLength = SAV.OTLength;
B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999";
B_MaxCoins.Click += (sender, e) => MT_Coins.Text = "9999";
CB_Gender.Items.Clear();
CB_Gender.Items.AddRange(Main.gendersymbols.Take(2).ToArray()); // m/f depending on unicode selection
L_SID.Visible = MT_SID.Visible = SAV.Generation > 2;
L_Coins.Visible = B_MaxCoins.Visible = MT_Coins.Visible = SAV.Generation < 3;
CB_Gender.Visible = SAV.Generation > 1;
TB_OTName.Text = SAV.OT;
CB_Gender.SelectedIndex = SAV.Gender;
MT_TID.Text = SAV.TID.ToString("00000");
@ -27,6 +32,29 @@ namespace PKHeX
MT_Minutes.Text = SAV.PlayedMinutes.ToString();
MT_Seconds.Text = SAV.PlayedSeconds.ToString();
int badgeval = 0;
if (SAV is SAV1)
{
SAV1 sav1 = (SAV1)SAV;
MT_Coins.Text = sav1.Coin.ToString();
badgeval = sav1.Badges;
L_Started.Visible = L_Fame.Visible = false;
CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
GB_Map.Visible = false;
GB_Options.Visible = true;
CB_BattleStyle.Items.AddRange(new[] { "Switch", "Set" });
CB_SoundType.Items.AddRange(new[] { "Mono", "Stereo", "Earphone2", "Earphone3" });
CB_TextSpeed.Items.AddRange(new[] { "0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7" });
CHK_BattleEffects.Checked = sav1.BattleEffects;
CB_BattleStyle.SelectedIndex = sav1.BattleStyleSwitch ? 0 : 1;
CB_SoundType.SelectedIndex = sav1.Sound;
CB_TextSpeed.SelectedIndex = sav1.TextSpeed;
}
if (SAV is SAV3)
{
GB_Map.Visible = false;
@ -38,7 +66,6 @@ namespace PKHeX
return;
}
int badgeval = 0;
if (SAV is SAV4)
{
SAV4 s = (SAV4)SAV;
@ -104,6 +131,18 @@ namespace PKHeX
for (int i = 0; i < cba.Length; i++)
badgeval |= (cba[i].Checked ? 1 : 0) << i;
if (SAV is SAV1)
{
SAV1 sav1 = (SAV1) SAV;
sav1.Coin = (ushort) Util.ToUInt32(MT_Coins.Text);
sav1.Badges = badgeval & 0xFF;
sav1.BattleEffects = CHK_BattleEffects.Checked;
sav1.BattleStyleSwitch = CB_BattleStyle.SelectedIndex == 0;
sav1.Sound = CB_SoundType.SelectedIndex;
sav1.TextSpeed = CB_TextSpeed.SelectedIndex;
}
if (SAV is SAV4)
{
SAV4 s = (SAV4)SAV;

View file

@ -117,4 +117,100 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAA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al file
View file

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PKHeX
{
public partial class Util
{
/// <summary>
/// Swaps the Endianness of an int
/// <param name="val">Value to swap endianness of.</param>
/// <returns>The endianness-swapped value.</returns>
internal static int SwapEndianness(int val)
{
return (int) SwapEndianness((uint) val);
}
/// <summary>
/// Swaps the Endianness of a uint
/// <param name="val">Value to swap endianness of.</param>
/// <returns>The endianness-swapped value.</returns>
internal static uint SwapEndianness(uint val)
{
return ((val & 0x000000FF) << 24)
| ((val & 0x0000FF00) << 8)
| ((val & 0x00FF0000) >> 8)
| ((val & 0xFF000000) >> 24);
}
/// <summary>
/// Swaps the Endianness of a short
/// <param name="val">Value to swap endianness of.</param>
/// <returns>The endianness-swapped value.</returns>
internal static int SwapEndianness(short val)
{
return (short)SwapEndianness((ushort)val);
}
/// <summary>
/// Swaps the Endianness of a ushort
/// <param name="val">Value to swap endianness of.</param>
/// <returns>The endianness-swapped value.</returns>
internal static ushort SwapEndianness(ushort val)
{
return (ushort) (((val & 0x00FF) << 8) | ((val & 0xFF00) >> 8));
}
}
}