// Returns a list of tiles which have changed public IList <byte> UpdateAnimations(int frames) { List <byte> retData = new List <byte>(); if (animationGroup == null) { return(retData); } for (int i = 0; i < animationGroup.NumAnimations; i++) { Animation animation = animationGroup.GetAnimationIndex(i); animationCounter[i] -= frames; while (animationCounter[i] <= 0) { animationPos[i]++; if (animationPos[i] >= animation.NumIndices) { animationPos[i] = 0; } int pos = animationPos[i]; animationCounter[i] += animation.GetCounter(pos); GfxHeaderData header = animation.GetGfxHeader(pos); graphicsState.AddGfxHeader(header, GfxHeaderType.Animation); // Console.WriteLine(i + ":" + animationPos[i]); // Check which tiles changed if (header.DestAddr >= 0x8800 && header.DestAddr < 0x9800 && header.DestBank == 1) { for (int addr = header.DestAddr; addr < header.DestAddr + (Project.EvalToInt(header.GetValue(2)) + 1) * 16; addr++) { int tile = (addr - 0x8800) / 16; tile -= 128; if (tile < 0) { tile += 256; } foreach (byte metatile in usedTileList[tile]) { tileImagesCache[metatile] = null; retData.Add(metatile); } } } } } if (TileModifiedEvent != null) { foreach (byte b in retData) { TileModifiedEvent(b); } } if (DrawInvalidatedTiles) { DrawAllTiles(); } return(retData); }