summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
author Alex W. Jackson <alex.w.jackson@gmail.com>2014-05-15 18:33:54 +0000
committer Alex W. Jackson <alex.w.jackson@gmail.com>2014-05-15 18:33:54 +0000
commitffd0b5f2ad3ffeefd77d088575e8f9805c448c57 (patch)
treea31c1f2fc974ac82732f6de51fba42a7fe2243c9 /src/emu
parent1a9ed9ebe857c3df11176a7509ebd389df863d99 (diff)
drawgfx.c: make it possible to reset the total elements of a gfx_element [Alex Jackson]
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/drawgfx.c49
-rw-r--r--src/emu/drawgfx.h3
2 files changed, 47 insertions, 5 deletions
diff --git a/src/emu/drawgfx.c b/src/emu/drawgfx.c
index 4e5bd6698c9..f985456c786 100644
--- a/src/emu/drawgfx.c
+++ b/src/emu/drawgfx.c
@@ -172,6 +172,8 @@ gfx_element::gfx_element(palette_device *palette, const gfx_layout &gl, const UI
void gfx_element::set_layout(const gfx_layout &gl, const UINT8 *srcdata)
{
+ m_srcdata = srcdata;
+
// configure ourselves
m_width = m_origwidth = gl.width;
m_height = m_origheight = gl.height;
@@ -199,7 +201,7 @@ void gfx_element::set_layout(const gfx_layout &gl, const UINT8 *srcdata)
// RAW graphics must have a pointer up front
assert(srcdata != NULL);
- m_gfxdata = const_cast<UINT8 *>(m_srcdata);
+ m_gfxdata = const_cast<UINT8 *>(srcdata);
}
// decoded graphics case
@@ -234,9 +236,6 @@ void gfx_element::set_layout(const gfx_layout &gl, const UINT8 *srcdata)
m_pen_usage.resize(m_total_elements);
else
m_pen_usage.reset();
-
- // set the source
- set_source(srcdata);
}
@@ -259,6 +258,48 @@ void gfx_element::set_raw_layout(const UINT8 *srcdata, UINT32 width, UINT32 heig
//-------------------------------------------------
+// set_source - set the source data for a gfx_element
+//-------------------------------------------------
+
+void gfx_element::set_source(const UINT8 *source)
+{
+ m_srcdata = source;
+ memset(m_dirty, 1, elements());
+ if (m_layout_is_raw) m_gfxdata = const_cast<UINT8 *>(source);
+}
+
+
+//-------------------------------------------------
+// set_source_and_total - set the source data
+// and total elements for a gfx_element
+//-------------------------------------------------
+
+void gfx_element::set_source_and_total(const UINT8 *source, UINT32 total)
+{
+ m_srcdata = source;
+ m_total_elements = total;
+
+ // mark everything dirty
+ m_dirty.resize_and_clear(m_total_elements, 1);
+
+ // allocate a pen usage array for entries with 32 pens or less
+ if (m_color_depth <= 32)
+ m_pen_usage.resize(m_total_elements);
+
+ if (m_layout_is_raw)
+ {
+ m_gfxdata = const_cast<UINT8 *>(source);
+ }
+ else
+ {
+ // allocate memory for the data
+ m_gfxdata_allocated.resize(m_total_elements * m_char_modulo);
+ m_gfxdata = &m_gfxdata_allocated[0];
+ }
+}
+
+
+//-------------------------------------------------
// set_source_clip - set a source clipping rect
//-------------------------------------------------
diff --git a/src/emu/drawgfx.h b/src/emu/drawgfx.h
index 3b397cd9052..2edfd3c0eca 100644
--- a/src/emu/drawgfx.h
+++ b/src/emu/drawgfx.h
@@ -62,7 +62,8 @@ public:
// setters
void set_layout(const gfx_layout &gl, const UINT8 *srcdata);
void set_raw_layout(const UINT8 *srcdata, UINT32 width, UINT32 height, UINT32 total, UINT32 linemod, UINT32 charmod);
- void set_source(const UINT8 *source) { m_srcdata = source; if (m_layout_is_raw) m_gfxdata = const_cast<UINT8 *>(source); memset(m_dirty, 1, elements()); }
+ void set_source(const UINT8 *source);
+ void set_source_and_total(const UINT8 *source, UINT32 total);
void set_xormask(UINT32 xormask) { m_layout_xormask = xormask; }
void set_palette(palette_device *palette) { m_palette = palette; }
void set_colors(UINT32 colors) { m_total_colors = colors; }