PCE BG Viewer:

Added a dropdown box to select VDC1/VDC2.
  Now it is automatically updated in 3fps. (this is just a makeshift. PCE core should provide callbacks)
This commit is contained in:
taotao54321 2012-03-12 06:27:34 +00:00
parent b10b7632e8
commit 287c5c61f8
3 changed files with 42 additions and 12 deletions

View File

@ -1802,6 +1802,7 @@ namespace BizHawk.MultiClient
NESNameTableViewer1.UpdateValues();
NESPPU1.UpdateValues();
PCEBGViewer1.UpdateValues();
PCEBGViewer1.Generate(); // TODO: just a makeshift. PCE core should provide callbacks.
TAStudio1.UpdateValues();
}

View File

@ -28,12 +28,22 @@
/// </summary>
private void InitializeComponent()
{
this.vdcComboBox = new System.Windows.Forms.ComboBox();
this.canvas = new BizHawk.MultiClient.PCEBGCanvas();
this.SuspendLayout();
//
// vdcComboBox
//
this.vdcComboBox.FormattingEnabled = true;
this.vdcComboBox.Location = new System.Drawing.Point(13, 13);
this.vdcComboBox.Name = "vdcComboBox";
this.vdcComboBox.Size = new System.Drawing.Size(121, 20);
this.vdcComboBox.TabIndex = 1;
this.vdcComboBox.SelectedIndexChanged += new System.EventHandler(this.vdcComboBox_SelectedIndexChanged);
//
// canvas
//
this.canvas.Location = new System.Drawing.Point(12, 12);
this.canvas.Location = new System.Drawing.Point(12, 49);
this.canvas.Name = "canvas";
this.canvas.Size = new System.Drawing.Size(1024, 512);
this.canvas.TabIndex = 0;
@ -42,7 +52,8 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1056, 549);
this.ClientSize = new System.Drawing.Size(1056, 573);
this.Controls.Add(this.vdcComboBox);
this.Controls.Add(this.canvas);
this.Name = "PCEBGViewer";
this.ShowIcon = false;
@ -56,5 +67,6 @@
#endregion
private PCEBGCanvas canvas;
private System.Windows.Forms.ComboBox vdcComboBox;
}
}

View File

@ -18,24 +18,32 @@ namespace BizHawk.MultiClient
public PCEBGViewer()
{
InitializeComponent();
vdcComboBox.Items.Add("VDC1");
vdcComboBox.Items.Add("VDC2");
vdcComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
vdcComboBox.SelectedIndex = 0;
Activated += (o, e) => Generate();
}
private unsafe void Generate()
public unsafe void Generate()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
if (pce == null) return;
int width = 8 * pce.VDC1.BatWidth;
int height = 8 * pce.VDC1.BatHeight;
if (Global.Emulator.Frame % 20 != 0) return; // TODO: just a makeshift. hard-coded 3fps
VDC vdc = vdcComboBox.SelectedIndex == 0 ? pce.VDC1 : pce.VDC2;
int width = 8 * vdc.BatWidth;
int height = 8 * vdc.BatHeight;
BitmapData buf = canvas.bat.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, canvas.bat.PixelFormat);
int pitch = buf.Stride / 4;
int* begin = (int*)buf.Scan0.ToPointer();
int* p = begin;
// TODO: this does not clear background, why?
for (int i = 0; i < pitch * buf.Height; ++i, ++p)
*p = canvas.BackColor.ToArgb();
//for (int i = 0; i < pitch * buf.Height; ++i, ++p)
// *p = canvas.BackColor.ToArgb();
p = begin;
for (int y = 0; y < height; ++y)
@ -46,11 +54,11 @@ namespace BizHawk.MultiClient
{
int xTile = x / 8;
int xOfs = x % 8;
int tileNo = pce.VDC1.VRAM[(ushort)(((yTile * pce.VDC1.BatWidth) + xTile))] & 0x07FF;
int paletteNo = pce.VDC1.VRAM[(ushort)(((yTile * pce.VDC1.BatWidth) + xTile))] >> 12;
int tileNo = vdc.VRAM[(ushort)(((yTile * vdc.BatWidth) + xTile))] & 0x07FF;
int paletteNo = vdc.VRAM[(ushort)(((yTile * vdc.BatWidth) + xTile))] >> 12;
int paletteBase = paletteNo * 16;
byte c = pce.VDC1.PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs];
byte c = vdc.PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs];
if (c == 0)
*p = pce.VCE.Palette[0];
else
@ -67,13 +75,15 @@ namespace BizHawk.MultiClient
public void Restart()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!(Global.Emulator is PCEngine))
{
this.Close();
return;
}
else
pce = Global.Emulator as PCEngine;
pce = Global.Emulator as PCEngine;
vdcComboBox.SelectedIndex = 0;
vdcComboBox.Enabled = pce.SystemId == "SGX";
}
public void UpdateValues()
@ -87,11 +97,18 @@ namespace BizHawk.MultiClient
private void PCEBGViewer_Load(object sender, EventArgs e)
{
pce = Global.Emulator as PCEngine;
vdcComboBox.SelectedIndex = 0;
vdcComboBox.Enabled = pce.SystemId == "SGX";
}
private void PCEBGViewer_FormClosed(object sender, FormClosedEventArgs e)
{
}
private void vdcComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
Generate();
}
}
}