diff --git a/src/Content/SoundBank.cs b/src/Content/SoundBank.cs index a499987..48913f3 100644 --- a/src/Content/SoundBank.cs +++ b/src/Content/SoundBank.cs @@ -13,6 +13,9 @@ namespace XnaToFna { public static partial class ContentHelper { + // Many thanks to Ethan Lee and everyone else involved for his reverse-engineering work that powers this! + // This is heavily based on FNA / FACT. + public enum SoundBankEventType : uint { Stop = 0, PlayWave = 1, @@ -306,9 +309,10 @@ public static void UpdateSoundBank(string path, BinaryReader reader, BinaryWrite writer.Write(reader.ReadBytesUntil(cuesComplexPos)); for (ushort i = 0; i < cuesComplex; i++) { byte flags = reader.ReadByte(); - writer.Write(flags); - if ((flags & 0x04) == 0x04) + if ((flags & 0x04) == 0x00) { variations++; + } + writer.Write(flags); writer.Write(SwapEndian(x360, reader.ReadUInt32())); writer.Write(SwapEndian(x360, reader.ReadUInt32())); writer.Write(reader.ReadByte()); @@ -318,17 +322,24 @@ public static void UpdateSoundBank(string path, BinaryReader reader, BinaryWrite } if (variations != 0) { + // Variation data seems to... vary... between X360 and PC. writer.Write(reader.ReadBytesUntil(variationsPos)); for (ushort i = 0; i < variations; i++) { - ushort count = SwapEndian(x360, reader.ReadUInt16()); + ushort count; + ushort flags; + if (platform == 1) { + count = SwapEndian(x360, reader.ReadUInt16()); + flags = SwapEndian(x360, reader.ReadUInt16()); + } else { + flags = SwapEndian(x360, reader.ReadUInt16()); + count = SwapEndian(x360, reader.ReadUInt16()); + } writer.Write(count); - ushort flags = SwapEndian(x360, reader.ReadUInt16()); writer.Write(flags); - flags = (ushort) ((short) (flags >> 3) & 0x7); writer.Write(SwapEndian(x360, reader.ReadUInt16())); writer.Write(SwapEndian(x360, reader.ReadUInt16())); - switch (flags) { + switch ((flags >> 3) & 0x07) { case 0: for (ushort ci = 0; ci < count; ci++) { writer.Write(SwapEndian(x360, reader.ReadUInt16())); diff --git a/src/Content/WaveBank.cs b/src/Content/WaveBank.cs index 7cfcede..4dc9318 100644 --- a/src/Content/WaveBank.cs +++ b/src/Content/WaveBank.cs @@ -13,6 +13,9 @@ namespace XnaToFna { public static partial class ContentHelper { + // Many thanks to Ethan Lee and everyone else involved for his reverse-engineering work that powers this! + // This is heavily based on FNA / FACT. + public static class XWMAInfo { public readonly static int[] BytesPerSecond = { 12000, 24000, 4000, 6000, 8000, 20000 }; public readonly static short[] BlockAlign = { 929, 1487, 1280, 2230, 8917, 8192, 4459, 5945, 2304, 1536, 1485, 1008, 2731, 4096, 6827, 5462 }; diff --git a/src/Content/XACTGlobalSettings.cs b/src/Content/XACTGlobalSettings.cs index 1fe0847..387d73f 100644 --- a/src/Content/XACTGlobalSettings.cs +++ b/src/Content/XACTGlobalSettings.cs @@ -13,6 +13,9 @@ namespace XnaToFna { public static partial class ContentHelper { + // Many thanks to Ethan Lee and everyone else involved for his reverse-engineering work that powers this! + // This is heavily based on FNA / FACT. + public enum CrossfadeType : byte { Linear, Logarithmic,