Exemplo n.º 1
0
 public override Sprite GetSprite(ObjectEntry obj)
 {
     int w = ((obj.SubType >> 4) + 1) * 16;
     int h = ((obj.SubType & 0xF) + 1) * 16;
     BitmapBits bmp = new BitmapBits(w, h);
     bmp.DrawRectangle(0x1C, 0, 0, w - 1, h - 1);
     Sprite spr = new Sprite(new Sprite(bmp, new Point(-(w / 2), -(h / 2))), img);
     spr.Offset = new Point(spr.X + obj.X, spr.Y + obj.Y);
     return spr;
 }
Exemplo n.º 2
0
 public override void Init(Dictionary<string, string> data)
 {
     List<byte> tmpartfile = new List<byte>(new byte[0xA000]);
     tmpartfile.AddRange(ObjectHelper.OpenArtFile("../art/nemesis/Robotnik's head.bin", Compression.CompressionType.Nemesis));
     tmpartfile.AddRange(new byte[0xA300 - tmpartfile.Count]);
     tmpartfile.AddRange(ObjectHelper.OpenArtFile("../art/nemesis/Robotnik.bin", Compression.CompressionType.Nemesis));
     tmpartfile.AddRange(new byte[0xAC80 - tmpartfile.Count]);
     tmpartfile.AddRange(ObjectHelper.OpenArtFile("../art/nemesis/Robotnik's lover half.bin", Compression.CompressionType.Nemesis));
     byte[] artfile = tmpartfile.ToArray();
     byte[] mapfile = System.IO.File.ReadAllBytes("../mappings/sprite/objC6_a.bin");
     img = ObjectHelper.MapToBmp(artfile, mapfile, 0, 0, out offset);
 }
Exemplo n.º 3
0
 public Sprite(params Sprite[] sprites)
 {
     int left = 0;
     int right = 0;
     int top = 0;
     int bottom = 0;
     for (int i = 0; i < sprites.Length; i++)
     {
         left = Math.Min(sprites[i].Left, left);
         right = Math.Max(sprites[i].Right, right);
         top = Math.Min(sprites[i].Top, top);
         bottom = Math.Max(sprites[i].Bottom, bottom);
     }
     Offset = new Point(left, top);
     Image = new BitmapBits(right - left, bottom - top);
     for (int i = 0; i < sprites.Length; i++)
         Image.DrawBitmapComposited(sprites[i].Image, new Point(sprites[i].X - left, sprites[i].Y - top));
 }
Exemplo n.º 4
0
 public Sprite(BitmapBits spr, Point off)
 {
     Image = spr;
     Offset = off;
 }
Exemplo n.º 5
0
 public void DrawBitmapComposited(BitmapBits source, Point location)
 {
     int srcl = 0;
     if (location.X < 0)
         srcl = -location.X;
     int srct = 0;
     if (location.Y < 0)
         srct = -location.Y;
     int srcr = source.Width;
     if (srcr > Width - location.X)
         srcr = Width - location.X;
     int srcb = source.Height;
     if (srcb > Height - location.Y)
         srcb = Height - location.Y;
     for (int i = srct; i < srcb; i++)
         for (int x = srcl; x < srcr; x++)
             if (source[x, i] != 0)
                 this[location.X + x, location.Y + i] = source[x, i];
 }
Exemplo n.º 6
0
 public override void Init(Dictionary<string, string> data)
 {
     List<byte> tmpartfile = new List<byte>();
     tmpartfile.AddRange(ObjectHelper.OpenArtFile("../General/Sprites/Monitors/Monitors.bin", Compression.CompressionType.Nemesis));
     tmpartfile.AddRange(new byte[0x6200 - tmpartfile.Count]);
     tmpartfile.AddRange(ObjectHelper.OpenArtFile("../General/Sprites/HUD Icon/Sonic life icon.bin", Compression.CompressionType.Nemesis));
     byte[] artfile = tmpartfile.ToArray();
     img = ObjectHelper.MapASMToBmp(artfile, "../General/Sprites/Monitors/Map - Monitor.asm", 0, 0, out offset);
     imgw = img.Width;
     imgh = img.Height;
     Point off;
     BitmapBits im;
     for (int i = 0; i < 11; i++)
     {
         im = ObjectHelper.MapASMToBmp(artfile, "../General/Sprites/Monitors/Map - Monitor.asm", i + 1, 0, out off);
         imgs.Add(im);
         offsets.Add(off);
         imgws.Add(im.Width);
         imghs.Add(im.Height);
     }
 }
