NES NT Viewer - Refresh Rate bar
This commit is contained in:
parent
1bb58fc026
commit
17f02b3e3f
|
@ -259,6 +259,7 @@
|
|||
public bool NESNameTableSaveWindowPosition = true;
|
||||
public int NESNameTableWndx = -1;
|
||||
public int NESNameTableWndy = -1;
|
||||
public int NESNameTableRefreshRate = 4;
|
||||
|
||||
// NES Graphics settings
|
||||
public bool NESAllowMoreThanEightSprites = false;
|
||||
|
|
|
@ -55,11 +55,17 @@
|
|||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.PaletteLabel = new System.Windows.Forms.Label();
|
||||
this.NameTableView = new BizHawk.MultiClient.NameTableViewer();
|
||||
this.groupBox5 = new System.Windows.Forms.GroupBox();
|
||||
this.RefreshRate = new System.Windows.Forms.TrackBar();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.groupBox4.SuspendLayout();
|
||||
this.groupBox5.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.RefreshRate)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
|
@ -324,11 +330,55 @@
|
|||
this.NameTableView.MouseLeave += new System.EventHandler(this.NameTableView_MouseLeave);
|
||||
this.NameTableView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.NameTableView_MouseMove);
|
||||
//
|
||||
// groupBox5
|
||||
//
|
||||
this.groupBox5.Controls.Add(this.label7);
|
||||
this.groupBox5.Controls.Add(this.label6);
|
||||
this.groupBox5.Controls.Add(this.RefreshRate);
|
||||
this.groupBox5.Location = new System.Drawing.Point(563, 313);
|
||||
this.groupBox5.Name = "groupBox5";
|
||||
this.groupBox5.Size = new System.Drawing.Size(108, 236);
|
||||
this.groupBox5.TabIndex = 14;
|
||||
this.groupBox5.TabStop = false;
|
||||
this.groupBox5.Text = "Refresh";
|
||||
//
|
||||
// RefreshRate
|
||||
//
|
||||
this.RefreshRate.LargeChange = 2;
|
||||
this.RefreshRate.Location = new System.Drawing.Point(9, 47);
|
||||
this.RefreshRate.Maximum = 8;
|
||||
this.RefreshRate.Minimum = 1;
|
||||
this.RefreshRate.Name = "RefreshRate";
|
||||
this.RefreshRate.Orientation = System.Windows.Forms.Orientation.Vertical;
|
||||
this.RefreshRate.Size = new System.Drawing.Size(42, 136);
|
||||
this.RefreshRate.TabIndex = 0;
|
||||
this.RefreshRate.TickFrequency = 4;
|
||||
this.RefreshRate.Value = 1;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(7, 32);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(29, 13);
|
||||
this.label6.TabIndex = 1;
|
||||
this.label6.Text = "Less";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(7, 186);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(31, 13);
|
||||
this.label7.TabIndex = 2;
|
||||
this.label7.Text = "More";
|
||||
//
|
||||
// NESNameTableViewer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(679, 561);
|
||||
this.Controls.Add(this.groupBox5);
|
||||
this.Controls.Add(this.groupBox4);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
|
@ -349,6 +399,9 @@
|
|||
this.groupBox3.PerformLayout();
|
||||
this.groupBox4.ResumeLayout(false);
|
||||
this.groupBox4.PerformLayout();
|
||||
this.groupBox5.ResumeLayout(false);
|
||||
this.groupBox5.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.RefreshRate)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -383,5 +436,9 @@
|
|||
private System.Windows.Forms.Label TableLabel;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label PaletteLabel;
|
||||
private System.Windows.Forms.GroupBox groupBox5;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.TrackBar RefreshRate;
|
||||
private System.Windows.Forms.Label label7;
|
||||
}
|
||||
}
|
|
@ -13,6 +13,9 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
public partial class NESNameTableViewer : Form
|
||||
{
|
||||
//TODO:
|
||||
//Show Scroll Lines + UI Toggle
|
||||
|
||||
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
|
||||
int defaultHeight;
|
||||
NES Nes;
|
||||
|
@ -31,6 +34,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
Global.Config.NESNameTableWndx = this.Location.X;
|
||||
Global.Config.NESNameTableWndy = this.Location.Y;
|
||||
Global.Config.NESNameTableRefreshRate = RefreshRate.Value;
|
||||
}
|
||||
|
||||
unsafe void Generate()
|
||||
|
@ -38,13 +42,13 @@ namespace BizHawk.MultiClient
|
|||
if (!this.IsHandleCreated || this.IsDisposed) return;
|
||||
if (Nes == null) return;
|
||||
|
||||
NES.PPU ppu = Nes.ppu;
|
||||
if (!this.IsHandleCreated || this.IsDisposed) return;
|
||||
if (Global.Emulator.Frame % RefreshRate.Value != 0) return;
|
||||
|
||||
BitmapData bmpdata = NameTableView.nametables.LockBits(new Rectangle(0, 0, 512, 480), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
|
||||
int* dptr = (int*)bmpdata.Scan0.ToPointer();
|
||||
int pitch = bmpdata.Stride / 4;
|
||||
int pt_add = ppu.reg_2000.bg_pattern_hi ? 0x1000 : 0;
|
||||
int pt_add = Nes.ppu.reg_2000.bg_pattern_hi ? 0x1000 : 0;
|
||||
|
||||
//TODO - buffer all the data from the ppu, because it will be read multiple times and that is slow
|
||||
|
||||
|
@ -66,9 +70,9 @@ namespace BizHawk.MultiClient
|
|||
int ty = py >> 3;
|
||||
int ntbyte_ptr = ntaddr + (ty * 32) + tx;
|
||||
int atbyte_ptr = ntaddr + 0x3C0 + ((ty >> 2) << 3) + (tx >> 2);
|
||||
int nt = ppu.ppubus_peek(ntbyte_ptr + 0x2000);
|
||||
int nt = Nes.ppu.ppubus_peek(ntbyte_ptr + 0x2000);
|
||||
|
||||
int at = ppu.ppubus_peek(atbyte_ptr + 0x2000);
|
||||
int at = Nes.ppu.ppubus_peek(atbyte_ptr + 0x2000);
|
||||
if ((ty & 2) != 0) at >>= 4;
|
||||
if ((tx & 2) != 0) at >>= 2;
|
||||
at &= 0x03;
|
||||
|
@ -77,8 +81,8 @@ namespace BizHawk.MultiClient
|
|||
int bgpx = x & 7;
|
||||
int bgpy = y & 7;
|
||||
int pt_addr = (nt << 4) + bgpy + pt_add;
|
||||
int pt_0 = ppu.ppubus_peek(pt_addr);
|
||||
int pt_1 = ppu.ppubus_peek(pt_addr + 8);
|
||||
int pt_0 = Nes.ppu.ppubus_peek(pt_addr);
|
||||
int pt_1 = Nes.ppu.ppubus_peek(pt_addr + 8);
|
||||
int pixel = ((pt_0 >> (7 - bgpx)) & 1) | (((pt_1 >> (7 - bgpx)) & 1) << 1);
|
||||
|
||||
//if the pixel is transparent, draw the backdrop color
|
||||
|
@ -86,7 +90,7 @@ namespace BizHawk.MultiClient
|
|||
if (pixel != 0)
|
||||
pixel |= at;
|
||||
|
||||
pixel = ppu.PALRAM[pixel];
|
||||
pixel = Nes.ppu.PALRAM[pixel];
|
||||
int cvalue = Nes.LookupColor(pixel);
|
||||
*dptr = cvalue;
|
||||
}
|
||||
|
@ -121,6 +125,7 @@ namespace BizHawk.MultiClient
|
|||
this.Location = new Point(Global.Config.NESNameTableWndx, Global.Config.NESNameTableWndy);
|
||||
|
||||
Nes = Global.Emulator as NES;
|
||||
RefreshRate.Value = Global.Config.NESNameTableRefreshRate;
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue