Video: Option to set a custom aspect ratio

This commit is contained in:
Souryo 2017-02-18 13:41:16 -05:00
parent 0a6a21e443
commit d6db1d50c5
14 changed files with 111 additions and 21 deletions

View file

@ -56,6 +56,7 @@ VideoFilterType EmulationSettings::_videoFilterType = VideoFilterType::None;
VideoResizeFilter EmulationSettings::_resizeFilter = VideoResizeFilter::NearestNeighbor;
double EmulationSettings::_videoScale = 1;
VideoAspectRatio EmulationSettings::_aspectRatio = VideoAspectRatio::Auto;
double EmulationSettings::_customAspectRatio = 1.0;
PictureSettings EmulationSettings::_pictureSettings;
NtscFilterSettings EmulationSettings::_ntscFilterSettings;
bool EmulationSettings::_backgroundEnabled = true;

View file

@ -113,7 +113,8 @@ enum class VideoAspectRatio
NTSC = 1,
PAL = 2,
Standard = 3,
Widescreen = 4
Widescreen = 4,
Custom = 5
};
struct OverscanDimensions
@ -338,6 +339,7 @@ private:
static VideoFilterType _videoFilterType;
static double _videoScale;
static VideoAspectRatio _aspectRatio;
static double _customAspectRatio;
static VideoResizeFilter _resizeFilter;
static PictureSettings _pictureSettings;
static NtscFilterSettings _ntscFilterSettings;
@ -693,16 +695,10 @@ public:
return _resizeFilter;
}
static void SetVideoAspectRatio(VideoAspectRatio aspectRatio)
static void SetVideoAspectRatio(VideoAspectRatio aspectRatio, double customRatio)
{
if(_aspectRatio != aspectRatio) {
_aspectRatio = aspectRatio;
}
}
static VideoAspectRatio GetVideoAspectRatio()
{
return _aspectRatio;
_aspectRatio = aspectRatio;
_customAspectRatio = customRatio;
}
static bool GetBackgroundEnabled()
@ -757,6 +753,7 @@ public:
case VideoAspectRatio::PAL: return 18.0 / 13.0;
case VideoAspectRatio::Standard: return 4.0 / 3.0;
case VideoAspectRatio::Widescreen: return 16.0 / 9.0;
case VideoAspectRatio::Custom: return _customAspectRatio;
}
return 0.0;
}

View file

@ -20,6 +20,7 @@ namespace Mesen.GUI.Config
public VideoFilterType VideoFilter = VideoFilterType.None;
public bool UseBilinearInterpolation = false;
public VideoAspectRatio AspectRatio = VideoAspectRatio.Auto;
public double CustomAspectRatio = 1.0;
public bool VerticalSync = false;
public bool UseHdPacks = false;
public string PaletteData;
@ -71,7 +72,7 @@ namespace Mesen.GUI.Config
InteropEmu.SetVideoFilter(videoInfo.VideoFilter);
InteropEmu.SetVideoResizeFilter(videoInfo.UseBilinearInterpolation ? VideoResizeFilter.Bilinear : VideoResizeFilter.NearestNeighbor);
InteropEmu.SetVideoScale(videoInfo.VideoScale);
InteropEmu.SetVideoAspectRatio(videoInfo.AspectRatio);
InteropEmu.SetVideoAspectRatio(videoInfo.AspectRatio, videoInfo.CustomAspectRatio);
InteropEmu.SetPictureSettings(videoInfo.Brightness / 100.0, videoInfo.Contrast / 100.0, videoInfo.Saturation / 100.0, videoInfo.Hue / 100.0, videoInfo.ScanlineIntensity / 100.0);
InteropEmu.SetNtscFilterSettings(videoInfo.NtscArtifacts / 100.0, videoInfo.NtscBleed / 100.0, videoInfo.NtscFringing / 100.0, videoInfo.NtscGamma / 100.0, videoInfo.NtscResolution / 100.0, videoInfo.NtscSharpness / 100.0, videoInfo.NtscMergeFields, videoInfo.NtscYFilterLength / 100.0, videoInfo.NtscIFilterLength / 100.0, videoInfo.NtscQFilterLength / 100.0);

View file

@ -85,6 +85,7 @@
<Value ID="PAL">PAL (11:8)</Value>
<Value ID="Standard">Standard (4:3)</Value>
<Value ID="Widescreen">Widescreen (16:9)</Value>
<Value ID="Custom">Custom</Value>
</Enum>
<Enum ID="VideoFilterType">
<Value ID="None">None</Value>

