diff --git a/ArcFormats/ArcXP3.cs b/ArcFormats/ArcXP3.cs index 97d18eea..fb471725 100644 --- a/ArcFormats/ArcXP3.cs +++ b/ArcFormats/ArcXP3.cs @@ -92,6 +92,7 @@ namespace GameRes.Formats.KiriKiri { arcStrings.ArcNoEncryption, NoCryptAlgorithm }, { "Cafe Sourire", new XorCrypt (0xcd) }, { "Coμ", new ComyuCrypt() }, + { "Damegane", new DameganeCrypt() }, { "Fate/hollow ataraxia", new FateHACrypt() }, { "Fate/stay night", new FateCrypt() }, { "Imouto Style", new ImoutoStyleCrypt() }, @@ -1055,4 +1056,31 @@ NextEntry: } } } + + internal class DameganeCrypt : ICrypt + { + public override byte Decrypt (Xp3Entry entry, long offset, byte value) + { + if (0 != (offset & 1)) + return (byte)(value ^ entry.Hash); + else + return (byte)(value ^ offset); + } + + public override void Decrypt (Xp3Entry entry, long offset, byte[] values, int pos, int count) + { + for (int i = 0; i < count; ++i, ++offset) + { + if (0 != (offset & 1)) + values[pos+i] ^= (byte)entry.Hash; + else + values[pos+i] ^= (byte)offset; + } + } + + public override void Encrypt (Xp3Entry entry, long offset, byte[] values, int pos, int count) + { + Decrypt (entry, offset, values, pos, count); + } + } }