Undo Previous PR on Gambatte Colors and Implement an Option (#1918)

* Revert "New GBC LCD correction for Gambatte palette from documented shader research https://forums.libretro.com/t/real-gba-and-ds-phat-colors/1540"

This reverts commit 88cda24876.

* Implement the libretro GBC color palette as an added option instead of a change to the Gambatte option
This commit is contained in:
TiKevin83 2020-04-08 20:41:50 -04:00 committed by GitHub
parent b960351732
commit faf4b02c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 204 additions and 162 deletions

View File

@ -28,168 +28,182 @@
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton6 = new System.Windows.Forms.RadioButton();
this.radioButton5 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.bmpView1 = new BizHawk.Client.EmuHawk.BmpView();
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButton6);
this.groupBox1.Controls.Add(this.radioButton5);
this.groupBox1.Controls.Add(this.radioButton3);
this.groupBox1.Controls.Add(this.radioButton4);
this.groupBox1.Controls.Add(this.radioButton2);
this.groupBox1.Controls.Add(this.radioButton1);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(132, 182);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Preset Select";
//
// radioButton6
//
this.radioButton6.AutoSize = true;
this.radioButton6.Location = new System.Drawing.Point(6, 134);
this.radioButton6.Name = "radioButton6";
this.radioButton6.Size = new System.Drawing.Size(47, 17);
this.radioButton6.TabIndex = 3;
this.radioButton6.TabStop = true;
this.radioButton6.Text = "GBA";
this.radioButton6.UseVisualStyleBackColor = true;
this.radioButton6.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton5
//
this.radioButton5.AutoSize = true;
this.radioButton5.Location = new System.Drawing.Point(6, 111);
this.radioButton5.Name = "radioButton5";
this.radioButton5.Size = new System.Drawing.Size(117, 17);
this.radioButton5.TabIndex = 2;
this.radioButton5.TabStop = true;
this.radioButton5.Text = "VBA Accurate (Old)";
this.radioButton5.UseVisualStyleBackColor = true;
this.radioButton5.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(6, 65);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(72, 17);
this.radioButton3.TabIndex = 2;
this.radioButton3.TabStop = true;
this.radioButton3.Text = "VBA Vivid";
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.Location = new System.Drawing.Point(6, 88);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(92, 17);
this.radioButton4.TabIndex = 1;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "VBA Accurate";
this.radioButton4.UseVisualStyleBackColor = true;
this.radioButton4.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(6, 42);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(48, 17);
this.radioButton2.TabIndex = 1;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "Vivid";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(6, 19);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(71, 17);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Gambatte";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.bmpView1);
this.groupBox2.Location = new System.Drawing.Point(150, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(268, 153);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Preview";
//
// bmpView1
//
this.bmpView1.Location = new System.Drawing.Point(6, 19);
this.bmpView1.Name = "bmpView1";
this.bmpView1.Size = new System.Drawing.Size(256, 128);
this.bmpView1.TabIndex = 3;
this.bmpView1.Text = "bmpView1";
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.buttonOK.Location = new System.Drawing.Point(263, 171);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 3;
this.buttonOK.Text = "OK";
this.buttonOK.UseVisualStyleBackColor = true;
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(344, 171);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton6 = new System.Windows.Forms.RadioButton();
this.radioButton5 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.bmpView1 = new BizHawk.Client.EmuHawk.BmpView();
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.radioButton7 = new System.Windows.Forms.RadioButton();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButton7);
this.groupBox1.Controls.Add(this.radioButton6);
this.groupBox1.Controls.Add(this.radioButton5);
this.groupBox1.Controls.Add(this.radioButton3);
this.groupBox1.Controls.Add(this.radioButton4);
this.groupBox1.Controls.Add(this.radioButton2);
this.groupBox1.Controls.Add(this.radioButton1);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(132, 182);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Preset Select";
this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// radioButton6
//
this.radioButton6.AutoSize = true;
this.radioButton6.Location = new System.Drawing.Point(6, 134);
this.radioButton6.Name = "radioButton6";
this.radioButton6.Size = new System.Drawing.Size(47, 17);
this.radioButton6.TabIndex = 3;
this.radioButton6.TabStop = true;
this.radioButton6.Text = "GBA";
this.radioButton6.UseVisualStyleBackColor = true;
this.radioButton6.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton5
//
this.radioButton5.AutoSize = true;
this.radioButton5.Location = new System.Drawing.Point(6, 111);
this.radioButton5.Name = "radioButton5";
this.radioButton5.Size = new System.Drawing.Size(117, 17);
this.radioButton5.TabIndex = 2;
this.radioButton5.TabStop = true;
this.radioButton5.Text = "VBA Accurate (Old)";
this.radioButton5.UseVisualStyleBackColor = true;
this.radioButton5.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(6, 65);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(72, 17);
this.radioButton3.TabIndex = 2;
this.radioButton3.TabStop = true;
this.radioButton3.Text = "VBA Vivid";
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.Location = new System.Drawing.Point(6, 88);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(92, 17);
this.radioButton4.TabIndex = 1;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "VBA Accurate";
this.radioButton4.UseVisualStyleBackColor = true;
this.radioButton4.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(6, 42);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(48, 17);
this.radioButton2.TabIndex = 1;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "Vivid";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(6, 19);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(71, 17);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Gambatte";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.bmpView1);
this.groupBox2.Location = new System.Drawing.Point(150, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(268, 153);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Preview";
//
// bmpView1
//
this.bmpView1.Location = new System.Drawing.Point(6, 19);
this.bmpView1.Name = "bmpView1";
this.bmpView1.Size = new System.Drawing.Size(256, 128);
this.bmpView1.TabIndex = 3;
this.bmpView1.Text = "bmpView1";
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.buttonOK.Location = new System.Drawing.Point(263, 171);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 3;
this.buttonOK.Text = "OK";
this.buttonOK.UseVisualStyleBackColor = true;
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(344, 171);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// radioButton7
//
this.radioButton7.AutoSize = true;
this.radioButton7.Location = new System.Drawing.Point(6, 157);
this.radioButton7.Name = "radioButton7";
this.radioButton7.Size = new System.Drawing.Size(85, 17);
this.radioButton7.TabIndex = 4;
this.radioButton7.TabStop = true;
this.radioButton7.Text = "Libretro GBC";
this.radioButton7.UseVisualStyleBackColor = true;
this.radioButton7.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// CGBColorChooserForm
//
this.AcceptButton = this.buttonOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(431, 206);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.gambatte_MultiSize;
this.Name = "CGBColorChooserForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Game Boy Color Palette Config";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(431, 206);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "CGBColorChooserForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Game Boy Color Palette Config";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -206,5 +220,6 @@
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.RadioButton radioButton6;
private System.Windows.Forms.RadioButton radioButton7;
}
}