View file

@ -223,6 +223,7 @@
<Control ID="lblVideoFilter">Filtro:</Control>
<Control ID="chkVerticalSync">Activar la sincronización vertical</Control>
<Control ID="lblDisplayRatio">Formato de imagen:</Control>
<Control ID="lblCustomRatio">Custom ratio:</Control>
<Control ID="chkBilinearInterpolation">Utilizar la interpolación Bilinear</Control>
<Control ID="chkShowFps">Mostrar FPS</Control>
<Control ID="chkUseHdPacks">Utilizar los packs de Alta Definición de HDNes</Control>
@ -574,6 +575,7 @@
<Value ID="PAL">PAL (11:8)</Value>
<Value ID="Standard">Estándar (4:3)</Value>
<Value ID="Widescreen">Pantalla panorámica (16:9)</Value>
<Value ID="Custom">Custom</Value>
</Enum>
<Enum ID="VideoFilterType">
<Value ID="None">Ninguno</Value>

View file

@ -224,6 +224,7 @@
<Control ID="lblVideoFilter">Filtre :</Control>
<Control ID="chkVerticalSync">Activer la synchronisation verticale</Control>
<Control ID="lblDisplayRatio">Format d'image :</Control>
<Control ID="lblCustomRatio">Ratio personalisé :</Control>
<Control ID="chkBilinearInterpolation">Utiliser l'interpolation bilinéaire</Control>
<Control ID="chkShowFps">Afficher le FPS</Control>
<Control ID="chkUseHdPacks">Utiliser les packs haute-définition de HDNes</Control>
@ -589,6 +590,7 @@
<Value ID="PAL">PAL (11:8)</Value>
<Value ID="Standard">Standard (4:3)</Value>
<Value ID="Widescreen">Écran large (16:9)</Value>
<Value ID="Custom">Personalisé</Value>
</Enum>
<Enum ID="VideoFilterType">
<Value ID="None">Aucun</Value>

View file

@ -225,6 +225,7 @@
<Control ID="chkBilinearInterpolation">バイリニア補間を有効にする</Control>
<Control ID="chkVerticalSync">垂直同期を有効にする</Control>
<Control ID="lblDisplayRatio">画面アスペクト:</Control>
<Control ID="lblCustomRatio">アスペクトレシオ:</Control>
<Control ID="chkShowFps">フレームレート表示</Control>
<Control ID="chkUseHdPacks">HDNesのHDパックを使う</Control>
<Control ID="tpgOverscan">オーバースキャン</Control>
@ -571,6 +572,7 @@
<Value ID="PAL">PAL (11:8)</Value>
<Value ID="Standard">ノーマル (4:3)</Value>
<Value ID="Widescreen">ワイド (16:9)</Value>
<Value ID="Custom">カスタム</Value>
</Enum>
<Enum ID="VideoFilterType">
<Value ID="None">なし</Value>

View file

@ -223,6 +223,7 @@
<Control ID="lblVideoFilter">Filtro:</Control>
<Control ID="chkVerticalSync">Ativar a sincronização vertical</Control>
<Control ID="lblDisplayRatio">Formato de imagem:</Control>
<Control ID="lblCustomRatio">Custom ratio:</Control>
<Control ID="chkBilinearInterpolation">Utilizar a interpolação Bilinear</Control>
<Control ID="chkShowFps">Mostrar FPS</Control>
<Control ID="chkUseHdPacks">Utilizar os packs de Alta Definição do HDNes</Control>
@ -574,6 +575,7 @@
<Value ID="PAL">PAL (11:8)</Value>
<Value ID="Standard">Padrão (4:3)</Value>
<Value ID="Widescreen">Widescreen (16:9)</Value>
<Value ID="Custom">Custom</Value>
</Enum>
<Enum ID="VideoFilterType">
<Value ID="None">Nenhum</Value>

View file

