PCEHawk: Add option for cropping

Resolves #71
This commit is contained in:
alyosha-tas 2018-02-10 15:28:27 -05:00
parent 36900b15d4
commit fd7a3a731e
5 changed files with 285 additions and 143 deletions

View File

@ -28,123 +28,238 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.OK = new System.Windows.Forms.Button(); this.OK = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button(); this.Cancel = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.DispBG2 = new System.Windows.Forms.CheckBox(); this.DispBG2 = new System.Windows.Forms.CheckBox();
this.DispOBJ2 = new System.Windows.Forms.CheckBox(); this.DispOBJ2 = new System.Windows.Forms.CheckBox();
this.DispBG1 = new System.Windows.Forms.CheckBox(); this.DispBG1 = new System.Windows.Forms.CheckBox();
this.DispOBJ1 = new System.Windows.Forms.CheckBox(); this.DispOBJ1 = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.SuspendLayout(); this.label5 = new System.Windows.Forms.Label();
// this.btnAreaFull = new System.Windows.Forms.Button();
// OK this.btnAreaStandard = new System.Windows.Forms.Button();
// this.label4 = new System.Windows.Forms.Label();
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.label3 = new System.Windows.Forms.Label();
this.OK.DialogResult = System.Windows.Forms.DialogResult.OK; this.NTSC_LastLineNumeric = new System.Windows.Forms.NumericUpDown();
this.OK.Location = new System.Drawing.Point(205, 96); this.NTSC_FirstLineNumeric = new System.Windows.Forms.NumericUpDown();
this.OK.Name = "OK"; this.groupBox1.SuspendLayout();
this.OK.Size = new System.Drawing.Size(75, 23); this.groupBox2.SuspendLayout();
this.OK.TabIndex = 4; ((System.ComponentModel.ISupportInitialize)(this.NTSC_LastLineNumeric)).BeginInit();
this.OK.Text = "&OK"; ((System.ComponentModel.ISupportInitialize)(this.NTSC_FirstLineNumeric)).BeginInit();
this.OK.UseVisualStyleBackColor = true; this.SuspendLayout();
this.OK.Click += new System.EventHandler(this.Ok_Click); //
// // OK
// Cancel //
// this.OK.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.OK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.OK.Location = new System.Drawing.Point(205, 279);
this.Cancel.Location = new System.Drawing.Point(286, 96); this.OK.Name = "OK";
this.Cancel.Name = "Cancel"; this.OK.Size = new System.Drawing.Size(75, 23);
this.Cancel.Size = new System.Drawing.Size(75, 23); this.OK.TabIndex = 4;
this.Cancel.TabIndex = 5; this.OK.Text = "&OK";
this.Cancel.Text = "&Cancel"; this.OK.UseVisualStyleBackColor = true;
this.Cancel.UseVisualStyleBackColor = true; this.OK.Click += new System.EventHandler(this.Ok_Click);
// //
// groupBox1 // Cancel
// //
this.groupBox1.Controls.Add(this.DispBG2); this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.DispOBJ2); this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.groupBox1.Controls.Add(this.DispBG1); this.Cancel.Location = new System.Drawing.Point(286, 279);
this.groupBox1.Controls.Add(this.DispOBJ1); this.Cancel.Name = "Cancel";
this.groupBox1.Location = new System.Drawing.Point(9, 12); this.Cancel.Size = new System.Drawing.Size(75, 23);
this.groupBox1.Name = "groupBox1"; this.Cancel.TabIndex = 5;
this.groupBox1.Size = new System.Drawing.Size(352, 73); this.Cancel.Text = "&Cancel";
this.groupBox1.TabIndex = 2; this.Cancel.UseVisualStyleBackColor = true;
this.groupBox1.TabStop = false; //
this.groupBox1.Text = "Background and Sprites"; // groupBox1
// //
// DispBG2 this.groupBox1.Controls.Add(this.DispBG2);
// this.groupBox1.Controls.Add(this.DispOBJ2);
this.DispBG2.AutoSize = true; this.groupBox1.Controls.Add(this.DispBG1);
this.DispBG2.Checked = true; this.groupBox1.Controls.Add(this.DispOBJ1);
this.DispBG2.CheckState = System.Windows.Forms.CheckState.Checked; this.groupBox1.Location = new System.Drawing.Point(9, 12);
this.DispBG2.Location = new System.Drawing.Point(108, 43); this.groupBox1.Name = "groupBox1";
this.DispBG2.Name = "DispBG2"; this.groupBox1.Size = new System.Drawing.Size(352, 73);
this.DispBG2.Size = new System.Drawing.Size(84, 17); this.groupBox1.TabIndex = 2;
this.DispBG2.TabIndex = 3; this.groupBox1.TabStop = false;
this.DispBG2.Text = "Display BG2"; this.groupBox1.Text = "Background and Sprites";
this.DispBG2.UseVisualStyleBackColor = true; //
// // DispBG2
// DispOBJ2 //
// this.DispBG2.AutoSize = true;
this.DispOBJ2.AutoSize = true; this.DispBG2.Checked = true;
this.DispOBJ2.Checked = true; this.DispBG2.CheckState = System.Windows.Forms.CheckState.Checked;
this.DispOBJ2.CheckState = System.Windows.Forms.CheckState.Checked; this.DispBG2.Location = new System.Drawing.Point(108, 43);
this.DispOBJ2.Location = new System.Drawing.Point(108, 21); this.DispBG2.Name = "DispBG2";
this.DispOBJ2.Name = "DispOBJ2"; this.DispBG2.Size = new System.Drawing.Size(84, 17);
this.DispOBJ2.Size = new System.Drawing.Size(89, 17); this.DispBG2.TabIndex = 3;
this.DispOBJ2.TabIndex = 2; this.DispBG2.Text = "Display BG2";
this.DispOBJ2.Text = "Display OBJ2"; this.DispBG2.UseVisualStyleBackColor = true;
this.DispOBJ2.UseVisualStyleBackColor = true; //
// // DispOBJ2
// DispBG1 //
// this.DispOBJ2.AutoSize = true;
this.DispBG1.AutoSize = true; this.DispOBJ2.Checked = true;
this.DispBG1.Checked = true; this.DispOBJ2.CheckState = System.Windows.Forms.CheckState.Checked;
this.DispBG1.CheckState = System.Windows.Forms.CheckState.Checked; this.DispOBJ2.Location = new System.Drawing.Point(108, 21);
this.DispBG1.Location = new System.Drawing.Point(9, 43); this.DispOBJ2.Name = "DispOBJ2";
this.DispBG1.Name = "DispBG1"; this.DispOBJ2.Size = new System.Drawing.Size(89, 17);
this.DispBG1.Size = new System.Drawing.Size(84, 17); this.DispOBJ2.TabIndex = 2;
this.DispBG1.TabIndex = 1; this.DispOBJ2.Text = "Display OBJ2";
this.DispBG1.Text = "Display BG1"; this.DispOBJ2.UseVisualStyleBackColor = true;
this.DispBG1.UseVisualStyleBackColor = true; //
// // DispBG1
// DispOBJ1 //
// this.DispBG1.AutoSize = true;
this.DispOBJ1.AutoSize = true; this.DispBG1.Checked = true;
this.DispOBJ1.Checked = true; this.DispBG1.CheckState = System.Windows.Forms.CheckState.Checked;
this.DispOBJ1.CheckState = System.Windows.Forms.CheckState.Checked; this.DispBG1.Location = new System.Drawing.Point(9, 43);
this.DispOBJ1.Location = new System.Drawing.Point(9, 21); this.DispBG1.Name = "DispBG1";
this.DispOBJ1.Name = "DispOBJ1"; this.DispBG1.Size = new System.Drawing.Size(84, 17);
this.DispOBJ1.Size = new System.Drawing.Size(89, 17); this.DispBG1.TabIndex = 1;
this.DispOBJ1.TabIndex = 0; this.DispBG1.Text = "Display BG1";
this.DispOBJ1.Text = "Display OBJ1"; this.DispBG1.UseVisualStyleBackColor = true;
this.DispOBJ1.UseVisualStyleBackColor = true; //
// // DispOBJ1
// PCEGraphicsConfig //
// this.DispOBJ1.AutoSize = true;
this.AcceptButton = this.OK; this.DispOBJ1.Checked = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.DispOBJ1.CheckState = System.Windows.Forms.CheckState.Checked;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.DispOBJ1.Location = new System.Drawing.Point(9, 21);
this.CancelButton = this.Cancel; this.DispOBJ1.Name = "DispOBJ1";
this.ClientSize = new System.Drawing.Size(373, 128); this.DispOBJ1.Size = new System.Drawing.Size(89, 17);
this.Controls.Add(this.groupBox1); this.DispOBJ1.TabIndex = 0;
this.Controls.Add(this.Cancel); this.DispOBJ1.Text = "Display OBJ1";
this.Controls.Add(this.OK); this.DispOBJ1.UseVisualStyleBackColor = true;
this.MaximizeBox = false; //
this.MaximumSize = new System.Drawing.Size(389, 433); // groupBox2
this.MinimizeBox = false; //
this.MinimumSize = new System.Drawing.Size(389, 166); this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.Name = "PCEGraphicsConfig"; | System.Windows.Forms.AnchorStyles.Right)));
this.ShowIcon = false; this.groupBox2.Controls.Add(this.label5);
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.groupBox2.Controls.Add(this.btnAreaFull);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.groupBox2.Controls.Add(this.btnAreaStandard);
this.Text = "PC Engine Graphics Settings"; this.groupBox2.Controls.Add(this.label4);
this.Load += new System.EventHandler(this.PCEGraphicsConfig_Load); this.groupBox2.Controls.Add(this.label3);
this.groupBox1.ResumeLayout(false); this.groupBox2.Controls.Add(this.NTSC_LastLineNumeric);
this.groupBox1.PerformLayout(); this.groupBox2.Controls.Add(this.NTSC_FirstLineNumeric);
this.ResumeLayout(false); this.groupBox2.Location = new System.Drawing.Point(9, 100);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(352, 150);
this.groupBox2.TabIndex = 6;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Drawing Area";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(62, 22);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(36, 13);
this.label5.TabIndex = 41;
this.label5.Text = "NTSC";
//
// btnAreaFull
//
this.btnAreaFull.Location = new System.Drawing.Point(6, 115);
this.btnAreaFull.Name = "btnAreaFull";
this.btnAreaFull.Size = new System.Drawing.Size(100, 23);
this.btnAreaFull.TabIndex = 40;
this.btnAreaFull.Text = "Full [0,262]";
this.btnAreaFull.UseVisualStyleBackColor = true;
this.btnAreaFull.Click += new System.EventHandler(this.BtnAreaFull_Click);
//
// btnAreaStandard
//
this.btnAreaStandard.Location = new System.Drawing.Point(6, 92);
this.btnAreaStandard.Name = "btnAreaStandard";
this.btnAreaStandard.Size = new System.Drawing.Size(100, 23);
this.btnAreaStandard.TabIndex = 35;
this.btnAreaStandard.Text = "Standard [18,252]";
this.btnAreaStandard.UseVisualStyleBackColor = true;
this.btnAreaStandard.Click += new System.EventHandler(this.BtnAreaStandard_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(4, 69);
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, 43);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(48, 13);
this.label3.TabIndex = 23;
this.label3.Text = "First line:";
//
// NTSC_LastLineNumeric
//
this.NTSC_LastLineNumeric.Location = new System.Drawing.Point(59, 67);
this.NTSC_LastLineNumeric.Maximum = new decimal(new int[] {
262,
0,
0,
0});
this.NTSC_LastLineNumeric.Minimum = new decimal(new int[] {
128,
0,
0,
0});
this.NTSC_LastLineNumeric.Name = "NTSC_LastLineNumeric";
this.NTSC_LastLineNumeric.Size = new System.Drawing.Size(47, 20);
this.NTSC_LastLineNumeric.TabIndex = 28;
this.NTSC_LastLineNumeric.Value = new decimal(new int[] {
128,
0,
0,
0});
//
// NTSC_FirstLineNumeric
//
this.NTSC_FirstLineNumeric.Location = new System.Drawing.Point(59, 41);
this.NTSC_FirstLineNumeric.Maximum = new decimal(new int[] {
127,
0,
0,
0});
this.NTSC_FirstLineNumeric.Name = "NTSC_FirstLineNumeric";
this.NTSC_FirstLineNumeric.Size = new System.Drawing.Size(47, 20);
this.NTSC_FirstLineNumeric.TabIndex = 21;
//
// PCEGraphicsConfig
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(373, 311);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.Cancel);
this.Controls.Add(this.OK);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(389, 433);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(389, 166);
this.Name = "PCEGraphicsConfig";
this.ShowIcon = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "PC Engine Graphics Settings";
this.Load += new System.EventHandler(this.PCEGraphicsConfig_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.NTSC_LastLineNumeric)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NTSC_FirstLineNumeric)).EndInit();
this.ResumeLayout(false);
} }
@ -157,5 +272,13 @@
private System.Windows.Forms.CheckBox DispOBJ2; private System.Windows.Forms.CheckBox DispOBJ2;
private System.Windows.Forms.CheckBox DispBG1; private System.Windows.Forms.CheckBox DispBG1;
private System.Windows.Forms.CheckBox DispOBJ1; private System.Windows.Forms.CheckBox DispOBJ1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button btnAreaFull;
private System.Windows.Forms.Button btnAreaStandard;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.NumericUpDown NTSC_LastLineNumeric;
private System.Windows.Forms.NumericUpDown NTSC_FirstLineNumeric;
} }
} }

