GB config dialogs cleanup

This commit is contained in:
adelikat 2017-05-31 08:52:55 -05:00
parent f84065a45a
commit 1164868063
18 changed files with 341 additions and 329 deletions

View File

@ -1324,7 +1324,7 @@ namespace BizHawk.Client.EmuHawk
{
Global.Config = ConfigService.Load<Config>(PathManager.DefaultIniPath);
Global.Config.ResolveDefaults();
InitControls(); //rebind hotkeys
InitControls(); // rebind hotkeys
GlobalWin.OSD.AddMessage("Config file loaded: " + PathManager.DefaultIniPath);
}
@ -1343,7 +1343,7 @@ namespace BizHawk.Client.EmuHawk
{
Global.Config = ConfigService.Load<Config>(ofd.FileName);
Global.Config.ResolveDefaults();
InitControls(); //rebind hotkeys
InitControls(); // rebind hotkeys
GlobalWin.OSD.AddMessage("Config file loaded: " + ofd.FileName);
}
}
@ -1988,7 +1988,7 @@ namespace BizHawk.Client.EmuHawk
private void GBCoreSettingsMenuItem_Click(object sender, EventArgs e)
{
config.GB.GBPrefs.DoGBPrefsDialog(this);
GBPrefs.DoGBPrefsDialog(this);
}
private void LoadGbInSgbMenuItem_Click(object sender, EventArgs e)
@ -2294,7 +2294,7 @@ namespace BizHawk.Client.EmuHawk
private void DgbSettingsMenuItem_Click(object sender, EventArgs e)
{
config.GB.DGBPrefs.DoDGBPrefsDialog(this);
DGBPrefs.DoDGBPrefsDialog(this);
}
#endregion

View File

