예제 #1
0
        public ISpriteRun SetPixels(IDataModel model, ModelDelta token, int page, int[,] pixels)
        {
            var data = Decompress(model, Start, allowLengthErrors: true);

            page %= Pages;

            var pageLength = SpriteFormat.TileWidth * SpriteFormat.TileHeight * 8 * SpriteFormat.BitsPerPixel;

            SpriteRun.SetPixels(data, page * pageLength, pixels, SpriteFormat.BitsPerPixel);

            var newModelData = Compress(data, 0, data.Length);
            var newRun       = (ISpriteRun)model.RelocateForExpansion(token, this, newModelData.Count);

            for (int i = 0; i < newModelData.Count; i++)
            {
                token.ChangeData(model, newRun.Start + i, newModelData[i]);
            }
            for (int i = newModelData.Count; i < Length; i++)
            {
                token.ChangeData(model, newRun.Start + i, 0xFF);
            }
            newRun = new LzSpriteRun(SpriteFormat, model, newRun.Start, newRun.PointerSources);
            model.ObserveRunWritten(token, newRun);
            return(newRun);
        }
예제 #2
0
 public static bool TryParseSpriteFormat(string pointerFormat, out SpriteFormat spriteFormat)
 {
     spriteFormat = default;
     if (!pointerFormat.StartsWith("`ucs") || !pointerFormat.EndsWith("`"))
     {
         return(false);
     }
     return(LzSpriteRun.TryParseDimensions(pointerFormat, out spriteFormat));
 }
예제 #3
0
        public LzSpriteRun IncreaseHeight(int tiles, ModelDelta token)
        {
            var data         = Decompress(Model, Start);
            var longerData   = data.Concat(new byte[SpriteFormat.ExpectedByteLength / SpriteFormat.TileHeight * tiles]).ToArray();
            var newModelData = Compress(longerData, 0, longerData.Length);

            var newRun = Model.RelocateForExpansion(token, this, newModelData.Count);

            for (int i = 0; i < newModelData.Count; i++)
            {
                token.ChangeData(Model, newRun.Start + i, newModelData[i]);
            }
            for (int i = newModelData.Count; i < Length; i++)
            {
                token.ChangeData(Model, newRun.Start + i, 0xFF);
            }

            var newFormat = new SpriteFormat(SpriteFormat.BitsPerPixel, SpriteFormat.TileWidth, SpriteFormat.TileHeight + tiles, SpriteFormat.PaletteHint, SpriteFormat.AllowLengthErrors);

            newRun = new LzSpriteRun(newFormat, Model, newRun.Start, newRun.PointerSources);
            Model.ObserveRunWritten(token, newRun);
            return(newRun);
        }