View File

@ -21,6 +21,8 @@ namespace BizHawk.Client.EmuHawk
DispBG1.Checked = s.ShowBG1; DispBG1.Checked = s.ShowBG1;
DispOBJ2.Checked = s.ShowOBJ2; DispOBJ2.Checked = s.ShowOBJ2;
DispBG2.Checked = s.ShowBG2; DispBG2.Checked = s.ShowBG2;
NTSC_FirstLineNumeric.Value = s.Top_Line;
NTSC_LastLineNumeric.Value = s.Bottom_Line;
} }
private void Ok_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
@ -31,8 +33,22 @@ namespace BizHawk.Client.EmuHawk
s.ShowBG1 = DispBG1.Checked; s.ShowBG1 = DispBG1.Checked;
s.ShowOBJ2 = DispOBJ2.Checked; s.ShowOBJ2 = DispOBJ2.Checked;
s.ShowBG2 = DispBG2.Checked; s.ShowBG2 = DispBG2.Checked;
s.Top_Line = (int)NTSC_FirstLineNumeric.Value;
s.Bottom_Line = (int)NTSC_LastLineNumeric.Value;
pce.PutSettings(s); pce.PutSettings(s);
Close(); Close();
} }
private void BtnAreaStandard_Click(object sender, EventArgs e)
{
NTSC_FirstLineNumeric.Value = 18;
NTSC_LastLineNumeric.Value = 252;
}
private void BtnAreaFull_Click(object sender, EventArgs e)
{
NTSC_FirstLineNumeric.Value = 0;
NTSC_LastLineNumeric.Value = 262;
}
} }
} }