@ -11,19 +11,18 @@ using BizHawk.Client.EmuHawk.WinFormExtensions;
namespace BizHawk.Client.EmuHawk
{
public partial class BmpView : Control
public class BmpView : Control
{
[Browsable(false)]
public Bitmap bmp { get; private set; }
public Bitmap BMP { get; private set; }
bool scaled;
private bool _scaled;
public BmpView()
{
if (Process.GetCurrentProcess().ProcessName == "devenv")
{
// in the designer
//this.BackColor = Color.Black;
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
}
else
@ -33,29 +32,29 @@ namespace BizHawk.Client.EmuHawk
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, true);
this.BackColor = Color.Transparent;
this.Paint += new PaintEventHandler(BmpView_Paint);
this.SizeChanged += new EventHandler(BmpView_SizeChanged);
BackColor = Color.Transparent;
Paint += BmpView_Paint;
SizeChanged += BmpView_SizeChanged;
ChangeBitmapSize(1, 1);
}
}
void BmpView_SizeChanged(object sender, EventArgs e)
private void BmpView_SizeChanged(object sender, EventArgs e)
{
scaled = !(bmp.Width == Width && bmp.Height == Height);
_scaled = !(BMP.Width == Width && BMP.Height == Height);
}
void BmpView_Paint(object sender, PaintEventArgs e)
private void BmpView_Paint(object sender, PaintEventArgs e)
{
if (scaled)
if (_scaled)
{
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
e.Graphics.DrawImage(bmp, 0, 0, Width, Height);
e.Graphics.DrawImage(BMP, 0, 0, Width, Height);
}
else
{
e.Graphics.DrawImageUnscaled(bmp, 0, 0);
e.Graphics.DrawImageUnscaled(BMP, 0, 0);
}
}
@ -66,22 +65,26 @@ namespace BizHawk.Client.EmuHawk
public void ChangeBitmapSize(int w, int h)
{
if (bmp != null)
if (BMP != null)
{
if (w == bmp.Width && h == bmp.Height)
if (w == BMP.Width && h == BMP.Height)
{
return;
bmp.Dispose();
}
BMP.Dispose();
}
bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
BMP = new Bitmap(w, h, PixelFormat.Format32bppArgb);
BmpView_SizeChanged(null, null);
Refresh();
}
public void Clear()
{
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var lockdata = BMP.LockBits(new Rectangle(0, 0, BMP.Width, BMP.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Win32.MemSet(lockdata.Scan0, 0xff, (uint)(lockdata.Height * lockdata.Stride));
bmp.UnlockBits(lockdata);
BMP.UnlockBits(lockdata);
Refresh();
}
@ -113,7 +116,7 @@ namespace BizHawk.Client.EmuHawk
}
var file = new FileInfo(sfd.FileName);
var b = this.bmp;
var b = BMP;
ImageFormat i;
string extension = file.Extension.ToUpper();

View File

@ -69,7 +69,7 @@
this.radioButton6.TabStop = true;
this.radioButton6.Text = "GBA";
this.radioButton6.UseVisualStyleBackColor = true;
this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
this.radioButton6.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton5
//
@ -81,7 +81,7 @@
this.radioButton5.TabStop = true;
this.radioButton5.Text = "VBA Accurate (Old)";
this.radioButton5.UseVisualStyleBackColor = true;
this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
this.radioButton5.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton3
//
@ -93,7 +93,7 @@
this.radioButton3.TabStop = true;
this.radioButton3.Text = "VBA Vivid";
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
this.radioButton3.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton4
//
@ -105,7 +105,7 @@
this.radioButton4.TabStop = true;
this.radioButton4.Text = "VBA Accurate";
this.radioButton4.UseVisualStyleBackColor = true;
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
this.radioButton4.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton2
//
@ -117,7 +117,7 @@
this.radioButton2.TabStop = true;
this.radioButton2.Text = "Vivid";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
this.radioButton2.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// radioButton1
//
@ -129,7 +129,7 @@
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Gambatte";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
this.radioButton1.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
//
// groupBox2
//
@ -187,7 +187,6 @@
this.Name = "CGBColorChooserForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Game Boy Color Palette Config";
this.Load += new System.EventHandler(this.CGBColorChooserForm_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);

View File

@ -2,40 +2,51 @@
using System.Drawing;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
namespace BizHawk.Client.EmuHawk
{
public partial class CGBColorChooserForm : Form
{
CGBColorChooserForm()
private CGBColorChooserForm()
{
InitializeComponent();
bmpView1.ChangeBitmapSize(new Size(256, 128));
}
void LoadType(Gameboy.GambatteSettings s)
private GBColors.ColorType _type;
private void LoadType(Gameboy.GambatteSettings s)
{
type = s.CGBColors;
switch (type)
_type = s.CGBColors;
switch (_type)
{
case GBColors.ColorType.gambatte: radioButton1.Checked = true; break;
case GBColors.ColorType.vivid: radioButton2.Checked = true; break;
case GBColors.ColorType.vbavivid: radioButton3.Checked = true; break;
case GBColors.ColorType.vbagbnew: radioButton4.Checked = true; break;
case GBColors.ColorType.vbabgbold: radioButton5.Checked = true; break;
case GBColors.ColorType.gba: radioButton6.Checked = true; break;
case GBColors.ColorType.gambatte:
radioButton1.Checked = true;
break;
case GBColors.ColorType.vivid:
radioButton2.Checked = true;
break;
case GBColors.ColorType.vbavivid:
radioButton3.Checked = true;
break;
case GBColors.ColorType.vbagbnew:
radioButton4.Checked = true;
break;
case GBColors.ColorType.vbabgbold:
radioButton5.Checked = true;
break;
case GBColors.ColorType.gba:
radioButton6.Checked = true;
break;
}
}
GBColors.ColorType type;
unsafe void RefreshType()
private unsafe void RefreshType()
{
var lockdata = bmpView1.bmp.LockBits(new Rectangle(0, 0, 256, 128), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
var lockdata = bmpView1.BMP.LockBits(new Rectangle(0, 0, 256, 128), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int[] lut = GBColors.GetLut(type);
int[] lut = GBColors.GetLut(_type);
int* dest = (int*)lockdata.Scan0;
@ -45,35 +56,56 @@ namespace BizHawk.Client.EmuHawk
{
int r = i % 32;
int g = j % 32;
int b = i / 32 * 4 + j / 32;
int b = (i / 32 * 4) + (j / 32);
int color = lut[r | g << 5 | b << 10];
*dest++ = color;
}
dest -= 256;
dest += lockdata.Stride / sizeof(int);
}
bmpView1.bmp.UnlockBits(lockdata);
bmpView1.BMP.UnlockBits(lockdata);
bmpView1.Refresh();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
private void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (sender == radioButton1)
type = GBColors.ColorType.gambatte;
{
_type = GBColors.ColorType.gambatte;
}
if (sender == radioButton2)
type = GBColors.ColorType.vivid;
{
_type = GBColors.ColorType.vivid;
}
if (sender == radioButton3)
type = GBColors.ColorType.vbavivid;
{
_type = GBColors.ColorType.vbavivid;
}
if (sender == radioButton4)
type = GBColors.ColorType.vbagbnew;
{
_type = GBColors.ColorType.vbagbnew;
}
if (sender == radioButton5)
type = GBColors.ColorType.vbabgbold;
{
_type = GBColors.ColorType.vbabgbold;
}
if (sender == radioButton6)
type = GBColors.ColorType.gba;
var radio_button = sender as RadioButton;
if (radio_button != null && radio_button.Checked)
{
_type = GBColors.ColorType.gba;
}
var radioButton = sender as RadioButton;
if (radioButton != null && radioButton.Checked)
{
RefreshType();
}
}
public static void DoCGBColorChoserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s)
@ -81,33 +113,12 @@ namespace BizHawk.Client.EmuHawk
using (var dlg = new CGBColorChooserForm())
{
dlg.LoadType(s);
var result = dlg.ShowDialog(parent);
if (result == DialogResult.OK)
s.CGBColors = dlg.type;
}
}
public static void DoCGBColorChooserFormDialog(IWin32Window parent)
{
using (var dlg = new CGBColorChooserForm())
{
var gb = Global.Emulator as Gameboy;
dlg.LoadType(gb.GetSettings());
var result = dlg.ShowDialog(parent);
if (result == DialogResult.OK)
{
var s = gb.GetSettings();
s.CGBColors = dlg.type;
gb.PutSettings(s);
s.CGBColors = dlg._type;
}
}
}
private void CGBColorChooserForm_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -62,7 +62,7 @@
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(40, 32);
this.panel1.TabIndex = 0;
this.panel1.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel1.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel2
//
@ -71,7 +71,7 @@
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(40, 32);
this.panel2.TabIndex = 1;
this.panel2.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel2.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel3
//
@ -80,7 +80,7 @@
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(40, 32);
this.panel3.TabIndex = 2;
this.panel3.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel3.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel4
//
@ -89,7 +89,7 @@
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(40, 32);
this.panel4.TabIndex = 3;
this.panel4.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel4.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel5
//
@ -98,7 +98,7 @@
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(40, 32);
this.panel5.TabIndex = 4;
this.panel5.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel5.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel6
//
@ -107,7 +107,7 @@
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(40, 32);
this.panel6.TabIndex = 5;
this.panel6.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel6.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel7
//
@ -116,7 +116,7 @@
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(40, 32);
this.panel7.TabIndex = 6;
this.panel7.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel7.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel8
//
@ -125,7 +125,7 @@
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(40, 32);
this.panel8.TabIndex = 7;
this.panel8.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel8.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel9
//
@ -134,7 +134,7 @@
this.panel9.Name = "panel9";
this.panel9.Size = new System.Drawing.Size(40, 32);
this.panel9.TabIndex = 8;
this.panel9.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel9.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel10
//
@ -143,7 +143,7 @@
this.panel10.Name = "panel10";
this.panel10.Size = new System.Drawing.Size(40, 32);
this.panel10.TabIndex = 9;
this.panel10.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel10.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel11
//
@ -152,7 +152,7 @@
this.panel11.Name = "panel11";
this.panel11.Size = new System.Drawing.Size(40, 32);
this.panel11.TabIndex = 10;
this.panel11.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel11.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// panel12
//
@ -161,7 +161,7 @@
this.panel12.Name = "panel12";
this.panel12.Size = new System.Drawing.Size(40, 32);
this.panel12.TabIndex = 11;
this.panel12.DoubleClick += new System.EventHandler(this.panel12_DoubleClick);
this.panel12.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
//
// label1
//
@ -200,7 +200,7 @@
this.OK.TabIndex = 22;
this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click);
this.OK.Click += new System.EventHandler(this.Ok_Click);
//
// Cancel
//
@ -221,7 +221,7 @@
this.buttonInterpolateBG.TabIndex = 25;
this.buttonInterpolateBG.Text = "Interpolate";
this.buttonInterpolateBG.UseVisualStyleBackColor = true;
this.buttonInterpolateBG.Click += new System.EventHandler(this.button3_Click);
this.buttonInterpolateBG.Click += new System.EventHandler(this.Button3_Click);
//
// buttonInterpolateSP1
//
@ -231,7 +231,7 @@
this.buttonInterpolateSP1.TabIndex = 26;
this.buttonInterpolateSP1.Text = "Interpolate";
this.buttonInterpolateSP1.UseVisualStyleBackColor = true;
this.buttonInterpolateSP1.Click += new System.EventHandler(this.button4_Click);
this.buttonInterpolateSP1.Click += new System.EventHandler(this.Button4_Click);
//
// buttonInterpolateSP2
//
@ -241,7 +241,7 @@
this.buttonInterpolateSP2.TabIndex = 27;
this.buttonInterpolateSP2.Text = "Interpolate";
this.buttonInterpolateSP2.UseVisualStyleBackColor = true;
this.buttonInterpolateSP2.Click += new System.EventHandler(this.button5_Click);
this.buttonInterpolateSP2.Click += new System.EventHandler(this.Button5_Click);
//
// buttonLoad
//
@ -251,7 +251,7 @@
this.buttonLoad.TabIndex = 28;
this.buttonLoad.Text = "&Load...";
this.buttonLoad.UseVisualStyleBackColor = true;
this.buttonLoad.Click += new System.EventHandler(this.button6_Click);
this.buttonLoad.Click += new System.EventHandler(this.Button6_Click);
//
// buttonSave
//
@ -261,7 +261,7 @@
this.buttonSave.TabIndex = 29;
this.buttonSave.Text = "&Save...";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.button7_Click);
this.buttonSave.Click += new System.EventHandler(this.Button7_Click);
//
// DefaultButton
//
@ -320,7 +320,6 @@
this.Name = "ColorChooserForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Game Boy Palette Config";
this.Load += new System.EventHandler(this.ColorChooserForm_Load);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.ColorChooserForm_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.ColorChooserForm_DragEnter);
this.ResumeLayout(false);