Exemplo n.º 7
0
 public void DrawBitmap(BitmapBits source, Point location)
 {
     int dstx = location.X; int dsty = location.Y;
     for (int i = 0; i < source.Height; i++)
     {
         int di = ((dsty + i) * Width) + dstx;
         int si = i * source.Width;
         Array.Copy(source.Bits, si, Bits, di, source.Width);
     }
 }
Exemplo n.º 8
0
 public static Sprite MapToBmp(byte[] artfile, byte[] mapfile, int frame, int startpal)
 {
     BitmapBits[] bmp = null;
     Point off = new Point();
     switch (LevelData.EngineVersion)
     {
         case EngineVersion.S1:
             S1Mappings s1map = new S1Mappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2));
             bmp = LevelData.S1MapFrameToBmp(artfile, s1map, startpal, out off);
             break;
         case EngineVersion.S2:
         case EngineVersion.S2NA:
             S2Mappings s2map = new S2Mappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2));
             bmp = LevelData.S2MapFrameToBmp(artfile, s2map, startpal, out off);
             break;
         case EngineVersion.S3K:
         case EngineVersion.SKC:
             S3KMappings s3kmap = new S3KMappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2));
             bmp = LevelData.S3KMapFrameToBmp(artfile, s3kmap, startpal, out off);
             break;
     }
     BitmapBits Image = new BitmapBits(bmp[0].Width, bmp[0].Height);
     Image.DrawBitmapComposited(bmp[0], Point.Empty);
     Image.DrawBitmapComposited(bmp[1], Point.Empty);
     return new Sprite(Image, off);
 }
Exemplo n.º 9
0
 public override void Draw(BitmapBits bmp, Point camera, ObjectEntry obj, bool includeDebug)
 {
     BitmapBits bits = new BitmapBits(img);
     bits.Flip(obj.XFlip, obj.YFlip);
     bmp.DrawBitmapComposited(bits, new Point(obj.X + offset.X - camera.X, obj.Y + offset.Y - camera.Y));
 }
Exemplo n.º 10
0
 public override void Init(Dictionary<string, string> data)
 {
     img = ObjectHelper.UnknownObject;
     List<Sprite> sprs = new List<Sprite>();
     int left = -208;
     int right = 208;
     int top = 0;
     int bottom = 0;
     for (int i = 0; i < Obj06_CosineTable.Length; i++)
     {
         top = Math.Min(Obj06_CosineTable[i], top);
         bottom = Math.Max(Obj06_CosineTable[i], bottom);
     }
     Point offset = new Point(left, top);
     BitmapBits bmp = new BitmapBits(right - left, bottom - top);
     for (int x = 0; x < 0x1A0; x++)
     {
         int y = Obj06_CosineTable[x] - top;
         if (x < bmp.Width & y >= 0 & y < bmp.Height)
             bmp[x, y] = 0x1C;
     }
     sprs.Add(new Sprite(bmp, offset));
     offset = new Point(-192, 0);
     bmp = new BitmapBits(0x180, 53);
     bmp.DrawLine(0x1C, 192, 0, 192, 52);
     bmp.DrawLine(0x1C, 0, 52, 0x180, 52);
     sprs.Add(new Sprite(bmp, offset));
     sprs.Add(img);
     sprite = new Sprite(sprs.ToArray());
 }
Exemplo n.º 11
0
 public override Sprite GetSprite(ObjectEntry obj)
 {
     byte subtype = obj.SubType;
     if (subtype > 10) subtype = 0;
     BitmapBits bits = new BitmapBits(imgs[subtype].Image);
     bits.Flip(obj.XFlip, obj.YFlip);
     return new Sprite(bits, new Point(imgs[subtype].X + obj.X, imgs[subtype].Y + obj.Y));
 }
