Beispiel #1
0
        public bool LoadSpecialGraphics(string fileName)
        {
            if (!File.Exists(fileName)) return false;
            int dataPointer = 0;
            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            byte[] data = new byte[fs.Length];
            fs.Read(data, 0, (int) fs.Length);
            fs.Close();

            SpecialBanks.Clear();
            for (int i = 0; i < 4; i++)
            {
                GraphicsBank nextBank = new GraphicsBank();
                for (int j = 0; j < 64; j++)
                {
                    byte[] nextTileChunk = new byte[16];
                    for (int k = 0; k < 16; k++) nextTileChunk[k] = data[dataPointer++];
                    nextBank[j] = new Tile(nextTileChunk);
                }
                SpecialBanks.Add(nextBank);
            }

            SpecialTable = new PatternTable();
            for (int j = 0; j < 4; j++)
            {
                SpecialTable.SetGraphicsbank(j, SpecialBanks[j]);
            }
            return true;
        }
        public void LoadDefault()
        {
            byte[] graphicsData = Resource.default_graphics;
            int dataPointer = 0;

            GraphicsBanks.Clear();

            for (int i = 0; i < 256; i++)
            {
                GraphicsBank nextBank = new GraphicsBank();
                for (int j = 0; j < 64; j++)
                {
                    byte[] nextTileChunk = new byte[16];
                    for (int k = 0; k < 16; k++) nextTileChunk[k] = graphicsData[dataPointer++];
                    nextBank[j] = new Tile(nextTileChunk);
                }
                GraphicsBanks.Add(nextBank);
            }

            XDocument xDoc = XDocument.Parse(Resource.default_graphics_names);
            foreach (var e in xDoc.Element("graphicsinfo").Elements("graphics"))
            {
                GraphicsInfo gi = new GraphicsInfo();
                gi.LoadFromElement(e);
                GraphicsInfo.Add(gi);
            }
        }
Beispiel #3
0
        public void LoadDefaultSpecialGraphics()
        {
            int dataPointer = 0;

            byte[] data = Resource.special_graphics;

            SpecialBanks.Clear();
            for (int i = 0; i < 4; i++)
            {
                GraphicsBank nextBank = new GraphicsBank();
                for (int j = 0; j < 64; j++)
                {
                    byte[] nextTileChunk = new byte[16];
                    for (int k = 0; k < 16; k++)
                    {
                        nextTileChunk[k] = data[dataPointer++];
                    }
                    nextBank[j] = new Tile(nextTileChunk);
                }
                SpecialBanks.Add(nextBank);
            }

            SpecialTable = new PatternTable();
            for (int j = 0; j < 4; j++)
            {
                SpecialTable.SetGraphicsbank(j, SpecialBanks[j]);
            }
        }
Beispiel #4
0
        public bool LoadGraphics(string filename)
        {
            if (!File.Exists(filename))
            {
                return(false);
            }
            FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);

            byte[] graphicsData = new byte[0x40000];

            fs.Read(graphicsData, 0, (int)fs.Length);
            fs.Close();
            int dataPointer = 0;

            GraphicsBanks.Clear();

            for (int i = 0; i < 256; i++)
            {
                GraphicsBank nextBank = new GraphicsBank();
                for (int j = 0; j < 64; j++)
                {
                    byte[] nextTileChunk = new byte[16];
                    for (int k = 0; k < 16; k++)
                    {
                        nextTileChunk[k] = graphicsData[dataPointer++];
                    }
                    nextBank[j] = new Tile(nextTileChunk);
                }
                GraphicsBanks.Add(nextBank);
            }

            LastModified = File.GetLastWriteTime(filename);
            return(true);
        }
Beispiel #5
0
        public void LoadDefault()
        {
            byte[] graphicsData = Resource.default_graphics;
            int    dataPointer  = 0;

            GraphicsBanks.Clear();

            for (int i = 0; i < 256; i++)
            {
                GraphicsBank nextBank = new GraphicsBank();
                for (int j = 0; j < 64; j++)
                {
                    byte[] nextTileChunk = new byte[16];
                    for (int k = 0; k < 16; k++)
                    {
                        nextTileChunk[k] = graphicsData[dataPointer++];
                    }
                    nextBank[j] = new Tile(nextTileChunk);
                }
                GraphicsBanks.Add(nextBank);
            }

            XDocument xDoc = XDocument.Parse(Resource.default_graphics_names);

            foreach (var e in xDoc.Element("graphicsinfo").Elements("graphics"))
            {
                GraphicsInfo gi = new GraphicsInfo();
                gi.LoadFromElement(e);
                GraphicsInfo.Add(gi);
            }
        }
Beispiel #6
0
        public bool ImportGraphics(string filename)
        {
            if (!File.Exists(filename))
            {
                return(false);
            }
            bool       IsChr = Path.GetExtension(filename) == "chr";
            FileStream fs    = new FileStream(filename, FileMode.Open, FileAccess.Read);

            byte[] graphicsData = new byte[0x40000];
            int    length, offset;

            if (!IsChr)
            {
                byte[] header = new byte[16];
                fs.Read(header, 0, 16);

                length = header[5] * 8192;
                offset = header[4] * 16384 + 16;
            }
            else
            {
                length = (int)fs.Length;
                offset = 0;
            }

            fs.Seek(offset, SeekOrigin.Begin);
            fs.Read(graphicsData, 0, length);
            fs.Close();
            int dataPointer = 0;

            GraphicsBanks.Clear();

            for (int i = 0; i < 256; i++)
            {
                GraphicsBank nextBank = new GraphicsBank();
                for (int j = 0; j < 64; j++)
                {
                    byte[] nextTileChunk = new byte[16];
                    for (int k = 0; k < 16; k++)
                    {
                        nextTileChunk[k] = graphicsData[dataPointer++];
                    }
                    nextBank[j] = new Tile(nextTileChunk);
                }
                GraphicsBanks.Add(nextBank);
            }

            if (GraphicsUpdated != null)
            {
                GraphicsUpdated(this, null);
            }

            LastModified = File.GetLastWriteTime(filename);
            //ProjectController.GraphicsManager.SaveGraphics(ProjectController.RootDirectory + @"\" + ProjectController.ProjectName + ".chr");
            return(true);
        }
