From 7d51048dc671ed5a060696ba72009d4de742cdb7 Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Wed, 5 Mar 2014 03:59:58 +0000 Subject: [PATCH] Declaring indirect colors in MCFG is now mandatory. Removed dynamic creation and resizing of indirection tables [Alex Jackson] --- src/emu/emupal.c | 28 ++++++++++++---------------- src/mame/drivers/cop01.c | 1 + src/mame/drivers/gberet.c | 2 +- src/mame/video/taito_b.c | 2 +- src/mame/video/toobin.c | 2 +- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/emu/emupal.c b/src/emu/emupal.c index 727382f5846..7b27a1579e6 100644 --- a/src/emu/emupal.c +++ b/src/emu/emupal.c @@ -96,12 +96,8 @@ void palette_device::static_enable_hilights(device_t &device) void palette_device::set_indirect_color(int index, rgb_t rgb) { - // if we have a static size, make sure we're in range - assert(m_indirect_entries == 0 || index < m_indirect_entries); - - // otherwise, ensure the array is expanded enough to handle the index - while (m_indirect_colors.count() <= index) - m_indirect_colors.append(rgb_t(0)); + // make sure we are in range + assert(index < m_indirect_entries); // alpha doesn't matter rgb.set_a(255); @@ -125,15 +121,12 @@ void palette_device::set_indirect_color(int index, rgb_t rgb) void palette_device::set_pen_indirect(pen_t pen, UINT16 index) { - assert(pen < m_entries); + // make sure we are in range + assert(pen < m_entries && index < m_indirect_entries); - // allocate the array if needed - m_indirect_pens.resize(m_entries); m_indirect_pens[pen] = index; - // permit drivers to configure the pens prior to the colors if they desire - if (index < m_indirect_colors.count()) - m_palette->entry_set_color(pen, m_indirect_colors[index]); + m_palette->entry_set_color(pen, m_indirect_colors[index]); } @@ -312,7 +305,7 @@ inline void palette_device::update_for_write(offs_t byte_offset, int bytes_modif UINT32 data = m_paletteram.read(base + index); if (m_paletteram_ext.base() != NULL) data |= m_paletteram_ext.read(base + index) << (8 * bpe); - set_pen_color(base + index, m_raw_to_rgb(data)); + m_palette->entry_set_color(base + index, m_raw_to_rgb(data)); } } @@ -419,7 +412,10 @@ void palette_device::device_start() { m_indirect_colors.resize(m_indirect_entries); for (int color = 0; color < m_indirect_entries; color++) - m_indirect_colors[color] = rgb_t(0); + { + // alpha = 0 ensures change is detected the first time set_indirect_color() is called + m_indirect_colors[color] = rgb_t(0, 0, 0, 0); + } m_indirect_pens.resize(m_entries); for (int pen = 0; pen < m_entries; pen++) @@ -427,7 +423,7 @@ void palette_device::device_start() } } - // call the initialization helper if present (this will expand the indirection tables to full size) + // call the initialization helper if present if (!m_init.isnull()) m_init(*this); @@ -437,7 +433,7 @@ void palette_device::device_start() save_item(NAME(m_save_pen)); save_item(NAME(m_save_contrast)); - // save indirection tables if explicitly requested + // save indirection tables if we have them if (m_indirect_entries > 0) { save_item(NAME(m_indirect_colors)); diff --git a/src/mame/drivers/cop01.c b/src/mame/drivers/cop01.c index ffab350ce95..a9832bc5866 100644 --- a/src/mame/drivers/cop01.c +++ b/src/mame/drivers/cop01.c @@ -503,6 +503,7 @@ static MACHINE_CONFIG_START( mightguy, cop01_state ) MCFG_GFXDECODE_ADD("gfxdecode", cop01) MCFG_PALETTE_ADD("palette", 16+8*16+16*16) + MCFG_PALETTE_INDIRECT_ENTRIES(256) MCFG_PALETTE_INIT_OWNER(cop01_state, cop01) /* sound hardware */ diff --git a/src/mame/drivers/gberet.c b/src/mame/drivers/gberet.c index 798c3c5c0cd..bbdbefe348e 100644 --- a/src/mame/drivers/gberet.c +++ b/src/mame/drivers/gberet.c @@ -456,7 +456,7 @@ static MACHINE_CONFIG_START( gberetb, gberet_state ) MCFG_GFXDECODE_ADD("gfxdecode", gberetb) MCFG_PALETTE_ADD("palette", 2*16*16) - + MCFG_PALETTE_INDIRECT_ENTRIES(32) MCFG_PALETTE_INIT_OWNER(gberet_state,gberet) MCFG_VIDEO_START_OVERRIDE(gberet_state,gberet) diff --git a/src/mame/video/taito_b.c b/src/mame/video/taito_b.c index 76765e61d79..3a86fc9c51f 100644 --- a/src/mame/video/taito_b.c +++ b/src/mame/video/taito_b.c @@ -396,7 +396,7 @@ UINT32 taitob_state::screen_update_taitob(screen_device &screen, bitmap_ind16 &b UINT32 taitob_state::screen_update_realpunc(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { address_space &space = machine().driver_data()->generic_space(); - const rgb_t *palette = m_palette->palette()->entry_list_adjusted(); + const pen_t *palette = m_palette->pens(); UINT8 video_control = m_tc0180vcu->get_videoctrl(space, 0); int x, y; diff --git a/src/mame/video/toobin.c b/src/mame/video/toobin.c index 8451f5427d5..e07a871b090 100644 --- a/src/mame/video/toobin.c +++ b/src/mame/video/toobin.c @@ -223,7 +223,7 @@ UINT32 toobin_state::screen_update_toobin(screen_device &screen, bitmap_rgb32 &b /* draw and merge the MO */ bitmap_ind16 &mobitmap = m_mob->bitmap(); - const rgb_t *palette = m_palette->palette()->entry_list_adjusted(); + const pen_t *palette = m_palette->pens(); for (int y = cliprect.min_y; y <= cliprect.max_y; y++) { UINT32 *dest = &bitmap.pix32(y);