@ -224,6 +224,7 @@
<Control ID="lblVideoFilter">Фильтр :</Control>
<Control ID="chkVerticalSync">Включить вертикальную синхронизацию</Control>
<Control ID="lblDisplayRatio">Соотношение сторон :</Control>
<Control ID="lblCustomRatio">Custom ratio:</Control>
<Control ID="chkBilinearInterpolation">Билинейная интерполяция</Control>
<Control ID="chkShowFps">Показывать FPS</Control>
<Control ID="chkUseHdPacks">Использовать HDNes HD packs</Control>
@ -580,6 +581,7 @@
<Value ID="PAL">PAL (11:8)</Value>
<Value ID="Standard">Стандарт (4:3)</Value>
<Value ID="Widescreen">Широкий экран (16:9)</Value>
<Value ID="Custom">Custom</Value>
</Enum>
<Enum ID="VideoFilterType">
<Value ID="None">Отсутствует</Value>

View file

@ -224,6 +224,7 @@
<Control ID="lblVideoFilter">Фiльтр :</Control>
<Control ID="chkVerticalSync">Включити вертикальну синхронізацію</Control>
<Control ID="lblDisplayRatio">Співвідношення сторін :</Control>
<Control ID="lblCustomRatio">Custom ratio:</Control>
<Control ID="chkBilinearInterpolation">Білінійна інтерполяція</Control>
<Control ID="chkShowFps">Показувати FPS</Control>
<Control ID="chkUseHdPacks">Використовувати HDNes HD packs</Control>
@ -579,6 +580,7 @@
<Value ID="PAL">PAL (11:8)</Value>
<Value ID="Standard">Стандарт (4:3)</Value>
<Value ID="Widescreen">Широкий екран (16:9)</Value>
<Value ID="Custom">Custom</Value>
</Enum>
<Enum ID="VideoFilterType">
<Value ID="None">Відсутнє</Value>

View file