View File

@ -11,27 +11,23 @@ namespace BizHawk.Client.EmuHawk
{
public partial class ColorChooserForm : Form
{
ColorChooserForm()
private ColorChooserForm()
{
InitializeComponent();
}
private readonly Color[] colors = new Color[12];
private readonly Color[] _colors = new Color[12];
/// <summary>
/// gambatte's default dmg colors
/// </summary>
static readonly int[] DefaultCGBColors =
// gambatte's default dmg colors
private static readonly int[] DefaultCGBColors =
{
0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000,
0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000,
0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000
};
/// <summary>
/// bsnes's default dmg colors with slight tweaking
/// </summary>
static readonly int[] DefaultDMGColors =
// bsnes's default dmg colors with slight tweaking
private static readonly int[] DefaultDMGColors =
{
10798341, 8956165, 1922333, 337157,
10798341, 8956165, 1922333, 337157,
@ -40,83 +36,84 @@ namespace BizHawk.Client.EmuHawk
private void RefreshAllBackdrops()
{
panel1.BackColor = colors[0];
panel2.BackColor = colors[1];
panel3.BackColor = colors[2];
panel4.BackColor = colors[3];
panel5.BackColor = colors[4];
panel6.BackColor = colors[5];
panel7.BackColor = colors[6];
panel8.BackColor = colors[7];
panel9.BackColor = colors[8];
panel10.BackColor = colors[9];
panel11.BackColor = colors[10];
panel12.BackColor = colors[11];
panel1.BackColor = _colors[0];
panel2.BackColor = _colors[1];
panel3.BackColor = _colors[2];
panel4.BackColor = _colors[3];
panel5.BackColor = _colors[4];
panel6.BackColor = _colors[5];
panel7.BackColor = _colors[6];
panel8.BackColor = _colors[7];
panel9.BackColor = _colors[8];
panel10.BackColor = _colors[9];
panel11.BackColor = _colors[10];
panel12.BackColor = _colors[11];
}
Color betweencolor(Color left, Color right, double pos)
private Color Betweencolor(Color left, Color right, double pos)
{
int R = (int)(right.R * pos + left.R * (1.0 - pos) + 0.5);
int G = (int)(right.G * pos + left.G * (1.0 - pos) + 0.5);
int B = (int)(right.B * pos + left.B * (1.0 - pos) + 0.5);
int A = (int)(right.A * pos + left.A * (1.0 - pos) + 0.5);
int r = (int)(right.R * pos + left.R * (1.0 - pos) + 0.5);
int g = (int)(right.G * pos + left.G * (1.0 - pos) + 0.5);
int b = (int)(right.B * pos + left.B * (1.0 - pos) + 0.5);
int a = (int)(right.A * pos + left.A * (1.0 - pos) + 0.5);
return Color.FromArgb(A, R, G, B);
return Color.FromArgb(a, r, g, b);
}
void interpolate_colors(int firstindex, int lastindex)
private void InterpolateColors(int firstindex, int lastindex)
{
for (int i = firstindex + 1; i < lastindex; i++)
{
double pos = (i - firstindex) / (double)(lastindex - firstindex);
colors[i] = betweencolor(colors[firstindex], colors[lastindex], pos);
_colors[i] = Betweencolor(_colors[firstindex], _colors[lastindex], pos);
}
RefreshAllBackdrops();
}
private void button3_Click(object sender, EventArgs e)
private void Button3_Click(object sender, EventArgs e)
{
interpolate_colors(0, 3);
InterpolateColors(0, 3);
}
private void button4_Click(object sender, EventArgs e)
private void Button4_Click(object sender, EventArgs e)
{
interpolate_colors(4, 7);
InterpolateColors(4, 7);
}
private void button5_Click(object sender, EventArgs e)
private void Button5_Click(object sender, EventArgs e)
{
interpolate_colors(8, 11);
InterpolateColors(8, 11);
}
private void panel12_DoubleClick(object _sender, EventArgs e)
private void Panel12_DoubleClick(object sender, EventArgs e)
{
Panel sender = (Panel)_sender;
Panel psender = (Panel)sender;
int i;
if (sender == panel1)
if (psender == panel1)
i = 0;
else if (sender == panel2)
else if (psender == panel2)
i = 1;
else if (sender == panel3)
else if (psender == panel3)
i = 2;
else if (sender == panel4)
else if (psender == panel4)
i = 3;
else if (sender == panel5)
else if (psender == panel5)
i = 4;
else if (sender == panel6)
else if (psender == panel6)
i = 5;
else if (sender == panel7)
else if (psender == panel7)
i = 6;
else if (sender == panel8)
else if (psender == panel8)
i = 7;
else if (sender == panel9)
else if (psender == panel9)
i = 8;
else if (sender == panel10)
else if (psender == panel10)
i = 9;
else if (sender == panel11)
else if (psender == panel11)
i = 10;
else if (sender == panel12)
else if (psender == panel12)
i = 11;
else
return; // i = -1;
@ -125,14 +122,16 @@ namespace BizHawk.Client.EmuHawk
{
dlg.AllowFullOpen = true;
dlg.AnyColor = true;
dlg.Color = colors[i];
dlg.Color = _colors[i];
// custom colors are ints, not Color structs?
// and they don't work right unless the alpha bits are set to 0
// and the rgb order is switched
int[] customs = new int[12];
for (int j = 0; j < customs.Length; j++)
customs[j] = colors[j].R | colors[j].G << 8 | colors[j].B << 16;
{
customs[j] = _colors[j].R | _colors[j].G << 8 | _colors[j].B << 16;
}
dlg.CustomColors = customs;
dlg.FullOpen = true;
@ -141,19 +140,17 @@ namespace BizHawk.Client.EmuHawk
if (result == DialogResult.OK)
{
if (colors[i] != dlg.Color)
if (_colors[i] != dlg.Color)
{
colors[i] = dlg.Color;
sender.BackColor = colors[i];
_colors[i] = dlg.Color;
psender.BackColor = _colors[i];
}
}
}
}
/// <summary>
/// ini keys for gambatte palette file
/// </summary>
private static readonly string[] paletteinikeys =
// ini keys for gambatte palette file
private static readonly string[] Paletteinikeys =
{
"Background0",
"Background1",
@ -172,18 +169,20 @@ namespace BizHawk.Client.EmuHawk
/// <summary>
/// load gambatte-style .pal file
/// </summary>
/// <param name="f"></param>
/// <returns>null on failure</returns>
public static int[] LoadPalFile(TextReader f)
{
Dictionary<string, int> lines = new Dictionary<string, int>();
var lines = new Dictionary<string, int>();
string line;
while ((line = f.ReadLine()) != null)
{
int i = line.IndexOf('=');
if (i < 0)
{
continue;
}
try
{
lines.Add(line.Substring(0, i), int.Parse(line.Substring(i + 1)));
@ -197,44 +196,49 @@ namespace BizHawk.Client.EmuHawk
try
{
for (int i = 0; i < 12; i++)
ret[i] = lines[paletteinikeys[i]];
{
ret[i] = lines[Paletteinikeys[i]];
}
}
catch (KeyNotFoundException)
{
return null;
}
return ret;
}
/// <summary>
/// save gambatte-style palette file
/// </summary>
/// <param name="f"></param>
/// <param name="colors"></param>
public static void SavePalFile(TextWriter f, int[] colors)
// save gambatte-style palette file
private static void SavePalFile(TextWriter f, int[] colors)
{
f.WriteLine("[General]");
for (int i = 0; i < 12; i++)
f.WriteLine(String.Format("{0}={1}", paletteinikeys[i], colors[i]));
{
f.WriteLine($"{Paletteinikeys[i]}={colors[i]}");
}
}
void SetAllColors(int[] _colors)
private void SetAllColors(int[] colors)
{
// fix alpha to 255 in created color objects, else problems
for (int i = 0; i < colors.Length; i++)
for (int i = 0; i < _colors.Length; i++)
{
colors[i] = Color.FromArgb(255, Color.FromArgb(_colors[i]));
_colors[i] = Color.FromArgb(255, Color.FromArgb(colors[i]));
}
RefreshAllBackdrops();
}
static void DoColorChooserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s, bool fromemu)
private static void DoColorChooserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s, bool fromemu)
{
using (var dlg = new ColorChooserForm())
{
var gb = Global.Emulator as Gameboy;
if (fromemu)
{
s = gb.GetSettings();
}
dlg.SetAllColors(s.GBPalette);
var result = dlg.ShowDialog(parent);
@ -242,34 +246,35 @@ namespace BizHawk.Client.EmuHawk
{
int[] colorints = new int[12];
for (int i = 0; i < 12; i++)
colorints[i] = dlg.colors[i].ToArgb();
{
colorints[i] = dlg._colors[i].ToArgb();
}
s.GBPalette = colorints;
if (fromemu)
{
gb.PutSettings(s);
}
}
}
}
public static void DoColorChooserFormDialog(IWin32Window parent)
{
DoColorChooserFormDialog(parent, null, true);
}
public static void DoColorChooserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s)
{
DoColorChooserFormDialog(parent, s, false);
}
void LoadColorFile(string filename, bool alert)
private void LoadColorFile(string filename, bool alert)
{
try
{
using (StreamReader f = new StreamReader(filename))
using (var f = new StreamReader(filename))
{
int[] newcolors = LoadPalFile(f);
if (newcolors == null)
{
throw new Exception();
}
SetAllColors(newcolors);
}
@ -277,20 +282,25 @@ namespace BizHawk.Client.EmuHawk
catch
{
if (alert)
{
MessageBox.Show(this, "Error loading .pal file!");
}
}
}
void SaveColorFile(string filename)
private void SaveColorFile(string filename)
{
try
{
using (StreamWriter f = new StreamWriter(filename))
using (var f = new StreamWriter(filename))
{
int[] savecolors = new int[12];
for (int i = 0; i < 12; i++)
{
// clear alpha because gambatte color files don't usually contain it
savecolors[i] = colors[i].ToArgb() & 0xffffff;
savecolors[i] = _colors[i].ToArgb() & 0xffffff;
}
SavePalFile(f, savecolors);
}
}
@ -300,7 +310,7 @@ namespace BizHawk.Client.EmuHawk
}
}
private void button6_Click(object sender, EventArgs e)
private void Button6_Click(object sender, EventArgs e)
{
using (var ofd = new OpenFileDialog())
{
@ -310,7 +320,9 @@ namespace BizHawk.Client.EmuHawk
var result = ofd.ShowDialog(this);
if (result == DialogResult.OK)
{
LoadColorFile(ofd.FileName, true);
}
}
}
@ -318,23 +330,25 @@ namespace BizHawk.Client.EmuHawk
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length > 1)
{
return;
}
LoadColorFile(files[0], true);
}
}
private void ColorChooserForm_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop)
? DragDropEffects.Move
: DragDropEffects.None;
}
private void button7_Click(object sender, EventArgs e)
private void Button7_Click(object sender, EventArgs e)
{
using (var sfd = new SaveFileDialog())
{
@ -345,11 +359,13 @@ namespace BizHawk.Client.EmuHawk
sfd.RestoreDirectory = true;
var result = sfd.ShowDialog(this);
if (result == DialogResult.OK)
{
SaveColorFile(sfd.FileName);
}
}
}
private void OK_Click(object sender, EventArgs e)
private void Ok_Click(object sender, EventArgs e)
{
}
@ -362,10 +378,5 @@ namespace BizHawk.Client.EmuHawk
{
SetAllColors(DefaultCGBColors);
}
private void ColorChooserForm_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -1,4 +1,4 @@
namespace BizHawk.Client.EmuHawk.config.GB
namespace BizHawk.Client.EmuHawk
{
partial class DGBPrefs
{
@ -31,9 +31,9 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DGBPrefs));
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.gbPrefControl1 = new BizHawk.Client.EmuHawk.config.GB.GBPrefControl();
this.gbPrefControl1 = new GBPrefControl();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.gbPrefControl2 = new BizHawk.Client.EmuHawk.config.GB.GBPrefControl();
this.gbPrefControl2 = new GBPrefControl();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();

