diff --git a/BizHawk.MultiClient/GBtools/GBGPUView.Designer.cs b/BizHawk.MultiClient/GBtools/GBGPUView.Designer.cs index 2d27cc17c2..fd086f25df 100644 --- a/BizHawk.MultiClient/GBtools/GBGPUView.Designer.cs +++ b/BizHawk.MultiClient/GBtools/GBGPUView.Designer.cs @@ -35,9 +35,16 @@ this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.bmpViewBG = new BizHawk.MultiClient.GBtools.BmpView(); + this.bmpViewWin = new BizHawk.MultiClient.GBtools.BmpView(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.bmpViewTiles1 = new BizHawk.MultiClient.GBtools.BmpView(); + this.bmpViewTiles2 = new BizHawk.MultiClient.GBtools.BmpView(); this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.bmpViewBGPal = new BizHawk.MultiClient.GBtools.BmpView(); + this.bmpViewSPPal = new BizHawk.MultiClient.GBtools.BmpView(); this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.bmpViewOAM = new BizHawk.MultiClient.GBtools.BmpView(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.hScrollBarScanline = new System.Windows.Forms.HScrollBar(); this.labelScanline = new System.Windows.Forms.Label(); @@ -48,13 +55,6 @@ this.groupBoxDetails = new System.Windows.Forms.GroupBox(); this.labelDetails = new System.Windows.Forms.Label(); this.bmpViewDetails = new BizHawk.MultiClient.GBtools.BmpView(); - this.bmpViewOAM = new BizHawk.MultiClient.GBtools.BmpView(); - this.bmpViewBGPal = new BizHawk.MultiClient.GBtools.BmpView(); - this.bmpViewSPPal = new BizHawk.MultiClient.GBtools.BmpView(); - this.bmpViewTiles1 = new BizHawk.MultiClient.GBtools.BmpView(); - this.bmpViewTiles2 = new BizHawk.MultiClient.GBtools.BmpView(); - this.bmpViewBG = new BizHawk.MultiClient.GBtools.BmpView(); - this.bmpViewWin = new BizHawk.MultiClient.GBtools.BmpView(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -130,6 +130,30 @@ this.groupBox1.TabStop = false; this.groupBox1.Text = "Tilemaps"; // + // bmpViewBG + // + this.bmpViewBG.BackColor = System.Drawing.Color.Black; + this.bmpViewBG.Location = new System.Drawing.Point(6, 32); + this.bmpViewBG.Name = "bmpViewBG"; + this.bmpViewBG.Size = new System.Drawing.Size(256, 256); + this.bmpViewBG.TabIndex = 4; + this.bmpViewBG.Text = "bmpView1"; + this.bmpViewBG.MouseEnter += new System.EventHandler(this.bmpViewBG_MouseEnter); + this.bmpViewBG.MouseLeave += new System.EventHandler(this.bmpViewBG_MouseLeave); + this.bmpViewBG.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewBG_MouseMove); + // + // bmpViewWin + // + this.bmpViewWin.BackColor = System.Drawing.Color.Black; + this.bmpViewWin.Location = new System.Drawing.Point(268, 32); + this.bmpViewWin.Name = "bmpViewWin"; + this.bmpViewWin.Size = new System.Drawing.Size(256, 256); + this.bmpViewWin.TabIndex = 5; + this.bmpViewWin.Text = "bmpView2"; + this.bmpViewWin.MouseEnter += new System.EventHandler(this.bmpViewWin_MouseEnter); + this.bmpViewWin.MouseLeave += new System.EventHandler(this.bmpViewWin_MouseLeave); + this.bmpViewWin.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewWin_MouseMove); + // // groupBox2 // this.groupBox2.Controls.Add(this.label3); @@ -143,6 +167,30 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "Tiles"; // + // bmpViewTiles1 + // + this.bmpViewTiles1.BackColor = System.Drawing.Color.Black; + this.bmpViewTiles1.Location = new System.Drawing.Point(6, 32); + this.bmpViewTiles1.Name = "bmpViewTiles1"; + this.bmpViewTiles1.Size = new System.Drawing.Size(128, 192); + this.bmpViewTiles1.TabIndex = 6; + this.bmpViewTiles1.Text = "bmpView1"; + this.bmpViewTiles1.MouseEnter += new System.EventHandler(this.bmpViewTiles1_MouseEnter); + this.bmpViewTiles1.MouseLeave += new System.EventHandler(this.bmpViewTiles1_MouseLeave); + this.bmpViewTiles1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewTiles1_MouseMove); + // + // bmpViewTiles2 + // + this.bmpViewTiles2.BackColor = System.Drawing.Color.Black; + this.bmpViewTiles2.Location = new System.Drawing.Point(140, 32); + this.bmpViewTiles2.Name = "bmpViewTiles2"; + this.bmpViewTiles2.Size = new System.Drawing.Size(128, 192); + this.bmpViewTiles2.TabIndex = 7; + this.bmpViewTiles2.Text = "bmpView2"; + this.bmpViewTiles2.MouseEnter += new System.EventHandler(this.bmpViewTiles2_MouseEnter); + this.bmpViewTiles2.MouseLeave += new System.EventHandler(this.bmpViewTiles2_MouseLeave); + this.bmpViewTiles2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewTiles2_MouseMove); + // // groupBox3 // this.groupBox3.Controls.Add(this.label5); @@ -156,6 +204,30 @@ this.groupBox3.TabStop = false; this.groupBox3.Text = "Palettes"; // + // bmpViewBGPal + // + this.bmpViewBGPal.BackColor = System.Drawing.Color.Black; + this.bmpViewBGPal.Location = new System.Drawing.Point(6, 32); + this.bmpViewBGPal.Name = "bmpViewBGPal"; + this.bmpViewBGPal.Size = new System.Drawing.Size(128, 64); + this.bmpViewBGPal.TabIndex = 10; + this.bmpViewBGPal.Text = "bmpView1"; + this.bmpViewBGPal.MouseEnter += new System.EventHandler(this.bmpViewBGPal_MouseEnter); + this.bmpViewBGPal.MouseLeave += new System.EventHandler(this.bmpViewBGPal_MouseLeave); + this.bmpViewBGPal.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewBGPal_MouseMove); + // + // bmpViewSPPal + // + this.bmpViewSPPal.BackColor = System.Drawing.Color.Black; + this.bmpViewSPPal.Location = new System.Drawing.Point(140, 32); + this.bmpViewSPPal.Name = "bmpViewSPPal"; + this.bmpViewSPPal.Size = new System.Drawing.Size(128, 64); + this.bmpViewSPPal.TabIndex = 11; + this.bmpViewSPPal.Text = "bmpView2"; + this.bmpViewSPPal.MouseEnter += new System.EventHandler(this.bmpViewSPPal_MouseEnter); + this.bmpViewSPPal.MouseLeave += new System.EventHandler(this.bmpViewSPPal_MouseLeave); + this.bmpViewSPPal.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewSPPal_MouseMove); + // // groupBox4 // this.groupBox4.Controls.Add(this.bmpViewOAM); @@ -166,6 +238,17 @@ this.groupBox4.TabStop = false; this.groupBox4.Text = "Sprites"; // + // bmpViewOAM + // + this.bmpViewOAM.BackColor = System.Drawing.Color.Black; + this.bmpViewOAM.Location = new System.Drawing.Point(6, 19); + this.bmpViewOAM.Name = "bmpViewOAM"; + this.bmpViewOAM.Size = new System.Drawing.Size(320, 16); + this.bmpViewOAM.TabIndex = 14; + this.bmpViewOAM.MouseEnter += new System.EventHandler(this.bmpViewOAM_MouseEnter); + this.bmpViewOAM.MouseLeave += new System.EventHandler(this.bmpViewOAM_MouseLeave); + this.bmpViewOAM.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewOAM_MouseMove); + // // groupBox5 // this.groupBox5.Controls.Add(this.hScrollBarScanline); @@ -274,89 +357,6 @@ this.bmpViewDetails.Size = new System.Drawing.Size(64, 128); this.bmpViewDetails.TabIndex = 0; // - // bmpViewOAM - // - this.bmpViewOAM.BackColor = System.Drawing.Color.Black; - this.bmpViewOAM.Location = new System.Drawing.Point(6, 19); - this.bmpViewOAM.Name = "bmpViewOAM"; - this.bmpViewOAM.Size = new System.Drawing.Size(320, 16); - this.bmpViewOAM.TabIndex = 14; - this.bmpViewOAM.MouseEnter += new System.EventHandler(this.bmpViewOAM_MouseEnter); - this.bmpViewOAM.MouseLeave += new System.EventHandler(this.bmpViewOAM_MouseLeave); - this.bmpViewOAM.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewOAM_MouseMove); - // - // bmpViewBGPal - // - this.bmpViewBGPal.BackColor = System.Drawing.Color.Black; - this.bmpViewBGPal.Location = new System.Drawing.Point(6, 32); - this.bmpViewBGPal.Name = "bmpViewBGPal"; - this.bmpViewBGPal.Size = new System.Drawing.Size(128, 64); - this.bmpViewBGPal.TabIndex = 10; - this.bmpViewBGPal.Text = "bmpView1"; - this.bmpViewBGPal.MouseEnter += new System.EventHandler(this.bmpViewBGPal_MouseEnter); - this.bmpViewBGPal.MouseLeave += new System.EventHandler(this.bmpViewBGPal_MouseLeave); - this.bmpViewBGPal.Move += new System.EventHandler(this.bmpViewBGPal_Move); - // - // bmpViewSPPal - // - this.bmpViewSPPal.BackColor = System.Drawing.Color.Black; - this.bmpViewSPPal.Location = new System.Drawing.Point(140, 32); - this.bmpViewSPPal.Name = "bmpViewSPPal"; - this.bmpViewSPPal.Size = new System.Drawing.Size(128, 64); - this.bmpViewSPPal.TabIndex = 11; - this.bmpViewSPPal.Text = "bmpView2"; - this.bmpViewSPPal.MouseEnter += new System.EventHandler(this.bmpViewSPPal_MouseEnter); - this.bmpViewSPPal.MouseLeave += new System.EventHandler(this.bmpViewSPPal_MouseLeave); - this.bmpViewSPPal.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewSPPal_MouseMove); - // - // bmpViewTiles1 - // - this.bmpViewTiles1.BackColor = System.Drawing.Color.Black; - this.bmpViewTiles1.Location = new System.Drawing.Point(6, 32); - this.bmpViewTiles1.Name = "bmpViewTiles1"; - this.bmpViewTiles1.Size = new System.Drawing.Size(128, 192); - this.bmpViewTiles1.TabIndex = 6; - this.bmpViewTiles1.Text = "bmpView1"; - this.bmpViewTiles1.MouseEnter += new System.EventHandler(this.bmpViewTiles1_MouseEnter); - this.bmpViewTiles1.MouseLeave += new System.EventHandler(this.bmpViewTiles1_MouseLeave); - this.bmpViewTiles1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewTiles1_MouseMove); - // - // bmpViewTiles2 - // - this.bmpViewTiles2.BackColor = System.Drawing.Color.Black; - this.bmpViewTiles2.Location = new System.Drawing.Point(140, 32); - this.bmpViewTiles2.Name = "bmpViewTiles2"; - this.bmpViewTiles2.Size = new System.Drawing.Size(128, 192); - this.bmpViewTiles2.TabIndex = 7; - this.bmpViewTiles2.Text = "bmpView2"; - this.bmpViewTiles2.MouseEnter += new System.EventHandler(this.bmpViewTiles2_MouseEnter); - this.bmpViewTiles2.MouseLeave += new System.EventHandler(this.bmpViewTiles2_MouseLeave); - this.bmpViewTiles2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewTiles2_MouseMove); - // - // bmpViewBG - // - this.bmpViewBG.BackColor = System.Drawing.Color.Black; - this.bmpViewBG.Location = new System.Drawing.Point(6, 32); - this.bmpViewBG.Name = "bmpViewBG"; - this.bmpViewBG.Size = new System.Drawing.Size(256, 256); - this.bmpViewBG.TabIndex = 4; - this.bmpViewBG.Text = "bmpView1"; - this.bmpViewBG.MouseEnter += new System.EventHandler(this.bmpViewBG_MouseEnter); - this.bmpViewBG.MouseLeave += new System.EventHandler(this.bmpViewBG_MouseLeave); - this.bmpViewBG.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewBG_MouseMove); - // - // bmpViewWin - // - this.bmpViewWin.BackColor = System.Drawing.Color.Black; - this.bmpViewWin.Location = new System.Drawing.Point(268, 32); - this.bmpViewWin.Name = "bmpViewWin"; - this.bmpViewWin.Size = new System.Drawing.Size(256, 256); - this.bmpViewWin.TabIndex = 5; - this.bmpViewWin.Text = "bmpView2"; - this.bmpViewWin.MouseEnter += new System.EventHandler(this.bmpViewWin_MouseEnter); - this.bmpViewWin.MouseLeave += new System.EventHandler(this.bmpViewWin_MouseLeave); - this.bmpViewWin.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewWin_MouseMove); - // // GBGPUView // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/BizHawk.MultiClient/GBtools/GBGPUView.cs b/BizHawk.MultiClient/GBtools/GBGPUView.cs index 215b195129..7f00360a8e 100644 --- a/BizHawk.MultiClient/GBtools/GBGPUView.cs +++ b/BizHawk.MultiClient/GBtools/GBGPUView.cs @@ -548,6 +548,65 @@ namespace BizHawk.MultiClient.GBtools bmpViewDetails.Refresh(); } + unsafe void PaletteMouseover(int x, int y, bool sprite) + { + bmpViewDetails.ChangeBitmapSize(8, 10); + if (bmpViewDetails.Height != 80) + bmpViewDetails.Height = 80; + var sb = new StringBuilder(); + x /= 16; + y /= 16; + int *pal = (int*)(sprite ? sppal : bgpal) + x * 4; + int color = pal[y]; + + sb.AppendLine(string.Format("Palette {0}", x)); + sb.AppendLine(string.Format("Color {0}", y)); + sb.AppendLine(string.Format("(R,G,B) = ({0},{1},{2})", color >> 16 & 255, color >> 8 & 255, color & 255)); + + var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, 10), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); + int* dest = (int*)lockdata.Scan0; + int pitch = lockdata.Stride / sizeof(int); + + for (int py = 0; py < 10; py++) + { + for (int px = 0; px < 8; px++) + { + if (py < 8) + *dest++ = color; + else + *dest++ = pal[px / 2]; + } + dest -= 8; + dest += pitch; + } + bmpViewDetails.bmp.UnlockBits(lockdata); + labelDetails.Text = sb.ToString(); + bmpViewDetails.Refresh(); + } + + unsafe void TileMouseover(int x, int y, bool secondbank) + { + // todo: draw with a specific palette + bmpViewDetails.ChangeBitmapSize(8, 8); + if (bmpViewDetails.Height != 64) + bmpViewDetails.Height = 64; + var sb = new StringBuilder(); + x /= 8; + y /= 8; + int tileindex = y * 16 + x; + int tileoffs = tileindex * 16; + if (cgb) + sb.AppendLine(string.Format("Tile #{0} @{2}:{1:x4}", tileindex, tileoffs + 0x8000, secondbank ? 1 : 0)); + else + sb.AppendLine(string.Format("Tile #{0} @{1:x4}", tileindex, tileoffs + 0x8000)); + + var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); + DrawTile((byte*)vram + tileoffs + (secondbank ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)bgpal); + bmpViewDetails.bmp.UnlockBits(lockdata); + labelDetails.Text = sb.ToString(); + bmpViewDetails.Refresh(); + } + unsafe void TilemapMouseover(int x, int y, bool win) { bmpViewDetails.ChangeBitmapSize(8, 8); @@ -632,23 +691,29 @@ namespace BizHawk.MultiClient.GBtools private void bmpViewTiles1_MouseMove(object sender, MouseEventArgs e) { - + TileMouseover(e.X, e.Y, false); } private void bmpViewTiles2_MouseEnter(object sender, EventArgs e) { + if (!cgb) + return; SaveFreeze(); groupBoxDetails.Text = "Details - Tiles"; } private void bmpViewTiles2_MouseLeave(object sender, EventArgs e) { + if (!cgb) + return; LoadFreeze(); } private void bmpViewTiles2_MouseMove(object sender, MouseEventArgs e) { - + if (!cgb) + return; + TileMouseover(e.X, e.Y, true); } private void bmpViewBGPal_MouseEnter(object sender, EventArgs e) @@ -662,9 +727,9 @@ namespace BizHawk.MultiClient.GBtools LoadFreeze(); } - private void bmpViewBGPal_Move(object sender, EventArgs e) + private void bmpViewBGPal_MouseMove(object sender, MouseEventArgs e) { - + PaletteMouseover(e.X, e.Y, false); } private void bmpViewSPPal_MouseEnter(object sender, EventArgs e) @@ -680,7 +745,7 @@ namespace BizHawk.MultiClient.GBtools private void bmpViewSPPal_MouseMove(object sender, MouseEventArgs e) { - + PaletteMouseover(e.X, e.Y, true); } private void bmpViewOAM_MouseEnter(object sender, EventArgs e) @@ -700,5 +765,6 @@ namespace BizHawk.MultiClient.GBtools } #endregion + } }