diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs
index 9aa024bf21..95c8f01167 100644
--- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs
+++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs
@@ -252,6 +252,16 @@ namespace BizHawk.Emulation.Cores.WonderSwan
public struct Settings
{
public LayerFlags LayerMask; // 1 = show
+ ///
+ /// map bw shades to output colors, [0] = darkest, [15] = lightest
+ ///
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
+ public uint[] BWPalette;
+ ///
+ /// map color shades to output colors, bits 0-3 blue, bits 4-7 green, bits 8-11 red
+ ///
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4096)]
+ public uint[] ColorPalette;
}
}
}
diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs
index c3bc8d0752..024db5612c 100644
--- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs
+++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs
@@ -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;
}
}
diff --git a/output/dll/bizswan.dll b/output/dll/bizswan.dll
index 7c6b69620b..ab5717249e 100644
Binary files a/output/dll/bizswan.dll and b/output/dll/bizswan.dll differ
diff --git a/output64/dll/bizswan.dll b/output64/dll/bizswan.dll
index 7e3a0341d6..7c0542124a 100644
Binary files a/output64/dll/bizswan.dll and b/output64/dll/bizswan.dll differ
diff --git a/wonderswan/gfx.cpp b/wonderswan/gfx.cpp
index ac51c557d9..baaaafce1d 100644
--- a/wonderswan/gfx.cpp
+++ b/wonderswan/gfx.cpp
@@ -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);
diff --git a/wonderswan/gfx.h b/wonderswan/gfx.h
index 0fbef1e471..b1f7bafb32 100644
--- a/wonderswan/gfx.h
+++ b/wonderswan/gfx.h
@@ -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 ====================================
diff --git a/wonderswan/system.cpp b/wonderswan/system.cpp
index 3a61d3992b..28928d0a29 100644
--- a/wonderswan/system.cpp
+++ b/wonderswan/system.cpp
@@ -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
diff --git a/wonderswan/system.h b/wonderswan/system.h
index 51dff3972e..2ab37ae0ce 100644
--- a/wonderswan/system.h
+++ b/wonderswan/system.h
@@ -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