Previous 199869 Revisions Next

r29198 Wednesday 2nd April, 2014 at 20:02:31 UTC by James Wallace
Added support for horizontal 'belt' reels which may be needed for future AWP titles. To invoke, add an attribute "beltreel" to the reel element in the layout, and set it to 1. [J. Wallace]
[src/emu]rendlay.c rendlay.h

trunk/src/emu/rendlay.c
r29197r29198
666666      m_stateoffset = xml_get_attribute_int_with_subst(machine, compnode, "stateoffset", 0);
667667      m_numsymbolsvisible = xml_get_attribute_int_with_subst(machine, compnode, "numsymbolsvisible", 3);
668668      m_reelreversed = xml_get_attribute_int_with_subst(machine, compnode, "reelreversed", 0);
669      m_beltreel = xml_get_attribute_int_with_subst(machine, compnode, "beltreel", 0);
670     
669671   }
670672
671673   // led7seg nodes
r29197r29198
981983/* 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 */
982984void layout_element::component::draw_reel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state)
983985{
986   if (m_beltreel)
987   {
988      draw_beltreel(machine,dest,bounds,state);
989   }
990   else
991   {
992      const int max_state_used = 0x10000;
993
994      // shift the reels a bit based on this param, allows fine tuning
995      int use_state = (state + m_stateoffset) % max_state_used;
996
997      // compute premultiplied colors
998      UINT32 r = m_color.r * 255.0;
999      UINT32 g = m_color.g * 255.0;
1000      UINT32 b = m_color.b * 255.0;
1001      UINT32 a = m_color.a * 255.0;
1002
1003      // get the width of the string
1004      render_font *font = machine.render().font_alloc("default");
1005      float aspect = 1.0f;
1006      INT32 width;
1007     
1008
1009      int curry = 0;
1010      int num_shown = m_numsymbolsvisible;
1011
1012      int ourheight = bounds.height();
1013
1014      for (int fruit = 0;fruit<m_numstops;fruit++)
1015      {
1016         int basey;
1017
1018         if (m_reelreversed==1)
1019         {
1020            basey = bounds.min_y + ((use_state)*(ourheight/num_shown)/(max_state_used/m_numstops)) + curry;
1021         }
1022         else
1023         {
1024            basey = bounds.min_y - ((use_state)*(ourheight/num_shown)/(max_state_used/m_numstops)) + curry;
1025         }
1026
1027         // wrap around...
1028         if (basey < bounds.min_y)
1029            basey += ((max_state_used)*(ourheight/num_shown)/(max_state_used/m_numstops));
1030         if (basey > bounds.max_y)
1031            basey -= ((max_state_used)*(ourheight/num_shown)/(max_state_used/m_numstops));
1032
1033         int endpos = basey+ourheight/num_shown;
1034
1035         // only render the symbol / text if it's atually in view because the code is SLOW
1036         if ((endpos >= bounds.min_y) && (basey <= bounds.max_y))
1037         {
1038            while (1)
1039            {
1040               width = font->string_width(ourheight/num_shown, aspect, m_stopnames[fruit]);
1041               if (width < bounds.width())
1042                  break;
1043               aspect *= 0.9f;
1044            }
1045
1046            INT32 curx;
1047            curx = bounds.min_x + (bounds.width() - width) / 2;
1048
1049            if (m_file[fruit])
1050               if (!m_bitmap[fruit].valid())
1051                  load_reel_bitmap(fruit);
1052
1053            if (m_file[fruit]) // render gfx
1054            {
1055               bitmap_argb32 tempbitmap2(dest.width(), ourheight/num_shown);
1056
1057               if (m_bitmap[fruit].valid())
1058               {
1059                  render_resample_argb_bitmap_hq(tempbitmap2, m_bitmap[fruit], m_color);
1060
1061                  for (int y = 0; y < ourheight/num_shown; y++)
1062                  {
1063                     int effy = basey + y;
1064
1065                     if (effy >= bounds.min_y && effy <= bounds.max_y)
1066                     {
1067                        UINT32 *src = &tempbitmap2.pix32(y);
1068                        UINT32 *d = &dest.pix32(effy);
1069                        for (int x = 0; x < dest.width(); x++)
1070                        {
1071                           int effx = x;
1072                           if (effx >= bounds.min_x && effx <= bounds.max_x)
1073                           {
1074                              UINT32 spix = rgb_t(src[x]).a();
1075                              if (spix != 0)
1076                              {
1077                                 d[effx] = src[x];
1078                              }
1079                           }
1080                        }
1081                     }
1082
1083                  }
1084               }
1085            }
1086            else // render text (fallback)
1087            {
1088               // allocate a temporary bitmap
1089               bitmap_argb32 tempbitmap(dest.width(), dest.height());
1090
1091               // loop over characters
1092               for (const char *s = m_stopnames[fruit]; *s != 0; s++)
1093               {
1094                  // get the font bitmap
1095                  rectangle chbounds;
1096                  font->get_scaled_bitmap_and_bounds(tempbitmap, ourheight/num_shown, aspect, *s, chbounds);
1097
1098                  // copy the data into the target
1099                  for (int y = 0; y < chbounds.height(); y++)
1100                  {
1101                     int effy = basey + y;
1102
1103                     if (effy >= bounds.min_y && effy <= bounds.max_y)
1104                     {
1105                        UINT32 *src = &tempbitmap.pix32(y);
1106                        UINT32 *d = &dest.pix32(effy);
1107                        for (int x = 0; x < chbounds.width(); x++)
1108                        {
1109                           int effx = curx + x + chbounds.min_x;
1110                           if (effx >= bounds.min_x && effx <= bounds.max_x)
1111                           {
1112                              UINT32 spix = rgb_t(src[x]).a();
1113                              if (spix != 0)
1114                              {
1115                                 rgb_t dpix = d[effx];
1116                                 UINT32 ta = (a * (spix + 1)) >> 8;
1117                                 UINT32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8;
1118                                 UINT32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8;
1119                                 UINT32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8;
1120                                 d[effx] = rgb_t(tr, tg, tb);
1121                              }
1122                           }
1123                        }
1124                     }
1125                  }
1126
1127                  // advance in the X direction
1128                  curx += font->char_width(ourheight/num_shown, aspect, *s);
1129
1130               }
1131
1132            }
1133         }
1134
1135         curry += ourheight/num_shown;
1136      }
1137   // free the temporary bitmap and font
1138   machine.render().font_free(font);
1139   }
1140}
1141
1142
1143void layout_element::component::draw_beltreel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state)
1144{
9841145   const int max_state_used = 0x10000;
9851146
9861147   // shift the reels a bit based on this param, allows fine tuning
r29197r29198
9961157   render_font *font = machine.render().font_alloc("default");
9971158   float aspect = 1.0f;
9981159   INT32 width;
999   int curry = 0;
1160   int currx = 0;
10001161   int num_shown = m_numsymbolsvisible;
10011162
1002   int ourheight = bounds.height();
1163   int ourwidth = bounds.width();
10031164
10041165   for (int fruit = 0;fruit<m_numstops;fruit++)
10051166   {
1006      int basey;
1007
1167      int basex;
10081168      if (m_reelreversed==1)
10091169      {
1010         basey = bounds.min_y + ((use_state)*(ourheight/num_shown)/(max_state_used/m_numstops)) + curry;
1170         basex = bounds.min_x + ((use_state)*(ourwidth/num_shown)/(max_state_used/m_numstops)) + currx;
10111171      }
10121172      else
10131173      {
1014         basey = bounds.min_y - ((use_state)*(ourheight/num_shown)/(max_state_used/m_numstops)) + curry;
1174         basex = bounds.min_x - ((use_state)*(ourwidth/num_shown)/(max_state_used/m_numstops)) + currx;
10151175      }
10161176
10171177      // wrap around...
1018      if (basey < bounds.min_y)
1019         basey += ((max_state_used)*(ourheight/num_shown)/(max_state_used/m_numstops));
1020      if (basey > bounds.max_y)
1021         basey -= ((max_state_used)*(ourheight/num_shown)/(max_state_used/m_numstops));
1178      if (basex < bounds.min_x)
1179         basex += ((max_state_used)*(ourwidth/num_shown)/(max_state_used/m_numstops));
1180      if (basex > bounds.max_x)
1181         basex -= ((max_state_used)*(ourwidth/num_shown)/(max_state_used/m_numstops));
10221182
1023      int endpos = basey+ourheight/num_shown;
1183      int endpos = basex+(ourwidth/num_shown);
10241184
10251185      // only render the symbol / text if it's atually in view because the code is SLOW
1026      if ((endpos >= bounds.min_y) && (basey <= bounds.max_y))
1186      if ((endpos >= bounds.min_x) && (basex <= bounds.max_x))
10271187      {
10281188         while (1)
10291189         {
1030            width = font->string_width(ourheight/num_shown, aspect, m_stopnames[fruit]);
1190            width = font->string_width(dest.height(), aspect, m_stopnames[fruit]);
10311191            if (width < bounds.width())
10321192               break;
10331193            aspect *= 0.9f;
10341194         }
10351195
10361196         INT32 curx;
1037         curx = bounds.min_x + (bounds.width() - width) / 2;
1197         curx = bounds.min_x;
10381198
10391199         if (m_file[fruit])
10401200            if (!m_bitmap[fruit].valid())
r29197r29198
10421202
10431203         if (m_file[fruit]) // render gfx
10441204         {
1045            bitmap_argb32 tempbitmap2(dest.width(), ourheight/num_shown);
1205            bitmap_argb32 tempbitmap2(ourwidth/num_shown, dest.height());
10461206
10471207            if (m_bitmap[fruit].valid())
10481208            {
10491209               render_resample_argb_bitmap_hq(tempbitmap2, m_bitmap[fruit], m_color);
10501210
1051               for (int y = 0; y < ourheight/num_shown; y++)
1211               for (int y = 0; y < dest.height(); y++)
10521212               {
1053                  int effy = basey + y;
1213                  int effy = y;
10541214
10551215                  if (effy >= bounds.min_y && effy <= bounds.max_y)
10561216                  {
10571217                     UINT32 *src = &tempbitmap2.pix32(y);
10581218                     UINT32 *d = &dest.pix32(effy);
1059                     for (int x = 0; x < dest.width(); x++)
1219                     for (int x = 0; x < ourwidth/num_shown; x++)
10601220                     {
1061                        int effx = x;
1221                        int effx = basex + x;
10621222                        if (effx >= bounds.min_x && effx <= bounds.max_x)
10631223                        {
10641224                           UINT32 spix = rgb_t(src[x]).a();
r29197r29198
10831243            {
10841244               // get the font bitmap
10851245               rectangle chbounds;
1086               font->get_scaled_bitmap_and_bounds(tempbitmap, ourheight/num_shown, aspect, *s, chbounds);
1246               font->get_scaled_bitmap_and_bounds(tempbitmap, dest.height(), aspect, *s, chbounds);
10871247
10881248               // copy the data into the target
10891249               for (int y = 0; y < chbounds.height(); y++)
10901250               {
1091                  int effy = basey + y;
1251                  int effy = y;
10921252
10931253                  if (effy >= bounds.min_y && effy <= bounds.max_y)
10941254                  {
r29197r29198
10961256                     UINT32 *d = &dest.pix32(effy);
10971257                     for (int x = 0; x < chbounds.width(); x++)
10981258                     {
1099                        int effx = curx + x + chbounds.min_x;
1259                        int effx = basex + curx + x;
11001260                        if (effx >= bounds.min_x && effx <= bounds.max_x)
11011261                        {
1102                           UINT32 spix = rgb_t(src[x]).a();
1262                           UINT32 spix = rgb_t(src[x]).a();
11031263                           if (spix != 0)
11041264                           {
11051265                              rgb_t dpix = d[effx];
r29197r29198
11151275               }
11161276
11171277               // advance in the X direction
1118               curx += font->char_width(ourheight/num_shown, aspect, *s);
1278               curx += font->char_width(dest.height(), aspect, *s);
11191279
11201280            }
11211281
11221282         }
11231283      }
11241284
1125      curry += ourheight/num_shown;
1285      currx += ourwidth/num_shown;
11261286   }
11271287
11281288   // free the temporary bitmap and font
r29197r29198
11301290}
11311291
11321292
1133
1134
11351293//-------------------------------------------------
11361294//  load_bitmap - load a PNG file with artwork for
11371295//  a component
trunk/src/emu/rendlay.h
r29197r29198
105105      void draw_text(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds);
106106      void draw_simplecounter(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
107107      void draw_reel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
108      void draw_beltreel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
108109      void load_bitmap();
109110      void load_reel_bitmap(int number);
110111      void draw_led7seg(bitmap_argb32 &dest, const rectangle &bounds, int pattern);
r29197r29198
148149      int                 m_stateoffset;
149150      int                 m_reelreversed;
150151      int                 m_numsymbolsvisible;
151
152      int               m_beltreel;
152153   };
153154
154155   // a texture encapsulates a texture for a given element in a given state

Previous 199869 Revisions Next


© 1997-2024 The MAME Team