View File

@ -1,30 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk.config.GB
namespace BizHawk.Client.EmuHawk
{
public partial class DGBPrefs : Form
{
DGBPrefs()
private DGBPrefs()
{
InitializeComponent();
}
void PutSettings(GambatteLink.GambatteLinkSettings s, GambatteLink.GambatteLinkSyncSettings ss)
private void PutSettings(GambatteLink.GambatteLinkSettings s, GambatteLink.GambatteLinkSyncSettings ss)
{
gbPrefControl1.PutSettings(s.L, ss.L);
gbPrefControl2.PutSettings(s.R, ss.R);
}
void GetSettings(out GambatteLink.GambatteLinkSettings s, out GambatteLink.GambatteLinkSyncSettings ss)
private void GetSettings(out GambatteLink.GambatteLinkSettings s, out GambatteLink.GambatteLinkSyncSettings ss)
{
Gameboy.GambatteSettings sl;
Gameboy.GambatteSyncSettings ssl;
@ -37,13 +31,7 @@ namespace BizHawk.Client.EmuHawk.config.GB
ss = new GambatteLink.GambatteLinkSyncSettings(ssl, ssr);
}
private bool SyncSettingsChanged
{
get
{
return gbPrefControl1.SyncSettingsChanged || gbPrefControl2.SyncSettingsChanged;
}
}
private bool SyncSettingsChanged => gbPrefControl1.SyncSettingsChanged || gbPrefControl2.SyncSettingsChanged;
public static void DoDGBPrefsDialog(IWin32Window owner)
{
@ -64,7 +52,9 @@ namespace BizHawk.Client.EmuHawk.config.GB
dlg.GetSettings(out s, out ss);
gambatte.PutSettings(s);
if (dlg.SyncSettingsChanged)
{
GlobalWin.MainForm.PutCoreSyncSettings(ss);
}
}
}
}

