private static AnimationFrame[] checkCache(int body, int action, int direction) { // Make sure the cache is complete. // max number of bodies is about 0x1000 if (m_Cache == null) m_Cache = new AnimationFrame[0x1000][][][]; if (m_Cache[body] == null) m_Cache[body] = new AnimationFrame[35][][]; if (m_Cache[body][action] == null) m_Cache[body][action] = new AnimationFrame[8][]; if (m_Cache[body][action][direction] == null) m_Cache[body][action][direction] = new AnimationFrame[1]; if (m_Cache[body][action][direction][0] != null) return m_Cache[body][action][direction]; else return null; }
public static AnimationFrame[] GetAnimation(BinaryFileReader reader) { ushort[] palette = getPalette(reader); // 0x100 * 2 = 0x0200 bytes int read_start = (int)reader.Position; // save file position after palette. int frameCount = reader.ReadInt(); // 0x04 bytes int[] lookups = new int[frameCount]; // frameCount * 0x04 bytes for (int i = 0; i < frameCount; ++i) { lookups[i] = reader.ReadInt(); } AnimationFrame[] frames = new AnimationFrame[frameCount]; for (int i = 0; i < frameCount; ++i) { if (lookups[i] < lookups[0]) { frames[i] = AnimationFrame.Empty; // Fix for broken animations, per issue13 } else { reader.Seek(read_start + lookups[i], SeekOrigin.Begin); frames[i] = new AnimationFrame(m_graphics, palette, reader); } } return frames; }