mirror of
https://github.com/holub/mame
synced 2025-04-23 08:49:55 +03:00
Added ability to add the graphics in the external drwho art file to the new reel structure. [David Haywood]
This commit is contained in:
parent
389d12b57c
commit
100b581b4f
@ -609,10 +609,16 @@ layout_element::texture::~texture()
|
||||
layout_element::component::component(running_machine &machine, xml_data_node &compnode, const char *dirname)
|
||||
: m_next(NULL),
|
||||
m_type(CTYPE_INVALID),
|
||||
m_state(0),
|
||||
m_file(NULL),
|
||||
m_hasalpha(false)
|
||||
m_state(0)
|
||||
{
|
||||
for (int i=0;i<MAX_BITMAPS;i++)
|
||||
{
|
||||
m_hasalpha[i] = false;
|
||||
m_file[i] = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// fetch common data
|
||||
m_state = xml_get_attribute_int_with_subst(machine, compnode, "state", -1);
|
||||
parse_bounds(machine, xml_get_sibling(compnode.child, "bounds"), m_bounds);
|
||||
@ -623,9 +629,9 @@ layout_element::component::component(running_machine &machine, xml_data_node &co
|
||||
{
|
||||
m_type = CTYPE_IMAGE;
|
||||
m_dirname = dirname;
|
||||
m_imagefile = xml_get_attribute_string_with_subst(machine, compnode, "file", "");
|
||||
m_alphafile = xml_get_attribute_string_with_subst(machine, compnode, "alphafile", "");
|
||||
m_file = global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ));
|
||||
m_imagefile[0] = xml_get_attribute_string_with_subst(machine, compnode, "file", "");
|
||||
m_alphafile[0] = xml_get_attribute_string_with_subst(machine, compnode, "alphafile", "");
|
||||
m_file[0] = global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ));
|
||||
}
|
||||
|
||||
// text nodes
|
||||
@ -667,6 +673,30 @@ layout_element::component::component(running_machine &machine, xml_data_node &co
|
||||
}
|
||||
m_stopnames[m_numstops++] = symbollist;
|
||||
|
||||
// careful, dirname is NULL if we're coming from internal layout, and our string assignment doesn't like that
|
||||
if (dirname != NULL)
|
||||
m_dirname = dirname;
|
||||
|
||||
for (int i=0;i<m_numstops;i++)
|
||||
{
|
||||
location=m_stopnames[i].find(0,":");
|
||||
if (location!=-1)
|
||||
{
|
||||
m_imagefile[i] = m_stopnames[i];
|
||||
m_stopnames[i].substr(0, location);
|
||||
m_imagefile[i].substr(location+1, m_imagefile[i].len()-(location-1));
|
||||
|
||||
//m_alphafile[i] =
|
||||
m_file[i] = global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ));
|
||||
}
|
||||
else
|
||||
{
|
||||
//m_imagefile[i] = 0;
|
||||
//m_alphafile[i] = 0;
|
||||
m_file[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
m_stateoffset = xml_get_attribute_int_with_subst(machine, compnode, "stateoffset", 0);
|
||||
m_numsymbolsvisible = xml_get_attribute_int_with_subst(machine, compnode, "numsymbolsvisible", 3);
|
||||
m_reelreversed = xml_get_attribute_int_with_subst(machine, compnode, "reelreversed", 0);
|
||||
@ -711,7 +741,10 @@ layout_element::component::component(running_machine &machine, xml_data_node &co
|
||||
|
||||
layout_element::component::~component()
|
||||
{
|
||||
global_free(m_file);
|
||||
for (int i=0;i<MAX_BITMAPS;i++)
|
||||
{
|
||||
global_free(m_file[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -724,11 +757,11 @@ void layout_element::component::draw(running_machine &machine, bitmap_argb32 &de
|
||||
switch (m_type)
|
||||
{
|
||||
case CTYPE_IMAGE:
|
||||
if (!m_bitmap.valid())
|
||||
if (!m_bitmap[0].valid())
|
||||
load_bitmap();
|
||||
{
|
||||
bitmap_argb32 destsub(dest, bounds);
|
||||
render_resample_argb_bitmap_hq(destsub, m_bitmap, m_color);
|
||||
render_resample_argb_bitmap_hq(destsub, m_bitmap[0], m_color);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -773,6 +806,7 @@ void layout_element::component::draw(running_machine &machine, bitmap_argb32 &de
|
||||
break;
|
||||
|
||||
case CTYPE_REEL:
|
||||
|
||||
draw_reel(machine, dest, bounds, state);
|
||||
break;
|
||||
|
||||
@ -975,6 +1009,8 @@ void layout_element::component::draw_simplecounter(running_machine &machine, bit
|
||||
/* state is a normalized value between 0 and 65536 so that we don't need to worry about how many motor steps here or in the .lay, only the number of symbols */
|
||||
void layout_element::component::draw_reel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state)
|
||||
{
|
||||
|
||||
|
||||
const int max_state_used = 0x10000;
|
||||
|
||||
// shift the reels a bit based on this param, allows fine tuning
|
||||
@ -1033,52 +1069,94 @@ void layout_element::component::draw_reel(running_machine &machine, bitmap_argb3
|
||||
INT32 curx;
|
||||
curx = bounds.min_x + (bounds.width() - width) / 2;
|
||||
|
||||
if (m_file[fruit])
|
||||
if (!m_bitmap[fruit].valid())
|
||||
load_reel_bitmap(fruit);
|
||||
|
||||
// allocate a temporary bitmap
|
||||
bitmap_argb32 tempbitmap(dest.width(), dest.height());
|
||||
|
||||
// loop over characters
|
||||
for (const char *s = m_stopnames[fruit]; *s != 0; s++)
|
||||
if (m_file[fruit]) // render gfx
|
||||
{
|
||||
// get the font bitmap
|
||||
rectangle chbounds;
|
||||
font->get_scaled_bitmap_and_bounds(tempbitmap, ourheight/num_shown, aspect, *s, chbounds);
|
||||
|
||||
// copy the data into the target
|
||||
for (int y = 0; y < chbounds.height(); y++)
|
||||
bitmap_argb32 tempbitmap2(dest.width(), ourheight/num_shown);
|
||||
|
||||
if (m_bitmap[fruit].valid())
|
||||
{
|
||||
int effy = basey + y;
|
||||
render_resample_argb_bitmap_hq(tempbitmap2, m_bitmap[fruit], m_color);
|
||||
|
||||
if (effy >= bounds.min_y && effy <= bounds.max_y)
|
||||
for (int y = 0; y < ourheight/num_shown; y++)
|
||||
{
|
||||
UINT32 *src = &tempbitmap.pix32(y);
|
||||
UINT32 *d = &dest.pix32(effy);
|
||||
for (int x = 0; x < chbounds.width(); x++)
|
||||
{
|
||||
int effx = curx + x + chbounds.min_x;
|
||||
if (effx >= bounds.min_x && effx <= bounds.max_x)
|
||||
{
|
||||
int effy = basey + y;
|
||||
|
||||
UINT32 spix = RGB_ALPHA(src[x]);
|
||||
if (spix != 0)
|
||||
if (effy >= bounds.min_y && effy <= bounds.max_y)
|
||||
{
|
||||
UINT32 *src = &tempbitmap2.pix32(y);
|
||||
UINT32 *d = &dest.pix32(effy);
|
||||
for (int x = 0; x < dest.width(); x++)
|
||||
{
|
||||
int effx = x;
|
||||
if (effx >= bounds.min_x && effx <= bounds.max_x)
|
||||
{
|
||||
UINT32 dpix = d[effx];
|
||||
UINT32 ta = (a * (spix + 1)) >> 8;
|
||||
UINT32 tr = (r * ta + RGB_RED(dpix) * (0x100 - ta)) >> 8;
|
||||
UINT32 tg = (g * ta + RGB_GREEN(dpix) * (0x100 - ta)) >> 8;
|
||||
UINT32 tb = (b * ta + RGB_BLUE(dpix) * (0x100 - ta)) >> 8;
|
||||
d[effx] = MAKE_ARGB(0xff, tr, tg, tb);
|
||||
|
||||
UINT32 spix = RGB_ALPHA(src[x]);
|
||||
if (spix != 0)
|
||||
{
|
||||
d[effx] = src[x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else // render text (fallback)
|
||||
{
|
||||
// allocate a temporary bitmap
|
||||
bitmap_argb32 tempbitmap(dest.width(), dest.height());
|
||||
|
||||
// loop over characters
|
||||
for (const char *s = m_stopnames[fruit]; *s != 0; s++)
|
||||
{
|
||||
// get the font bitmap
|
||||
rectangle chbounds;
|
||||
font->get_scaled_bitmap_and_bounds(tempbitmap, ourheight/num_shown, aspect, *s, chbounds);
|
||||
|
||||
// copy the data into the target
|
||||
for (int y = 0; y < chbounds.height(); y++)
|
||||
{
|
||||
int effy = basey + y;
|
||||
|
||||
if (effy >= bounds.min_y && effy <= bounds.max_y)
|
||||
{
|
||||
UINT32 *src = &tempbitmap.pix32(y);
|
||||
UINT32 *d = &dest.pix32(effy);
|
||||
for (int x = 0; x < chbounds.width(); x++)
|
||||
{
|
||||
int effx = curx + x + chbounds.min_x;
|
||||
if (effx >= bounds.min_x && effx <= bounds.max_x)
|
||||
{
|
||||
|
||||
UINT32 spix = RGB_ALPHA(src[x]);
|
||||
if (spix != 0)
|
||||
{
|
||||
UINT32 dpix = d[effx];
|
||||
UINT32 ta = (a * (spix + 1)) >> 8;
|
||||
UINT32 tr = (r * ta + RGB_RED(dpix) * (0x100 - ta)) >> 8;
|
||||
UINT32 tg = (g * ta + RGB_GREEN(dpix) * (0x100 - ta)) >> 8;
|
||||
UINT32 tb = (b * ta + RGB_BLUE(dpix) * (0x100 - ta)) >> 8;
|
||||
d[effx] = MAKE_ARGB(0xff, tr, tg, tb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// advance in the X direction
|
||||
curx += font->char_width(ourheight/num_shown, aspect, *s);
|
||||
// advance in the X direction
|
||||
curx += font->char_width(ourheight/num_shown, aspect, *s);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
curry += ourheight/num_shown;
|
||||
}
|
||||
|
||||
@ -1097,32 +1175,55 @@ void layout_element::component::draw_reel(running_machine &machine, bitmap_argb3
|
||||
void layout_element::component::load_bitmap()
|
||||
{
|
||||
// load the basic bitmap
|
||||
assert(m_file != NULL);
|
||||
m_hasalpha = render_load_png(m_bitmap, *m_file, m_dirname, m_imagefile);
|
||||
assert(m_file[0] != NULL);
|
||||
m_hasalpha[0] = render_load_png(m_bitmap[0], *m_file[0], m_dirname, m_imagefile[0]);
|
||||
|
||||
// load the alpha bitmap if specified
|
||||
if (m_bitmap.valid() && m_alphafile)
|
||||
render_load_png(m_bitmap, *m_file, m_dirname, m_alphafile, true);
|
||||
if (m_bitmap[0].valid() && m_alphafile[0])
|
||||
render_load_png(m_bitmap[0], *m_file[0], m_dirname, m_alphafile[0], true);
|
||||
|
||||
// if we can't load the bitmap, allocate a dummy one and report an error
|
||||
if (!m_bitmap.valid())
|
||||
if (!m_bitmap[0].valid())
|
||||
{
|
||||
// draw some stripes in the bitmap
|
||||
m_bitmap.allocate(100, 100);
|
||||
m_bitmap.fill(0);
|
||||
m_bitmap[0].allocate(100, 100);
|
||||
m_bitmap[0].fill(0);
|
||||
for (int step = 0; step < 100; step += 25)
|
||||
for (int line = 0; line < 100; line++)
|
||||
m_bitmap.pix32((step + line) % 100, line % 100) = MAKE_ARGB(0xff,0xff,0xff,0xff);
|
||||
m_bitmap[0].pix32((step + line) % 100, line % 100) = MAKE_ARGB(0xff,0xff,0xff,0xff);
|
||||
|
||||
// log an error
|
||||
if (!m_alphafile)
|
||||
mame_printf_warning("Unable to load component bitmap '%s'", m_imagefile.cstr());
|
||||
if (!m_alphafile[0])
|
||||
mame_printf_warning("Unable to load component bitmap '%s'", m_imagefile[0].cstr());
|
||||
else
|
||||
mame_printf_warning("Unable to load component bitmap '%s'/'%s'", m_imagefile.cstr(), m_alphafile.cstr());
|
||||
mame_printf_warning("Unable to load component bitmap '%s'/'%s'", m_imagefile[0].cstr(), m_alphafile[0].cstr());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void layout_element::component::load_reel_bitmap(int number)
|
||||
{
|
||||
|
||||
// load the basic bitmap
|
||||
assert(m_file != NULL);
|
||||
/*m_hasalpha[number] = */ render_load_png(m_bitmap[number], *m_file[number], m_dirname, m_imagefile[number]);
|
||||
|
||||
// load the alpha bitmap if specified
|
||||
//if (m_bitmap[number].valid() && m_alphafile[number])
|
||||
// render_load_png(m_bitmap[number], *m_file[number], m_dirname, m_alphafile[number], true);
|
||||
|
||||
// if we can't load the bitmap just use text rendering
|
||||
if (!m_bitmap[number].valid())
|
||||
{
|
||||
// fallback to text rendering
|
||||
global_free(m_file[number]);
|
||||
m_file[number] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// draw_led7seg - draw a 7-segment LCD
|
||||
//-------------------------------------------------
|
||||
|
@ -133,6 +133,7 @@ private:
|
||||
void draw_simplecounter(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
|
||||
void draw_reel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
|
||||
void load_bitmap();
|
||||
void load_reel_bitmap(int number);
|
||||
void draw_led7seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
|
||||
void draw_led14seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
|
||||
void draw_led14segsc(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
|
||||
@ -149,26 +150,28 @@ private:
|
||||
void draw_segment_comma(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color);
|
||||
void apply_skew(bitmap_argb32 &dest, int skewwidth);
|
||||
|
||||
// internal state
|
||||
component * m_next; // link to next component
|
||||
component_type m_type; // type of component
|
||||
int m_state; // state where this component is visible (-1 means all states)
|
||||
render_bounds m_bounds; // bounds of the element
|
||||
render_color m_color; // color of the element
|
||||
astring m_string; // string for text components
|
||||
int m_digits; // number of digits for simple counters
|
||||
int m_textalign; // text alignment to box
|
||||
bitmap_argb32 m_bitmap; // source bitmap for images
|
||||
astring m_dirname; // directory name of image file (for lazy loading)
|
||||
emu_file * m_file; // file object for reading image/alpha files
|
||||
astring m_imagefile; // name of the image file (for lazy loading)
|
||||
astring m_alphafile; // name of the alpha file (for lazy loading)
|
||||
bool m_hasalpha; // is there any alpha component present?
|
||||
#define MAX_BITMAPS 32
|
||||
|
||||
// internal state
|
||||
component * m_next; // link to next component
|
||||
component_type m_type; // type of component
|
||||
int m_state; // state where this component is visible (-1 means all states)
|
||||
render_bounds m_bounds; // bounds of the element
|
||||
render_color m_color; // color of the element
|
||||
astring m_string; // string for text components
|
||||
int m_digits; // number of digits for simple counters
|
||||
int m_textalign; // text alignment to box
|
||||
bitmap_argb32 m_bitmap[MAX_BITMAPS]; // source bitmap for images
|
||||
astring m_dirname; // directory name of image file (for lazy loading)
|
||||
emu_file * m_file[MAX_BITMAPS]; // file object for reading image/alpha files
|
||||
astring m_imagefile[MAX_BITMAPS]; // name of the image file (for lazy loading)
|
||||
astring m_alphafile[MAX_BITMAPS]; // name of the alpha file (for lazy loading)
|
||||
bool m_hasalpha[MAX_BITMAPS]; // is there any alpha component present?
|
||||
|
||||
#define MAX_STOPS 256
|
||||
// stuff for fruit machine reels
|
||||
// basically made up of multiple text strings / gfx
|
||||
int m_numstops;
|
||||
astring m_stopnames[MAX_STOPS];
|
||||
astring m_stopnames[MAX_BITMAPS];
|
||||
int m_stateoffset;
|
||||
int m_reelreversed;
|
||||
int m_numsymbolsvisible;
|
||||
|
@ -14,6 +14,22 @@
|
||||
<color red="0.0" green="1.0" blue="0.0" />
|
||||
</rect>
|
||||
</element>
|
||||
|
||||
<element name="reellamp">
|
||||
<rect state ="0">
|
||||
<bounds x="0" y="0" width="7" height="7" />
|
||||
<color red="0.1" green="0.1" blue="0.1" />
|
||||
</rect>
|
||||
<rect state ="1">
|
||||
<bounds x="0" y="0" width="7" height="7" />
|
||||
<color red="0.6" green="0.6" blue="0.6" />
|
||||
</rect>
|
||||
<rect state ="2">
|
||||
<bounds x="0" y="0" width="7" height="7" />
|
||||
<color red="0.6" green="0.6" blue="0.6" />
|
||||
</rect>
|
||||
</element>
|
||||
|
||||
<element name="Steppers" defstate="0">
|
||||
<simplecounter maxstate="999" digits="3">
|
||||
<color red="1.0" green="1.0" blue="1.0" />
|
||||
@ -21,9 +37,11 @@
|
||||
</simplecounter>
|
||||
</element>
|
||||
|
||||
|
||||
|
||||
<!-- a stateoffset of 682 will shift us by 1 step on a 96 step reel (0x10000/96) which seems a good default alignment for 96 step / 16 symbol reels -->
|
||||
<element name="SteppersReel1" defstate="0">
|
||||
<reel stateoffset="682" symbollist="Fruit1,Fruit2,Fruit3,Fruit4,Fruit5,Fruit6,Fruit7,Fruit8,Fruit9,Fruit10,Fruit11,Fruit12,Fruit13,Fruit14,Fruit15,Fruit16">
|
||||
<reel stateoffset="682" symbollist="Fruit1:image11.png,Fruit2:image12.png,Fruit3:image13.png,Fruit4:image14.png,Fruit5:image15.png,Fruit6:image16.png,Fruit7:image17.png,Fruit8:image18.png,Fruit9:image19.png,Fruit10:image110.png,Fruit11:image111.png,Fruit12:image112.png,Fruit13:image113.png,Fruit14:image114.png,Fruit15:image115.png,Fruit16:image116.png">
|
||||
<color red="1.0" green="1.0" blue="1.0" />
|
||||
<bounds x="0" y="0" width="1" height="1" />
|
||||
</reel>
|
||||
@ -148,6 +166,46 @@
|
||||
<bounds x="350" y="410" width="10" height="5"/>
|
||||
</backdrop>
|
||||
|
||||
<!-- these are typically the reel lamps, so duplicate them here -->
|
||||
<backdrop name="lamp32" element="reellamp" state="0">
|
||||
<bounds x="210" y="300" width="50" height="17"/>
|
||||
</backdrop>
|
||||
<backdrop name="lamp33" element="reellamp" state="0">
|
||||
<bounds x="210" y="317" width="50" height="17"/>
|
||||
</backdrop>
|
||||
<backdrop name="lamp34" element="reellamp" state="0">
|
||||
<bounds x="210" y="333" width="50" height="17"/>
|
||||
</backdrop>
|
||||
|
||||
<backdrop name="lamp35" element="reellamp" state="0">
|
||||
<bounds x="260" y="300" width="50" height="17"/>
|
||||
</backdrop>
|
||||
<backdrop name="lamp36" element="reellamp" state="0">
|
||||
<bounds x="260" y="317" width="50" height="17"/>
|
||||
</backdrop>
|
||||
<backdrop name="lamp37" element="reellamp" state="0">
|
||||
<bounds x="260" y="333" width="50" height="17"/>
|
||||
</backdrop>
|
||||
|
||||
<backdrop name="lamp48" element="reellamp" state="0">
|
||||
<bounds x="310" y="300" width="50" height="17"/>
|
||||
</backdrop>
|
||||
<backdrop name="lamp49" element="reellamp" state="0">
|
||||
<bounds x="310" y="317" width="50" height="17"/>
|
||||
</backdrop>
|
||||
<backdrop name="lamp50" element="reellamp" state="0">
|
||||
<bounds x="310" y="333" width="50" height="17"/>
|
||||
</backdrop>
|
||||
|
||||
<backdrop name="lamp51" element="reellamp" state="0">
|
||||
<bounds x="210" y="360" width="50" height="17"/>
|
||||
</backdrop>
|
||||
<backdrop name="lamp52" element="reellamp" state="0">
|
||||
<bounds x="210" y="377" width="50" height="17"/>
|
||||
</backdrop>
|
||||
<backdrop name="lamp53" element="reellamp" state="0">
|
||||
<bounds x="210" y="393" width="50" height="17"/>
|
||||
</backdrop>
|
||||
|
||||
<backdrop name="sreel1" element="SteppersReel1" state="0">
|
||||
<bounds x="210" y="300" width="50" height="50"/>
|
||||
|
Loading…
Reference in New Issue
Block a user