From d6bc37726c5dbe95354b784a0ab7e18b11ee9626 Mon Sep 17 00:00:00 2001 From: Souryo Date: Wed, 6 Jan 2016 20:34:45 -0500 Subject: [PATCH] Video options - Vertical sync, Aspect Ratio + GUI --- Core/EmulationSettings.h | 6 +- GUI.NET/Config/VideoInfo.cs | 15 +- .../Forms/Config/frmVideoConfig.Designer.cs | 351 +++++++++++++----- GUI.NET/Forms/Config/frmVideoConfig.cs | 7 + GUI.NET/Forms/frmMain.Designer.cs | 7 +- GUI.NET/Forms/frmMain.cs | 17 +- GUI.NET/InteropEmu.cs | 15 +- InteropDLL/ConsoleWrapper.cpp | 4 +- Windows/Renderer.cpp | 3 +- 9 files changed, 327 insertions(+), 98 deletions(-) diff --git a/Core/EmulationSettings.h b/Core/EmulationSettings.h index 00e53063..f50ac8d1 100644 --- a/Core/EmulationSettings.h +++ b/Core/EmulationSettings.h @@ -7,6 +7,7 @@ enum EmulationFlags { Paused = 0x01, ShowFPS = 0x02, + VerticalSync = 0x04, }; enum class AudioChannel @@ -59,6 +60,7 @@ class EmulationSettings { private: static uint32_t _flags; + static bool _audioEnabled; static uint32_t _audioLatency; static double _channelVolume[5]; @@ -72,12 +74,12 @@ private: static uint32_t _videoScale; public: - static void SetFlags(uint32_t flags) + static void SetFlags(EmulationFlags flags) { _flags |= flags; } - static void ClearFlags(uint32_t flags) + static void ClearFlags(EmulationFlags flags) { _flags &= ~flags; } diff --git a/GUI.NET/Config/VideoInfo.cs b/GUI.NET/Config/VideoInfo.cs index 8b230ea7..b98f1f52 100644 --- a/GUI.NET/Config/VideoInfo.cs +++ b/GUI.NET/Config/VideoInfo.cs @@ -19,6 +19,9 @@ namespace Mesen.GUI.Config public UInt32 OverscanBottom = 8; public UInt32 VideoScale = 2; public VideoFilterType VideoFilter = VideoFilterType.None; + public VideoAspectRatio AspectRatio = VideoAspectRatio.Auto; + public bool VerticalSync = true; + public bool FullscreenMode = false; public VideoInfo() { @@ -30,10 +33,16 @@ namespace Mesen.GUI.Config InteropEmu.SetEmulationSpeed(videoInfo.EmulationSpeed); - if(ConfigManager.Config.VideoInfo.ShowFPS) { - InteropEmu.SetFlags((UInt32)EmulationFlags.ShowFPS); + if(videoInfo.ShowFPS) { + InteropEmu.SetFlags(EmulationFlags.ShowFPS); } else { - InteropEmu.ClearFlags((UInt32)EmulationFlags.ShowFPS); + InteropEmu.ClearFlags(EmulationFlags.ShowFPS); + } + + if(videoInfo.VerticalSync) { + InteropEmu.SetFlags(EmulationFlags.VerticalSync); + } else { + InteropEmu.ClearFlags(EmulationFlags.VerticalSync); } InteropEmu.SetOverscanDimensions(videoInfo.OverscanLeft, videoInfo.OverscanRight, videoInfo.OverscanTop, videoInfo.OverscanBottom); diff --git a/GUI.NET/Forms/Config/frmVideoConfig.Designer.cs b/GUI.NET/Forms/Config/frmVideoConfig.Designer.cs index fca8c289..e1050f77 100644 --- a/GUI.NET/Forms/Config/frmVideoConfig.Designer.cs +++ b/GUI.NET/Forms/Config/frmVideoConfig.Designer.cs @@ -28,6 +28,18 @@ private void InitializeComponent() { this.tlpMain = new System.Windows.Forms.TableLayoutPanel(); + this.chkShowFps = new System.Windows.Forms.CheckBox(); + this.flowLayoutPanel6 = new System.Windows.Forms.FlowLayoutPanel(); + this.lblEmulationSpeed = new System.Windows.Forms.Label(); + this.nudEmulationSpeed = new System.Windows.Forms.NumericUpDown(); + this.lblEmuSpeedHint = new System.Windows.Forms.Label(); + this.lblVideoScale = new System.Windows.Forms.Label(); + this.lblVideoFilter = new System.Windows.Forms.Label(); + this.cboScale = new System.Windows.Forms.ComboBox(); + this.cboFilter = new System.Windows.Forms.ComboBox(); + this.tabMain = new System.Windows.Forms.TabControl(); + this.tpgGeneral = new System.Windows.Forms.TabPage(); + this.tpgOverscan = new System.Windows.Forms.TabPage(); this.grpCropping = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.picOverscan = new System.Windows.Forms.PictureBox(); @@ -43,12 +55,17 @@ this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel(); this.lblRight = new System.Windows.Forms.Label(); this.nudOverscanRight = new System.Windows.Forms.NumericUpDown(); - this.chkShowFps = new System.Windows.Forms.CheckBox(); - this.flowLayoutPanel6 = new System.Windows.Forms.FlowLayoutPanel(); - this.lblEmulationSpeed = new System.Windows.Forms.Label(); - this.nudEmulationSpeed = new System.Windows.Forms.NumericUpDown(); - this.lblEmuSpeedHint = new System.Windows.Forms.Label(); + this.chkVerticalSync = new System.Windows.Forms.CheckBox(); + this.cboAspectRatio = new System.Windows.Forms.ComboBox(); + this.lblDisplayRatio = new System.Windows.Forms.Label(); + this.tpgPalette = new System.Windows.Forms.TabPage(); + this.chkFullscreenMode = new System.Windows.Forms.CheckBox(); this.tlpMain.SuspendLayout(); + this.flowLayoutPanel6.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudEmulationSpeed)).BeginInit(); + this.tabMain.SuspendLayout(); + this.tpgGeneral.SuspendLayout(); + this.tpgOverscan.SuspendLayout(); this.grpCropping.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picOverscan)).BeginInit(); @@ -60,8 +77,6 @@ ((System.ComponentModel.ISupportInitialize)(this.nudOverscanBottom)).BeginInit(); this.flowLayoutPanel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudOverscanRight)).BeginInit(); - this.flowLayoutPanel6.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nudEmulationSpeed)).BeginInit(); this.SuspendLayout(); // // baseConfigPanel @@ -71,29 +86,180 @@ // // tlpMain // - this.tlpMain.ColumnCount = 1; + this.tlpMain.ColumnCount = 2; this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tlpMain.Controls.Add(this.grpCropping, 0, 2); - this.tlpMain.Controls.Add(this.chkShowFps, 0, 1); - this.tlpMain.Controls.Add(this.flowLayoutPanel6, 0, 0); + this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tlpMain.Controls.Add(this.chkFullscreenMode, 0, 4); + this.tlpMain.Controls.Add(this.lblVideoScale, 0, 0); + this.tlpMain.Controls.Add(this.lblVideoFilter, 0, 1); + this.tlpMain.Controls.Add(this.cboScale, 1, 0); + this.tlpMain.Controls.Add(this.cboFilter, 1, 1); + this.tlpMain.Controls.Add(this.chkVerticalSync, 0, 3); + this.tlpMain.Controls.Add(this.cboAspectRatio, 1, 2); + this.tlpMain.Controls.Add(this.lblDisplayRatio, 0, 2); + this.tlpMain.Controls.Add(this.flowLayoutPanel6, 1, 6); + this.tlpMain.Controls.Add(this.lblEmulationSpeed, 0, 6); + this.tlpMain.Controls.Add(this.chkShowFps, 0, 5); this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill; - this.tlpMain.Location = new System.Drawing.Point(0, 0); + this.tlpMain.Location = new System.Drawing.Point(3, 3); + this.tlpMain.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0); this.tlpMain.Name = "tlpMain"; - this.tlpMain.RowCount = 3; + this.tlpMain.RowCount = 8; this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tlpMain.Size = new System.Drawing.Size(362, 308); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.Size = new System.Drawing.Size(348, 276); this.tlpMain.TabIndex = 1; // + // chkShowFps + // + this.chkShowFps.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.chkShowFps.AutoSize = true; + this.tlpMain.SetColumnSpan(this.chkShowFps, 2); + this.chkShowFps.Location = new System.Drawing.Point(3, 130); + this.chkShowFps.Name = "chkShowFps"; + this.chkShowFps.Size = new System.Drawing.Size(76, 17); + this.chkShowFps.TabIndex = 9; + this.chkShowFps.Text = "Show FPS"; + this.chkShowFps.UseVisualStyleBackColor = true; + // + // flowLayoutPanel6 + // + this.flowLayoutPanel6.AutoSize = true; + this.flowLayoutPanel6.Controls.Add(this.nudEmulationSpeed); + this.flowLayoutPanel6.Controls.Add(this.lblEmuSpeedHint); + this.flowLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel6.Location = new System.Drawing.Point(96, 150); + this.flowLayoutPanel6.Margin = new System.Windows.Forms.Padding(0); + this.flowLayoutPanel6.Name = "flowLayoutPanel6"; + this.flowLayoutPanel6.Size = new System.Drawing.Size(252, 26); + this.flowLayoutPanel6.TabIndex = 10; + // + // lblEmulationSpeed + // + this.lblEmulationSpeed.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblEmulationSpeed.AutoSize = true; + this.lblEmulationSpeed.Location = new System.Drawing.Point(3, 156); + this.lblEmulationSpeed.Name = "lblEmulationSpeed"; + this.lblEmulationSpeed.Size = new System.Drawing.Size(90, 13); + this.lblEmulationSpeed.TabIndex = 0; + this.lblEmulationSpeed.Text = "Emulation Speed:"; + // + // nudEmulationSpeed + // + this.nudEmulationSpeed.Location = new System.Drawing.Point(3, 3); + this.nudEmulationSpeed.Maximum = new decimal(new int[] { + 500, + 0, + 0, + 0}); + this.nudEmulationSpeed.Name = "nudEmulationSpeed"; + this.nudEmulationSpeed.Size = new System.Drawing.Size(48, 20); + this.nudEmulationSpeed.TabIndex = 1; + // + // lblEmuSpeedHint + // + this.lblEmuSpeedHint.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblEmuSpeedHint.AutoSize = true; + this.lblEmuSpeedHint.Location = new System.Drawing.Point(57, 6); + this.lblEmuSpeedHint.Name = "lblEmuSpeedHint"; + this.lblEmuSpeedHint.Size = new System.Drawing.Size(107, 13); + this.lblEmuSpeedHint.TabIndex = 2; + this.lblEmuSpeedHint.Text = "(0 = Maximum speed)"; + // + // lblVideoScale + // + this.lblVideoScale.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblVideoScale.AutoSize = true; + this.lblVideoScale.Location = new System.Drawing.Point(3, 7); + this.lblVideoScale.Name = "lblVideoScale"; + this.lblVideoScale.Size = new System.Drawing.Size(37, 13); + this.lblVideoScale.TabIndex = 11; + this.lblVideoScale.Text = "Scale:"; + // + // lblVideoFilter + // + this.lblVideoFilter.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblVideoFilter.AutoSize = true; + this.lblVideoFilter.Location = new System.Drawing.Point(3, 34); + this.lblVideoFilter.Name = "lblVideoFilter"; + this.lblVideoFilter.Size = new System.Drawing.Size(32, 13); + this.lblVideoFilter.TabIndex = 12; + this.lblVideoFilter.Text = "Filter:"; + // + // cboScale + // + this.cboScale.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboScale.FormattingEnabled = true; + this.cboScale.Items.AddRange(new object[] { + "1x", + "2x", + "3x", + "4x"}); + this.cboScale.Location = new System.Drawing.Point(99, 3); + this.cboScale.Name = "cboScale"; + this.cboScale.Size = new System.Drawing.Size(48, 21); + this.cboScale.TabIndex = 13; + // + // cboFilter + // + this.cboFilter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboFilter.FormattingEnabled = true; + this.cboFilter.Items.AddRange(new object[] { + "None", + "NTSC"}); + this.cboFilter.Location = new System.Drawing.Point(99, 30); + this.cboFilter.Name = "cboFilter"; + this.cboFilter.Size = new System.Drawing.Size(76, 21); + this.cboFilter.TabIndex = 14; + // + // tabMain + // + this.tabMain.Controls.Add(this.tpgGeneral); + this.tabMain.Controls.Add(this.tpgOverscan); + this.tabMain.Controls.Add(this.tpgPalette); + this.tabMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabMain.Location = new System.Drawing.Point(0, 0); + this.tabMain.Name = "tabMain"; + this.tabMain.SelectedIndex = 0; + this.tabMain.Size = new System.Drawing.Size(362, 308); + this.tabMain.TabIndex = 2; + // + // tpgGeneral + // + this.tpgGeneral.Controls.Add(this.tlpMain); + this.tpgGeneral.Location = new System.Drawing.Point(4, 22); + this.tpgGeneral.Name = "tpgGeneral"; + this.tpgGeneral.Padding = new System.Windows.Forms.Padding(3); + this.tpgGeneral.Size = new System.Drawing.Size(354, 282); + this.tpgGeneral.TabIndex = 0; + this.tpgGeneral.Text = "General"; + this.tpgGeneral.UseVisualStyleBackColor = true; + // + // tpgOverscan + // + this.tpgOverscan.Controls.Add(this.grpCropping); + this.tpgOverscan.Location = new System.Drawing.Point(4, 22); + this.tpgOverscan.Name = "tpgOverscan"; + this.tpgOverscan.Padding = new System.Windows.Forms.Padding(3); + this.tpgOverscan.Size = new System.Drawing.Size(354, 282); + this.tpgOverscan.TabIndex = 1; + this.tpgOverscan.Text = "Overscan"; + this.tpgOverscan.UseVisualStyleBackColor = true; + // // grpCropping // this.grpCropping.Controls.Add(this.tableLayoutPanel1); this.grpCropping.Dock = System.Windows.Forms.DockStyle.Fill; - this.grpCropping.Location = new System.Drawing.Point(3, 52); + this.grpCropping.Location = new System.Drawing.Point(3, 3); this.grpCropping.Name = "grpCropping"; - this.grpCropping.Size = new System.Drawing.Size(356, 253); - this.grpCropping.TabIndex = 7; + this.grpCropping.Size = new System.Drawing.Size(348, 276); + this.grpCropping.TabIndex = 8; this.grpCropping.TabStop = false; this.grpCropping.Text = "Video Cropping"; // @@ -246,74 +412,84 @@ this.nudOverscanRight.Size = new System.Drawing.Size(50, 20); this.nudOverscanRight.TabIndex = 1; // - // chkShowFps + // chkVerticalSync // - this.chkShowFps.AutoSize = true; - this.chkShowFps.Location = new System.Drawing.Point(3, 29); - this.chkShowFps.Name = "chkShowFps"; - this.chkShowFps.Size = new System.Drawing.Size(76, 17); - this.chkShowFps.TabIndex = 9; - this.chkShowFps.Text = "Show FPS"; - this.chkShowFps.UseVisualStyleBackColor = true; + this.chkVerticalSync.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.chkVerticalSync.AutoSize = true; + this.tlpMain.SetColumnSpan(this.chkVerticalSync, 2); + this.chkVerticalSync.Location = new System.Drawing.Point(3, 84); + this.chkVerticalSync.Name = "chkVerticalSync"; + this.chkVerticalSync.Size = new System.Drawing.Size(121, 17); + this.chkVerticalSync.TabIndex = 15; + this.chkVerticalSync.Text = "Enable vertical sync"; + this.chkVerticalSync.UseVisualStyleBackColor = true; // - // flowLayoutPanel6 + // cboAspectRatio // - this.flowLayoutPanel6.AutoSize = true; - this.flowLayoutPanel6.Controls.Add(this.lblEmulationSpeed); - this.flowLayoutPanel6.Controls.Add(this.nudEmulationSpeed); - this.flowLayoutPanel6.Controls.Add(this.lblEmuSpeedHint); - this.flowLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill; - this.flowLayoutPanel6.Location = new System.Drawing.Point(0, 0); - this.flowLayoutPanel6.Margin = new System.Windows.Forms.Padding(0); - this.flowLayoutPanel6.Name = "flowLayoutPanel6"; - this.flowLayoutPanel6.Size = new System.Drawing.Size(362, 26); - this.flowLayoutPanel6.TabIndex = 10; + this.cboAspectRatio.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboAspectRatio.FormattingEnabled = true; + this.cboAspectRatio.Items.AddRange(new object[] { + "Auto", + "NTSC (8:7)", + "PAL (18:13)", + "Standard (4:3)", + "Widescreen (16:9)"}); + this.cboAspectRatio.Location = new System.Drawing.Point(99, 57); + this.cboAspectRatio.Name = "cboAspectRatio"; + this.cboAspectRatio.Size = new System.Drawing.Size(121, 21); + this.cboAspectRatio.TabIndex = 16; // - // lblEmulationSpeed + // lblDisplayRatio // - this.lblEmulationSpeed.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.lblEmulationSpeed.AutoSize = true; - this.lblEmulationSpeed.Location = new System.Drawing.Point(3, 6); - this.lblEmulationSpeed.Name = "lblEmulationSpeed"; - this.lblEmulationSpeed.Size = new System.Drawing.Size(90, 13); - this.lblEmulationSpeed.TabIndex = 0; - this.lblEmulationSpeed.Text = "Emulation Speed:"; + this.lblDisplayRatio.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblDisplayRatio.AutoSize = true; + this.lblDisplayRatio.Location = new System.Drawing.Point(3, 61); + this.lblDisplayRatio.Name = "lblDisplayRatio"; + this.lblDisplayRatio.Size = new System.Drawing.Size(71, 13); + this.lblDisplayRatio.TabIndex = 17; + this.lblDisplayRatio.Text = "Aspect Ratio:"; // - // nudEmulationSpeed + // tpgPalette // - this.nudEmulationSpeed.Location = new System.Drawing.Point(99, 3); - this.nudEmulationSpeed.Maximum = new decimal(new int[] { - 500, - 0, - 0, - 0}); - this.nudEmulationSpeed.Name = "nudEmulationSpeed"; - this.nudEmulationSpeed.Size = new System.Drawing.Size(48, 20); - this.nudEmulationSpeed.TabIndex = 1; + this.tpgPalette.Location = new System.Drawing.Point(4, 22); + this.tpgPalette.Name = "tpgPalette"; + this.tpgPalette.Padding = new System.Windows.Forms.Padding(3); + this.tpgPalette.Size = new System.Drawing.Size(354, 282); + this.tpgPalette.TabIndex = 2; + this.tpgPalette.Text = "Palette"; + this.tpgPalette.UseVisualStyleBackColor = true; // - // lblEmuSpeedHint + // chkFullscreenMode // - this.lblEmuSpeedHint.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.lblEmuSpeedHint.AutoSize = true; - this.lblEmuSpeedHint.Location = new System.Drawing.Point(153, 6); - this.lblEmuSpeedHint.Name = "lblEmuSpeedHint"; - this.lblEmuSpeedHint.Size = new System.Drawing.Size(107, 13); - this.lblEmuSpeedHint.TabIndex = 2; - this.lblEmuSpeedHint.Text = "(0 = Maximum speed)"; + this.chkFullscreenMode.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.chkFullscreenMode.AutoSize = true; + this.tlpMain.SetColumnSpan(this.chkFullscreenMode, 2); + this.chkFullscreenMode.Location = new System.Drawing.Point(3, 107); + this.chkFullscreenMode.Name = "chkFullscreenMode"; + this.chkFullscreenMode.Size = new System.Drawing.Size(113, 17); + this.chkFullscreenMode.TabIndex = 18; + this.chkFullscreenMode.Text = "Fullscreen window"; + this.chkFullscreenMode.UseVisualStyleBackColor = true; // // frmVideoConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(362, 337); - this.Controls.Add(this.tlpMain); + this.Controls.Add(this.tabMain); this.Name = "frmVideoConfig"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Video Options"; this.Controls.SetChildIndex(this.baseConfigPanel, 0); - this.Controls.SetChildIndex(this.tlpMain, 0); + this.Controls.SetChildIndex(this.tabMain, 0); this.tlpMain.ResumeLayout(false); this.tlpMain.PerformLayout(); + this.flowLayoutPanel6.ResumeLayout(false); + this.flowLayoutPanel6.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudEmulationSpeed)).EndInit(); + this.tabMain.ResumeLayout(false); + this.tpgGeneral.ResumeLayout(false); + this.tpgOverscan.ResumeLayout(false); this.grpCropping.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.picOverscan)).EndInit(); @@ -329,9 +505,6 @@ this.flowLayoutPanel2.ResumeLayout(false); this.flowLayoutPanel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudOverscanRight)).EndInit(); - this.flowLayoutPanel6.ResumeLayout(false); - this.flowLayoutPanel6.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nudEmulationSpeed)).EndInit(); this.ResumeLayout(false); } @@ -339,25 +512,37 @@ #endregion private System.Windows.Forms.TableLayoutPanel tlpMain; - private System.Windows.Forms.GroupBox grpCropping; private System.Windows.Forms.CheckBox chkShowFps; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel3; - private System.Windows.Forms.Label lblLeft; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel4; - private System.Windows.Forms.Label lblTop; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel5; - private System.Windows.Forms.Label lblBottom; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2; - private System.Windows.Forms.Label lblRight; - private System.Windows.Forms.PictureBox picOverscan; - private System.Windows.Forms.NumericUpDown nudOverscanLeft; - private System.Windows.Forms.NumericUpDown nudOverscanTop; - private System.Windows.Forms.NumericUpDown nudOverscanBottom; - private System.Windows.Forms.NumericUpDown nudOverscanRight; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel6; private System.Windows.Forms.Label lblEmulationSpeed; private System.Windows.Forms.NumericUpDown nudEmulationSpeed; private System.Windows.Forms.Label lblEmuSpeedHint; + private System.Windows.Forms.Label lblVideoScale; + private System.Windows.Forms.Label lblVideoFilter; + private System.Windows.Forms.ComboBox cboScale; + private System.Windows.Forms.ComboBox cboFilter; + private System.Windows.Forms.CheckBox chkVerticalSync; + private System.Windows.Forms.ComboBox cboAspectRatio; + private System.Windows.Forms.Label lblDisplayRatio; + private System.Windows.Forms.TabControl tabMain; + private System.Windows.Forms.TabPage tpgGeneral; + private System.Windows.Forms.TabPage tpgOverscan; + private System.Windows.Forms.GroupBox grpCropping; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.PictureBox picOverscan; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel3; + private System.Windows.Forms.Label lblLeft; + private System.Windows.Forms.NumericUpDown nudOverscanLeft; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel4; + private System.Windows.Forms.Label lblTop; + private System.Windows.Forms.NumericUpDown nudOverscanTop; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel5; + private System.Windows.Forms.Label lblBottom; + private System.Windows.Forms.NumericUpDown nudOverscanBottom; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2; + private System.Windows.Forms.Label lblRight; + private System.Windows.Forms.NumericUpDown nudOverscanRight; + private System.Windows.Forms.CheckBox chkFullscreenMode; + private System.Windows.Forms.TabPage tpgPalette; } } \ No newline at end of file diff --git a/GUI.NET/Forms/Config/frmVideoConfig.cs b/GUI.NET/Forms/Config/frmVideoConfig.cs index f517f105..6e9dfbbb 100644 --- a/GUI.NET/Forms/Config/frmVideoConfig.cs +++ b/GUI.NET/Forms/Config/frmVideoConfig.cs @@ -21,6 +21,13 @@ namespace Mesen.GUI.Forms.Config AddBinding("EmulationSpeed", nudEmulationSpeed); AddBinding("ShowFPS", chkShowFps); + AddBinding("VerticalSync", chkVerticalSync); + AddBinding("FullscreenMode", chkFullscreenMode); + + AddBinding("VideoScale", cboScale); + AddBinding("AspectRatio", cboAspectRatio); + AddBinding("VideoFilter", cboFilter); + AddBinding("OverscanLeft", nudOverscanLeft); AddBinding("OverscanRight", nudOverscanRight); AddBinding("OverscanTop", nudOverscanTop); diff --git a/GUI.NET/Forms/frmMain.Designer.cs b/GUI.NET/Forms/frmMain.Designer.cs index 2795e115..922d98df 100644 --- a/GUI.NET/Forms/frmMain.Designer.cs +++ b/GUI.NET/Forms/frmMain.Designer.cs @@ -393,14 +393,14 @@ // mnuNoneFilter // this.mnuNoneFilter.Name = "mnuNoneFilter"; - this.mnuNoneFilter.Size = new System.Drawing.Size(152, 22); + this.mnuNoneFilter.Size = new System.Drawing.Size(104, 22); this.mnuNoneFilter.Text = "None"; this.mnuNoneFilter.Click += new System.EventHandler(this.mnuNoneFilter_Click); // // mnuNtscFilter // this.mnuNtscFilter.Name = "mnuNtscFilter"; - this.mnuNtscFilter.Size = new System.Drawing.Size(152, 22); + this.mnuNtscFilter.Size = new System.Drawing.Size(104, 22); this.mnuNtscFilter.Text = "NTSC"; this.mnuNtscFilter.Click += new System.EventHandler(this.mnuNtscFilter_Click); // @@ -743,7 +743,7 @@ this.dxViewer.Location = new System.Drawing.Point(0, 24); this.dxViewer.Margin = new System.Windows.Forms.Padding(0); this.dxViewer.Name = "dxViewer"; - this.dxViewer.Size = new System.Drawing.Size(1024, 960); + this.dxViewer.Size = new System.Drawing.Size(263, 176); this.dxViewer.TabIndex = 1; // // frmMain @@ -752,6 +752,7 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.BackColor = System.Drawing.Color.Black; this.ClientSize = new System.Drawing.Size(365, 272); this.Controls.Add(this.dxViewer); this.Controls.Add(this.menuStrip); diff --git a/GUI.NET/Forms/frmMain.cs b/GUI.NET/Forms/frmMain.cs index 53431e24..0ea7a6ed 100644 --- a/GUI.NET/Forms/frmMain.cs +++ b/GUI.NET/Forms/frmMain.cs @@ -174,6 +174,20 @@ namespace Mesen.GUI.Forms UpdateEmulationSpeedMenu(); UpdateScaleMenu(ConfigManager.Config.VideoInfo.VideoScale); UpdateFilterMenu(ConfigManager.Config.VideoInfo.VideoFilter); + + UpdateViewerSize(); + } + + private void UpdateViewerSize() + { + InteropEmu.ScreenSize size = InteropEmu.GetScreenSize(); + switch(ConfigManager.Config.VideoInfo.AspectRatio) { + case VideoAspectRatio.NTSC: size.Width = (int)(size.Height * 8 / 7.0); break; + case VideoAspectRatio.PAL: size.Width = (int)(size.Height * 18 / 13.0); break; + case VideoAspectRatio.Standard: size.Width = (int)(size.Height * 4 / 3.0); break; + case VideoAspectRatio.Widescreen: size.Width = (int)(size.Height * 16 / 9.0); break; + } + dxViewer.Size = new Size(size.Width, size.Height); } private void Application_ThreadException(object sender, ThreadExceptionEventArgs e) @@ -192,8 +206,7 @@ namespace Mesen.GUI.Forms CheatInfo.ClearCheats(); } else if(e.NotificationType == InteropEmu.ConsoleNotificationType.ResolutionChanged) { this.BeginInvoke((MethodInvoker)(() => { - InteropEmu.ScreenSize size = InteropEmu.GetScreenSize(); - dxViewer.Size = new Size(size.Width, size.Height); + UpdateVideoSettings(); })); } UpdateMenus(); diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index 999d2c13..51074105 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -68,8 +68,8 @@ namespace Mesen.GUI [DllImport(DLLPath)] public static extern void CheatAddProActionRocky(UInt32 code); [DllImport(DLLPath)] public static extern void CheatClear(); - [DllImport(DLLPath)] public static extern void SetFlags(UInt32 flags); - [DllImport(DLLPath)] public static extern void ClearFlags(UInt32 flags); + [DllImport(DLLPath)] public static extern void SetFlags(EmulationFlags flags); + [DllImport(DLLPath)] public static extern void ClearFlags(EmulationFlags flags); [DllImport(DLLPath)] public static extern void SetChannelVolume(UInt32 channel, double volume); [DllImport(DLLPath)] public static extern void SetAudioLatency(UInt32 msLatency); [DllImport(DLLPath)] public static extern void SetNesModel(NesModel model); @@ -77,6 +77,7 @@ namespace Mesen.GUI [DllImport(DLLPath)] public static extern void SetOverscanDimensions(UInt32 left, UInt32 right, UInt32 top, UInt32 bottom); [DllImport(DLLPath)] public static extern void SetVideoScale(UInt32 scale); [DllImport(DLLPath)] public static extern void SetVideoFilter(VideoFilterType filter); + [DllImport(DLLPath, EntryPoint="GetScreenSize")] private static extern void GetScreenSizeWrapper(out ScreenSize size); [DllImport(DLLPath)] public static extern void DebugInitialize(); @@ -410,6 +411,7 @@ namespace Mesen.GUI { Paused = 0x01, ShowFPS = 0x02, + VerticalSync = 0x04, } public enum BreakpointType @@ -432,6 +434,15 @@ namespace Mesen.GUI NTSC = 1, } + public enum VideoAspectRatio + { + Auto = 0, + NTSC = 1, + PAL = 2, + Standard = 3, + Widescreen = 4 + } + public enum DebugMemoryType { CpuMemory = 0, diff --git a/InteropDLL/ConsoleWrapper.cpp b/InteropDLL/ConsoleWrapper.cpp index 296f7805..66e47371 100644 --- a/InteropDLL/ConsoleWrapper.cpp +++ b/InteropDLL/ConsoleWrapper.cpp @@ -201,8 +201,8 @@ namespace InteropEmu { DllExport void __stdcall CheatAddProActionRocky(uint32_t code) { CheatManager::AddProActionRockyCode(code); } DllExport void __stdcall CheatClear() { CheatManager::ClearCodes(); } - DllExport void __stdcall SetFlags(uint32_t flags) { EmulationSettings::SetFlags(flags); } - DllExport void __stdcall ClearFlags(uint32_t flags) { EmulationSettings::ClearFlags(flags); } + DllExport void __stdcall SetFlags(EmulationFlags flags) { EmulationSettings::SetFlags(flags); } + DllExport void __stdcall ClearFlags(EmulationFlags flags) { EmulationSettings::ClearFlags(flags); } DllExport void __stdcall SetChannelVolume(uint32_t channel, double volume) { EmulationSettings::SetChannelVolume((AudioChannel)channel, volume); } DllExport void __stdcall SetAudioLatency(uint32_t msLatency) { EmulationSettings::SetAudioLatency(msLatency); } DllExport void __stdcall SetNesModel(uint32_t model) { EmulationSettings::SetNesModel((NesModel)model); } diff --git a/Windows/Renderer.cpp b/Windows/Renderer.cpp index 8c1b5486..32c0234e 100644 --- a/Windows/Renderer.cpp +++ b/Windows/Renderer.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#include #include "Renderer.h" #include "DirectXTK/SpriteBatch.h" #include "DirectXTK/SpriteFont.h" @@ -476,7 +477,7 @@ namespace NES _spriteBatch->End(); // Present the information rendered to the back buffer to the front buffer (the screen) - _pSwapChain->Present(0, 0); + _pSwapChain->Present(EmulationSettings::CheckFlag(EmulationFlags::VerticalSync) ? 1 : 0, 0); _frameLock.Release(); }