Misc updates

fix hall of fame fixed offset
fix ball throw type unlock/learned flags using fixed offset
fix current throw type defaulting to -1 when Nihilist (new USUM style)
by adding in for USUM

add fused slot offset fetching
convert event flag combined byte fetch to use Get/SetEventFlag with
event flag references.

add ZRingUnlocked sav properties & checkbox for toggling

set AlolaTime only if the combobox is enabled (only disabled if not yet
set by game)

Closes #1595
This commit is contained in:
Kurt 2017-11-12 21:28:34 -08:00
parent 7bc316d79c
commit dbabcb9ef0
3 changed files with 53 additions and 41 deletions

View file

@ -62,7 +62,7 @@ namespace PKHeX.Core
protected override int GiftCountMax => 48;
protected override int GiftFlagMax => 0x100 * 8;
protected override int EventFlagMax => USUM ? 4928 : 3968;
protected override int EventConstMax => (EventFlag - EventConst) / 2;
protected override int EventConstMax => 1000;
public override int OTLength => 12;
public override int NickLength => 12;
@ -248,7 +248,8 @@ namespace PKHeX.Core
/* 35 */ QRSaveData = Blocks[35].Offset; // 0x6B800 // [1C8] QRReaderSaveData
/* 36 */ // = Blocks[36].Offset; // 0x6BA00 // [200] TurtleSalmonSave
EventFlag = EventConst + 0x7D0;
EventFlag = EventConst + EventConstMax * 2; // After Event Const (u16)*n
HoF = EventFlag + EventFlagMax / 8; // After Event Flags (1b)*(1u8/8b)*n
OFS_PouchHeldItem = Bag + 0; // 430 (Case 0)
OFS_PouchKeyItem = Bag + 0x6B8; // 184 (Case 4)
@ -265,7 +266,6 @@ namespace PKHeX.Core
LastViewedBox = PCLayout + 0x5E3;
PCFlags = PCLayout + 0x5E0;
HoF = 0x25C0; // Inside EventWork (const/flag) block
FashionLength = 0x1A08;
@ -1266,6 +1266,14 @@ namespace PKHeX.Core
Array.Resize(ref TeamSlots, teamCount);
}
private int FusedCount => USUM ? 3 : 1;
public int GetFusedSlotOffset(int slot)
{
if (Fused < 0 || slot < 0 || slot >= FusedCount)
return -1;
return Fused + SIZE_PARTY * slot; // 0x104*slot
}
public override int DaycareSeedSize => 32; // 128 bits
public override int GetDaycareSlotOffset(int loc, int slot)
{
@ -1445,32 +1453,17 @@ namespace PKHeX.Core
return string.Join(Environment.NewLine,
Blocks.Select(b => $"{b.ID:00}: {b.Offset:X5}-{b.Offset + b.Length:X5}, {b.Length:X5}"));
}
public byte BallThrowTypeUnlocked
{
get => (byte)(((BitConverter.ToUInt16(Data, 0x23F4) << 4) >> 10) << 2);
set
{
ushort flags = (ushort)(BitConverter.ToUInt16(Data, 0x23F4) & 0xF03F);
flags |= (ushort)((value & 0xFC) << 4);
BitConverter.GetBytes(flags).CopyTo(Data, 0x23F4);
}
}
public byte BallThrowTypeLearned
{
get => (byte)((Data[0x2583] & 0x7F) << 1);
set => Data[0x2583] = (byte)((Data[0x2583] & 0x80) | ((value & 0xFE) >> 1));
}
public byte BattleTreeSuperUnlocked
{
get => (byte)(Data[0x23F9] >> 5);
set => Data[0x23F9] = (byte)((Data[0x23F9] & 0x1F) | ((value & 0x07) << 5));
}
public bool MegaUnlocked
{
get => (Data[TrainerCard + 0x78] & 0x01) != 0;
set => Data[TrainerCard + 0x78] = (byte)((Data[TrainerCard + 0x78] & 0xFE) | (value ? 1 : 0)); // in battle
// Data[0x1F22] = (byte)((Data[0x1F22] & 0xFE) | (value ? 1 : 0)); // event
}
public bool ZMoveUnlocked
{
get => (Data[TrainerCard + 0x78] & 2) != 0;
set => Data[TrainerCard + 0x78] = (byte)((Data[TrainerCard + 0x78] & ~2) | (value ? 2 : 0)); // in battle
}
public override string GetString(int Offset, int Count) => StringConverter.GetString7(Data, Offset, Count);
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)

