diff --git a/PKHeX.Core/Properties/Resources.Designer.cs b/PKHeX.Core/Properties/Resources.Designer.cs
index aaadbe747..8bb90631a 100644
--- a/PKHeX.Core/Properties/Resources.Designer.cs
+++ b/PKHeX.Core/Properties/Resources.Designer.cs
@@ -125,6 +125,25 @@ internal class Resources {
}
}
+ ///
+ /// Looks up a localized string similar to 0196 Dialga 0:Battleable,1:Disappeared
+ ///0197 Palkia 0:Battleable,1:Disappeared
+ ///0085 Giratina(DistortionWorld) 13:Battleable,14:Disappeared
+ ///0158 Heatran 00:Event,01:Battleable,02:Disappeared
+ ///0054 Fullmoon Is. 0:Not appeared,520:On the Map
+ ///0055 Newmoon Is. 0:Not appeared,553:On the Map
+ ///0056 Spring Path 0:Not appeared,786:Appeared
+ ///0057 Seabreak Path 0:Not appeared,4136:Appeared
+ ///0067 Member Card 0:Not activated,4617:Activated
+ ///0068 Oak Letter 0:Not activated,4370:Activated
+ ///0069 Azure Flute 0:Not activat [rest of string was truncated]";.
+ ///
+ internal static string const_pt {
+ get {
+ return ResourceManager.GetString("const_pt", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to 148 Starter 00:Rowlet,01:Litten,02:Popplio
///432 Tapu Koko 03:Battleable,04:Defeated,05:Captured
@@ -272,6 +291,31 @@ internal class Resources {
}
}
+ ///
+ /// Looks up a localized string similar to 0481 Uxie disappeared
+ ///0479 Mesprit(Verity Cavern) disappeared
+ ///0480 Azelf disappeared
+ ///0208 Dialga captured
+ ///0209 Palkia captured
+ ///0591 Cresselia(FullmoonIs.) disappeared
+ ///0476 Charon(Mt.Stark) disappeared
+ ///0293 Heatran Battleable
+ ///0288 Heatran Disappeared
+ ///0579 Regigigas disappeared
+ ///0306 EventObj(SpearPillar) Appeared
+ ///0461 Cynthia(SpearPillar) Disappeared
+ ///0672 Cynthia(SendoffSpring) Disappeared
+ ///0592 Giratina disappeared
+ ///0344 Darkrai disappeared
+ ///0301 Oak(R224)#1 disappeared
+ ///0594 Oak(R224)#2 disappea [rest of string was truncated]";.
+ ///
+ internal static string flags_pt {
+ get {
+ return ResourceManager.GetString("flags_pt", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to 3100 Is Alolan Champion + Magearna Event Active
///3487 Received Magearna Gift
diff --git a/PKHeX.Core/Properties/Resources.resx b/PKHeX.Core/Properties/Resources.resx
index 264319c55..9292671c9 100644
--- a/PKHeX.Core/Properties/Resources.resx
+++ b/PKHeX.Core/Properties/Resources.resx
@@ -1457,4 +1457,10 @@
..\Resources\text\other\flags_b2w2.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;shift_jis
+
+ ..\Resources\text\other\const_pt.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;shift_jis
+
+
+ ..\Resources\text\other\flags_pt.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;shift_jis
+
\ No newline at end of file
diff --git a/PKHeX.Core/Resources/text/other/const_pt.txt b/PKHeX.Core/Resources/text/other/const_pt.txt
new file mode 100644
index 000000000..fff29a69c
--- /dev/null
+++ b/PKHeX.Core/Resources/text/other/const_pt.txt
@@ -0,0 +1,13 @@
+0196 Dialga 0:Battleable,1:Disappeared
+0197 Palkia 0:Battleable,1:Disappeared
+0085 Giratina(DistortionWorld) 13:Battleable,14:Disappeared
+0158 Heatran 00:Event,01:Battleable,02:Disappeared
+0054 Fullmoon Is. 0:Not appeared,520:On the Map
+0055 Newmoon Is. 0:Not appeared,553:On the Map
+0056 Spring Path 0:Not appeared,786:Appeared
+0057 Seabreak Path 0:Not appeared,4136:Appeared
+0067 Member Card 0:Not activated,4617:Activated
+0068 Oak Letter 0:Not activated,4370:Activated
+0069 Azure Flute 0:Not activated,4387:Activated
+0087 Event Marley(R224) 0:Not activated,1:Activatable,2:Activated
+0133 Marley(R224) 0:Not Activated,1:Appearable,2:Appeared
\ No newline at end of file
diff --git a/PKHeX.Core/Resources/text/other/flags_dp.txt b/PKHeX.Core/Resources/text/other/flags_dp.txt
index b494ab702..b7a5c62d6 100644
--- a/PKHeX.Core/Resources/text/other/flags_dp.txt
+++ b/PKHeX.Core/Resources/text/other/flags_dp.txt
@@ -12,4 +12,10 @@
0307 Ferry FullmoonIs. accessable
0316 Ferry NewmoonIs. accessable
0301 Oak(R224) disappeared
-0634 Shaymin(R224 MapObj) disappeared
\ No newline at end of file
+0634 Shaymin(R224 MapObj) disappeared
+2404 HOF(TrainerCard Upgrade)
+2408 Cool Contest Master
+2409 Beauty Contest Master
+2410 Cute Contest Master
+2411 Smart Contest Master
+2412 Tough Contest Master
\ No newline at end of file
diff --git a/PKHeX.Core/Resources/text/other/flags_hgss.txt b/PKHeX.Core/Resources/text/other/flags_hgss.txt
index 6caad0894..872c7f57a 100644
--- a/PKHeX.Core/Resources/text/other/flags_hgss.txt
+++ b/PKHeX.Core/Resources/text/other/flags_hgss.txt
@@ -12,4 +12,7 @@
0578 Ho-Oh disappeared
0781 Lati@s(PewterCity) disappeared
0721 Kyogre/Groudon disappeared
-0722 Rayquaza disappeared
\ No newline at end of file
+0722 Rayquaza disappeared
+2404 HOF(TrainerCard Upgrade)
+0388 ShinyLeaf(TrainerCard Upgrade)
+0241 Pokeathlon(TrainerCard Upgrade)
\ No newline at end of file
diff --git a/PKHeX.Core/Resources/text/other/flags_pt.txt b/PKHeX.Core/Resources/text/other/flags_pt.txt
new file mode 100644
index 000000000..73e3e78a7
--- /dev/null
+++ b/PKHeX.Core/Resources/text/other/flags_pt.txt
@@ -0,0 +1,32 @@
+0481 Uxie disappeared
+0479 Mesprit(Verity Cavern) disappeared
+0480 Azelf disappeared
+0208 Dialga captured
+0209 Palkia captured
+0591 Cresselia(FullmoonIs.) disappeared
+0476 Charon(Mt.Stark) disappeared
+0293 Heatran Battleable
+0288 Heatran Disappeared
+0579 Regigigas disappeared
+0306 EventObj(SpearPillar) Appeared
+0461 Cynthia(SpearPillar) Disappeared
+0672 Cynthia(SendoffSpring) Disappeared
+0592 Giratina disappeared
+0344 Darkrai disappeared
+0301 Oak(R224)#1 disappeared
+0594 Oak(R224)#2 disappeared
+0714 Marley(R224) disappeared
+0604 Shaymin(R224 MapObj) disappeared
+0291 Shaymin(FlowerParadise) disappeared
+0286 Arceus disappeared
+0307 Ferry FullmoonIs. accessable
+0316 Ferry NewmoonIs. accessable
+0578 Oak(EternaCity) disappeared
+0281 Legendary birds roamed#1
+0153 Legendary birds roamed#2
+2404 HOF(TrainerCard Upgrade)
+2408 Cool Contest Master
+2409 Beauty Contest Master
+2410 Cute Contest Master
+2411 Smart Contest Master
+2412 Tough Contest Master
\ No newline at end of file
diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs
index 17ba862b2..cfbfca093 100644
--- a/PKHeX.Core/Saves/SAV4.cs
+++ b/PKHeX.Core/Saves/SAV4.cs
@@ -206,6 +206,7 @@ private void getSAVOffsets()
EventConst = 0xD9C + GBO;
EventFlag = 0xFDC + GBO;
Daycare = 0x141C + GBO;
+ OFS_HONEY = 0x72E4 + GBO;
Box = 0xC104 + SBO;
break;
case GameVersion.Pt:
@@ -234,8 +235,10 @@ private void getSAVOffsets()
LegalMailItems = Legal.Pouch_Mail_Pt;
HeldItems = Legal.HeldItems_Pt;
-
+ EventConst = 0xDAC + GBO;
+ EventFlag = 0xFEC + GBO;
Daycare = 0x1654 + GBO;
+ OFS_HONEY = 0x7F38 + GBO;
Box = 0xCF30 + SBO;
break;
case GameVersion.HGSS:
@@ -1030,17 +1033,22 @@ public int DexUpgraded
switch (Version)
{
case GameVersion.DP:
- if ((Data[0x1413 + GBO] & 1) != 0) return 4;
- else if ((Data[0x1415 + GBO] & 1) != 0) return 3;
- else if ((Data[0x1404 + GBO] & 1) != 0) return 2;
- else if ((Data[0x1414 + GBO] & 1) != 0) return 1;
+ if (Data[0x1413 + GBO] != 0) return 4;
+ else if (Data[0x1415 + GBO] != 0) return 3;
+ else if (Data[0x1404 + GBO] != 0) return 2;
+ else if (Data[0x1414 + GBO] != 0) return 1;
else return 0;
case GameVersion.HGSS:
- if ((Data[0x15ED + GBO] & 1) != 0) return 3;
- else if ((Data[0x15EF + GBO] & 1) != 0) return 2;
- else if ((Data[0x15EE + GBO] & 1) != 0 && (Data[0x10D1 + GBO] & 8) != 0) return 1;
+ if (Data[0x15ED + GBO] != 0) return 3;
+ else if (Data[0x15EF + GBO] != 0) return 2;
+ else if (Data[0x15EE + GBO] != 0 && (Data[0x10D1 + GBO] & 8) != 0) return 1;
+ else return 0;
+ case GameVersion.Pt:
+ if (Data[0x1641 + GBO] != 0) return 4;
+ else if (Data[0x1643 + GBO] != 0) return 3;
+ else if (Data[0x1640 + GBO] != 0) return 2;
+ else if (Data[0x1642 + GBO] != 0) return 1;
else return 0;
- // case GameVersion.Pt: break;
default: return 0;
}
}
@@ -1049,53 +1057,41 @@ public int DexUpgraded
switch (Version)
{
case GameVersion.DP:
- Data[0x1413 + GBO] = (byte)((Data[0x1413 + GBO] & 0xFE) | (value == 4 ? 1 : 0));
- Data[0x1415 + GBO] = (byte)((Data[0x1415 + GBO] & 0xFE) | (value >= 3 ? 1 : 0));
- Data[0x1404 + GBO] = (byte)((Data[0x1404 + GBO] & 0xFE) | (value >= 2 ? 1 : 0));
- Data[0x1414 + GBO] = (byte)((Data[0x1414 + GBO] & 0xFE) | (value >= 1 ? 1 : 0));
+ Data[0x1413 + GBO] = (byte)(value == 4 ? 1 : 0);
+ Data[0x1415 + GBO] = (byte)(value >= 3 ? 1 : 0);
+ Data[0x1404 + GBO] = (byte)(value >= 2 ? 1 : 0);
+ Data[0x1414 + GBO] = (byte)(value >= 1 ? 1 : 0);
break;
case GameVersion.HGSS:
- Data[0x15ED + GBO] = (byte)((Data[0x15ED + GBO] & 0xFE) | (value == 3 ? 1 : 0));
- Data[0x15EF + GBO] = (byte)((Data[0x15EF + GBO] & 0xFE) | (value >= 2 ? 1 : 0));
- Data[0x15EE + GBO] = (byte)((Data[0x15EE + GBO] & 0xFE) | (value >= 1 ? 1 : 0));
- Data[0x10D1 + GBO] = (byte)((Data[0x10D1 + GBO] & 0xF7) | (value >= 1 ? 8 : 0));
+ Data[0x15ED + GBO] = (byte)(value == 3 ? 1 : 0);
+ Data[0x15EF + GBO] = (byte)(value >= 2 ? 1 : 0);
+ Data[0x15EE + GBO] = (byte)(value >= 1 ? 1 : 0);
+ Data[0x10D1 + GBO] = (byte)(Data[0x10D1 + GBO] & ~8 | (value >= 1 ? 8 : 0));
+ break;
+ case GameVersion.Pt:
+ Data[0x1641 + GBO] = (byte)(value == 4 ? 1 : 0);
+ Data[0x1643 + GBO] = (byte)(value >= 3 ? 1 : 0);
+ Data[0x1640 + GBO] = (byte)(value >= 2 ? 1 : 0);
+ Data[0x1642 + GBO] = (byte)(value >= 1 ? 1 : 0);
break;
- // case GameVersion.Pt: break;
default: return;
}
}
}
// Honey Trees
- private const int HONEY_DP = 0x72E4;
- private const int HONEY_PT = 0x7F38;
+ private int OFS_HONEY = int.MinValue;
private const int HONEY_SIZE = 8;
public HoneyTree getHoneyTree(int index)
{
- if (index > 21)
- return null;
- switch (Version)
- {
- case GameVersion.DP:
- return new HoneyTree(getData(HONEY_DP + HONEY_SIZE*index, HONEY_SIZE));
- case GameVersion.Pt:
- return new HoneyTree(getData(HONEY_PT + HONEY_SIZE*index, HONEY_SIZE));
- }
- return null;
+ if (index <= 21 && OFS_HONEY > 0)
+ return new HoneyTree(getData(OFS_HONEY + HONEY_SIZE * index, HONEY_SIZE));
+ else return null;
}
public void setHoneyTree(HoneyTree tree, int index)
{
- if (index > 21)
- return;
- switch (Version)
- {
- case GameVersion.DP:
- setData(tree.Data, HONEY_DP + HONEY_SIZE*index);
- break;
- case GameVersion.Pt:
- setData(tree.Data, HONEY_PT + HONEY_SIZE*index);
- break;
- }
+ if (index <= 21 && OFS_HONEY > 0)
+ setData(tree.Data, OFS_HONEY + HONEY_SIZE * index);
}
public int[] MunchlaxTrees
{
@@ -1116,78 +1112,6 @@ public int[] MunchlaxTrees
return new[] { A, B, C, D };
}
}
- public int PoketchApps
- {
- get
- {
- int ret = 0;
- int ofs;
- switch (Version)
- {
- case GameVersion.DP: ofs = 0x114F; break;
- default: return ret;
- }
- ofs += GBO;
- for (int i = 0; i < 25; i++)
- {
- if (Data[ofs + i] != 0) ret |= 1 << i;
- }
- return ret;
- }
- set
- {
- int c = 0;
- int ofs;
- switch (Version)
- {
- case GameVersion.DP: ofs = 0x114F; break;
- default: return;
- }
- ofs += GBO;
- for (int i = 0; i < 25; i++)
- {
- if ((value & 1 << i) != 0)
- {
- c++;
- if (Data[ofs + i] == 0)
- Data[ofs + i] = 1;
- }
- else Data[ofs + i] = 0;
- }
- Data[ofs - 2] = (byte)c;
- Data[ofs - 1] = 0; // current used, force set for first App.
- }
- }
- public byte[] PoketchDotArtist
- {
- get
- {
- byte[] ret = new byte[120]; // 2bit*24px*20px
- int ofs;
- switch (Version)
- {
- case GameVersion.DP: ofs = 0x1176; break;
- default: return ret;
- }
- ofs += GBO;
- for (int i = 0; i < 120; i++)
- ret[i] = Data[ofs + i];
- return ret;
- }
- set
- {
- int ofs;
- switch (Version)
- {
- case GameVersion.DP: ofs = 0x1176; break;
- default: return;
- }
- ofs += GBO;
- for (int i = 0; i < 120; i++)
- Data[ofs + i] = value[i];
- Data[ofs - 0x2A] |= 0x04; // 0x114C "Touch!"
- }
- }
public override string getString(int Offset, int Count) => PKX.getString4(Data, Offset, Count);
public override byte[] setString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
diff --git a/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs b/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs
index fe2e8152c..9aeed0668 100644
--- a/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs
+++ b/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs
@@ -948,7 +948,7 @@ public bool ToggleInterface()
B_CGearSkin.Enabled = SAV.Generation == 5;
B_OpenTrainerInfo.Enabled = B_OpenItemPouch.Enabled = SAV.HasParty; // Box RS
- B_OpenMiscEditor.Enabled = SAV.Generation <= 5 && SAV.Generation >= 3 && !SAV.Pt;
+ B_OpenMiscEditor.Enabled = SAV is SAV3 || SAV is SAV4 || SAV is SAV5;
B_OpenHoneyTreeEditor.Enabled = SAV.DP || SAV.Pt;
B_OpenRTCEditor.Enabled = SAV.RS || SAV.E;
diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.Designer.cs
index c0be9a819..6803298b6 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.Designer.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.Designer.cs
@@ -35,7 +35,6 @@ private void InitializeComponent()
this.TAB_Main = new System.Windows.Forms.TabPage();
this.NUD_BP = new System.Windows.Forms.NumericUpDown();
this.L_BP = new System.Windows.Forms.Label();
- this.CHK_UpgradeTC = new System.Windows.Forms.CheckBox();
this.CB_UpgradeMap = new System.Windows.Forms.ComboBox();
this.GB_FlyDest = new System.Windows.Forms.GroupBox();
this.B_AllFlyDest = new System.Windows.Forms.Button();
@@ -92,6 +91,8 @@ private void InitializeComponent()
this.NUD_CastleRankItem = new System.Windows.Forms.NumericUpDown();
this.NUD_CastleRankInfo = new System.Windows.Forms.NumericUpDown();
this.L_CastleRank01 = new System.Windows.Forms.Label();
+ this.NUD_UGFlags = new System.Windows.Forms.NumericUpDown();
+ this.L_UGFlags = new System.Windows.Forms.Label();
this.TC_Misc.SuspendLayout();
this.TAB_Main.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_BP)).BeginInit();
@@ -128,6 +129,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.NUD_CastleRankRcv)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_CastleRankItem)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_CastleRankInfo)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.NUD_UGFlags)).BeginInit();
this.SuspendLayout();
//
// B_Cancel
@@ -164,9 +166,10 @@ private void InitializeComponent()
//
// TAB_Main
//
+ this.TAB_Main.Controls.Add(this.L_UGFlags);
+ this.TAB_Main.Controls.Add(this.NUD_UGFlags);
this.TAB_Main.Controls.Add(this.NUD_BP);
this.TAB_Main.Controls.Add(this.L_BP);
- this.TAB_Main.Controls.Add(this.CHK_UpgradeTC);
this.TAB_Main.Controls.Add(this.CB_UpgradeMap);
this.TAB_Main.Controls.Add(this.GB_FlyDest);
this.TAB_Main.Controls.Add(this.GB_Poketch);
@@ -205,16 +208,6 @@ private void InitializeComponent()
this.L_BP.Text = "BP:";
this.L_BP.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
- // CHK_UpgradeTC
- //
- this.CHK_UpgradeTC.AutoSize = true;
- this.CHK_UpgradeTC.Location = new System.Drawing.Point(5, 40);
- this.CHK_UpgradeTC.Name = "CHK_UpgradeTC";
- this.CHK_UpgradeTC.Size = new System.Drawing.Size(165, 16);
- this.CHK_UpgradeTC.TabIndex = 2;
- this.CHK_UpgradeTC.Text = "Upgrade TrainerCard (HOF)";
- this.CHK_UpgradeTC.UseVisualStyleBackColor = true;
- //
// CB_UpgradeMap
//
this.CB_UpgradeMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
@@ -1041,6 +1034,32 @@ private void InitializeComponent()
this.L_CastleRank01.Text = "Recovery / Item / Info";
this.L_CastleRank01.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
+ // NUD_UGFlags
+ //
+ this.NUD_UGFlags.Location = new System.Drawing.Point(109, 33);
+ this.NUD_UGFlags.Maximum = new decimal(new int[] {
+ 999999,
+ 0,
+ 0,
+ 0});
+ this.NUD_UGFlags.Name = "NUD_UGFlags";
+ this.NUD_UGFlags.Size = new System.Drawing.Size(61, 19);
+ this.NUD_UGFlags.TabIndex = 2;
+ this.NUD_UGFlags.Value = new decimal(new int[] {
+ 999999,
+ 0,
+ 0,
+ 0});
+ //
+ // L_UGFlags
+ //
+ this.L_UGFlags.Location = new System.Drawing.Point(3, 30);
+ this.L_UGFlags.Name = "L_UGFlags";
+ this.L_UGFlags.Size = new System.Drawing.Size(100, 23);
+ this.L_UGFlags.TabIndex = 7;
+ this.L_UGFlags.Text = "Flags Obtained";
+ this.L_UGFlags.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
// SAV_Misc4
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -1092,6 +1111,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.NUD_CastleRankRcv)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_CastleRankItem)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_CastleRankInfo)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.NUD_UGFlags)).EndInit();
this.ResumeLayout(false);
}
@@ -1104,7 +1124,6 @@ private void InitializeComponent()
private System.Windows.Forms.TabPage TAB_Main;
private System.Windows.Forms.NumericUpDown NUD_BP;
private System.Windows.Forms.Label L_BP;
- private System.Windows.Forms.CheckBox CHK_UpgradeTC;
private System.Windows.Forms.ComboBox CB_UpgradeMap;
private System.Windows.Forms.GroupBox GB_FlyDest;
private System.Windows.Forms.Button B_AllFlyDest;
@@ -1161,5 +1180,7 @@ private void InitializeComponent()
private System.Windows.Forms.NumericUpDown NUD_CastleRankItem;
private System.Windows.Forms.NumericUpDown NUD_CastleRankInfo;
private System.Windows.Forms.Label L_CastleRank01;
+ private System.Windows.Forms.Label L_UGFlags;
+ private System.Windows.Forms.NumericUpDown NUD_UGFlags;
}
}
diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs
index 52c9f8567..e2d9d440b 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs
@@ -17,28 +17,66 @@ public SAV_Misc4(SaveFile sav)
SAV = (SAV4)(Origin = sav).Clone();
InitializeComponent();
+ int GBO = SAV.getGBO;
switch (SAV.Version)
{
+ case GameVersion.D:
+ case GameVersion.P:
case GameVersion.DP:
- readMain(isPoketch: true, isFly: true, isBP: true, isTC: false, isMap: false);
- readBF();
+ ofsFlag = GBO + 0xFDC;
+ ofsBP = GBO + 0x65F8;
+ ofsUGFlagCount = GBO + 0x3A60;
+ ofsPoketch = GBO + 0x114F;
+ CB_UpgradeMap.Visible = false;
+ GB_Prints.Visible = GB_Prints.Enabled = GB_Hall.Visible = GB_Hall.Enabled = GB_Castle.Visible = GB_Castle.Enabled = false;
+ BFF = new[] { new[] { 0, 1, 0x5FCA, 0x04, 0x6601 }, };
break;
+ case GameVersion.Pt:
+ ofsFlag = GBO + 0xFEC;
+ ofsBP = GBO + 0x7234;
+ ofsUGFlagCount = GBO + 0x3CE8;
+ ofsPoketch = GBO + 0x1163;
+ CB_UpgradeMap.Visible = false;
+ ofsPrints = GBO + 0xE4A;
+ BFF = new[] {
+ new[] { 0, 1, 0x68E0, 0x04, 0x723D },
+ new[] { 1, 0, 0x68F4, 0x10, 0x7EF8 },
+ new[] { 0, 0, 0x6924, 0x18, 0x7EFC },
+ new[] { 2, 0, 0x696C, 0x10, 0x7F00 },
+ new[] { 0, 0, 0x699C, 0x04, 0x7F04 },
+ };
+ ofsHallStat = GBO + 0x2820;
+ break;
+ case GameVersion.HG:
+ case GameVersion.SS:
case GameVersion.HGSS:
- readMain(isPoketch: false, isFly: true, isBP: true, isTC: true, isMap: true);
- readBF();
- break;
- default:
- readMain();
- TC_Misc.Controls.Remove(TAB_BF);
+ ofsFlag = GBO + 0x10C4;
+ ofsBP = GBO + 0x5BB8;
+ NUD_UGFlags.Visible = false;
+ GB_Poketch.Visible = false;
+ ofsMap = GBO + 0xBAE7;
+ ofsPrints = GBO + 0xE7E;
+ BFF = new[] {
+ // { BFV, BFT, addr, 1BFTlen, checkBit
+ new[] { 0, 1, 0x5264, 0x04, 0x5BC1 },
+ new[] { 1, 0, 0x5278, 0x10, 0x687C },
+ new[] { 0, 0, 0x52A8, 0x18, 0x6880 },
+ new[] { 2, 0, 0x52F0, 0x10, 0x6884 },
+ new[] { 0, 0, 0x5320, 0x04, 0x6888 },
+ };
+ ofsHallStat = GBO + 0x230C;
break;
+ default: return;
}
+ ofsFly = ofsFlag + 0x136;
+ readMain();
+ readBF();
}
private void B_Save_Click(object sender, EventArgs e)
{
saveMain();
- if (TC_Misc.Controls.Contains(TAB_BF))
- saveBF();
+ saveBF();
Origin.setData(SAV.Data, 0);
Close();
@@ -49,137 +87,84 @@ private void B_Cancel_Click(object sender, EventArgs e)
Close();
}
+ private int ofsFlag;
private int ofsFly;
private int ofsBP;
+ private int ofsMap = -1;
+ private int ofsUGFlagCount = -1;
+ private int ofsPoketch = -1;
private int[] FlyDestC;
- private void readMain(bool isPoketch = false, bool isFly = false, bool isBP = false, bool isTC = false, bool isMap = false)
+ private void readMain()
{
- int GBO = SAV.getGBO;
- if (isPoketch)
- readPoketch();
- else GB_Poketch.Visible = false;
-
- if (isFly)
+ int[] FlyDestD;
+ System.Collections.Generic.List metLocationList;
+ switch (SAV.Version)
{
- string[] FlyDestA = null;
- switch (SAV.Version)
- {
- case GameVersion.HGSS:
- ofsFly = GBO + 0x11FA;
- FlyDestA = new[] {
- "NewBark Town", "Cherrygrove City", "Violet City", "Azalea Town",
- "Goldenrod City", "Ecruteak City", "Olivine City", "Cianwood City",
- "Mahogany Town", "Lake of Rage", "Blackthorn City",
- "Safari Zone Gate", "Frontier Access", "Mt.Silver",
- "Victory Road", "Indigo Plateau",
- "Pallet Town", "Viridian City", "Pewter City", "Cerulean City", "Vermilion City",
- "Lavender Town", "Celadon City", "Saffron City", "Fuchsia City", "Cinnabar Island"
- };
- FlyDestC = new[] {
- 11, 12, 13, 14,
- 16, 18, 17, 15,
- 19, 20, 21,
- 30, 27, 22,
- 33, 9,
- 0, 1, 2, 3, 5,
- 4, 6, 10, 7, 8
- };
- break;
- case GameVersion.DP:
- ofsFly = GBO + 0x1112;
- FlyDestA = new[] {
- "Twinleaf Town", "Sandgem Town", "Jubilife City", "Oreburgh City",
- "Floaroma Town", "Eterna City", "Hearthome City", "Solaceon Town",
- "Veilstone City", "Pastoria City", "Celestic Town", "Canalave City",
- "Snowpoint City", "Sunyshore City",
- "Pokemon League", "Fight Area", "Survival Area", "Resort Area"
- };
- FlyDestC = new[] {
- 0, 1, 7, 9,
- 2, 10, 11, 3,
- 13, 12, 4, 8,
- 15, 14,
- 68, 17, 5, 6
- };
- break;
- }
- uint val = BitConverter.ToUInt32(SAV.Data, ofsFly);
- CLB_FlyDest.Items.Clear();
- CLB_FlyDest.Items.AddRange(FlyDestA);
- for (int i = 0; i < CLB_FlyDest.Items.Count; i++)
- {
- if (FlyDestC[i] < 32)
- CLB_FlyDest.SetItemChecked(i, (val & (uint)1 << FlyDestC[i]) != 0);
- else
- CLB_FlyDest.SetItemChecked(i, (SAV.Data[ofsFly + (FlyDestC[i] >> 3)] & 1 << (FlyDestC[i] - (FlyDestC[i] >> 3 << 3))) != 0);
- }
+ case GameVersion.D:
+ case GameVersion.P:
+ case GameVersion.DP:
+ case GameVersion.Pt:
+ metLocationList = GameInfo.getLocationList(GameVersion.Pt, 4, false);
+ FlyDestD = new[] { 1, 2, 6, 8, 3, 9, 10, 4, 12, 11, 5, 7, 14, 13, 54, 15, 81, 82, 83, 55, };
+ FlyDestC = new[] { 0, 1, 7, 9, 2, 10, 11, 3, 13, 12, 4, 8, 15, 14, 16, 68, 17, 5, 6, 67, };
+ break;
+ case GameVersion.HG:
+ case GameVersion.SS:
+ case GameVersion.HGSS:
+ metLocationList = GameInfo.getLocationList(GameVersion.HG, 4, false);
+ FlyDestD = new[] { 126, 127, 128, 129, 131, 133, 132, 130, 134, 135, 136, 227, 229, 137, 221, 147, 138, 139, 140, 141, 143, 142, 144, 148, 145, 146, 225, };
+ FlyDestC = new[] { 11, 12, 13, 14, 16, 18, 17, 15, 19, 20, 21, 30, 27, 22, 33, 9, 0, 1, 2, 3, 5, 4, 6, 10, 7, 8, 35, };
+ break;
+ default: return;
}
- else GB_FlyDest.Visible = false;
+ uint valFly = BitConverter.ToUInt32(SAV.Data, ofsFly);
+ CLB_FlyDest.Items.Clear();
+ for (int i = 0; i < FlyDestD.Length; i++)
+ CLB_FlyDest.Items.Add(metLocationList.First(v => v.Value == FlyDestD[i]).Text, FlyDestC[i] < 32 ? (valFly & (uint)1 << FlyDestC[i]) != 0 : (SAV.Data[ofsFly + (FlyDestC[i] >> 3)] & 1 << (FlyDestC[i] & 7)) != 0);
+ uint valBP = BitConverter.ToUInt16(SAV.Data, ofsBP);
+ NUD_BP.Value = valBP > 9999 ? 9999 : valBP;
- if (isBP)
+ if (ofsPoketch > 0) readPoketch();
+ if (ofsUGFlagCount > 0)
{
- switch (SAV.Version)
- {
- case GameVersion.HGSS: ofsBP = GBO + 0x5BB8; break;
- case GameVersion.DP: ofsBP = GBO + 0x65F8; break;
- }
- uint val = BitConverter.ToUInt16(SAV.Data, ofsBP);
- if (val > 9999) val = 9999;
- NUD_BP.Value = val;
+ uint fc = BitConverter.ToUInt32(SAV.Data, ofsUGFlagCount) & 0xFFFFF;
+ NUD_UGFlags.Value = fc > 999999 ? 999999 : fc;
}
- else L_BP.Visible = NUD_BP.Visible = false;
-
- if (isTC)
- CHK_UpgradeTC.Checked = (SAV.Data[GBO + 0x11F0] & 0x10) != 0;
- else CHK_UpgradeTC.Visible = false;
-
- if (isMap)
+ if (ofsMap > 0)
{
string[] items = new[] { "Map Johto", "Map Johto+", "Map Johto & Kanto" };
- int index = SAV.Data[SAV.getGBO + 0xBAE7] >> 3 & 3;
+ int index = SAV.Data[ofsMap] >> 3 & 3;
if (index > 2) index = 2;
CB_UpgradeMap.Items.AddRange(items);
CB_UpgradeMap.SelectedIndex = index;
}
- else CB_UpgradeMap.Visible = false;
}
private void saveMain()
{
- int GBO = SAV.getGBO;
- if (GB_Poketch.Visible)
+ uint valFly = BitConverter.ToUInt32(SAV.Data, ofsFly);
+ for (int i = 0; i < CLB_FlyDest.Items.Count; i++)
{
- savePoketch();
- }
- if (GB_FlyDest.Visible)
- {
- uint val = BitConverter.ToUInt32(SAV.Data, ofsFly);
- for (int i = 0; i < CLB_FlyDest.Items.Count; i++)
+ if (FlyDestC[i] < 32)
{
- if (FlyDestC[i] < 32)
- {
- if (CLB_FlyDest.GetItemChecked(i))
- val |= (uint)1 << FlyDestC[i];
- else
- val &= ~((uint)1 << FlyDestC[i]);
- }
- else SAV.Data[ofsFly + (FlyDestC[i] >> 3)] = (byte)(SAV.Data[ofsFly + (FlyDestC[i] >> 3)] & ~(1 << (FlyDestC[i] - (FlyDestC[i] >> 3 << 3))) | ((CLB_FlyDest.GetItemChecked(i) ? 1 : 0) << (FlyDestC[i] - (FlyDestC[i] >> 3 << 3))));
+ if (CLB_FlyDest.GetItemChecked(i))
+ valFly |= (uint)1 << FlyDestC[i];
+ else
+ valFly &= ~((uint)1 << FlyDestC[i]);
}
- BitConverter.GetBytes(val).CopyTo(SAV.Data, ofsFly);
-
+ else SAV.Data[ofsFly + (FlyDestC[i] >> 3)] = (byte)(SAV.Data[ofsFly + (FlyDestC[i] >> 3)] & ~(1 << (FlyDestC[i] & 7)) | (CLB_FlyDest.GetItemChecked(i) ? 1 << (FlyDestC[i] & 7) : 0));
}
- if (NUD_BP.Visible)
- BitConverter.GetBytes((ushort)NUD_BP.Value).CopyTo(SAV.Data, ofsBP);
+ BitConverter.GetBytes(valFly).CopyTo(SAV.Data, ofsFly);
+ BitConverter.GetBytes((ushort)NUD_BP.Value).CopyTo(SAV.Data, ofsBP);
- if (CHK_UpgradeTC.Visible)
- SAV.Data[GBO + 0x11F0] = (byte)(SAV.Data[GBO + 0x11F0] & 0xEF | (CHK_UpgradeTC.Checked ? 0x10 : 0));
-
- if (CB_UpgradeMap.Visible)
+ if (ofsPoketch > 0) savePoketch();
+ if (ofsUGFlagCount > 0)
+ BitConverter.GetBytes(BitConverter.ToUInt32(SAV.Data, ofsUGFlagCount) & ~(uint)0xFFFFF | (uint)NUD_UGFlags.Value).CopyTo(SAV.Data, ofsUGFlagCount);
+ if (ofsMap > 0)
{
- int val = CB_UpgradeMap.SelectedIndex;
- if (val >= 0)
- SAV.Data[GBO + 0xBAE7] = (byte)(SAV.Data[GBO + 0xBAE7] & 0xE7 | val << 3);
+ int valMap = CB_UpgradeMap.SelectedIndex;
+ if (valMap >= 0)
+ SAV.Data[ofsMap] = (byte)(SAV.Data[ofsMap] & 0xE7 | valMap << 3);
}
-
}
private void B_AllFlyDest_Click(object sender, EventArgs e)
{
@@ -190,6 +175,7 @@ private void B_AllFlyDest_Click(object sender, EventArgs e)
#region Poketch
private byte[] DotArtistByte;
private byte[] ColorTable;
+ private bool[] oldPoketchVal;
private readonly ToolTip tip1 = new ToolTip();
private void readPoketch()
{
@@ -200,14 +186,15 @@ private void readPoketch()
"16 Move Tester", "17 Calendar", "18 Dot Artist", "19 Roulette", "20 Trainer Counter",
"21 Kitchen Timer", "22 Color Changer", "23 Matchup Checker", "24 Stopwatch", "25 Alarm Clock"
};
+ oldPoketchVal = new bool[PoketchTitle.Length];
CLB_Poketch.Items.Clear();
- CLB_Poketch.Items.AddRange(PoketchTitle);
+ for (int i = 0; i < PoketchTitle.Length; i++)
+ {
+ oldPoketchVal[i] = SAV.Data[ofsPoketch + i] != 0;
+ CLB_Poketch.Items.Add(PoketchTitle[i], oldPoketchVal[i]);
+ }
- int ret = SAV.PoketchApps;
- for (int i = 0; i < CLB_Poketch.Items.Count; i++)
- CLB_Poketch.SetItemChecked(i, (ret & 1 << i) != 0);
-
- DotArtistByte = SAV.PoketchDotArtist;
+ DotArtistByte = SAV.Data.Skip(ofsPoketch + 0x27).Take(120).ToArray();
ColorTable = new byte[] { 248, 168, 88, 8 };
setPictureBoxFromFlags(DotArtistByte);
string tip = "Guide about D&D ImageFile Format";
@@ -220,12 +207,24 @@ private void readPoketch()
}
private void savePoketch()
{
- int ret = 0;
- for(int i = 0; i < CLB_Poketch.Items.Count; i++)
- if (CLB_Poketch.GetItemChecked(i)) ret |= 1 << i;
-
- SAV.PoketchApps = ret;
- SAV.PoketchDotArtist = DotArtistByte;
+ byte count = 0;
+ for (int i = 0; i < CLB_Poketch.Items.Count; i++)
+ {
+ if (CLB_Poketch.GetItemChecked(i))
+ {
+ count++;
+ if (!oldPoketchVal[i])
+ SAV.Data[ofsPoketch + i] = 1;
+ }
+ else if (oldPoketchVal[i])
+ SAV.Data[ofsPoketch + i] = 0;
+ }
+ SAV.Data[ofsPoketch - 2] = count;
+ byte current = SAV.Data[ofsPoketch - 1];
+ if (current >= CLB_Poketch.Items.Count || !CLB_Poketch.GetItemChecked(current))
+ SAV.Data[ofsPoketch - 1] = 0;
+ DotArtistByte.CopyTo(SAV.Data, ofsPoketch + 0x27);
+ SAV.Data[ofsPoketch - 3] |= 0x04; // "Touch!"
}
private void setPictureBoxFromFlags(byte[] inp)
@@ -386,7 +385,7 @@ private void PB_DotArtist_MouseClick(object sender, MouseEventArgs e)
#region BattleFrontier
private int[] Prints;
- private int ofsPrints;
+ private int ofsPrints = -1;
private Color[] PrintColorA;
private Button[] PrintButtonA;
private bool editing;
@@ -399,58 +398,32 @@ private void PB_DotArtist_MouseClick(object sender, MouseEventArgs e)
private string[] BFN;
private readonly ToolTip tip2 = new ToolTip();
private NumericUpDown[] HallNUDA;
- private bool XBupdated = false;
+ private bool HallStatUpdated = false;
+ private int ofsHallStat = -1;
private void readBF()
{
- switch (SAV.Version)
- {
- case GameVersion.DP:
- BFF = new[]
- {
- new[] { 0, 1, 0x5FCA, 0x04, 0x6601 },
- };
- break;
- case GameVersion.HGSS:
- BFF = new[] {
- // { BFV, BFT, addr, 1BFTlen, checkBit
- new[] { 0, 1, 0x5264, 0x04, 0x5BC1 },
- new[] { 1, 0, 0x5278, 0x10, 0x687C },
- new[] { 0, 0, 0x52A8, 0x18, 0x6880 },
- new[] { 2, 0, 0x52F0, 0x10, 0x6884 },
- new[] { 0, 0, 0x5320, 0x04, 0x6888 },
- };
- break;
- }
- BFV = new[]
- {
+ BFV = new[] {
new[] { 2, 0 }, // Max, Current
new[] { 2, 0, 3, 1 }, // Max, Current, Max(Trade), Current(Trade)
new[] { 2, 0, 1, -1, 3 }, // Max, Current, Current(CP), (UsedCP), Max(CP)
};
BFT = new[] {
new[] { "Singles", "Doubles", "Multi" },
- new[] { "Singles", "Doubles", "Multi(NPC)", "Multi(2P)", "WiFi" },
- };
- BFN = new[]
- {
- "Tower","Factory","Hall","Castle","Arcade"
+ new[] { "Singles", "Doubles", "Multi(Trainer)", "Multi(friend)", "WiFi" },
};
+ BFN = new[] { "Tower", "Factory", "Hall", "Castle", "Arcade" };
+ if (SAV.DP) BFN = BFN.Take(1).ToArray();
StatNUDA = new[] { NUD_Stat0, NUD_Stat1, NUD_Stat2, NUD_Stat3 };
StatLabelA = new[] { L_Stat0, L_Stat1, L_Stat2, L_Stat3 };
StatRBA = new[] { RB_Stats3_01, RB_Stats3_02 };
- switch (SAV.Version)
- {
- case GameVersion.DP: BFN = BFN.Take(1).ToArray(); ofsPrints = -1; break;
- case GameVersion.HGSS: ofsPrints = SAV.getGBO + 0xE7E; break;
- }
if (ofsPrints > 0)
{
PrintColorA = new[] { Color.Transparent, Color.Silver, Color.Gold };
PrintButtonA = new[] { BTN_PrintTower, BTN_PrintFactory, BTN_PrintHall, BTN_PrintCastle, BTN_PrintArcade };
Prints = new int[PrintButtonA.Length];
for (int i = 0; i < Prints.Length; i++)
- Prints[i] = 1 + Math.Sign((BitConverter.ToUInt16(SAV.Data, ofsPrints + i * 2) >> 1) - 1);
+ Prints[i] = 1 + Math.Sign((BitConverter.ToUInt16(SAV.Data, ofsPrints + (i << 1)) >> 1) - 1);
setPrints();
HallNUDA = new[] {
@@ -463,8 +436,34 @@ private void readBF()
for (int i = 0; i < HallNUDA.Length; i++)
tip2.SetToolTip(HallNUDA[i], TypeName[typenameIndex[i]]);
}
- else
- GB_Prints.Visible = GB_Prints.Enabled = GB_Hall.Visible = GB_Hall.Enabled = GB_Castle.Visible = GB_Castle.Enabled = false;
+ if (ofsHallStat > 0)
+ {
+ bool f = false;
+ for (int i = 0, h; i < 2; i++, ofsHallStat += 0x14)
+ {
+ h = BitConverter.ToInt32(SAV.Data, ofsHallStat);
+ if (h == -1) continue;
+ for (int j = 0; j < 0x20; j++)
+ {
+ for (int k = 0, a = j + 0x20 << 12; k < 2; k++, a += 0x40000)
+ {
+ if (h == BitConverter.ToInt32(SAV.Data, a) && BitConverter.ToInt16(SAV.Data, a + 0xBA8) == 0xBA0)
+ {
+ f = true;
+ ofsHallStat = a;
+ break;
+ }
+ }
+ if (f) break;
+ }
+ if (f) break;
+ }
+ if (!f)
+ {
+ ofsHallStat = -1;
+ NUD_HallStreaks.Visible = NUD_HallStreaks.Enabled = false;
+ }
+ }
editing = true;
CB_Stats1.Items.Clear();
@@ -486,13 +485,13 @@ private void readBF()
}
private void saveBF()
{
- if(GB_Prints.Visible)
+ if(ofsPrints > 0)
for(int i = 0; i < Prints.Length; i++)
{
- if (Prints[i] == 1 + Math.Sign((BitConverter.ToUInt16(SAV.Data, ofsPrints + i * 2) >> 1) - 1)) continue;
- BitConverter.GetBytes(Prints[i] << 1).CopyTo(SAV.Data, ofsPrints + i * 2);
+ if (Prints[i] == 1 + Math.Sign((BitConverter.ToUInt16(SAV.Data, ofsPrints + (i << 1)) >> 1) - 1)) continue;
+ BitConverter.GetBytes(Prints[i] << 1).CopyTo(SAV.Data, ofsPrints + (i << 1));
}
- if (XBupdated) setXBChksum();
+ if (HallStatUpdated) BitConverter.GetBytes(SaveUtil.ccitt16(SAV.Data.Skip(ofsHallStat).Take(0xBAE).ToArray())).CopyTo(SAV.Data, ofsHallStat + 0xBAE);
}
private void setPrints()
@@ -548,14 +547,14 @@ private void ChangeStat(object sender, EventArgs e)
if (editing) return;
if (sender is RadioButton && ((RadioButton)sender).Checked == false) return;
StatAddrControl(SetValToSav: -2, SetSavToVal: true);
- if (CB_Stats1.SelectedIndex == 2)
+ if (GB_Hall.Visible)
{
GB_Hall.Text = "Battle Hall (" + (string)CB_Stats2.SelectedItem + ")";
editing = true;
getHallStat();
editing = false;
}
- else if (CB_Stats1.SelectedIndex == 3)
+ else if (GB_Castle.Visible)
{
GB_Castle.Text = "Battle Castle (" + (string)CB_Stats2.SelectedItem + ")";
editing = true;
@@ -571,12 +570,7 @@ private void StatAddrControl(int SetValToSav = -2, bool SetSavToVal = false)
int addrVal = SAV.getGBO + BFF[Facility][2] + BFF[Facility][3] * BattleType + (RBi << 3);
int addrFlag = SAV.getGBO + BFF[Facility][4];
byte maskFlag = (byte)(1 << BattleType + (RBi << 2));
- int TowerContinueCountOfs = 0;
- switch (SAV.Version)
- {
- case GameVersion.DP: TowerContinueCountOfs = 3; break;
- case GameVersion.HGSS: TowerContinueCountOfs = 1; break;
- }
+ int TowerContinueCountOfs = SAV.DP ? 3 : 1;
if (SetSavToVal)
{
@@ -585,8 +579,7 @@ private void StatAddrControl(int SetValToSav = -2, bool SetSavToVal = false)
{
if (BFV[BFF[Facility][0]][i] < 0) continue;
int vali = BitConverter.ToUInt16(SAV.Data, addrVal + (i << 1));
- if (vali > 9999) vali = 9999;
- StatNUDA[BFV[BFF[Facility][0]][i]].Value = vali;
+ StatNUDA[BFV[BFF[Facility][0]][i]].Value = vali > 9999 ? 9999 : vali;
}
CHK_Continue.Checked = (SAV.Data[addrFlag] & maskFlag) != 0;
@@ -605,8 +598,7 @@ private void StatAddrControl(int SetValToSav = -2, bool SetSavToVal = false)
SetValToSav = Array.IndexOf(BFV[BFF[Facility][0]], SetValToSav);
if (SetValToSav < 0) return;
- if (val > 9999) val = 9999;
- BitConverter.GetBytes(val).CopyTo(SAV.Data, addrVal + (SetValToSav << 1));
+ BitConverter.GetBytes((ushort)(val > 9999 ? 9999 : val)).CopyTo(SAV.Data, addrVal + (SetValToSav << 1));
return;
}
else if (SetValToSav == -1)
@@ -648,18 +640,6 @@ private void CHK_Continue_CheckedChanged(object sender, EventArgs e)
StatAddrControl(SetValToSav: -1, SetSavToVal: false);
}
- // memo BattleStage !:write
- //
- // 0x0230C randC randC !!randD randD !randD randD !!randE
- // 0x02320 randB randB !!randC randC !randC randC !!randD
- // 0x0F618 1235 1235 !!1237 1237 !!1239 1239 !!1241
- // 0x26000 randC randC randC randC randC randC !!randE
- // -->StartBS-->EndBS -->MenuSave-->MenuSave -->StartBS-->EndBS
- // 0x4230C randB !!randC randC !!randD randD !randD randD
- // 0x42320 randA !!randB randB !!randC randC !randC randC
- // 0x4F618 1234 !!1236 1236 !!1238 1238 !!1240 1240
- // 0x66000 randB randB !!randD randD randD randD randD
-
private int species = -1;
private void changeCBSpecies(object sender, EventArgs e)
{
@@ -676,9 +656,7 @@ private void getCastleStat()
for (int i = 0, val; i < na.Length; i++)
{
val = BitConverter.ToInt16(SAV.Data, ofs + (i << 1));
- if (val > na[i].Maximum) val = (int)na[i].Maximum;
- if (val < na[i].Minimum) val = (int)na[i].Minimum;
- na[i].Value = val;
+ na[i].Value = val > na[i].Maximum ? na[i].Maximum : val < na[i].Minimum ? na[i].Minimum : val;
}
}
private void NUD_CastleRank_ValueChanged(object sender, EventArgs e)
@@ -715,12 +693,11 @@ private void getHallStat()
}
L_SumHall.Text = s.ToString();
- int XBO = getXBO();
- NUD_HallStreaks.Visible = NUD_HallStreaks.Enabled = XBO > 0;
- if (XBO <= 0) return;
- ushort v = BitConverter.ToUInt16(SAV.Data, XBO + 4 + 0x3DE * CB_Stats2.SelectedIndex + (species << 1));
- if (v > 9999) v = 9999;
- NUD_HallStreaks.Value = v;
+ if (ofsHallStat > 0)
+ {
+ ushort v = BitConverter.ToUInt16(SAV.Data, ofsHallStat + 4 + 0x3DE * CB_Stats2.SelectedIndex + (species << 1));
+ NUD_HallStreaks.Value = v > 9999 ? 9999 : v;
+ }
}
private void CHK_HallCurrent_CheckedChanged(object sender, EventArgs e)
@@ -744,44 +721,11 @@ private void NUD_HallType_ValueChanged(object sender, EventArgs e)
private void NUD_HallStreaks_ValueChanged(object sender, EventArgs e)
{
- if (editing) return;
- int XBO = getXBO();
- if (XBO < 0) return;
- BitConverter.GetBytes((ushort)NUD_HallStreaks.Value).CopyTo(SAV.Data, XBO + 4 + 0x3DE * CB_Stats2.SelectedIndex + (species << 1));
- XBupdated = true;
- }
- private int getXBO()
- {
- int[] XBC = new int[0x1E * 2];
- for (int i = 0; i < 0x1E; i++)
- {
- XBC[i] = BitConverter.ToInt32(SAV.Data, 0x22 + i << 12);
- XBC[i + 0x1E] = BitConverter.ToInt32(SAV.Data, 0x62 + i << 12);
- }
- for (int i = 0, h, j, a; i < 10; i++)
- {
- a = SAV.getGBO + 0x230C + (i << 2);
- h = BitConverter.ToInt32(SAV.Data, a);
- if (h == -1) continue;
- j = Array.IndexOf(XBC, h);
- if (j < 0) continue;
- if (j < 0x1E)
- a = 0x22 + j;
- else
- a = 0x44 + j;
- a <<= 12;
- if (BitConverter.ToUInt16(SAV.Data, a + 0xBA8) == 0xBA0)
- return a;
- }
- return -1;
- }
- private void setXBChksum()
- {
- int XBO = getXBO();
- if (XBO < 0) return;
- BitConverter.GetBytes(SaveUtil.ccitt16(SAV.Data.Skip(XBO).Take(0xBAE).ToArray())).CopyTo(SAV.Data, XBO + 0xBAE);
+ if (editing || ofsHallStat < 0) return;
+ BitConverter.GetBytes((ushort)NUD_HallStreaks.Value).CopyTo(SAV.Data, ofsHallStat + 4 + 0x3DE * CB_Stats2.SelectedIndex + (species << 1));
+ HallStatUpdated = true;
}
#endregion
}
-}
+}
\ No newline at end of file
diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs
index fc129ec9c..66e825785 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs
@@ -111,6 +111,9 @@ private string[] getStringList(string type)
case GameVersion.DP:
gamePrefix = "dp";
break;
+ case GameVersion.Pt:
+ gamePrefix = "pt";
+ break;
case GameVersion.HGSS:
gamePrefix = "hgss";
break;