mirror of
https://github.com/holub/mame
synced 2025-04-25 17:56:43 +03:00
Added support for horizontal 'belt' reels which may be needed for future AWP titles. To invoke, add an attribute "beltreel" to the reel element in the layout, and set it to 1. [J. Wallace]
This commit is contained in:
parent
80b2b403e6
commit
3f5b920514
@ -666,6 +666,8 @@ layout_element::component::component(running_machine &machine, xml_data_node &co
|
|||||||
m_stateoffset = xml_get_attribute_int_with_subst(machine, compnode, "stateoffset", 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_numsymbolsvisible = xml_get_attribute_int_with_subst(machine, compnode, "numsymbolsvisible", 3);
|
||||||
m_reelreversed = xml_get_attribute_int_with_subst(machine, compnode, "reelreversed", 0);
|
m_reelreversed = xml_get_attribute_int_with_subst(machine, compnode, "reelreversed", 0);
|
||||||
|
m_beltreel = xml_get_attribute_int_with_subst(machine, compnode, "beltreel", 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// led7seg nodes
|
// led7seg nodes
|
||||||
@ -981,6 +983,12 @@ 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 */
|
/* 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)
|
void layout_element::component::draw_reel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state)
|
||||||
{
|
{
|
||||||
|
if (m_beltreel)
|
||||||
|
{
|
||||||
|
draw_beltreel(machine,dest,bounds,state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
const int max_state_used = 0x10000;
|
const int max_state_used = 0x10000;
|
||||||
|
|
||||||
// shift the reels a bit based on this param, allows fine tuning
|
// shift the reels a bit based on this param, allows fine tuning
|
||||||
@ -996,6 +1004,8 @@ void layout_element::component::draw_reel(running_machine &machine, bitmap_argb3
|
|||||||
render_font *font = machine.render().font_alloc("default");
|
render_font *font = machine.render().font_alloc("default");
|
||||||
float aspect = 1.0f;
|
float aspect = 1.0f;
|
||||||
INT32 width;
|
INT32 width;
|
||||||
|
|
||||||
|
|
||||||
int curry = 0;
|
int curry = 0;
|
||||||
int num_shown = m_numsymbolsvisible;
|
int num_shown = m_numsymbolsvisible;
|
||||||
|
|
||||||
@ -1124,14 +1134,162 @@ void layout_element::component::draw_reel(running_machine &machine, bitmap_argb3
|
|||||||
|
|
||||||
curry += ourheight/num_shown;
|
curry += ourheight/num_shown;
|
||||||
}
|
}
|
||||||
|
// free the temporary bitmap and font
|
||||||
|
machine.render().font_free(font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void layout_element::component::draw_beltreel(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
|
||||||
|
int use_state = (state + m_stateoffset) % max_state_used;
|
||||||
|
|
||||||
|
// compute premultiplied colors
|
||||||
|
UINT32 r = m_color.r * 255.0;
|
||||||
|
UINT32 g = m_color.g * 255.0;
|
||||||
|
UINT32 b = m_color.b * 255.0;
|
||||||
|
UINT32 a = m_color.a * 255.0;
|
||||||
|
|
||||||
|
// get the width of the string
|
||||||
|
render_font *font = machine.render().font_alloc("default");
|
||||||
|
float aspect = 1.0f;
|
||||||
|
INT32 width;
|
||||||
|
int currx = 0;
|
||||||
|
int num_shown = m_numsymbolsvisible;
|
||||||
|
|
||||||
|
int ourwidth = bounds.width();
|
||||||
|
|
||||||
|
for (int fruit = 0;fruit<m_numstops;fruit++)
|
||||||
|
{
|
||||||
|
int basex;
|
||||||
|
if (m_reelreversed==1)
|
||||||
|
{
|
||||||
|
basex = bounds.min_x + ((use_state)*(ourwidth/num_shown)/(max_state_used/m_numstops)) + currx;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
basex = bounds.min_x - ((use_state)*(ourwidth/num_shown)/(max_state_used/m_numstops)) + currx;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrap around...
|
||||||
|
if (basex < bounds.min_x)
|
||||||
|
basex += ((max_state_used)*(ourwidth/num_shown)/(max_state_used/m_numstops));
|
||||||
|
if (basex > bounds.max_x)
|
||||||
|
basex -= ((max_state_used)*(ourwidth/num_shown)/(max_state_used/m_numstops));
|
||||||
|
|
||||||
|
int endpos = basex+(ourwidth/num_shown);
|
||||||
|
|
||||||
|
// only render the symbol / text if it's atually in view because the code is SLOW
|
||||||
|
if ((endpos >= bounds.min_x) && (basex <= bounds.max_x))
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
width = font->string_width(dest.height(), aspect, m_stopnames[fruit]);
|
||||||
|
if (width < bounds.width())
|
||||||
|
break;
|
||||||
|
aspect *= 0.9f;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 curx;
|
||||||
|
curx = bounds.min_x;
|
||||||
|
|
||||||
|
if (m_file[fruit])
|
||||||
|
if (!m_bitmap[fruit].valid())
|
||||||
|
load_reel_bitmap(fruit);
|
||||||
|
|
||||||
|
if (m_file[fruit]) // render gfx
|
||||||
|
{
|
||||||
|
bitmap_argb32 tempbitmap2(ourwidth/num_shown, dest.height());
|
||||||
|
|
||||||
|
if (m_bitmap[fruit].valid())
|
||||||
|
{
|
||||||
|
render_resample_argb_bitmap_hq(tempbitmap2, m_bitmap[fruit], m_color);
|
||||||
|
|
||||||
|
for (int y = 0; y < dest.height(); y++)
|
||||||
|
{
|
||||||
|
int effy = y;
|
||||||
|
|
||||||
|
if (effy >= bounds.min_y && effy <= bounds.max_y)
|
||||||
|
{
|
||||||
|
UINT32 *src = &tempbitmap2.pix32(y);
|
||||||
|
UINT32 *d = &dest.pix32(effy);
|
||||||
|
for (int x = 0; x < ourwidth/num_shown; x++)
|
||||||
|
{
|
||||||
|
int effx = basex + x;
|
||||||
|
if (effx >= bounds.min_x && effx <= bounds.max_x)
|
||||||
|
{
|
||||||
|
UINT32 spix = rgb_t(src[x]).a();
|
||||||
|
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, dest.height(), aspect, *s, chbounds);
|
||||||
|
|
||||||
|
// copy the data into the target
|
||||||
|
for (int y = 0; y < chbounds.height(); y++)
|
||||||
|
{
|
||||||
|
int effy = 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 = basex + curx + x;
|
||||||
|
if (effx >= bounds.min_x && effx <= bounds.max_x)
|
||||||
|
{
|
||||||
|
UINT32 spix = rgb_t(src[x]).a();
|
||||||
|
if (spix != 0)
|
||||||
|
{
|
||||||
|
rgb_t dpix = d[effx];
|
||||||
|
UINT32 ta = (a * (spix + 1)) >> 8;
|
||||||
|
UINT32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8;
|
||||||
|
UINT32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8;
|
||||||
|
UINT32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8;
|
||||||
|
d[effx] = rgb_t(tr, tg, tb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// advance in the X direction
|
||||||
|
curx += font->char_width(dest.height(), aspect, *s);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currx += ourwidth/num_shown;
|
||||||
|
}
|
||||||
|
|
||||||
// free the temporary bitmap and font
|
// free the temporary bitmap and font
|
||||||
machine.render().font_free(font);
|
machine.render().font_free(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// load_bitmap - load a PNG file with artwork for
|
// load_bitmap - load a PNG file with artwork for
|
||||||
// a component
|
// a component
|
||||||
|
@ -105,6 +105,7 @@ private:
|
|||||||
void draw_text(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds);
|
void draw_text(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds);
|
||||||
void draw_simplecounter(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
|
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 draw_reel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
|
||||||
|
void draw_beltreel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
|
||||||
void load_bitmap();
|
void load_bitmap();
|
||||||
void load_reel_bitmap(int number);
|
void load_reel_bitmap(int number);
|
||||||
void draw_led7seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
|
void draw_led7seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
|
||||||
@ -148,7 +149,7 @@ private:
|
|||||||
int m_stateoffset;
|
int m_stateoffset;
|
||||||
int m_reelreversed;
|
int m_reelreversed;
|
||||||
int m_numsymbolsvisible;
|
int m_numsymbolsvisible;
|
||||||
|
int m_beltreel;
|
||||||
};
|
};
|
||||||
|
|
||||||
// a texture encapsulates a texture for a given element in a given state
|
// a texture encapsulates a texture for a given element in a given state
|
||||||
|
Loading…
Reference in New Issue
Block a user