NES Graphics Config - Ability to set the first and last scanlines. NES Core - refactor MyVideoProvider to accomodate new settings. Set to Top 8, Bottom 231 by default.

This commit is contained in:
andres.delikat 2011-09-04 01:12:12 +00:00
parent e13af4064b
commit 721a514d26
6 changed files with 120 additions and 32 deletions

View File

@ -131,6 +131,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo
class MyVideoProvider : IVideoProvider class MyVideoProvider : IVideoProvider
{ {
public int top = 8;
public int bottom = 231;
NES emu; NES emu;
public MyVideoProvider(NES emu) public MyVideoProvider(NES emu)
{ {
@ -143,22 +146,30 @@ namespace BizHawk.Emulation.Consoles.Nintendo
int backdrop = emu.CoreInputComm.NES_BackdropColor; int backdrop = emu.CoreInputComm.NES_BackdropColor;
bool useBackdrop = (backdrop & 0xFF000000) != 0; bool useBackdrop = (backdrop & 0xFF000000) != 0;
//TODO - we could recalculate this on the fly (and invalidate/recalculate it when the palette is changed) //TODO - we could recalculate this on the fly (and invalidate/recalculate it when the palette is changed)
for (int i = 0; i < 256 * 240; i++) for (int x = 0; x < 256; x++)
{ {
short pixel = emu.ppu.xbuf[i]; for (int y = top; y < bottom; y++)
{
short pixel = emu.ppu.xbuf[(y*256) + x];
if ((pixel & 0x8000) != 0 && useBackdrop) if ((pixel & 0x8000) != 0 && useBackdrop)
{ {
pixels[i] = backdrop; pixels[((y-top)*256) + x] = backdrop;
}
else pixels[((y-top)*256) + x] = emu.palette_compiled[pixel & 0x7FFF];
} }
else pixels[i] = emu.palette_compiled[pixel & 0x7FFF];
} }
return pixels; return pixels;
} }
public int BufferWidth { get { return 256; } } public int BufferWidth { get { return 256; } }
public int BufferHeight { get { return 240; } } public int BufferHeight { get { return bottom - top; } }
public int BackgroundColor { get { return 0; } } public int BackgroundColor { get { return 0; } }
public int Top { get { return top; } set { top = value; } }
public int Bottom { get { return bottom; } set { bottom = value; } }
} }
public int FirstDrawLine { get { return videoProvider.top; } set { videoProvider.top = value; } }
public int LastDrawLine { get { return videoProvider.bottom; } set { videoProvider.bottom = value; } }
MyVideoProvider videoProvider; MyVideoProvider videoProvider;
public IVideoProvider VideoProvider { get { return videoProvider; } } public IVideoProvider VideoProvider { get { return videoProvider; } }
public ISoundProvider SoundProvider { get { return apu; } } public ISoundProvider SoundProvider { get { return apu; } }

View File

@ -270,6 +270,8 @@
public bool NESDispSprites = true; public bool NESDispSprites = true;
public int NESBackgroundColor = 0; public int NESBackgroundColor = 0;
public string NESPaletteFile = ""; public string NESPaletteFile = "";
public int NESTopLine = 8;
public int NESBottomLine = 231;
//GB Debugger settings //GB Debugger settings
public bool AutoloadGBDebugger = false; public bool AutoloadGBDebugger = false;

View File

