Support palette RAM formats that are byteswapped relative to CPU endianness [Alex Jackson]

This commit is contained in:
Alex W. Jackson 2014-03-01 04:14:07 +00:00
parent 3a92f2edea
commit 88fde55dda
3 changed files with 33 additions and 5 deletions

View File

@ -25,6 +25,7 @@ palette_device::palette_device(const machine_config &mconfig, const char *tag, d
m_enable_shadows(0),
m_enable_hilights(0),
m_raw_to_rgb(raw_to_rgb_converter()),
m_endianness_supplied(false),
m_palette(NULL),
m_pens(NULL),
m_shadow_table(NULL),
@ -51,6 +52,14 @@ void palette_device::static_set_format(device_t &device, raw_to_rgb_converter ra
}
void palette_device::static_set_endianness(device_t &device, endianness_t endianness)
{
palette_device &palette = downcast<palette_device &>(device);
palette.m_endianness = endianness;
palette.m_endianness_supplied = true;
}
void palette_device::static_set_entries(device_t &device, int entries)
{
downcast<palette_device &>(device).m_entries = entries;
@ -364,15 +373,27 @@ void palette_device::device_start()
// make sure we have specified a format
assert(m_raw_to_rgb.bytes_per_entry() > 0);
// determine bytes per entry
int bytes_per_entry = m_raw_to_rgb.bytes_per_entry();
if (share_ext == NULL)
m_paletteram.set(*share, bytes_per_entry);
if (m_endianness_supplied)
{
// forcing endianness only makes sense when the RAM is narrower than the palette format and not split
assert(share_ext == NULL && share->width() < bytes_per_entry);
m_paletteram.set(share->ptr(), share->bytes(), share->width(), m_endianness, bytes_per_entry);
}
else
{
m_paletteram.set(*share, bytes_per_entry / 2);
m_paletteram_ext.set(*share_ext, bytes_per_entry / 2);
m_endianness = share->endianness();
if (share_ext == NULL)
m_paletteram.set(*share, bytes_per_entry);
else
{
m_paletteram.set(*share, bytes_per_entry / 2);
m_paletteram_ext.set(*share_ext, bytes_per_entry / 2);
}
}
}

View File

@ -199,6 +199,9 @@
#define MCFG_PALETTE_FORMAT(_format) \
palette_device::static_set_format(*device, PALETTE_FORMAT_##_format);
#define MCFG_PALETTE_ENDIANNESS(_endianness) \
palette_device::static_set_endianness(*device, _endianness);
#define MCFG_PALETTE_ENTRIES(_entries) \
palette_device::static_set_entries(*device, _entries);
@ -323,6 +326,7 @@ public:
// static configuration
static void static_set_init(device_t &device, palette_init_delegate init);
static void static_set_format(device_t &device, raw_to_rgb_converter raw_to_rgb);
static void static_set_endianness(device_t &device, endianness_t endianness);
static void static_set_entries(device_t &device, int entries);
static void static_enable_shadows(device_t &device);
static void static_enable_hilights(device_t &device);
@ -406,6 +410,8 @@ private:
// palette RAM
raw_to_rgb_converter m_raw_to_rgb; // format of palette RAM
endianness_t m_endianness; // endianness of palette RAM
bool m_endianness_supplied; // endianness supplied in static config
memory_array m_paletteram; // base memory
memory_array m_paletteram_ext; // extended memory

View File

@ -232,6 +232,7 @@ static MACHINE_CONFIG_START( flkatck, flkatck_state )
MCFG_GFXDECODE_ADD("gfxdecode", flkatck)
MCFG_PALETTE_ADD("palette", 512)
MCFG_PALETTE_FORMAT(xBBBBBGGGGGRRRRR)
MCFG_PALETTE_ENDIANNESS(ENDIANNESS_LITTLE)
MCFG_K007121_ADD("k007121")
MCFG_K007121_PALETTE("palette")