diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs index a95b342f7..17ba862b2 100644 --- a/PKHeX.Core/Saves/SAV4.cs +++ b/PKHeX.Core/Saves/SAV4.cs @@ -510,11 +510,29 @@ public override int CurrentBox get => Data[Version == GameVersion.HGSS ? getBoxOffset(BoxCount) : Box - 4]; set => Data[Version == GameVersion.HGSS ? getBoxOffset(BoxCount) : Box - 4] = (byte)value; } + private static int InvertHGSSBoxWallpaperAlias(int value) + { + // HG/SS Special Wallpapers 1-8 (Primo Phrases) are shifted by +0x10; swap 0x2_ and 0x1_ by xoring with 0x30 + if (value >= 0x10) + return value ^ 0x30; + return value; + } + public override int getBoxWallpaper(int box) + { + int value = base.getBoxWallpaper(box); + return Version == GameVersion.HGSS ? InvertHGSSBoxWallpaperAlias(value) : value; + } + public override void setBoxWallpaper(int box, int value) + { + if (Version == GameVersion.HGSS) + value = InvertHGSSBoxWallpaperAlias(value); + base.setBoxWallpaper(box, value); + } protected override int getBoxWallpaperOffset(int box) { // Box Wallpaper is directly after the Box Names int offset = getBoxOffset(BoxCount); - if (Version == GameVersion.HGSS) offset += 0x18; + if (Version == GameVersion.HGSS) offset += 0x8; offset += BoxCount*0x28 + box; return offset; } diff --git a/PKHeX.Core/Saves/SaveFile.cs b/PKHeX.Core/Saves/SaveFile.cs index 8ce5c6cd4..795181f79 100644 --- a/PKHeX.Core/Saves/SaveFile.cs +++ b/PKHeX.Core/Saves/SaveFile.cs @@ -446,7 +446,7 @@ public bool SwapBox(int box1, int box2) } protected virtual int getBoxWallpaperOffset(int box) { return -1; } - public int getBoxWallpaper(int box) + public virtual int getBoxWallpaper(int box) { int offset = getBoxWallpaperOffset(box); if (offset < 0 || box > BoxCount) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_BoxLayout.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_BoxLayout.cs index 16ddccba7..adcc92106 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_BoxLayout.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_BoxLayout.cs @@ -95,7 +95,7 @@ private void changeBox(object sender, EventArgs e) return; editing = true; - CB_BG.SelectedIndex = SAV.getBoxWallpaper(LB_BoxSelect.SelectedIndex); + CB_BG.SelectedIndex = Math.Min(CB_BG.Items.Count - 1, SAV.getBoxWallpaper(LB_BoxSelect.SelectedIndex)); TB_BoxName.Text = SAV.getBoxName(LB_BoxSelect.SelectedIndex); editing = false;