gb gpu view: stuff

This commit is contained in:
goyuken 2012-11-09 01:41:30 +00:00
parent 89344449a2
commit 54ea30c50d
2 changed files with 112 additions and 23 deletions

View File

@ -47,6 +47,9 @@
this.radioButtonRefreshFrame = new System.Windows.Forms.RadioButton();
this.groupBoxDetails = new System.Windows.Forms.GroupBox();
this.labelDetails = new System.Windows.Forms.Label();
this.groupBoxMemory = new System.Windows.Forms.GroupBox();
this.labelMemory = new System.Windows.Forms.Label();
this.bmpViewMemory = new BizHawk.MultiClient.GBtools.BmpView();
this.bmpViewDetails = new BizHawk.MultiClient.GBtools.BmpView();
this.bmpViewOAM = new BizHawk.MultiClient.GBtools.BmpView();
this.bmpViewBGPal = new BizHawk.MultiClient.GBtools.BmpView();
@ -55,12 +58,14 @@
this.bmpViewTiles2 = new BizHawk.MultiClient.GBtools.BmpView();
this.bmpViewBG = new BizHawk.MultiClient.GBtools.BmpView();
this.bmpViewWin = new BizHawk.MultiClient.GBtools.BmpView();
this.label7 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBoxDetails.SuspendLayout();
this.groupBoxMemory.SuspendLayout();
this.SuspendLayout();
//
// label1
@ -145,13 +150,14 @@
//
// groupBox3
//
this.groupBox3.Controls.Add(this.label7);
this.groupBox3.Controls.Add(this.label5);
this.groupBox3.Controls.Add(this.bmpViewBGPal);
this.groupBox3.Controls.Add(this.bmpViewSPPal);
this.groupBox3.Controls.Add(this.label6);
this.groupBox3.Location = new System.Drawing.Point(548, 248);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(274, 102);
this.groupBox3.Size = new System.Drawing.Size(274, 115);
this.groupBox3.TabIndex = 18;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Palettes";
@ -174,7 +180,7 @@
this.groupBox5.Controls.Add(this.radioButtonRefreshManual);
this.groupBox5.Controls.Add(this.radioButtonRefreshScanline);
this.groupBox5.Controls.Add(this.radioButtonRefreshFrame);
this.groupBox5.Location = new System.Drawing.Point(548, 356);
this.groupBox5.Location = new System.Drawing.Point(548, 369);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(274, 94);
this.groupBox5.TabIndex = 20;
@ -252,7 +258,7 @@
this.groupBoxDetails.Controls.Add(this.bmpViewDetails);
this.groupBoxDetails.Location = new System.Drawing.Point(12, 359);
this.groupBoxDetails.Name = "groupBoxDetails";
this.groupBoxDetails.Size = new System.Drawing.Size(418, 153);
this.groupBoxDetails.Size = new System.Drawing.Size(262, 153);
this.groupBoxDetails.TabIndex = 21;
this.groupBoxDetails.TabStop = false;
this.groupBoxDetails.Text = "Details";
@ -261,11 +267,41 @@
//
this.labelDetails.AutoSize = true;
this.labelDetails.Location = new System.Drawing.Point(76, 16);
this.labelDetails.MaximumSize = new System.Drawing.Size(150, 0);
this.labelDetails.Name = "labelDetails";
this.labelDetails.Size = new System.Drawing.Size(206, 13);
this.labelDetails.Size = new System.Drawing.Size(135, 26);
this.labelDetails.TabIndex = 1;
this.labelDetails.Text = "Mouse over an item to see details about it.";
//
// groupBoxMemory
//
this.groupBoxMemory.Controls.Add(this.bmpViewMemory);
this.groupBoxMemory.Controls.Add(this.labelMemory);
this.groupBoxMemory.Location = new System.Drawing.Point(280, 359);
this.groupBoxMemory.Name = "groupBoxMemory";
this.groupBoxMemory.Size = new System.Drawing.Size(262, 153);
this.groupBoxMemory.TabIndex = 22;
this.groupBoxMemory.TabStop = false;
this.groupBoxMemory.Text = "Details - Memory";
//
// labelMemory
//
this.labelMemory.AutoSize = true;
this.labelMemory.Location = new System.Drawing.Point(76, 16);
this.labelMemory.MaximumSize = new System.Drawing.Size(150, 0);
this.labelMemory.Name = "labelMemory";
this.labelMemory.Size = new System.Drawing.Size(149, 26);
this.labelMemory.TabIndex = 0;
this.labelMemory.Text = "Right-click an item to display it here.";
//
// bmpViewMemory
//
this.bmpViewMemory.BackColor = System.Drawing.Color.Black;
this.bmpViewMemory.Location = new System.Drawing.Point(6, 19);
this.bmpViewMemory.Name = "bmpViewMemory";
this.bmpViewMemory.Size = new System.Drawing.Size(64, 128);
this.bmpViewMemory.TabIndex = 1;
//
// bmpViewDetails
//
this.bmpViewDetails.BackColor = System.Drawing.Color.Black;
@ -273,6 +309,7 @@
this.bmpViewDetails.Name = "bmpViewDetails";
this.bmpViewDetails.Size = new System.Drawing.Size(64, 128);
this.bmpViewDetails.TabIndex = 0;
this.bmpViewDetails.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bmpView_MouseClick);
//
// bmpViewOAM
//
@ -281,6 +318,7 @@
this.bmpViewOAM.Name = "bmpViewOAM";
this.bmpViewOAM.Size = new System.Drawing.Size(320, 16);
this.bmpViewOAM.TabIndex = 14;
this.bmpViewOAM.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bmpView_MouseClick);
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);
@ -293,6 +331,7 @@
this.bmpViewBGPal.Size = new System.Drawing.Size(128, 64);
this.bmpViewBGPal.TabIndex = 10;
this.bmpViewBGPal.Text = "bmpView1";
this.bmpViewBGPal.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bmpView_MouseClick);
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);
@ -305,6 +344,7 @@
this.bmpViewSPPal.Size = new System.Drawing.Size(128, 64);
this.bmpViewSPPal.TabIndex = 11;
this.bmpViewSPPal.Text = "bmpView2";
this.bmpViewSPPal.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bmpView_MouseClick);
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);
@ -317,6 +357,7 @@
this.bmpViewTiles1.Size = new System.Drawing.Size(128, 192);
this.bmpViewTiles1.TabIndex = 6;
this.bmpViewTiles1.Text = "bmpView1";
this.bmpViewTiles1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bmpView_MouseClick);
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);
@ -329,6 +370,7 @@
this.bmpViewTiles2.Size = new System.Drawing.Size(128, 192);
this.bmpViewTiles2.TabIndex = 7;
this.bmpViewTiles2.Text = "bmpView2";
this.bmpViewTiles2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bmpView_MouseClick);
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);
@ -341,6 +383,7 @@
this.bmpViewBG.Size = new System.Drawing.Size(256, 256);
this.bmpViewBG.TabIndex = 4;
this.bmpViewBG.Text = "bmpView1";
this.bmpViewBG.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bmpView_MouseClick);
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);
@ -353,15 +396,26 @@
this.bmpViewWin.Size = new System.Drawing.Size(256, 256);
this.bmpViewWin.TabIndex = 5;
this.bmpViewWin.Text = "bmpView2";
this.bmpViewWin.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bmpView_MouseClick);
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);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(6, 99);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(266, 13);
this.label7.TabIndex = 14;
this.label7.Text = "Left-click a palette to use it for drawing the tiles display.";
//
// GBGPUView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(834, 524);
this.Controls.Add(this.groupBoxMemory);
this.Controls.Add(this.groupBoxDetails);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox4);
@ -384,6 +438,8 @@
this.groupBox5.PerformLayout();
this.groupBoxDetails.ResumeLayout(false);
this.groupBoxDetails.PerformLayout();
this.groupBoxMemory.ResumeLayout(false);
this.groupBoxMemory.PerformLayout();
this.ResumeLayout(false);
}
@ -417,5 +473,9 @@
private System.Windows.Forms.GroupBox groupBoxDetails;
private BmpView bmpViewDetails;
private System.Windows.Forms.Label labelDetails;
private System.Windows.Forms.GroupBox groupBoxMemory;
private System.Windows.Forms.Label labelMemory;
private BmpView bmpViewMemory;
private System.Windows.Forms.Label label7;
}
}

