Exemplo n.º 1
0
            public static int getframe(int tidx)
            {
                if (!lookup.ContainsKey(tidx))
                {
                    return(tidx);
                }
                VspAnimation va = (VspAnimation)lookup[tidx];

                if (va.Delay == 0)
                {
                    return(va.Start);
                }
                switch (va.Mode)
                {
                case Vsp24.ANIMATION_FORWARD:    // forward
                    return(va.Start + ((ticks / va.Delay) % (va.End - va.Start + 1)));

                case Vsp24.ANIMATION_PINGPONG:
                    int range = va.End - va.Start + 1;
                    range  = range * 2 - 2;
                    range  = (ticks / va.Delay) % range;
                    range -= (int)((va.End - va.Start + 1) / 2);
                    if (range > va.End - va.Start)
                    {
                        range -= 2;
                    }
                    return(va.Start + Math.Abs(range));

                case Vsp24.ANIMATION_REVERSE:
                    return(va.End - ((ticks / va.Delay) % (va.End - va.Start + 1)));

                default: return(tidx);
                }
            }
Exemplo n.º 2
0
        public VspAnimation Clone()
        {
            VspAnimation va = new VspAnimation();

            va.Start = this.Start;
            va.End   = this.End;
            va.Delay = this.Delay;
            va.Mode  = this.Mode;
            va.ID    = this.ID;
            va.Name  = string.Copy(this.Name);

            return(va);
        }
Exemplo n.º 3
0
        private void b_newanim_Click(object sender, System.EventArgs e)
        {
            VspAnimation va = new VspAnimation();

            va.ID = anims.Count;
            anims.Add(va);

            ListViewItem lvi = new ListViewItem(new string[] { va.ID.ToString(), va.Name });

            lvi.Tag = va;
            lv_anims.Items.Add(lvi);

            lvi.Selected = true;
            lvi.EnsureVisible();
        }
Exemplo n.º 4
0
        private void lv_anims_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (currAnim != null)
            {
                GrabData();
            }
            if (lv_anims.SelectedItems.Count == 0)
            {
                DisableEditor();
                return;
            }
            ListViewItem lvi = lv_anims.SelectedItems[0];

            currAnim = (VspAnimation)lvi.Tag;
            PutData();
            EnableEditor();
        }
Exemplo n.º 5
0
 private void lv_anims_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if(currAnim!=null) GrabData();
     if(lv_anims.SelectedItems.Count==0)
     {
         DisableEditor();
         return;
     }
     ListViewItem lvi = lv_anims.SelectedItems[0];
     currAnim = (VspAnimation)lvi.Tag;
     PutData();
     EnableEditor();
 }
Exemplo n.º 6
0
        private void b_newanim_Click(object sender, System.EventArgs e)
        {
            VspAnimation va = new VspAnimation();
            va.ID = anims.Count;
            anims.Add(va);

            ListViewItem lvi = new ListViewItem( new string[] { va.ID.ToString(), va.Name } );
            lvi.Tag = va;
            lv_anims.Items.Add(lvi);

            lvi.Selected=true;
            lvi.EnsureVisible();
        }
Exemplo n.º 7
0
        public unsafe static Vsp24 ReadVsp24(FileInfo fi)
        {
            //Errors.Error("loading vsp");
            Vsp24 vsp = new Vsp24();

            vsp.FileOnDisk = fi;

            FileStream   fs = fi.OpenRead();
            BinaryReader br = new BinaryReader(fs);

            int sig     = br.ReadInt32();
            int version = br.ReadInt32();

            if (sig != VSP_SIGNATURE || version != VSP_VERSION)
            {
                return(null);
            }

            // assume 16
            int tilesize = br.ReadInt32();

            // assume 24-bit
            int format = br.ReadInt32();

            int tilecount = br.ReadInt32();

            // assume zlib
            int compression = br.ReadInt32();

            int datalen  = br.ReadInt32();
            int zdatalen = br.ReadInt32();

            byte[] zdata = br.ReadBytes(zdatalen);

            byte[] data = ZLIB.Decode(zdata, datalen);

            for (int tile = 0; tile < tilecount; tile++)
            {
                int[] px = new int[256];
                for (int i = 0; i < 256; i++)
                {
                    int idx = tile * 256 + i;
                    int c   = unchecked ((int)0xFF000000);
                    c     = c | (data[idx * 3] << 16);
                    c     = c | (data[idx * 3 + 1] << 8);
                    c     = c | data[idx * 3 + 2];
                    px[i] = c;
                }
                vsp.Tiles.Add(new Vsp24Tile(vsp, new pr2.BufferImage(16, 16, px)));
            }

            int animcount = br.ReadInt32();

            for (int i = 0; i < animcount; i++)
            {
                VspAnimation va = new VspAnimation();
                va.Name  = Helper.BytesToString(br.ReadBytes(256));
                va.Start = br.ReadInt32();
                va.End   = br.ReadInt32();
                va.Delay = br.ReadInt32();
                va.Mode  = br.ReadInt32();
                va.ID    = i;

                vsp.Animations.Add(va);
            }
            int obscount = br.ReadInt32();
            int od_len   = br.ReadInt32();
            int od_zlen  = br.ReadInt32();

            byte[] zd = br.ReadBytes(od_zlen);
            byte[] od = ZLIB.Decode(zd, od_len);

            for (int i = 0; i < obscount; i++)
            {
                int[] tile = new int[256];
                for (int j = 0; j < 256; j++)
                {
                    tile[j] = od[i * 256 + j];
                }
                vsp.ObstructionTiles.Add(new VspObstructionTile(vsp, tile));
            }

            br.Close();

            return(vsp);
        }
