Пример #1
0
        private void DrawTile()
        {
            if (!loaded)
            {
                return;
            }
            Bitmap    b  = new Bitmap(64, 64);
            FastPixel fp = new FastPixel(b);

            fp.rgbValues = new byte[16384];
            fp.Lock();
            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    for (int xx = 0; xx < 8; xx++)
                    {
                        for (int yy = 0; yy < 8; yy++)
                        {
                            fp.SetPixel(x * 8 + xx, y * 8 + yy, palette[pPalette.SelectedIndex, tiles[pTiles.SelectedIndex, x, y]]);
                        }
                    }
                }
            }
            fp.Unlock(true);
            pTile.Image = b;
            DrawPreviewTile();
        }
Пример #2
0
        public Bitmap drawTileset(Color[,] palette, byte[, ,] gfxData)
        {
            Bitmap    b  = new Bitmap(256, 256);
            FastPixel fp = new FastPixel(b);

            fp.rgbValues = new byte[256 * 256 * 4];
            fp.Lock();
            for (int i = 0; i < 256; i++)
            {
                for (int y = 0; y < 2; y++)
                {
                    for (int x = 0; x < 2; x++)
                    {
                        byte by    = assemblyData[i * 8 + x + (y * 2) + 0xD000];
                        byte props = assemblyData[i * 8 + 4 + x + (y * 2) + 0xD000];
                        byte pal   = (byte)((props & 0x7));

                        by -= 0x80;
                        bool vflip = false;
                        bool hflip = false;
                        if (((props >> 4) & 2) != 0)
                        {
                            hflip = true;
                        }
                        if (((props >> 4) & 4) != 0)
                        {
                            vflip = true;
                        }
                        for (int yy = 0; yy < 8; yy++)
                        {
                            for (int xx = 0; xx < 8; xx++)
                            {
                                fp.SetPixel(((i % 16) * 16) + x * 8 + xx, ((i / 16) * 16) + y * 8 + yy, palette[pal, gfxData[by, hflip ? 7 - xx : xx, vflip ? 7 - yy : yy]]);
                            }
                        }
                    }
                }
            }
            fp.Unlock(true);

            return(b);
        }
Пример #3
0
        private void DrawPreviewTile()
        {
            Bitmap    b  = new Bitmap(8, 8);
            FastPixel fp = new FastPixel(b);

            fp.rgbValues = new byte[256];
            fp.Lock();
            bool hflip = chkHorizontal.Checked;
            bool vflip = chkVertical.Checked;

            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    fp.SetPixel(x, y, palette[pPalette.SelectedIndex, tiles[pTiles.SelectedIndex, hflip ? 7 - x : x, vflip ? 7 - y : y]]);
                }
            }
            fp.Unlock(true);
            pPreviewTile.Image = b;
        }
Пример #4
0
        private void DrawTileset()
        {
            Bitmap    b  = new Bitmap(256, 256);
            FastPixel fp = new FastPixel(b);

            fp.rgbValues = new byte[256 * 256 * 4];
            fp.Lock();
            for (int i = 0; i < 256; i++)
            {
                for (int y = 0; y < 2; y++)
                {
                    for (int x = 0; x < 2; x++)
                    {
                        byte by    = formation[i * 8 + x + (y * 2)];
                        byte props = formation[i * 8 + 4 + x + (y * 2)];
                        byte pal   = (byte)((props & 0x7));

                        by -= 0x80;
                        bool vflip = false;
                        bool hflip = false;
                        if (((props >> 4) & 2) != 0)
                        {
                            hflip = true;
                        }
                        if (((props >> 4) & 4) != 0)
                        {
                            vflip = true;
                        }
                        for (int yy = 0; yy < 8; yy++)
                        {
                            for (int xx = 0; xx < 8; xx++)
                            {
                                fp.SetPixel(((i % 16) * 16) + x * 8 + xx, ((i / 16) * 16) + y * 8 + yy, palette[pal, tiles[by, hflip ? 7 - xx : xx, vflip ? 7 - yy : yy]]);
                            }
                        }
                    }
                }
            }
            fp.Unlock(true);
            pTileset.Image = b;
        }
