Wonderswan - Support settings to change colors. Breaks existing binary savestates (existing text savestates should be OK). B&W palette is exposed as a setting, albeit without a very nice UI. Color palette is available behind the scenes, but is not exposed as a setting.

This commit is contained in:
nattthebear 2016-03-26 13:35:57 -04:00
parent 570709e65c
commit 66abc95c58
8 changed files with 70 additions and 7 deletions

View File

@ -252,6 +252,16 @@ namespace BizHawk.Emulation.Cores.WonderSwan
public struct Settings
{
public LayerFlags LayerMask; // 1 = show
/// <summary>
/// map bw shades to output colors, [0] = darkest, [15] = lightest
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public uint[] BWPalette;
/// <summary>
/// map color shades to output colors, bits 0-3 blue, bits 4-7 green, bits 8-11 red
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4096)]
public uint[] ColorPalette;
}
}
}

View File

@ -5,6 +5,7 @@ using System.Text;
using BizHawk.Emulation.Common;
using System.ComponentModel;
using BizHawk.Common;
using System.Drawing;
namespace BizHawk.Emulation.Cores.WonderSwan
{
@ -30,23 +31,58 @@ namespace BizHawk.Emulation.Cores.WonderSwan
[DefaultValue(true)]
public bool EnableSprites { get; set; }
[DisplayName("B&W Palette")]
[Description("Colors to display in Wonderswan (not Color) mode")]
public Color[] BWPalette { get; private set; }
public BizSwan.Settings GetNativeSettings()
{
var ret = new BizSwan.Settings();
if (EnableBG) ret.LayerMask |= BizSwan.LayerFlags.BG;
if (EnableFG) ret.LayerMask |= BizSwan.LayerFlags.FG;
if (EnableSprites) ret.LayerMask |= BizSwan.LayerFlags.Sprite;
ret.BWPalette = new uint[16];
for (int i = 0; i < 16; i++)
ret.BWPalette[i] = (uint)BWPalette[i].ToArgb() | 0xff000000;
// default color algorithm from wonderswan
// todo: we could give options like the gameboy cores have
ret.ColorPalette = new uint[4096];
for (int r = 0; r < 16; r++)
{
for (int g = 0; g < 16; g++)
{
for (int b = 0; b < 16; b++)
{
uint neo_r, neo_g, neo_b;
neo_r = (uint)r * 17;
neo_g = (uint)g * 17;
neo_b = (uint)b * 17;
ret.ColorPalette[r << 8 | g << 4 | b] = 0xff000000 | neo_r << 16 | neo_g << 8 | neo_b << 0;
}
}
}
return ret;
}
public Settings()
{
SettingsUtil.SetDefaultValues(this);
BWPalette = new Color[16];
for (int i = 0; i < 16; i++)
{
BWPalette[i] = Color.FromArgb(255, i * 17, i * 17, i * 17);
}
}
public Settings Clone()
{
return (Settings)MemberwiseClone();
var ret = (Settings)MemberwiseClone();
ret.BWPalette = (Color[])BWPalette.Clone();
return ret;
}
}

Binary file not shown.

Binary file not shown.

View File

@ -26,7 +26,7 @@ namespace MDFN_IEN_WSWAN
GFX::GFX()
:LayerEnabled(7) // 1 = bg, 2 = fg, 4 = sprite
{
SetPixelFormat();
//SetPixelFormat();
}
@ -239,6 +239,16 @@ namespace MDFN_IEN_WSWAN
LayerEnabled = mask;
}
void GFX::SetBWPalette(const uint32 *colors)
{
std::memcpy(ColorMapG, colors, sizeof(ColorMapG));
}
void GFX::SetColorPalette(const uint32 *colors)
{
std::memcpy(ColorMap, colors, sizeof(ColorMap));
}
/*
void GFX::SetPixelFormat()
{
for(int r = 0; r < 16; r++)
@ -268,7 +278,7 @@ namespace MDFN_IEN_WSWAN
}
}
}
}
}*/
void GFX::Scanline(uint32 *target)
{
@ -626,10 +636,11 @@ namespace MDFN_IEN_WSWAN
NSS(wsColors);
NSS(wsCols);
NSS(ColorMapG);
NSS(ColorMap);
NSS(LayerEnabled);
/* non-sync settings related to output
NSS(ColorMapG); // b&w color output
NSS(ColorMap); // color color output
NSS(LayerEnabled); // layer enable mask
*/
NSS(wsLine);
NSS(SpriteTable);

View File

@ -29,6 +29,8 @@ public:
bool ExecuteLine(uint32 *surface, bool skip);
void SetLayerEnableMask(uint32 mask);
void SetBWPalette(const uint32 *colors);
void SetColorPalette(const uint32 *colors);
private:
// TCACHE ====================================

View File

@ -268,6 +268,8 @@ namespace MDFN_IEN_WSWAN
void System::PutSettings(const Settings &s)
{
gfx.SetLayerEnableMask(s.LayerMask);
gfx.SetBWPalette(s.BWPalette);
gfx.SetColorPalette(s.ColorPalette);
}
uint32 System::GetNECReg(int which) const

View File

@ -77,6 +77,8 @@ struct SyncSettings
struct Settings
{
uint32 LayerMask; // 1 = enable bg, 2 = enable fg, 4 = enable sprites
uint32 BWPalette[16]; // map 16 b&w shades to output colors
uint32 ColorPalette[4096]; // map 4096 color shades to output colors
};
namespace Debug