Exemplo n.º 8
0
        public VspAnimation Clone()
        {
            VspAnimation va = new VspAnimation();

            va.Start = this.Start;
            va.End = this.End;
            va.Delay = this.Delay;
            va.Mode = this.Mode;
            va.ID = this.ID;
            va.Name = string.Copy(this.Name);

            return va;
        }
Exemplo n.º 9
0
        public static Vsp24 ReadVsp8(FileInfo fi)
        {
            if (!fi.Exists) return null;
            FileStream fs = fi.OpenRead();
            BinaryReader br = new BinaryReader(fs);

            Vsp8 vsp = new Vsp8();

            vsp.FileOnDisk = fi;

            ushort version = br.ReadUInt16();
            byte[] pal = br.ReadBytes(768);
            ushort tilecount = br.ReadUInt16();

            for (int i = 0; i < 256; i++)
            {
                vsp.Palette[i] = new Vsp8PaletteEntry();
                vsp.Palette[i].r = pal[i * 3];
                vsp.Palette[i].g = pal[i * 3 + 1];
                vsp.Palette[i].b = pal[i * 3 + 2];
            }
            byte[] tiles;

            if (version == 2)
            {
                tiles = br.ReadBytes(tilecount * 256);
            }
            else
            {
                // tile data is rle compressed
                int compressedlength = br.ReadInt32();
                tiles = DecompressData8(br.ReadBytes(compressedlength));
            }
            byte[] animations = br.ReadBytes(800);
            br.Close();

            MemoryStream ms;

            ms = new MemoryStream(tiles);
            br = new BinaryReader(ms);
            for (int i = 0; i < tilecount; i++)
            {
                Vsp8Tile vt = new Vsp8Tile(vsp, br.ReadBytes(256));
                vt.doAvg();
                vsp.Tiles.Add(vt);
            }
            br.Close();

            ms = new MemoryStream(animations);

            br = new BinaryReader(ms);
            for (int i = 0; i < 100; i++)
            {
                VspAnimation va = new VspAnimation();

                va.Start = (int)br.ReadUInt16();
                va.End = (int)br.ReadUInt16();
                va.Delay = (int)br.ReadUInt16();
                va.Mode = (int)br.ReadUInt16();

                va.ID = i;

                vsp.Animations.Add(va);
            }
            br.Close();

            return Vsp24.FromVsp8(vsp);
        }
Exemplo n.º 10
0
        public static unsafe Vsp24 ReadVsp24(FileInfo fi)
        {
            //Errors.Error("loading vsp");
            Vsp24 vsp = new Vsp24();

            vsp.FileOnDisk = fi;

            FileStream fs = fi.OpenRead();
            BinaryReader br = new BinaryReader(fs);

            int sig = br.ReadInt32();
            int version = br.ReadInt32();
            if (sig != VSP_SIGNATURE || version != VSP_VERSION)
                return null;

            // assume Global.TILE_SIZE
            int tilesize = br.ReadInt32();

            // assume 24-bit
            int format = br.ReadInt32();

            int tilecount = br.ReadInt32();

            // assume zlib
            int compression = br.ReadInt32();

            int datalen = br.ReadInt32();
            int zdatalen = br.ReadInt32();

            byte[] zdata = br.ReadBytes(zdatalen);

            byte[] data = ZLIB.Decode(zdata, datalen);

            for (int tile = 0; tile < tilecount; tile++)
            {
                int[] px = new int[Global.TILE_SIZE * Global.TILE_SIZE];
                for (int i = 0; i < Global.TILE_SIZE * Global.TILE_SIZE; i++)
                {
                    int idx = tile * Global.TILE_SIZE * Global.TILE_SIZE + i;
                    int c = unchecked((int)0xFF000000);
                    c = c | (data[idx * 3] << 16);
                    c = c | (data[idx * 3 + 1] << 8);
                    c = c | data[idx * 3 + 2];
                    px[i] = c;
                }
                vsp.Tiles.Add(new Vsp24Tile(vsp, new pr2.BufferImage(Global.TILE_SIZE, Global.TILE_SIZE, px)));
            }

            int animcount = br.ReadInt32();
            for (int i = 0; i < animcount; i++)
            {
                VspAnimation va = new VspAnimation();
                va.Name = Helper.BytesToString(br.ReadBytes(256));
                va.Start = br.ReadInt32();
                va.End = br.ReadInt32();
                va.Delay = br.ReadInt32();
                va.Mode = br.ReadInt32();
                va.ID = i;

                vsp.Animations.Add(va);
            }
            int obscount = br.ReadInt32();
            int od_len = br.ReadInt32();
            int od_zlen = br.ReadInt32();
            byte[] zd = br.ReadBytes(od_zlen);
            byte[] od = ZLIB.Decode(zd, od_len);

            for (int i = 0; i < obscount; i++)
            {
                int[] tile = new int[256];
                for (int j = 0; j < 256; j++)
                    tile[j] = od[i * 256 + j];
                vsp.ObstructionTiles.Add(new VspObstructionTile(vsp, tile));
            }

            br.Close();

            return vsp;
        }