View File

@ -39,6 +39,9 @@ namespace BizHawk.Client.EmuHawk
case GBColors.ColorType.gba:
radioButton6.Checked = true;
break;
case GBColors.ColorType.libretrogbc:
radioButton7.Checked = true;
break;
}
}
@ -101,6 +104,11 @@ namespace BizHawk.Client.EmuHawk
_type = GBColors.ColorType.gba;
}
if (sender == radioButton7)
{
_type = GBColors.ColorType.libretrogbc;
}
if (sender is RadioButton radioButton && radioButton.Checked)
{
RefreshType();
@ -117,5 +125,10 @@ namespace BizHawk.Client.EmuHawk
s.CGBColors = dlg._type;
}
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
}
}

View File

@ -51,12 +51,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public static Triple GambatteColor(Triple c)
{
Triple ret;
ret.r = (c.r * 13 + c.g * 2 + c.b) >> 1;
ret.g = (c.g * 3 + c.b) << 1;
ret.b = (c.r * 3 + c.g * 2 + c.b * 11) >> 1;
return ret;
}
public static Triple LibretroGBCColor(Triple c)
{
Triple ret;
ret.r = (c.r * 13 + c.g * 2 + c.b) >> 1;
ret.g = (c.g * 3 + c.b) << 1;
ret.b = (c.r * 3 + c.g * 2 + c.b * 11) >> 1;
double gammaR = Math.Pow((double)c.r / 31, 2.2);
double gammaG = Math.Pow((double)c.g / 31, 2.2);
double gammaB = Math.Pow((double)c.b / 31, 2.2);
ret.r = (int)(Math.Pow(gammaR * .87 + gammaG * .18 - gammaB * .05, 1/ 2.2) * 255 + .5);
ret.g = (int)(Math.Pow(gammaG * .66 + gammaR * .115 + gammaB * .225, 1/ 2.2) * 255 + .5);
ret.b = (int)(Math.Pow(gammaB * .79 + gammaR * .14 + gammaG * .07, 1/ 2.2) * 255 + .5);
ret.r = (int)(Math.Pow(gammaR * .87 + gammaG * .18 - gammaB * .05, 1 / 2.2) * 255 + .5);
ret.g = (int)(Math.Pow(gammaG * .66 + gammaR * .115 + gammaB * .225, 1 / 2.2) * 255 + .5);
ret.b = (int)(Math.Pow(gammaB * .79 + gammaR * .14 + gammaG * .07, 1 / 2.2) * 255 + .5);
ret.r = Math.Max(0, Math.Min(255, ret.r));
ret.g = Math.Max(0, Math.Min(255, ret.g));
ret.b = Math.Max(0, Math.Min(255, ret.b));
@ -130,7 +142,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
vbavivid,
vbagbnew,
vbabgbold,
gba
gba,
libretrogbc
}
public static int[] GetLut(ColorType c)
@ -151,6 +164,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
case ColorType.vbagbnew: f = NewVBAColor; break;
case ColorType.vbabgbold: f = OldVBAColor; break;
case ColorType.gba: f = GBAColor; break;
case ColorType.libretrogbc: f = LibretroGBCColor; break;
}
int i = 0;