diff --git a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs index d320345a59..300e817eab 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs @@ -261,10 +261,11 @@ namespace BizHawk.Client.EmuHawk { int vw = videoProvider.BufferWidth; int vh = videoProvider.BufferHeight; - if (Global.Config.DispObeyAR) + + if (Global.Config.DispObeyAR && Global.Config.DispFixAspectRatio) { - vw = videoProvider.VirtualWidth; - vh = videoProvider.VirtualHeight; + vw = videoProvider.VirtualWidth; + vh = videoProvider.VirtualHeight; } int[] videoBuffer = videoProvider.GetVideoBuffer(); @@ -316,6 +317,7 @@ TESTEROO: //setup the final presentation filter Filters.FinalPresentation fPresent = CurrentFilterProgram["presentation"] as Filters.FinalPresentation; + fPresent.TextureSize = new Size(bufferWidth, bufferHeight); fPresent.BackgroundColor = videoProvider.BackgroundColor; fPresent.GuiRenderer = Renderer; fPresent.GL = GL; diff --git a/BizHawk.Client.EmuHawk/DisplayManager/Filters/Gui.cs b/BizHawk.Client.EmuHawk/DisplayManager/Filters/Gui.cs index 026bb02a35..7f9c4282cd 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/Filters/Gui.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/Filters/Gui.cs @@ -34,27 +34,47 @@ namespace BizHawk.Client.EmuHawk.Filters /// public float WidthScale, HeightScale; - public LetterboxingLogic(bool maintainAspect, bool maintainInteger, int targetWidth, int targetHeight, int sourceWidth, int sourceHeight) + public LetterboxingLogic(bool maintainAspect, bool maintainInteger, int targetWidth, int targetHeight, int sourceWidth, int sourceHeight, int textureWidth, int textureHeight) { //do maths on the viewport and the native resolution and the user settings to get a display rectangle - Size sz = new Size(targetWidth, targetHeight); - float widthScale = (float)sz.Width / sourceWidth; - float heightScale = (float)sz.Height / sourceHeight; + //this doesnt make sense + if (!maintainAspect) + maintainInteger = false; + + float widthScale = (float)targetWidth / sourceWidth; + float heightScale = (float)targetHeight / sourceHeight; + if (maintainAspect) { if (widthScale > heightScale) widthScale = heightScale; if (heightScale > widthScale) heightScale = widthScale; } + if (maintainInteger) { - widthScale = (float)Math.Floor(widthScale); - heightScale = (float)Math.Floor(heightScale); + //pre- AR-correction + //widthScale = (float)Math.Floor(widthScale); + //heightScale = (float)Math.Floor(heightScale); + + //don't distorted the original texture + float apparentWidth = sourceWidth * widthScale; + float apparentHeight = sourceHeight * heightScale; + widthScale = (float)Math.Floor(apparentWidth / textureWidth); + heightScale = (float)Math.Floor(apparentHeight / textureHeight); + + vw = (int)(widthScale * textureWidth); + vh = (int)(heightScale * textureHeight); } - vw = (int)(widthScale * sourceWidth); - vh = (int)(heightScale * sourceHeight); - vx = (sz.Width - vw) / 2; - vy = (sz.Height - vh) / 2; + else + { + vw = (int)(widthScale * sourceWidth); + vh = (int)(heightScale * sourceHeight); + } + + + vx = (targetWidth - vw) / 2; + vy = (targetHeight - vh) / 2; WidthScale = widthScale; HeightScale = heightScale; } @@ -77,6 +97,7 @@ namespace BizHawk.Client.EmuHawk.Filters } Size OutputSize, InputSize; + public Size TextureSize; public int BackgroundColor; public GuiRenderer GuiRenderer; public IGL GL; @@ -105,7 +126,7 @@ namespace BizHawk.Client.EmuHawk.Filters if (FilterOption != eFilterOption.Bicubic) return size; - LL = new LetterboxingLogic(Global.Config.DispFixAspectRatio, Global.Config.DispFixScaleInteger, OutputSize.Width, OutputSize.Height, size.Width, size.Height); + LL = new LetterboxingLogic(Global.Config.DispFixAspectRatio, Global.Config.DispFixScaleInteger, OutputSize.Width, OutputSize.Height, size.Width, size.Height, TextureSize.Width, TextureSize.Height); return size; } @@ -127,7 +148,7 @@ namespace BizHawk.Client.EmuHawk.Filters FindInput().SurfaceDisposition = SurfaceDisposition.Texture; DeclareOutput(new SurfaceState(new SurfaceFormat(OutputSize), SurfaceDisposition.RenderTarget)); InputSize = state.SurfaceFormat.Size; - LL = new LetterboxingLogic(Global.Config.DispFixAspectRatio, Global.Config.DispFixScaleInteger, OutputSize.Width, OutputSize.Height, InputSize.Width, InputSize.Height); + LL = new LetterboxingLogic(Global.Config.DispFixAspectRatio, Global.Config.DispFixScaleInteger, OutputSize.Width, OutputSize.Height, InputSize.Width, InputSize.Height, TextureSize.Width, TextureSize.Height); } public override Vector2 UntransformPoint(string channel, Vector2 point) diff --git a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs index 6bc0ed4b00..dca437f3b0 100644 --- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs @@ -41,21 +41,24 @@ this.rbHq2x = new System.Windows.Forms.RadioButton(); this.checkLetterbox = new System.Windows.Forms.CheckBox(); this.checkPadInteger = new System.Windows.Forms.CheckBox(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.grpFinalFilter = new System.Windows.Forms.GroupBox(); this.rbFinalFilterBicubic = new System.Windows.Forms.RadioButton(); this.rbFinalFilterNone = new System.Windows.Forms.RadioButton(); this.rbFinalFilterBilinear = new System.Windows.Forms.RadioButton(); - this.checkObeyAR = new System.Windows.Forms.CheckBox(); + this.rbUseRaw = new System.Windows.Forms.RadioButton(); + this.rbUseSystem = new System.Windows.Forms.RadioButton(); + this.grpARSelection = new System.Windows.Forms.GroupBox(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).BeginInit(); - this.groupBox2.SuspendLayout(); + this.grpFinalFilter.SuspendLayout(); + this.grpARSelection.SuspendLayout(); this.SuspendLayout(); // // btnCancel // this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(289, 221); + this.btnCancel.Location = new System.Drawing.Point(288, 314); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.TabIndex = 5; @@ -65,7 +68,7 @@ // btnOk // this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnOk.Location = new System.Drawing.Point(208, 221); + this.btnOk.Location = new System.Drawing.Point(207, 314); this.btnOk.Name = "btnOk"; this.btnOk.Size = new System.Drawing.Size(75, 23); this.btnOk.TabIndex = 4; @@ -174,34 +177,36 @@ // checkLetterbox // this.checkLetterbox.AutoSize = true; - this.checkLetterbox.Location = new System.Drawing.Point(12, 172); + this.checkLetterbox.Location = new System.Drawing.Point(12, 176); this.checkLetterbox.Name = "checkLetterbox"; this.checkLetterbox.Size = new System.Drawing.Size(173, 17); this.checkLetterbox.TabIndex = 8; this.checkLetterbox.Text = "Maintain aspect ratio (letterbox)"; this.checkLetterbox.UseVisualStyleBackColor = true; + this.checkLetterbox.CheckedChanged += new System.EventHandler(this.checkLetterbox_CheckedChanged); // // checkPadInteger // this.checkPadInteger.AutoSize = true; - this.checkPadInteger.Location = new System.Drawing.Point(12, 218); + this.checkPadInteger.Location = new System.Drawing.Point(21, 276); this.checkPadInteger.Name = "checkPadInteger"; - this.checkPadInteger.Size = new System.Drawing.Size(120, 17); + this.checkPadInteger.Size = new System.Drawing.Size(248, 17); this.checkPadInteger.TabIndex = 9; - this.checkPadInteger.Text = "Pad to integer scale"; + this.checkPadInteger.Text = "Stretch pixels by integers only (e.g. no 1.3333x)"; this.checkPadInteger.UseVisualStyleBackColor = true; + this.checkPadInteger.CheckedChanged += new System.EventHandler(this.checkPadInteger_CheckedChanged); // - // groupBox2 + // grpFinalFilter // - this.groupBox2.Controls.Add(this.rbFinalFilterBicubic); - this.groupBox2.Controls.Add(this.rbFinalFilterNone); - this.groupBox2.Controls.Add(this.rbFinalFilterBilinear); - this.groupBox2.Location = new System.Drawing.Point(191, 34); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(173, 132); - this.groupBox2.TabIndex = 8; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Final Filter"; + this.grpFinalFilter.Controls.Add(this.rbFinalFilterBicubic); + this.grpFinalFilter.Controls.Add(this.rbFinalFilterNone); + this.grpFinalFilter.Controls.Add(this.rbFinalFilterBilinear); + this.grpFinalFilter.Location = new System.Drawing.Point(191, 34); + this.grpFinalFilter.Name = "grpFinalFilter"; + this.grpFinalFilter.Size = new System.Drawing.Size(173, 132); + this.grpFinalFilter.TabIndex = 8; + this.grpFinalFilter.TabStop = false; + this.grpFinalFilter.Text = "Final Filter"; // // rbFinalFilterBicubic // @@ -236,15 +241,40 @@ this.rbFinalFilterBilinear.Text = "Bilinear"; this.rbFinalFilterBilinear.UseVisualStyleBackColor = true; // - // checkObeyAR + // rbUseRaw // - this.checkObeyAR.AutoSize = true; - this.checkObeyAR.Location = new System.Drawing.Point(12, 195); - this.checkObeyAR.Name = "checkObeyAR"; - this.checkObeyAR.Size = new System.Drawing.Size(211, 17); - this.checkObeyAR.TabIndex = 10; - this.checkObeyAR.Text = "Obey system\'s Aspect Ratio suggestion"; - this.checkObeyAR.UseVisualStyleBackColor = true; + this.rbUseRaw.AutoSize = true; + this.rbUseRaw.Location = new System.Drawing.Point(6, 19); + this.rbUseRaw.Name = "rbUseRaw"; + this.rbUseRaw.Size = new System.Drawing.Size(240, 17); + this.rbUseRaw.TabIndex = 11; + this.rbUseRaw.TabStop = true; + this.rbUseRaw.Text = "Use 1:1 pixel size (for crispness or debugging)"; + this.rbUseRaw.UseVisualStyleBackColor = true; + this.rbUseRaw.CheckedChanged += new System.EventHandler(this.rbUseRaw_CheckedChanged); + // + // rbUseSystem + // + this.rbUseSystem.AutoSize = true; + this.rbUseSystem.Location = new System.Drawing.Point(6, 42); + this.rbUseSystem.Name = "rbUseSystem"; + this.rbUseSystem.Size = new System.Drawing.Size(167, 17); + this.rbUseSystem.TabIndex = 12; + this.rbUseSystem.TabStop = true; + this.rbUseSystem.Text = "Use system\'s recommendation"; + this.rbUseSystem.UseVisualStyleBackColor = true; + this.rbUseSystem.CheckedChanged += new System.EventHandler(this.rbUseSystem_CheckedChanged); + // + // grpARSelection + // + this.grpARSelection.Controls.Add(this.rbUseRaw); + this.grpARSelection.Controls.Add(this.rbUseSystem); + this.grpARSelection.Location = new System.Drawing.Point(21, 199); + this.grpARSelection.Name = "grpARSelection"; + this.grpARSelection.Size = new System.Drawing.Size(264, 71); + this.grpARSelection.TabIndex = 13; + this.grpARSelection.TabStop = false; + this.grpARSelection.Text = "Aspect Ratio Selection"; // // DisplayConfigLite // @@ -252,9 +282,9 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(376, 256); - this.Controls.Add(this.checkObeyAR); - this.Controls.Add(this.groupBox2); + this.ClientSize = new System.Drawing.Size(375, 349); + this.Controls.Add(this.grpARSelection); + this.Controls.Add(this.grpFinalFilter); this.Controls.Add(this.checkPadInteger); this.Controls.Add(this.checkLetterbox); this.Controls.Add(this.groupBox1); @@ -268,8 +298,10 @@ this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).EndInit(); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); + this.grpFinalFilter.ResumeLayout(false); + this.grpFinalFilter.PerformLayout(); + this.grpARSelection.ResumeLayout(false); + this.grpARSelection.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -287,13 +319,15 @@ private System.Windows.Forms.TrackBar tbScanlineIntensity; private System.Windows.Forms.CheckBox checkLetterbox; private System.Windows.Forms.CheckBox checkPadInteger; - private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.GroupBox grpFinalFilter; private System.Windows.Forms.RadioButton rbFinalFilterBicubic; private System.Windows.Forms.RadioButton rbFinalFilterNone; private System.Windows.Forms.RadioButton rbFinalFilterBilinear; private System.Windows.Forms.Button btnSelectUserFilter; private System.Windows.Forms.RadioButton rbUser; private System.Windows.Forms.Label lblUserFilterName; - private System.Windows.Forms.CheckBox checkObeyAR; + private System.Windows.Forms.RadioButton rbUseRaw; + private System.Windows.Forms.RadioButton rbUseSystem; + private System.Windows.Forms.GroupBox grpARSelection; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs index fe64c4e745..d0cf9a91b5 100644 --- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs +++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs @@ -35,7 +35,10 @@ namespace BizHawk.Client.EmuHawk.config tbScanlineIntensity.Value = Global.Config.TargetScanlineFilterIntensity; checkLetterbox.Checked = Global.Config.DispFixAspectRatio; checkPadInteger.Checked = Global.Config.DispFixScaleInteger; - checkObeyAR.Checked = Global.Config.DispObeyAR; + rbUseSystem.Checked = Global.Config.DispObeyAR; + rbUseRaw.Checked = !Global.Config.DispObeyAR; + + RefreshAspectRatioOptions(); } private void btnOk_Click(object sender, EventArgs e) @@ -59,7 +62,7 @@ namespace BizHawk.Client.EmuHawk.config Global.Config.TargetScanlineFilterIntensity = tbScanlineIntensity.Value; Global.Config.DispFixAspectRatio = checkLetterbox.Checked; Global.Config.DispFixScaleInteger = checkPadInteger.Checked; - Global.Config.DispObeyAR = checkObeyAR.Checked; + Global.Config.DispObeyAR = rbUseSystem.Checked; Global.Config.DispUserFilterPath = PathSelection; GlobalWin.DisplayManager.RefreshUserShader(); @@ -86,5 +89,31 @@ namespace BizHawk.Client.EmuHawk.config } } + private void checkLetterbox_CheckedChanged(object sender, EventArgs e) + { + RefreshAspectRatioOptions(); + } + private void checkPadInteger_CheckedChanged(object sender, EventArgs e) + { + RefreshAspectRatioOptions(); + } + + private void rbUseRaw_CheckedChanged(object sender, EventArgs e) + { + RefreshAspectRatioOptions(); + } + + private void rbUseSystem_CheckedChanged(object sender, EventArgs e) + { + RefreshAspectRatioOptions(); + } + + void RefreshAspectRatioOptions() + { + grpARSelection.Enabled = checkLetterbox.Checked; + checkPadInteger.Enabled = checkLetterbox.Checked; + } + + } }