Beispiel #7
0
        public void SetGraphicsbank(int index, GraphicsBank bank)
        {
            int limit = (index + 1) * 4;
            for (int y = 0, i = index * 4; i < limit; i++, y++)
            {
                for (int j = 0, x = 0; j < 16; j++, x++)
                {
                    _TileData[j, i] = bank[x, y];
                }
            }

            if (GraphicsChanged != null) GraphicsChanged(this, new TEventArgs<int>(index));
        }
Beispiel #8
0
        public void SetGraphicsbank(int index, GraphicsBank bank)
        {
            int limit = (index + 1) * 4;

            for (int y = 0, i = index * 4; i < limit; i++, y++)
            {
                for (int j = 0, x = 0; j < 16; j++, x++)
                {
                    _TileData[j, i] = bank[x, y];
                }
            }

            if (GraphicsChanged != null)
            {
                GraphicsChanged(this, new TEventArgs <int>(index));
            }
        }
Beispiel #9
0
        public void LoadDefaultSpecialGraphics()
        {
            int dataPointer = 0;
            byte[] data = Resource.special_graphics;

            SpecialBanks.Clear();
            for (int i = 0; i < 4; i++)
            {
                GraphicsBank nextBank = new GraphicsBank();
                for (int j = 0; j < 64; j++)
                {
                    byte[] nextTileChunk = new byte[16];
                    for (int k = 0; k < 16; k++) nextTileChunk[k] = data[dataPointer++];
                    nextBank[j] = new Tile(nextTileChunk);
                }
                SpecialBanks.Add(nextBank);
            }

            SpecialTable = new PatternTable();
            for (int j = 0; j < 4; j++)
            {
                SpecialTable.SetGraphicsbank(j, SpecialBanks[j]);
            }
        }
Beispiel #10
0
        public bool LoadSpecialGraphics(string fileName)
        {
            if (!File.Exists(fileName))
            {
                return(false);
            }
            int        dataPointer = 0;
            FileStream fs          = new FileStream(fileName, FileMode.Open, FileAccess.Read);

            byte[] data = new byte[fs.Length];
            fs.Read(data, 0, (int)fs.Length);
            fs.Close();

            SpecialBanks.Clear();
            for (int i = 0; i < 4; i++)
            {
                GraphicsBank nextBank = new GraphicsBank();
                for (int j = 0; j < 64; j++)
                {
                    byte[] nextTileChunk = new byte[16];
                    for (int k = 0; k < 16; k++)
                    {
                        nextTileChunk[k] = data[dataPointer++];
                    }
                    nextBank[j] = new Tile(nextTileChunk);
                }
                SpecialBanks.Add(nextBank);
            }

            SpecialTable = new PatternTable();
            for (int j = 0; j < 4; j++)
            {
                SpecialTable.SetGraphicsbank(j, SpecialBanks[j]);
            }
            return(true);
        }
Beispiel #11
0
        public bool LoadGraphics(string filename)
        {
            if (!File.Exists(filename)) return false;
            FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
            byte[] graphicsData = new byte[0x40000];

            fs.Read(graphicsData, 0, (int)fs.Length);
            fs.Close();
            int dataPointer = 0;

            GraphicsBanks.Clear();

            for (int i = 0; i < 256; i++)
            {
                GraphicsBank nextBank = new GraphicsBank();
                for (int j = 0; j < 64; j++)
                {
                    byte[] nextTileChunk = new byte[16];
                    for (int k = 0; k < 16; k++) nextTileChunk[k] = graphicsData[dataPointer++];
                    nextBank[j] = new Tile(nextTileChunk);
                }
                GraphicsBanks.Add(nextBank);
            }

            LastModified = File.GetLastWriteTime(filename);
            return true;
        }
Beispiel #12
0
        public bool ImportGraphics(string filename)
        {
            if (!File.Exists(filename)) return false;
            bool IsChr = Path.GetExtension(filename) == "chr";
            FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
            byte[] graphicsData = new byte[0x40000];
            int length, offset;

            if (!IsChr)
            {
                byte[] header = new byte[16];
                fs.Read(header, 0, 16);

                length = header[5] * 8192;
                offset = header[4] * 16384 + 16;
            }
            else
            {
                length = (int)fs.Length;
                offset = 0;
            }

            fs.Seek(offset, SeekOrigin.Begin);
            fs.Read(graphicsData, 0, length);
            fs.Close();
            int dataPointer = 0;

            GraphicsBanks.Clear();

            for (int i = 0; i < 256; i++)
            {
                GraphicsBank nextBank = new GraphicsBank();
                for (int j = 0; j < 64; j++)
                {
                    byte[] nextTileChunk = new byte[16];
                    for (int k = 0; k < 16; k++) nextTileChunk[k] = graphicsData[dataPointer++];
                    nextBank[j] = new Tile(nextTileChunk);
                }
                GraphicsBanks.Add(nextBank);
            }

            if (GraphicsUpdated != null)
            {
                GraphicsUpdated(this, null);
            }

            LastModified = File.GetLastWriteTime(filename);
            //ProjectController.GraphicsManager.SaveGraphics(ProjectController.RootDirectory + @"\" + ProjectController.ProjectName + ".chr");
            return true;
        }