Previous 199869 Revisions Next

r33775 Tuesday 9th December, 2014 at 18:44:01 UTC by Jürgen Buchmüller
Rename led8seg to led8seg{,_gts1} and CTYPE_LED8SEG{,_GTS1} as per hap's request. (nw)
[src/emu]rendlay.c rendlay.h
[src/mame/layout]gts1.lay

trunk/src/emu/rendlay.c
r242286r242287
9494
9595enum
9696{
97   LINE_CAP_NONE = 0,
98   LINE_CAP_START = 1,
99   LINE_CAP_END = 2
97    LINE_CAP_NONE = 0,
98    LINE_CAP_START = 1,
99    LINE_CAP_END = 2
100100};
101101
102102
r242286r242287
120120
121121inline int gcd(int a, int b)
122122{
123   while (b != 0)
124   {
125      int t = b;
126      b = a % b;
127      a = t;
128   }
129   return a;
123    while (b != 0)
124    {
125        int t = b;
126        b = a % b;
127        a = t;
128    }
129    return a;
130130}
131131
132132
r242286r242287
137137
138138inline void reduce_fraction(int &num, int &den)
139139{
140   // search the greatest common divisor
141   int div = gcd(num, den);
140    // search the greatest common divisor
141    int div = gcd(num, den);
142142
143   // reduce the fraction if a common divisor has been found
144   if (div > 1)
145   {
146      num /= div;
147      den /= div;
148   }
143    // reduce the fraction if a common divisor has been found
144    if (div > 1)
145    {
146        num /= div;
147        den /= div;
148    }
149149}
150150
151151
r242286r242287
161161
162162static int get_variable_value(running_machine &machine, const char *string, char **outputptr)
163163{
164   char temp[100];
164    char temp[100];
165165
166   // screen 0 parameters
167   screen_device_iterator iter(machine.root_device());
168   int scrnum = 0;
169   for (const screen_device *device = iter.first(); device != NULL; device = iter.next(), scrnum++)
170   {
171      // native X aspect factor
172      sprintf(temp, "~scr%dnativexaspect~", scrnum);
173      if (!strncmp(string, temp, strlen(temp)))
174      {
175         int num = device->visible_area().width();
176         int den = device->visible_area().height();
177         reduce_fraction(num, den);
178         *outputptr += sprintf(*outputptr, "%d", num);
179         return strlen(temp);
180      }
166    // screen 0 parameters
167    screen_device_iterator iter(machine.root_device());
168    int scrnum = 0;
169    for (const screen_device *device = iter.first(); device != NULL; device = iter.next(), scrnum++)
170    {
171        // native X aspect factor
172        sprintf(temp, "~scr%dnativexaspect~", scrnum);
173        if (!strncmp(string, temp, strlen(temp)))
174        {
175            int num = device->visible_area().width();
176            int den = device->visible_area().height();
177            reduce_fraction(num, den);
178            *outputptr += sprintf(*outputptr, "%d", num);
179            return strlen(temp);
180        }
181181
182      // native Y aspect factor
183      sprintf(temp, "~scr%dnativeyaspect~", scrnum);
184      if (!strncmp(string, temp, strlen(temp)))
185      {
186         int num = device->visible_area().width();
187         int den = device->visible_area().height();
188         reduce_fraction(num, den);
189         *outputptr += sprintf(*outputptr, "%d", den);
190         return strlen(temp);
191      }
182        // native Y aspect factor
183        sprintf(temp, "~scr%dnativeyaspect~", scrnum);
184        if (!strncmp(string, temp, strlen(temp)))
185        {
186            int num = device->visible_area().width();
187            int den = device->visible_area().height();
188            reduce_fraction(num, den);
189            *outputptr += sprintf(*outputptr, "%d", den);
190            return strlen(temp);
191        }
192192
193      // native width
194      sprintf(temp, "~scr%dwidth~", scrnum);
195      if (!strncmp(string, temp, strlen(temp)))
196      {
197         *outputptr += sprintf(*outputptr, "%d", device->visible_area().width());
198         return strlen(temp);
199      }
193        // native width
194        sprintf(temp, "~scr%dwidth~", scrnum);
195        if (!strncmp(string, temp, strlen(temp)))
196        {
197            *outputptr += sprintf(*outputptr, "%d", device->visible_area().width());
198            return strlen(temp);
199        }
200200
201      // native height
202      sprintf(temp, "~scr%dheight~", scrnum);
203      if (!strncmp(string, temp, strlen(temp)))
204      {
205         *outputptr += sprintf(*outputptr, "%d", device->visible_area().height());
206         return strlen(temp);
207      }
208   }
201        // native height
202        sprintf(temp, "~scr%dheight~", scrnum);
203        if (!strncmp(string, temp, strlen(temp)))
204        {
205            *outputptr += sprintf(*outputptr, "%d", device->visible_area().height());
206            return strlen(temp);
207        }
208    }
209209
210   // default: copy the first character and continue
211   **outputptr = *string;
212   *outputptr += 1;
213   return 1;
210    // default: copy the first character and continue
211    **outputptr = *string;
212    *outputptr += 1;
213    return 1;
214214}
215215
216216
r242286r242287
222222
223223static const char *xml_get_attribute_string_with_subst(running_machine &machine, xml_data_node &node, const char *attribute, const char *defvalue)
224224{
225   const char *str = xml_get_attribute_string(&node, attribute, NULL);
226   static char buffer[1000];
225    const char *str = xml_get_attribute_string(&node, attribute, NULL);
226    static char buffer[1000];
227227
228   // if nothing, just return the default
229   if (str == NULL)
230      return defvalue;
228    // if nothing, just return the default
229    if (str == NULL)
230        return defvalue;
231231
232   // if no tildes, don't worry
233   if (strchr(str, '~') == NULL)
234      return str;
232    // if no tildes, don't worry
233    if (strchr(str, '~') == NULL)
234        return str;
235235
236   // make a copy of the string, doing substitutions along the way
237   const char *s;
238   char *d;
239   for (s = str, d = buffer; *s != 0; )
240   {
241      // if not a variable, just copy
242      if (*s != '~')
243         *d++ = *s++;
236    // make a copy of the string, doing substitutions along the way
237    const char *s;
238    char *d;
239    for (s = str, d = buffer; *s != 0; )
240    {
241        // if not a variable, just copy
242        if (*s != '~')
243            *d++ = *s++;
244244
245      // extract the variable
246      else
247         s += get_variable_value(machine, s, &d);
248   }
249   *d = 0;
250   return buffer;
245        // extract the variable
246        else
247            s += get_variable_value(machine, s, &d);
248    }
249    *d = 0;
250    return buffer;
251251}
252252
253253
r242286r242287
259259
260260static int xml_get_attribute_int_with_subst(running_machine &machine, xml_data_node &node, const char *attribute, int defvalue)
261261{
262   const char *string = xml_get_attribute_string_with_subst(machine, node, attribute, NULL);
263   int value;
262    const char *string = xml_get_attribute_string_with_subst(machine, node, attribute, NULL);
263    int value;
264264
265   if (string == NULL)
266      return defvalue;
267   if (string[0] == '$')
268      return (sscanf(&string[1], "%X", &value) == 1) ? value : defvalue;
269   if (string[0] == '0' && string[1] == 'x')
270      return (sscanf(&string[2], "%X", &value) == 1) ? value : defvalue;
271   if (string[0] == '#')
272      return (sscanf(&string[1], "%d", &value) == 1) ? value : defvalue;
273   return (sscanf(&string[0], "%d", &value) == 1) ? value : defvalue;
265    if (string == NULL)
266        return defvalue;
267    if (string[0] == '$')
268        return (sscanf(&string[1], "%X", &value) == 1) ? value : defvalue;
269    if (string[0] == '0' && string[1] == 'x')
270        return (sscanf(&string[2], "%X", &value) == 1) ? value : defvalue;
271    if (string[0] == '#')
272        return (sscanf(&string[1], "%d", &value) == 1) ? value : defvalue;
273    return (sscanf(&string[0], "%d", &value) == 1) ? value : defvalue;
274274}
275275
276276
r242286r242287
282282
283283static float xml_get_attribute_float_with_subst(running_machine &machine, xml_data_node &node, const char *attribute, float defvalue)
284284{
285   const char *string = xml_get_attribute_string_with_subst(machine, node, attribute, NULL);
286   float value;
285    const char *string = xml_get_attribute_string_with_subst(machine, node, attribute, NULL);
286    float value;
287287
288   if (string == NULL || sscanf(string, "%f", &value) != 1)
289      return defvalue;
290   return value;
288    if (string == NULL || sscanf(string, "%f", &value) != 1)
289        return defvalue;
290    return value;
291291}
292292
293293
r242286r242287
297297
298298void parse_bounds(running_machine &machine, xml_data_node *boundsnode, render_bounds &bounds)
299299{
300   // skip if nothing
301   if (boundsnode == NULL)
302   {
303      bounds.x0 = bounds.y0 = 0.0f;
304      bounds.x1 = bounds.y1 = 1.0f;
305      return;
306   }
300    // skip if nothing
301    if (boundsnode == NULL)
302    {
303        bounds.x0 = bounds.y0 = 0.0f;
304        bounds.x1 = bounds.y1 = 1.0f;
305        return;
306    }
307307
308   // parse out the data
309   if (xml_get_attribute(boundsnode, "left") != NULL)
310   {
311      // left/right/top/bottom format
312      bounds.x0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "left", 0.0f);
313      bounds.x1 = xml_get_attribute_float_with_subst(machine, *boundsnode, "right", 1.0f);
314      bounds.y0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "top", 0.0f);
315      bounds.y1 = xml_get_attribute_float_with_subst(machine, *boundsnode, "bottom", 1.0f);
316   }
317   else if (xml_get_attribute(boundsnode, "x") != NULL)
318   {
319      // x/y/width/height format
320      bounds.x0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "x", 0.0f);
321      bounds.x1 = bounds.x0 + xml_get_attribute_float_with_subst(machine, *boundsnode, "width", 1.0f);
322      bounds.y0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "y", 0.0f);
323      bounds.y1 = bounds.y0 + xml_get_attribute_float_with_subst(machine, *boundsnode, "height", 1.0f);
324   }
325   else
326      throw emu_fatalerror("Illegal bounds value in XML");
308    // parse out the data
309    if (xml_get_attribute(boundsnode, "left") != NULL)
310    {
311        // left/right/top/bottom format
312        bounds.x0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "left", 0.0f);
313        bounds.x1 = xml_get_attribute_float_with_subst(machine, *boundsnode, "right", 1.0f);
314        bounds.y0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "top", 0.0f);
315        bounds.y1 = xml_get_attribute_float_with_subst(machine, *boundsnode, "bottom", 1.0f);
316    }
317    else if (xml_get_attribute(boundsnode, "x") != NULL)
318    {
319        // x/y/width/height format
320        bounds.x0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "x", 0.0f);
321        bounds.x1 = bounds.x0 + xml_get_attribute_float_with_subst(machine, *boundsnode, "width", 1.0f);
322        bounds.y0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "y", 0.0f);
323        bounds.y1 = bounds.y0 + xml_get_attribute_float_with_subst(machine, *boundsnode, "height", 1.0f);
324    }
325    else
326        throw emu_fatalerror("Illegal bounds value in XML");
327327
328   // check for errors
329   if (bounds.x0 > bounds.x1 || bounds.y0 > bounds.y1)
330      throw emu_fatalerror("Illegal bounds value in XML: (%f-%f)-(%f-%f)", bounds.x0, bounds.x1, bounds.y0, bounds.y1);
328    // check for errors
329    if (bounds.x0 > bounds.x1 || bounds.y0 > bounds.y1)
330        throw emu_fatalerror("Illegal bounds value in XML: (%f-%f)-(%f-%f)", bounds.x0, bounds.x1, bounds.y0, bounds.y1);
331331}
332332
333333
r242286r242287
337337
338338void parse_color(running_machine &machine, xml_data_node *colornode, render_color &color)
339339{
340   // skip if nothing
341   if (colornode == NULL)
342   {
343      color.r = color.g = color.b = color.a = 1.0f;
344      return;
345   }
340    // skip if nothing
341    if (colornode == NULL)
342    {
343        color.r = color.g = color.b = color.a = 1.0f;
344        return;
345    }
346346
347   // parse out the data
348   color.r = xml_get_attribute_float_with_subst(machine, *colornode, "red", 1.0);
349   color.g = xml_get_attribute_float_with_subst(machine, *colornode, "green", 1.0);
350   color.b = xml_get_attribute_float_with_subst(machine, *colornode, "blue", 1.0);
351   color.a = xml_get_attribute_float_with_subst(machine, *colornode, "alpha", 1.0);
347    // parse out the data
348    color.r = xml_get_attribute_float_with_subst(machine, *colornode, "red", 1.0);
349    color.g = xml_get_attribute_float_with_subst(machine, *colornode, "green", 1.0);
350    color.b = xml_get_attribute_float_with_subst(machine, *colornode, "blue", 1.0);
351    color.a = xml_get_attribute_float_with_subst(machine, *colornode, "alpha", 1.0);
352352
353   // check for errors
354   if (color.r < 0.0 || color.r > 1.0 || color.g < 0.0 || color.g > 1.0 ||
355      color.b < 0.0 || color.b > 1.0 || color.a < 0.0 || color.a > 1.0)
356      throw emu_fatalerror("Illegal ARGB color value in XML: %f,%f,%f,%f", color.r, color.g, color.b, color.a);
353    // check for errors
354    if (color.r < 0.0 || color.r > 1.0 || color.g < 0.0 || color.g > 1.0 ||
355        color.b < 0.0 || color.b > 1.0 || color.a < 0.0 || color.a > 1.0)
356        throw emu_fatalerror("Illegal ARGB color value in XML: %f,%f,%f,%f", color.r, color.g, color.b, color.a);
357357}
358358
359359
r242286r242287
364364
365365static void parse_orientation(running_machine &machine, xml_data_node *orientnode, int &orientation)
366366{
367   // skip if nothing
368   if (orientnode == NULL)
369   {
370      orientation = ROT0;
371      return;
372   }
367    // skip if nothing
368    if (orientnode == NULL)
369    {
370        orientation = ROT0;
371        return;
372    }
373373
374   // parse out the data
375   int rotate = xml_get_attribute_int_with_subst(machine, *orientnode, "rotate", 0);
376   switch (rotate)
377   {
378      case 0:     orientation = ROT0;     break;
379      case 90:    orientation = ROT90;    break;
380      case 180:   orientation = ROT180;   break;
381      case 270:   orientation = ROT270;   break;
382      default:    throw emu_fatalerror("Invalid rotation in XML orientation node: %d", rotate);
383   }
384   if (strcmp("yes", xml_get_attribute_string_with_subst(machine, *orientnode, "swapxy", "no")) == 0)
385      orientation ^= ORIENTATION_SWAP_XY;
386   if (strcmp("yes", xml_get_attribute_string_with_subst(machine, *orientnode, "flipx", "no")) == 0)
387      orientation ^= ORIENTATION_FLIP_X;
388   if (strcmp("yes", xml_get_attribute_string_with_subst(machine, *orientnode, "flipy", "no")) == 0)
389      orientation ^= ORIENTATION_FLIP_Y;
374    // parse out the data
375    int rotate = xml_get_attribute_int_with_subst(machine, *orientnode, "rotate", 0);
376    switch (rotate)
377    {
378        case 0:     orientation = ROT0;     break;
379        case 90:    orientation = ROT90;    break;
380        case 180:   orientation = ROT180;   break;
381        case 270:   orientation = ROT270;   break;
382        default:    throw emu_fatalerror("Invalid rotation in XML orientation node: %d", rotate);
383    }
384    if (strcmp("yes", xml_get_attribute_string_with_subst(machine, *orientnode, "swapxy", "no")) == 0)
385        orientation ^= ORIENTATION_SWAP_XY;
386    if (strcmp("yes", xml_get_attribute_string_with_subst(machine, *orientnode, "flipx", "no")) == 0)
387        orientation ^= ORIENTATION_FLIP_X;
388    if (strcmp("yes", xml_get_attribute_string_with_subst(machine, *orientnode, "flipy", "no")) == 0)
389        orientation ^= ORIENTATION_FLIP_Y;
390390}
391391
392392
r242286r242287
400400//-------------------------------------------------
401401
402402layout_element::layout_element(running_machine &machine, xml_data_node &elemnode, const char *dirname)
403   : m_next(NULL),
404      m_machine(machine),
405      m_defstate(0),
406      m_maxstate(0)
403    : m_next(NULL),
404        m_machine(machine),
405        m_defstate(0),
406        m_maxstate(0)
407407{
408   // extract the name
409   const char *name = xml_get_attribute_string_with_subst(machine, elemnode, "name", NULL);
410   if (name == NULL)
411      throw emu_fatalerror("All layout elements must have a name!\n");
412   m_name = name;
408    // extract the name
409    const char *name = xml_get_attribute_string_with_subst(machine, elemnode, "name", NULL);
410    if (name == NULL)
411        throw emu_fatalerror("All layout elements must have a name!\n");
412    m_name = name;
413413
414   // get the default state
415   m_defstate = xml_get_attribute_int_with_subst(machine, elemnode, "defstate", -1);
414    // get the default state
415    m_defstate = xml_get_attribute_int_with_subst(machine, elemnode, "defstate", -1);
416416
417   // parse components in order
418   bool first = true;
419   render_bounds bounds = { 0 };
420   for (xml_data_node *compnode = elemnode.child; compnode != NULL; compnode = compnode->next)
421   {
422      // allocate a new component
423      component &newcomp = m_complist.append(*global_alloc(component(machine, *compnode, dirname)));
417    // parse components in order
418    bool first = true;
419    render_bounds bounds = { 0 };
420    for (xml_data_node *compnode = elemnode.child; compnode != NULL; compnode = compnode->next)
421    {
422        // allocate a new component
423        component &newcomp = m_complist.append(*global_alloc(component(machine, *compnode, dirname)));
424424
425      // accumulate bounds
426      if (first)
427         bounds = newcomp.m_bounds;
428      else
429         union_render_bounds(&bounds, &newcomp.m_bounds);
430      first = false;
425        // accumulate bounds
426        if (first)
427            bounds = newcomp.m_bounds;
428        else
429            union_render_bounds(&bounds, &newcomp.m_bounds);
430        first = false;
431431
432      // determine the maximum state
433      if (newcomp.m_state > m_maxstate)
434         m_maxstate = newcomp.m_state;
435      if (newcomp.m_type == component::CTYPE_LED7SEG || newcomp.m_type == component::CTYPE_LED8SEG)
436         m_maxstate = 255;
437      if (newcomp.m_type == component::CTYPE_LED14SEG)
438         m_maxstate = 16383;
439      if (newcomp.m_type == component::CTYPE_LED14SEGSC || newcomp.m_type == component::CTYPE_LED16SEG)
440         m_maxstate = 65535;
441      if (newcomp.m_type == component::CTYPE_LED16SEGSC)
442         m_maxstate = 262143;
443      if (newcomp.m_type == component::CTYPE_DOTMATRIX)
444         m_maxstate = 255;
445      if (newcomp.m_type == component::CTYPE_DOTMATRIX5DOT)
446         m_maxstate = 31;
447      if (newcomp.m_type == component::CTYPE_DOTMATRIXDOT)
448         m_maxstate = 1;
449      if (newcomp.m_type == component::CTYPE_SIMPLECOUNTER)
450         m_maxstate = xml_get_attribute_int_with_subst(machine, *compnode, "maxstate", 999);
451      if (newcomp.m_type == component::CTYPE_REEL)
452         m_maxstate = 65536;
453   }
432        // determine the maximum state
433        if (newcomp.m_state > m_maxstate)
434            m_maxstate = newcomp.m_state;
435        if (newcomp.m_type == component::CTYPE_LED7SEG || newcomp.m_type == component::CTYPE_LED8SEG_GTS1)
436            m_maxstate = 255;
437        if (newcomp.m_type == component::CTYPE_LED14SEG)
438            m_maxstate = 16383;
439        if (newcomp.m_type == component::CTYPE_LED14SEGSC || newcomp.m_type == component::CTYPE_LED16SEG)
440            m_maxstate = 65535;
441        if (newcomp.m_type == component::CTYPE_LED16SEGSC)
442            m_maxstate = 262143;
443        if (newcomp.m_type == component::CTYPE_DOTMATRIX)
444            m_maxstate = 255;
445        if (newcomp.m_type == component::CTYPE_DOTMATRIX5DOT)
446            m_maxstate = 31;
447        if (newcomp.m_type == component::CTYPE_DOTMATRIXDOT)
448            m_maxstate = 1;
449        if (newcomp.m_type == component::CTYPE_SIMPLECOUNTER)
450            m_maxstate = xml_get_attribute_int_with_subst(machine, *compnode, "maxstate", 999);
451        if (newcomp.m_type == component::CTYPE_REEL)
452            m_maxstate = 65536;
453    }
454454
455   if (m_complist.first() != NULL)
456   {
457      // determine the scale/offset for normalization
458      float xoffs = bounds.x0;
459      float yoffs = bounds.y0;
460      float xscale = 1.0f / (bounds.x1 - bounds.x0);
461      float yscale = 1.0f / (bounds.y1 - bounds.y0);
455    if (m_complist.first() != NULL)
456    {
457        // determine the scale/offset for normalization
458        float xoffs = bounds.x0;
459        float yoffs = bounds.y0;
460        float xscale = 1.0f / (bounds.x1 - bounds.x0);
461        float yscale = 1.0f / (bounds.y1 - bounds.y0);
462462
463      // normalize all the component bounds
464      for (component *curcomp = m_complist.first(); curcomp != NULL; curcomp = curcomp->next())
465      {
466         curcomp->m_bounds.x0 = (curcomp->m_bounds.x0 - xoffs) * xscale;
467         curcomp->m_bounds.x1 = (curcomp->m_bounds.x1 - xoffs) * xscale;
468         curcomp->m_bounds.y0 = (curcomp->m_bounds.y0 - yoffs) * yscale;
469         curcomp->m_bounds.y1 = (curcomp->m_bounds.y1 - yoffs) * yscale;
470      }
471   }
463        // normalize all the component bounds
464        for (component *curcomp = m_complist.first(); curcomp != NULL; curcomp = curcomp->next())
465        {
466            curcomp->m_bounds.x0 = (curcomp->m_bounds.x0 - xoffs) * xscale;
467            curcomp->m_bounds.x1 = (curcomp->m_bounds.x1 - xoffs) * xscale;
468            curcomp->m_bounds.y0 = (curcomp->m_bounds.y0 - yoffs) * yscale;
469            curcomp->m_bounds.y1 = (curcomp->m_bounds.y1 - yoffs) * yscale;
470        }
471    }
472472
473   // allocate an array of element textures for the states
474   m_elemtex.resize(m_maxstate + 1);
473    // allocate an array of element textures for the states
474    m_elemtex.resize(m_maxstate + 1);
475475}
476476
477477
r242286r242287
492492
493493render_texture *layout_element::state_texture(int state)
494494{
495   assert(state <= m_maxstate);
496   if (m_elemtex[state].m_texture == NULL)
497   {
498      m_elemtex[state].m_element = this;
499      m_elemtex[state].m_state = state;
500      m_elemtex[state].m_texture = machine().render().texture_alloc(element_scale, &m_elemtex[state]);
501   }
502   return m_elemtex[state].m_texture;
495    assert(state <= m_maxstate);
496    if (m_elemtex[state].m_texture == NULL)
497    {
498        m_elemtex[state].m_element = this;
499        m_elemtex[state].m_state = state;
500        m_elemtex[state].m_texture = machine().render().texture_alloc(element_scale, &m_elemtex[state]);
501    }
502    return m_elemtex[state].m_texture;
503503}
504504
505505
r242286r242287
511511
512512void layout_element::element_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param)
513513{
514   texture *elemtex = (texture *)param;
514    texture *elemtex = (texture *)param;
515515
516   // iterate over components that are part of the current state
517   for (component *curcomp = elemtex->m_element->m_complist.first(); curcomp != NULL; curcomp = curcomp->next())
518      if (curcomp->m_state == -1 || curcomp->m_state == elemtex->m_state)
519      {
520         // get the local scaled bounds
521         rectangle bounds;
522         bounds.min_x = render_round_nearest(curcomp->bounds().x0 * dest.width());
523         bounds.min_y = render_round_nearest(curcomp->bounds().y0 * dest.height());
524         bounds.max_x = render_round_nearest(curcomp->bounds().x1 * dest.width());
525         bounds.max_y = render_round_nearest(curcomp->bounds().y1 * dest.height());
526         bounds &= dest.cliprect();
516    // iterate over components that are part of the current state
517    for (component *curcomp = elemtex->m_element->m_complist.first(); curcomp != NULL; curcomp = curcomp->next())
518        if (curcomp->m_state == -1 || curcomp->m_state == elemtex->m_state)
519        {
520            // get the local scaled bounds
521            rectangle bounds;
522            bounds.min_x = render_round_nearest(curcomp->bounds().x0 * dest.width());
523            bounds.min_y = render_round_nearest(curcomp->bounds().y0 * dest.height());
524            bounds.max_x = render_round_nearest(curcomp->bounds().x1 * dest.width());
525            bounds.max_y = render_round_nearest(curcomp->bounds().y1 * dest.height());
526            bounds &= dest.cliprect();
527527
528         // based on the component type, add to the texture
529         curcomp->draw(elemtex->m_element->machine(), dest, bounds, elemtex->m_state);
530      }
528            // based on the component type, add to the texture
529            curcomp->draw(elemtex->m_element->machine(), dest, bounds, elemtex->m_state);
530        }
531531}
532532
533533
r242286r242287
540540//-------------------------------------------------
541541
542542layout_element::texture::texture()
543   : m_element(NULL),
544      m_texture(NULL),
545      m_state(0)
543    : m_element(NULL),
544        m_texture(NULL),
545        m_state(0)
546546{
547547}
548548
r242286r242287
553553
554554layout_element::texture::~texture()
555555{
556   if (m_element != NULL)
557      m_element->machine().render().texture_free(m_texture);
556    if (m_element != NULL)
557        m_element->machine().render().texture_free(m_texture);
558558}
559559
560560
r242286r242287
568568//-------------------------------------------------
569569
570570layout_element::component::component(running_machine &machine, xml_data_node &compnode, const char *dirname)
571   : m_next(NULL),
572      m_type(CTYPE_INVALID),
573      m_state(0)
571    : m_next(NULL),
572        m_type(CTYPE_INVALID),
573        m_state(0)
574574{
575   for (int i=0;i<MAX_BITMAPS;i++)
576      m_hasalpha[i] = false;
575    for (int i=0;i<MAX_BITMAPS;i++)
576        m_hasalpha[i] = false;
577577
578   // fetch common data
579   m_state = xml_get_attribute_int_with_subst(machine, compnode, "state", -1);
580   parse_bounds(machine, xml_get_sibling(compnode.child, "bounds"), m_bounds);
581   parse_color(machine, xml_get_sibling(compnode.child, "color"), m_color);
578    // fetch common data
579    m_state = xml_get_attribute_int_with_subst(machine, compnode, "state", -1);
580    parse_bounds(machine, xml_get_sibling(compnode.child, "bounds"), m_bounds);
581    parse_color(machine, xml_get_sibling(compnode.child, "color"), m_color);
582582
583   // image nodes
584   if (strcmp(compnode.name, "image") == 0)
585   {
586      m_type = CTYPE_IMAGE;
587      if (dirname != NULL)
588         m_dirname = dirname;
589      m_imagefile[0] = xml_get_attribute_string_with_subst(machine, compnode, "file", "");
590      m_alphafile[0] = xml_get_attribute_string_with_subst(machine, compnode, "alphafile", "");
591      m_file[0].reset(global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ)));
592   }
583    // image nodes
584    if (strcmp(compnode.name, "image") == 0)
585    {
586        m_type = CTYPE_IMAGE;
587        if (dirname != NULL)
588            m_dirname = dirname;
589        m_imagefile[0] = xml_get_attribute_string_with_subst(machine, compnode, "file", "");
590        m_alphafile[0] = xml_get_attribute_string_with_subst(machine, compnode, "alphafile", "");
591        m_file[0].reset(global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ)));
592    }
593593
594   // text nodes
595   else if (strcmp(compnode.name, "text") == 0)
596   {
597      m_type = CTYPE_TEXT;
598      m_string = xml_get_attribute_string_with_subst(machine, compnode, "string", "");
599      m_textalign = xml_get_attribute_int_with_subst(machine, compnode, "align", 0);
600   }
594    // text nodes
595    else if (strcmp(compnode.name, "text") == 0)
596    {
597        m_type = CTYPE_TEXT;
598        m_string = xml_get_attribute_string_with_subst(machine, compnode, "string", "");
599        m_textalign = xml_get_attribute_int_with_subst(machine, compnode, "align", 0);
600    }
601601
602   // dotmatrix nodes
603   else if (strcmp(compnode.name, "dotmatrix") == 0)
604   {
605      m_type = CTYPE_DOTMATRIX;
606   }
607   else if (strcmp(compnode.name, "dotmatrix5dot") == 0)
608   {
609      m_type = CTYPE_DOTMATRIX5DOT;
610   }
611   else if (strcmp(compnode.name, "dotmatrixdot") == 0)
612   {
613      m_type = CTYPE_DOTMATRIXDOT;
614   }
602    // dotmatrix nodes
603    else if (strcmp(compnode.name, "dotmatrix") == 0)
604    {
605        m_type = CTYPE_DOTMATRIX;
606    }
607    else if (strcmp(compnode.name, "dotmatrix5dot") == 0)
608    {
609        m_type = CTYPE_DOTMATRIX5DOT;
610    }
611    else if (strcmp(compnode.name, "dotmatrixdot") == 0)
612    {
613        m_type = CTYPE_DOTMATRIXDOT;
614    }
615615
616   // simplecounter nodes
617   else if (strcmp(compnode.name, "simplecounter") == 0)
618   {
619      m_type = CTYPE_SIMPLECOUNTER;
620      m_digits = xml_get_attribute_int_with_subst(machine, compnode, "digits", 2);
621      m_textalign = xml_get_attribute_int_with_subst(machine, compnode, "align", 0);
622   }
616    // simplecounter nodes
617    else if (strcmp(compnode.name, "simplecounter") == 0)
618    {
619        m_type = CTYPE_SIMPLECOUNTER;
620        m_digits = xml_get_attribute_int_with_subst(machine, compnode, "digits", 2);
621        m_textalign = xml_get_attribute_int_with_subst(machine, compnode, "align", 0);
622    }
623623
624   // fruit machine reels
625   else if (strcmp(compnode.name, "reel") == 0)
626   {
627      m_type = CTYPE_REEL;
624    // fruit machine reels
625    else if (strcmp(compnode.name, "reel") == 0)
626    {
627        m_type = CTYPE_REEL;
628628
629      astring symbollist = xml_get_attribute_string_with_subst(machine, compnode, "symbollist", "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15");
629        astring symbollist = xml_get_attribute_string_with_subst(machine, compnode, "symbollist", "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15");
630630
631      // split out position names from string and figure out our number of symbols
632      int location = -1;
633      m_numstops = 0;
634      location=symbollist.find(0,",");
635      while (location!=-1)
636      {
637         m_stopnames[m_numstops] = symbollist;
638         m_stopnames[m_numstops].substr(0, location);
639         symbollist.substr(location+1, symbollist.len()-(location-1));
640         m_numstops++;
641         location=symbollist.find(0,",");
642      }
643      m_stopnames[m_numstops++] = symbollist;
631        // split out position names from string and figure out our number of symbols
632        int location = -1;
633        m_numstops = 0;
634        location=symbollist.find(0,",");
635        while (location!=-1)
636        {
637            m_stopnames[m_numstops] = symbollist;
638            m_stopnames[m_numstops].substr(0, location);
639            symbollist.substr(location+1, symbollist.len()-(location-1));
640            m_numstops++;
641            location=symbollist.find(0,",");
642        }
643        m_stopnames[m_numstops++] = symbollist;
644644
645      // careful, dirname is NULL if we're coming from internal layout, and our string assignment doesn't like that
646      if (dirname != NULL)
647         m_dirname = dirname;
645        // careful, dirname is NULL if we're coming from internal layout, and our string assignment doesn't like that
646        if (dirname != NULL)
647            m_dirname = dirname;
648648
649      for (int i=0;i<m_numstops;i++)
650      {
651         location=m_stopnames[i].find(0,":");
652         if (location!=-1)
653         {
654            m_imagefile[i] = m_stopnames[i];
655            m_stopnames[i].substr(0, location);
656            m_imagefile[i].substr(location+1, m_imagefile[i].len()-(location-1));
649        for (int i=0;i<m_numstops;i++)
650        {
651            location=m_stopnames[i].find(0,":");
652            if (location!=-1)
653            {
654                m_imagefile[i] = m_stopnames[i];
655                m_stopnames[i].substr(0, location);
656                m_imagefile[i].substr(location+1, m_imagefile[i].len()-(location-1));
657657
658            //m_alphafile[i] =
659            m_file[i].reset(global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ)));
660         }
661         else
662         {
663            //m_imagefile[i] = 0;
664            //m_alphafile[i] = 0;
665            m_file[i].reset();
666         }
667      }
658                //m_alphafile[i] =
659                m_file[i].reset(global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ)));
660            }
661            else
662            {
663                //m_imagefile[i] = 0;
664                //m_alphafile[i] = 0;
665                m_file[i].reset();
666            }
667        }
668668
669      m_stateoffset = xml_get_attribute_int_with_subst(machine, compnode, "stateoffset", 0);
670      m_numsymbolsvisible = xml_get_attribute_int_with_subst(machine, compnode, "numsymbolsvisible", 3);
671      m_reelreversed = xml_get_attribute_int_with_subst(machine, compnode, "reelreversed", 0);
672      m_beltreel = xml_get_attribute_int_with_subst(machine, compnode, "beltreel", 0);
669        m_stateoffset = xml_get_attribute_int_with_subst(machine, compnode, "stateoffset", 0);
670        m_numsymbolsvisible = xml_get_attribute_int_with_subst(machine, compnode, "numsymbolsvisible", 3);
671        m_reelreversed = xml_get_attribute_int_with_subst(machine, compnode, "reelreversed", 0);
672        m_beltreel = xml_get_attribute_int_with_subst(machine, compnode, "beltreel", 0);
673673
674   }
674    }
675675
676   // led7seg nodes
677   else if (strcmp(compnode.name, "led7seg") == 0)
678      m_type = CTYPE_LED7SEG;
676    // led7seg nodes
677    else if (strcmp(compnode.name, "led7seg") == 0)
678        m_type = CTYPE_LED7SEG;
679679
680   // led8seg nodes
681   else if (strcmp(compnode.name, "led8seg") == 0)
682      m_type = CTYPE_LED8SEG;
680    // led8seg_gts1 nodes
681    else if (strcmp(compnode.name, "led8seg_gts1") == 0)
682        m_type = CTYPE_LED8SEG_GTS1;
683683
684   // led14seg nodes
685   else if (strcmp(compnode.name, "led14seg") == 0)
686      m_type = CTYPE_LED14SEG;
684    // led14seg nodes
685    else if (strcmp(compnode.name, "led14seg") == 0)
686        m_type = CTYPE_LED14SEG;
687687
688   // led14segsc nodes
689   else if (strcmp(compnode.name, "led14segsc") == 0)
690      m_type = CTYPE_LED14SEGSC;
688    // led14segsc nodes
689    else if (strcmp(compnode.name, "led14segsc") == 0)
690        m_type = CTYPE_LED14SEGSC;
691691
692   // led16seg nodes
693   else if (strcmp(compnode.name, "led16seg") == 0)
694      m_type = CTYPE_LED16SEG;
692    // led16seg nodes
693    else if (strcmp(compnode.name, "led16seg") == 0)
694        m_type = CTYPE_LED16SEG;
695695
696   // led16segsc nodes
697   else if (strcmp(compnode.name, "led16segsc") == 0)
698      m_type = CTYPE_LED16SEGSC;
696    // led16segsc nodes
697    else if (strcmp(compnode.name, "led16segsc") == 0)
698        m_type = CTYPE_LED16SEGSC;
699699
700   // rect nodes
701   else if (strcmp(compnode.name, "rect") == 0)
702      m_type = CTYPE_RECT;
700    // rect nodes
701    else if (strcmp(compnode.name, "rect") == 0)
702        m_type = CTYPE_RECT;
703703
704   // disk nodes
705   else if (strcmp(compnode.name, "disk") == 0)
706      m_type = CTYPE_DISK;
704    // disk nodes
705    else if (strcmp(compnode.name, "disk") == 0)
706        m_type = CTYPE_DISK;
707707
708   // error otherwise
709   else
710      throw emu_fatalerror("Unknown element component: %s", compnode.name);
708    // error otherwise
709    else
710        throw emu_fatalerror("Unknown element component: %s", compnode.name);
711711}
712712
713713
r242286r242287
726726
727727void layout_element::component::draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state)
728728{
729   switch (m_type)
730   {
731      case CTYPE_IMAGE:
732         if (!m_bitmap[0].valid())
733            load_bitmap();
734         {
735            bitmap_argb32 destsub(dest, bounds);
736            render_resample_argb_bitmap_hq(destsub, m_bitmap[0], m_color);
737         }
738         break;
729    switch (m_type)
730    {
731        case CTYPE_IMAGE:
732            if (!m_bitmap[0].valid())
733                load_bitmap();
734            {
735                bitmap_argb32 destsub(dest, bounds);
736                render_resample_argb_bitmap_hq(destsub, m_bitmap[0], m_color);
737            }
738            break;
739739
740      case CTYPE_RECT:
741         draw_rect(dest, bounds);
742         break;
740        case CTYPE_RECT:
741            draw_rect(dest, bounds);
742            break;
743743
744      case CTYPE_DISK:
745         draw_disk(dest, bounds);
746         break;
744        case CTYPE_DISK:
745            draw_disk(dest, bounds);
746            break;
747747
748      case CTYPE_TEXT:
749         draw_text(machine, dest, bounds);
750         break;
748        case CTYPE_TEXT:
749            draw_text(machine, dest, bounds);
750            break;
751751
752      case CTYPE_LED7SEG:
753         draw_led7seg(dest, bounds, state);
754         break;
752        case CTYPE_LED7SEG:
753            draw_led7seg(dest, bounds, state);
754            break;
755755
756      case CTYPE_LED8SEG:
757         draw_led8seg(dest, bounds, state);
758         break;
756        case CTYPE_LED8SEG_GTS1:
757            draw_led8seg_gts1(dest, bounds, state);
758            break;
759759
760      case CTYPE_LED14SEG:
761         draw_led14seg(dest, bounds, state);
762         break;
760        case CTYPE_LED14SEG:
761            draw_led14seg(dest, bounds, state);
762            break;
763763
764      case CTYPE_LED16SEG:
765         draw_led16seg(dest, bounds, state);
766         break;
764        case CTYPE_LED16SEG:
765            draw_led16seg(dest, bounds, state);
766            break;
767767
768      case CTYPE_LED14SEGSC:
769         draw_led14segsc(dest, bounds, state);
770         break;
768        case CTYPE_LED14SEGSC:
769            draw_led14segsc(dest, bounds, state);
770            break;
771771
772      case CTYPE_LED16SEGSC:
773         draw_led16segsc(dest, bounds, state);
774         break;
772        case CTYPE_LED16SEGSC:
773            draw_led16segsc(dest, bounds, state);
774            break;
775775
776      case CTYPE_DOTMATRIX:
777         draw_dotmatrix(8, dest, bounds, state);
778         break;
776        case CTYPE_DOTMATRIX:
777            draw_dotmatrix(8, dest, bounds, state);
778            break;
779779
780      case CTYPE_DOTMATRIX5DOT:
781         draw_dotmatrix(5, dest, bounds, state);
782         break;
780        case CTYPE_DOTMATRIX5DOT:
781            draw_dotmatrix(5, dest, bounds, state);
782            break;
783783
784      case CTYPE_DOTMATRIXDOT:
785         draw_dotmatrix(1, dest, bounds, state);
786         break;
784        case CTYPE_DOTMATRIXDOT:
785            draw_dotmatrix(1, dest, bounds, state);
786            break;
787787
788      case CTYPE_SIMPLECOUNTER:
789         draw_simplecounter(machine, dest, bounds, state);
790         break;
788        case CTYPE_SIMPLECOUNTER:
789            draw_simplecounter(machine, dest, bounds, state);
790            break;
791791
792      case CTYPE_REEL:
793         draw_reel(machine, dest, bounds, state);
794         break;
792        case CTYPE_REEL:
793            draw_reel(machine, dest, bounds, state);
794            break;
795795
796      default:
797         throw emu_fatalerror("Unknown component type requested draw()");
798   }
796        default:
797            throw emu_fatalerror("Unknown component type requested draw()");
798    }
799799}
800800
801801
r242286r242287
806806
807807void layout_element::component::draw_rect(bitmap_argb32 &dest, const rectangle &bounds)
808808{
809   // compute premultiplied colors
810   UINT32 r = m_color.r * m_color.a * 255.0;
811   UINT32 g = m_color.g * m_color.a * 255.0;
812   UINT32 b = m_color.b * m_color.a * 255.0;
813   UINT32 inva = (1.0f - m_color.a) * 255.0;
809    // compute premultiplied colors
810    UINT32 r = m_color.r * m_color.a * 255.0;
811    UINT32 g = m_color.g * m_color.a * 255.0;
812    UINT32 b = m_color.b * m_color.a * 255.0;
813    UINT32 inva = (1.0f - m_color.a) * 255.0;
814814
815   // iterate over X and Y
816   for (UINT32 y = bounds.min_y; y <= bounds.max_y; y++)
817   {
818      for (UINT32 x = bounds.min_x; x <= bounds.max_x; x++)
819      {
820         UINT32 finalr = r;
821         UINT32 finalg = g;
822         UINT32 finalb = b;
815    // iterate over X and Y
816    for (UINT32 y = bounds.min_y; y <= bounds.max_y; y++)
817    {
818        for (UINT32 x = bounds.min_x; x <= bounds.max_x; x++)
819        {
820            UINT32 finalr = r;
821            UINT32 finalg = g;
822            UINT32 finalb = b;
823823
824         // if we're translucent, add in the destination pixel contribution
825         if (inva > 0)
826         {
827            rgb_t dpix = dest.pix32(y, x);
828            finalr += (dpix.r() * inva) >> 8;
829            finalg += (dpix.g() * inva) >> 8;
830            finalb += (dpix.b() * inva) >> 8;
831         }
824            // if we're translucent, add in the destination pixel contribution
825            if (inva > 0)
826            {
827                rgb_t dpix = dest.pix32(y, x);
828                finalr += (dpix.r() * inva) >> 8;
829                finalg += (dpix.g() * inva) >> 8;
830                finalb += (dpix.b() * inva) >> 8;
831            }
832832
833         // store the target pixel, dividing the RGBA values by the overall scale factor
834         dest.pix32(y, x) = rgb_t(finalr, finalg, finalb);
835      }
836   }
833            // store the target pixel, dividing the RGBA values by the overall scale factor
834            dest.pix32(y, x) = rgb_t(finalr, finalg, finalb);
835        }
836    }
837837}
838838
839839
r242286r242287
844844
845845void layout_element::component::draw_disk(bitmap_argb32 &dest, const rectangle &bounds)
846846{
847   // compute premultiplied colors
848   UINT32 r = m_color.r * m_color.a * 255.0;
849   UINT32 g = m_color.g * m_color.a * 255.0;
850   UINT32 b = m_color.b * m_color.a * 255.0;
851   UINT32 inva = (1.0f - m_color.a) * 255.0;
847    // compute premultiplied colors
848    UINT32 r = m_color.r * m_color.a * 255.0;
849    UINT32 g = m_color.g * m_color.a * 255.0;
850    UINT32 b = m_color.b * m_color.a * 255.0;
851    UINT32 inva = (1.0f - m_color.a) * 255.0;
852852
853   // find the center
854   float xcenter = float(bounds.xcenter());
855   float ycenter = float(bounds.ycenter());
856   float xradius = float(bounds.width()) * 0.5f;
857   float yradius = float(bounds.height()) * 0.5f;
858   float ooyradius2 = 1.0f / (yradius * yradius);
853    // find the center
854    float xcenter = float(bounds.xcenter());
855    float ycenter = float(bounds.ycenter());
856    float xradius = float(bounds.width()) * 0.5f;
857    float yradius = float(bounds.height()) * 0.5f;
858    float ooyradius2 = 1.0f / (yradius * yradius);
859859
860   // iterate over y
861   for (UINT32 y = bounds.min_y; y <= bounds.max_y; y++)
862   {
863      float ycoord = ycenter - ((float)y + 0.5f);
864      float xval = xradius * sqrt(1.0f - (ycoord * ycoord) * ooyradius2);
860    // iterate over y
861    for (UINT32 y = bounds.min_y; y <= bounds.max_y; y++)
862    {
863        float ycoord = ycenter - ((float)y + 0.5f);
864        float xval = xradius * sqrt(1.0f - (ycoord * ycoord) * ooyradius2);
865865
866      // compute left/right coordinates
867      INT32 left = (INT32)(xcenter - xval + 0.5f);
868      INT32 right = (INT32)(xcenter + xval + 0.5f);
866        // compute left/right coordinates
867        INT32 left = (INT32)(xcenter - xval + 0.5f);
868        INT32 right = (INT32)(xcenter + xval + 0.5f);
869869
870      // draw this scanline
871      for (UINT32 x = left; x < right; x++)
872      {
873         UINT32 finalr = r;
874         UINT32 finalg = g;
875         UINT32 finalb = b;
870        // draw this scanline
871        for (UINT32 x = left; x < right; x++)
872        {
873            UINT32 finalr = r;
874            UINT32 finalg = g;
875            UINT32 finalb = b;
876876
877         // if we're translucent, add in the destination pixel contribution
878         if (inva > 0)
879         {
880            rgb_t dpix = dest.pix32(y, x);
881            finalr += (dpix.r() * inva) >> 8;
882            finalg += (dpix.g() * inva) >> 8;
883            finalb += (dpix.b() * inva) >> 8;
884         }
877            // if we're translucent, add in the destination pixel contribution
878            if (inva > 0)
879            {
880                rgb_t dpix = dest.pix32(y, x);
881                finalr += (dpix.r() * inva) >> 8;
882                finalg += (dpix.g() * inva) >> 8;
883                finalb += (dpix.b() * inva) >> 8;
884            }
885885
886         // store the target pixel, dividing the RGBA values by the overall scale factor
887         dest.pix32(y, x) = rgb_t(finalr, finalg, finalb);
888      }
889   }
886            // store the target pixel, dividing the RGBA values by the overall scale factor
887            dest.pix32(y, x) = rgb_t(finalr, finalg, finalb);
888        }
889    }
890890}
891891
892892
r242286r242287
896896
897897void layout_element::component::draw_text(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds)
898898{
899   // compute premultiplied colors
900   UINT32 r = m_color.r * 255.0;
901   UINT32 g = m_color.g * 255.0;
902   UINT32 b = m_color.b * 255.0;
903   UINT32 a = m_color.a * 255.0;
899    // compute premultiplied colors
900    UINT32 r = m_color.r * 255.0;
901    UINT32 g = m_color.g * 255.0;
902    UINT32 b = m_color.b * 255.0;
903    UINT32 a = m_color.a * 255.0;
904904
905   // get the width of the string
906   render_font *font = machine.render().font_alloc("default");
907   float aspect = 1.0f;
908   INT32 width;
905    // get the width of the string
906    render_font *font = machine.render().font_alloc("default");
907    float aspect = 1.0f;
908    INT32 width;
909909
910910
911   while (1)
912   {
913      width = font->string_width(bounds.height(), aspect, m_string);
914      if (width < bounds.width())
915         break;
916      aspect *= 0.9f;
917   }
911    while (1)
912    {
913        width = font->string_width(bounds.height(), aspect, m_string);
914        if (width < bounds.width())
915            break;
916        aspect *= 0.9f;
917    }
918918
919919
920   // get alignment
921   INT32 curx;
922   switch (m_textalign)
923   {
924      // left
925      case 1:
926         curx = bounds.min_x;
927         break;
920    // get alignment
921    INT32 curx;
922    switch (m_textalign)
923    {
924        // left
925        case 1:
926            curx = bounds.min_x;
927            break;
928928
929      // right
930      case 2:
931         curx = bounds.max_x - width;
932         break;
929        // right
930        case 2:
931            curx = bounds.max_x - width;
932            break;
933933
934      // default to center
935      default:
936         curx = bounds.min_x + (bounds.width() - width) / 2;
937         break;
938   }
934        // default to center
935        default:
936            curx = bounds.min_x + (bounds.width() - width) / 2;
937            break;
938    }
939939
940   // allocate a temporary bitmap
941   bitmap_argb32 tempbitmap(dest.width(), dest.height());
940    // allocate a temporary bitmap
941    bitmap_argb32 tempbitmap(dest.width(), dest.height());
942942
943   // loop over characters
944   for (const char *s = m_string; *s != 0; s++)
945   {
946      // get the font bitmap
947      rectangle chbounds;
948      font->get_scaled_bitmap_and_bounds(tempbitmap, bounds.height(), aspect, *s, chbounds);
943    // loop over characters
944    for (const char *s = m_string; *s != 0; s++)
945    {
946        // get the font bitmap
947        rectangle chbounds;
948        font->get_scaled_bitmap_and_bounds(tempbitmap, bounds.height(), aspect, *s, chbounds);
949949
950      // copy the data into the target
951      for (int y = 0; y < chbounds.height(); y++)
952      {
953         int effy = bounds.min_y + y;
954         if (effy >= bounds.min_y && effy <= bounds.max_y)
955         {
956            UINT32 *src = &tempbitmap.pix32(y);
957            UINT32 *d = &dest.pix32(effy);
958            for (int x = 0; x < chbounds.width(); x++)
959            {
960               int effx = curx + x + chbounds.min_x;
961               if (effx >= bounds.min_x && effx <= bounds.max_x)
962               {
963                  UINT32 spix = rgb_t(src[x]).a();
964                  if (spix != 0)
965                  {
966                     rgb_t dpix = d[effx];
967                     UINT32 ta = (a * (spix + 1)) >> 8;
968                     UINT32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8;
969                     UINT32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8;
970                     UINT32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8;
971                     d[effx] = rgb_t(tr, tg, tb);
972                  }
973               }
974            }
975         }
976      }
950        // copy the data into the target
951        for (int y = 0; y < chbounds.height(); y++)
952        {
953            int effy = bounds.min_y + y;
954            if (effy >= bounds.min_y && effy <= bounds.max_y)
955            {
956                UINT32 *src = &tempbitmap.pix32(y);
957                UINT32 *d = &dest.pix32(effy);
958                for (int x = 0; x < chbounds.width(); x++)
959                {
960                    int effx = curx + x + chbounds.min_x;
961                    if (effx >= bounds.min_x && effx <= bounds.max_x)
962                    {
963                        UINT32 spix = rgb_t(src[x]).a();
964                        if (spix != 0)
965                        {
966                            rgb_t dpix = d[effx];
967                            UINT32 ta = (a * (spix + 1)) >> 8;
968                            UINT32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8;
969                            UINT32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8;
970                            UINT32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8;
971                            d[effx] = rgb_t(tr, tg, tb);
972                        }
973                    }
974                }
975            }
976        }
977977
978      // advance in the X direction
979      curx += font->char_width(bounds.height(), aspect, *s);
980   }
978        // advance in the X direction
979        curx += font->char_width(bounds.height(), aspect, *s);
980    }
981981
982   // free the temporary bitmap and font
983   machine.render().font_free(font);
982    // free the temporary bitmap and font
983    machine.render().font_free(font);
984984}
985985
986986void layout_element::component::draw_simplecounter(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state)
987987{
988   char temp[256];
989   sprintf(temp, "%0*d", m_digits, state);
990   m_string = astring(temp);
991   draw_text(machine, dest, bounds);
988    char temp[256];
989    sprintf(temp, "%0*d", m_digits, state);
990    m_string = astring(temp);
991    draw_text(machine, dest, bounds);
992992}
993993
994994/* 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 */
995995void layout_element::component::draw_reel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state)
996996{
997   if (m_beltreel)
998   {
999      draw_beltreel(machine,dest,bounds,state);
1000   }
1001   else
1002   {
1003      const int max_state_used = 0x10000;
997    if (m_beltreel)
998    {
999        draw_beltreel(machine,dest,bounds,state);
1000    }
1001    else
1002    {
1003        const int max_state_used = 0x10000;
10041004
1005      // shift the reels a bit based on this param, allows fine tuning
1006      int use_state = (state + m_stateoffset) % max_state_used;
1005        // shift the reels a bit based on this param, allows fine tuning
1006        int use_state = (state + m_stateoffset) % max_state_used;
10071007
1008      // compute premultiplied colors
1009      UINT32 r = m_color.r * 255.0;
1010      UINT32 g = m_color.g * 255.0;
1011      UINT32 b = m_color.b * 255.0;
1012      UINT32 a = m_color.a * 255.0;
1008        // compute premultiplied colors
1009        UINT32 r = m_color.r * 255.0;
1010        UINT32 g = m_color.g * 255.0;
1011        UINT32 b = m_color.b * 255.0;
1012        UINT32 a = m_color.a * 255.0;
10131013
1014      // get the width of the string
1015      render_font *font = machine.render().font_alloc("default");
1016      float aspect = 1.0f;
1017      INT32 width;
1014        // get the width of the string
1015        render_font *font = machine.render().font_alloc("default");
1016        float aspect = 1.0f;
1017        INT32 width;
10181018
10191019
1020      int curry = 0;
1021      int num_shown = m_numsymbolsvisible;
1020        int curry = 0;
1021        int num_shown = m_numsymbolsvisible;
10221022
1023      int ourheight = bounds.height();
1023        int ourheight = bounds.height();
10241024
1025      for (int fruit = 0;fruit<m_numstops;fruit++)
1026      {
1027         int basey;
1025        for (int fruit = 0;fruit<m_numstops;fruit++)
1026        {
1027            int basey;
10281028
1029         if (m_reelreversed==1)
1030         {
1031            basey = bounds.min_y + ((use_state)*(ourheight/num_shown)/(max_state_used/m_numstops)) + curry;
1032         }
1033         else
1034         {
1035            basey = bounds.min_y - ((use_state)*(ourheight/num_shown)/(max_state_used/m_numstops)) + curry;
1036         }
1029            if (m_reelreversed==1)
1030            {
1031                basey = bounds.min_y + ((use_state)*(ourheight/num_shown)/(max_state_used/m_numstops)) + curry;
1032            }
1033            else
1034            {
1035                basey = bounds.min_y - ((use_state)*(ourheight/num_shown)/(max_state_used/m_numstops)) + curry;
1036            }
10371037
1038         // wrap around...
1039         if (basey < bounds.min_y)
1040            basey += ((max_state_used)*(ourheight/num_shown)/(max_state_used/m_numstops));
1041         if (basey > bounds.max_y)
1042            basey -= ((max_state_used)*(ourheight/num_shown)/(max_state_used/m_numstops));
1038            // wrap around...
1039            if (basey < bounds.min_y)
1040                basey += ((max_state_used)*(ourheight/num_shown)/(max_state_used/m_numstops));
1041            if (basey > bounds.max_y)
1042                basey -= ((max_state_used)*(ourheight/num_shown)/(max_state_used/m_numstops));
10431043
1044         int endpos = basey+ourheight/num_shown;
1044            int endpos = basey+ourheight/num_shown;
10451045
1046         // only render the symbol / text if it's atually in view because the code is SLOW
1047         if ((endpos >= bounds.min_y) && (basey <= bounds.max_y))
1048         {
1049            while (1)
1050            {
1051               width = font->string_width(ourheight/num_shown, aspect, m_stopnames[fruit]);
1052               if (width < bounds.width())
1053                  break;
1054               aspect *= 0.9f;
1055            }
1046            // only render the symbol / text if it's atually in view because the code is SLOW
1047            if ((endpos >= bounds.min_y) && (basey <= bounds.max_y))
1048            {
1049                while (1)
1050                {
1051                    width = font->string_width(ourheight/num_shown, aspect, m_stopnames[fruit]);
1052                    if (width < bounds.width())
1053                        break;
1054                    aspect *= 0.9f;
1055                }
10561056
1057            INT32 curx;
1058            curx = bounds.min_x + (bounds.width() - width) / 2;
1057                INT32 curx;
1058                curx = bounds.min_x + (bounds.width() - width) / 2;
10591059
1060            if (m_file[fruit])
1061               if (!m_bitmap[fruit].valid())
1062                  load_reel_bitmap(fruit);
1060                if (m_file[fruit])
1061                    if (!m_bitmap[fruit].valid())
1062                        load_reel_bitmap(fruit);
10631063
1064            if (m_file[fruit]) // render gfx
1065            {
1066               bitmap_argb32 tempbitmap2(dest.width(), ourheight/num_shown);
1064                if (m_file[fruit]) // render gfx
1065                {
1066                    bitmap_argb32 tempbitmap2(dest.width(), ourheight/num_shown);
10671067
1068               if (m_bitmap[fruit].valid())
1069               {
1070                  render_resample_argb_bitmap_hq(tempbitmap2, m_bitmap[fruit], m_color);
1068                    if (m_bitmap[fruit].valid())
1069                    {
1070                        render_resample_argb_bitmap_hq(tempbitmap2, m_bitmap[fruit], m_color);
10711071
1072                  for (int y = 0; y < ourheight/num_shown; y++)
1073                  {
1074                     int effy = basey + y;
1072                        for (int y = 0; y < ourheight/num_shown; y++)
1073                        {
1074                            int effy = basey + y;
10751075
1076                     if (effy >= bounds.min_y && effy <= bounds.max_y)
1077                     {
1078                        UINT32 *src = &tempbitmap2.pix32(y);
1079                        UINT32 *d = &dest.pix32(effy);
1080                        for (int x = 0; x < dest.width(); x++)
1081                        {
1082                           int effx = x;
1083                           if (effx >= bounds.min_x && effx <= bounds.max_x)
1084                           {
1085                              UINT32 spix = rgb_t(src[x]).a();
1086                              if (spix != 0)
1087                              {
1088                                 d[effx] = src[x];
1089                              }
1090                           }
1091                        }
1092                     }
1076                            if (effy >= bounds.min_y && effy <= bounds.max_y)
1077                            {
1078                                UINT32 *src = &tempbitmap2.pix32(y);
1079                                UINT32 *d = &dest.pix32(effy);
1080                                for (int x = 0; x < dest.width(); x++)
1081                                {
1082                                    int effx = x;
1083                                    if (effx >= bounds.min_x && effx <= bounds.max_x)
1084                                    {
1085                                        UINT32 spix = rgb_t(src[x]).a();
1086                                        if (spix != 0)
1087                                        {
1088                                            d[effx] = src[x];
1089                                        }
1090                                    }
1091                                }
1092                            }
10931093
1094                  }
1095               }
1096            }
1097            else // render text (fallback)
1098            {
1099               // allocate a temporary bitmap
1100               bitmap_argb32 tempbitmap(dest.width(), dest.height());
1094                        }
1095                    }
1096                }
1097                else // render text (fallback)
1098                {
1099                    // allocate a temporary bitmap
1100                    bitmap_argb32 tempbitmap(dest.width(), dest.height());
11011101
1102               // loop over characters
1103               for (const char *s = m_stopnames[fruit]; *s != 0; s++)
1104               {
1105                  // get the font bitmap
1106                  rectangle chbounds;
1107                  font->get_scaled_bitmap_and_bounds(tempbitmap, ourheight/num_shown, aspect, *s, chbounds);
1102                    // loop over characters
1103                    for (const char *s = m_stopnames[fruit]; *s != 0; s++)
1104                    {
1105                        // get the font bitmap
1106                        rectangle chbounds;
1107                        font->get_scaled_bitmap_and_bounds(tempbitmap, ourheight/num_shown, aspect, *s, chbounds);
11081108
1109                  // copy the data into the target
1110                  for (int y = 0; y < chbounds.height(); y++)
1111                  {
1112                     int effy = basey + y;
1109                        // copy the data into the target
1110                        for (int y = 0; y < chbounds.height(); y++)
1111                        {
1112                            int effy = basey + y;
11131113
1114                     if (effy >= bounds.min_y && effy <= bounds.max_y)
1115                     {
1116                        UINT32 *src = &tempbitmap.pix32(y);
1117                        UINT32 *d = &dest.pix32(effy);
1118                        for (int x = 0; x < chbounds.width(); x++)
1119                        {
1120                           int effx = curx + x + chbounds.min_x;
1121                           if (effx >= bounds.min_x && effx <= bounds.max_x)
1122                           {
1123                              UINT32 spix = rgb_t(src[x]).a();
1124                              if (spix != 0)
1125                              {
1126                                 rgb_t dpix = d[effx];
1127                                 UINT32 ta = (a * (spix + 1)) >> 8;
1128                                 UINT32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8;
1129                                 UINT32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8;
1130                                 UINT32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8;
1131                                 d[effx] = rgb_t(tr, tg, tb);
1132                              }
1133                           }
1134                        }
1135                     }
1136                  }
1114                            if (effy >= bounds.min_y && effy <= bounds.max_y)
1115                            {
1116                                UINT32 *src = &tempbitmap.pix32(y);
1117                                UINT32 *d = &dest.pix32(effy);
1118                                for (int x = 0; x < chbounds.width(); x++)
1119                                {
1120                                    int effx = curx + x + chbounds.min_x;
1121                                    if (effx >= bounds.min_x && effx <= bounds.max_x)
1122                                    {
1123                                        UINT32 spix = rgb_t(src[x]).a();
1124                                        if (spix != 0)
1125                                        {
1126                                            rgb_t dpix = d[effx];
1127                                            UINT32 ta = (a * (spix + 1)) >> 8;
1128                                            UINT32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8;
1129                                            UINT32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8;
1130                                            UINT32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8;
1131                                            d[effx] = rgb_t(tr, tg, tb);
1132                                        }
1133                                    }
1134                                }
1135                            }
1136                        }
11371137
1138                  // advance in the X direction
1139                  curx += font->char_width(ourheight/num_shown, aspect, *s);
1138                        // advance in the X direction
1139                        curx += font->char_width(ourheight/num_shown, aspect, *s);
11401140
1141               }
1141                    }
11421142
1143            }
1144         }
1143                }
1144            }
11451145
1146         curry += ourheight/num_shown;
1147      }
1148   // free the temporary bitmap and font
1149   machine.render().font_free(font);
1150   }
1146            curry += ourheight/num_shown;
1147        }
1148    // free the temporary bitmap and font
1149    machine.render().font_free(font);
1150    }
11511151}
11521152
11531153
11541154void layout_element::component::draw_beltreel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state)
11551155{
1156   const int max_state_used = 0x10000;
1156    const int max_state_used = 0x10000;
11571157
1158   // shift the reels a bit based on this param, allows fine tuning
1159   int use_state = (state + m_stateoffset) % max_state_used;
1158    // shift the reels a bit based on this param, allows fine tuning
1159    int use_state = (state + m_stateoffset) % max_state_used;
11601160
1161   // compute premultiplied colors
1162   UINT32 r = m_color.r * 255.0;
1163   UINT32 g = m_color.g * 255.0;
1164   UINT32 b = m_color.b * 255.0;
1165   UINT32 a = m_color.a * 255.0;
1161    // compute premultiplied colors
1162    UINT32 r = m_color.r * 255.0;
1163    UINT32 g = m_color.g * 255.0;
1164    UINT32 b = m_color.b * 255.0;
1165    UINT32 a = m_color.a * 255.0;
11661166
1167   // get the width of the string
1168   render_font *font = machine.render().font_alloc("default");
1169   float aspect = 1.0f;
1170   INT32 width;
1171   int currx = 0;
1172   int num_shown = m_numsymbolsvisible;
1167    // get the width of the string
1168    render_font *font = machine.render().font_alloc("default");
1169    float aspect = 1.0f;
1170    INT32 width;
1171    int currx = 0;
1172    int num_shown = m_numsymbolsvisible;
11731173
1174   int ourwidth = bounds.width();
1174    int ourwidth = bounds.width();
11751175
1176   for (int fruit = 0;fruit<m_numstops;fruit++)
1177   {
1178      int basex;
1179      if (m_reelreversed==1)
1180      {
1181         basex = bounds.min_x + ((use_state)*(ourwidth/num_shown)/(max_state_used/m_numstops)) + currx;
1182      }
1183      else
1184      {
1185         basex = bounds.min_x - ((use_state)*(ourwidth/num_shown)/(max_state_used/m_numstops)) + currx;
1186      }
1176    for (int fruit = 0;fruit<m_numstops;fruit++)
1177    {
1178        int basex;
1179        if (m_reelreversed==1)
1180        {
1181            basex = bounds.min_x + ((use_state)*(ourwidth/num_shown)/(max_state_used/m_numstops)) + currx;
1182        }
1183        else
1184        {
1185            basex = bounds.min_x - ((use_state)*(ourwidth/num_shown)/(max_state_used/m_numstops)) + currx;
1186        }
11871187
1188      // wrap around...
1189      if (basex < bounds.min_x)
1190         basex += ((max_state_used)*(ourwidth/num_shown)/(max_state_used/m_numstops));
1191      if (basex > bounds.max_x)
1192         basex -= ((max_state_used)*(ourwidth/num_shown)/(max_state_used/m_numstops));
1188        // wrap around...
1189        if (basex < bounds.min_x)
1190            basex += ((max_state_used)*(ourwidth/num_shown)/(max_state_used/m_numstops));
1191        if (basex > bounds.max_x)
1192            basex -= ((max_state_used)*(ourwidth/num_shown)/(max_state_used/m_numstops));
11931193
1194      int endpos = basex+(ourwidth/num_shown);
1194        int endpos = basex+(ourwidth/num_shown);
11951195
1196      // only render the symbol / text if it's atually in view because the code is SLOW
1197      if ((endpos >= bounds.min_x) && (basex <= bounds.max_x))
1198      {
1199         while (1)
1200         {
1201            width = font->string_width(dest.height(), aspect, m_stopnames[fruit]);
1202            if (width < bounds.width())
1203               break;
1204            aspect *= 0.9f;
1205         }
1196        // only render the symbol / text if it's atually in view because the code is SLOW
1197        if ((endpos >= bounds.min_x) && (basex <= bounds.max_x))
1198        {
1199            while (1)
1200            {
1201                width = font->string_width(dest.height(), aspect, m_stopnames[fruit]);
1202                if (width < bounds.width())
1203                    break;
1204                aspect *= 0.9f;
1205            }
12061206
1207         INT32 curx;
1208         curx = bounds.min_x;
1207            INT32 curx;
1208            curx = bounds.min_x;
12091209
1210         if (m_file[fruit])
1211            if (!m_bitmap[fruit].valid())
1212               load_reel_bitmap(fruit);
1210            if (m_file[fruit])
1211                if (!m_bitmap[fruit].valid())
1212                    load_reel_bitmap(fruit);
12131213
1214         if (m_file[fruit]) // render gfx
1215         {
1216            bitmap_argb32 tempbitmap2(ourwidth/num_shown, dest.height());
1214            if (m_file[fruit]) // render gfx
1215            {
1216                bitmap_argb32 tempbitmap2(ourwidth/num_shown, dest.height());
12171217
1218            if (m_bitmap[fruit].valid())
1219            {
1220               render_resample_argb_bitmap_hq(tempbitmap2, m_bitmap[fruit], m_color);
1218                if (m_bitmap[fruit].valid())
1219                {
1220                    render_resample_argb_bitmap_hq(tempbitmap2, m_bitmap[fruit], m_color);
12211221
1222               for (int y = 0; y < dest.height(); y++)
1223               {
1224                  int effy = y;
1222                    for (int y = 0; y < dest.height(); y++)
1223                    {
1224                        int effy = y;
12251225
1226                  if (effy >= bounds.min_y && effy <= bounds.max_y)
1227                  {
1228                     UINT32 *src = &tempbitmap2.pix32(y);
1229                     UINT32 *d = &dest.pix32(effy);
1230                     for (int x = 0; x < ourwidth/num_shown; x++)
1231                     {
1232                        int effx = basex + x;
1233                        if (effx >= bounds.min_x && effx <= bounds.max_x)
1234                        {
1235                           UINT32 spix = rgb_t(src[x]).a();
1236                           if (spix != 0)
1237                           {
1238                              d[effx] = src[x];
1239                           }
1240                        }
1241                     }
1242                  }
1226                        if (effy >= bounds.min_y && effy <= bounds.max_y)
1227                        {
1228                            UINT32 *src = &tempbitmap2.pix32(y);
1229                            UINT32 *d = &dest.pix32(effy);
1230                            for (int x = 0; x < ourwidth/num_shown; x++)
1231                            {
1232                                int effx = basex + x;
1233                                if (effx >= bounds.min_x && effx <= bounds.max_x)
1234                                {
1235                                    UINT32 spix = rgb_t(src[x]).a();
1236                                    if (spix != 0)
1237                                    {
1238                                        d[effx] = src[x];
1239                                    }
1240                                }
1241                            }
1242                        }
12431243
1244               }
1245            }
1246         }
1247         else // render text (fallback)
1248         {
1249            // allocate a temporary bitmap
1250            bitmap_argb32 tempbitmap(dest.width(), dest.height());
1244                    }
1245                }
1246            }
1247            else // render text (fallback)
1248            {
1249                // allocate a temporary bitmap
1250                bitmap_argb32 tempbitmap(dest.width(), dest.height());
12511251
1252            // loop over characters
1253            for (const char *s = m_stopnames[fruit]; *s != 0; s++)
1254            {
1255               // get the font bitmap
1256               rectangle chbounds;
1257               font->get_scaled_bitmap_and_bounds(tempbitmap, dest.height(), aspect, *s, chbounds);
1252                // loop over characters
1253                for (const char *s = m_stopnames[fruit]; *s != 0; s++)
1254                {
1255                    // get the font bitmap
1256                    rectangle chbounds;
1257                    font->get_scaled_bitmap_and_bounds(tempbitmap, dest.height(), aspect, *s, chbounds);
12581258
1259               // copy the data into the target
1260               for (int y = 0; y < chbounds.height(); y++)
1261               {
1262                  int effy = y;
1259                    // copy the data into the target
1260                    for (int y = 0; y < chbounds.height(); y++)
1261                    {
1262                        int effy = y;
12631263
1264                  if (effy >= bounds.min_y && effy <= bounds.max_y)
1265                  {
1266                     UINT32 *src = &tempbitmap.pix32(y);
1267                     UINT32 *d = &dest.pix32(effy);
1268                     for (int x = 0; x < chbounds.width(); x++)
1269                     {
1270                        int effx = basex + curx + x;
1271                        if (effx >= bounds.min_x && effx <= bounds.max_x)
1272                        {
1273                           UINT32 spix = rgb_t(src[x]).a();
1274                           if (spix != 0)
1275                           {
1276                              rgb_t dpix = d[effx];
1277                              UINT32 ta = (a * (spix + 1)) >> 8;
1278                              UINT32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8;
1279                              UINT32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8;
1280                              UINT32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8;
1281                              d[effx] = rgb_t(tr, tg, tb);
1282                           }
1283                        }
1284                     }
1285                  }
1286               }
1264                        if (effy >= bounds.min_y && effy <= bounds.max_y)
1265                        {
1266                            UINT32 *src = &tempbitmap.pix32(y);
1267                            UINT32 *d = &dest.pix32(effy);
1268                            for (int x = 0; x < chbounds.width(); x++)
1269                            {
1270                                int effx = basex + curx + x;
1271                                if (effx >= bounds.min_x && effx <= bounds.max_x)
1272                                {
1273                                    UINT32 spix = rgb_t(src[x]).a();
1274                                    if (spix != 0)
1275                                    {
1276                                        rgb_t dpix = d[effx];
1277                                        UINT32 ta = (a * (spix + 1)) >> 8;
1278                                        UINT32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8;
1279                                        UINT32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8;
1280                                        UINT32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8;
1281                                        d[effx] = rgb_t(tr, tg, tb);
1282                                    }
1283                                }
1284                            }
1285                        }
1286                    }
12871287
1288               // advance in the X direction
1289               curx += font->char_width(dest.height(), aspect, *s);
1288                    // advance in the X direction
1289                    curx += font->char_width(dest.height(), aspect, *s);
12901290
1291            }
1291                }
12921292
1293         }
1294      }
1293            }
1294        }
12951295
1296      currx += ourwidth/num_shown;
1297   }
1296        currx += ourwidth/num_shown;
1297    }
12981298
1299   // free the temporary bitmap and font
1300   machine.render().font_free(font);
1299    // free the temporary bitmap and font
1300    machine.render().font_free(font);
13011301}
13021302
13031303
r242286r242287
13081308
13091309void layout_element::component::load_bitmap()
13101310{
1311   // load the basic bitmap
1312   assert(m_file[0] != NULL);
1313   m_hasalpha[0] = render_load_png(m_bitmap[0], *m_file[0], m_dirname, m_imagefile[0]);
1311    // load the basic bitmap
1312    assert(m_file[0] != NULL);
1313    m_hasalpha[0] = render_load_png(m_bitmap[0], *m_file[0], m_dirname, m_imagefile[0]);
13141314
1315   // load the alpha bitmap if specified
1316   if (m_bitmap[0].valid() && m_alphafile[0])
1317      render_load_png(m_bitmap[0], *m_file[0], m_dirname, m_alphafile[0], true);
1315    // load the alpha bitmap if specified
1316    if (m_bitmap[0].valid() && m_alphafile[0])
1317        render_load_png(m_bitmap[0], *m_file[0], m_dirname, m_alphafile[0], true);
13181318
1319   // if we can't load the bitmap, allocate a dummy one and report an error
1320   if (!m_bitmap[0].valid())
1321   {
1322      // draw some stripes in the bitmap
1323      m_bitmap[0].allocate(100, 100);
1324      m_bitmap[0].fill(0);
1325      for (int step = 0; step < 100; step += 25)
1326         for (int line = 0; line < 100; line++)
1327            m_bitmap[0].pix32((step + line) % 100, line % 100) = rgb_t(0xff,0xff,0xff,0xff);
1319    // if we can't load the bitmap, allocate a dummy one and report an error
1320    if (!m_bitmap[0].valid())
1321    {
1322        // draw some stripes in the bitmap
1323        m_bitmap[0].allocate(100, 100);
1324        m_bitmap[0].fill(0);
1325        for (int step = 0; step < 100; step += 25)
1326            for (int line = 0; line < 100; line++)
1327                m_bitmap[0].pix32((step + line) % 100, line % 100) = rgb_t(0xff,0xff,0xff,0xff);
13281328
1329      // log an error
1330      if (!m_alphafile[0])
1331         osd_printf_warning("Unable to load component bitmap '%s'\n", m_imagefile[0].cstr());
1332      else
1333         osd_printf_warning("Unable to load component bitmap '%s'/'%s'\n", m_imagefile[0].cstr(), m_alphafile[0].cstr());
1334   }
1329        // log an error
1330        if (!m_alphafile[0])
1331            osd_printf_warning("Unable to load component bitmap '%s'\n", m_imagefile[0].cstr());
1332        else
1333            osd_printf_warning("Unable to load component bitmap '%s'/'%s'\n", m_imagefile[0].cstr(), m_alphafile[0].cstr());
1334    }
13351335}
13361336
13371337
13381338void layout_element::component::load_reel_bitmap(int number)
13391339{
1340   // load the basic bitmap
1341   assert(m_file != NULL);
1342   /*m_hasalpha[number] = */ render_load_png(m_bitmap[number], *m_file[number], m_dirname, m_imagefile[number]);
1340    // load the basic bitmap
1341    assert(m_file != NULL);
1342    /*m_hasalpha[number] = */ render_load_png(m_bitmap[number], *m_file[number], m_dirname, m_imagefile[number]);
13431343
1344   // load the alpha bitmap if specified
1345   //if (m_bitmap[number].valid() && m_alphafile[number])
1346   //  render_load_png(m_bitmap[number], *m_file[number], m_dirname, m_alphafile[number], true);
1344    // load the alpha bitmap if specified
1345    //if (m_bitmap[number].valid() && m_alphafile[number])
1346    //  render_load_png(m_bitmap[number], *m_file[number], m_dirname, m_alphafile[number], true);
13471347
1348   // if we can't load the bitmap just use text rendering
1349   if (!m_bitmap[number].valid())
1350   {
1351      // fallback to text rendering
1352      m_file[number].reset();
1353   }
1348    // if we can't load the bitmap just use text rendering
1349    if (!m_bitmap[number].valid())
1350    {
1351        // fallback to text rendering
1352        m_file[number].reset();
1353    }
13541354
13551355}
13561356
r242286r242287
13621362
13631363void layout_element::component::draw_led7seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern)
13641364{
1365   const rgb_t onpen = rgb_t(0xff,0xff,0xff,0xff);
1366   const rgb_t offpen = rgb_t(0xff,0x20,0x20,0x20);
1365    const rgb_t onpen = rgb_t(0xff,0xff,0xff,0xff);
1366    const rgb_t offpen = rgb_t(0xff,0x20,0x20,0x20);
13671367
1368   // sizes for computation
1369   int bmwidth = 250;
1370   int bmheight = 400;
1371   int segwidth = 40;
1372   int skewwidth = 40;
1368    // sizes for computation
1369    int bmwidth = 250;
1370    int bmheight = 400;
1371    int segwidth = 40;
1372    int skewwidth = 40;
13731373
1374   // allocate a temporary bitmap for drawing
1375   bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight);
1376   tempbitmap.fill(rgb_t(0xff,0x00,0x00,0x00));
1374    // allocate a temporary bitmap for drawing
1375    bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight);
1376    tempbitmap.fill(rgb_t(0xff,0x00,0x00,0x00));
13771377
1378   // top bar
1379   draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 0)) ? onpen : offpen);
1378    // top bar
1379    draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 0)) ? onpen : offpen);
13801380
1381   // top-right bar
1382   draw_segment_vertical(tempbitmap, 0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2, segwidth, (pattern & (1 << 1)) ? onpen : offpen);
1381    // top-right bar
1382    draw_segment_vertical(tempbitmap, 0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2, segwidth, (pattern & (1 << 1)) ? onpen : offpen);
13831383
1384   // bottom-right bar
1385   draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2, segwidth, (pattern & (1 << 2)) ? onpen : offpen);
1384    // bottom-right bar
1385    draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2, segwidth, (pattern & (1 << 2)) ? onpen : offpen);
13861386
1387   // bottom bar
1388   draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight - segwidth/2, segwidth, (pattern & (1 << 3)) ? onpen : offpen);
1387    // bottom bar
1388    draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight - segwidth/2, segwidth, (pattern & (1 << 3)) ? onpen : offpen);
13891389
1390   // bottom-left bar
1391   draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 4)) ? onpen : offpen);
1390    // bottom-left bar
1391    draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 4)) ? onpen : offpen);
13921392
1393   // top-left bar
1394   draw_segment_vertical(tempbitmap, 0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 5)) ? onpen : offpen);
1393    // top-left bar
1394    draw_segment_vertical(tempbitmap, 0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 5)) ? onpen : offpen);
13951395
1396   // middle bar
1397   draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight/2, segwidth, (pattern & (1 << 6)) ? onpen : offpen);
1396    // middle bar
1397    draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight/2, segwidth, (pattern & (1 << 6)) ? onpen : offpen);
13981398
1399   // apply skew
1400   apply_skew(tempbitmap, 40);
1399    // apply skew
1400    apply_skew(tempbitmap, 40);
14011401
1402   // decimal point
1403   draw_segment_decimal(tempbitmap, bmwidth + segwidth/2, bmheight - segwidth/2, segwidth, (pattern & (1 << 7)) ? onpen : offpen);
1402    // decimal point
1403    draw_segment_decimal(tempbitmap, bmwidth + segwidth/2, bmheight - segwidth/2, segwidth, (pattern & (1 << 7)) ? onpen : offpen);
14041404
1405   // resample to the target size
1406   render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
1405    // resample to the target size
1406    render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
14071407}
14081408
14091409
14101410//-----------------------------------------------------------------
1411//  draw_led8seg - draw a 8-segment fluorescent (Gottlieb System 1)
1411//  draw_led8seg_gts1 - draw a 8-segment fluorescent (Gottlieb System 1)
14121412//-----------------------------------------------------------------
14131413
1414void layout_element::component::draw_led8seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern)
1414void layout_element::component::draw_led8seg_gts1(bitmap_argb32 &dest, const rectangle &bounds, int pattern)
14151415{
1416   const rgb_t onpen = rgb_t(0xff,0xff,0xff,0xff);
1417   const rgb_t offpen = rgb_t(0xff,0x20,0x20,0x20);
1418   const rgb_t backpen = rgb_t(0xff,0x00,0x00,0x00);
1416    const rgb_t onpen = rgb_t(0xff,0xff,0xff,0xff);
1417    const rgb_t offpen = rgb_t(0xff,0x20,0x20,0x20);
1418    const rgb_t backpen = rgb_t(0xff,0x00,0x00,0x00);
14191419
1420   // sizes for computation
1421   int bmwidth = 250;
1422   int bmheight = 400;
1423   int segwidth = 40;
1424   int skewwidth = 40;
1420    // sizes for computation
1421    int bmwidth = 250;
1422    int bmheight = 400;
1423    int segwidth = 40;
1424    int skewwidth = 40;
14251425
1426   // allocate a temporary bitmap for drawing
1427   bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight);
1428   tempbitmap.fill(backpen);
1426    // allocate a temporary bitmap for drawing
1427    bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight);
1428    tempbitmap.fill(backpen);
14291429
1430   // top bar
1431   draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 0)) ? onpen : offpen);
1430    // top bar
1431    draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 0)) ? onpen : offpen);
14321432
1433   // top-right bar
1434   draw_segment_vertical(tempbitmap, 0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2, segwidth, (pattern & (1 << 1)) ? onpen : offpen);
1433    // top-right bar
1434    draw_segment_vertical(tempbitmap, 0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2, segwidth, (pattern & (1 << 1)) ? onpen : offpen);
14351435
1436   // bottom-right bar
1437   draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2, segwidth, (pattern & (1 << 2)) ? onpen : offpen);
1436    // bottom-right bar
1437    draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2, segwidth, (pattern & (1 << 2)) ? onpen : offpen);
14381438
1439   // bottom bar
1440   draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight - segwidth/2, segwidth, (pattern & (1 << 3)) ? onpen : offpen);
1439    // bottom bar
1440    draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight - segwidth/2, segwidth, (pattern & (1 << 3)) ? onpen : offpen);
14411441
1442   // bottom-left bar
1443   draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 4)) ? onpen : offpen);
1442    // bottom-left bar
1443    draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 4)) ? onpen : offpen);
14441444
1445   // top-left bar
1446   draw_segment_vertical(tempbitmap, 0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 5)) ? onpen : offpen);
1445    // top-left bar
1446    draw_segment_vertical(tempbitmap, 0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 5)) ? onpen : offpen);
14471447
1448   // horizontal bars
1449   draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, 2*bmwidth/3 - 2*segwidth/3, bmheight/2, segwidth, (pattern & (1 << 6)) ? onpen : offpen);
1450   draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3 + bmwidth/2, bmwidth - 2*segwidth/3, bmheight/2, segwidth, (pattern & (1 << 6)) ? onpen : offpen);
1448    // horizontal bars
1449    draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3, 2*bmwidth/3 - 2*segwidth/3, bmheight/2, segwidth, (pattern & (1 << 6)) ? onpen : offpen);
1450    draw_segment_horizontal(tempbitmap, 0 + 2*segwidth/3 + bmwidth/2, bmwidth - 2*segwidth/3, bmheight/2, segwidth, (pattern & (1 << 6)) ? onpen : offpen);
14511451
1452   // vertical bars
1453   draw_segment_vertical(tempbitmap, 0 + segwidth/3 - 8, bmheight/2 - segwidth/3 + 2, 2*bmwidth/3 - segwidth/2 - 4, segwidth + 8, backpen);
1454   draw_segment_vertical(tempbitmap, 0 + segwidth/3, bmheight/2 - segwidth/3, 2*bmwidth/3 - segwidth/2 - 4, segwidth, (pattern & (1 << 7)) ? onpen : offpen);
1452    // vertical bars
1453    draw_segment_vertical(tempbitmap, 0 + segwidth/3 - 8, bmheight/2 - segwidth/3 + 2, 2*bmwidth/3 - segwidth/2 - 4, segwidth + 8, backpen);
1454    draw_segment_vertical(tempbitmap, 0 + segwidth/3, bmheight/2 - segwidth/3, 2*bmwidth/3 - segwidth/2 - 4, segwidth, (pattern & (1 << 7)) ? onpen : offpen);
14551455
1456   draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3 - 2, bmheight - segwidth/3 + 8, 2*bmwidth/3 - segwidth/2 - 4, segwidth + 8, backpen);
1457   draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3, bmheight - segwidth/3, 2*bmwidth/3 - segwidth/2 - 4, segwidth, (pattern & (1 << 7)) ? onpen : offpen);
1456    draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3 - 2, bmheight - segwidth/3 + 8, 2*bmwidth/3 - segwidth/2 - 4, segwidth + 8, backpen);
1457    draw_segment_vertical(tempbitmap, bmheight/2 + segwidth/3, bmheight - segwidth/3, 2*bmwidth/3 - segwidth/2 - 4, segwidth, (pattern & (1 << 7)) ? onpen : offpen);
14581458
1459   // apply skew
1460   apply_skew(tempbitmap, 40);
1459    // apply skew
1460    apply_skew(tempbitmap, 40);
14611461
1462   // resample to the target size
1463   render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
1462    // resample to the target size
1463    render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
14641464}
14651465
14661466
r242286r242287
14701470
14711471void layout_element::component::draw_led14seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern)
14721472{
1473   const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
1474   const rgb_t offpen = rgb_t(0xff, 0x20, 0x20, 0x20);
1473    const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
1474    const rgb_t offpen = rgb_t(0xff, 0x20, 0x20, 0x20);
14751475
1476   // sizes for computation
1477   int bmwidth = 250;
1478   int bmheight = 400;
1479   int segwidth = 40;
1480   int skewwidth = 40;
1476    // sizes for computation
1477    int bmwidth = 250;
1478    int bmheight = 400;
1479    int segwidth = 40;
1480    int skewwidth = 40;
14811481
1482   // allocate a temporary bitmap for drawing
1483   bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight);
1484   tempbitmap.fill(rgb_t(0xff, 0x00, 0x00, 0x00));
1482    // allocate a temporary bitmap for drawing
1483    bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight);
1484    tempbitmap.fill(rgb_t(0xff, 0x00, 0x00, 0x00));
14851485
1486   // top bar
1487   draw_segment_horizontal(tempbitmap,
1488      0 + 2*segwidth/3, bmwidth - 2*segwidth/3, 0 + segwidth/2,
1489      segwidth, (pattern & (1 << 0)) ? onpen : offpen);
1486    // top bar
1487    draw_segment_horizontal(tempbitmap,
1488        0 + 2*segwidth/3, bmwidth - 2*segwidth/3, 0 + segwidth/2,
1489        segwidth, (pattern & (1 << 0)) ? onpen : offpen);
14901490
1491   // right-top bar
1492   draw_segment_vertical(tempbitmap,
1493      0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2,
1494      segwidth, (pattern & (1 << 1)) ? onpen : offpen);
1491    // right-top bar
1492    draw_segment_vertical(tempbitmap,
1493        0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2,
1494        segwidth, (pattern & (1 << 1)) ? onpen : offpen);
14951495
1496   // right-bottom bar
1497   draw_segment_vertical(tempbitmap,
1498      bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2,
1499      segwidth, (pattern & (1 << 2)) ? onpen : offpen);
1496    // right-bottom bar
1497    draw_segment_vertical(tempbitmap,
1498        bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2,
1499        segwidth, (pattern & (1 << 2)) ? onpen : offpen);
15001500
1501   // bottom bar
1502   draw_segment_horizontal(tempbitmap,
1503      0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight - segwidth/2,
1504      segwidth, (pattern & (1 << 3)) ? onpen : offpen);
1501    // bottom bar
1502    draw_segment_horizontal(tempbitmap,
1503        0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight - segwidth/2,
1504        segwidth, (pattern & (1 << 3)) ? onpen : offpen);
15051505
1506   // left-bottom bar
1507   draw_segment_vertical(tempbitmap,
1508      bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2,
1509      segwidth, (pattern & (1 << 4)) ? onpen : offpen);
1506    // left-bottom bar
1507    draw_segment_vertical(tempbitmap,
1508        bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2,
1509        segwidth, (pattern & (1 << 4)) ? onpen : offpen);
15101510
1511   // left-top bar
1512   draw_segment_vertical(tempbitmap,
1513      0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2,
1514      segwidth, (pattern & (1 << 5)) ? onpen : offpen);
1511    // left-top bar
1512    draw_segment_vertical(tempbitmap,
1513        0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2,
1514        segwidth, (pattern & (1 << 5)) ? onpen : offpen);
15151515
1516   // horizontal-middle-left bar
1517   draw_segment_horizontal_caps(tempbitmap,
1518      0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight/2,
1519      segwidth, LINE_CAP_START, (pattern & (1 << 6)) ? onpen : offpen);
1516    // horizontal-middle-left bar
1517    draw_segment_horizontal_caps(tempbitmap,
1518        0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight/2,
1519        segwidth, LINE_CAP_START, (pattern & (1 << 6)) ? onpen : offpen);
15201520
1521   // horizontal-middle-right bar
1522   draw_segment_horizontal_caps(tempbitmap,
1523      0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight/2,
1524      segwidth, LINE_CAP_END, (pattern & (1 << 7)) ? onpen : offpen);
1521    // horizontal-middle-right bar
1522    draw_segment_horizontal_caps(tempbitmap,
1523        0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight/2,
1524        segwidth, LINE_CAP_END, (pattern & (1 << 7)) ? onpen : offpen);
15251525
1526   // vertical-middle-top bar
1527   draw_segment_vertical_caps(tempbitmap,
1528      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3, bmwidth/2,
1529      segwidth, LINE_CAP_NONE, (pattern & (1 << 8)) ? onpen : offpen);
1526    // vertical-middle-top bar
1527    draw_segment_vertical_caps(tempbitmap,
1528        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3, bmwidth/2,
1529        segwidth, LINE_CAP_NONE, (pattern & (1 << 8)) ? onpen : offpen);
15301530
1531   // vertical-middle-bottom bar
1532   draw_segment_vertical_caps(tempbitmap,
1533      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3, bmwidth/2,
1534      segwidth, LINE_CAP_NONE, (pattern & (1 << 9)) ? onpen : offpen);
1531    // vertical-middle-bottom bar
1532    draw_segment_vertical_caps(tempbitmap,
1533        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3, bmwidth/2,
1534        segwidth, LINE_CAP_NONE, (pattern & (1 << 9)) ? onpen : offpen);
15351535
1536   // diagonal-left-bottom bar
1537   draw_segment_diagonal_1(tempbitmap,
1538      0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1539      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1540      segwidth, (pattern & (1 << 10)) ? onpen : offpen);
1536    // diagonal-left-bottom bar
1537    draw_segment_diagonal_1(tempbitmap,
1538        0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1539        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1540        segwidth, (pattern & (1 << 10)) ? onpen : offpen);
15411541
1542   // diagonal-left-top bar
1543   draw_segment_diagonal_2(tempbitmap,
1544      0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1545      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1546      segwidth, (pattern & (1 << 11)) ? onpen : offpen);
1542    // diagonal-left-top bar
1543    draw_segment_diagonal_2(tempbitmap,
1544        0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1545        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1546        segwidth, (pattern & (1 << 11)) ? onpen : offpen);
15471547
1548   // diagonal-right-top bar
1549   draw_segment_diagonal_1(tempbitmap,
1550      bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1551      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1552      segwidth, (pattern & (1 << 12)) ? onpen : offpen);
1548    // diagonal-right-top bar
1549    draw_segment_diagonal_1(tempbitmap,
1550        bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1551        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1552        segwidth, (pattern & (1 << 12)) ? onpen : offpen);
15531553
1554   // diagonal-right-bottom bar
1555   draw_segment_diagonal_2(tempbitmap,
1556      bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1557      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1558      segwidth, (pattern & (1 << 13)) ? onpen : offpen);
1554    // diagonal-right-bottom bar
1555    draw_segment_diagonal_2(tempbitmap,
1556        bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1557        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1558        segwidth, (pattern & (1 << 13)) ? onpen : offpen);
15591559
1560   // apply skew
1561   apply_skew(tempbitmap, 40);
1560    // apply skew
1561    apply_skew(tempbitmap, 40);
15621562
1563   // resample to the target size
1564   render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
1563    // resample to the target size
1564    render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
15651565}
15661566
15671567
r242286r242287
15721572
15731573void layout_element::component::draw_led14segsc(bitmap_argb32 &dest, const rectangle &bounds, int pattern)
15741574{
1575   const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
1576   const rgb_t offpen = rgb_t(0xff, 0x20, 0x20, 0x20);
1575    const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
1576    const rgb_t offpen = rgb_t(0xff, 0x20, 0x20, 0x20);
15771577
1578   // sizes for computation
1579   int bmwidth = 250;
1580   int bmheight = 400;
1581   int segwidth = 40;
1582   int skewwidth = 40;
1578    // sizes for computation
1579    int bmwidth = 250;
1580    int bmheight = 400;
1581    int segwidth = 40;
1582    int skewwidth = 40;
15831583
1584   // allocate a temporary bitmap for drawing, adding some extra space for the tail
1585   bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight + segwidth);
1586   tempbitmap.fill(rgb_t(0xff, 0x00, 0x00, 0x00));
1584    // allocate a temporary bitmap for drawing, adding some extra space for the tail
1585    bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight + segwidth);
1586    tempbitmap.fill(rgb_t(0xff, 0x00, 0x00, 0x00));
15871587
1588   // top bar
1589   draw_segment_horizontal(tempbitmap,
1590      0 + 2*segwidth/3, bmwidth - 2*segwidth/3, 0 + segwidth/2,
1591      segwidth, (pattern & (1 << 0)) ? onpen : offpen);
1588    // top bar
1589    draw_segment_horizontal(tempbitmap,
1590        0 + 2*segwidth/3, bmwidth - 2*segwidth/3, 0 + segwidth/2,
1591        segwidth, (pattern & (1 << 0)) ? onpen : offpen);
15921592
1593   // right-top bar
1594   draw_segment_vertical(tempbitmap,
1595      0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2,
1596      segwidth, (pattern & (1 << 1)) ? onpen : offpen);
1593    // right-top bar
1594    draw_segment_vertical(tempbitmap,
1595        0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2,
1596        segwidth, (pattern & (1 << 1)) ? onpen : offpen);
15971597
1598   // right-bottom bar
1599   draw_segment_vertical(tempbitmap,
1600      bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2,
1601      segwidth, (pattern & (1 << 2)) ? onpen : offpen);
1598    // right-bottom bar
1599    draw_segment_vertical(tempbitmap,
1600        bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2,
1601        segwidth, (pattern & (1 << 2)) ? onpen : offpen);
16021602
1603   // bottom bar
1604   draw_segment_horizontal(tempbitmap,
1605      0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight - segwidth/2,
1606      segwidth, (pattern & (1 << 3)) ? onpen : offpen);
1603    // bottom bar
1604    draw_segment_horizontal(tempbitmap,
1605        0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight - segwidth/2,
1606        segwidth, (pattern & (1 << 3)) ? onpen : offpen);
16071607
1608   // left-bottom bar
1609   draw_segment_vertical(tempbitmap,
1610      bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2,
1611      segwidth, (pattern & (1 << 4)) ? onpen : offpen);
1608    // left-bottom bar
1609    draw_segment_vertical(tempbitmap,
1610        bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2,
1611        segwidth, (pattern & (1 << 4)) ? onpen : offpen);
16121612
1613   // left-top bar
1614   draw_segment_vertical(tempbitmap,
1615      0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2,
1616      segwidth, (pattern & (1 << 5)) ? onpen : offpen);
1613    // left-top bar
1614    draw_segment_vertical(tempbitmap,
1615        0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2,
1616        segwidth, (pattern & (1 << 5)) ? onpen : offpen);
16171617
1618   // horizontal-middle-left bar
1619   draw_segment_horizontal_caps(tempbitmap,
1620      0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight/2,
1621      segwidth, LINE_CAP_START, (pattern & (1 << 6)) ? onpen : offpen);
1618    // horizontal-middle-left bar
1619    draw_segment_horizontal_caps(tempbitmap,
1620        0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight/2,
1621        segwidth, LINE_CAP_START, (pattern & (1 << 6)) ? onpen : offpen);
16221622
1623   // horizontal-middle-right bar
1624   draw_segment_horizontal_caps(tempbitmap,
1625      0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight/2,
1626      segwidth, LINE_CAP_END, (pattern & (1 << 7)) ? onpen : offpen);
1623    // horizontal-middle-right bar
1624    draw_segment_horizontal_caps(tempbitmap,
1625        0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight/2,
1626        segwidth, LINE_CAP_END, (pattern & (1 << 7)) ? onpen : offpen);
16271627
1628   // vertical-middle-top bar
1629   draw_segment_vertical_caps(tempbitmap,
1630      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3, bmwidth/2,
1631      segwidth, LINE_CAP_NONE, (pattern & (1 << 8)) ? onpen : offpen);
1628    // vertical-middle-top bar
1629    draw_segment_vertical_caps(tempbitmap,
1630        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3, bmwidth/2,
1631        segwidth, LINE_CAP_NONE, (pattern & (1 << 8)) ? onpen : offpen);
16321632
1633   // vertical-middle-bottom bar
1634   draw_segment_vertical_caps(tempbitmap,
1635      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3, bmwidth/2,
1636      segwidth, LINE_CAP_NONE, (pattern & (1 << 9)) ? onpen : offpen);
1633    // vertical-middle-bottom bar
1634    draw_segment_vertical_caps(tempbitmap,
1635        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3, bmwidth/2,
1636        segwidth, LINE_CAP_NONE, (pattern & (1 << 9)) ? onpen : offpen);
16371637
1638   // diagonal-left-bottom bar
1639   draw_segment_diagonal_1(tempbitmap,
1640      0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1641      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1642      segwidth, (pattern & (1 << 10)) ? onpen : offpen);
1638    // diagonal-left-bottom bar
1639    draw_segment_diagonal_1(tempbitmap,
1640        0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1641        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1642        segwidth, (pattern & (1 << 10)) ? onpen : offpen);
16431643
1644   // diagonal-left-top bar
1645   draw_segment_diagonal_2(tempbitmap,
1646      0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1647      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1648      segwidth, (pattern & (1 << 11)) ? onpen : offpen);
1644    // diagonal-left-top bar
1645    draw_segment_diagonal_2(tempbitmap,
1646        0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1647        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1648        segwidth, (pattern & (1 << 11)) ? onpen : offpen);
16491649
1650   // diagonal-right-top bar
1651   draw_segment_diagonal_1(tempbitmap,
1652      bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1653      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1654      segwidth, (pattern & (1 << 12)) ? onpen : offpen);
1650    // diagonal-right-top bar
1651    draw_segment_diagonal_1(tempbitmap,
1652        bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1653        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1654        segwidth, (pattern & (1 << 12)) ? onpen : offpen);
16551655
1656   // diagonal-right-bottom bar
1657   draw_segment_diagonal_2(tempbitmap,
1658      bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1659      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1660      segwidth, (pattern & (1 << 13)) ? onpen : offpen);
1656    // diagonal-right-bottom bar
1657    draw_segment_diagonal_2(tempbitmap,
1658        bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1659        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1660        segwidth, (pattern & (1 << 13)) ? onpen : offpen);
16611661
1662   // apply skew
1663   apply_skew(tempbitmap, 40);
1662    // apply skew
1663    apply_skew(tempbitmap, 40);
16641664
1665   // comma tail
1666   draw_segment_diagonal_1(tempbitmap,
1667      bmwidth - (segwidth/2), bmwidth + segwidth,
1668      bmheight - (segwidth), bmheight + segwidth*1.5,
1669      segwidth/2, (pattern & (1 << 15)) ? onpen : offpen);
1665    // comma tail
1666    draw_segment_diagonal_1(tempbitmap,
1667        bmwidth - (segwidth/2), bmwidth + segwidth,
1668        bmheight - (segwidth), bmheight + segwidth*1.5,
1669        segwidth/2, (pattern & (1 << 15)) ? onpen : offpen);
16701670
1671   // decimal point
1672   draw_segment_decimal(tempbitmap, bmwidth + segwidth/2, bmheight - segwidth/2, segwidth, (pattern & (1 << 14)) ? onpen : offpen);
1671    // decimal point
1672    draw_segment_decimal(tempbitmap, bmwidth + segwidth/2, bmheight - segwidth/2, segwidth, (pattern & (1 << 14)) ? onpen : offpen);
16731673
1674   // resample to the target size
1675   render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
1674    // resample to the target size
1675    render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
16761676}
16771677
16781678
r242286r242287
16821682
16831683void layout_element::component::draw_led16seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern)
16841684{
1685   const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
1686   const rgb_t offpen = rgb_t(0xff, 0x20, 0x20, 0x20);
1685    const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
1686    const rgb_t offpen = rgb_t(0xff, 0x20, 0x20, 0x20);
16871687
1688   // sizes for computation
1689   int bmwidth = 250;
1690   int bmheight = 400;
1691   int segwidth = 40;
1692   int skewwidth = 40;
1688    // sizes for computation
1689    int bmwidth = 250;
1690    int bmheight = 400;
1691    int segwidth = 40;
1692    int skewwidth = 40;
16931693
1694   // allocate a temporary bitmap for drawing
1695   bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight);
1696   tempbitmap.fill(rgb_t(0xff, 0x00, 0x00, 0x00));
1694    // allocate a temporary bitmap for drawing
1695    bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight);
1696    tempbitmap.fill(rgb_t(0xff, 0x00, 0x00, 0x00));
16971697
1698   // top-left bar
1699   draw_segment_horizontal_caps(tempbitmap,
1700      0 + 2*segwidth/3, bmwidth/2 - segwidth/10, 0 + segwidth/2,
1701      segwidth, LINE_CAP_START, (pattern & (1 << 0)) ? onpen : offpen);
1698    // top-left bar
1699    draw_segment_horizontal_caps(tempbitmap,
1700        0 + 2*segwidth/3, bmwidth/2 - segwidth/10, 0 + segwidth/2,
1701        segwidth, LINE_CAP_START, (pattern & (1 << 0)) ? onpen : offpen);
17021702
1703   // top-right bar
1704   draw_segment_horizontal_caps(tempbitmap,
1705      0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, 0 + segwidth/2,
1706      segwidth, LINE_CAP_END, (pattern & (1 << 1)) ? onpen : offpen);
1703    // top-right bar
1704    draw_segment_horizontal_caps(tempbitmap,
1705        0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, 0 + segwidth/2,
1706        segwidth, LINE_CAP_END, (pattern & (1 << 1)) ? onpen : offpen);
17071707
1708   // right-top bar
1709   draw_segment_vertical(tempbitmap,
1710      0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2,
1711      segwidth, (pattern & (1 << 2)) ? onpen : offpen);
1708    // right-top bar
1709    draw_segment_vertical(tempbitmap,
1710        0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2,
1711        segwidth, (pattern & (1 << 2)) ? onpen : offpen);
17121712
1713   // right-bottom bar
1714   draw_segment_vertical(tempbitmap,
1715      bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2,
1716      segwidth, (pattern & (1 << 3)) ? onpen : offpen);
1713    // right-bottom bar
1714    draw_segment_vertical(tempbitmap,
1715        bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2,
1716        segwidth, (pattern & (1 << 3)) ? onpen : offpen);
17171717
1718   // bottom-right bar
1719   draw_segment_horizontal_caps(tempbitmap,
1720      0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight - segwidth/2,
1721      segwidth, LINE_CAP_END, (pattern & (1 << 4)) ? onpen : offpen);
1718    // bottom-right bar
1719    draw_segment_horizontal_caps(tempbitmap,
1720        0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight - segwidth/2,
1721        segwidth, LINE_CAP_END, (pattern & (1 << 4)) ? onpen : offpen);
17221722
1723   // bottom-left bar
1724   draw_segment_horizontal_caps(tempbitmap,
1725      0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight - segwidth/2,
1726      segwidth, LINE_CAP_START, (pattern & (1 << 5)) ? onpen : offpen);
1723    // bottom-left bar
1724    draw_segment_horizontal_caps(tempbitmap,
1725        0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight - segwidth/2,
1726        segwidth, LINE_CAP_START, (pattern & (1 << 5)) ? onpen : offpen);
17271727
1728   // left-bottom bar
1729   draw_segment_vertical(tempbitmap,
1730      bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2,
1731      segwidth, (pattern & (1 << 6)) ? onpen : offpen);
1728    // left-bottom bar
1729    draw_segment_vertical(tempbitmap,
1730        bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2,
1731        segwidth, (pattern & (1 << 6)) ? onpen : offpen);
17321732
1733   // left-top bar
1734   draw_segment_vertical(tempbitmap,
1735      0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2,
1736      segwidth, (pattern & (1 << 7)) ? onpen : offpen);
1733    // left-top bar
1734    draw_segment_vertical(tempbitmap,
1735        0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2,
1736        segwidth, (pattern & (1 << 7)) ? onpen : offpen);
17371737
1738   // horizontal-middle-left bar
1739   draw_segment_horizontal_caps(tempbitmap,
1740      0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight/2,
1741      segwidth, LINE_CAP_START, (pattern & (1 << 8)) ? onpen : offpen);
1738    // horizontal-middle-left bar
1739    draw_segment_horizontal_caps(tempbitmap,
1740        0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight/2,
1741        segwidth, LINE_CAP_START, (pattern & (1 << 8)) ? onpen : offpen);
17421742
1743   // horizontal-middle-right bar
1744   draw_segment_horizontal_caps(tempbitmap,
1745      0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight/2,
1746      segwidth, LINE_CAP_END, (pattern & (1 << 9)) ? onpen : offpen);
1743    // horizontal-middle-right bar
1744    draw_segment_horizontal_caps(tempbitmap,
1745        0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight/2,
1746        segwidth, LINE_CAP_END, (pattern & (1 << 9)) ? onpen : offpen);
17471747
1748   // vertical-middle-top bar
1749   draw_segment_vertical_caps(tempbitmap,
1750      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3, bmwidth/2,
1751      segwidth, LINE_CAP_NONE, (pattern & (1 << 10)) ? onpen : offpen);
1748    // vertical-middle-top bar
1749    draw_segment_vertical_caps(tempbitmap,
1750        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3, bmwidth/2,
1751        segwidth, LINE_CAP_NONE, (pattern & (1 << 10)) ? onpen : offpen);
17521752
1753   // vertical-middle-bottom bar
1754   draw_segment_vertical_caps(tempbitmap,
1755      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3, bmwidth/2,
1756      segwidth, LINE_CAP_NONE, (pattern & (1 << 11)) ? onpen : offpen);
1753    // vertical-middle-bottom bar
1754    draw_segment_vertical_caps(tempbitmap,
1755        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3, bmwidth/2,
1756        segwidth, LINE_CAP_NONE, (pattern & (1 << 11)) ? onpen : offpen);
17571757
1758   // diagonal-left-bottom bar
1759   draw_segment_diagonal_1(tempbitmap,
1760      0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1761      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1762      segwidth, (pattern & (1 << 12)) ? onpen : offpen);
1758    // diagonal-left-bottom bar
1759    draw_segment_diagonal_1(tempbitmap,
1760        0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1761        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1762        segwidth, (pattern & (1 << 12)) ? onpen : offpen);
17631763
1764   // diagonal-left-top bar
1765   draw_segment_diagonal_2(tempbitmap,
1766      0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1767      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1768      segwidth, (pattern & (1 << 13)) ? onpen : offpen);
1764    // diagonal-left-top bar
1765    draw_segment_diagonal_2(tempbitmap,
1766        0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1767        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1768        segwidth, (pattern & (1 << 13)) ? onpen : offpen);
17691769
1770   // diagonal-right-top bar
1771   draw_segment_diagonal_1(tempbitmap,
1772      bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1773      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1774      segwidth, (pattern & (1 << 14)) ? onpen : offpen);
1770    // diagonal-right-top bar
1771    draw_segment_diagonal_1(tempbitmap,
1772        bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1773        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1774        segwidth, (pattern & (1 << 14)) ? onpen : offpen);
17751775
1776   // diagonal-right-bottom bar
1777   draw_segment_diagonal_2(tempbitmap,
1778      bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1779      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1780      segwidth, (pattern & (1 << 15)) ? onpen : offpen);
1776    // diagonal-right-bottom bar
1777    draw_segment_diagonal_2(tempbitmap,
1778        bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1779        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1780        segwidth, (pattern & (1 << 15)) ? onpen : offpen);
17811781
1782   // apply skew
1783   apply_skew(tempbitmap, 40);
1782    // apply skew
1783    apply_skew(tempbitmap, 40);
17841784
1785   // resample to the target size
1786   render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
1785    // resample to the target size
1786    render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
17871787}
17881788
17891789
r242286r242287
17941794
17951795void layout_element::component::draw_led16segsc(bitmap_argb32 &dest, const rectangle &bounds, int pattern)
17961796{
1797   const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
1798   const rgb_t offpen = rgb_t(0xff, 0x20, 0x20, 0x20);
1797    const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
1798    const rgb_t offpen = rgb_t(0xff, 0x20, 0x20, 0x20);
17991799
1800   // sizes for computation
1801   int bmwidth = 250;
1802   int bmheight = 400;
1803   int segwidth = 40;
1804   int skewwidth = 40;
1800    // sizes for computation
1801    int bmwidth = 250;
1802    int bmheight = 400;
1803    int segwidth = 40;
1804    int skewwidth = 40;
18051805
1806   // allocate a temporary bitmap for drawing
1807   bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight + segwidth);
1808   tempbitmap.fill(rgb_t(0xff, 0x00, 0x00, 0x00));
1806    // allocate a temporary bitmap for drawing
1807    bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight + segwidth);
1808    tempbitmap.fill(rgb_t(0xff, 0x00, 0x00, 0x00));
18091809
1810   // top-left bar
1811   draw_segment_horizontal_caps(tempbitmap,
1812      0 + 2*segwidth/3, bmwidth/2 - segwidth/10, 0 + segwidth/2,
1813      segwidth, LINE_CAP_START, (pattern & (1 << 0)) ? onpen : offpen);
1810    // top-left bar
1811    draw_segment_horizontal_caps(tempbitmap,
1812        0 + 2*segwidth/3, bmwidth/2 - segwidth/10, 0 + segwidth/2,
1813        segwidth, LINE_CAP_START, (pattern & (1 << 0)) ? onpen : offpen);
18141814
1815   // top-right bar
1816   draw_segment_horizontal_caps(tempbitmap,
1817      0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, 0 + segwidth/2,
1818      segwidth, LINE_CAP_END, (pattern & (1 << 1)) ? onpen : offpen);
1815    // top-right bar
1816    draw_segment_horizontal_caps(tempbitmap,
1817        0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, 0 + segwidth/2,
1818        segwidth, LINE_CAP_END, (pattern & (1 << 1)) ? onpen : offpen);
18191819
1820   // right-top bar
1821   draw_segment_vertical(tempbitmap,
1822      0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2,
1823      segwidth, (pattern & (1 << 2)) ? onpen : offpen);
1820    // right-top bar
1821    draw_segment_vertical(tempbitmap,
1822        0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2,
1823        segwidth, (pattern & (1 << 2)) ? onpen : offpen);
18241824
1825   // right-bottom bar
1826   draw_segment_vertical(tempbitmap,
1827      bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2,
1828      segwidth, (pattern & (1 << 3)) ? onpen : offpen);
1825    // right-bottom bar
1826    draw_segment_vertical(tempbitmap,
1827        bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2,
1828        segwidth, (pattern & (1 << 3)) ? onpen : offpen);
18291829
1830   // bottom-right bar
1831   draw_segment_horizontal_caps(tempbitmap,
1832      0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight - segwidth/2,
1833      segwidth, LINE_CAP_END, (pattern & (1 << 4)) ? onpen : offpen);
1830    // bottom-right bar
1831    draw_segment_horizontal_caps(tempbitmap,
1832        0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight - segwidth/2,
1833        segwidth, LINE_CAP_END, (pattern & (1 << 4)) ? onpen : offpen);
18341834
1835   // bottom-left bar
1836   draw_segment_horizontal_caps(tempbitmap,
1837      0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight - segwidth/2,
1838      segwidth, LINE_CAP_START, (pattern & (1 << 5)) ? onpen : offpen);
1835    // bottom-left bar
1836    draw_segment_horizontal_caps(tempbitmap,
1837        0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight - segwidth/2,
1838        segwidth, LINE_CAP_START, (pattern & (1 << 5)) ? onpen : offpen);
18391839
1840   // left-bottom bar
1841   draw_segment_vertical(tempbitmap,
1842      bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2,
1843      segwidth, (pattern & (1 << 6)) ? onpen : offpen);
1840    // left-bottom bar
1841    draw_segment_vertical(tempbitmap,
1842        bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2,
1843        segwidth, (pattern & (1 << 6)) ? onpen : offpen);
18441844
1845   // left-top bar
1846   draw_segment_vertical(tempbitmap,
1847      0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2,
1848      segwidth, (pattern & (1 << 7)) ? onpen : offpen);
1845    // left-top bar
1846    draw_segment_vertical(tempbitmap,
1847        0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2,
1848        segwidth, (pattern & (1 << 7)) ? onpen : offpen);
18491849
1850   // horizontal-middle-left bar
1851   draw_segment_horizontal_caps(tempbitmap,
1852      0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight/2,
1853      segwidth, LINE_CAP_START, (pattern & (1 << 8)) ? onpen : offpen);
1850    // horizontal-middle-left bar
1851    draw_segment_horizontal_caps(tempbitmap,
1852        0 + 2*segwidth/3, bmwidth/2 - segwidth/10, bmheight/2,
1853        segwidth, LINE_CAP_START, (pattern & (1 << 8)) ? onpen : offpen);
18541854
1855   // horizontal-middle-right bar
1856   draw_segment_horizontal_caps(tempbitmap,
1857      0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight/2,
1858      segwidth, LINE_CAP_END, (pattern & (1 << 9)) ? onpen : offpen);
1855    // horizontal-middle-right bar
1856    draw_segment_horizontal_caps(tempbitmap,
1857        0 + bmwidth/2 + segwidth/10, bmwidth - 2*segwidth/3, bmheight/2,
1858        segwidth, LINE_CAP_END, (pattern & (1 << 9)) ? onpen : offpen);
18591859
1860   // vertical-middle-top bar
1861   draw_segment_vertical_caps(tempbitmap,
1862      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3, bmwidth/2,
1863      segwidth, LINE_CAP_NONE, (pattern & (1 << 10)) ? onpen : offpen);
1860    // vertical-middle-top bar
1861    draw_segment_vertical_caps(tempbitmap,
1862        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3, bmwidth/2,
1863        segwidth, LINE_CAP_NONE, (pattern & (1 << 10)) ? onpen : offpen);
18641864
1865   // vertical-middle-bottom bar
1866   draw_segment_vertical_caps(tempbitmap,
1867      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3, bmwidth/2,
1868      segwidth, LINE_CAP_NONE, (pattern & (1 << 11)) ? onpen : offpen);
1865    // vertical-middle-bottom bar
1866    draw_segment_vertical_caps(tempbitmap,
1867        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3, bmwidth/2,
1868        segwidth, LINE_CAP_NONE, (pattern & (1 << 11)) ? onpen : offpen);
18691869
1870   // diagonal-left-bottom bar
1871   draw_segment_diagonal_1(tempbitmap,
1872      0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1873      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1874      segwidth, (pattern & (1 << 12)) ? onpen : offpen);
1870    // diagonal-left-bottom bar
1871    draw_segment_diagonal_1(tempbitmap,
1872        0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1873        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1874        segwidth, (pattern & (1 << 12)) ? onpen : offpen);
18751875
1876   // diagonal-left-top bar
1877   draw_segment_diagonal_2(tempbitmap,
1878      0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1879      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1880      segwidth, (pattern & (1 << 13)) ? onpen : offpen);
1876    // diagonal-left-top bar
1877    draw_segment_diagonal_2(tempbitmap,
1878        0 + segwidth + segwidth/5, bmwidth/2 - segwidth/2 - segwidth/5,
1879        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1880        segwidth, (pattern & (1 << 13)) ? onpen : offpen);
18811881
1882   // diagonal-right-top bar
1883   draw_segment_diagonal_1(tempbitmap,
1884      bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1885      0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1886      segwidth, (pattern & (1 << 14)) ? onpen : offpen);
1882    // diagonal-right-top bar
1883    draw_segment_diagonal_1(tempbitmap,
1884        bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1885        0 + segwidth + segwidth/3, bmheight/2 - segwidth/2 - segwidth/3,
1886        segwidth, (pattern & (1 << 14)) ? onpen : offpen);
18871887
1888   // diagonal-right-bottom bar
1889   draw_segment_diagonal_2(tempbitmap,
1890      bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1891      bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1892      segwidth, (pattern & (1 << 15)) ? onpen : offpen);
1888    // diagonal-right-bottom bar
1889    draw_segment_diagonal_2(tempbitmap,
1890        bmwidth/2 + segwidth/2 + segwidth/5, bmwidth - segwidth - segwidth/5,
1891        bmheight/2 + segwidth/2 + segwidth/3, bmheight - segwidth - segwidth/3,
1892        segwidth, (pattern & (1 << 15)) ? onpen : offpen);
18931893
1894   // comma tail
1895   draw_segment_diagonal_1(tempbitmap,
1896      bmwidth - (segwidth/2), bmwidth + segwidth,
1897      bmheight - (segwidth), bmheight + segwidth*1.5,
1898      segwidth/2, (pattern & (1 << 17)) ? onpen : offpen);
1894    // comma tail
1895    draw_segment_diagonal_1(tempbitmap,
1896        bmwidth - (segwidth/2), bmwidth + segwidth,
1897        bmheight - (segwidth), bmheight + segwidth*1.5,
1898        segwidth/2, (pattern & (1 << 17)) ? onpen : offpen);
18991899
1900   // decimal point (draw last for priority)
1901   draw_segment_decimal(tempbitmap, bmwidth + segwidth/2, bmheight - segwidth/2, segwidth, (pattern & (1 << 16)) ? onpen : offpen);
1900    // decimal point (draw last for priority)
1901    draw_segment_decimal(tempbitmap, bmwidth + segwidth/2, bmheight - segwidth/2, segwidth, (pattern & (1 << 16)) ? onpen : offpen);
19021902
1903   // apply skew
1904   apply_skew(tempbitmap, 40);
1903    // apply skew
1904    apply_skew(tempbitmap, 40);
19051905
1906   // resample to the target size
1907   render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
1906    // resample to the target size
1907    render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
19081908}
19091909
19101910
r242286r242287
19151915
19161916void layout_element::component::draw_dotmatrix(int dots, bitmap_argb32 &dest, const rectangle &bounds, int pattern)
19171917{
1918   const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
1919   const rgb_t offpen = rgb_t(0xff, 0x20, 0x20, 0x20);
1918    const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
1919    const rgb_t offpen = rgb_t(0xff, 0x20, 0x20, 0x20);
19201920
1921   // sizes for computation
1922   int bmheight = 300;
1923   int dotwidth = 250;
1921    // sizes for computation
1922    int bmheight = 300;
1923    int dotwidth = 250;
19241924
1925   // allocate a temporary bitmap for drawing
1926   bitmap_argb32 tempbitmap(dotwidth*dots, bmheight);
1927   tempbitmap.fill(rgb_t(0xff, 0x00, 0x00, 0x00));
1925    // allocate a temporary bitmap for drawing
1926    bitmap_argb32 tempbitmap(dotwidth*dots, bmheight);
1927    tempbitmap.fill(rgb_t(0xff, 0x00, 0x00, 0x00));
19281928
1929   for (int i = 0; i < dots; i++)
1930      draw_segment_decimal(tempbitmap, ((dotwidth/2 )+ (i * dotwidth)), bmheight/2, dotwidth, (pattern & (1 << i))?onpen:offpen);
1929    for (int i = 0; i < dots; i++)
1930        draw_segment_decimal(tempbitmap, ((dotwidth/2 )+ (i * dotwidth)), bmheight/2, dotwidth, (pattern & (1 << i))?onpen:offpen);
19311931
1932   // resample to the target size
1933   render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
1932    // resample to the target size
1933    render_resample_argb_bitmap_hq(dest, tempbitmap, m_color);
19341934}
19351935
19361936
r242286r242287
19421942
19431943void layout_element::component::draw_segment_horizontal_caps(bitmap_argb32 &dest, int minx, int maxx, int midy, int width, int caps, rgb_t color)
19441944{
1945   // loop over the width of the segment
1946   for (int y = 0; y < width / 2; y++)
1947   {
1948      UINT32 *d0 = &dest.pix32(midy - y);
1949      UINT32 *d1 = &dest.pix32(midy + y);
1950      int ty = (y < width / 8) ? width / 8 : y;
1945    // loop over the width of the segment
1946    for (int y = 0; y < width / 2; y++)
1947    {
1948        UINT32 *d0 = &dest.pix32(midy - y);
1949        UINT32 *d1 = &dest.pix32(midy + y);
1950        int ty = (y < width / 8) ? width / 8 : y;
19511951
1952      // loop over the length of the segment
1953      for (int x = minx + ((caps & LINE_CAP_START) ? ty : 0); x < maxx - ((caps & LINE_CAP_END) ? ty : 0); x++)
1954         d0[x] = d1[x] = color;
1955   }
1952        // loop over the length of the segment
1953        for (int x = minx + ((caps & LINE_CAP_START) ? ty : 0); x < maxx - ((caps & LINE_CAP_END) ? ty : 0); x++)
1954            d0[x] = d1[x] = color;
1955    }
19561956}
19571957
19581958
r242286r242287
19631963
19641964void layout_element::component::draw_segment_horizontal(bitmap_argb32 &dest, int minx, int maxx, int midy, int width, rgb_t color)
19651965{
1966   draw_segment_horizontal_caps(dest, minx, maxx, midy, width, LINE_CAP_START | LINE_CAP_END, color);
1966    draw_segment_horizontal_caps(dest, minx, maxx, midy, width, LINE_CAP_START | LINE_CAP_END, color);
19671967}
19681968
19691969
r242286r242287
19751975
19761976void layout_element::component::draw_segment_vertical_caps(bitmap_argb32 &dest, int miny, int maxy, int midx, int width, int caps, rgb_t color)
19771977{
1978   // loop over the width of the segment
1979   for (int x = 0; x < width / 2; x++)
1980   {
1981      UINT32 *d0 = &dest.pix32(0, midx - x);
1982      UINT32 *d1 = &dest.pix32(0, midx + x);
1983      int tx = (x < width / 8) ? width / 8 : x;
1978    // loop over the width of the segment
1979    for (int x = 0; x < width / 2; x++)
1980    {
1981        UINT32 *d0 = &dest.pix32(0, midx - x);
1982        UINT32 *d1 = &dest.pix32(0, midx + x);
1983        int tx = (x < width / 8) ? width / 8 : x;
19841984
1985      // loop over the length of the segment
1986      for (int y = miny + ((caps & LINE_CAP_START) ? tx : 0); y < maxy - ((caps & LINE_CAP_END) ? tx : 0); y++)
1987         d0[y * dest.rowpixels()] = d1[y * dest.rowpixels()] = color;
1988   }
1985        // loop over the length of the segment
1986        for (int y = miny + ((caps & LINE_CAP_START) ? tx : 0); y < maxy - ((caps & LINE_CAP_END) ? tx : 0); y++)
1987            d0[y * dest.rowpixels()] = d1[y * dest.rowpixels()] = color;
1988    }
19891989}
19901990
19911991
r242286r242287
19961996
19971997void layout_element::component::draw_segment_vertical(bitmap_argb32 &dest, int miny, int maxy, int midx, int width, rgb_t color)
19981998{
1999   draw_segment_vertical_caps(dest, miny, maxy, midx, width, LINE_CAP_START | LINE_CAP_END, color);
1999    draw_segment_vertical_caps(dest, miny, maxy, midx, width, LINE_CAP_START | LINE_CAP_END, color);
20002000}
20012001
20022002
r242286r242287
20072007
20082008void layout_element::component::draw_segment_diagonal_1(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color)
20092009{
2010   // compute parameters
2011   width *= 1.5;
2012   float ratio = (maxy - miny - width) / (float)(maxx - minx);
2010    // compute parameters
2011    width *= 1.5;
2012    float ratio = (maxy - miny - width) / (float)(maxx - minx);
20132013
2014   // draw line
2015   for (int x = minx; x < maxx; x++)
2016      if (x >= 0 && x < dest.width())
2017      {
2018         UINT32 *d = &dest.pix32(0, x);
2019         int step = (x - minx) * ratio;
2014    // draw line
2015    for (int x = minx; x < maxx; x++)
2016        if (x >= 0 && x < dest.width())
2017        {
2018            UINT32 *d = &dest.pix32(0, x);
2019            int step = (x - minx) * ratio;
20202020
2021         for (int y = maxy - width - step; y < maxy - step; y++)
2022            if (y >= 0 && y < dest.height())
2023               d[y * dest.rowpixels()] = color;
2024      }
2021            for (int y = maxy - width - step; y < maxy - step; y++)
2022                if (y >= 0 && y < dest.height())
2023                    d[y * dest.rowpixels()] = color;
2024        }
20252025}
20262026
20272027
r242286r242287
20322032
20332033void layout_element::component::draw_segment_diagonal_2(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color)
20342034{
2035   // compute parameters
2036   width *= 1.5;
2037   float ratio = (maxy - miny - width) / (float)(maxx - minx);
2035    // compute parameters
2036    width *= 1.5;
2037    float ratio = (maxy - miny - width) / (float)(maxx - minx);
20382038
2039   // draw line
2040   for (int x = minx; x < maxx; x++)
2041      if (x >= 0 && x < dest.width())
2042      {
2043         UINT32 *d = &dest.pix32(0, x);
2044         int step = (x - minx) * ratio;
2039    // draw line
2040    for (int x = minx; x < maxx; x++)
2041        if (x >= 0 && x < dest.width())
2042        {
2043            UINT32 *d = &dest.pix32(0, x);
2044            int step = (x - minx) * ratio;
20452045
2046         for (int y = miny + step; y < miny + step + width; y++)
2047            if (y >= 0 && y < dest.height())
2048               d[y * dest.rowpixels()] = color;
2049      }
2046            for (int y = miny + step; y < miny + step + width; y++)
2047                if (y >= 0 && y < dest.height())
2048                    d[y * dest.rowpixels()] = color;
2049        }
20502050}
20512051
20522052
r242286r242287
20562056
20572057void layout_element::component::draw_segment_decimal(bitmap_argb32 &dest, int midx, int midy, int width, rgb_t color)
20582058{
2059   // compute parameters
2060   width /= 2;
2061   float ooradius2 = 1.0f / (float)(width * width);
2059    // compute parameters
2060    width /= 2;
2061    float ooradius2 = 1.0f / (float)(width * width);
20622062
2063   // iterate over y
2064   for (UINT32 y = 0; y <= width; y++)
2065   {
2066      UINT32 *d0 = &dest.pix32(midy - y);
2067      UINT32 *d1 = &dest.pix32(midy + y);
2068      float xval = width * sqrt(1.0f - (float)(y * y) * ooradius2);
2069      INT32 left, right;
2063    // iterate over y
2064    for (UINT32 y = 0; y <= width; y++)
2065    {
2066        UINT32 *d0 = &dest.pix32(midy - y);
2067        UINT32 *d1 = &dest.pix32(midy + y);
2068        float xval = width * sqrt(1.0f - (float)(y * y) * ooradius2);
2069        INT32 left, right;
20702070
2071      // compute left/right coordinates
2072      left = midx - (INT32)(xval + 0.5f);
2073      right = midx + (INT32)(xval + 0.5f);
2071        // compute left/right coordinates
2072        left = midx - (INT32)(xval + 0.5f);
2073        right = midx + (INT32)(xval + 0.5f);
20742074
2075      // draw this scanline
2076      for (UINT32 x = left; x < right; x++)
2077         d0[x] = d1[x] = color;
2078   }
2075        // draw this scanline
2076        for (UINT32 x = left; x < right; x++)
2077            d0[x] = d1[x] = color;
2078    }
20792079}
20802080
20812081
r242286r242287
20852085
20862086void layout_element::component::draw_segment_comma(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color)
20872087{
2088   // compute parameters
2089   width *= 1.5;
2090   float ratio = (maxy - miny - width) / (float)(maxx - minx);
2088    // compute parameters
2089    width *= 1.5;
2090    float ratio = (maxy - miny - width) / (float)(maxx - minx);
20912091
2092   // draw line
2093   for (int x = minx; x < maxx; x++)
2094   {
2095      UINT32 *d = &dest.pix32(0, x);
2096      int step = (x - minx) * ratio;
2092    // draw line
2093    for (int x = minx; x < maxx; x++)
2094    {
2095        UINT32 *d = &dest.pix32(0, x);
2096        int step = (x - minx) * ratio;
20972097
2098      for (int y = maxy; y < maxy  - width - step; y--)
2099         d[y * dest.rowpixels()] = color;
2100   }
2098        for (int y = maxy; y < maxy  - width - step; y--)
2099            d[y * dest.rowpixels()] = color;
2100    }
21012101}
21022102
21032103
r242286r242287
21072107
21082108void layout_element::component::apply_skew(bitmap_argb32 &dest, int skewwidth)
21092109{
2110   for (int y = 0; y < dest.height(); y++)
2111   {
2112      UINT32 *destrow = &dest.pix32(y);
2113      int offs = skewwidth * (dest.height() - y) / dest.height();
2114      for (int x = dest.width() - skewwidth - 1; x >= 0; x--)
2115         destrow[x + offs] = destrow[x];
2116      for (int x = 0; x < offs; x++)
2117         destrow[x] = 0;
2118   }
2110    for (int y = 0; y < dest.height(); y++)
2111    {
2112        UINT32 *destrow = &dest.pix32(y);
2113        int offs = skewwidth * (dest.height() - y) / dest.height();
2114        for (int x = dest.width() - skewwidth - 1; x >= 0; x--)
2115            destrow[x + offs] = destrow[x];
2116        for (int x = 0; x < offs; x++)
2117            destrow[x] = 0;
2118    }
21192119}
21202120
21212121
r242286r242287
21292129//-------------------------------------------------
21302130
21312131layout_view::layout_view(running_machine &machine, xml_data_node &viewnode, simple_list<layout_element> &elemlist)
2132   : m_next(NULL),
2133      m_aspect(1.0f),
2134      m_scraspect(1.0f)
2132    : m_next(NULL),
2133        m_aspect(1.0f),
2134        m_scraspect(1.0f)
21352135{
2136   // allocate a copy of the name
2137   m_name = xml_get_attribute_string_with_subst(machine, viewnode, "name", "");
2136    // allocate a copy of the name
2137    m_name = xml_get_attribute_string_with_subst(machine, viewnode, "name", "");
21382138
2139   // if we have a bounds item, load it
2140   xml_data_node *boundsnode = xml_get_sibling(viewnode.child, "bounds");
2141   m_expbounds.x0 = m_expbounds.y0 = m_expbounds.x1 = m_expbounds.y1 = 0;
2142   if (boundsnode != NULL)
2143      parse_bounds(machine, xml_get_sibling(boundsnode, "bounds"), m_expbounds);
2139    // if we have a bounds item, load it
2140    xml_data_node *boundsnode = xml_get_sibling(viewnode.child, "bounds");
2141    m_expbounds.x0 = m_expbounds.y0 = m_expbounds.x1 = m_expbounds.y1 = 0;
2142    if (boundsnode != NULL)
2143        parse_bounds(machine, xml_get_sibling(boundsnode, "bounds"), m_expbounds);
21442144
2145   // load backdrop items
2146   for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "backdrop"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "backdrop"))
2147      m_backdrop_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
2145    // load backdrop items
2146    for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "backdrop"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "backdrop"))
2147        m_backdrop_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
21482148
2149   // load screen items
2150   for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "screen"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "screen"))
2151      m_screen_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
2149    // load screen items
2150    for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "screen"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "screen"))
2151        m_screen_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
21522152
2153   // load overlay items
2154   for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "overlay"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "overlay"))
2155      m_overlay_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
2153    // load overlay items
2154    for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "overlay"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "overlay"))
2155        m_overlay_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
21562156
2157   // load bezel items
2158   for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "bezel"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "bezel"))
2159      m_bezel_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
2157    // load bezel items
2158    for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "bezel"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "bezel"))
2159        m_bezel_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
21602160
2161   // load cpanel items
2162   for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "cpanel"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "cpanel"))
2163      m_cpanel_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
2161    // load cpanel items
2162    for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "cpanel"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "cpanel"))
2163        m_cpanel_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
21642164
2165   // load marquee items
2166   for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "marquee"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "marquee"))
2167      m_marquee_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
2165    // load marquee items
2166    for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "marquee"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "marquee"))
2167        m_marquee_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
21682168
2169   // recompute the data for the view based on a default layer config
2170   recompute(render_layer_config());
2169    // recompute the data for the view based on a default layer config
2170    recompute(render_layer_config());
21712171}
21722172
21732173
r242286r242287
21872187
21882188layout_view::item *layout_view::first_item(item_layer layer) const
21892189{
2190   switch (layer)
2191   {
2192      case ITEM_LAYER_BACKDROP:   return m_backdrop_list.first();
2193      case ITEM_LAYER_SCREEN:     return m_screen_list.first();
2194      case ITEM_LAYER_OVERLAY:    return m_overlay_list.first();
2195      case ITEM_LAYER_BEZEL:      return m_bezel_list.first();
2196      case ITEM_LAYER_CPANEL:     return m_cpanel_list.first();
2197      case ITEM_LAYER_MARQUEE:    return m_marquee_list.first();
2198      default:                    return NULL;
2199   }
2190    switch (layer)
2191    {
2192        case ITEM_LAYER_BACKDROP:   return m_backdrop_list.first();
2193        case ITEM_LAYER_SCREEN:     return m_screen_list.first();
2194        case ITEM_LAYER_OVERLAY:    return m_overlay_list.first();
2195        case ITEM_LAYER_BEZEL:      return m_bezel_list.first();
2196        case ITEM_LAYER_CPANEL:     return m_cpanel_list.first();
2197        case ITEM_LAYER_MARQUEE:    return m_marquee_list.first();
2198        default:                    return NULL;
2199    }
22002200}
22012201
22022202
r242286r242287
22072207
22082208void layout_view::recompute(render_layer_config layerconfig)
22092209{
2210   // reset the bounds
2211   m_bounds.x0 = m_bounds.y0 = m_bounds.x1 = m_bounds.y1 = 0.0f;
2212   m_scrbounds.x0 = m_scrbounds.y0 = m_scrbounds.x1 = m_scrbounds.y1 = 0.0f;
2213   m_screens.reset();
2210    // reset the bounds
2211    m_bounds.x0 = m_bounds.y0 = m_bounds.x1 = m_bounds.y1 = 0.0f;
2212    m_scrbounds.x0 = m_scrbounds.y0 = m_scrbounds.x1 = m_scrbounds.y1 = 0.0f;
2213    m_screens.reset();
22142214
2215   // loop over all layers
2216   bool first = true;
2217   bool scrfirst = true;
2218   for (item_layer layer = ITEM_LAYER_FIRST; layer < ITEM_LAYER_MAX; layer++)
2219   {
2220      // determine if this layer should be visible
2221      switch (layer)
2222      {
2223         case ITEM_LAYER_BACKDROP:   m_layenabled[layer] = layerconfig.backdrops_enabled();  break;
2224         case ITEM_LAYER_OVERLAY:    m_layenabled[layer] = layerconfig.overlays_enabled();   break;
2225         case ITEM_LAYER_BEZEL:      m_layenabled[layer] = layerconfig.bezels_enabled();     break;
2226         case ITEM_LAYER_CPANEL:     m_layenabled[layer] = layerconfig.cpanels_enabled();    break;
2227         case ITEM_LAYER_MARQUEE:    m_layenabled[layer] = layerconfig.marquees_enabled();   break;
2228         default:                    m_layenabled[layer] = true;                             break;
2229      }
2215    // loop over all layers
2216    bool first = true;
2217    bool scrfirst = true;
2218    for (item_layer layer = ITEM_LAYER_FIRST; layer < ITEM_LAYER_MAX; layer++)
2219    {
2220        // determine if this layer should be visible
2221        switch (layer)
2222        {
2223            case ITEM_LAYER_BACKDROP:   m_layenabled[layer] = layerconfig.backdrops_enabled();  break;
2224            case ITEM_LAYER_OVERLAY:    m_layenabled[layer] = layerconfig.overlays_enabled();   break;
2225            case ITEM_LAYER_BEZEL:      m_layenabled[layer] = layerconfig.bezels_enabled();     break;
2226            case ITEM_LAYER_CPANEL:     m_layenabled[layer] = layerconfig.cpanels_enabled();    break;
2227            case ITEM_LAYER_MARQUEE:    m_layenabled[layer] = layerconfig.marquees_enabled();   break;
2228            default:                    m_layenabled[layer] = true;                             break;
2229        }
22302230
2231      // only do it if requested
2232      if (m_layenabled[layer])
2233         for (item *curitem = first_item(layer); curitem != NULL; curitem = curitem->next())
2234         {
2235            // accumulate bounds
2236            if (first)
2237               m_bounds = curitem->m_rawbounds;
2238            else
2239               union_render_bounds(&m_bounds, &curitem->m_rawbounds);
2240            first = false;
2231        // only do it if requested
2232        if (m_layenabled[layer])
2233            for (item *curitem = first_item(layer); curitem != NULL; curitem = curitem->next())
2234            {
2235                // accumulate bounds
2236                if (first)
2237                    m_bounds = curitem->m_rawbounds;
2238                else
2239                    union_render_bounds(&m_bounds, &curitem->m_rawbounds);
2240                first = false;
22412241
2242            // accumulate screen bounds
2243            if (curitem->m_screen != NULL)
2244            {
2245               if (scrfirst)
2246                  m_scrbounds = curitem->m_rawbounds;
2247               else
2248                  union_render_bounds(&m_scrbounds, &curitem->m_rawbounds);
2249               scrfirst = false;
2242                // accumulate screen bounds
2243                if (curitem->m_screen != NULL)
2244                {
2245                    if (scrfirst)
2246                        m_scrbounds = curitem->m_rawbounds;
2247                    else
2248                        union_render_bounds(&m_scrbounds, &curitem->m_rawbounds);
2249                    scrfirst = false;
22502250
2251               // accumulate the screens in use while we're scanning
2252               m_screens.add(*curitem->m_screen);
2253            }
2254         }
2255   }
2251                    // accumulate the screens in use while we're scanning
2252                    m_screens.add(*curitem->m_screen);
2253                }
2254            }
2255    }
22562256
2257   // if we have an explicit bounds, override it
2258   if (m_expbounds.x1 > m_expbounds.x0)
2259      m_bounds = m_expbounds;
2257    // if we have an explicit bounds, override it
2258    if (m_expbounds.x1 > m_expbounds.x0)
2259        m_bounds = m_expbounds;
22602260
2261   // if we're handling things normally, the target bounds are (0,0)-(1,1)
2262   render_bounds target_bounds;
2263   if (!layerconfig.zoom_to_screen() || m_screens.count() == 0)
2264   {
2265      // compute the aspect ratio of the view
2266      m_aspect = (m_bounds.x1 - m_bounds.x0) / (m_bounds.y1 - m_bounds.y0);
2261    // if we're handling things normally, the target bounds are (0,0)-(1,1)
2262    render_bounds target_bounds;
2263    if (!layerconfig.zoom_to_screen() || m_screens.count() == 0)
2264    {
2265        // compute the aspect ratio of the view
2266        m_aspect = (m_bounds.x1 - m_bounds.x0) / (m_bounds.y1 - m_bounds.y0);
22672267
2268      target_bounds.x0 = target_bounds.y0 = 0.0f;
2269      target_bounds.x1 = target_bounds.y1 = 1.0f;
2270   }
2268        target_bounds.x0 = target_bounds.y0 = 0.0f;
2269        target_bounds.x1 = target_bounds.y1 = 1.0f;
2270    }
22712271
2272   // if we're cropping, we want the screen area to fill (0,0)-(1,1)
2273   else
2274   {
2275      // compute the aspect ratio of the screen
2276      m_scraspect = (m_scrbounds.x1 - m_scrbounds.x0) / (m_scrbounds.y1 - m_scrbounds.y0);
2272    // if we're cropping, we want the screen area to fill (0,0)-(1,1)
2273    else
2274    {
2275        // compute the aspect ratio of the screen
2276        m_scraspect = (m_scrbounds.x1 - m_scrbounds.x0) / (m_scrbounds.y1 - m_scrbounds.y0);
22772277
2278      float targwidth = (m_bounds.x1 - m_bounds.x0) / (m_scrbounds.x1 - m_scrbounds.x0);
2279      float targheight = (m_bounds.y1 - m_bounds.y0) / (m_scrbounds.y1 - m_scrbounds.y0);
2280      target_bounds.x0 = (m_bounds.x0 - m_scrbounds.x0) / (m_bounds.x1 - m_bounds.x0) * targwidth;
2281      target_bounds.y0 = (m_bounds.y0 - m_scrbounds.y0) / (m_bounds.y1 - m_bounds.y0) * targheight;
2282      target_bounds.x1 = target_bounds.x0 + targwidth;
2283      target_bounds.y1 = target_bounds.y0 + targheight;
2284   }
2278        float targwidth = (m_bounds.x1 - m_bounds.x0) / (m_scrbounds.x1 - m_scrbounds.x0);
2279        float targheight = (m_bounds.y1 - m_bounds.y0) / (m_scrbounds.y1 - m_scrbounds.y0);
2280        target_bounds.x0 = (m_bounds.x0 - m_scrbounds.x0) / (m_bounds.x1 - m_bounds.x0) * targwidth;
2281        target_bounds.y0 = (m_bounds.y0 - m_scrbounds.y0) / (m_bounds.y1 - m_bounds.y0) * targheight;
2282        target_bounds.x1 = target_bounds.x0 + targwidth;
2283        target_bounds.y1 = target_bounds.y0 + targheight;
2284    }
22852285
2286   // determine the scale/offset for normalization
2287   float xoffs = m_bounds.x0;
2288   float yoffs = m_bounds.y0;
2289   float xscale = (target_bounds.x1 - target_bounds.x0) / (m_bounds.x1 - m_bounds.x0);
2290   float yscale = (target_bounds.y1 - target_bounds.y0) / (m_bounds.y1 - m_bounds.y0);
2286    // determine the scale/offset for normalization
2287    float xoffs = m_bounds.x0;
2288    float yoffs = m_bounds.y0;
2289    float xscale = (target_bounds.x1 - target_bounds.x0) / (m_bounds.x1 - m_bounds.x0);
2290    float yscale = (target_bounds.y1 - target_bounds.y0) / (m_bounds.y1 - m_bounds.y0);
22912291
2292   // normalize all the item bounds
2293   for (item_layer layer = ITEM_LAYER_FIRST; layer < ITEM_LAYER_MAX; layer++)
2294      for (item *curitem = first_item(layer); curitem != NULL; curitem = curitem->next())
2295      {
2296         curitem->m_bounds.x0 = target_bounds.x0 + (curitem->m_rawbounds.x0 - xoffs) * xscale;
2297         curitem->m_bounds.x1 = target_bounds.x0 + (curitem->m_rawbounds.x1 - xoffs) * xscale;
2298         curitem->m_bounds.y0 = target_bounds.y0 + (curitem->m_rawbounds.y0 - yoffs) * yscale;
2299         curitem->m_bounds.y1 = target_bounds.y0 + (curitem->m_rawbounds.y1 - yoffs) * yscale;
2300      }
2292    // normalize all the item bounds
2293    for (item_layer layer = ITEM_LAYER_FIRST; layer < ITEM_LAYER_MAX; layer++)
2294        for (item *curitem = first_item(layer); curitem != NULL; curitem = curitem->next())
2295        {
2296            curitem->m_bounds.x0 = target_bounds.x0 + (curitem->m_rawbounds.x0 - xoffs) * xscale;
2297            curitem->m_bounds.x1 = target_bounds.x0 + (curitem->m_rawbounds.x1 - xoffs) * xscale;
2298            curitem->m_bounds.y0 = target_bounds.y0 + (curitem->m_rawbounds.y0 - yoffs) * yscale;
2299            curitem->m_bounds.y1 = target_bounds.y0 + (curitem->m_rawbounds.y1 - yoffs) * yscale;
2300        }
23012301}
23022302
23032303
r242286r242287
23112311//-------------------------------------------------
23122312
23132313layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simple_list<layout_element> &elemlist)
2314   : m_next(NULL),
2315      m_element(NULL),
2316      m_input_mask(0),
2317      m_screen(NULL),
2318      m_orientation(ROT0)
2314    : m_next(NULL),
2315        m_element(NULL),
2316        m_input_mask(0),
2317        m_screen(NULL),
2318        m_orientation(ROT0)
23192319{
2320   // allocate a copy of the output name
2321   m_output_name = xml_get_attribute_string_with_subst(machine, itemnode, "name", "");
2320    // allocate a copy of the output name
2321    m_output_name = xml_get_attribute_string_with_subst(machine, itemnode, "name", "");
23222322
2323   // allocate a copy of the input tag
2324   m_input_tag = xml_get_attribute_string_with_subst(machine, itemnode, "inputtag", "");
2323    // allocate a copy of the input tag
2324    m_input_tag = xml_get_attribute_string_with_subst(machine, itemnode, "inputtag", "");
23252325
2326   // find the associated element
2327   const char *name = xml_get_attribute_string_with_subst(machine, itemnode, "element", NULL);
2328   if (name != NULL)
2329   {
2330      // search the list of elements for a match
2331      for (m_element = elemlist.first(); m_element != NULL; m_element = m_element->next())
2332         if (strcmp(name, m_element->name()) == 0)
2333            break;
2326    // find the associated element
2327    const char *name = xml_get_attribute_string_with_subst(machine, itemnode, "element", NULL);
2328    if (name != NULL)
2329    {
2330        // search the list of elements for a match
2331        for (m_element = elemlist.first(); m_element != NULL; m_element = m_element->next())
2332            if (strcmp(name, m_element->name()) == 0)
2333                break;
23342334
2335      // error if not found
2336      if (m_element == NULL)
2337         throw emu_fatalerror("Unable to find layout element %s", name);
2338   }
2335        // error if not found
2336        if (m_element == NULL)
2337            throw emu_fatalerror("Unable to find layout element %s", name);
2338    }
23392339
2340   // fetch common data
2341   int index = xml_get_attribute_int_with_subst(machine, itemnode, "index", -1);
2342   if (index != -1)
2343   {
2344      screen_device_iterator iter(machine.root_device());
2345      m_screen = iter.byindex(index);
2346   }
2347   m_input_mask = xml_get_attribute_int_with_subst(machine, itemnode, "inputmask", 0);
2348   if (m_output_name[0] != 0 && m_element != NULL)
2349      output_set_value(m_output_name, m_element->default_state());
2350   parse_bounds(machine, xml_get_sibling(itemnode.child, "bounds"), m_rawbounds);
2351   parse_color(machine, xml_get_sibling(itemnode.child, "color"), m_color);
2352   parse_orientation(machine, xml_get_sibling(itemnode.child, "orientation"), m_orientation);
2340    // fetch common data
2341    int index = xml_get_attribute_int_with_subst(machine, itemnode, "index", -1);
2342    if (index != -1)
2343    {
2344        screen_device_iterator iter(machine.root_device());
2345        m_screen = iter.byindex(index);
2346    }
2347    m_input_mask = xml_get_attribute_int_with_subst(machine, itemnode, "inputmask", 0);
2348    if (m_output_name[0] != 0 && m_element != NULL)
2349        output_set_value(m_output_name, m_element->default_state());
2350    parse_bounds(machine, xml_get_sibling(itemnode.child, "bounds"), m_rawbounds);
2351    parse_color(machine, xml_get_sibling(itemnode.child, "color"), m_color);
2352    parse_orientation(machine, xml_get_sibling(itemnode.child, "orientation"), m_orientation);
23532353
2354   // sanity checks
2355   if (strcmp(itemnode.name, "screen") == 0)
2356   {
2357      if (m_screen == NULL)
2358         throw emu_fatalerror("Layout references invalid screen index %d", index);
2359   }
2360   else
2361   {
2362      if (m_element == NULL)
2363         throw emu_fatalerror("Layout item of type %s require an element tag", itemnode.name);
2364   }
2354    // sanity checks
2355    if (strcmp(itemnode.name, "screen") == 0)
2356    {
2357        if (m_screen == NULL)
2358            throw emu_fatalerror("Layout references invalid screen index %d", index);
2359    }
2360    else
2361    {
2362        if (m_element == NULL)
2363            throw emu_fatalerror("Layout item of type %s require an element tag", itemnode.name);
2364    }
23652365}
23662366
23672367
r242286r242287
23812381
23822382render_container *layout_view::item::screen_container(running_machine &machine) const
23832383{
2384   return (m_screen != NULL) ? &m_screen->container() : NULL;
2384    return (m_screen != NULL) ? &m_screen->container() : NULL;
23852385}
23862386
23872387//-------------------------------------------------
r242286r242287
23902390
23912391int layout_view::item::state() const
23922392{
2393   int state = 0;
2393    int state = 0;
23942394
2395   assert(m_element != NULL);
2395    assert(m_element != NULL);
23962396
2397   // if configured to an output, fetch the output value
2398   if (m_output_name[0] != 0)
2399      state = output_get_value(m_output_name);
2397    // if configured to an output, fetch the output value
2398    if (m_output_name[0] != 0)
2399        state = output_get_value(m_output_name);
24002400
2401   // if configured to an input, fetch the input value
2402   else if (m_input_tag[0] != 0)
2403   {
2404      ioport_port *port = m_element->machine().root_device().ioport(m_input_tag);
2405      if (port != NULL)
2406      {
2407         ioport_field *field = port->field(m_input_mask);
2408         if (field != NULL)
2409            state = ((port->read() ^ field->defvalue()) & m_input_mask) ? 1 : 0;
2410      }
2411   }
2412   return state;
2401    // if configured to an input, fetch the input value
2402    else if (m_input_tag[0] != 0)
2403    {
2404        ioport_port *port = m_element->machine().root_device().ioport(m_input_tag);
2405        if (port != NULL)
2406        {
2407            ioport_field *field = port->field(m_input_mask);
2408            if (field != NULL)
2409                state = ((port->read() ^ field->defvalue()) & m_input_mask) ? 1 : 0;
2410        }
2411    }
2412    return state;
24132413}
24142414
24152415
r242286r242287
24232423//-------------------------------------------------
24242424
24252425layout_file::layout_file(running_machine &machine, xml_data_node &rootnode, const char *dirname)
2426   : m_next(NULL)
2426    : m_next(NULL)
24272427{
2428   // find the layout node
2429   xml_data_node *mamelayoutnode = xml_get_sibling(rootnode.child, "mamelayout");
2430   if (mamelayoutnode == NULL)
2431      throw emu_fatalerror("Invalid XML file: missing mamelayout node");
2428    // find the layout node
2429    xml_data_node *mamelayoutnode = xml_get_sibling(rootnode.child, "mamelayout");
2430    if (mamelayoutnode == NULL)
2431        throw emu_fatalerror("Invalid XML file: missing mamelayout node");
24322432
2433   // validate the config data version
2434   int version = xml_get_attribute_int(mamelayoutnode, "version", 0);
2435   if (version != LAYOUT_VERSION)
2436      throw emu_fatalerror("Invalid XML file: unsupported version");
2433    // validate the config data version
2434    int version = xml_get_attribute_int(mamelayoutnode, "version", 0);
2435    if (version != LAYOUT_VERSION)
2436        throw emu_fatalerror("Invalid XML file: unsupported version");
24372437
2438   // parse all the elements
2439   for (xml_data_node *elemnode = xml_get_sibling(mamelayoutnode->child, "element"); elemnode != NULL; elemnode = xml_get_sibling(elemnode->next, "element"))
2440      m_elemlist.append(*global_alloc(layout_element(machine, *elemnode, dirname)));
2438    // parse all the elements
2439    for (xml_data_node *elemnode = xml_get_sibling(mamelayoutnode->child, "element"); elemnode != NULL; elemnode = xml_get_sibling(elemnode->next, "element"))
2440        m_elemlist.append(*global_alloc(layout_element(machine, *elemnode, dirname)));
24412441
2442   // parse all the views
2443   for (xml_data_node *viewnode = xml_get_sibling(mamelayoutnode->child, "view"); viewnode != NULL; viewnode = xml_get_sibling(viewnode->next, "view"))
2444      m_viewlist.append(*global_alloc(layout_view(machine, *viewnode, m_elemlist)));
2442    // parse all the views
2443    for (xml_data_node *viewnode = xml_get_sibling(mamelayoutnode->child, "view"); viewnode != NULL; viewnode = xml_get_sibling(viewnode->next, "view"))
2444        m_viewlist.append(*global_alloc(layout_view(machine, *viewnode, m_elemlist)));
24452445}
24462446
24472447
trunk/src/emu/rendlay.h
r242286r242287
2020
2121enum item_layer
2222{
23   ITEM_LAYER_FIRST = 0,
24   ITEM_LAYER_BACKDROP = ITEM_LAYER_FIRST,
25   ITEM_LAYER_SCREEN,
26   ITEM_LAYER_OVERLAY,
27   ITEM_LAYER_BEZEL,
28   ITEM_LAYER_CPANEL,
29   ITEM_LAYER_MARQUEE,
30   ITEM_LAYER_MAX
23    ITEM_LAYER_FIRST = 0,
24    ITEM_LAYER_BACKDROP = ITEM_LAYER_FIRST,
25    ITEM_LAYER_SCREEN,
26    ITEM_LAYER_OVERLAY,
27    ITEM_LAYER_BEZEL,
28    ITEM_LAYER_CPANEL,
29    ITEM_LAYER_MARQUEE,
30    ITEM_LAYER_MAX
3131};
3232DECLARE_ENUM_OPERATORS(item_layer);
3333
r242286r242287
4343// a layout_element is a single named element, which may have multiple components
4444class layout_element
4545{
46   friend class simple_list<layout_element>;
46    friend class simple_list<layout_element>;
4747
4848public:
49   // construction/destruction
50   layout_element(running_machine &machine, xml_data_node &elemnode, const char *dirname);
51   virtual ~layout_element();
49    // construction/destruction
50    layout_element(running_machine &machine, xml_data_node &elemnode, const char *dirname);
51    virtual ~layout_element();
5252
53   // getters
54   layout_element *next() const { return m_next; }
55   const char *name() const { return m_name; }
56   running_machine &machine() const { return m_machine; }
57   int default_state() const { return m_defstate; }
58   int maxstate() const { return m_maxstate; }
59   render_texture *state_texture(int state);
53    // getters
54    layout_element *next() const { return m_next; }
55    const char *name() const { return m_name; }
56    running_machine &machine() const { return m_machine; }
57    int default_state() const { return m_defstate; }
58    int maxstate() const { return m_maxstate; }
59    render_texture *state_texture(int state);
6060
6161private:
62   // a component represents an image, rectangle, or disk in an element
63   class component
64   {
65      friend class layout_element;
66      friend class simple_list<component>;
62    // a component represents an image, rectangle, or disk in an element
63    class component
64    {
65        friend class layout_element;
66        friend class simple_list<component>;
6767
68   public:
69      // construction/destruction
70      component(running_machine &machine, xml_data_node &compnode, const char *dirname);
71      ~component();
68    public:
69        // construction/destruction
70        component(running_machine &machine, xml_data_node &compnode, const char *dirname);
71        ~component();
7272
73      // getters
74      component *next() const { return m_next; }
75      const render_bounds &bounds() const { return m_bounds; }
73        // getters
74        component *next() const { return m_next; }
75        const render_bounds &bounds() const { return m_bounds; }
7676
77      // operations
78      void draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
77        // operations
78        void draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
7979
80   private:
81      // component types
82      enum component_type
83      {
84         CTYPE_INVALID = 0,
85         CTYPE_IMAGE,
86         CTYPE_RECT,
87         CTYPE_DISK,
88         CTYPE_TEXT,
89         CTYPE_LED7SEG,
90         CTYPE_LED8SEG,
91         CTYPE_LED14SEG,
92         CTYPE_LED16SEG,
93         CTYPE_LED14SEGSC,
94         CTYPE_LED16SEGSC,
95         CTYPE_DOTMATRIX,
96         CTYPE_DOTMATRIX5DOT,
97         CTYPE_DOTMATRIXDOT,
98         CTYPE_SIMPLECOUNTER,
99         CTYPE_REEL,
100         CTYPE_MAX
101      };
80    private:
81        // component types
82        enum component_type
83        {
84            CTYPE_INVALID = 0,
85            CTYPE_IMAGE,
86            CTYPE_RECT,
87            CTYPE_DISK,
88            CTYPE_TEXT,
89            CTYPE_LED7SEG,
90            CTYPE_LED8SEG_GTS1,
91            CTYPE_LED14SEG,
92            CTYPE_LED16SEG,
93            CTYPE_LED14SEGSC,
94            CTYPE_LED16SEGSC,
95            CTYPE_DOTMATRIX,
96            CTYPE_DOTMATRIX5DOT,
97            CTYPE_DOTMATRIXDOT,
98            CTYPE_SIMPLECOUNTER,
99            CTYPE_REEL,
100            CTYPE_MAX
101        };
102102
103      // helpers
104      void draw_rect(bitmap_argb32 &dest, const rectangle &bounds);
105      void draw_disk(bitmap_argb32 &dest, const rectangle &bounds);
106      void draw_text(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds);
107      void draw_simplecounter(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
108      void draw_reel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
109      void draw_beltreel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
110      void load_bitmap();
111      void load_reel_bitmap(int number);
112      void draw_led7seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
113      void draw_led8seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
114      void draw_led14seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
115      void draw_led14segsc(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
116      void draw_led16seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
117      void draw_led16segsc(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
118      void draw_dotmatrix(int dots,bitmap_argb32 &dest, const rectangle &bounds, int pattern);
119      void draw_segment_horizontal_caps(bitmap_argb32 &dest, int minx, int maxx, int midy, int width, int caps, rgb_t color);
120      void draw_segment_horizontal(bitmap_argb32 &dest, int minx, int maxx, int midy, int width, rgb_t color);
121      void draw_segment_vertical_caps(bitmap_argb32 &dest, int miny, int maxy, int midx, int width, int caps, rgb_t color);
122      void draw_segment_vertical(bitmap_argb32 &dest, int miny, int maxy, int midx, int width, rgb_t color);
123      void draw_segment_diagonal_1(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color);
124      void draw_segment_diagonal_2(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color);
125      void draw_segment_decimal(bitmap_argb32 &dest, int midx, int midy, int width, rgb_t color);
126      void draw_segment_comma(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color);
127      void apply_skew(bitmap_argb32 &dest, int skewwidth);
103        // helpers
104        void draw_rect(bitmap_argb32 &dest, const rectangle &bounds);
105        void draw_disk(bitmap_argb32 &dest, const rectangle &bounds);
106        void draw_text(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds);
107        void draw_simplecounter(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
108        void draw_reel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
109        void draw_beltreel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
110        void load_bitmap();
111        void load_reel_bitmap(int number);
112        void draw_led7seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
113        void draw_led8seg_gts1(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
114        void draw_led14seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
115        void draw_led14segsc(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
116        void draw_led16seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
117        void draw_led16segsc(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
118        void draw_dotmatrix(int dots,bitmap_argb32 &dest, const rectangle &bounds, int pattern);
119        void draw_segment_horizontal_caps(bitmap_argb32 &dest, int minx, int maxx, int midy, int width, int caps, rgb_t color);
120        void draw_segment_horizontal(bitmap_argb32 &dest, int minx, int maxx, int midy, int width, rgb_t color);
121        void draw_segment_vertical_caps(bitmap_argb32 &dest, int miny, int maxy, int midx, int width, int caps, rgb_t color);
122        void draw_segment_vertical(bitmap_argb32 &dest, int miny, int maxy, int midx, int width, rgb_t color);
123        void draw_segment_diagonal_1(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color);
124        void draw_segment_diagonal_2(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color);
125        void draw_segment_decimal(bitmap_argb32 &dest, int midx, int midy, int width, rgb_t color);
126        void draw_segment_comma(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color);
127        void apply_skew(bitmap_argb32 &dest, int skewwidth);
128128
129      #define MAX_BITMAPS 32
129        #define MAX_BITMAPS 32
130130
131      // internal state
132      component *         m_next;                     // link to next component
133      component_type      m_type;                     // type of component
134      int                 m_state;                    // state where this component is visible (-1 means all states)
135      render_bounds       m_bounds;                   // bounds of the element
136      render_color        m_color;                    // color of the element
137      astring             m_string;                   // string for text components
138      int                 m_digits;                   // number of digits for simple counters
139      int                 m_textalign;                // text alignment to box
140      bitmap_argb32       m_bitmap[MAX_BITMAPS];      // source bitmap for images
141      astring             m_dirname;                  // directory name of image file (for lazy loading)
142      auto_pointer<emu_file> m_file[MAX_BITMAPS];        // file object for reading image/alpha files
143      astring             m_imagefile[MAX_BITMAPS];   // name of the image file (for lazy loading)
144      astring             m_alphafile[MAX_BITMAPS];   // name of the alpha file (for lazy loading)
145      bool                m_hasalpha[MAX_BITMAPS];    // is there any alpha component present?
131        // internal state
132        component *         m_next;                     // link to next component
133        component_type      m_type;                     // type of component
134        int                 m_state;                    // state where this component is visible (-1 means all states)
135        render_bounds       m_bounds;                   // bounds of the element
136        render_color        m_color;                    // color of the element
137        astring             m_string;                   // string for text components
138        int                 m_digits;                   // number of digits for simple counters
139        int                 m_textalign;                // text alignment to box
140        bitmap_argb32       m_bitmap[MAX_BITMAPS];      // source bitmap for images
141        astring             m_dirname;                  // directory name of image file (for lazy loading)
142        auto_pointer<emu_file> m_file[MAX_BITMAPS];        // file object for reading image/alpha files
143        astring             m_imagefile[MAX_BITMAPS];   // name of the image file (for lazy loading)
144        astring             m_alphafile[MAX_BITMAPS];   // name of the alpha file (for lazy loading)
145        bool                m_hasalpha[MAX_BITMAPS];    // is there any alpha component present?
146146
147      // stuff for fruit machine reels
148      // basically made up of multiple text strings / gfx
149      int                 m_numstops;
150      astring             m_stopnames[MAX_BITMAPS];
151      int                 m_stateoffset;
152      int                 m_reelreversed;
153      int                 m_numsymbolsvisible;
154      int                 m_beltreel;
155   };
147        // stuff for fruit machine reels
148        // basically made up of multiple text strings / gfx
149        int                 m_numstops;
150        astring             m_stopnames[MAX_BITMAPS];
151        int                 m_stateoffset;
152        int                 m_reelreversed;
153        int                 m_numsymbolsvisible;
154        int                 m_beltreel;
155    };
156156
157   // a texture encapsulates a texture for a given element in a given state
158   class texture
159   {
160   public:
161      texture();
162      ~texture();
157    // a texture encapsulates a texture for a given element in a given state
158    class texture
159    {
160    public:
161        texture();
162        ~texture();
163163
164      layout_element *    m_element;      // pointer back to the element
165      render_texture *    m_texture;      // texture for this state
166      int                 m_state;        // associated state number
167   };
164        layout_element *    m_element;      // pointer back to the element
165        render_texture *    m_texture;      // texture for this state
166        int                 m_state;        // associated state number
167    };
168168
169   // internal helpers
170   static void element_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param);
169    // internal helpers
170    static void element_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param);
171171
172   // internal state
173   layout_element *    m_next;             // link to next element
174   running_machine &   m_machine;          // reference to the owning machine
175   astring             m_name;             // name of this element
176   simple_list<component> m_complist;      // list of components
177   int                 m_defstate;         // default state of this element
178   int                 m_maxstate;         // maximum state value for all components
179   dynamic_array<texture> m_elemtex;       // array of element textures used for managing the scaled bitmaps
172    // internal state
173    layout_element *    m_next;             // link to next element
174    running_machine &   m_machine;          // reference to the owning machine
175    astring             m_name;             // name of this element
176    simple_list<component> m_complist;      // list of components
177    int                 m_defstate;         // default state of this element
178    int                 m_maxstate;         // maximum state value for all components
179    dynamic_array<texture> m_elemtex;       // array of element textures used for managing the scaled bitmaps
180180};
181181
182182
r242286r242287
185185// a layout_view encapsulates a named list of items
186186class layout_view
187187{
188   friend class simple_list<layout_view>;
188    friend class simple_list<layout_view>;
189189
190190public:
191   // an item is a single backdrop, screen, overlay, bezel, cpanel, or marquee item
192   class item
193   {
194      friend class layout_view;
195      friend class simple_list<item>;
191    // an item is a single backdrop, screen, overlay, bezel, cpanel, or marquee item
192    class item
193    {
194        friend class layout_view;
195        friend class simple_list<item>;
196196
197   public:
198      // construction/destruction
199      item(running_machine &machine, xml_data_node &itemnode, simple_list<layout_element> &elemlist);
200      virtual ~item();
197    public:
198        // construction/destruction
199        item(running_machine &machine, xml_data_node &itemnode, simple_list<layout_element> &elemlist);
200        virtual ~item();
201201
202      // getters
203      item *next() const { return m_next; }
204      layout_element *element() const { return m_element; }
205      screen_device *screen() { return m_screen; }
206      const render_bounds &bounds() const { return m_bounds; }
207      const render_color &color() const { return m_color; }
208      int orientation() const { return m_orientation; }
209      render_container *screen_container(running_machine &machine) const;
210      bool has_input() const { return bool(m_input_tag); }
211      const char *input_tag_and_mask(ioport_value &mask) const { mask = m_input_mask; return m_input_tag; }
202        // getters
203        item *next() const { return m_next; }
204        layout_element *element() const { return m_element; }
205        screen_device *screen() { return m_screen; }
206        const render_bounds &bounds() const { return m_bounds; }
207        const render_color &color() const { return m_color; }
208        int orientation() const { return m_orientation; }
209        render_container *screen_container(running_machine &machine) const;
210        bool has_input() const { return bool(m_input_tag); }
211        const char *input_tag_and_mask(ioport_value &mask) const { mask = m_input_mask; return m_input_tag; }
212212
213      // fetch state based on configured source
214      int state() const;
213        // fetch state based on configured source
214        int state() const;
215215
216   private:
217      // internal state
218      item *              m_next;             // link to next item
219      layout_element *    m_element;          // pointer to the associated element (non-screens only)
220      astring             m_output_name;      // name of this item
221      astring             m_input_tag;        // input tag of this item
222      ioport_value        m_input_mask;       // input mask of this item
223      screen_device *     m_screen;           // pointer to screen
224      int                 m_orientation;      // orientation of this item
225      render_bounds       m_bounds;           // bounds of the item
226      render_bounds       m_rawbounds;        // raw (original) bounds of the item
227      render_color        m_color;            // color of the item
228   };
216    private:
217        // internal state
218        item *              m_next;             // link to next item
219        layout_element *    m_element;          // pointer to the associated element (non-screens only)
220        astring             m_output_name;      // name of this item
221        astring             m_input_tag;        // input tag of this item
222        ioport_value        m_input_mask;       // input mask of this item
223        screen_device *     m_screen;           // pointer to screen
224        int                 m_orientation;      // orientation of this item
225        render_bounds       m_bounds;           // bounds of the item
226        render_bounds       m_rawbounds;        // raw (original) bounds of the item
227        render_color        m_color;            // color of the item
228    };
229229
230   // construction/destruction
231   layout_view(running_machine &machine, xml_data_node &viewnode, simple_list<layout_element> &elemlist);
232   virtual ~layout_view();
230    // construction/destruction
231    layout_view(running_machine &machine, xml_data_node &viewnode, simple_list<layout_element> &elemlist);
232    virtual ~layout_view();
233233
234   // getters
235   layout_view *next() const { return m_next; }
236   item *first_item(item_layer layer) const;
237   const char *name() const { return m_name; }
238   const render_screen_list &screens() const { return m_screens; }
239   bool layer_enabled(item_layer layer) const { return m_layenabled[layer]; }
234    // getters
235    layout_view *next() const { return m_next; }
236    item *first_item(item_layer layer) const;
237    const char *name() const { return m_name; }
238    const render_screen_list &screens() const { return m_screens; }
239    bool layer_enabled(item_layer layer) const { return m_layenabled[layer]; }
240240
241   //
242   bool has_art() const { return (m_backdrop_list.count() + m_overlay_list.count() + m_bezel_list.count() + m_cpanel_list.count() + m_marquee_list.count() != 0); }
243   float effective_aspect(render_layer_config config) const { return (config.zoom_to_screen() && m_screens.count() != 0) ? m_scraspect : m_aspect; }
241    //
242    bool has_art() const { return (m_backdrop_list.count() + m_overlay_list.count() + m_bezel_list.count() + m_cpanel_list.count() + m_marquee_list.count() != 0); }
243    float effective_aspect(render_layer_config config) const { return (config.zoom_to_screen() && m_screens.count() != 0) ? m_scraspect : m_aspect; }
244244
245   // operations
246   void recompute(render_layer_config layerconfig);
245    // operations
246    void recompute(render_layer_config layerconfig);
247247
248248private:
249   // internal state
250   layout_view *       m_next;             // pointer to next layout in the list
251   astring             m_name;             // name of the layout
252   float               m_aspect;           // X/Y of the layout
253   float               m_scraspect;        // X/Y of the screen areas
254   render_screen_list  m_screens;          // list of active screens
255   render_bounds       m_bounds;           // computed bounds of the view
256   render_bounds       m_scrbounds;        // computed bounds of the screens within the view
257   render_bounds       m_expbounds;        // explicit bounds of the view
258   bool                m_layenabled[ITEM_LAYER_MAX]; // is this layer enabled?
259   simple_list<item>   m_backdrop_list;    // list of backdrop items
260   simple_list<item>   m_screen_list;      // list of screen items
261   simple_list<item>   m_overlay_list;     // list of overlay items
262   simple_list<item>   m_bezel_list;       // list of bezel items
263   simple_list<item>   m_cpanel_list;      // list of marquee items
264   simple_list<item>   m_marquee_list;     // list of marquee items
249    // internal state
250    layout_view *       m_next;             // pointer to next layout in the list
251    astring             m_name;             // name of the layout
252    float               m_aspect;           // X/Y of the layout
253    float               m_scraspect;        // X/Y of the screen areas
254    render_screen_list  m_screens;          // list of active screens
255    render_bounds       m_bounds;           // computed bounds of the view
256    render_bounds       m_scrbounds;        // computed bounds of the screens within the view
257    render_bounds       m_expbounds;        // explicit bounds of the view
258    bool                m_layenabled[ITEM_LAYER_MAX]; // is this layer enabled?
259    simple_list<item>   m_backdrop_list;    // list of backdrop items
260    simple_list<item>   m_screen_list;      // list of screen items
261    simple_list<item>   m_overlay_list;     // list of overlay items
262    simple_list<item>   m_bezel_list;       // list of bezel items
263    simple_list<item>   m_cpanel_list;      // list of marquee items
264    simple_list<item>   m_marquee_list;     // list of marquee items
265265};
266266
267267
r242286r242287
270270// a layout_file consists of a list of elements and a list of views
271271class layout_file
272272{
273   friend class simple_list<layout_file>;
273    friend class simple_list<layout_file>;
274274
275275public:
276   // construction/destruction
277   layout_file(running_machine &machine, xml_data_node &rootnode, const char *dirname);
278   virtual ~layout_file();
276    // construction/destruction
277    layout_file(running_machine &machine, xml_data_node &rootnode, const char *dirname);
278    virtual ~layout_file();
279279
280   // getters
281   layout_file *next() const { return m_next; }
282   layout_element *first_element() const { return m_elemlist.first(); }
283   layout_view *first_view() const { return m_viewlist.first(); }
280    // getters
281    layout_file *next() const { return m_next; }
282    layout_element *first_element() const { return m_elemlist.first(); }
283    layout_view *first_view() const { return m_viewlist.first(); }
284284
285285private:
286   // internal state
287   layout_file *       m_next;             // pointer to the next file in the list
288   simple_list<layout_element> m_elemlist; // list of shared layout elements
289   simple_list<layout_view> m_viewlist;    // list of views
286    // internal state
287    layout_file *       m_next;             // pointer to the next file in the list
288    simple_list<layout_element> m_elemlist; // list of shared layout elements
289    simple_list<layout_view> m_viewlist;    // list of views
290290};
291291
292292
trunk/src/mame/layout/gts1.lay
r242286r242287
55<mamelayout version="2">
66
77   <element name="digit8_" defstate="0">
8      <led8seg>
8      <led8seg_gts1>
99         <color red="0.0" green="0.75" blue="1.0" />
10      </led8seg>
10      </led8seg_gts1>
1111   </element>
1212   <element name="digit7_" defstate="0">
1313      <led7seg>


Previous 199869 Revisions Next


© 1997-2024 The MAME Team