示例#1
0
        private void ImportTitleLogo()
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = LAZYSHELL.Properties.Settings.Default.LastRomPath;
            openFileDialog1.Title            = "Import title logo";
            openFileDialog1.Filter           = "Image files (*.gif,*.jpg,*.png)|*.gif;*.jpg;*.png";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (openFileDialog1.FileName == null)
            {
                return;
            }
            Bitmap import = new Bitmap(Image.FromFile(openFileDialog1.FileName));

            if (import.Width != 256 || import.Height != 96)
            {
                MessageBox.Show(
                    "The dimensions of the imported image must be 256 x 96.",
                    "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            byte[] graphics      = new byte[0x3000];
            byte[] gameTitle     = new byte[0x1C00];
            byte[] gameCopyright = new byte[0x1400];
            int[]  palette       = paletteSet.Palettes[3];
            Do.PixelsToBPP(
                Do.ImageToPixels(import, new Size(256, 56), new Rectangle(0, 0, 256, 56)), gameTitle,
                new Size(256 / 8, 56 / 8), palette, 0x20);
            palette = paletteSet.Palettes[6];
            Do.PixelsToBPP(
                Do.ImageToPixels(import, new Size(256, 56), new Rectangle(0, 56, 256, 40)), gameCopyright,
                new Size(256 / 8, 40 / 8), palette, 0x20);
            Buffer.BlockCopy(gameTitle, 0, graphics, 0, 0x1C00);
            Buffer.BlockCopy(gameCopyright, 0, graphics, 0x1C00, 0x1400);
            byte[] tileset          = new byte[0x300];
            byte[] tilesetTitle     = new byte[0x300];
            byte[] tilesetCopyright = new byte[0x300];
            byte[] temp             = new byte[graphics.Length]; graphics.CopyTo(temp, 0);
            Do.CopyToTileset(graphics, tilesetTitle, palette, 3, true, true, 0x20, 2, new Size(256, 96), 2);
            Do.CopyToTileset(temp, tilesetCopyright, palette, 6, true, true, 0x20, 2, new Size(256, 96), 2);
            Buffer.BlockCopy(tilesetTitle, 0, tileset, 0, 0x300);
            Buffer.BlockCopy(tilesetCopyright, 0x1C0, tileset, 0x1C0, 0x140);
            Buffer.BlockCopy(tileset, 0, Model.TitleData, 0xBBE0, 0x300);
            Buffer.BlockCopy(graphics, 0, Model.TitleData, 0xBEE0, 0x1B80);
            Model.TitleTileSet = new Tileset(paletteSet, "title");
            this.tileset       = Model.TitleTileSet;
        }
示例#2
0
        private void importImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = LazyShell.Properties.Settings.Default.LastRomPath;
            openFileDialog1.Title            = "Import opening credits";
            openFileDialog1.Filter           = "Image files (*.gif,*.jpg,*.png)|*.gif;*.jpg;*.png";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (openFileDialog1.FileName == null)
            {
                return;
            }
            Bitmap import = new Bitmap(Image.FromFile(openFileDialog1.FileName));

            if (import.Width != 256 || import.Height != 144)
            {
                MessageBox.Show(
                    "The dimensions of the imported image must be 256 x 144.",
                    "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            byte[] graphics = new byte[0x4000];
            int[]  palette  = paletteSet.Palettes[0];
            Do.PixelsToBPP(
                Do.ImageToPixels(import, new Size(256, 144), new Rectangle(0, 0, 256, 144)), graphics,
                new Size(256 / 8, 144 / 8), palette, 0x10);
            byte[] tileset = new byte[0x800];
            byte[] temp    = new byte[graphics.Length]; graphics.CopyTo(temp, 0);
            Do.CopyToTileset(graphics, tileset, palette, 0, true, false, 0x10, 2, new Size(256, 144), 0);
            Buffer.BlockCopy(tileset, 0, castTileset, 0, 0x480);
            Buffer.BlockCopy(graphics, 0, castGraphics, 0, 0x1340);
            this.tileset = new Tileset(castTileset, castGraphics, paletteSet, 16, 9, TilesetType.Opening);
            SetTilesetImage();
        }
示例#3
0
        // import/export
        private void ImportTitle()
        {
            Layer = 0;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = LAZYSHELL.Properties.Settings.Default.LastRomPath;
            openFileDialog1.Title            = "Import Layer 1";
            openFileDialog1.Filter           = "Image files (*.gif,*.jpg,*.png)|*.gif;*.jpg;*.png";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (openFileDialog1.FileName == null)
            {
                return;
            }
            Bitmap importL1 = new Bitmap(Image.FromFile(openFileDialog1.FileName));

            if (importL1.Width != 256 || importL1.Height != 512)
            {
                MessageBox.Show(
                    "The dimensions of the imported image must be exactly 256 x 512.",
                    "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            int[] importL1pixels = Do.ImageToPixels(importL1, new Size(256, 512), new Rectangle(0, 0, 256, 512));
            Layer = 1;
            openFileDialog1.Title = "Import Layer 2";
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (openFileDialog1.FileName == null)
            {
                return;
            }
            Bitmap importL2 = new Bitmap(Image.FromFile(openFileDialog1.FileName));

            if (importL2.Width != 256 || importL2.Height != 512)
            {
                MessageBox.Show(
                    "The dimensions of the imported image must be exactly 256 x 512.",
                    "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            int[] importL2pixels = Do.ImageToPixels(importL2, new Size(256, 512), new Rectangle(0, 0, 256, 512));
            // now combine the two into one pixel array
            int[] importPixels = new int[256 * 1024];
            for (int y = 0; y < 512; y++)
            {
                for (int x = 0; x < 256; x++)
                {
                    importPixels[y * 256 + x]         = importL1pixels[y * 256 + x];
                    importPixels[(y + 512) * 256 + x] = importL2pixels[y * 256 + x];
                }
            }
            byte[]  graphics = new byte[0x20000];
            int[][] palettes = new int[8][];
            for (int i = 0; i < 8; i++)
            {
                palettes[i] = paletteSet.Palettes[i];
            }
            int[] paletteIndexes = Do.PixelsToBPP(
                importPixels, graphics,
                new Size(256 / 8, 1024 / 8), palettes, 0x20);
            if (paletteIndexes == null)
            {
                return;
            }
            byte[] tileset = new byte[0x2000];
            Do.CopyToTileset(graphics, tileset, palettes, paletteIndexes, true, false, 0x20, 2, new Size(256, 1024), 0);
            Buffer.BlockCopy(tileset, 0, Model.TitleData, 0, 0x2000);
            Buffer.BlockCopy(graphics, 0, Model.TitleData, 0x6C00, 0x4FE0);
            Model.TitleTileSet = new Tileset(paletteSet, "title");
            this.tileset       = Model.TitleTileSet;
        }