summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2012-02-04 19:24:25 +0000
committer Aaron Giles <aaron@aarongiles.com>2012-02-04 19:24:25 +0000
commit3d10a899455381437b4d884c95963d65e260025c (patch)
tree855c0fcfa4caef1262b0550a622eb2564799c7c3
parent39027314376a08aee3da3a5fbe99d5451b8203a5 (diff)
Fix tilemap viewer. Tilemaps now use the bitmap's raw palette instead
of machine->pens to lookup RGB32 values if the palette is present (it is on all screen bitmaps). Today these are identical, but it's part of a long-term effort to move away from a global palette and allowing each bitmap or screen to have their own if that is preferred.
-rw-r--r--src/emu/tilemap.c11
-rw-r--r--src/emu/uigfx.c1
2 files changed, 7 insertions, 5 deletions
diff --git a/src/emu/tilemap.c b/src/emu/tilemap.c
index ab0ee1f5e96..1ebc08a3262 100644
--- a/src/emu/tilemap.c
+++ b/src/emu/tilemap.c
@@ -1184,6 +1184,7 @@ void tilemap_t::draw_instance(_BitmapClass &dest, const blit_parameters &blit, i
x_end = MIN(x_end, x2);
// if we're rendering something, compute the pointers
+ const rgb_t *clut = (dest.palette() != NULL) ? palette_entry_list_raw(dest.palette()) : machine().pens;
if (prev_trans != WHOLLY_TRANSPARENT)
{
const UINT16 *source0 = source_baseaddr + x_start;
@@ -1200,9 +1201,9 @@ void tilemap_t::draw_instance(_BitmapClass &dest, const blit_parameters &blit, i
else if (sizeof(*dest0) == 2)
scanline_draw_opaque_ind16(reinterpret_cast<UINT16 *>(dest0), source0, x_end - x_start, pmap0, blit.tilemap_priority_code);
else if (sizeof(*dest0) == 4 && blit.alpha >= 0xff)
- scanline_draw_opaque_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, machine().pens, pmap0, blit.tilemap_priority_code);
+ scanline_draw_opaque_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, clut, pmap0, blit.tilemap_priority_code);
else if (sizeof(*dest0) == 4)
- scanline_draw_opaque_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, machine().pens, pmap0, blit.tilemap_priority_code, blit.alpha);
+ scanline_draw_opaque_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, clut, pmap0, blit.tilemap_priority_code, blit.alpha);
dest0 += dest_rowpixels;
source0 += m_pixmap.rowpixels();
@@ -1221,9 +1222,9 @@ void tilemap_t::draw_instance(_BitmapClass &dest, const blit_parameters &blit, i
else if (sizeof(*dest0) == 2)
scanline_draw_masked_ind16(reinterpret_cast<UINT16 *>(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, pmap0, blit.tilemap_priority_code);
else if (sizeof(*dest0) == 4 && blit.alpha >= 0xff)
- scanline_draw_masked_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, machine().pens, pmap0, blit.tilemap_priority_code);
+ scanline_draw_masked_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, clut, pmap0, blit.tilemap_priority_code);
else if (sizeof(*dest0) == 4)
- scanline_draw_masked_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, machine().pens, pmap0, blit.tilemap_priority_code, blit.alpha);
+ scanline_draw_masked_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, clut, pmap0, blit.tilemap_priority_code, blit.alpha);
dest0 += dest_rowpixels;
source0 += m_pixmap.rowpixels();
@@ -1277,7 +1278,7 @@ void tilemap_t::draw_roz_core(_BitmapClass &destbitmap, const blit_parameters &b
UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound)
{
// pre-cache all the inner loop values
- const pen_t *clut = &machine().pens[blit.tilemap_priority_code >> 16];
+ const rgb_t *clut = ((destbitmap.palette() != NULL) ? palette_entry_list_raw(destbitmap.palette()) : machine().pens) + (blit.tilemap_priority_code >> 16);
bitmap_ind8 &priority_bitmap = machine().priority_bitmap;
const int xmask = m_pixmap.width() - 1;
const int ymask = m_pixmap.height() - 1;
diff --git a/src/emu/uigfx.c b/src/emu/uigfx.c
index f5580a30ff1..87f8d75ecae 100644
--- a/src/emu/uigfx.c
+++ b/src/emu/uigfx.c
@@ -1039,6 +1039,7 @@ static void tilemap_update_bitmap(running_machine &machine, ui_gfx_state *state,
/* allocate new stuff */
state->bitmap = global_alloc(bitmap_rgb32(width, height));
+ state->bitmap->set_palette(machine.palette);
state->texture = machine.render().texture_alloc();
state->texture->set_bitmap(*state->bitmap, state->bitmap->cliprect(), TEXFORMAT_RGB32);