snes-hookup ui for color palette selection

This commit is contained in:
zeromus 2012-11-25 20:06:31 +00:00
parent 7a6f5fcf99
commit 57e9619ff6
7 changed files with 326 additions and 209 deletions

View File

@ -373,6 +373,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
return test;
}
public SnesColors.ColorType CurrPalette { get; private set; }
public void SetPalette(SnesColors.ColorType pal)
{
CurrPalette = pal;
int[] tmp = SnesColors.GetLUT(pal);
fixed (int* p = &tmp[0])
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_color_lut((IntPtr)p);
}
public LibsnesCore()
{
}
@ -411,10 +421,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
scanlineStart_cb = new LibsnesDll.snes_scanlineStart_t(snes_scanlineStart);
// set palette
int[] tmp = SnesColors.GetLUT(SnesColors.ColorType.Bizhawk);
fixed (int* p = &tmp[0])
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_color_lut((IntPtr)p);
// set default palette. Should be overridden by frontend probably
SetPalette(SnesColors.ColorType.BizHawk);
// start up audio resampler

View File

@ -362,9 +362,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
return ScreenInfo.GetScreenInfo();
}
//the same basic color table that libsnes uses to convert from snes 555 to rgba32
public static int[] colortable;
static int[] directColorTable = new int[256]; //8bpp gfx -> rgb555
static SNESGraphicsDecoder()
{
@ -380,13 +378,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
int color = (b << 10) | (g << 5) | r;
directColorTable[i] = color;
}
colortable = SnesColors.GetLUT(SnesColors.ColorType.Bizhawk);
}
int[] colortable;
public byte* vram, oam;
public ushort* cgram, vram16;
public SNESGraphicsDecoder()
public SNESGraphicsDecoder(SnesColors.ColorType pal)
{
colortable = SnesColors.GetLUT(pal);
IntPtr block = LibsnesDll.snes_get_memory_data(LibsnesDll.SNES_MEMORY.VRAM);
vram = (byte*)block;
vram16 = (ushort*)block;

View File

@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
// none of this is optimized for speed because we make a LUT at load time
public static void BizColor(out int or, out int og, out int ob, int l, int r, int g, int b)
public static void BsnesColor(out int or, out int og, out int ob, int l, int r, int g, int b)
{
// bizhawk through r3808, from bsnes
double luma = (double)l / 15.0;
@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
ob = ab * 255 / 31;
}
public static void NattColor(out int or, out int og, out int ob, int l, int r, int g, int b)
public static void BizColor(out int or, out int og, out int ob, int l, int r, int g, int b)
{
// bizhawk r3809. assumes that luma mixing is done in analog
or = (r * l * 17 + 15) / 31;
@ -81,12 +81,39 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
public enum ColorType
{
Bizhawk,
Natt,
BizHawk,
BSNES,
Snes9x
};
//I separated these out to try and make them lazy construct, but it didnt work. try it some other way later.
public static class BIZCOLOR
{
public static int[] palette = GenLUT(ColorType.BizHawk);
}
public static class SNES9XCOLOR
{
public static int[] palette = GenLUT(ColorType.Snes9x);
}
public static class BSNESCOLOR
{
public static int[] palette = GenLUT(ColorType.BSNES);
}
public static int[] GetLUT(ColorType t)
{
if (t == ColorType.Snes9x)
return SNES9XCOLOR.palette;
else if (t == ColorType.BizHawk)
return BIZCOLOR.palette;
else
return BSNESCOLOR.palette;
}
static int[] GenLUT(ColorType t)
{
int[] ret = new int[16 * 32768];
for (int l = 0; l < 16; l++)
@ -100,10 +127,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
int ar, ag, ab;
if (t == ColorType.Snes9x)
Snes9xColor(out ar, out ag, out ab, l, r, g, b);
else if (t == ColorType.Natt)
NattColor(out ar, out ag, out ab, l, r, g, b);
else
else if (t == ColorType.BizHawk)
BizColor(out ar, out ag, out ab, l, r, g, b);
else
BsnesColor(out ar, out ag, out ab, l, r, g, b);
int color = (ar << 16) + (ag << 8) + (ab << 0) | unchecked((int)0xFF000000);
ret[(l << 15) + (b << 10) + (g << 5) + (r << 0)] = color;
}

View File

@ -456,6 +456,7 @@ namespace BizHawk.MultiClient
public int SNESGraphicsDebuggerRefreshRate = 4;
public bool SNESGraphicsUseUserBackdropColor = false;
public int SNESGraphicsUserBackdropColor = -1;
public string SNESPalette = "BizHawk";
// SNES Graphics settings
//bsnes allows the layers to be enabled for each priority level.

View File

@ -1908,6 +1908,12 @@ namespace BizHawk.MultiClient
Global.Game = game;
SyncControls();
if (nextEmulator is LibsnesCore)
{
var snes = nextEmulator as LibsnesCore;
snes.SetPalette((SnesColors.ColorType)Enum.Parse(typeof(SnesColors.ColorType), Global.Config.SNESPalette, false));
}
if (game.System == "NES")
{
NES nes = Global.Emulator as NES;

View File

@ -41,6 +41,20 @@
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.panel1 = new System.Windows.Forms.Panel();
this.comboPalette = new System.Windows.Forms.ComboBox();
this.groupBox7 = new System.Windows.Forms.GroupBox();
this.txtOBSELT1OfsBits = new System.Windows.Forms.TextBox();
this.txtOBSELT1OfsDescr = new System.Windows.Forms.TextBox();
this.label30 = new System.Windows.Forms.Label();
this.txtOBSELBaseBits = new System.Windows.Forms.TextBox();
this.txtOBSELBaseDescr = new System.Windows.Forms.TextBox();
this.label29 = new System.Windows.Forms.Label();
this.txtOBSELSizeBits = new System.Windows.Forms.TextBox();
this.label26 = new System.Windows.Forms.Label();
this.txtOBSELSizeDescr = new System.Windows.Forms.TextBox();
this.label28 = new System.Windows.Forms.Label();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.labelClipboard = new System.Windows.Forms.Label();
this.label24 = new System.Windows.Forms.Label();
this.pnBackdropColor = new System.Windows.Forms.Panel();
this.checkBackdropColor = new System.Windows.Forms.CheckBox();
@ -134,6 +148,7 @@
this.radioButton5 = new System.Windows.Forms.RadioButton();
this.radioButton10 = new System.Windows.Forms.RadioButton();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.paletteViewer = new BizHawk.MultiClient.SNESGraphicsViewer();
this.tabctrlDetails = new System.Windows.Forms.TabControl();
this.tpPalette = new System.Windows.Forms.TabPage();
this.txtPaletteDetailsIndexSpecific = new System.Windows.Forms.TextBox();
@ -148,28 +163,16 @@
this.pnDetailsPaletteColor = new System.Windows.Forms.Panel();
this.lblDetailsPaletteAddress = new System.Windows.Forms.Label();
this.tpTile = new System.Windows.Forms.TabPage();
this.viewerPanel = new System.Windows.Forms.Panel();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.labelClipboard = new System.Windows.Forms.Label();
this.messagetimer = new System.Windows.Forms.Timer(this.components);
this.label26 = new System.Windows.Forms.Label();
this.txtOBSELSizeDescr = new System.Windows.Forms.TextBox();
this.label28 = new System.Windows.Forms.Label();
this.txtOBSELSizeBits = new System.Windows.Forms.TextBox();
this.groupBox7 = new System.Windows.Forms.GroupBox();
this.txtOBSELBaseBits = new System.Windows.Forms.TextBox();
this.txtOBSELBaseDescr = new System.Windows.Forms.TextBox();
this.label29 = new System.Windows.Forms.Label();
this.txtOBSELT1OfsBits = new System.Windows.Forms.TextBox();
this.txtOBSELT1OfsDescr = new System.Windows.Forms.TextBox();
this.label30 = new System.Windows.Forms.Label();
this.paletteViewer = new BizHawk.MultiClient.SNESGraphicsViewer();
this.viewerTile = new BizHawk.MultiClient.SNESGraphicsViewer();
this.viewerPanel = new System.Windows.Forms.Panel();
this.viewer = new BizHawk.MultiClient.SNESGraphicsViewer();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.messagetimer = new System.Windows.Forms.Timer(this.components);
this.menuStrip1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.panel1.SuspendLayout();
this.groupBox7.SuspendLayout();
this.groupBox6.SuspendLayout();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudScanline)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.sliderScanline)).BeginInit();
@ -182,8 +185,6 @@
this.tpPalette.SuspendLayout();
this.tpTile.SuspendLayout();
this.viewerPanel.SuspendLayout();
this.groupBox6.SuspendLayout();
this.groupBox7.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
@ -280,6 +281,7 @@
//
this.panel1.AutoSize = true;
this.panel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.panel1.Controls.Add(this.comboPalette);
this.panel1.Controls.Add(this.groupBox7);
this.panel1.Controls.Add(this.groupBox6);
this.panel1.Controls.Add(this.label24);
@ -296,6 +298,153 @@
this.panel1.Size = new System.Drawing.Size(558, 672);
this.panel1.TabIndex = 0;
//
// comboPalette
//
this.comboPalette.DisplayMember = "descr";
this.comboPalette.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboPalette.FormattingEnabled = true;
this.comboPalette.Location = new System.Drawing.Point(108, 588);
this.comboPalette.Name = "comboPalette";
this.comboPalette.Size = new System.Drawing.Size(121, 21);
this.comboPalette.TabIndex = 52;
this.comboPalette.ValueMember = "type";
this.comboPalette.SelectedIndexChanged += new System.EventHandler(this.comboPalette_SelectedIndexChanged);
//
// groupBox7
//
this.groupBox7.Controls.Add(this.txtOBSELT1OfsBits);
this.groupBox7.Controls.Add(this.txtOBSELT1OfsDescr);
this.groupBox7.Controls.Add(this.label30);
this.groupBox7.Controls.Add(this.txtOBSELBaseBits);
this.groupBox7.Controls.Add(this.txtOBSELBaseDescr);
this.groupBox7.Controls.Add(this.label29);
this.groupBox7.Controls.Add(this.txtOBSELSizeBits);
this.groupBox7.Controls.Add(this.label26);
this.groupBox7.Controls.Add(this.txtOBSELSizeDescr);
this.groupBox7.Controls.Add(this.label28);
this.groupBox7.Location = new System.Drawing.Point(1, 419);
this.groupBox7.Name = "groupBox7";
this.groupBox7.Size = new System.Drawing.Size(228, 114);
this.groupBox7.TabIndex = 51;
this.groupBox7.TabStop = false;
this.groupBox7.Text = "OBJ";
//
// txtOBSELT1OfsBits
//
this.txtOBSELT1OfsBits.BackColor = System.Drawing.Color.LightGreen;
this.txtOBSELT1OfsBits.Location = new System.Drawing.Point(12, 72);
this.txtOBSELT1OfsBits.Multiline = true;
this.txtOBSELT1OfsBits.Name = "txtOBSELT1OfsBits";
this.txtOBSELT1OfsBits.ReadOnly = true;
this.txtOBSELT1OfsBits.Size = new System.Drawing.Size(15, 17);
this.txtOBSELT1OfsBits.TabIndex = 55;
this.txtOBSELT1OfsBits.Text = "00";
//
// txtOBSELT1OfsDescr
//
this.txtOBSELT1OfsDescr.Location = new System.Drawing.Point(77, 72);
this.txtOBSELT1OfsDescr.Multiline = true;
this.txtOBSELT1OfsDescr.Name = "txtOBSELT1OfsDescr";
this.txtOBSELT1OfsDescr.ReadOnly = true;
this.txtOBSELT1OfsDescr.Size = new System.Drawing.Size(80, 18);
this.txtOBSELT1OfsDescr.TabIndex = 54;
//
// label30
//
this.label30.AutoSize = true;
this.label30.Location = new System.Drawing.Point(31, 75);
this.label30.Name = "label30";
this.label30.Size = new System.Drawing.Size(45, 13);
this.label30.TabIndex = 53;
this.label30.Text = "T1.Addr";
//
// txtOBSELBaseBits
//
this.txtOBSELBaseBits.BackColor = System.Drawing.Color.LightGreen;
this.txtOBSELBaseBits.Location = new System.Drawing.Point(12, 51);
this.txtOBSELBaseBits.Multiline = true;
this.txtOBSELBaseBits.Name = "txtOBSELBaseBits";
this.txtOBSELBaseBits.ReadOnly = true;
this.txtOBSELBaseBits.Size = new System.Drawing.Size(15, 17);
this.txtOBSELBaseBits.TabIndex = 52;
this.txtOBSELBaseBits.Text = "00";
//
// txtOBSELBaseDescr
//
this.txtOBSELBaseDescr.Location = new System.Drawing.Point(77, 51);
this.txtOBSELBaseDescr.Multiline = true;
this.txtOBSELBaseDescr.Name = "txtOBSELBaseDescr";
this.txtOBSELBaseDescr.ReadOnly = true;
this.txtOBSELBaseDescr.Size = new System.Drawing.Size(80, 18);
this.txtOBSELBaseDescr.TabIndex = 51;
//
// label29
//
this.label29.AutoSize = true;
this.label29.Location = new System.Drawing.Point(31, 54);
this.label29.Name = "label29";
this.label29.Size = new System.Drawing.Size(47, 13);
this.label29.TabIndex = 50;
this.label29.Text = "TD.Addr";
//
// txtOBSELSizeBits
//
this.txtOBSELSizeBits.BackColor = System.Drawing.Color.LightGreen;
this.txtOBSELSizeBits.Location = new System.Drawing.Point(12, 29);
this.txtOBSELSizeBits.Multiline = true;
this.txtOBSELSizeBits.Name = "txtOBSELSizeBits";
this.txtOBSELSizeBits.ReadOnly = true;
this.txtOBSELSizeBits.Size = new System.Drawing.Size(15, 17);
this.txtOBSELSizeBits.TabIndex = 49;
this.txtOBSELSizeBits.Text = "00";
//
// label26
//
this.label26.AutoSize = true;
this.label26.Location = new System.Drawing.Point(5, 14);
this.label26.Name = "label26";
this.label26.Size = new System.Drawing.Size(42, 13);
this.label26.TabIndex = 45;
this.label26.Text = "OBSEL";
//
// txtOBSELSizeDescr
//
this.txtOBSELSizeDescr.Location = new System.Drawing.Point(77, 29);
this.txtOBSELSizeDescr.Multiline = true;
this.txtOBSELSizeDescr.Name = "txtOBSELSizeDescr";
this.txtOBSELSizeDescr.ReadOnly = true;
this.txtOBSELSizeDescr.Size = new System.Drawing.Size(80, 18);
this.txtOBSELSizeDescr.TabIndex = 48;
this.txtOBSELSizeDescr.Text = "64x32, 32x32";
//
// label28
//
this.label28.AutoSize = true;
this.label28.Location = new System.Drawing.Point(31, 32);
this.label28.Name = "label28";
this.label28.Size = new System.Drawing.Size(27, 13);
this.label28.TabIndex = 47;
this.label28.Text = "Size";
//
// groupBox6
//
this.groupBox6.Controls.Add(this.labelClipboard);
this.groupBox6.Location = new System.Drawing.Point(1, 539);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(228, 43);
this.groupBox6.TabIndex = 50;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "Copy to Clipboard";
//
// labelClipboard
//
this.labelClipboard.AutoSize = true;
this.labelClipboard.Location = new System.Drawing.Point(7, 23);
this.labelClipboard.Name = "labelClipboard";
this.labelClipboard.Size = new System.Drawing.Size(212, 13);
this.labelClipboard.TabIndex = 0;
this.labelClipboard.Text = "CTRL+C copies the pane under the mouse.";
//
// label24
//
this.label24.AutoSize = true;
@ -1335,6 +1484,17 @@
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Palette";
//
// paletteViewer
//
this.paletteViewer.BackColor = System.Drawing.Color.Transparent;
this.paletteViewer.Location = new System.Drawing.Point(6, 14);
this.paletteViewer.Name = "paletteViewer";
this.paletteViewer.Size = new System.Drawing.Size(307, 307);
this.paletteViewer.TabIndex = 18;
this.paletteViewer.TabStop = false;
this.paletteViewer.MouseClick += new System.Windows.Forms.MouseEventHandler(this.paletteViewer_MouseClick);
this.paletteViewer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.paletteViewer_MouseMove);
//
// tabctrlDetails
//
this.tabctrlDetails.Controls.Add(this.tpPalette);
@ -1485,6 +1645,15 @@
this.tpTile.Text = "Tile";
this.tpTile.UseVisualStyleBackColor = true;
//
// viewerTile
//
this.viewerTile.BackColor = System.Drawing.Color.Transparent;
this.viewerTile.Location = new System.Drawing.Point(6, 6);
this.viewerTile.Name = "viewerTile";
this.viewerTile.Size = new System.Drawing.Size(64, 64);
this.viewerTile.TabIndex = 19;
this.viewerTile.TabStop = false;
//
// viewerPanel
//
this.viewerPanel.AutoScroll = true;
@ -1497,172 +1666,6 @@
this.viewerPanel.Size = new System.Drawing.Size(516, 667);
this.viewerPanel.TabIndex = 1;
//
// toolTip1
//
this.toolTip1.AutoPopDelay = 5000;
this.toolTip1.InitialDelay = 250;
this.toolTip1.ReshowDelay = 100;
//
// groupBox6
//
this.groupBox6.Controls.Add(this.labelClipboard);
this.groupBox6.Location = new System.Drawing.Point(1, 539);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(228, 43);
this.groupBox6.TabIndex = 50;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "Copy to Clipboard";
//
// labelClipboard
//
this.labelClipboard.AutoSize = true;
this.labelClipboard.Location = new System.Drawing.Point(7, 23);
this.labelClipboard.Name = "labelClipboard";
this.labelClipboard.Size = new System.Drawing.Size(212, 13);
this.labelClipboard.TabIndex = 0;
this.labelClipboard.Text = "CTRL+C copies the pane under the mouse.";
//
// messagetimer
//
this.messagetimer.Interval = 5000;
this.messagetimer.Tick += new System.EventHandler(this.messagetimer_Tick);
//
// label26
//
this.label26.AutoSize = true;
this.label26.Location = new System.Drawing.Point(5, 14);
this.label26.Name = "label26";
this.label26.Size = new System.Drawing.Size(42, 13);
this.label26.TabIndex = 45;
this.label26.Text = "OBSEL";
//
// txtOBSELSizeDescr
//
this.txtOBSELSizeDescr.Location = new System.Drawing.Point(77, 29);
this.txtOBSELSizeDescr.Multiline = true;
this.txtOBSELSizeDescr.Name = "txtOBSELSizeDescr";
this.txtOBSELSizeDescr.ReadOnly = true;
this.txtOBSELSizeDescr.Size = new System.Drawing.Size(80, 18);
this.txtOBSELSizeDescr.TabIndex = 48;
this.txtOBSELSizeDescr.Text = "64x32, 32x32";
//
// label28
//
this.label28.AutoSize = true;
this.label28.Location = new System.Drawing.Point(31, 32);
this.label28.Name = "label28";
this.label28.Size = new System.Drawing.Size(27, 13);
this.label28.TabIndex = 47;
this.label28.Text = "Size";
//
// txtOBSELSizeBits
//
this.txtOBSELSizeBits.BackColor = System.Drawing.Color.LightGreen;
this.txtOBSELSizeBits.Location = new System.Drawing.Point(12, 29);
this.txtOBSELSizeBits.Multiline = true;
this.txtOBSELSizeBits.Name = "txtOBSELSizeBits";
this.txtOBSELSizeBits.ReadOnly = true;
this.txtOBSELSizeBits.Size = new System.Drawing.Size(15, 17);
this.txtOBSELSizeBits.TabIndex = 49;
this.txtOBSELSizeBits.Text = "00";
//
// groupBox7
//
this.groupBox7.Controls.Add(this.txtOBSELT1OfsBits);
this.groupBox7.Controls.Add(this.txtOBSELT1OfsDescr);
this.groupBox7.Controls.Add(this.label30);
this.groupBox7.Controls.Add(this.txtOBSELBaseBits);
this.groupBox7.Controls.Add(this.txtOBSELBaseDescr);
this.groupBox7.Controls.Add(this.label29);
this.groupBox7.Controls.Add(this.txtOBSELSizeBits);
this.groupBox7.Controls.Add(this.label26);
this.groupBox7.Controls.Add(this.txtOBSELSizeDescr);
this.groupBox7.Controls.Add(this.label28);
this.groupBox7.Location = new System.Drawing.Point(1, 419);
this.groupBox7.Name = "groupBox7";
this.groupBox7.Size = new System.Drawing.Size(228, 114);
this.groupBox7.TabIndex = 51;
this.groupBox7.TabStop = false;
this.groupBox7.Text = "OBJ";
//
// txtOBSELBaseBits
//
this.txtOBSELBaseBits.BackColor = System.Drawing.Color.LightGreen;
this.txtOBSELBaseBits.Location = new System.Drawing.Point(12, 51);
this.txtOBSELBaseBits.Multiline = true;
this.txtOBSELBaseBits.Name = "txtOBSELBaseBits";
this.txtOBSELBaseBits.ReadOnly = true;
this.txtOBSELBaseBits.Size = new System.Drawing.Size(15, 17);
this.txtOBSELBaseBits.TabIndex = 52;
this.txtOBSELBaseBits.Text = "00";
//
// txtOBSELBaseDescr
//
this.txtOBSELBaseDescr.Location = new System.Drawing.Point(77, 51);
this.txtOBSELBaseDescr.Multiline = true;
this.txtOBSELBaseDescr.Name = "txtOBSELBaseDescr";
this.txtOBSELBaseDescr.ReadOnly = true;
this.txtOBSELBaseDescr.Size = new System.Drawing.Size(80, 18);
this.txtOBSELBaseDescr.TabIndex = 51;
//
// label29
//
this.label29.AutoSize = true;
this.label29.Location = new System.Drawing.Point(31, 54);
this.label29.Name = "label29";
this.label29.Size = new System.Drawing.Size(47, 13);
this.label29.TabIndex = 50;
this.label29.Text = "TD.Addr";
//
// txtOBSELT1OfsBits
//
this.txtOBSELT1OfsBits.BackColor = System.Drawing.Color.LightGreen;
this.txtOBSELT1OfsBits.Location = new System.Drawing.Point(12, 72);
this.txtOBSELT1OfsBits.Multiline = true;
this.txtOBSELT1OfsBits.Name = "txtOBSELT1OfsBits";
this.txtOBSELT1OfsBits.ReadOnly = true;
this.txtOBSELT1OfsBits.Size = new System.Drawing.Size(15, 17);
this.txtOBSELT1OfsBits.TabIndex = 55;
this.txtOBSELT1OfsBits.Text = "00";
//
// txtOBSELT1OfsDescr
//
this.txtOBSELT1OfsDescr.Location = new System.Drawing.Point(77, 72);
this.txtOBSELT1OfsDescr.Multiline = true;
this.txtOBSELT1OfsDescr.Name = "txtOBSELT1OfsDescr";
this.txtOBSELT1OfsDescr.ReadOnly = true;
this.txtOBSELT1OfsDescr.Size = new System.Drawing.Size(80, 18);
this.txtOBSELT1OfsDescr.TabIndex = 54;
//
// label30
//
this.label30.AutoSize = true;
this.label30.Location = new System.Drawing.Point(31, 75);
this.label30.Name = "label30";
this.label30.Size = new System.Drawing.Size(45, 13);
this.label30.TabIndex = 53;
this.label30.Text = "T1.Addr";
//
// paletteViewer
//
this.paletteViewer.BackColor = System.Drawing.Color.Transparent;
this.paletteViewer.Location = new System.Drawing.Point(6, 14);
this.paletteViewer.Name = "paletteViewer";
this.paletteViewer.Size = new System.Drawing.Size(307, 307);
this.paletteViewer.TabIndex = 18;
this.paletteViewer.TabStop = false;
this.paletteViewer.MouseClick += new System.Windows.Forms.MouseEventHandler(this.paletteViewer_MouseClick);
this.paletteViewer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.paletteViewer_MouseMove);
//
// viewerTile
//
this.viewerTile.BackColor = System.Drawing.Color.Transparent;
this.viewerTile.Location = new System.Drawing.Point(6, 6);
this.viewerTile.Name = "viewerTile";
this.viewerTile.Size = new System.Drawing.Size(64, 64);
this.viewerTile.TabIndex = 19;
this.viewerTile.TabStop = false;
//
// viewer
//
this.viewer.BackColor = System.Drawing.Color.Transparent;
@ -1675,6 +1678,17 @@
this.viewer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.viewer_MouseMove);
this.viewer.MouseUp += new System.Windows.Forms.MouseEventHandler(this.viewer_MouseUp);
//
// toolTip1
//
this.toolTip1.AutoPopDelay = 5000;
this.toolTip1.InitialDelay = 250;
this.toolTip1.ReshowDelay = 100;
//
// messagetimer
//
this.messagetimer.Interval = 5000;
this.messagetimer.Tick += new System.EventHandler(this.messagetimer_Tick);
//
// SNESGraphicsDebugger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -1694,6 +1708,10 @@
this.tableLayoutPanel1.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.groupBox7.ResumeLayout(false);
this.groupBox7.PerformLayout();
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudScanline)).EndInit();
@ -1712,10 +1730,6 @@
this.tpPalette.PerformLayout();
this.tpTile.ResumeLayout(false);
this.viewerPanel.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
this.groupBox7.ResumeLayout(false);
this.groupBox7.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -1860,5 +1874,6 @@
private System.Windows.Forms.Label label26;
private System.Windows.Forms.TextBox txtOBSELSizeDescr;
private System.Windows.Forms.Label label28;
private System.Windows.Forms.ComboBox comboPalette;
}
}