View File

@ -1,4 +1,4 @@
namespace BizHawk.Client.EmuHawk.config.GB
namespace BizHawk.Client.EmuHawk
{
partial class GBPrefControl
{
@ -48,7 +48,7 @@
this.propertyGrid1.Size = new System.Drawing.Size(338, 279);
this.propertyGrid1.TabIndex = 0;
this.propertyGrid1.ToolbarVisible = false;
this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged);
this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.PropertyGrid1_PropertyValueChanged);
//
// buttonDefaults
//
@ -59,7 +59,7 @@
this.buttonDefaults.TabIndex = 1;
this.buttonDefaults.Text = "Defaults";
this.buttonDefaults.UseVisualStyleBackColor = true;
this.buttonDefaults.Click += new System.EventHandler(this.buttonDefaults_Click);
this.buttonDefaults.Click += new System.EventHandler(this.ButtonDefaults_Click);
//
// buttonPalette
//
@ -70,7 +70,7 @@
this.buttonPalette.TabIndex = 2;
this.buttonPalette.Text = "Palette...";
this.buttonPalette.UseVisualStyleBackColor = true;
this.buttonPalette.Click += new System.EventHandler(this.buttonPalette_Click);
this.buttonPalette.Click += new System.EventHandler(this.ButtonPalette_Click);
//
// checkBoxMuted
//
@ -82,7 +82,7 @@
this.checkBoxMuted.TabIndex = 3;
this.checkBoxMuted.Text = "Mute";
this.checkBoxMuted.UseVisualStyleBackColor = true;
this.checkBoxMuted.CheckedChanged += new System.EventHandler(this.checkBoxMuted_CheckedChanged);
this.checkBoxMuted.CheckedChanged += new System.EventHandler(this.CheckBoxMuted_CheckedChanged);
//
// cbDisplayBG
//
@ -94,7 +94,7 @@
this.cbDisplayBG.TabIndex = 4;
this.cbDisplayBG.Text = "BG";
this.cbDisplayBG.UseVisualStyleBackColor = true;
this.cbDisplayBG.CheckedChanged += new System.EventHandler(this.cbDisplayBG_CheckedChanged);
this.cbDisplayBG.CheckedChanged += new System.EventHandler(this.CbDisplayBG_CheckedChanged);
//
// cbDisplayOBJ
//
@ -106,7 +106,7 @@
this.cbDisplayOBJ.TabIndex = 5;
this.cbDisplayOBJ.Text = "OBJ";
this.cbDisplayOBJ.UseVisualStyleBackColor = true;
this.cbDisplayOBJ.CheckedChanged += new System.EventHandler(this.cbDisplayOBJ_CheckedChanged);
this.cbDisplayOBJ.CheckedChanged += new System.EventHandler(this.CbDisplayOBJ_CheckedChanged);
//
// cbDisplayWIN
//
@ -118,7 +118,7 @@
this.cbDisplayWIN.TabIndex = 6;
this.cbDisplayWIN.Text = "WIN";
this.cbDisplayWIN.UseVisualStyleBackColor = true;
this.cbDisplayWIN.CheckedChanged += new System.EventHandler(this.cbDisplayWIN_CheckedChanged);
this.cbDisplayWIN.CheckedChanged += new System.EventHandler(this.CbDisplayWin_CheckedChanged);
//
// GBPrefControl
//

View File

@ -1,16 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk.config.GB
namespace BizHawk.Client.EmuHawk
{
public partial class GBPrefControl : UserControl
{
@ -21,68 +16,75 @@ namespace BizHawk.Client.EmuHawk.config.GB
[Browsable(false)]
public bool ColorGameBoy { get; set; }
[Browsable(false)]
public bool SyncSettingsChanged { get; private set; }
Gameboy.GambatteSettings s;
Gameboy.GambatteSyncSettings ss;
private Gameboy.GambatteSettings _s;
private Gameboy.GambatteSyncSettings _ss;
public void PutSettings(Gameboy.GambatteSettings s, Gameboy.GambatteSyncSettings ss)
{
this.s = s ?? new Gameboy.GambatteSettings();
this.ss = ss ?? new Gameboy.GambatteSyncSettings();
propertyGrid1.SelectedObject = this.ss;
_s = s ?? new Gameboy.GambatteSettings();
_ss = ss ?? new Gameboy.GambatteSyncSettings();
propertyGrid1.SelectedObject = _ss;
propertyGrid1.Enabled = !Global.MovieSession.Movie.IsActive;
checkBoxMuted.Checked = this.s.Muted;
cbDisplayBG.Checked = this.s.DisplayBG;
cbDisplayOBJ.Checked = this.s.DisplayOBJ;
cbDisplayWIN.Checked = this.s.DisplayWindow;
checkBoxMuted.Checked = _s.Muted;
cbDisplayBG.Checked = _s.DisplayBG;
cbDisplayOBJ.Checked = _s.DisplayOBJ;
cbDisplayWIN.Checked = _s.DisplayWindow;
}
public void GetSettings(out Gameboy.GambatteSettings s, out Gameboy.GambatteSyncSettings ss)
{
s = this.s;
ss = this.ss;
s = _s;
ss = _ss;
}
private void buttonDefaults_Click(object sender, EventArgs e)
private void ButtonDefaults_Click(object sender, EventArgs e)
{
PutSettings(null, Global.MovieSession.Movie.IsActive ? ss : null);
PutSettings(null, Global.MovieSession.Movie.IsActive ? _ss : null);
if (!Global.MovieSession.Movie.IsActive)
{
SyncSettingsChanged = true;
}
}
private void buttonPalette_Click(object sender, EventArgs e)
private void ButtonPalette_Click(object sender, EventArgs e)
{
if (ColorGameBoy)
CGBColorChooserForm.DoCGBColorChoserFormDialog(this.ParentForm, s);
{
CGBColorChooserForm.DoCGBColorChoserFormDialog(ParentForm, _s);
}
else
ColorChooserForm.DoColorChooserFormDialog(this.ParentForm, s);
{
ColorChooserForm.DoColorChooserFormDialog(ParentForm, _s);
}
}
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
private void PropertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
SyncSettingsChanged = true;
}
private void checkBoxMuted_CheckedChanged(object sender, EventArgs e)
private void CheckBoxMuted_CheckedChanged(object sender, EventArgs e)
{
s.Muted = (sender as CheckBox).Checked;
_s.Muted = ((CheckBox)sender).Checked;
}
private void cbDisplayBG_CheckedChanged(object sender, EventArgs e)
private void CbDisplayBG_CheckedChanged(object sender, EventArgs e)
{
s.DisplayBG = (sender as CheckBox).Checked;
_s.DisplayBG = ((CheckBox)sender).Checked;
}
private void cbDisplayOBJ_CheckedChanged(object sender, EventArgs e)
private void CbDisplayOBJ_CheckedChanged(object sender, EventArgs e)
{
s.DisplayOBJ = (sender as CheckBox).Checked;
_s.DisplayOBJ = ((CheckBox)sender).Checked;
}
private void cbDisplayWIN_CheckedChanged(object sender, EventArgs e)
private void CbDisplayWin_CheckedChanged(object sender, EventArgs e)
{
s.DisplayWindow = (sender as CheckBox).Checked;
_s.DisplayWindow = ((CheckBox)sender).Checked;
}
}
}