View file

@ -192,6 +192,7 @@ namespace PKHeX.WinForms
this.NUD_ThumbsTotal = new System.Windows.Forms.NumericUpDown();
this.L_ThumbsTotal = new System.Windows.Forms.Label();
this.B_Fashion = new System.Windows.Forms.Button();
this.CHK_UnlockZMove = new System.Windows.Forms.CheckBox();
this.TC_Editor.SuspendLayout();
this.Tab_Overview.SuspendLayout();
this.GB_Stats.SuspendLayout();
@ -1669,6 +1670,7 @@ namespace PKHeX.WinForms
//
// Tab_Misc
//
this.Tab_Misc.Controls.Add(this.CHK_UnlockZMove);
this.Tab_Misc.Controls.Add(this.CHK_UnlockMega);
this.Tab_Misc.Controls.Add(this.L_BallThrowType);
this.Tab_Misc.Controls.Add(this.CB_BallThrowType);
@ -1990,6 +1992,16 @@ namespace PKHeX.WinForms
this.B_Fashion.UseVisualStyleBackColor = true;
this.B_Fashion.Click += new System.EventHandler(this.B_Fashion_Click);
//
// CHK_UnlockZMove
//
this.CHK_UnlockZMove.AutoSize = true;
this.CHK_UnlockZMove.Location = new System.Drawing.Point(6, 273);
this.CHK_UnlockZMove.Name = "CHK_UnlockZMove";
this.CHK_UnlockZMove.Size = new System.Drawing.Size(105, 17);
this.CHK_UnlockZMove.TabIndex = 73;
this.CHK_UnlockZMove.Text = "Unlock Z Moves";
this.CHK_UnlockZMove.UseVisualStyleBackColor = true;
//
// SAV_Trainer7
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -2214,5 +2226,6 @@ namespace PKHeX.WinForms
private System.Windows.Forms.CheckBox CHK_UnlockSuperDoubles;
private System.Windows.Forms.CheckBox CHK_UnlockSuperSingles;
private System.Windows.Forms.CheckBox CHK_UnlockMega;
private System.Windows.Forms.CheckBox CHK_UnlockZMove;
}
}

View file