View File

@ -31,6 +31,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
} }
Settings = o; Settings = o;
CoreComm.ScreenLogicalOffsetY = Settings.Top_Line;
return ret; return ret;
} }
@ -41,7 +44,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
return ret; return ret;
} }
internal PCESettings Settings; public PCESettings Settings;
private PCESyncSettings _syncSettings; private PCESyncSettings _syncSettings;
public class PCESettings public class PCESettings
@ -51,6 +54,10 @@ namespace BizHawk.Emulation.Cores.PCEngine
public bool ShowBG2 = true; public bool ShowBG2 = true;
public bool ShowOBJ2 = true; public bool ShowOBJ2 = true;
// cropping settings
public int Top_Line = 18;
public int Bottom_Line = 252;
// these three require core reboot to use // these three require core reboot to use
public bool SpriteLimit = false; public bool SpriteLimit = false;
public bool EqualizeVolume = false; public bool EqualizeVolume = false;

View File

@ -36,9 +36,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
int ActiveDisplayStartLine = DisplayStartLine; int ActiveDisplayStartLine = DisplayStartLine;
Console.WriteLine(ActiveDisplayStartLine + Registers[VDW] + 1);
Console.WriteLine(Registers[5]);
while (true) while (true)
{ {
int VBlankLine = ActiveDisplayStartLine + Registers[VDW] + 1; int VBlankLine = ActiveDisplayStartLine + Registers[VDW] + 1;
@ -110,7 +107,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
public void RenderScanLine() public void RenderScanLine()
{ {
if ((ActiveLine + ViewStartLine) >= 262) if (((ActiveLine + ViewStartLine) >= pce.Settings.Bottom_Line) ||
((ActiveLine + ViewStartLine) < pce.Settings.Top_Line))
return; return;
RenderBackgroundScanline(pce.Settings.ShowBG1); RenderBackgroundScanline(pce.Settings.ShowBG1);
@ -128,7 +126,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
int p = vce.Palette[256]; int p = vce.Palette[256];
fixed (int* FBptr = FrameBuffer) fixed (int* FBptr = FrameBuffer)
{ {
int* dst = FBptr + (ActiveLine + ViewStartLine) * FramePitch; int* dst = FBptr + (ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch;
for (int i = 0; i < FrameWidth; i++) for (int i = 0; i < FrameWidth; i++)
*dst++ = p; *dst++ = p;
} }
@ -152,7 +150,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
{ {
// pointer to the BAT and the framebuffer for this line // pointer to the BAT and the framebuffer for this line
ushort* BatRow = VRAMptr + yTile * BatWidth; ushort* BatRow = VRAMptr + yTile * BatWidth;
int* dst = FBptr + (ActiveLine + ViewStartLine) * FramePitch; int* dst = FBptr + (ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch;
// parameters that change per tile // parameters that change per tile
ushort BatEnt; ushort BatEnt;
@ -206,7 +204,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
if (BackgroundEnabled == false) if (BackgroundEnabled == false)
{ {
for (int i = 0; i < FrameWidth; i++) for (int i = 0; i < FrameWidth; i++)
FrameBuffer[((ActiveLine + ViewStartLine) * FramePitch) + i] = vce.Palette[256]; FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + i] = vce.Palette[256];
return; return;
} }
@ -230,10 +228,10 @@ namespace BizHawk.Emulation.Cores.PCEngine
byte c = PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs]; byte c = PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs];
if (c == 0) if (c == 0)
FrameBuffer[((ActiveLine + ViewStartLine) * FramePitch) + x] = vce.Palette[0]; FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + x] = vce.Palette[0];
else else
{ {
FrameBuffer[((ActiveLine + ViewStartLine) * FramePitch) + x] = show ? vce.Palette[paletteBase + c] : vce.Palette[0]; FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + x] = show ? vce.Palette[paletteBase + c] : vce.Palette[0];
PriorityBuffer[x] = 1; PriorityBuffer[x] = 1;
} }
} }
@ -365,7 +363,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
{ {
InterSpritePriorityBuffer[xs] = 1; InterSpritePriorityBuffer[xs] = 1;
if ((priority || PriorityBuffer[xs] == 0) && show) if ((priority || PriorityBuffer[xs] == 0) && show)
FrameBuffer[((ActiveLine + ViewStartLine) * FramePitch) + xs] = vce.Palette[paletteBase + pixel]; FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
} }
} }
} }
@ -382,7 +380,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
{ {
InterSpritePriorityBuffer[xs] = 1; InterSpritePriorityBuffer[xs] = 1;
if ((priority || PriorityBuffer[xs] == 0) && show) if ((priority || PriorityBuffer[xs] == 0) && show)
FrameBuffer[((ActiveLine + ViewStartLine) * FramePitch) + xs] = vce.Palette[paletteBase + pixel]; FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
} }
} }
@ -403,7 +401,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
{ {
InterSpritePriorityBuffer[xs] = 1; InterSpritePriorityBuffer[xs] = 1;
if ((priority || PriorityBuffer[xs] == 0) && show) if ((priority || PriorityBuffer[xs] == 0) && show)
FrameBuffer[((ActiveLine + ViewStartLine) * FramePitch) + xs] = vce.Palette[paletteBase + pixel]; FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
} }
} }
if (width == 32) if (width == 32)
@ -419,7 +417,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
{ {
InterSpritePriorityBuffer[xs] = 1; InterSpritePriorityBuffer[xs] = 1;
if ((priority || PriorityBuffer[xs] == 0) && show) if ((priority || PriorityBuffer[xs] == 0) && show)
FrameBuffer[((ActiveLine + ViewStartLine) * FramePitch) + xs] = vce.Palette[paletteBase + pixel]; FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
} }
} }
} }
@ -440,9 +438,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
} }
public int VirtualWidth => FramePitch; public int VirtualWidth => FramePitch;
public int VirtualHeight => FrameHeight; public int VirtualHeight => BufferHeight;
public int BufferWidth => FramePitch; public int BufferWidth => FramePitch;
public int BufferHeight => FrameHeight; public int BufferHeight => (pce.Settings.Bottom_Line - pce.Settings.Top_Line);
public int BackgroundColor => vce.Palette[256]; public int BackgroundColor => vce.Palette[256];
public int VsyncNumerator public int VsyncNumerator

