Esempio n. 1
0
 public static UInt16 UInt16FromData(List <Byte> data, int index)
 {
     byte[] output = new byte[2];
     AELogger.Log(index.ToString());
     output[0] = data[index];
     output[1] = data[index + 1];
     return(BitConverter.ToUInt16(output, 0));
 }
Esempio n. 2
0
 public static void Log(String output)
 {
     AELogger.Log("BCMData : " + output);
 }
Esempio n. 3
0
        public bool WriteOutput(String filename)
        {
            Stream       t = new FileStream(filename, FileMode.Create);
            BinaryWriter b = new BinaryWriter(t);

            b.Write(BAC_HEADER_A);
            b.Write(BAC_HEADER_B);
            b.Write((UInt16)AnimList.Count);
            b.Write((UInt16)AnimList_b.Count);
            b.Write((UInt16)HitList.Count);
            b.Write(ZERO_BYTE);
            b.Write(ZERO_BYTE);
            UInt32 currentPointer = (UInt32)BAC_HITBOX_SIZE + 40;

            b.Write(currentPointer);
            currentPointer += (UInt32)AnimList.Count * sizeof(UInt32);
            b.Write(currentPointer);
            currentPointer += (UInt32)AnimList_b.Count * sizeof(UInt32);
            b.Write(currentPointer);
            currentPointer += (UInt32)AnimList.Count * sizeof(UInt32);
            b.Write(currentPointer);
            currentPointer += (UInt32)AnimList_b.Count * sizeof(UInt32);
            b.Write(currentPointer);

            for (int i = 0; i < BAC_HITBOX_SIZE; i++)
            {
                b.Write(hitboxBytes[i]);
            }

            currentPointer += (UInt32)HitList.Count * sizeof(UInt32);
            for (int i = 0; i < AnimList.Count; i++)
            {
                if (AnimList[i].bEmpty)
                {
                    b.Write((UInt32)0);
                }
                else
                {
                    b.Write(currentPointer);
                    currentPointer += (UInt32)AnimList[i].data.Count;
                }
            }

            for (int i = 0; i < AnimList_b.Count; i++)
            {
                if (AnimList_b[i].bEmpty)
                {
                    b.Write((UInt32)0);
                }
                else
                {
                    b.Write(currentPointer);
                    currentPointer += (UInt32)AnimList_b[i].data.Count;
                }
            }

            AELogger.Log(currentPointer.ToString("X"));
            UInt32 hitStartPointer = currentPointer;

            // names are off by b7c0
            for (int i = 0; i < HitList.Count; i++)
            {
                if (!HitList[i].bEmpty)
                {
                    currentPointer += (UInt32)BAC_HIT_SIZE;
                }
            }

            // anim name table
            for (int i = 0; i < AnimList.Count; i++)
            {
                if (AnimList[i].bEmpty)
                {
                    b.Write((UInt32)0);
                }
                else
                {
                    b.Write(currentPointer);
                    currentPointer += (UInt32)AnimList[i].name.Length + 1;
                }
            }

            for (int i = 0; i < AnimList_b.Count; i++)
            {
                if (AnimList_b[i].bEmpty)
                {
                    b.Write((UInt32)0);
                }
                else
                {
                    b.Write(currentPointer);
                    currentPointer += (UInt32)AnimList_b[i].name.Length + 1;
                }
            }

            // hit table
            currentPointer = hitStartPointer;
            for (int i = 0; i < HitList.Count; i++)
            {
                if (HitList[i].bEmpty)
                {
                    b.Write((UInt32)0);
                }
                else
                {
                    b.Write(currentPointer);
                    currentPointer += (UInt32)BAC_HIT_SIZE;
                }
            }

            for (int i = 0; i < AnimList.Count; i++)
            {
                WriteAnim(AnimList[i], b);
            }

            for (int i = 0; i < AnimList_b.Count; i++)
            {
                WriteAnim(AnimList_b[i], b);
            }

            for (int i = 0; i < HitList.Count; i++)
            {
                WriteHit(HitList[i], b);
            }

            for (int i = 0; i < AnimList.Count; i++)
            {
                if (!AnimList[i].bEmpty)
                {
                    b.Write(Encoding.Default.GetBytes(AnimList[i].name));
                    b.Write(ZERO_BYTE);
                }
            }

            for (int i = 0; i < AnimList_b.Count; i++)
            {
                if (!AnimList_b[i].bEmpty)
                {
                    b.Write(Encoding.Default.GetBytes(AnimList_b[i].name));
                    b.Write(ZERO_BYTE);
                }
            }

            b.Close();
            t.Close();

            return(true);
        }