@ -115,6 +115,9 @@
this.mnuPaletteYuv = new System.Windows.Forms.ToolStripMenuItem();
this.mnuPaletteNestopiaRgb = new System.Windows.Forms.ToolStripMenuItem();
this.mnuPaletteSonyCxa2025As = new System.Windows.Forms.ToolStripMenuItem();
this.flowLayoutPanel6 = new System.Windows.Forms.FlowLayoutPanel();
this.lblCustomRatio = new System.Windows.Forms.Label();
this.nudCustomRatio = new System.Windows.Forms.NumericUpDown();
this.tlpMain.SuspendLayout();
this.flowLayoutPanel7.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picHdNesTooltip)).BeginInit();
@ -151,6 +154,8 @@
this.tableLayoutPanel9.SuspendLayout();
this.contextPicturePresets.SuspendLayout();
this.contextPaletteList.SuspendLayout();
this.flowLayoutPanel6.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudCustomRatio)).BeginInit();
this.SuspendLayout();
//
// baseConfigPanel
@ -165,11 +170,11 @@
this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tlpMain.Controls.Add(this.lblVideoScale, 0, 0);
this.tlpMain.Controls.Add(this.chkVerticalSync, 0, 3);
this.tlpMain.Controls.Add(this.cboAspectRatio, 1, 1);
this.tlpMain.Controls.Add(this.lblDisplayRatio, 0, 1);
this.tlpMain.Controls.Add(this.chkShowFps, 0, 4);
this.tlpMain.Controls.Add(this.flowLayoutPanel7, 0, 2);
this.tlpMain.Controls.Add(this.nudScale, 1, 0);
this.tlpMain.Controls.Add(this.flowLayoutPanel6, 1, 1);
this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.tlpMain.Location = new System.Drawing.Point(3, 3);
this.tlpMain.Margin = new System.Windows.Forms.Padding(0);
@ -200,7 +205,7 @@
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, 79);
this.chkVerticalSync.Location = new System.Drawing.Point(3, 78);
this.chkVerticalSync.Name = "chkVerticalSync";
this.chkVerticalSync.Size = new System.Drawing.Size(121, 17);
this.chkVerticalSync.TabIndex = 15;
@ -217,16 +222,17 @@
"PAL (18:13)",
"Standard (4:3)",
"Widescreen (16:9)"});
this.cboAspectRatio.Location = new System.Drawing.Point(80, 29);
this.cboAspectRatio.Location = new System.Drawing.Point(3, 3);
this.cboAspectRatio.Name = "cboAspectRatio";
this.cboAspectRatio.Size = new System.Drawing.Size(121, 21);
this.cboAspectRatio.TabIndex = 16;
this.cboAspectRatio.SelectionChangeCommitted += new System.EventHandler(this.cboAspectRatio_SelectionChangeCommitted);
//
// lblDisplayRatio
//
this.lblDisplayRatio.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblDisplayRatio.AutoSize = true;
this.lblDisplayRatio.Location = new System.Drawing.Point(3, 33);
this.lblDisplayRatio.Location = new System.Drawing.Point(3, 32);
this.lblDisplayRatio.Name = "lblDisplayRatio";
this.lblDisplayRatio.Size = new System.Drawing.Size(71, 13);
this.lblDisplayRatio.TabIndex = 17;
@ -237,7 +243,7 @@
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, 102);
this.chkShowFps.Location = new System.Drawing.Point(3, 101);
this.chkShowFps.Name = "chkShowFps";
this.chkShowFps.Size = new System.Drawing.Size(76, 17);
this.chkShowFps.TabIndex = 9;
@ -250,7 +256,7 @@
this.flowLayoutPanel7.Controls.Add(this.chkUseHdPacks);
this.flowLayoutPanel7.Controls.Add(this.picHdNesTooltip);
this.flowLayoutPanel7.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel7.Location = new System.Drawing.Point(0, 53);
this.flowLayoutPanel7.Location = new System.Drawing.Point(0, 52);
this.flowLayoutPanel7.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel7.Name = "flowLayoutPanel7";
this.flowLayoutPanel7.Size = new System.Drawing.Size(521, 23);
@ -1167,7 +1173,7 @@
this.mnuPaletteNestopiaRgb,
this.mnuPaletteSonyCxa2025As});
this.contextPaletteList.Name = "contextPicturePresets";
this.contextPaletteList.Size = new System.Drawing.Size(236, 186);
this.contextPaletteList.Size = new System.Drawing.Size(236, 164);
this.contextPaletteList.Opening += new System.ComponentModel.CancelEventHandler(this.contextPaletteList_Opening);
//
// mnuDefaultPalette
@ -1224,6 +1230,57 @@
this.mnuPaletteSonyCxa2025As.Text = "Sony CXA2025AS";
this.mnuPaletteSonyCxa2025As.Click += new System.EventHandler(this.mnuPaletteSonyCxa2025As_Click);
//
// flowLayoutPanel6
//
this.flowLayoutPanel6.Controls.Add(this.cboAspectRatio);
this.flowLayoutPanel6.Controls.Add(this.lblCustomRatio);
this.flowLayoutPanel6.Controls.Add(this.nudCustomRatio);
this.flowLayoutPanel6.Location = new System.Drawing.Point(77, 26);
this.flowLayoutPanel6.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
this.flowLayoutPanel6.Name = "flowLayoutPanel6";
this.flowLayoutPanel6.Size = new System.Drawing.Size(364, 26);
this.flowLayoutPanel6.TabIndex = 22;
//
// lblCustomRatio
//
this.lblCustomRatio.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblCustomRatio.AutoSize = true;
this.lblCustomRatio.Location = new System.Drawing.Point(130, 7);
this.lblCustomRatio.Name = "lblCustomRatio";
this.lblCustomRatio.Size = new System.Drawing.Size(76, 13);
this.lblCustomRatio.TabIndex = 17;
this.lblCustomRatio.Text = "Custom Ratio: ";
this.lblCustomRatio.Visible = false;
//
// nudCustomRatio
//
this.nudCustomRatio.DecimalPlaces = 3;
this.nudCustomRatio.Increment = new decimal(new int[] {
1,
0,
0,
65536});
this.nudCustomRatio.Location = new System.Drawing.Point(212, 3);
this.nudCustomRatio.Maximum = new decimal(new int[] {
5,
0,
0,
0});
this.nudCustomRatio.Minimum = new decimal(new int[] {
1,
0,
0,
65536});
this.nudCustomRatio.Name = "nudCustomRatio";
this.nudCustomRatio.Size = new System.Drawing.Size(48, 20);
this.nudCustomRatio.TabIndex = 22;
this.nudCustomRatio.Value = new decimal(new int[] {
1,
0,
0,
65536});
this.nudCustomRatio.Visible = false;
//
// frmVideoConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -1287,6 +1344,9 @@
this.tableLayoutPanel9.PerformLayout();
this.contextPicturePresets.ResumeLayout(false);
this.contextPaletteList.ResumeLayout(false);
this.flowLayoutPanel6.ResumeLayout(false);
this.flowLayoutPanel6.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudCustomRatio)).EndInit();
this.ResumeLayout(false);
}
@ -1379,5 +1439,8 @@
private Controls.ctrlHorizontalTrackbar trkIFilterLength;
private Controls.ctrlHorizontalTrackbar trkQFilterLength;
private System.Windows.Forms.ToolStripMenuItem mnuPaletteSonyCxa2025As;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel6;
private System.Windows.Forms.Label lblCustomRatio;
private System.Windows.Forms.NumericUpDown nudCustomRatio;
}
}