View File

@ -239,11 +239,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
private void RenderScanLine() private void RenderScanLine()
{ {
//if (VDC1.ActiveLine >= FrameHeight) if (((VDC1.ActiveLine + VDC1.ViewStartLine) >= PCE.Settings.Bottom_Line) ||
if ((VDC1.ActiveLine + VDC1.ViewStartLine) >= 262) ((VDC1.ActiveLine + VDC1.ViewStartLine) < PCE.Settings.Top_Line))
return; InitializeScanLine(VDC1.ActiveLine);
InitializeScanLine(VDC1.ActiveLine);
switch (EffectivePriorityMode) switch (EffectivePriorityMode)
{ {
@ -292,7 +290,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
{ {
// pointer to the BAT and the framebuffer for this line // pointer to the BAT and the framebuffer for this line
ushort* BatRow = VRAMptr + yTile * vdc.BatWidth; ushort* BatRow = VRAMptr + yTile * vdc.BatWidth;
int* dst = FBptr + (vdc.ActiveLine + vdc.ViewStartLine) * FrameWidth; int* dst = FBptr + (vdc.ActiveLine + vdc.ViewStartLine - PCE.Settings.Top_Line) * FrameWidth;
// parameters that change per tile // parameters that change per tile
ushort BatEnt; ushort BatEnt;
@ -448,7 +446,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
byte myPriority = priority ? highPriority : lowPriority; byte myPriority = priority ? highPriority : lowPriority;
if (PriorityBuffer[xs] < myPriority) if (PriorityBuffer[xs] < myPriority)
{ {
if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel]; if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
PriorityBuffer[xs] = myPriority; PriorityBuffer[xs] = myPriority;
} }
} }
@ -467,7 +465,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
byte myPriority = priority ? highPriority : lowPriority; byte myPriority = priority ? highPriority : lowPriority;
if (PriorityBuffer[xs] < myPriority) if (PriorityBuffer[xs] < myPriority)
{ {
if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel]; if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
PriorityBuffer[xs] = myPriority; PriorityBuffer[xs] = myPriority;
} }
} }
@ -489,7 +487,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
byte myPriority = priority ? highPriority : lowPriority; byte myPriority = priority ? highPriority : lowPriority;
if (PriorityBuffer[xs] < myPriority) if (PriorityBuffer[xs] < myPriority)
{ {
if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel]; if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
PriorityBuffer[xs] = myPriority; PriorityBuffer[xs] = myPriority;
} }
} }
@ -507,7 +505,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
byte myPriority = priority ? highPriority : lowPriority; byte myPriority = priority ? highPriority : lowPriority;
if (PriorityBuffer[xs] < myPriority) if (PriorityBuffer[xs] < myPriority)
{ {
if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel]; if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
PriorityBuffer[xs] = myPriority; PriorityBuffer[xs] = myPriority;
} }
} }