Пример #5
0
        private void DrawTiles()
        {
            FastPixel fp = new FastPixel(tilesBmp);

            fp.rgbValues = new byte[65536];
            fp.Lock();
            for (int y = 0; y < 16; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    for (int yy = 0; yy < 8; yy++)
                    {
                        for (int xx = 0; xx < 8; xx++)
                        {
                            fp.SetPixel(x * 8 + xx, y * 8 + yy, palette[pPalette.SelectedIndex, tiles[x + y * 16, xx, yy]]);
                        }
                    }
                }
            }
            fp.Unlock(true);
            pTiles.Image = tilesBmp;
        }
Пример #6
0
        public Bitmap DrawMap(Bitmap srcTileset, bool[] flags)
        {
            Bitmap b;

            if (room.type == RoomTypes.Small)
            {
                b = new Bitmap(160, 128);
            }
            else
            {
                b = new Bitmap(240, 176);
            }
            FastPixel fp  = new FastPixel(b);
            FastPixel src = new FastPixel(srcTileset);

            if (room.type == RoomTypes.Small)
            {
                fp.rgbValues = new byte[160 * 128 * 4];
            }
            else
            {
                fp.rgbValues = new byte[240 * 176 * 4];
            }
            src.rgbValues = new byte[256 * 256 * 4];
            fp.Lock();
            src.Lock();
            //Graphics g = Graphics.FromImage(b);

            if (room.type == RoomTypes.Small)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int x = 0; x < 10; x++)
                    {
                        byte v = room.decompressed[x + y * 10];
                        for (int yy = 0; yy < 16; yy++)
                        {
                            for (int xx = 0; xx < 16; xx++)
                            {
                                fp.SetPixel(x * 16 + xx, y * 16 + yy, src.GetPixel((v % 16) * 16 + xx, (v / 16) * 16 + yy));
                            }
                        }
                        //g.DrawImage(srcTileset, new Rectangle(x * 16, y * 16, 16, 16), (room.decompressed[x + (y * 10)] % 16) * 16, (room.decompressed[x + (y * 10)] / 16) * 16, 16, 16, GraphicsUnit.Pixel);
                    }
                }
            }
            else
            {
                for (int y = 0; y < 11; y++)
                {
                    for (int x = 0; x < 15; x++)
                    {
                        byte v = room.decompressed[x + y * 16];
                        for (int yy = 0; yy < 16; yy++)
                        {
                            for (int xx = 0; xx < 16; xx++)
                            {
                                fp.SetPixel(x * 16 + xx, y * 16 + yy, src.GetPixel((v % 16) * 16 + xx, (v / 16) * 16 + yy));
                            }
                        }
                    }
                }
            }
            src.Unlock(false);
            fp.Unlock(true);

            return(b);
        }