Exemplo n.º 12
0
 internal static BitmapBits[] S3KMapFrameToBmp(byte[] file, S3KMappings map, int startpal, out Point offset)
 {
     int left = 0;
     int right = 0;
     int top = 0;
     int bottom = 0;
     for (int i = 0; i < map.TileCount; i++)
     {
         left = Math.Min(map[i].X, left);
         right = Math.Max(map[i].X + (map[i].Width * 8), right);
         top = Math.Min(map[i].Y, top);
         bottom = Math.Max(map[i].Y + (map[i].Height * 8), bottom);
     }
     offset = new Point(left, top);
     BitmapBits[] bmp = new BitmapBits[] { new BitmapBits(right - left, bottom - top), new BitmapBits(right - left, bottom - top) };
     for (int i = map.TileCount - 1; i >= 0; i--)
     {
         BitmapBits pcbmp = new BitmapBits(map[i].Width * 8, map[i].Height * 8);
         int ti = 0;
         int pr = map[i].Tile.Priority ? 1 : 0;
         for (int x = 0; x < map[i].Width; x++)
         {
             for (int y = 0; y < map[i].Height; y++)
             {
                 pcbmp.DrawBitmapComposited(
                     ObjectHelper.TileToBmp8bpp(file, map[i].Tile.Tile + ti, (map[i].Tile.Palette + startpal) & 3),
                     new Point(x * 8, y * 8));
                 ti++;
             }
         }
         pcbmp.Flip(map[i].Tile.XFlip, map[i].Tile.YFlip);
         bmp[pr].DrawBitmapComposited(pcbmp, new Point(map[i].X - left, map[i].Y - top));
     }
     return bmp;
 }
Exemplo n.º 13
0
        public override void Init(Dictionary<string, string> data)
        {
            List<byte> tmpartfile = new List<byte>();
            tmpartfile.AddRange(ObjectHelper.OpenArtFile("Common/pathswapper-art.bin", Compression.CompressionType.Nemesis));
            byte[] mapfile = System.IO.File.ReadAllBytes("../mappings/sprite/obj03.bin");
            byte[] artfile1 = tmpartfile.ToArray();
            img = ObjectHelper.MapToBmp(artfile1, mapfile, 0, 1);
            Point off;
            BitmapBits im;
            Point pos;
            Size delta;
            for (int i = 0; i < 32; i++)
            {
                byte[] artfile = tmpartfile.GetRange(((i & 0x1C) << 5), 128).ToArray();
                BitmapBits tempim = ObjectHelper.MapToBmp(artfile, mapfile, (i & 4), 0).Image;
                if ((i & 4) != 0)
                {
                    im = new BitmapBits(tempim.Width * (1 << (i & 3)), tempim.Height);
                    delta = new Size(tempim.Width, 0);
                }
                else
                {
                    im = new BitmapBits(tempim.Width, tempim.Height * (1 << (i & 3)));
                    delta = new Size(0, tempim.Height);
                }

                pos = new Point(0, 0);
                off = new Point(-(im.Width / 2), -(im.Height / 2));
                for (int j = 0; j < (1 << (i & 3)); j++)
                {
                    im.DrawBitmap(tempim, pos);
                    pos = pos + delta;
                }
                imgs.Add(new Sprite(im, off));
            }
        }
Exemplo n.º 14
0
 public override void Draw(BitmapBits bmp, Point camera, ObjectEntry obj, bool includeDebug)
 {
     byte subtype = obj.SubType;
     if (subtype > 10) subtype = 0;
     BitmapBits bits = new BitmapBits(imgs[subtype]);
     bits.Flip(obj.XFlip, obj.YFlip);
     bmp.DrawBitmapComposited(bits, new Point(obj.X + offsets[subtype].X - camera.X, obj.Y + offsets[subtype].Y - camera.Y));
 }
Exemplo n.º 15
0
 public override void Init(Dictionary<string, string> data)
 {
     List<byte> tmpartfile = new List<byte>();
     tmpartfile.AddRange(ObjectHelper.OpenArtFile("../art/nemesis/Monitor and contents.bin", Compression.CompressionType.Nemesis));
     tmpartfile.AddRange(new byte[0x2A80 - tmpartfile.Count]);
     tmpartfile.AddRange(ObjectHelper.OpenArtFile("../art/nemesis/Sonic lives counter.bin", Compression.CompressionType.Nemesis));
     byte[] artfile = tmpartfile.ToArray();
     byte[] mapfile = System.IO.File.ReadAllBytes("../mappings/sprite/obj26.bin");
     img = ObjectHelper.MapToBmp(artfile, mapfile, 1, 0, out offset);
     Point off;
     BitmapBits im;
     for (int i = 0; i < 11; i++)
     {
         im = ObjectHelper.MapToBmp(artfile, mapfile, i + 1, 0, out off);
         imgs.Add(im);
         offsets.Add(off);
     }
 }
