From f74c3d5fe4145241fed342990252f5b0d0cbf5d5 Mon Sep 17 00:00:00 2001 From: Mu0n Date: Sat, 7 Oct 2023 08:47:13 -0400 Subject: [PATCH] Adding more scaling options Can now support 640x400 resolutions with perfect pixels in the scaling menu. Also fixes the wrong 768 width that was forced for every choice. --- .gitignore | 1 + Main/Display/Gpu.cs | 11 ++- Main/UI/MainWindow.Designer.cs | 133 +++++++++++++++++++++++++-------- Main/UI/MainWindow.cs | 30 ++++++-- 4 files changed, 132 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index d5deb08..940c2d8 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ Tests/*.lst bin/Debug bin/Release packages +UpgradeLog.htm diff --git a/Main/Display/Gpu.cs b/Main/Display/Gpu.cs index c8225c6..92ca3b5 100644 --- a/Main/Display/Gpu.cs +++ b/Main/Display/Gpu.cs @@ -36,8 +36,11 @@ public unsafe partial class Gpu : UserControl private static readonly int[] vs = new int[256 * 8]; private int[] lutCache = vs; + + //NativeHeight and NativeWidth are no longer used in this fork proposition public const int NativeHeight = 480; - public const int NativeWidth = 768; + public const int NativeWidth = 640; + private int MarginHeight; private int MarginWidth; @@ -85,10 +88,10 @@ public void SetViewSize(int viewWidth, int viewHeight) ParentForm.Width = viewWidth + MarginWidth; } - public void SetViewScaling(float scaling) + public void SetViewScaling(float scaling, int requiredWidth, int requiredHeight) { - int viewHeight = (int)Math.Ceiling((float)NativeHeight * scaling); - int viewWidth = (int)Math.Ceiling((float)NativeWidth * scaling); + int viewHeight = (int)((float)requiredHeight * scaling); + int viewWidth = (int)((float)requiredWidth * scaling); ParentForm.Height = viewHeight + MarginHeight; ParentForm.Width = viewWidth + MarginWidth; diff --git a/Main/UI/MainWindow.Designer.cs b/Main/UI/MainWindow.Designer.cs index 6dea885..c6e325d 100644 --- a/Main/UI/MainWindow.Designer.cs +++ b/Main/UI/MainWindow.Designer.cs @@ -63,9 +63,16 @@ private void InitializeComponent() this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.autorunEmulatorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewScalingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.scale1_0XToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.scale1_5XToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.scale2_0XToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.resolution_label_640x480MenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scalingseparator1MenuItem = new System.Windows.Forms.ToolStripSeparator(); + this.scale1_0X_H480ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scale1_5X_H480ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scale2_0X_H480ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.resolution_label_640x400MenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scalingseparator2MenuItem = new System.Windows.Forms.ToolStripSeparator(); + this.scale1_0X_H400ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scale1_5X_H400ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scale2_0X_H400ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.windowsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.terminalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.cPUToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -385,36 +392,89 @@ private void InitializeComponent() // viewScalingToolStripMenuItem // this.viewScalingToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.scale1_0XToolStripMenuItem, - this.scale1_5XToolStripMenuItem, - this.scale2_0XToolStripMenuItem}); + this.resolution_label_640x480MenuItem, + this.scalingseparator1MenuItem, + this.scale1_0X_H480ToolStripMenuItem, + this.scale1_5X_H480ToolStripMenuItem, + this.scale2_0X_H480ToolStripMenuItem, + this.resolution_label_640x400MenuItem, + this.scalingseparator2MenuItem, + this.scale1_0X_H400ToolStripMenuItem, + this.scale1_5X_H400ToolStripMenuItem, + this.scale2_0X_H400ToolStripMenuItem}); this.viewScalingToolStripMenuItem.Name = "viewScalingToolStripMenuItem"; this.viewScalingToolStripMenuItem.Size = new System.Drawing.Size(169, 22); this.viewScalingToolStripMenuItem.Text = "View Scaling"; - // - // scale1_0XToolStripMenuItem - // - this.scale1_0XToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.scale1_0XToolStripMenuItem.Name = "scale1_0XToolStripMenuItem"; - this.scale1_0XToolStripMenuItem.Size = new System.Drawing.Size(126, 22); - this.scale1_0XToolStripMenuItem.Text = "Scale 1.0X"; - this.scale1_0XToolStripMenuItem.Click += new System.EventHandler(this.scale1_0XToolStripMenuItem_Click); - // - // scale1_5XToolStripMenuItem - // - this.scale1_5XToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.scale1_5XToolStripMenuItem.Name = "scale1_5XToolStripMenuItem"; - this.scale1_5XToolStripMenuItem.Size = new System.Drawing.Size(126, 22); - this.scale1_5XToolStripMenuItem.Text = "Scale 1.5X"; - this.scale1_5XToolStripMenuItem.Click += new System.EventHandler(this.scale1_5XToolStripMenuItem_Click); - // - // scale2_0XToolStripMenuItem - // - this.scale2_0XToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.scale2_0XToolStripMenuItem.Name = "scale2_0XToolStripMenuItem"; - this.scale2_0XToolStripMenuItem.Size = new System.Drawing.Size(126, 22); - this.scale2_0XToolStripMenuItem.Text = "Scale 2.0X"; - this.scale2_0XToolStripMenuItem.Click += new System.EventHandler(this.scale2_0XToolStripMenuItem_Click); + // + // Disabled Menu Text entry to specify 640x480 + // + this.resolution_label_640x480MenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.resolution_label_640x480MenuItem.Name = "resolution_label_640x480MenuItem"; + this.resolution_label_640x480MenuItem.Size = new System.Drawing.Size(126, 22); + this.resolution_label_640x480MenuItem.Text = "640 x 480"; + this.resolution_label_640x480MenuItem.Enabled = false; + // + // Disabled Menu Text entry to specify 640x400 + // + this.resolution_label_640x400MenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.resolution_label_640x400MenuItem.Name = "resolution_label_640x400MenuItem"; + this.resolution_label_640x400MenuItem.Size = new System.Drawing.Size(126, 22); + this.resolution_label_640x400MenuItem.Text = "640 x 400"; + this.resolution_label_640x400MenuItem.Enabled = false; + // + // scale1_0X_H480ToolStripMenuItem + // 640x480 at 1x + // + this.scale1_0X_H480ToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.scale1_0X_H480ToolStripMenuItem.Name = "scale1_0X_H480ToolStripMenuItem"; + this.scale1_0X_H480ToolStripMenuItem.Size = new System.Drawing.Size(126, 22); + this.scale1_0X_H480ToolStripMenuItem.Text = "Scale 1.0X"; + this.scale1_0X_H480ToolStripMenuItem.Click += new System.EventHandler(this.scale1_0X_H480ToolStripMenuItem_Click); + // + // scale1_5X_H480ToolStripMenuItem + // 640x480 at 1.5x + // + this.scale1_5X_H480ToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.scale1_5X_H480ToolStripMenuItem.Name = "scale1_5X_H480ToolStripMenuItem"; + this.scale1_5X_H480ToolStripMenuItem.Size = new System.Drawing.Size(126, 22); + this.scale1_5X_H480ToolStripMenuItem.Text = "Scale 1.5X"; + this.scale1_5X_H480ToolStripMenuItem.Click += new System.EventHandler(this.scale1_5X_H480ToolStripMenuItem_Click); + // + // scale2_0X_H480ToolStripMenuItem + // 640x480 at 2x + // + this.scale2_0X_H480ToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.scale2_0X_H480ToolStripMenuItem.Name = "scale2_0X_H480ToolStripMenuItem"; + this.scale2_0X_H480ToolStripMenuItem.Size = new System.Drawing.Size(126, 22); + this.scale2_0X_H480ToolStripMenuItem.Text = "Scale 2.0X"; + this.scale2_0X_H480ToolStripMenuItem.Click += new System.EventHandler(this.scale2_0X_H480ToolStripMenuItem_Click); + // + // scale1_0X_H400ToolStripMenuItem + // 640x400 at 1x + // + this.scale1_0X_H400ToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.scale1_0X_H400ToolStripMenuItem.Name = "scale1_0X_H400ToolStripMenuItem"; + this.scale1_0X_H400ToolStripMenuItem.Size = new System.Drawing.Size(126, 22); + this.scale1_0X_H400ToolStripMenuItem.Text = "Scale 1.0X"; + this.scale1_0X_H400ToolStripMenuItem.Click += new System.EventHandler(this.scale1_0X_H400ToolStripMenuItem_Click); + // + // scale1_5X_H400ToolStripMenuItem + // 640x400 at 1.5x + // + this.scale1_5X_H400ToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.scale1_5X_H400ToolStripMenuItem.Name = "scale1_5X_H400ToolStripMenuItem"; + this.scale1_5X_H400ToolStripMenuItem.Size = new System.Drawing.Size(126, 22); + this.scale1_5X_H400ToolStripMenuItem.Text = "Scale 1.5X"; + this.scale1_5X_H400ToolStripMenuItem.Click += new System.EventHandler(this.scale1_5X_H400ToolStripMenuItem_Click); + // + // scale2_0X_H400ToolStripMenuItem + // 640x400 at 2x + // + this.scale2_0X_H400ToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.scale2_0X_H400ToolStripMenuItem.Name = "scale2_0X_H400ToolStripMenuItem"; + this.scale2_0X_H400ToolStripMenuItem.Size = new System.Drawing.Size(126, 22); + this.scale2_0X_H400ToolStripMenuItem.Text = "Scale 2.0X"; + this.scale2_0X_H400ToolStripMenuItem.Click += new System.EventHandler(this.scale2_0X_H400ToolStripMenuItem_Click); // // windowsToolStripMenuItem // @@ -663,9 +723,16 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem convertHexToPGZToolStripMenuItem; public Gpu gpu; private System.Windows.Forms.ToolStripMenuItem viewScalingToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem scale1_0XToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem scale2_0XToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem scale1_5XToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator scalingseparator1MenuItem; + private System.Windows.Forms.ToolStripMenuItem resolution_label_640x480MenuItem; + private System.Windows.Forms.ToolStripMenuItem scale1_0X_H480ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem scale2_0X_H480ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem scale1_5X_H480ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem resolution_label_640x400MenuItem; + private System.Windows.Forms.ToolStripSeparator scalingseparator2MenuItem; + private System.Windows.Forms.ToolStripMenuItem scale1_0X_H400ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem scale2_0X_H400ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem scale1_5X_H400ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem revJr816ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem revJrToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem revUPlusToolStripMenuItem; diff --git a/Main/UI/MainWindow.cs b/Main/UI/MainWindow.cs index 5eab13a..b0fddd5 100644 --- a/Main/UI/MainWindow.cs +++ b/Main/UI/MainWindow.cs @@ -1862,22 +1862,40 @@ private void MIDIToVGMConvertToolStripMenuItem_Click(object sender, EventArgs e) midiForm.Show(); } - private void scale1_0XToolStripMenuItem_Click(object sender, EventArgs e) + private void scale1_0X_H480ToolStripMenuItem_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Normal; - gpu.SetViewScaling(1.0f); + gpu.SetViewScaling(1.0f, 640, 480); } - private void scale1_5XToolStripMenuItem_Click(object sender, EventArgs e) + private void scale1_5X_H480ToolStripMenuItem_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Normal; - gpu.SetViewScaling(1.5f); + gpu.SetViewScaling(1.5f, 640, 480); } - private void scale2_0XToolStripMenuItem_Click(object sender, EventArgs e) + private void scale2_0X_H480ToolStripMenuItem_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Normal; - gpu.SetViewScaling(2.0f); + gpu.SetViewScaling(2.0f, 640, 480); + } + + private void scale1_0X_H400ToolStripMenuItem_Click(object sender, EventArgs e) + { + this.WindowState = FormWindowState.Normal; + gpu.SetViewScaling(1.0f, 640, 400); + } + + private void scale1_5X_H400ToolStripMenuItem_Click(object sender, EventArgs e) + { + this.WindowState = FormWindowState.Normal; + gpu.SetViewScaling(1.5f, 640, 400); + } + + private void scale2_0X_H400ToolStripMenuItem_Click(object sender, EventArgs e) + { + this.WindowState = FormWindowState.Normal; + gpu.SetViewScaling(2.0f, 640, 400); } } }