From fd7a3a731ee73b43fe78d8f5820160bb11d15676 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Sat, 10 Feb 2018 15:28:27 -0500 Subject: [PATCH] PCEHawk: Add option for cropping Resolves #71 --- .../config/PCE/PCEGraphicsConfig.Designer.cs | 357 ++++++++++++------ .../config/PCE/PCEGraphicsConfig.cs | 16 + .../Consoles/PC Engine/PCEngine.ISettable.cs | 9 +- .../Consoles/PC Engine/VDC.Render.cs | 28 +- .../Consoles/PC Engine/VPC.cs | 18 +- 5 files changed, 285 insertions(+), 143 deletions(-) diff --git a/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.Designer.cs b/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.Designer.cs index 4047b8680b..7f8e659c38 100644 --- a/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.Designer.cs @@ -28,123 +28,238 @@ /// private void InitializeComponent() { - this.OK = new System.Windows.Forms.Button(); - this.Cancel = new System.Windows.Forms.Button(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.DispBG2 = new System.Windows.Forms.CheckBox(); - this.DispOBJ2 = new System.Windows.Forms.CheckBox(); - this.DispBG1 = new System.Windows.Forms.CheckBox(); - this.DispOBJ1 = new System.Windows.Forms.CheckBox(); - this.groupBox1.SuspendLayout(); - this.SuspendLayout(); - // - // OK - // - this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.OK.Location = new System.Drawing.Point(205, 96); - this.OK.Name = "OK"; - this.OK.Size = new System.Drawing.Size(75, 23); - this.OK.TabIndex = 4; - this.OK.Text = "&OK"; - this.OK.UseVisualStyleBackColor = true; - this.OK.Click += new System.EventHandler(this.Ok_Click); - // - // Cancel - // - 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.Location = new System.Drawing.Point(286, 96); - this.Cancel.Name = "Cancel"; - this.Cancel.Size = new System.Drawing.Size(75, 23); - this.Cancel.TabIndex = 5; - this.Cancel.Text = "&Cancel"; - this.Cancel.UseVisualStyleBackColor = true; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.DispBG2); - this.groupBox1.Controls.Add(this.DispOBJ2); - this.groupBox1.Controls.Add(this.DispBG1); - this.groupBox1.Controls.Add(this.DispOBJ1); - this.groupBox1.Location = new System.Drawing.Point(9, 12); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(352, 73); - this.groupBox1.TabIndex = 2; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Background and Sprites"; - // - // DispBG2 - // - this.DispBG2.AutoSize = true; - this.DispBG2.Checked = true; - this.DispBG2.CheckState = System.Windows.Forms.CheckState.Checked; - this.DispBG2.Location = new System.Drawing.Point(108, 43); - this.DispBG2.Name = "DispBG2"; - this.DispBG2.Size = new System.Drawing.Size(84, 17); - this.DispBG2.TabIndex = 3; - this.DispBG2.Text = "Display BG2"; - this.DispBG2.UseVisualStyleBackColor = true; - // - // DispOBJ2 - // - this.DispOBJ2.AutoSize = true; - this.DispOBJ2.Checked = true; - this.DispOBJ2.CheckState = System.Windows.Forms.CheckState.Checked; - this.DispOBJ2.Location = new System.Drawing.Point(108, 21); - this.DispOBJ2.Name = "DispOBJ2"; - this.DispOBJ2.Size = new System.Drawing.Size(89, 17); - this.DispOBJ2.TabIndex = 2; - this.DispOBJ2.Text = "Display OBJ2"; - this.DispOBJ2.UseVisualStyleBackColor = true; - // - // DispBG1 - // - this.DispBG1.AutoSize = true; - this.DispBG1.Checked = true; - this.DispBG1.CheckState = System.Windows.Forms.CheckState.Checked; - this.DispBG1.Location = new System.Drawing.Point(9, 43); - this.DispBG1.Name = "DispBG1"; - this.DispBG1.Size = new System.Drawing.Size(84, 17); - this.DispBG1.TabIndex = 1; - this.DispBG1.Text = "Display BG1"; - this.DispBG1.UseVisualStyleBackColor = true; - // - // DispOBJ1 - // - this.DispOBJ1.AutoSize = true; - this.DispOBJ1.Checked = true; - this.DispOBJ1.CheckState = System.Windows.Forms.CheckState.Checked; - this.DispOBJ1.Location = new System.Drawing.Point(9, 21); - this.DispOBJ1.Name = "DispOBJ1"; - this.DispOBJ1.Size = new System.Drawing.Size(89, 17); - this.DispOBJ1.TabIndex = 0; - this.DispOBJ1.Text = "Display OBJ1"; - this.DispOBJ1.UseVisualStyleBackColor = true; - // - // 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, 128); - 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.ResumeLayout(false); + this.OK = new System.Windows.Forms.Button(); + this.Cancel = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.DispBG2 = new System.Windows.Forms.CheckBox(); + this.DispOBJ2 = new System.Windows.Forms.CheckBox(); + this.DispBG1 = new System.Windows.Forms.CheckBox(); + this.DispOBJ1 = new System.Windows.Forms.CheckBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.label5 = new System.Windows.Forms.Label(); + this.btnAreaFull = new System.Windows.Forms.Button(); + this.btnAreaStandard = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.NTSC_LastLineNumeric = new System.Windows.Forms.NumericUpDown(); + this.NTSC_FirstLineNumeric = new System.Windows.Forms.NumericUpDown(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NTSC_LastLineNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.NTSC_FirstLineNumeric)).BeginInit(); + this.SuspendLayout(); + // + // OK + // + this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.OK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.OK.Location = new System.Drawing.Point(205, 279); + this.OK.Name = "OK"; + this.OK.Size = new System.Drawing.Size(75, 23); + this.OK.TabIndex = 4; + this.OK.Text = "&OK"; + this.OK.UseVisualStyleBackColor = true; + this.OK.Click += new System.EventHandler(this.Ok_Click); + // + // Cancel + // + 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.Location = new System.Drawing.Point(286, 279); + this.Cancel.Name = "Cancel"; + this.Cancel.Size = new System.Drawing.Size(75, 23); + this.Cancel.TabIndex = 5; + this.Cancel.Text = "&Cancel"; + this.Cancel.UseVisualStyleBackColor = true; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.DispBG2); + this.groupBox1.Controls.Add(this.DispOBJ2); + this.groupBox1.Controls.Add(this.DispBG1); + this.groupBox1.Controls.Add(this.DispOBJ1); + this.groupBox1.Location = new System.Drawing.Point(9, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(352, 73); + this.groupBox1.TabIndex = 2; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Background and Sprites"; + // + // DispBG2 + // + this.DispBG2.AutoSize = true; + this.DispBG2.Checked = true; + this.DispBG2.CheckState = System.Windows.Forms.CheckState.Checked; + this.DispBG2.Location = new System.Drawing.Point(108, 43); + this.DispBG2.Name = "DispBG2"; + this.DispBG2.Size = new System.Drawing.Size(84, 17); + this.DispBG2.TabIndex = 3; + this.DispBG2.Text = "Display BG2"; + this.DispBG2.UseVisualStyleBackColor = true; + // + // DispOBJ2 + // + this.DispOBJ2.AutoSize = true; + this.DispOBJ2.Checked = true; + this.DispOBJ2.CheckState = System.Windows.Forms.CheckState.Checked; + this.DispOBJ2.Location = new System.Drawing.Point(108, 21); + this.DispOBJ2.Name = "DispOBJ2"; + this.DispOBJ2.Size = new System.Drawing.Size(89, 17); + this.DispOBJ2.TabIndex = 2; + this.DispOBJ2.Text = "Display OBJ2"; + this.DispOBJ2.UseVisualStyleBackColor = true; + // + // DispBG1 + // + this.DispBG1.AutoSize = true; + this.DispBG1.Checked = true; + this.DispBG1.CheckState = System.Windows.Forms.CheckState.Checked; + this.DispBG1.Location = new System.Drawing.Point(9, 43); + this.DispBG1.Name = "DispBG1"; + this.DispBG1.Size = new System.Drawing.Size(84, 17); + this.DispBG1.TabIndex = 1; + this.DispBG1.Text = "Display BG1"; + this.DispBG1.UseVisualStyleBackColor = true; + // + // DispOBJ1 + // + this.DispOBJ1.AutoSize = true; + this.DispOBJ1.Checked = true; + this.DispOBJ1.CheckState = System.Windows.Forms.CheckState.Checked; + this.DispOBJ1.Location = new System.Drawing.Point(9, 21); + this.DispOBJ1.Name = "DispOBJ1"; + this.DispOBJ1.Size = new System.Drawing.Size(89, 17); + this.DispOBJ1.TabIndex = 0; + this.DispOBJ1.Text = "Display OBJ1"; + this.DispOBJ1.UseVisualStyleBackColor = true; + // + // groupBox2 + // + this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox2.Controls.Add(this.label5); + this.groupBox2.Controls.Add(this.btnAreaFull); + this.groupBox2.Controls.Add(this.btnAreaStandard); + this.groupBox2.Controls.Add(this.label4); + this.groupBox2.Controls.Add(this.label3); + this.groupBox2.Controls.Add(this.NTSC_LastLineNumeric); + this.groupBox2.Controls.Add(this.NTSC_FirstLineNumeric); + 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 DispBG1; 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; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs b/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs index 13eaae966c..fd08ec4724 100644 --- a/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs +++ b/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs @@ -21,6 +21,8 @@ namespace BizHawk.Client.EmuHawk DispBG1.Checked = s.ShowBG1; DispOBJ2.Checked = s.ShowOBJ2; DispBG2.Checked = s.ShowBG2; + NTSC_FirstLineNumeric.Value = s.Top_Line; + NTSC_LastLineNumeric.Value = s.Bottom_Line; } private void Ok_Click(object sender, EventArgs e) @@ -31,8 +33,22 @@ namespace BizHawk.Client.EmuHawk s.ShowBG1 = DispBG1.Checked; s.ShowOBJ2 = DispOBJ2.Checked; s.ShowBG2 = DispBG2.Checked; + s.Top_Line = (int)NTSC_FirstLineNumeric.Value; + s.Bottom_Line = (int)NTSC_LastLineNumeric.Value; pce.PutSettings(s); 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; + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISettable.cs index 00f27089c4..122935eb76 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISettable.cs @@ -31,6 +31,9 @@ namespace BizHawk.Emulation.Cores.PCEngine } Settings = o; + + CoreComm.ScreenLogicalOffsetY = Settings.Top_Line; + return ret; } @@ -41,7 +44,7 @@ namespace BizHawk.Emulation.Cores.PCEngine return ret; } - internal PCESettings Settings; + public PCESettings Settings; private PCESyncSettings _syncSettings; public class PCESettings @@ -51,6 +54,10 @@ namespace BizHawk.Emulation.Cores.PCEngine public bool ShowBG2 = true; public bool ShowOBJ2 = true; + // cropping settings + public int Top_Line = 18; + public int Bottom_Line = 252; + // these three require core reboot to use public bool SpriteLimit = false; public bool EqualizeVolume = false; diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs index 72006fe392..0ddbd0030a 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs @@ -36,9 +36,6 @@ namespace BizHawk.Emulation.Cores.PCEngine int ActiveDisplayStartLine = DisplayStartLine; - Console.WriteLine(ActiveDisplayStartLine + Registers[VDW] + 1); - Console.WriteLine(Registers[5]); - while (true) { int VBlankLine = ActiveDisplayStartLine + Registers[VDW] + 1; @@ -110,7 +107,8 @@ namespace BizHawk.Emulation.Cores.PCEngine public void RenderScanLine() { - if ((ActiveLine + ViewStartLine) >= 262) + if (((ActiveLine + ViewStartLine) >= pce.Settings.Bottom_Line) || + ((ActiveLine + ViewStartLine) < pce.Settings.Top_Line)) return; RenderBackgroundScanline(pce.Settings.ShowBG1); @@ -128,7 +126,7 @@ namespace BizHawk.Emulation.Cores.PCEngine int p = vce.Palette[256]; 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++) *dst++ = p; } @@ -152,7 +150,7 @@ namespace BizHawk.Emulation.Cores.PCEngine { // pointer to the BAT and the framebuffer for this line 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 ushort BatEnt; @@ -206,7 +204,7 @@ namespace BizHawk.Emulation.Cores.PCEngine if (BackgroundEnabled == false) { 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; } @@ -230,10 +228,10 @@ namespace BizHawk.Emulation.Cores.PCEngine byte c = PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs]; if (c == 0) - FrameBuffer[((ActiveLine + ViewStartLine) * FramePitch) + x] = vce.Palette[0]; + FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + x] = vce.Palette[0]; 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; } } @@ -365,7 +363,7 @@ namespace BizHawk.Emulation.Cores.PCEngine { InterSpritePriorityBuffer[xs] = 1; 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; 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; 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) @@ -419,7 +417,7 @@ namespace BizHawk.Emulation.Cores.PCEngine { InterSpritePriorityBuffer[xs] = 1; 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 VirtualHeight => FrameHeight; + public int VirtualHeight => BufferHeight; 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 VsyncNumerator diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs index f3057cc169..82edefaecf 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs @@ -239,11 +239,9 @@ namespace BizHawk.Emulation.Cores.PCEngine private void RenderScanLine() { - //if (VDC1.ActiveLine >= FrameHeight) - if ((VDC1.ActiveLine + VDC1.ViewStartLine) >= 262) - return; - - InitializeScanLine(VDC1.ActiveLine); + if (((VDC1.ActiveLine + VDC1.ViewStartLine) >= PCE.Settings.Bottom_Line) || + ((VDC1.ActiveLine + VDC1.ViewStartLine) < PCE.Settings.Top_Line)) + InitializeScanLine(VDC1.ActiveLine); switch (EffectivePriorityMode) { @@ -292,7 +290,7 @@ namespace BizHawk.Emulation.Cores.PCEngine { // pointer to the BAT and the framebuffer for this line 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 ushort BatEnt; @@ -448,7 +446,7 @@ namespace BizHawk.Emulation.Cores.PCEngine byte myPriority = priority ? highPriority : lowPriority; 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; } } @@ -467,7 +465,7 @@ namespace BizHawk.Emulation.Cores.PCEngine byte myPriority = priority ? highPriority : lowPriority; 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; } } @@ -489,7 +487,7 @@ namespace BizHawk.Emulation.Cores.PCEngine byte myPriority = priority ? highPriority : lowPriority; 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; } } @@ -507,7 +505,7 @@ namespace BizHawk.Emulation.Cores.PCEngine byte myPriority = priority ? highPriority : lowPriority; 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; } }