Exemplo n.º 16
0
 public override void Draw(BitmapBits bmp, Point loc, byte subtype, bool XFlip, bool YFlip, bool includeDebug)
 {
     if (subtype > 10) subtype = 0;
     BitmapBits bits = new BitmapBits(imgs[subtype]);
     bits.Flip(XFlip, YFlip);
     bmp.DrawBitmapComposited(bits, new Point(loc.X + offsets[subtype].X, loc.Y + offsets[subtype].Y));
 }
Exemplo n.º 17
0
 public BitmapBits Scale(int factor)
 {
     BitmapBits res = new BitmapBits(Width * factor, Height * factor);
     for (int y = 0; y < res.Height; y++)
         for (int x = 0; x < res.Width; x++)
             res[x, y] = this[(x / factor), (y / factor)];
     return res;
 }
Exemplo n.º 18
0
 public override void Init(Dictionary<string, string> data)
 {
     byte[] artfile1 = ObjectHelper.OpenArtFile("../art/nemesis/Vertical spring.bin", Compression.CompressionType.Nemesis);
     byte[] artfile2 = ObjectHelper.OpenArtFile("../art/nemesis/Horizontal spring.bin", Compression.CompressionType.Nemesis);
     byte[] artfile3 = ObjectHelper.OpenArtFile("../art/nemesis/Diagonal spring.bin", Compression.CompressionType.Nemesis);
     img = ObjectHelper.MapASMToBmp(artfile1, "../s2.asm", "word_19048", 0, out offset);
     Point off = new Point();
     BitmapBits im;
     imgs.Add(img); // 0
     offsets.Add(offset);
     im = ObjectHelper.MapASMToBmp(artfile1, "../s2.asm", "word_19048", 1, out off); // 1
     imgs.Add(im);
     offsets.Add(off);
     im = ObjectHelper.MapASMToBmp(artfile2, "../s2.asm", "word_19076", 0, out off); // 2
     imgs.Add(im);
     offsets.Add(off);
     im = ObjectHelper.MapASMToBmp(artfile2, "../s2.asm", "word_19076", 1, out off); // 3
     imgs.Add(im);
     offsets.Add(off);
     imgs.Add(imgs[0]); // 4
     offsets.Add(offsets[0]);
     imgs.Add(imgs[1]); // 5
     offsets.Add(offsets[1]);
     im = ObjectHelper.MapASMToBmp(artfile3, "../s2.asm", "word_190B6", 0, out off); // 6
     imgs.Add(im);
     offsets.Add(off);
     im = ObjectHelper.MapASMToBmp(artfile3, "../s2.asm", "word_19136", 1, out off); // 7
     imgs.Add(im);
     offsets.Add(off);
     imgs.Add(imgs[6]); // 8
     offsets.Add(offsets[6]);
     imgs.Add(imgs[7]); // 9
     offsets.Add(offsets[7]);
     im = ObjectHelper.UnknownObject(out off); // A
     imgs.Add(im);
     offsets.Add(off);
     imgs.Add(im); // B
     offsets.Add(off);
     imgs.Add(im); // C
     offsets.Add(off);
     imgs.Add(im); // D
     offsets.Add(off);
     imgs.Add(im); // E
     offsets.Add(off);
     imgs.Add(im); // F
     offsets.Add(off);
 }
Exemplo n.º 19
0
 public static Sprite MapASMToBmp(byte[] artfile, string mapfileloc, string label, int startpal)
 {
     byte[] mapfile = LevelData.ASMToBin(mapfileloc, label);
     BitmapBits[] bmp = null;
     Point off = new Point();
     switch (LevelData.EngineVersion)
     {
         case EngineVersion.S1:
             bmp = LevelData.S1MapFrameToBmp(artfile, new S1Mappings(mapfile, 0), startpal, out off);
             break;
         case EngineVersion.S2:
         case EngineVersion.S2NA:
             bmp = LevelData.S2MapFrameToBmp(artfile, new S2Mappings(mapfile, 0), startpal, out off);
             break;
         case EngineVersion.S3K:
         case EngineVersion.SKC:
             bmp = LevelData.S3KMapFrameToBmp(artfile, new S3KMappings(mapfile, 0), startpal, out off);
             break;
     }
     BitmapBits Image = new BitmapBits(bmp[0].Width, bmp[0].Height);
     Image.DrawBitmapComposited(bmp[0], Point.Empty);
     Image.DrawBitmapComposited(bmp[1], Point.Empty);
     return new Sprite(Image, off);
 }
