From 4edba19a193cd1ce3b3d19418efcbbfd06327022 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 5 Aug 2017 10:16:55 -0700 Subject: [PATCH] Add platinum wallpaper mapping dp wallpapers .. pt wallpapers .. hgss wallpapers contiguous series 24 .. 8 .. 8 Closes #1381 --- PKHeX.Core/Saves/SAV4.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs index 470104382..3180c08dd 100644 --- a/PKHeX.Core/Saves/SAV4.cs +++ b/PKHeX.Core/Saves/SAV4.cs @@ -519,22 +519,25 @@ 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) + private static int AdjustWallpaper(int value, int shift) { - // 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; + // Pt's Special Wallpapers 1-8 are shifted by +0x8 + // HG/SS Special Wallpapers 1-8 (Primo Phrases) are shifted by +0x10 + if (value >= 0x10) // special + return value + shift; return value; } public override int GetBoxWallpaper(int box) { int value = base.GetBoxWallpaper(box); - return Version == GameVersion.HGSS ? InvertHGSSBoxWallpaperAlias(value) : value; + if (Version != GameVersion.DP) + value = AdjustWallpaper(value, -(Version == GameVersion.Pt ? 0x8 : 0x10)); + return value; } public override void SetBoxWallpaper(int box, int value) { - if (Version == GameVersion.HGSS) - value = InvertHGSSBoxWallpaperAlias(value); + if (Version != GameVersion.DP) + value = AdjustWallpaper(value, Version == GameVersion.Pt ? 0x8 : 0x10); base.SetBoxWallpaper(box, value); } protected override int GetBoxWallpaperOffset(int box)