View File

@ -1,4 +1,4 @@
namespace BizHawk.Client.EmuHawk.config.GB
namespace BizHawk.Client.EmuHawk
{
partial class GBPrefs
{
@ -31,7 +31,7 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GBPrefs));
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.gbPrefControl1 = new BizHawk.Client.EmuHawk.config.GB.GBPrefControl();
this.gbPrefControl1 = new GBPrefControl();
this.SuspendLayout();
//
// buttonOK

View File

@ -1,26 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk.config.GB
namespace BizHawk.Client.EmuHawk
{
public partial class GBPrefs : Form
{
public GBPrefs()
private GBPrefs()
{
InitializeComponent();
}
public static void DoGBPrefsDialog(IWin32Window owner)
{
var gb = ((Gameboy)Global.Emulator);
var gb = (Gameboy)Global.Emulator;
var s = gb.GetSettings();
var ss = gb.GetSyncSettings();
@ -33,7 +27,9 @@ namespace BizHawk.Client.EmuHawk.config.GB
dlg.gbPrefControl1.GetSettings(out s, out ss);
gb.PutSettings(s);
if (dlg.gbPrefControl1.SyncSettingsChanged)
{
GlobalWin.MainForm.PutCoreSyncSettings(ss);
}
}
}
}

View File

@ -378,14 +378,14 @@ namespace BizHawk.Client.EmuHawk
if (!_cgb)
{
DrawBGDMG(
bmpViewBG.bmp,
bmpViewBG.BMP,
_vram + (lcdc.Bit(3) ? 0x1c00 : 0x1800),
_vram + (lcdc.Bit(4) ? 0x0000 : 0x1000),
!lcdc.Bit(4),
_bgpal);
DrawBGDMG(
bmpViewWin.bmp,
bmpViewWin.BMP,
_vram + (lcdc.Bit(6) ? 0x1c00 : 0x1800),
_vram + 0x1000, // force win to second tile bank???
true,
@ -394,14 +394,14 @@ namespace BizHawk.Client.EmuHawk
else
{
DrawBGCGB(
bmpViewBG.bmp,
bmpViewBG.BMP,
_vram + (lcdc.Bit(3) ? 0x1c00 : 0x1800),
_vram + (lcdc.Bit(4) ? 0x0000 : 0x1000),
!lcdc.Bit(4),
_bgpal);
DrawBGCGB(
bmpViewWin.bmp,
bmpViewWin.BMP,
_vram + (lcdc.Bit(6) ? 0x1c00 : 0x1800),
_vram + 0x1000, // force win to second tile bank???
true,
@ -413,11 +413,11 @@ namespace BizHawk.Client.EmuHawk
// tile display
// TODO: user selects palette to use, instead of fixed palette 0
// or possibly "smart" where, if a tile is in use, it's drawn with one of the palettes actually being used with it?
DrawTiles(bmpViewTiles1.bmp, _vram, tilespal);
DrawTiles(bmpViewTiles1.BMP, _vram, tilespal);
bmpViewTiles1.Refresh();
if (_cgb)
{
DrawTiles(bmpViewTiles2.bmp, _vram + 0x2000, tilespal);
DrawTiles(bmpViewTiles2.BMP, _vram + 0x2000, tilespal);
bmpViewTiles2.Refresh();
}
@ -430,8 +430,8 @@ namespace BizHawk.Client.EmuHawk
bmpViewSPPal.ChangeBitmapSize(8, 4);
if (bmpViewSPPal.Width != 128)
bmpViewSPPal.Width = 128;
DrawPal(bmpViewBGPal.bmp, _bgpal, 8);
DrawPal(bmpViewSPPal.bmp, _sppal, 8);
DrawPal(bmpViewBGPal.BMP, _bgpal, 8);
DrawPal(bmpViewSPPal.BMP, _sppal, 8);
}
else
{
@ -441,8 +441,8 @@ namespace BizHawk.Client.EmuHawk
bmpViewSPPal.ChangeBitmapSize(2, 4);
if (bmpViewSPPal.Width != 32)
bmpViewSPPal.Width = 32;
DrawPal(bmpViewBGPal.bmp, _bgpal, 1);
DrawPal(bmpViewSPPal.bmp, _sppal, 2);
DrawPal(bmpViewBGPal.BMP, _bgpal, 1);
DrawPal(bmpViewSPPal.BMP, _sppal, 2);
}
bmpViewBGPal.Refresh();
bmpViewSPPal.Refresh();
@ -460,7 +460,7 @@ namespace BizHawk.Client.EmuHawk
if (bmpViewOAM.Height != 8)
bmpViewOAM.Height = 8;
}
DrawOam(bmpViewOAM.bmp, _oam, _vram, _sppal, lcdc.Bit(2), _cgb);
DrawOam(bmpViewOAM.BMP, _oam, _vram, _sppal, lcdc.Bit(2), _cgb);
bmpViewOAM.Refresh();
// try to run the current mouseover, to refresh if the mouse is being held over a pane while the emulator runs
@ -586,7 +586,7 @@ namespace BizHawk.Client.EmuHawk
_freezeLabel = groupBoxDetails.Text;
if (_freezeBmp != null)
_freezeBmp.Dispose();
_freezeBmp = (Bitmap)bmpViewDetails.bmp.Clone();
_freezeBmp = (Bitmap)bmpViewDetails.BMP.Clone();
_freezeDetails = labelDetails.Text;
}
@ -595,7 +595,7 @@ namespace BizHawk.Client.EmuHawk
groupBoxDetails.Text = _freezeLabel;
bmpViewDetails.Height = _freezeBmp.Height * 8;
bmpViewDetails.ChangeBitmapSize(_freezeBmp.Size);
using (var g = Graphics.FromImage(bmpViewDetails.bmp))
using (var g = Graphics.FromImage(bmpViewDetails.BMP))
g.DrawImageUnscaled(_freezeBmp, 0, 0);
labelDetails.Text = _freezeDetails;
bmpViewDetails.Refresh();
@ -605,9 +605,9 @@ namespace BizHawk.Client.EmuHawk
{
groupBoxMemory.Text = groupBoxDetails.Text;
bmpViewMemory.Size = bmpViewDetails.Size;
bmpViewMemory.ChangeBitmapSize(bmpViewDetails.bmp.Size);
using (var g = Graphics.FromImage(bmpViewMemory.bmp))
g.DrawImageUnscaled(bmpViewDetails.bmp, 0, 0);
bmpViewMemory.ChangeBitmapSize(bmpViewDetails.BMP.Size);
using (var g = Graphics.FromImage(bmpViewMemory.BMP))
g.DrawImageUnscaled(bmpViewDetails.BMP, 0, 0);
labelMemory.Text = labelDetails.Text;
bmpViewMemory.Refresh();
}
@ -627,7 +627,7 @@ namespace BizHawk.Client.EmuHawk
sb.AppendLine(string.Format("Color {0}", y));
sb.AppendLine(string.Format("(R,G,B) = ({0},{1},{2})", color >> 16 & 255, color >> 8 & 255, color & 255));
var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, 10), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, 10), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int);
@ -643,7 +643,7 @@ namespace BizHawk.Client.EmuHawk
dest -= 8;
dest += pitch;
}
bmpViewDetails.bmp.UnlockBits(lockdata);
bmpViewDetails.BMP.UnlockBits(lockdata);
labelDetails.Text = sb.ToString();
bmpViewDetails.Refresh();
}
@ -664,9 +664,9 @@ namespace BizHawk.Client.EmuHawk
else
sb.AppendLine(string.Format("Tile #{0} @{1:x4}", tileindex, tileoffs + 0x8000));
var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
DrawTile((byte*)_vram + tileoffs + (secondbank ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)tilespal);
bmpViewDetails.bmp.UnlockBits(lockdata);
bmpViewDetails.BMP.UnlockBits(lockdata);
labelDetails.Text = sb.ToString();
bmpViewDetails.Refresh();
}
@ -688,7 +688,7 @@ namespace BizHawk.Client.EmuHawk
if (tileindex < 128)
tileindex += 256; // compute all if from 0x8000 base
int tileoffs = tileindex * 16;
var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
if (!_cgb)
{
sb.AppendLine(string.Format("{0} Map ({1},{2}) @{3:x4}", win ? "Win" : "BG", x, y, mapoffs + 0x8000));
@ -705,7 +705,7 @@ namespace BizHawk.Client.EmuHawk
sb.AppendLine(string.Format(" Flags {0}{1}{2}", tileext.Bit(5) ? 'H' : ' ', tileext.Bit(6) ? 'V' : ' ', tileext.Bit(7) ? 'P' : ' '));
DrawTileHv((byte*)_vram + tileoffs + (tileext.Bit(3) ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_bgpal + 4 * (tileext & 7), tileext.Bit(5), tileext.Bit(6));
}
bmpViewDetails.bmp.UnlockBits(lockdata);
bmpViewDetails.BMP.UnlockBits(lockdata);
labelDetails.Text = sb.ToString();
bmpViewDetails.Refresh();
}
@ -716,8 +716,8 @@ namespace BizHawk.Client.EmuHawk
x /= 8;
y /= 8;
bmpViewDetails.ChangeBitmapSize(8, tall ? 16 : 8);
if (bmpViewDetails.Height != bmpViewDetails.bmp.Height * 8)
bmpViewDetails.Height = bmpViewDetails.bmp.Height * 8;
if (bmpViewDetails.Height != bmpViewDetails.BMP.Height * 8)
bmpViewDetails.Height = bmpViewDetails.BMP.Height * 8;
var sb = new StringBuilder();
byte* oament = (byte*)_oam + 4 * x;
@ -732,7 +732,7 @@ namespace BizHawk.Client.EmuHawk
int tileoffs = tilenum * 16;
sb.AppendLine(string.Format("Sprite #{0} @{1:x4}", x, 4 * x + 0xfe00));
sb.AppendLine(string.Format(" (x,y) = ({0},{1})", sx, sy));
var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, tall ? 16 : 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, tall ? 16 : 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
if (_cgb)
{
sb.AppendLine(string.Format(" Tile #{0} @{2}:{1:x4}", y == 1 ? tilenum ^ 1 : tilenum, tileoffs + 0x8000, flags.Bit(3) ? 1 : 0));
@ -750,7 +750,7 @@ namespace BizHawk.Client.EmuHawk
DrawTileHv((byte*)_vram + (tileoffs ^ 16), (int*)(lockdata.Scan0 + lockdata.Stride * 8), lockdata.Stride / sizeof(int), (int*)_sppal + 4 * (flags.Bit(4) ? 4 : 0), hflip, vflip);
}
sb.AppendLine(string.Format(" Flags {0}{1}{2}", hflip ? 'H' : ' ', vflip ? 'V' : ' ', flags.Bit(7) ? 'P' : ' '));
bmpViewDetails.bmp.UnlockBits(lockdata);
bmpViewDetails.BMP.UnlockBits(lockdata);
labelDetails.Text = sb.ToString();
bmpViewDetails.Refresh();
}
@ -909,7 +909,7 @@ namespace BizHawk.Client.EmuHawk
if (found is BmpView)
{
var bv = found as BmpView;
Clipboard.SetImage(bv.bmp);
Clipboard.SetImage(bv.BMP);
labelClipboard.Text = found.Text + " copied to clipboard.";
_messagetimer.Stop();
_messagetimer.Start();

View File

@ -170,7 +170,7 @@ namespace BizHawk.Client.EmuHawk
case 2: mbv.ChangeAllSizes(256, 512); break;
case 3: mbv.ChangeAllSizes(512, 512); break;
}
Bitmap bmp = mbv.BmpView.bmp;
Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0;
@ -229,7 +229,7 @@ namespace BizHawk.Client.EmuHawk
case 2: mbv.ChangeAllSizes(512, 512); break;
case 3: mbv.ChangeAllSizes(1024, 1024); break;
}
Bitmap bmp = mbv.BmpView.bmp;
Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0;
@ -257,7 +257,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawM3BG(MobileBmpView mbv)
{
mbv.ChangeAllSizes(240, 160);
Bitmap bmp = mbv.BmpView.bmp;
Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0;
@ -280,7 +280,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawM4BG(MobileBmpView mbv, bool secondframe)
{
mbv.ChangeAllSizes(240, 160);
Bitmap bmp = mbv.BmpView.bmp;
Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0;
@ -304,7 +304,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawM5BG(MobileBmpView mbv, bool secondframe)
{
mbv.ChangeAllSizes(160, 128);
Bitmap bmp = mbv.BmpView.bmp;
Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0;
@ -406,7 +406,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawSprites(MobileBmpView mbv)
{
mbv.BmpView.ChangeBitmapSize(1024, 512);
Bitmap bmp = mbv.BmpView.bmp;
Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// Clear()
Win32.MemSet(lockdata.Scan0, 0xff, (uint)(lockdata.Height * lockdata.Stride));
@ -439,7 +439,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawPalette(MobileBmpView mbv, bool sprite)
{
mbv.BmpView.ChangeBitmapSize(16, 16);
Bitmap bmp = mbv.BmpView.bmp;
Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0;
@ -489,7 +489,7 @@ namespace BizHawk.Client.EmuHawk
int th = tophalfonly ? 16 : 32;
mbv.BmpView.ChangeBitmapSize(tw * 8, 256);
Bitmap bmp = mbv.BmpView.bmp;
Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0;
@ -516,7 +516,7 @@ namespace BizHawk.Client.EmuHawk
int th = 32;
mbv.BmpView.ChangeBitmapSize(tw * 8, th * 8);
Bitmap bmp = mbv.BmpView.bmp;
Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0;
@ -837,7 +837,7 @@ namespace BizHawk.Client.EmuHawk
if (found is BmpView)
{
Clipboard.SetImage((found as BmpView).bmp);
Clipboard.SetImage((found as BmpView).BMP);
labelClipboard.Text = found.Text + " copied to clipboard.";
timerMessage.Stop();
timerMessage.Start();

View File

@ -60,7 +60,7 @@ namespace BizHawk.Client.EmuHawk
bv.Size = pixsize;
bv.ChangeBitmapSize(pixsize);
var lockdata = bv.bmp.LockBits(new Rectangle(Point.Empty, pixsize), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var lockdata = bv.BMP.LockBits(new Rectangle(Point.Empty, pixsize), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int pitch = lockdata.Stride / sizeof(int);
int* dest = (int*)lockdata.Scan0;
@ -77,13 +77,13 @@ namespace BizHawk.Client.EmuHawk
dest -= 8 * tilew;
dest += 8 * pitch;
}
bv.bmp.UnlockBits(lockdata);
bv.BMP.UnlockBits(lockdata);
bv.Refresh();
}
unsafe void DrawPalettes(int *pal)
{
var lockdata = bmpViewPal.bmp.LockBits(new Rectangle(0, 0, 16, 4), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var lockdata = bmpViewPal.BMP.LockBits(new Rectangle(0, 0, 16, 4), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int pitch = lockdata.Stride / sizeof(int);
int* dest = (int*)lockdata.Scan0;
@ -93,13 +93,13 @@ namespace BizHawk.Client.EmuHawk
*dest++ = *pal++;
dest += pitch - 16;
}
bmpViewPal.bmp.UnlockBits(lockdata);
bmpViewPal.BMP.UnlockBits(lockdata);
bmpViewPal.Refresh();
}
unsafe void DrawTiles()
{
var lockdata = bmpViewTiles.bmp.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var lockdata = bmpViewTiles.BMP.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int pitch = lockdata.Stride / sizeof(int);
int* dest = (int*)lockdata.Scan0;
byte* src = (byte*)View.PatternCache;
@ -115,7 +115,7 @@ namespace BizHawk.Client.EmuHawk
if ((tile & 63) == 0)
dest += 8 * pitch - 512;
}
bmpViewTiles.bmp.UnlockBits(lockdata);
bmpViewTiles.BMP.UnlockBits(lockdata);
bmpViewTiles.Refresh();
}
@ -186,7 +186,7 @@ namespace BizHawk.Client.EmuHawk
if (found is BmpView)
{
var bv = found as BmpView;
Clipboard.SetImage(bv.bmp);
Clipboard.SetImage(bv.BMP);
}
}
}

View File

@ -76,7 +76,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawSprites()
{
var lockdata = bmpViewSP.bmp.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var lockdata = bmpViewSP.BMP.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int);
@ -92,12 +92,12 @@ namespace BizHawk.Client.EmuHawk
Draw16x16(src + srcaddr, dest + destaddr, pitch, pal);
}
}
bmpViewSP.bmp.UnlockBits(lockdata);
bmpViewSP.BMP.UnlockBits(lockdata);
}
unsafe void DrawBacks()
{
var lockdata = bmpViewBG.bmp.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var lockdata = bmpViewBG.BMP.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int);
@ -113,15 +113,15 @@ namespace BizHawk.Client.EmuHawk
Draw8x8(src + srcaddr, dest + destaddr, pitch, pal);
}
}
bmpViewBG.bmp.UnlockBits(lockdata);
bmpViewBG.BMP.UnlockBits(lockdata);
}
unsafe void DrawPalettes()
{
fixed (int* pal = vce.Palette)
{
DrawPalette(bmpViewBGPal.bmp, pal);
DrawPalette(bmpViewSPPal.bmp, pal + 256);
DrawPalette(bmpViewBGPal.BMP, pal);
DrawPalette(bmpViewSPPal.BMP, pal + 256);
}
}
@ -211,7 +211,7 @@ namespace BizHawk.Client.EmuHawk
if (found is BmpView)
{
var bv = found as BmpView;
Clipboard.SetImage(bv.bmp);
Clipboard.SetImage(bv.BMP);
}
}
}

