コード例 #1
0
 private void RedrawAllWindows()
 {
     SNESGraphics.UpdateAll();
     if (vram != null && vram.Visible)
     {
         vram.RedrawAll();
     }
     if (cgram != null && cgram.Visible)
     {
         cgram.RedrawAll();
     }
     if (oam != null && oam.Visible)
     {
         oam.RedrawAll();
     }
     if (ppu2 != null && ppu2.Visible)
     {
         ppu2.RedrawAll();
     }
     if (tmap != null && tmap.Visible)
     {
         tmap.RedrawAll();
     }
     if (obj != null && obj.Visible)
     {
         obj.RedrawAll();
     }
 }
コード例 #2
0
        private void DrawTile(int tile, Bitmap img, int x, int y, int zoom)
        {
            int vram  = tile * SNESGraphics.bytesPerTile[bpp];
            int cgram = pal * SNESGraphics.colorsPerPalette[bpp];

            SNESGraphics.Draw8x8Tile(vram, bpp, false, false, cgram, img, x, y, zoom, 0);
        }
コード例 #3
0
        private void DrawTile(int tile, bool h, bool v, int c, Bitmap img, int x, int y, int zoom, int t)
        {
            int nameBase   = 0xE000 & ((Data.GetPPUReg(0x01) & 0x7) << 14);
            int nameOffset = 0x6000 & ((Data.GetPPUReg(0x01) & 0x18) << 10);
            int tileOffset = tile * 0x20;

            int vram  = 0xFFFF & (nameBase + (tile >= 0x100 ? nameOffset : 0) + tileOffset);
            int cgram = 0x80 + 0x10 * c;

            SNESGraphics.Draw8x8Tile(vram, 1, h, v, cgram, img, x, y, zoom, t);
        }
コード例 #4
0
ファイル: OAMEditor.cs プロジェクト: hnjm/SuperTileMapper
        private void DrawObject(int tile, bool h, bool v, bool s, int c, Bitmap img, int x, int y, int zoom)
        {
            int objsize = (Data.GetPPUReg(0x01) & 0xE0) >> 5;
            int nameBase = 0xE000 & ((Data.GetPPUReg(0x01) & 0x7) << 14);
            int nameOffset = 0x6000 & ((Data.GetPPUReg(0x01) & 0x18) << 10);
            int vram = 0xFFFF & (nameBase + (tile >= 0x100 ? nameOffset : 0) + tile * 0x20);
            int cgram = 0x80 + SNESGraphics.colorsPerPalette[1] * c;
            int bw = Util.OBJsizes[objsize, (s ? 1 : 0), 0] / 8, bh = Util.OBJsizes[objsize, (s ? 1 : 0), 1] / 8;

            SNESGraphics.DrawObject(vram, h, v, bw, bh, cgram, img, x, y, zoom);
        }
コード例 #5
0
        private void importDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ImportData   import = new ImportData("VRAM", Data.GetVRAMArray());
            DialogResult result = import.ShowDialog();

            if (result == DialogResult.OK)
            {
                SNESGraphics.UpdateAllTiles();
                RedrawAll();
                UpdateDetails();
                UpdateHexEditor(0);
                RedrawOtherWindows();
            }
        }
コード例 #6
0
ファイル: OAMEditor.cs プロジェクト: hnjm/SuperTileMapper
        private void RedrawScreen()
        {
            if (pictureBox3.Image != null)
            {
                pictureBox3.Image.Dispose();
            }
            Bitmap img = new Bitmap(512 * screenZoom, 256 * screenZoom);

            using (Graphics g = Graphics.FromImage(img))
            {
                Color back = SNESGraphics.GetTransparency(0, transparency);
                g.FillRectangle(new SolidBrush(back), new Rectangle(0, 0, img.Width, img.Height));

                int lines = ((Data.GetPPUReg(0x33) & 0x4) != 0) ? 239 : 224;
                if (displayArea == 1)
                {
                    g.DrawRectangle(new Pen(Color.Red), new Rectangle(256 * screenZoom, 1 * screenZoom, 256 * screenZoom - 1, lines * screenZoom - 1));
                }
                else if (displayArea == 2)
                {
                    g.FillRectangle(new SolidBrush(Color.FromArgb(0x80, 0x80, 0x80, 0x80)), new Rectangle(256 * screenZoom, 1 * screenZoom, 256 * screenZoom, lines * screenZoom));
                }
            }

            int rotation = Data.GetPPUReg(0x02) >> 1;

            for (int i = 0x7F; i >= 0; i--)
            {
                int j = (i + rotation) & 0x7F;

                int objLow  = Data.GetOAMByte(4 * j + 0);
                int objHigh = Data.GetOAMByte(4 * j + 1);
                int objBits = (Data.GetOAMByte(0x200 + j / 4) >> ((j % 4) * 2)) & 0x03;
                int y       = objHigh;
                int x       = ((objBits << 8) & 0x100) | objLow;

                DrawOBJ(j, img, x + 0x100, y, screenZoom);
                DrawOBJ(j, img, x - 0x100, y, screenZoom);
                DrawOBJ(j, img, x + 0x100, y - 0x100, screenZoom);
                DrawOBJ(j, img, x - 0x100, y - 0x100, screenZoom);
            }

            pictureBox3.Image  = img;
            pictureBox3.Width  = img.Width;
            pictureBox3.Height = img.Height;
        }