@ -107,7 +107,10 @@ namespace PKHeX.WinForms
CB_Vivillon.ValueMember = "Value";
CB_Vivillon.DataSource = PKX.GetFormList(666, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols).ToList();
foreach (string t in BattleStyles)
var styles = new List<string>(BattleStyles);
if (SAV.USUM)
styles.Add("Nihilist");
foreach (string t in styles)
{
CB_BallThrowType.Items.Add(t);
LB_BallThrowTypeUnlocked.Items.Add(t);
@ -211,29 +214,26 @@ namespace PKHeX.WinForms
if (SAV.BallThrowType >= 0 && SAV.BallThrowType < CB_BallThrowType.Items.Count)
CB_BallThrowType.SelectedIndex = SAV.BallThrowType;
byte bttu = SAV.BallThrowTypeUnlocked;
LB_BallThrowTypeUnlocked.SetSelected(0, true);
LB_BallThrowTypeUnlocked.SetSelected(1, true);
for (int i = 2; i < LB_BallThrowTypeUnlocked.Items.Count; i++)
LB_BallThrowTypeUnlocked.SetSelected(i, (bttu & (1 << i)) != 0);
LB_BallThrowTypeUnlocked.SetSelected(i, SAV.GetEventFlag(292 + i));
byte bttl = SAV.BallThrowTypeLearned;
LB_BallThrowTypeLearned.SetSelected(0, true);
for (int i = 1; i < LB_BallThrowTypeLearned.Items.Count; i++)
LB_BallThrowTypeLearned.SetSelected(i, (bttl & (1 << i)) != 0);
LB_BallThrowTypeLearned.SetSelected(i, SAV.GetEventFlag(3479 + i));
CB_BallThrowTypeListMode.SelectedIndex = 0;
uint stampBits = SAV.Stamps;
for (int i = 0; i < LB_Stamps.Items.Count; i++)
LB_Stamps.SetSelected(i, (stampBits & (1 << i)) != 0);
byte btsu = SAV.BattleTreeSuperUnlocked;
CHK_UnlockSuperSingles.Checked = (btsu & 1) != 0;
CHK_UnlockSuperDoubles.Checked = (btsu & (1 << 1)) != 0;
CHK_UnlockSuperMulti.Checked = (btsu & (1 << 2)) != 0;
CHK_UnlockSuperSingles.Checked = SAV.GetEventFlag(333);
CHK_UnlockSuperDoubles.Checked = SAV.GetEventFlag(334);
CHK_UnlockSuperMulti.Checked = SAV.GetEventFlag(335);
CHK_UnlockMega.Checked = SAV.MegaUnlocked;
CHK_UnlockZMove.Checked = SAV.ZMoveUnlocked;
}
private void Save()
{
@ -247,6 +247,7 @@ namespace PKHeX.WinForms
SAV.Country = WinFormsUtil.GetIndex(CB_Country);
SAV.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg);
SAV.Language = WinFormsUtil.GetIndex(CB_Language);
if (CB_AlolaTime.Enabled)
SAV.AlolaTime = (ulong)WinFormsUtil.GetIndex(CB_AlolaTime);
SAV.OT = TB_OTName.Text;
@ -321,18 +322,23 @@ namespace PKHeX.WinForms
if (CB_Vivillon.SelectedIndex >= 0) SAV.Vivillon = CB_Vivillon.SelectedIndex;
SAV.DaysFromRefreshed = (byte)NUD_DaysFromRefreshed.Value;
if (CB_BallThrowType.SelectedIndex >= 0)
SAV.BallThrowType = CB_BallThrowType.SelectedIndex;
SAV.BallThrowTypeUnlocked = (byte)GetBits(LB_BallThrowTypeUnlocked);
SAV.BallThrowTypeLearned = (byte)GetBits(LB_BallThrowTypeLearned);
for (int i = 2; i < LB_BallThrowTypeUnlocked.Items.Count; i++)
SAV.SetEventFlag(292 + i, LB_BallThrowTypeUnlocked.GetSelected(i));
for (int i = 1; i < LB_BallThrowTypeLearned.Items.Count; i++)
SAV.SetEventFlag(3479 + i, LB_BallThrowTypeLearned.GetSelected(i));
SAV.Stamps = GetBits(LB_Stamps);
byte btsu = 0;
if (CHK_UnlockSuperSingles.Checked) btsu |= 1;
if (CHK_UnlockSuperDoubles.Checked) btsu |= 1 << 1;
if (CHK_UnlockSuperMulti.Checked) btsu |= 1 << 2;
SAV.BattleTreeSuperUnlocked = btsu;
SAV.SetEventFlag(333, CHK_UnlockSuperSingles.Checked);
SAV.SetEventFlag(334, CHK_UnlockSuperDoubles.Checked);
SAV.SetEventFlag(335, CHK_UnlockSuperMulti.Checked);
SAV.MegaUnlocked = CHK_UnlockMega.Checked;
SAV.ZMoveUnlocked = CHK_UnlockZMove.Checked;
}
private static uint GetBits(ListBox listbox)
{