View File

@ -5,6 +5,8 @@
//TODO - add eDisplayType for BG1-Tiles, BG2-Tiles, etc. which show the tiles available to a BG. more concise than viewing all tiles and illustrating the relevant accessible areas
// . could this apply to the palette too?
//http://stackoverflow.com/questions/1101149/displaying-thumbnail-icons-128x128-pixels-or-larger-in-a-grid-in-listview
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -29,6 +31,7 @@ namespace BizHawk.MultiClient
InitializeComponent();
Closing += (o, e) => SaveConfigSettings();
viewerTile.ScaleImage = true;
viewer.ScaleImage = false;
var displayTypeItems = new List<DisplayTypeItem>();
@ -44,9 +47,18 @@ namespace BizHawk.MultiClient
displayTypeItems.Add(new DisplayTypeItem("Mode7 tiles",eDisplayType.TilesMode7));
displayTypeItems.Add(new DisplayTypeItem("Mode7Ext tiles",eDisplayType.TilesMode7Ext));
displayTypeItems.Add(new DisplayTypeItem("Mode7 tiles (DC)", eDisplayType.TilesMode7DC));
comboDisplayType.DataSource = displayTypeItems;
comboDisplayType.SelectedIndex = 0;
var paletteTypeItems = new List<PaletteTypeItem>();
paletteTypeItems.Add(new PaletteTypeItem("BizHawk Palette", SnesColors.ColorType.BizHawk));
paletteTypeItems.Add(new PaletteTypeItem("bsnes Palette", SnesColors.ColorType.BSNES));
paletteTypeItems.Add(new PaletteTypeItem("Snes9X Palette", SnesColors.ColorType.Snes9x));
suppression = true;
comboPalette.DataSource = paletteTypeItems;
comboPalette.SelectedIndex = 0;
suppression = false;
comboBGProps.SelectedIndex = 0;
tabctrlDetails.SelectedIndex = 1;
@ -126,7 +138,16 @@ namespace BizHawk.MultiClient
{
LibsnesCore core = Global.Emulator as LibsnesCore;
if (currentSnesCore != core && currentSnesCore != null)
{
currentSnesCore.ScanlineHookManager.Unregister(this);
}
if(currentSnesCore != core)
{
suppression = true;
comboPalette.SelectedValue = core.CurrPalette;
suppression = false;
}
currentSnesCore = core;
@ -149,14 +170,14 @@ namespace BizHawk.MultiClient
}
}
SNESGraphicsDecoder gd = new SNESGraphicsDecoder();
SNESGraphicsDecoder gd = new SNESGraphicsDecoder(SnesColors.ColorType.BizHawk);
SNESGraphicsDecoder.ScreenInfo si;
void RegenerateData()
{
gd = null;
if (currentSnesCore == null) return;
gd = new SNESGraphicsDecoder();
gd = NewDecoder();
if(checkBackdropColor.Checked)
gd.SetBackColor(DecodeWinformsColorToSNES(pnBackdropColor.BackColor));
gd.CacheTiles();
@ -371,6 +392,17 @@ namespace BizHawk.MultiClient
}
}
class PaletteTypeItem
{
public SnesColors.ColorType type { get; set; }
public string descr { get; set; }
public PaletteTypeItem(string descr, SnesColors.ColorType type)
{
this.type = type;
this.descr = descr;
}
}
private void comboDisplayType_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateValues();
@ -531,9 +563,16 @@ namespace BizHawk.MultiClient
return ret;
}
SNESGraphicsDecoder NewDecoder()
{
if (currentSnesCore != null)
return new SNESGraphicsDecoder(currentSnesCore.CurrPalette);
else return new SNESGraphicsDecoder(SnesColors.ColorType.BizHawk);
}
void RenderPalette()
{
var gd = new SNESGraphicsDecoder();
var gd = NewDecoder();
lastPalette = gd.GetPalette();
int pixsize = paletteCellSize * 16 + paletteCellSpacing * 17;
@ -585,7 +624,7 @@ namespace BizHawk.MultiClient
void UpdateColorDetails()
{
int rgb555 = lastPalette[lastColorNum];
var gd = new SNESGraphicsDecoder();
var gd = NewDecoder();
int color = gd.Colorize(rgb555);
pnDetailsPaletteColor.BackColor = Color.FromArgb(color);
@ -711,6 +750,7 @@ namespace BizHawk.MultiClient
TileViewerBGState currTileViewerBGState;
int currViewingTile = -1;
int currViewingTileBpp = -1;
int currViewingSprite = -1;
void RenderTileView(bool force=false)
{
//TODO - blech - handle invalid some other way with a dedicated black-setter
@ -759,6 +799,10 @@ namespace BizHawk.MultiClient
int ty = loc.Y / 8;
switch (CurrDisplaySelection)
{
case eDisplayType.Sprites:
//currViewingSprite = tx + ty * 16;
RenderView();
break;
case eDisplayType.Tiles4bpp:
currViewingTileBpp = 4;
currViewingTile = ty * 64 + tx;
@ -905,6 +949,22 @@ namespace BizHawk.MultiClient
labelClipboard.Text = "CTRL+C copies the pane under the mouse.";
}
private void comboPalette_SelectedIndexChanged(object sender, EventArgs e)
{
if (suppression) return;
var pal = (SnesColors.ColorType)comboPalette.SelectedValue;
Console.WriteLine("set {0}", pal);
Global.Config.SNESPalette = pal.ToString();
if (currentSnesCore != null)
{
currentSnesCore.SetPalette(pal);
}
RegenerateData();
RenderView();
RenderPalette();
RenderTileView();
}
}
}