コード例 #7
0
        private void hexBox1_CurrentPositionInLineChanged(object sender, EventArgs e)
        {
            int i = Util.Clamp((int)hexBox1.SelectionStart - 1, 0, Data.VRAM_SIZE - 1);

            Data.SetVRAMByte(i, hexBox1.ByteProvider.ReadByte(i));

            int b = SNESGraphics.bytesPerTile[bpp];

            SNESGraphics.UpdateTile(bpp, i / b);
            Redraw(i / b);
            if (showDetails == i / b)
            {
                UpdateDetails();
            }

            // TODO: this can be reduced to only redraw when an oam-used tile is modified
            RedrawOtherWindows();
        }
コード例 #8
0
        private void DrawOBJ(int tile, bool h, bool v, bool s, int c, Bitmap img, int x, int y, int zoom)
        {
            int objsize = (Data.GetPPUReg(0x01) & 0xE0) >> 5;
            int nameBase = 0xE000 & ((Data.GetPPUReg(0x01) & 0x7) << 14);
            int nameOffset = 0x6000 & ((Data.GetPPUReg(0x01) & 0x18) << 10);
            int vram = 0xFFFF & (nameBase + (tile >= 0x100 ? nameOffset : 0) + tile * 0x20);
            int cgram = 0x80 + SNESGraphics.colorsPerPalette[1] * c;
            int bw = Util.OBJsizes[objsize, (s ? 1 : 0), 0] / 8, bh = Util.OBJsizes[objsize, (s ? 1 : 0), 1] / 8;

            for (int ty = 0; ty < bh; ty++)
            {
                for (int tx = 0; tx < bw; tx++)
                {
                    SNESGraphics.Clear8x8Tile(cgram, img, x + 8 * tx, y + 8 * ty, zoom, viewerTransparency);
                }
            }
            SNESGraphics.DrawObject(vram, h, v, bw, bh, cgram, img, x, y, zoom);
        }
コード例 #9
0
        public void Redraw(int color)
        {
            Bitmap curImg = (Bitmap)pictureBox1.Image;
            Bitmap img = curImg == null ? new Bitmap(256, 256) : curImg;
            int    cx = color % 0x10, cy = color / 0x10;

            for (int py = 0; py < 16; py++)
            {
                for (int px = 0; px < 16; px++)
                {
                    img.SetPixel(16 * cx + px, 16 * cy + py, Data.GetCGRAMColor(cy * 0x10 + cx));
                }
            }
            pictureBox1.Image = img;

            for (int bpp = 0; bpp < 4; bpp++)
            {
                SNESGraphics.UpdateColor(bpp, showDetails);
            }
        }
コード例 #10
0
        private void importTilemapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int amount = 0x80 * 0x80, vram = 0;
            int mode = Data.GetPPUReg(0x05) & 0x7;

            if (mode != 7)
            {
                int bg = bgOfInterest - 1;
                vram = ((Data.GetPPUReg(0x07 + bg) & 0xFC) << 8) & 0xFC00;
                int scSize = Data.GetPPUReg(0x07 + bg) & 0x3;
                amount = 0x20 * 0x20 * (scSize == 0 ? 1 : scSize == 3 ? 4 : 2);
            }

            ImportData   import = new ImportData("VRAM", Data.GetVRAMArray(), amount: amount, step: 3, fileStep: 1, arrOffset: vram);
            DialogResult result = import.ShowDialog();

            if (result == DialogResult.OK)
            {
                SNESGraphics.UpdateAllTiles();
                RedrawAll();
                RedrawOtherWindows();
            }
        }
コード例 #11
0
        private void DrawTile(int tile, bool h, bool v, int c, Bitmap img, int x, int y, int zoom, int t)
        {
            int bg   = bgOfInterest - 1;
            int mode = Data.GetPPUReg(0x05) & 0x7;
            int bpp  = BGBitDepths[mode, bg];

            if (bpp >= 0)
            {
                if (bpp == 3)
                {
                    int vram = 0x80 * tile;
                    SNESGraphics.Draw8x8Tile(vram, bpp, h, v, 0, img, x, y, zoom, t);
                }
                else
                {
                    int nameBase   = 0xE000 & (Data.GetPPUReg(0x0B + (bg / 2)) << (((bg & 1) == 0) ? 13 : 9));
                    int tileOffset = tile * SNESGraphics.bytesPerTile[bpp];

                    int vram  = nameBase + tileOffset;
                    int cgram = (mode == 0 ? (c + 8 * bg) : (bpp <= 1 ? c : 0)) * SNESGraphics.colorsPerPalette[bpp];
                    SNESGraphics.Draw8x8Tile(vram, bpp, h, v, cgram, img, x, y, zoom, t);
                }
            }
        }