Fix GC export & XD ribbons

ribbons are big endian bools, invert bits
This commit is contained in:
Kaphotics 2016-10-02 19:50:38 -07:00
parent 0266fd1eb7
commit f2ee9492e6
4 changed files with 20 additions and 20 deletions

View File

@ -87,22 +87,22 @@ public XK3(byte[] decryptedData = null, string ident = null)
private string Nickname2 { get { return PKX.getColoStr(Data, 0x64, 10); } set { PKX.setColoStr(value, 10).CopyTo(Data, 0x64); } } // +2 terminator
// 0x7A-0x7B Unknown
private ushort RIB0 { get { return BigEndian.ToUInt16(Data, 0x7C); } set { BigEndian.GetBytes(value).CopyTo(Data, 0x7C); } }
public bool RibbonChampionG3Hoenn { get { return (RIB0 & (1 << 00)) == 1 << 00; } set { RIB0 = (ushort)(RIB0 & ~(1 << 00) | (ushort)(value ? 1 << 00 : 0)); } }
public bool RibbonWinning { get { return (RIB0 & (1 << 01)) == 1 << 01; } set { RIB0 = (ushort)(RIB0 & ~(1 << 01) | (ushort)(value ? 1 << 01 : 0)); } }
public bool RibbonVictory { get { return (RIB0 & (1 << 02)) == 1 << 02; } set { RIB0 = (ushort)(RIB0 & ~(1 << 02) | (ushort)(value ? 1 << 02 : 0)); } }
public bool RibbonArtist { get { return (RIB0 & (1 << 03)) == 1 << 03; } set { RIB0 = (ushort)(RIB0 & ~(1 << 03) | (ushort)(value ? 1 << 03 : 0)); } }
public bool RibbonEffort { get { return (RIB0 & (1 << 04)) == 1 << 04; } set { RIB0 = (ushort)(RIB0 & ~(1 << 04) | (ushort)(value ? 1 << 04 : 0)); } }
public bool RibbonChampionBattle { get { return (RIB0 & (1 << 05)) == 1 << 05; } set { RIB0 = (ushort)(RIB0 & ~(1 << 05) | (ushort)(value ? 1 << 05 : 0)); } }
public bool RibbonChampionRegional { get { return (RIB0 & (1 << 06)) == 1 << 06; } set { RIB0 = (ushort)(RIB0 & ~(1 << 06) | (ushort)(value ? 1 << 06 : 0)); } } // don't think this is right, shouldn't this be National?
public bool RibbonChampionNational { get { return (RIB0 & (1 << 07)) == 1 << 07; } set { RIB0 = (ushort)(RIB0 & ~(1 << 07) | (ushort)(value ? 1 << 07 : 0)); } }
public bool RibbonCountry { get { return (RIB0 & (1 << 08)) == 1 << 08; } set { RIB0 = (ushort)(RIB0 & ~(1 << 08) | (ushort)(value ? 1 << 08 : 0)); } }
public bool RibbonNational { get { return (RIB0 & (1 << 09)) == 1 << 09; } set { RIB0 = (ushort)(RIB0 & ~(1 << 09) | (ushort)(value ? 1 << 09 : 0)); } } // Shouldn't this be Regional? (are all these bits inverse?)
public bool RibbonEarth { get { return (RIB0 & (1 << 10)) == 1 << 10; } set { RIB0 = (ushort)(RIB0 & ~(1 << 10) | (ushort)(value ? 1 << 10 : 0)); } }
public bool RibbonWorld { get { return (RIB0 & (1 << 11)) == 1 << 11; } set { RIB0 = (ushort)(RIB0 & ~(1 << 11) | (ushort)(value ? 1 << 11 : 0)); } }
public bool Unused1 { get { return (RIB0 & (1 << 12)) == 1 << 12; } set { RIB0 = (ushort)(RIB0 & ~(1 << 12) | (ushort)(value ? 1 << 12 : 0)); } }
public bool Unused2 { get { return (RIB0 & (1 << 13)) == 1 << 13; } set { RIB0 = (ushort)(RIB0 & ~(1 << 13) | (ushort)(value ? 1 << 13 : 0)); } }
public bool Unused3 { get { return (RIB0 & (1 << 14)) == 1 << 14; } set { RIB0 = (ushort)(RIB0 & ~(1 << 14) | (ushort)(value ? 1 << 14 : 0)); } }
public bool Unused4 { get { return (RIB0 & (1 << 15)) == 1 << 15; } set { RIB0 = (ushort)(RIB0 & ~(1 << 15) | (ushort)(value ? 1 << 15 : 0)); } }
public bool RibbonChampionG3Hoenn { get { return (RIB0 & (1 << 15)) == 1 << 15; } set { RIB0 = (ushort)(RIB0 & ~(1 << 15) | (ushort)(value ? 1 << 15 : 0)); } }
public bool RibbonWinning { get { return (RIB0 & (1 << 14)) == 1 << 14; } set { RIB0 = (ushort)(RIB0 & ~(1 << 14) | (ushort)(value ? 1 << 14 : 0)); } }
public bool RibbonVictory { get { return (RIB0 & (1 << 13)) == 1 << 13; } set { RIB0 = (ushort)(RIB0 & ~(1 << 13) | (ushort)(value ? 1 << 13 : 0)); } }
public bool RibbonArtist { get { return (RIB0 & (1 << 12)) == 1 << 12; } set { RIB0 = (ushort)(RIB0 & ~(1 << 12) | (ushort)(value ? 1 << 12 : 0)); } }
public bool RibbonEffort { get { return (RIB0 & (1 << 11)) == 1 << 11; } set { RIB0 = (ushort)(RIB0 & ~(1 << 11) | (ushort)(value ? 1 << 11 : 0)); } }
public bool RibbonChampionBattle { get { return (RIB0 & (1 << 10)) == 1 << 10; } set { RIB0 = (ushort)(RIB0 & ~(1 << 10) | (ushort)(value ? 1 << 10 : 0)); } }
public bool RibbonChampionRegional { get { return (RIB0 & (1 << 09)) == 1 << 09; } set { RIB0 = (ushort)(RIB0 & ~(1 << 09) | (ushort)(value ? 1 << 09 : 0)); } }
public bool RibbonChampionNational { get { return (RIB0 & (1 << 08)) == 1 << 08; } set { RIB0 = (ushort)(RIB0 & ~(1 << 08) | (ushort)(value ? 1 << 08 : 0)); } }
public bool RibbonCountry { get { return (RIB0 & (1 << 07)) == 1 << 07; } set { RIB0 = (ushort)(RIB0 & ~(1 << 07) | (ushort)(value ? 1 << 07 : 0)); } }
public bool RibbonNational { get { return (RIB0 & (1 << 06)) == 1 << 06; } set { RIB0 = (ushort)(RIB0 & ~(1 << 06) | (ushort)(value ? 1 << 06 : 0)); } }
public bool RibbonEarth { get { return (RIB0 & (1 << 05)) == 1 << 05; } set { RIB0 = (ushort)(RIB0 & ~(1 << 05) | (ushort)(value ? 1 << 05 : 0)); } }
public bool RibbonWorld { get { return (RIB0 & (1 << 04)) == 1 << 04; } set { RIB0 = (ushort)(RIB0 & ~(1 << 04) | (ushort)(value ? 1 << 04 : 0)); } }
public bool Unused1 { get { return (RIB0 & (1 << 03)) == 1 << 03; } set { RIB0 = (ushort)(RIB0 & ~(1 << 03) | (ushort)(value ? 1 << 03 : 0)); } }
public bool Unused2 { get { return (RIB0 & (1 << 02)) == 1 << 02; } set { RIB0 = (ushort)(RIB0 & ~(1 << 02) | (ushort)(value ? 1 << 02 : 0)); } }
public bool Unused3 { get { return (RIB0 & (1 << 01)) == 1 << 01; } set { RIB0 = (ushort)(RIB0 & ~(1 << 01) | (ushort)(value ? 1 << 01 : 0)); } }
public bool Unused4 { get { return (RIB0 & (1 << 00)) == 1 << 00; } set { RIB0 = (ushort)(RIB0 & ~(1 << 00) | (ushort)(value ? 1 << 00 : 0)); } }
// 0x7E-0x7F Unknown
// Moves

View File

@ -111,7 +111,7 @@ public override byte[] Write(bool DSV)
// Put save slot back in original save data
byte[] newFile = (byte[])OriginalData.Clone();
Array.Copy(newSAV, 0, newFile, SLOT_START + SaveIndex*SLOT_SIZE, newSAV.Length);
return newFile;
return Header.Concat(newFile).ToArray();
}
// Configuration

View File

@ -62,7 +62,8 @@ public override byte[] Write(bool DSV)
// Set Data Back
foreach (RSBOX_Block b in Blocks)
b.Data.CopyTo(Data, b.Offset);
return Data.Take(Data.Length - SIZE_RESERVED).ToArray();
byte[] newFile = Data.Take(Data.Length - SIZE_RESERVED).ToArray();
return Header.Concat(newFile).ToArray();
}
// Configuration

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace PKHeX
@ -125,7 +124,7 @@ public override byte[] Write(bool DSV)
// Put save slot back in original save data
byte[] newFile = (byte[])OriginalData.Clone();
Array.Copy(newSAV, 0, newFile, SLOT_START + SaveIndex * SLOT_SIZE, newSAV.Length);
return newFile;
return Header.Concat(newFile).ToArray();
}
// Configuration