Пример #1
0
        /// <summary>
        /// Loads animation data/frames for the specified level.
        /// </summary>
        /// <param name="level">The level to load data for</param>
        /// <param name="lastFrame">The index of the first frame after the current area's frame data, or FF to leave unspecified. If an FF terminator is encountered in frame data, parsing will stop sooner.</param>
        /// <returns></returns>
        private static ChrAnimationLevelData LoadAnimationsForLevel(MetroidRom rom, LevelIndex level, int lastFrame)
        {
            ChrAnimationLevelData data = new ChrAnimationLevelData(level);

            // CHR usage table has been repurposed in MMC3 ROMs (hence accessor names don't match usage)
            data.SprBank0 = rom.ChrUsage.GetSprPage(level);
            data.SprBank1 = rom.ChrUsage.GetBgLastPage(level);
            // First frame index
            int  frameIndex = rom.ChrUsage.GetBgFirstPage(level);
            bool keepGoing  = true;

            while (keepGoing && frameIndex < lastFrame && frameIndex < 0xFF)
            {
                ChrAnimationTable loadedAnimation = LoadOneAnimation(rom, level, ref frameIndex);
                if (loadedAnimation == null)
                {
                    if (data.Animations.Count == 0)
                    {
                        loadedAnimation = new ChrAnimationTable();
                        ChrAnimationFrame frame = new ChrAnimationFrame();
                        frame.FrameTime = 1;
                        loadedAnimation.Frames.Add(frame);
                    }
                    else
                    {
                        return(data);
                    }
                }
                data.Animations.Add(loadedAnimation);
            }

            return(data);
        }
Пример #2
0
        private static ChrAnimationFrame?LoadOneFrame(MetroidRom rom, int frameIndex, out bool LastFrame)
        {
            LastFrame = false;
            if (frameIndex == 0xFF)
            {
                return(null);
            }

            ChrAnimationFrame result = new ChrAnimationFrame();

            result.Bank0 = rom.GetAnimationTable_Bank0(frameIndex);         //rom.data[TableOffset_Bank0 + frameIndex];
            result.Bank1 = rom.GetAnimationTable_Bank1(frameIndex);         //rom.data[TableOffset_Bank0 + frameIndex];
            result.Bank2 = rom.GetAnimationTable_Bank2(frameIndex);         //rom.data[TableOffset_Bank0 + frameIndex];
            result.Bank3 = rom.GetAnimationTable_Bank3(frameIndex);         //rom.data[TableOffset_Bank0 + frameIndex];
            // Don't store last-frame bit in result.Frame!
            result.FrameTime = rom.GetAnimationTable_FrameTime(frameIndex); //0x7F & rom.data[TableOffset_Bank0 + frameIndex];

            LastFrame = rom.GetAnimationTable_FrameLast(frameIndex);        //0 != (rom.data[TableOffset_Bank0 + frameIndex] & 0x80);
            return(result);
        }