View file

@ -30,6 +30,7 @@ namespace Mesen.GUI.Forms.Config
AddBinding("VideoScale", nudScale);
AddBinding("AspectRatio", cboAspectRatio);
AddBinding("CustomAspectRatio", nudCustomRatio);
AddBinding("VideoFilter", cboFilter);
AddBinding("OverscanLeft", nudOverscanLeft);
@ -82,6 +83,7 @@ namespace Mesen.GUI.Forms.Config
{
VideoFilterType orgFilter = ((VideoInfo)Entity).VideoFilter;
UpdateObject();
UpdateCustomRatioVisibility();
UpdatePalette();
VideoFilterType filter = ((VideoInfo)Entity).VideoFilter;
if(filter == VideoFilterType.NTSC) {
@ -478,5 +480,17 @@ namespace Mesen.GUI.Forms.Config
File.WriteAllBytes(sfd.FileName, bytePalette.ToArray());
}
}
private void cboAspectRatio_SelectionChangeCommitted(object sender, EventArgs e)
{
UpdateCustomRatioVisibility();
}
private void UpdateCustomRatioVisibility()
{
VideoAspectRatio ratio = cboAspectRatio.GetEnumValue<VideoAspectRatio>();
lblCustomRatio.Visible = ratio == VideoAspectRatio.Custom;
nudCustomRatio.Visible = ratio == VideoAspectRatio.Custom;
}
}
}

View file

@ -151,7 +151,7 @@ namespace Mesen.GUI
[DllImport(DLLPath)] public static extern void SetPpuNmiConfig(UInt32 extraScanlinesBeforeNmi, UInt32 extraScanlineAfterNmi);
[DllImport(DLLPath)] public static extern void SetOverscanDimensions(UInt32 left, UInt32 right, UInt32 top, UInt32 bottom);
[DllImport(DLLPath)] public static extern void SetVideoScale(double scale);
[DllImport(DLLPath)] public static extern void SetVideoAspectRatio(VideoAspectRatio aspectRatio);
[DllImport(DLLPath)] public static extern void SetVideoAspectRatio(VideoAspectRatio aspectRatio, double customRatio);
[DllImport(DLLPath)] public static extern void SetVideoFilter(VideoFilterType filter);
[DllImport(DLLPath)] public static extern void SetVideoResizeFilter(VideoResizeFilter filter);
[DllImport(DLLPath)] public static extern void SetRgbPalette(byte[] palette);
@ -1133,7 +1133,8 @@ namespace Mesen.GUI
NTSC = 1,
PAL = 2,
Standard = 3,
Widescreen = 4
Widescreen = 4,
Custom = 5
}
public enum DebugMemoryType

View file

@ -373,7 +373,7 @@ namespace InteropEmu {
DllExport void __stdcall SetOverclockRate(uint32_t overclockRate, bool adjustApu) { EmulationSettings::SetOverclockRate(overclockRate, adjustApu); }
DllExport void __stdcall SetPpuNmiConfig(uint32_t extraScanlinesBeforeNmi, uint32_t extraScanlinesAfterNmi) { EmulationSettings::SetPpuNmiConfig(extraScanlinesBeforeNmi, extraScanlinesAfterNmi); }
DllExport void __stdcall SetVideoScale(double scale) { EmulationSettings::SetVideoScale(scale); }
DllExport void __stdcall SetVideoAspectRatio(VideoAspectRatio aspectRatio) { EmulationSettings::SetVideoAspectRatio(aspectRatio); }
DllExport void __stdcall SetVideoAspectRatio(VideoAspectRatio aspectRatio, double customRatio) { EmulationSettings::SetVideoAspectRatio(aspectRatio, customRatio); }
DllExport void __stdcall SetVideoFilter(VideoFilterType filter) { EmulationSettings::SetVideoFilterType(filter); }
DllExport void __stdcall SetVideoResizeFilter(VideoResizeFilter filter) { EmulationSettings::SetVideoResizeFilter(filter); }
DllExport void __stdcall GetRgbPalette(uint32_t *paletteBuffer) { EmulationSettings::GetRgbPalette(paletteBuffer); }