View File

@ -22,6 +22,8 @@ namespace BizHawk.MultiClient.GBtools
bool cgb; // set once at start
int lcdc; // set at each callback
IntPtr tilespal; // current palette to use on tiles
public GBGPUView()
{
InitializeComponent();
@ -33,6 +35,7 @@ namespace BizHawk.MultiClient.GBtools
bmpViewSPPal.ChangeBitmapSize(8, 4);
bmpViewOAM.ChangeBitmapSize(320, 16);
bmpViewDetails.ChangeBitmapSize(8, 16);
bmpViewMemory.ChangeBitmapSize(8, 16);
hScrollBarScanline.Value = 0;
hScrollBarScanline_ValueChanged(null, null); // not firing in this case??
@ -52,6 +55,7 @@ namespace BizHawk.MultiClient.GBtools
if (Visible)
Close();
}
tilespal = bgpal;
if (cgb)
label4.Enabled = true;
@ -65,6 +69,7 @@ namespace BizHawk.MultiClient.GBtools
bmpViewSPPal.Clear();
bmpViewOAM.Clear();
bmpViewDetails.Clear();
bmpViewMemory.Clear();
cbscanline_emu = -4; // force refresh
}
else
@ -373,11 +378,11 @@ namespace BizHawk.MultiClient.GBtools
// tile display
// TODO: user selects palette to use, instead of fixed palette 0
// or possibly "smart" where, if a tile is in use, it's drawn with one of the palettes actually being used with it?
DrawTiles(bmpViewTiles1.bmp, vram, bgpal);
DrawTiles(bmpViewTiles1.bmp, vram, tilespal);
bmpViewTiles1.Refresh();
if (cgb)
{
DrawTiles(bmpViewTiles2.bmp, vram + 0x2000, bgpal);
DrawTiles(bmpViewTiles2.bmp, vram + 0x2000, tilespal);
bmpViewTiles2.Refresh();
}
@ -528,7 +533,7 @@ namespace BizHawk.MultiClient.GBtools
Bitmap freeze_bmp;
string freeze_details;
void SaveFreeze()
void SaveDetails()
{
freeze_label = groupBoxDetails.Text;
if (freeze_bmp != null)
@ -537,7 +542,7 @@ namespace BizHawk.MultiClient.GBtools
freeze_details = labelDetails.Text;
}
void LoadFreeze()
void LoadDetails()
{
groupBoxDetails.Text = freeze_label;
bmpViewDetails.Height = freeze_bmp.Height * 8;
@ -548,6 +553,17 @@ namespace BizHawk.MultiClient.GBtools
bmpViewDetails.Refresh();
}
void SetFreeze()
{
groupBoxMemory.Text = groupBoxDetails.Text;
bmpViewMemory.Size = bmpViewDetails.Size;
bmpViewMemory.ChangeBitmapSize(bmpViewDetails.bmp.Size);
using (var g = Graphics.FromImage(bmpViewMemory.bmp))
g.DrawImageUnscaled(bmpViewDetails.bmp, 0, 0);
labelMemory.Text = labelDetails.Text;
bmpViewMemory.Refresh();
}
unsafe void PaletteMouseover(int x, int y, bool sprite)
{
bmpViewDetails.ChangeBitmapSize(8, 10);
@ -601,7 +617,7 @@ namespace BizHawk.MultiClient.GBtools
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);
DrawTile((byte*)vram + tileoffs + (secondbank ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)tilespal);
bmpViewDetails.bmp.UnlockBits(lockdata);
labelDetails.Text = sb.ToString();
bmpViewDetails.Refresh();
@ -693,13 +709,13 @@ namespace BizHawk.MultiClient.GBtools
private void bmpViewBG_MouseEnter(object sender, EventArgs e)
{
SaveFreeze();
SaveDetails();
groupBoxDetails.Text = "Details - Background";
}
private void bmpViewBG_MouseLeave(object sender, EventArgs e)
{
LoadFreeze();
LoadDetails();
}
private void bmpViewBG_MouseMove(object sender, MouseEventArgs e)
@ -709,13 +725,13 @@ namespace BizHawk.MultiClient.GBtools
private void bmpViewWin_MouseEnter(object sender, EventArgs e)
{
SaveFreeze();
SaveDetails();
groupBoxDetails.Text = "Details - Window";
}
private void bmpViewWin_MouseLeave(object sender, EventArgs e)
{
LoadFreeze();
LoadDetails();
}
private void bmpViewWin_MouseMove(object sender, MouseEventArgs e)
@ -725,13 +741,13 @@ namespace BizHawk.MultiClient.GBtools
private void bmpViewTiles1_MouseEnter(object sender, EventArgs e)
{
SaveFreeze();
SaveDetails();
groupBoxDetails.Text = "Details - Tiles";
}
private void bmpViewTiles1_MouseLeave(object sender, EventArgs e)
{
LoadFreeze();
LoadDetails();
}
private void bmpViewTiles1_MouseMove(object sender, MouseEventArgs e)
@ -743,7 +759,7 @@ namespace BizHawk.MultiClient.GBtools
{
if (!cgb)
return;
SaveFreeze();
SaveDetails();
groupBoxDetails.Text = "Details - Tiles";
}
@ -751,7 +767,7 @@ namespace BizHawk.MultiClient.GBtools
{
if (!cgb)
return;
LoadFreeze();
LoadDetails();
}
private void bmpViewTiles2_MouseMove(object sender, MouseEventArgs e)
@ -763,13 +779,13 @@ namespace BizHawk.MultiClient.GBtools
private void bmpViewBGPal_MouseEnter(object sender, EventArgs e)
{
SaveFreeze();
SaveDetails();
groupBoxDetails.Text = "Details - Palette";
}
private void bmpViewBGPal_MouseLeave(object sender, EventArgs e)
{
LoadFreeze();
LoadDetails();
}
private void bmpViewBGPal_MouseMove(object sender, MouseEventArgs e)
@ -779,13 +795,13 @@ namespace BizHawk.MultiClient.GBtools
private void bmpViewSPPal_MouseEnter(object sender, EventArgs e)
{
SaveFreeze();
SaveDetails();
groupBoxDetails.Text = "Details - Palette";
}
private void bmpViewSPPal_MouseLeave(object sender, EventArgs e)
{
LoadFreeze();
LoadDetails();
}
private void bmpViewSPPal_MouseMove(object sender, MouseEventArgs e)
@ -795,13 +811,13 @@ namespace BizHawk.MultiClient.GBtools
private void bmpViewOAM_MouseEnter(object sender, EventArgs e)
{
SaveFreeze();
SaveDetails();
groupBoxDetails.Text = "Details - Sprite";
}
private void bmpViewOAM_MouseLeave(object sender, EventArgs e)
{
LoadFreeze();
LoadDetails();
}
private void bmpViewOAM_MouseMove(object sender, MouseEventArgs e)
@ -811,5 +827,18 @@ namespace BizHawk.MultiClient.GBtools
#endregion
private void bmpView_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
SetFreeze();
else if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
if (sender == bmpViewBGPal)
tilespal = bgpal + e.X / 16 * 16;
else if (sender == bmpViewSPPal)
tilespal = sppal + e.X / 16 * 16;
}
}
}
}