@ -1027,6 +1027,8 @@ namespace BizHawk.MultiClient
case "NES": case "NES":
{ {
NES nes = new NES(game, rom.FileData); NES nes = new NES(game, rom.FileData);
nes.FirstDrawLine = Global.Config.NESTopLine;
nes.LastDrawLine = Global.Config.NESBottomLine;
Global.Game.Status = nes.RomStatus; Global.Game.Status = nes.RomStatus;
nextEmulator = nes; nextEmulator = nes;
if (Global.Config.NESAutoLoadPalette && Global.Config.NESPaletteFile.Length > 0 && if (Global.Config.NESAutoLoadPalette && Global.Config.NESPaletteFile.Length > 0 &&

View File

@ -37,6 +37,10 @@
this.PalettePath = new System.Windows.Forms.TextBox(); this.PalettePath = new System.Windows.Forms.TextBox();
this.BrowsePalette = new System.Windows.Forms.Button(); this.BrowsePalette = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.LastLineNumeric = new System.Windows.Forms.NumericUpDown();
this.FirstLineNumeric = new System.Windows.Forms.NumericUpDown();
this.ClipLeftAndRightCheckBox = new System.Windows.Forms.CheckBox(); this.ClipLeftAndRightCheckBox = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox(); this.groupBox3 = new System.Windows.Forms.GroupBox();
this.checkUseBackdropColor = new System.Windows.Forms.CheckBox(); this.checkUseBackdropColor = new System.Windows.Forms.CheckBox();
@ -50,6 +54,8 @@
this.BGColorDialog = new System.Windows.Forms.ColorDialog(); this.BGColorDialog = new System.Windows.Forms.ColorDialog();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.LastLineNumeric)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.FirstLineNumeric)).BeginInit();
this.groupBox3.SuspendLayout(); this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout(); this.groupBox4.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -57,7 +63,7 @@
// OK // OK
// //
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OK.Location = new System.Drawing.Point(213, 403); this.OK.Location = new System.Drawing.Point(213, 372);
this.OK.Name = "OK"; this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23); this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 40; this.OK.TabIndex = 40;
@ -69,7 +75,7 @@
// //
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(294, 403); this.Cancel.Location = new System.Drawing.Point(294, 372);
this.Cancel.Name = "Cancel"; this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23); this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 45; this.Cancel.TabIndex = 45;
@ -79,7 +85,7 @@
// AllowMoreSprites // AllowMoreSprites
// //
this.AllowMoreSprites.AutoSize = true; this.AllowMoreSprites.AutoSize = true;
this.AllowMoreSprites.Location = new System.Drawing.Point(9, 19); this.AllowMoreSprites.Location = new System.Drawing.Point(143, 17);
this.AllowMoreSprites.Name = "AllowMoreSprites"; this.AllowMoreSprites.Name = "AllowMoreSprites";
this.AllowMoreSprites.Size = new System.Drawing.Size(203, 17); this.AllowMoreSprites.Size = new System.Drawing.Size(203, 17);
this.AllowMoreSprites.TabIndex = 15; this.AllowMoreSprites.TabIndex = 15;
@ -96,7 +102,7 @@
this.groupBox1.Controls.Add(this.BrowsePalette); this.groupBox1.Controls.Add(this.BrowsePalette);
this.groupBox1.Location = new System.Drawing.Point(12, 24); this.groupBox1.Location = new System.Drawing.Point(12, 24);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(352, 110); this.groupBox1.Size = new System.Drawing.Size(352, 95);
this.groupBox1.TabIndex = 3; this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "Palette Config"; this.groupBox1.Text = "Palette Config";
@ -106,7 +112,7 @@
this.AutoLoadPalette.AutoSize = true; this.AutoLoadPalette.AutoSize = true;
this.AutoLoadPalette.Checked = true; this.AutoLoadPalette.Checked = true;
this.AutoLoadPalette.CheckState = System.Windows.Forms.CheckState.Checked; this.AutoLoadPalette.CheckState = System.Windows.Forms.CheckState.Checked;
this.AutoLoadPalette.Location = new System.Drawing.Point(6, 73); this.AutoLoadPalette.Location = new System.Drawing.Point(6, 66);
this.AutoLoadPalette.Name = "AutoLoadPalette"; this.AutoLoadPalette.Name = "AutoLoadPalette";
this.AutoLoadPalette.Size = new System.Drawing.Size(135, 17); this.AutoLoadPalette.Size = new System.Drawing.Size(135, 17);
this.AutoLoadPalette.TabIndex = 10; this.AutoLoadPalette.TabIndex = 10;
@ -116,7 +122,7 @@
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 31); this.label1.Location = new System.Drawing.Point(6, 24);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 13); this.label1.Size = new System.Drawing.Size(100, 13);
this.label1.TabIndex = 2; this.label1.TabIndex = 2;
@ -126,7 +132,7 @@
// //
this.PalettePath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.PalettePath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.PalettePath.Location = new System.Drawing.Point(6, 47); this.PalettePath.Location = new System.Drawing.Point(6, 40);
this.PalettePath.Name = "PalettePath"; this.PalettePath.Name = "PalettePath";
this.PalettePath.Size = new System.Drawing.Size(259, 20); this.PalettePath.Size = new System.Drawing.Size(259, 20);
this.PalettePath.TabIndex = 1; this.PalettePath.TabIndex = 1;
@ -134,7 +140,7 @@
// BrowsePalette // BrowsePalette
// //
this.BrowsePalette.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.BrowsePalette.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.BrowsePalette.Location = new System.Drawing.Point(271, 44); this.BrowsePalette.Location = new System.Drawing.Point(271, 37);
this.BrowsePalette.Name = "BrowsePalette"; this.BrowsePalette.Name = "BrowsePalette";
this.BrowsePalette.Size = new System.Drawing.Size(75, 23); this.BrowsePalette.Size = new System.Drawing.Size(75, 23);
this.BrowsePalette.TabIndex = 5; this.BrowsePalette.TabIndex = 5;
@ -146,19 +152,76 @@
// //
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.LastLineNumeric);
this.groupBox2.Controls.Add(this.FirstLineNumeric);
this.groupBox2.Controls.Add(this.ClipLeftAndRightCheckBox); this.groupBox2.Controls.Add(this.ClipLeftAndRightCheckBox);
this.groupBox2.Controls.Add(this.AllowMoreSprites); this.groupBox2.Controls.Add(this.AllowMoreSprites);
this.groupBox2.Location = new System.Drawing.Point(12, 156); this.groupBox2.Location = new System.Drawing.Point(12, 125);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(352, 81); this.groupBox2.Size = new System.Drawing.Size(352, 88);
this.groupBox2.TabIndex = 4; this.groupBox2.TabIndex = 4;
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "Drawing Area";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(4, 47);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(49, 13);
this.label4.TabIndex = 24;
this.label4.Text = "Last line:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(5, 21);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(48, 13);
this.label3.TabIndex = 23;
this.label3.Text = "First line:";
//
// LastLineNumeric
//
this.LastLineNumeric.Location = new System.Drawing.Point(59, 45);
this.LastLineNumeric.Maximum = new decimal(new int[] {
240,
0,
0,
0});
this.LastLineNumeric.Minimum = new decimal(new int[] {
128,
0,
0,
0});
this.LastLineNumeric.Name = "LastLineNumeric";
this.LastLineNumeric.Size = new System.Drawing.Size(47, 20);
this.LastLineNumeric.TabIndex = 22;
this.LastLineNumeric.Value = new decimal(new int[] {
128,
0,
0,
0});
//
// FirstLineNumeric
//
this.FirstLineNumeric.Location = new System.Drawing.Point(59, 19);
this.FirstLineNumeric.Maximum = new decimal(new int[] {
127,
0,
0,
0});
this.FirstLineNumeric.Name = "FirstLineNumeric";
this.FirstLineNumeric.Size = new System.Drawing.Size(47, 20);
this.FirstLineNumeric.TabIndex = 21;
// //
// ClipLeftAndRightCheckBox // ClipLeftAndRightCheckBox
// //
this.ClipLeftAndRightCheckBox.AutoSize = true; this.ClipLeftAndRightCheckBox.AutoSize = true;
this.ClipLeftAndRightCheckBox.Enabled = false; this.ClipLeftAndRightCheckBox.Enabled = false;
this.ClipLeftAndRightCheckBox.Location = new System.Drawing.Point(9, 42); this.ClipLeftAndRightCheckBox.Location = new System.Drawing.Point(143, 47);
this.ClipLeftAndRightCheckBox.Name = "ClipLeftAndRightCheckBox"; this.ClipLeftAndRightCheckBox.Name = "ClipLeftAndRightCheckBox";
this.ClipLeftAndRightCheckBox.Size = new System.Drawing.Size(186, 17); this.ClipLeftAndRightCheckBox.Size = new System.Drawing.Size(186, 17);
this.ClipLeftAndRightCheckBox.TabIndex = 20; this.ClipLeftAndRightCheckBox.TabIndex = 20;
@ -167,7 +230,7 @@
// //
// groupBox3 // groupBox3
// //
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox3.Controls.Add(this.checkUseBackdropColor); this.groupBox3.Controls.Add(this.checkUseBackdropColor);
this.groupBox3.Controls.Add(this.ChangeBGColor); this.groupBox3.Controls.Add(this.ChangeBGColor);
@ -176,7 +239,7 @@
this.groupBox3.Controls.Add(this.groupBox4); this.groupBox3.Controls.Add(this.groupBox4);
this.groupBox3.Controls.Add(this.DispBackground); this.groupBox3.Controls.Add(this.DispBackground);
this.groupBox3.Controls.Add(this.DispSprites); this.groupBox3.Controls.Add(this.DispSprites);
this.groupBox3.Location = new System.Drawing.Point(12, 254); this.groupBox3.Location = new System.Drawing.Point(12, 223);
this.groupBox3.Name = "groupBox3"; this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(352, 128); this.groupBox3.Size = new System.Drawing.Size(352, 128);
this.groupBox3.TabIndex = 5; this.groupBox3.TabIndex = 5;
@ -269,7 +332,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel; this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(381, 438); this.ClientSize = new System.Drawing.Size(381, 407);
this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox1);
@ -285,6 +348,8 @@
this.groupBox1.PerformLayout(); this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false); this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout(); this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.LastLineNumeric)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.FirstLineNumeric)).EndInit();
this.groupBox3.ResumeLayout(false); this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout(); this.groupBox3.PerformLayout();
this.groupBox4.ResumeLayout(false); this.groupBox4.ResumeLayout(false);
@ -314,5 +379,9 @@
private System.Windows.Forms.Button ChangeBGColor; private System.Windows.Forms.Button ChangeBGColor;
private System.Windows.Forms.ColorDialog BGColorDialog; private System.Windows.Forms.ColorDialog BGColorDialog;
private System.Windows.Forms.CheckBox checkUseBackdropColor; private System.Windows.Forms.CheckBox checkUseBackdropColor;
private System.Windows.Forms.NumericUpDown FirstLineNumeric;
private System.Windows.Forms.NumericUpDown LastLineNumeric;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
} }
} }