Esempio n. 4
0
        public BACData(BinaryReader bReader)
        {
            //AELogger.Log(bReader.ReadInt64() + " " + bReader.ReadInt64(), true, true);
            Int64 header = bReader.ReadInt64();

            if (header != BAC_HEADER_A)
            {
                AELogger.Log(header.ToString() + " is not expected BAC header... error.");
                return;
            }
            header = bReader.ReadInt32();
            if (header != BAC_HEADER_B)
            {
                AELogger.Log(header.ToString() + " is not expected BAC header... error.");
                return;
            }

            bReader.BaseStream.Seek(12, SeekOrigin.Begin);
            UInt16 size_anim_list = bReader.ReadUInt16();

            AELogger.Log(size_anim_list + " size of anim list");

            bReader.BaseStream.Seek(14, SeekOrigin.Begin);
            UInt16 size_anim_b_list = bReader.ReadUInt16();

            AELogger.Log(size_anim_b_list + " size of anim b list");

            bReader.BaseStream.Seek(16, SeekOrigin.Begin);
            UInt16 size_hit_list = bReader.ReadUInt16();

            AELogger.Log(size_hit_list + " size of hit list");

            bReader.BaseStream.Seek(20, SeekOrigin.Begin);
            UInt32 addr_anim_table = bReader.ReadUInt32();

            AELogger.Log(addr_anim_table.ToString("X") + " address of animation table");

            bReader.BaseStream.Seek(24, SeekOrigin.Begin);
            UInt32 addr_anim_table_b = bReader.ReadUInt32();

            AELogger.Log(addr_anim_table_b.ToString("X") + " address of animation table b?");

            bReader.BaseStream.Seek(28, SeekOrigin.Begin);
            UInt32 addr_anim_name_table = bReader.ReadUInt32();

            AELogger.Log(addr_anim_name_table.ToString("X") + " address of animation name table");

            bReader.BaseStream.Seek(32, SeekOrigin.Begin);
            UInt32 addr_anim_name_table_b = bReader.ReadUInt32();

            AELogger.Log(addr_anim_name_table_b.ToString("X") + " address of animation name table b");

            bReader.BaseStream.Seek(36, SeekOrigin.Begin);
            UInt32 addr_hit_table = bReader.ReadUInt32();

            AELogger.Log(addr_hit_table.ToString("X") + " address of hit table");

            //672
            bReader.BaseStream.Seek(40, SeekOrigin.Begin);
            hitboxBytes = AEDataTools.SlurpBytes(bReader, BAC_HITBOX_SIZE);

            AnimList     = new List <BACAnim>(size_anim_list);
            LongestAnim  = 0;
            ShortestAnim = 4263493;
            for (UInt32 i = 0; i < size_anim_list; i++)
            {
                BACAnim b = new BACAnim();
                bReader.BaseStream.Seek(i * sizeof(UInt32) + addr_anim_table, SeekOrigin.Begin);
                UInt32 aAddr = bReader.ReadUInt32();
                UInt32 bAddr = bReader.ReadUInt32();
                while (bAddr == 0)
                {
                    bAddr = bReader.ReadUInt32();
                }

                if (aAddr != 0)
                {
                    bReader.BaseStream.Seek(aAddr, SeekOrigin.Begin);
                    b.bEmpty = false;
                    b.data   = animFromBytes(AEDataTools.SlurpBytes(bReader, (int)(bAddr - aAddr)));
                    if ((int)(bAddr - aAddr) > LongestAnim)
                    {
                        LongestAnim = (int)(bAddr - aAddr);
                    }
                    if ((int)(bAddr - aAddr) < ShortestAnim)
                    {
                        ShortestAnim = (int)(bAddr - aAddr);
                    }

                    bReader.BaseStream.Seek(addr_anim_name_table + (sizeof(UInt32) * i), SeekOrigin.Begin);
                    UInt32 nameAddr = bReader.ReadUInt32();
                    bReader.BaseStream.Seek(nameAddr, SeekOrigin.Begin);
                    b.name = AEDataTools.SlurpString(bReader);
                    AELogger.Log(i.ToString("X4") + ". " + b.name);
                    AnimList.Add(b);
                }
                else
                {
                    b.bEmpty = true;
                    AELogger.Log(i.ToString("X4") + ". empty one");
                    AnimList.Add(b);
                }
            }
            bReader.BaseStream.Seek(addr_hit_table, SeekOrigin.Begin);
            UInt32 addr_hit_table_start = bReader.ReadUInt32();

            AnimList_b = new List <BACAnim>(size_anim_b_list);
            for (UInt32 i = 0; i < size_anim_b_list; i++)
            {
                BACAnim b = new BACAnim();
                bReader.BaseStream.Seek(i * sizeof(UInt32) + addr_anim_table_b, SeekOrigin.Begin);
                UInt32 aAddr = bReader.ReadUInt32();
                UInt32 bAddr = bReader.ReadUInt32();
                while (bAddr == 0)
                {
                    bAddr = bReader.ReadUInt32();
                }
                bAddr = Math.Min(bAddr, addr_hit_table_start);

                if (aAddr != 0)
                {
                    bReader.BaseStream.Seek(aAddr, SeekOrigin.Begin);
                    b.bEmpty = false;
                    b.data   = animFromBytes(AEDataTools.SlurpBytes(bReader, (int)(bAddr - aAddr)));

                    bReader.BaseStream.Seek(addr_anim_name_table_b + (sizeof(UInt32) * (i)), SeekOrigin.Begin);
                    UInt32 nameAddr = bReader.ReadUInt32();
                    bReader.BaseStream.Seek(nameAddr, SeekOrigin.Begin);
                    b.name = AEDataTools.SlurpString(bReader);
                    AELogger.Log(i.ToString("X4") + "_b. " + b.name);
                    AnimList_b.Add(b);
                }
                else
                {
                    b.bEmpty = true;
                    AELogger.Log(i.ToString("X4") + "_b. empty one");
                    AnimList_b.Add(b);
                }
            }

            bReader.BaseStream.Seek(addr_anim_table, SeekOrigin.Begin);
            UInt32 addr_hit_table_end = bReader.ReadUInt32();

            HitList = new List <BACHit>(size_hit_list);
            for (UInt32 i = 0; i < size_hit_list; i++)
            {
                BACHit b = new BACHit();
                bReader.BaseStream.Seek(i * sizeof(UInt32) + addr_hit_table, SeekOrigin.Begin);
                UInt32 aAddr = bReader.ReadUInt32();

                if (aAddr != 0)
                {
                    bReader.BaseStream.Seek(aAddr, SeekOrigin.Begin);
                    b.bEmpty  = false;
                    b.subhits = new List <BACSubHit>(BACHit.SUBHIT_COUNT);
                    for (int j = 0; j < BACHit.SUBHIT_COUNT; j++)
                    {
                        BACSubHit bs = new BACSubHit();
                        bs.data = AEDataTools.SlurpBytes(bReader, BAC_SUB_HIT_SIZE);
                        b.subhits.Add(bs);
                    }

                    HitList.Add(b);
                }
                else
                {
                    b.bEmpty = true;
                    HitList.Add(b);
                }
            }
            // hits
            // 80 per hit
            // standing, crouching, jumping hit
            // s c j block
            // s c j counterhit
            // 3 more?
            // 80 * 12 = 960


            /*
             * bReader.BaseStream.Seek(, SeekOrigin.Begin);
             * UInt32  = bReader.ReadUInt32();
             * AELogger.Log(+"");
             */

            AELogger.Log(AnimList.Count + " is anim list size");
            AELogger.Log(AnimList_b.Count + " is anim list b size");
            AELogger.Log(HitList.Count + " is hit list size");
        }