View File

@ -65,7 +65,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawTiles(int *pal)
{
var lockdata = bmpViewTiles.bmp.LockBits(new Rectangle(0, 0, 256, 128), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var lockdata = bmpViewTiles.BMP.LockBits(new Rectangle(0, 0, 256, 128), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int);
@ -80,7 +80,7 @@ namespace BizHawk.Client.EmuHawk
Draw8x8(src + srcaddr, dest + destaddr, pitch, pal);
}
}
bmpViewTiles.bmp.UnlockBits(lockdata);
bmpViewTiles.BMP.UnlockBits(lockdata);
bmpViewTiles.Refresh();
}
@ -88,13 +88,13 @@ namespace BizHawk.Client.EmuHawk
{
int bgheight = vdp.FrameHeight == 192 ? 224 : 256;
int maxtile = bgheight * 4;
if (bgheight != bmpViewBG.bmp.Height)
if (bgheight != bmpViewBG.BMP.Height)
{
bmpViewBG.Height = bgheight;
bmpViewBG.ChangeBitmapSize(256, bgheight);
}
var lockdata = bmpViewBG.bmp.LockBits(new Rectangle(0, 0, 256, bgheight), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var lockdata = bmpViewBG.BMP.LockBits(new Rectangle(0, 0, 256, bgheight), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int);
@ -116,13 +116,13 @@ namespace BizHawk.Client.EmuHawk
Draw8x8hv(src + srcaddr, dest + destaddr, pitch, tpal, hflip, vflip);
}
}
bmpViewBG.bmp.UnlockBits(lockdata);
bmpViewBG.BMP.UnlockBits(lockdata);
bmpViewBG.Refresh();
}
unsafe void DrawPal(int* pal)
{
var lockdata = bmpViewPalette.bmp.LockBits(new Rectangle(0, 0, 16, 2), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var lockdata = bmpViewPalette.BMP.LockBits(new Rectangle(0, 0, 16, 2), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int);
@ -135,7 +135,7 @@ namespace BizHawk.Client.EmuHawk
dest -= 16;
dest += pitch;
}
bmpViewPalette.bmp.UnlockBits(lockdata);
bmpViewPalette.BMP.UnlockBits(lockdata);
bmpViewPalette.Refresh();
}
@ -204,7 +204,7 @@ namespace BizHawk.Client.EmuHawk
if (found is BmpView)
{
var bv = found as BmpView;
Clipboard.SetImage(bv.bmp);
Clipboard.SetImage(bv.BMP);
}
}
}

View File

@ -55,6 +55,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CRC/@EntryIndexedValue">CRC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DB/@EntryIndexedValue">DB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DC/@EntryIndexedValue">DC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DGB/@EntryIndexedValue">DGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DMG/@EntryIndexedValue">DMG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GB/@EntryIndexedValue">GB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GBA/@EntryIndexedValue">GBA</s:String>