Exemplo n.º 20
0
 public override void Draw(BitmapBits bmp, Point loc, byte subtype, bool XFlip, bool YFlip, bool includeDebug)
 {
     if (!includeDebug) return;
     BitmapBits bits = new BitmapBits(imgs[subtype & 0x1F]);
     bmp.DrawBitmapComposited(bits, new Point(loc.X + offsets[subtype & 0x1F].X, loc.Y + offsets[subtype & 0x1F].Y));
 }
Exemplo n.º 21
0
 internal static BitmapBits TileToBmp8bpp(byte[] file, int index, int pal)
 {
     BitmapBits bmp = new BitmapBits(8, 8);
     if (file != null && index * 32 + 32 <= file.Length)
     {
         for (int i = 0; i < 32; i++)
         {
             bmp.Bits[i * 2] = (byte)((file[i + (index * 32)] >> 4) + (pal * 16));
             bmp.Bits[(i * 2) + 1] = (byte)((file[i + (index * 32)] & 0xF) + (pal * 16));
             if (bmp.Bits[i * 2] % 16 == 0) bmp.Bits[i * 2] = 0;
             if (bmp.Bits[(i * 2) + 1] % 16 == 0) bmp.Bits[(i * 2) + 1] = 0;
         }
     }
     return bmp;
 }
Exemplo n.º 22
0
 public static BitmapBits FromTile(byte[] art, int index)
 {
     BitmapBits bmp = new BitmapBits(8, 8);
     if (index * 32 + 32 <= art.Length)
     {
         for (int i = 0; i < 32; i++)
         {
             bmp.Bits[i * 2] = (byte)(art[i + (index * 32)] >> 4);
             bmp.Bits[(i * 2) + 1] = (byte)(art[i + (index * 32)] & 0xF);
         }
     }
     return bmp;
 }
Exemplo n.º 23
0
 public BitmapBits(BitmapBits source)
 {
     Width = source.Width;
     Height = source.Height;
     Bits = new byte[source.Bits.Length];
     Array.Copy(source.Bits, Bits, Bits.Length);
 }
Exemplo n.º 24
0
        public override void Init(Dictionary<string, string> data)
        {
            List<byte> tmpartfile = new List<byte>();
            tmpartfile.AddRange(ObjectHelper.OpenArtFile("Common/pathswapper-art.bin", Compression.CompressionType.Nemesis));
            byte[] artfile1 = tmpartfile.ToArray();
            img = ObjectHelper.MapASMToBmp(artfile1, "../General/Sprites/Level Misc/Map - Path Swap.asm", 0, 1, out offset);
            imgw = img.Width;
            imgh = img.Height;
            Point off;
            BitmapBits im;
            Point pos;
            Size delta;
            for (int i = 0; i < 32; i++)
            {
                byte[] artfile = tmpartfile.GetRange(((i & 0x1C) << 5), 128).ToArray();
                BitmapBits tempim = ObjectHelper.MapASMToBmp(artfile, "../General/Sprites/Level Misc/Map - Path Swap.asm", (i & 4), 0, out off);
                if ((i & 4) != 0)
                {
                    im = new BitmapBits(tempim.Width * (1 << (i & 3)), tempim.Height);
                    delta = new Size(tempim.Width, 0);
                }
                else
                {
                    im = new BitmapBits(tempim.Width, tempim.Height * (1 << (i & 3)));
                    delta = new Size(0, tempim.Height);
                }

                pos = new Point(0, 0);
                off = new Point(-(im.Width / 2), -(im.Height / 2));
                for (int j = 0; j < (1 << (i & 3)); j++)
                {
                    im.DrawBitmap(tempim, pos);
                    pos = pos + delta;
                }
                imgs.Add(im);
                offsets.Add(off);
                imgws.Add(im.Width);
                imghs.Add(im.Height);
            }
        }