Beispiel #1
0
        static uint Kangaroo(SR1_Reader reader, ref G2AnimSegKeyflagInfo_Type kfInfo)
        {
            long oldPos = reader.BaseStream.Position;

            uint flags = 0;

            if (kfInfo.stream != 0)
            {
                flags            = kfInfo.flags & 7;
                kfInfo.flags   >>= 3;
                kfInfo.bitCount -= 3;
                if (kfInfo.bitCount < 1)
                {
                    kfInfo.stream += 4;
                    reader.BaseStream.Position = kfInfo.stream;
                    kfInfo.flags = reader.ReadUInt32();
                    if (kfInfo.bitCount < 0)
                    {
                        flags         |= kfInfo.flags << (kfInfo.bitCount + 3 & 0x1f) & 7;
                        kfInfo.flags >>= (-kfInfo.bitCount & 0x1f);
                    }
                    kfInfo.bitCount += 0x20;
                }
            }

            reader.BaseStream.Position = oldPos;

            return(flags);
        }
Beispiel #2
0
        static void Wombat(SR1_Reader reader, long segKeyKist, int flagBitOffset, ref G2AnimSegKeyflagInfo_Type kfInfo)
        {
            long oldPos = reader.BaseStream.Position;

            kfInfo.stream = segKeyKist + ((flagBitOffset >> 5) << 2);
            reader.BaseStream.Position = kfInfo.stream;
            uint flags = reader.ReadUInt32();

            kfInfo.bitCount = 0x20 - (flagBitOffset & 0x1f);
            kfInfo.flags    = flags >> (flagBitOffset & 0x1f);

            reader.BaseStream.Position = oldPos;
        }
Beispiel #3
0
        static int FooBar(SR1_Reader reader, long segKeyList, int chanData, int keyCount, int firstSeg, int lastSeg, int totalSegments)
        {
            long oldPos = reader.BaseStream.Position;

            reader.BaseStream.Position = segKeyList;

            int oldChanData = chanData;

            int flagBitOffset = (firstSeg * 3) + 8;
            int segIndex      = ((totalSegments * 3) + 7) & unchecked ((int)0xfffffff8);

            G2AnimSegKeyflagInfo_Type[] kfInfos = new G2AnimSegKeyflagInfo_Type[3];

            byte wombatFlags = reader.ReadByte();

            reader.BaseStream.Position = segKeyList;

            if ((wombatFlags & 0x01) != 0)
            {
                Wombat(reader, segKeyList, flagBitOffset, ref kfInfos[0]);
                flagBitOffset += segIndex;
            }
            if ((wombatFlags & 0x02) != 0)
            {
                Wombat(reader, segKeyList, flagBitOffset, ref kfInfos[1]);
                flagBitOffset += segIndex;
            }
            if ((wombatFlags & 0x04) != 0)
            {
                Wombat(reader, segKeyList, flagBitOffset, ref kfInfos[2]);
                flagBitOffset += segIndex;
            }

            flagBitOffset = 0;
            for (int i = firstSeg; i <= lastSeg; i++)
            {
                uint kangaroo0 = Kangaroo(reader, ref kfInfos[0]);
                uint kangaroo1 = Kangaroo(reader, ref kfInfos[1]);
                uint kangaroo2 = Kangaroo(reader, ref kfInfos[2]);

                uint kangarooAll = kangaroo0 | (kangaroo1 << 4) | (kangaroo2 << 8);

                while (kangarooAll != 0)
                {
                    int currentChanData = chanData;

                    if ((kangaroo0 & 1) != 0)
                    {
                        reader.BaseStream.Position = chanData + 1;
                        byte channelType = reader.ReadByte();
                        reader.BaseStream.Position--;
                        channelType &= 0xE0;
                        if (channelType == 0xE0)
                        {
                            channelType = 0;
                        }
                        if (channelType == 0)
                        {
                            currentChanData = chanData + (keyCount * 2);
                        }
                        else
                        {
                            currentChanData = chanData + 4;                             // Short pointer, so add double. (Quadruple, based on no$psx???)
                            if (channelType != 0x20)
                            {
                                if (flagBitOffset == 0)
                                {
                                    flagBitOffset = 8;
                                }

                                if (channelType == 0x40)
                                {
                                    // _G2Anim_InitializeChannel_AdaptiveDelta
                                    chanData += (((keyCount + 3) >> 2) + 2) * 2;                                     // Short pointer, so add double.
                                }
                                else if (channelType == 0x60)
                                {
                                    // _G2Anim_InitializeChannel_Linear
                                    long oldPos0 = reader.BaseStream.Position;

                                    reader.BaseStream.Position = chanData;
                                    short sVar4 = reader.ReadInt16();
                                    chanData += ((sVar4 & 0xfff) + 1) * 2;                                     // Short pointer, so add double.

                                    reader.BaseStream.Position = oldPos0;
                                }

                                flagBitOffset--;
                                currentChanData = chanData;
                            }
                        }
                    }

                    chanData      = currentChanData;
                    kangarooAll >>= 1;
                    kangaroo0     = kangarooAll;
                }
            }

            reader.BaseStream.Position = oldPos;

            return(chanData - oldChanData);
        }