Пример #7
0
        private void pTileset_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.X < 0 || e.Y < 0 || e.X > 511 || e.Y > 511)
            {
                return;
            }
            if (e.Button == MouseButtons.Left)
            {
                if (lastSetPoint.X == e.X / 16 * 16 && lastSetPoint.Y == e.Y / 16 * 16)
                {
                    return;
                }
                lastSetPoint = new Point(e.X / 16 * 16, e.Y / 16 * 16);
                if (history == 0)
                {
                    history = -1;
                    MakeHistory();
                }
                Bitmap    b  = (Bitmap)pTileset.Image;
                FastPixel fp = new FastPixel(b);
                fp.rgbValues = new byte[262144];
                fp.Lock();
                bool hflip = chkHorizontal.Checked;
                bool vflip = chkVertical.Checked;

                int dx      = e.X / 32;
                int dy      = e.Y / 32;
                int address = (dy * 16 + dx) * 8 + (e.X / 16 % 2) + (e.Y / 16 % 2) * 2;
                formation[address] = (byte)(pTiles.SelectedIndex + 0x80);
                int palIndex = pPalette.SelectedIndex;
                if ((originalFormation[address + 4] & 7) != 6 || !isPastTileset)
                {
                    byte p = (byte)(pPalette.SelectedIndex | 8);
                    if (chkHorizontal.Checked)
                    {
                        p |= 0x20;
                    }
                    if (chkVertical.Checked)
                    {
                        p |= 0x40;
                    }
                    if (chkPriority.Checked)
                    {
                        p |= 0x80;
                    }
                    formation[address + 4] = p;
                }
                else
                {
                    palIndex = originalFormation[address + 4] & 7;
                }

                for (int y = 0; y < 8; y++)
                {
                    for (int x = 0; x < 8; x++)
                    {
                        fp.SetPixel(dx * 16 + (e.X / 16 % 2) * 8 + x, dy * 16 + (e.Y / 16 % 2) * 8 + y, palette[pPalette.SelectedIndex, tiles[pTiles.SelectedIndex, hflip ? 7 - x : x, vflip ? 7 - y : y]]);
                    }
                }
                fp.Unlock(true);
                pTileset.Image = b;
                MakeHistory();
            }
            if (e.Button == MouseButtons.Right)
            {
                int dx      = e.X / 32;
                int dy      = e.Y / 32;
                int address = (dy * 16 + dx) * 8 + (e.X / 16 % 2) + (e.Y / 16 % 2) * 2;
                chkHorizontal.Checked  = (formation[address + 4] & 0x20) != 0;
                chkVertical.Checked    = (formation[address + 4] & 0x40) != 0;
                chkPriority.Checked    = (formation[address + 4] & 0x80) != 0;
                pTiles.SelectedIndex   = (byte)(formation[address] - 0x80);
                pPalette.SelectedIndex = formation[address + 4] & 0x7;
                DrawColors();
                DrawTiles();
                DrawTile();
                return;
            }
            if (e.Button == MouseButtons.Middle)
            {
                if (lastSetPoint.X == e.X / 16 * 16 && lastSetPoint.Y == e.Y / 16 * 16)
                {
                    return;
                }
                lastSetPoint = new Point(e.X / 16 * 16, e.Y / 16 * 16);
                int dx      = e.X / 32;
                int dy      = e.Y / 32;
                int address = (dy * 16 + dx) * 8 + (e.X / 16 % 2) + (e.Y / 16 % 2) * 2;
                if ((originalFormation[address + 4] & 7) == 6 && isPastTileset)
                {
                    return;
                }
                if (history == 0)
                {
                    history = -1;
                    MakeHistory();
                }
                bool hflip = (formation[address + 4] & 0x20) != 0;
                bool vflip = (formation[address + 4] & 0x40) != 0;
                byte p     = (byte)(pPalette.SelectedIndex | 8);
                if (hflip)
                {
                    p |= 0x20;
                }
                if (vflip)
                {
                    p |= 0x40;
                }
                formation[address + 4] = p;

                Bitmap    b  = (Bitmap)pTileset.Image;
                FastPixel fp = new FastPixel(b);
                fp.rgbValues = new byte[262144];
                fp.Lock();
                for (int y = 0; y < 8; y++)
                {
                    for (int x = 0; x < 8; x++)
                    {
                        fp.SetPixel(dx * 16 + (e.X / 16 % 2) * 8 + x, dy * 16 + (e.Y / 16 % 2) * 8 + y, palette[pPalette.SelectedIndex, tiles[(byte)(formation[address] - 0x80), hflip ? 7 - x : x, vflip ? 7 - y : y]]);
                    }
                }
                fp.Unlock(true);
                pTileset.Image = b;
                MakeHistory();
            }
        }