View File

@ -36,6 +36,8 @@ namespace BizHawk.MultiClient
private void NESGraphicsConfig_Load(object sender, EventArgs e) private void NESGraphicsConfig_Load(object sender, EventArgs e)
{ {
nes = Global.Emulator as NES; nes = Global.Emulator as NES;
FirstLineNumeric.Value = Global.Config.NESTopLine;
LastLineNumeric.Value = Global.Config.NESBottomLine;
AllowMoreSprites.Checked = Global.Config.NESAllowMoreThanEightSprites; AllowMoreSprites.Checked = Global.Config.NESAllowMoreThanEightSprites;
ClipLeftAndRightCheckBox.Checked = Global.Config.NESClipLeftAndRight; ClipLeftAndRightCheckBox.Checked = Global.Config.NESClipLeftAndRight;
AutoLoadPalette.Checked = Global.Config.NESAutoLoadPalette; AutoLoadPalette.Checked = Global.Config.NESAutoLoadPalette;
@ -85,6 +87,10 @@ namespace BizHawk.MultiClient
Global.RenderPanel.AddMessage("Standard Palette set"); Global.RenderPanel.AddMessage("Standard Palette set");
} }
Global.Config.NESTopLine = (int)FirstLineNumeric.Value;
Global.Config.NESBottomLine = (int)LastLineNumeric.Value;
nes.FirstDrawLine = (int)FirstLineNumeric.Value;
nes.LastDrawLine = (int)LastLineNumeric.Value;
Global.Config.NESAllowMoreThanEightSprites = AllowMoreSprites.Checked; Global.Config.NESAllowMoreThanEightSprites = AllowMoreSprites.Checked;
Global.Config.NESClipLeftAndRight = ClipLeftAndRightCheckBox.Checked; Global.Config.NESClipLeftAndRight = ClipLeftAndRightCheckBox.Checked;
Global.Config.NESAutoLoadPalette = AutoLoadPalette.Checked; Global.Config.NESAutoLoadPalette = AutoLoadPalette.Checked;
@ -109,7 +115,5 @@ namespace BizHawk.MultiClient
if (BGColorDialog.ShowDialog() == DialogResult.OK) if (BGColorDialog.ShowDialog() == DialogResult.OK)
SetColorBox(); SetColorBox();
} }
} }
} }

View File

@ -112,12 +112,12 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="BGColorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="BGColorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
</root> </root>