Previous 199869 Revisions Next

r20773 Wednesday 6th February, 2013 at 17:35:34 UTC by Angelo Salese
Part 1 of Last Bronx gfx fixing: fixed shadows in double X condition
[src/mame/video]stvvdp2.c

trunk/src/mame/video/stvvdp2.c
r20772r20773
24902490   *rgb = MAKE_RGB(_r, _g, _b);
24912491}
24922492
2493static void stv_vdp2_drawgfxzoom_rgb555(
2494      bitmap_rgb32 &dest_bmp,const rectangle &clip,running_machine &machine,
2493static void stv_vdp2_drawgfxzoom(
2494      bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
24952495      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
24962496      int transparency,int transparent_color,int scalex, int scaley,
24972497      int sprite_screen_width, int sprite_screen_height, int alpha)
24982498{
2499   saturn_state *state = machine.driver_data<saturn_state>();
25002499   rectangle myclip;
2501   UINT8* gfxdata;
25022500
2503   gfxdata = state->m_vdp2.gfx_decode + code * 0x20;
2504
25052501   if (!scalex || !scaley) return;
25062502
2507   #if 0
25082503   if (gfx->has_pen_usage() && transparency == STV_TRANSPARENCY_PEN)
25092504   {
25102505      int transmask = 0;
r20772r20773
25182513         /* character is totally opaque, can disable transparency */
25192514         transparency = STV_TRANSPARENCY_NONE;
25202515   }
2521   #endif
25222516
25232517   /*
25242518   scalex and scaley are 16.16 fixed point numbers
r20772r20773
25322526   myclip = clip;
25332527   myclip &= dest_bmp.cliprect();
25342528
2535//   if( gfx )
2529   if( gfx )
25362530   {
2537//      const UINT8 *source_base = gfx->get_data(code % gfx->elements());
2531      const pen_t *pal = &gfx->machine().pens[gfx->colorbase() + gfx->granularity() * (color % gfx->colors())];
2532      const UINT8 *source_base = gfx->get_data(code % gfx->elements());
25382533
25392534      //int sprite_screen_height = (scaley*gfx->height()+0x8000)>>16;
25402535      //int sprite_screen_width = (scalex*gfx->width()+0x8000)>>16;
r20772r20773
26062601            {
26072602               for( y=sy; y<ey; y++ )
26082603               {
2609                  const UINT8 *source = gfxdata + (y_index>>16)*16;
2604                  const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes();
26102605                  UINT32 *dest = &dest_bmp.pix32(y);
2611                  int r,g,b,data;
26122606
26132607                  int x, x_index = x_index_base;
26142608                  for( x=sx; x<ex; x++ )
26152609                  {
2616                     data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1];
2617                     b = pal5bit((data & 0x7c00) >> 10);
2618                     g = pal5bit((data & 0x03e0) >> 5);
2619                     r = pal5bit( data & 0x001f);
2620                     if(stv2_current_tilemap.fade_control & 1)
2621                        stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
2622
2623                     dest[x] = MAKE_RGB(r, g, b);
2610                     dest[x] = pal[source[x_index>>16]];
26242611                     x_index += dx;
26252612                  }
26262613
r20772r20773
26332620            {
26342621               for( y=sy; y<ey; y++ )
26352622               {
2636                  const UINT8 *source = gfxdata + (y_index>>16)*16;
2623                  const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes();
26372624                  UINT32 *dest = &dest_bmp.pix32(y);
2638                  int r,g,b,data;
26392625
26402626                  int x, x_index = x_index_base;
26412627                  for( x=sx; x<ex; x++ )
26422628                  {
2643                     data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1];
2644                     b = pal5bit((data & 0x7c00) >> 10);
2645                     g = pal5bit((data & 0x03e0) >> 5);
2646                     r = pal5bit( data & 0x001f);
2647                     if(stv2_current_tilemap.fade_control & 1)
2648                        stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
2649
2650                     if( data ) dest[x] = MAKE_RGB(r, g, b);
2629                     int c = source[x_index>>16];
2630                     if( c != transparent_color ) dest[x] = pal[c];
26512631                     x_index += dx;
26522632                  }
26532633
r20772r20773
26602640            {
26612641               for( y=sy; y<ey; y++ )
26622642               {
2663                  const UINT8 *source = gfxdata + (y_index>>16)*16;
2643                  const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes();
26642644                  UINT32 *dest = &dest_bmp.pix32(y);
2665                  int r,g,b,data;
26662645
26672646                  int x, x_index = x_index_base;
26682647                  for( x=sx; x<ex; x++ )
26692648                  {
2670               data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1];
2671                     b = pal5bit((data & 0x7c00) >> 10);
2672                     g = pal5bit((data & 0x03e0) >> 5);
2673                     r = pal5bit( data & 0x001f);
2674                     if(stv2_current_tilemap.fade_control & 1)
2675                        stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
2676
2677                     if( data ) dest[x] = alpha_blend_r32(dest[x], MAKE_RGB(r, g, b), alpha);
2649                     int c = source[x_index>>16];
2650                     if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
26782651                     x_index += dx;
26792652                  }
26802653
r20772r20773
26872660            {
26882661               for( y=sy; y<ey; y++ )
26892662               {
2690                  const UINT8 *source = gfxdata + (y_index>>16)*16;
2663                  const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes();
26912664                  UINT32 *dest = &dest_bmp.pix32(y);
2692                  int r,g,b,data;
26932665
26942666                  int x, x_index = x_index_base;
26952667                  for( x=sx; x<ex; x++ )
26962668                  {
2697                     data = (source[(x_index*2+0)>>16]<<0)|(source[(x_index*2+1)>>16]<<8);
2698                     b = pal5bit((data & 0x7c00) >> 10);
2699                     g = pal5bit((data & 0x03e0) >> 5);
2700                     r = pal5bit( data & 0x001f);
2701                     if(stv2_current_tilemap.fade_control & 1)
2702                        stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
2703
2704                     if( data ) dest[x] = stv_add_blend(dest[x], MAKE_RGB(r, g, b));
2669                     int c = source[x_index>>16];
2670                     if( c != transparent_color ) dest[x] = stv_add_blend(dest[x],pal[c]);
27052671                     x_index += dx;
27062672                  }
27072673
r20772r20773
27152681
27162682}
27172683
2718static void stv_vdp2_drawgfxzoom(
2719      bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
2684static void stv_vdp2_drawgfxzoom_rgb555(
2685      bitmap_rgb32 &dest_bmp,const rectangle &clip,running_machine &machine,
27202686      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
27212687      int transparency,int transparent_color,int scalex, int scaley,
27222688      int sprite_screen_width, int sprite_screen_height, int alpha)
27232689{
2690   saturn_state *state = machine.driver_data<saturn_state>();
27242691   rectangle myclip;
2692   UINT8* gfxdata;
27252693
2694   gfxdata = state->m_vdp2.gfx_decode + code * 0x20;
2695
27262696   if (!scalex || !scaley) return;
27272697
2698   #if 0
27282699   if (gfx->has_pen_usage() && transparency == STV_TRANSPARENCY_PEN)
27292700   {
27302701      int transmask = 0;
r20772r20773
27382709         /* character is totally opaque, can disable transparency */
27392710         transparency = STV_TRANSPARENCY_NONE;
27402711   }
2712   #endif
27412713
27422714   /*
27432715   scalex and scaley are 16.16 fixed point numbers
r20772r20773
27512723   myclip = clip;
27522724   myclip &= dest_bmp.cliprect();
27532725
2754   if( gfx )
2726//   if( gfx )
27552727   {
2756      const pen_t *pal = &gfx->machine().pens[gfx->colorbase() + gfx->granularity() * (color % gfx->colors())];
2757      const UINT8 *source_base = gfx->get_data(code % gfx->elements());
2728//      const UINT8 *source_base = gfx->get_data(code % gfx->elements());
27582729
27592730      //int sprite_screen_height = (scaley*gfx->height()+0x8000)>>16;
27602731      //int sprite_screen_width = (scalex*gfx->width()+0x8000)>>16;
r20772r20773
28262797            {
28272798               for( y=sy; y<ey; y++ )
28282799               {
2829                  const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes();
2800                  const UINT8 *source = gfxdata + (y_index>>16)*16;
28302801                  UINT32 *dest = &dest_bmp.pix32(y);
2802                  int r,g,b,data;
28312803
28322804                  int x, x_index = x_index_base;
28332805                  for( x=sx; x<ex; x++ )
28342806                  {
2835                     dest[x] = pal[source[x_index>>16]];
2807                     data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1];
2808                     b = pal5bit((data & 0x7c00) >> 10);
2809                     g = pal5bit((data & 0x03e0) >> 5);
2810                     r = pal5bit( data & 0x001f);
2811                     if(stv2_current_tilemap.fade_control & 1)
2812                        stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
2813
2814                     dest[x] = MAKE_RGB(r, g, b);
28362815                     x_index += dx;
28372816                  }
28382817
r20772r20773
28452824            {
28462825               for( y=sy; y<ey; y++ )
28472826               {
2848                  const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes();
2827                  const UINT8 *source = gfxdata + (y_index>>16)*16;
28492828                  UINT32 *dest = &dest_bmp.pix32(y);
2829                  int r,g,b,data;
28502830
28512831                  int x, x_index = x_index_base;
28522832                  for( x=sx; x<ex; x++ )
28532833                  {
2854                     int c = source[x_index>>16];
2855                     if( c != transparent_color ) dest[x] = pal[c];
2834                     data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1];
2835                     b = pal5bit((data & 0x7c00) >> 10);
2836                     g = pal5bit((data & 0x03e0) >> 5);
2837                     r = pal5bit( data & 0x001f);
2838                     if(stv2_current_tilemap.fade_control & 1)
2839                        stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
2840
2841                     if( data ) dest[x] = MAKE_RGB(r, g, b);
28562842                     x_index += dx;
28572843                  }
28582844
r20772r20773
28652851            {
28662852               for( y=sy; y<ey; y++ )
28672853               {
2868                  const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes();
2854                  const UINT8 *source = gfxdata + (y_index>>16)*16;
28692855                  UINT32 *dest = &dest_bmp.pix32(y);
2856                  int r,g,b,data;
28702857
28712858                  int x, x_index = x_index_base;
28722859                  for( x=sx; x<ex; x++ )
28732860                  {
2874                     int c = source[x_index>>16];
2875                     if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
2861               data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1];
2862                     b = pal5bit((data & 0x7c00) >> 10);
2863                     g = pal5bit((data & 0x03e0) >> 5);
2864                     r = pal5bit( data & 0x001f);
2865                     if(stv2_current_tilemap.fade_control & 1)
2866                        stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
2867
2868                     if( data ) dest[x] = alpha_blend_r32(dest[x], MAKE_RGB(r, g, b), alpha);
28762869                     x_index += dx;
28772870                  }
28782871
r20772r20773
28852878            {
28862879               for( y=sy; y<ey; y++ )
28872880               {
2888                  const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes();
2881                  const UINT8 *source = gfxdata + (y_index>>16)*16;
28892882                  UINT32 *dest = &dest_bmp.pix32(y);
2883                  int r,g,b,data;
28902884
28912885                  int x, x_index = x_index_base;
28922886                  for( x=sx; x<ex; x++ )
28932887                  {
2894                     int c = source[x_index>>16];
2895                     if( c != transparent_color ) dest[x] = stv_add_blend(dest[x],pal[c]);
2888                     data = (source[(x_index*2+0)>>16]<<0)|(source[(x_index*2+1)>>16]<<8);
2889                     b = pal5bit((data & 0x7c00) >> 10);
2890                     g = pal5bit((data & 0x03e0) >> 5);
2891                     r = pal5bit( data & 0x001f);
2892                     if(stv2_current_tilemap.fade_control & 1)
2893                        stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
2894
2895                     if( data ) dest[x] = stv_add_blend(dest[x], MAKE_RGB(r, g, b));
28962896                     x_index += dx;
28972897                  }
28982898
r20772r20773
64196419   UINT8   ccr = 0;
64206420   UINT8 sprite_priorities[8];
64216421   UINT8 sprite_ccr[8];
6422   int     sprite_color_mode = STV_VDP2_SPCLMD;
6422   int sprite_color_mode = STV_VDP2_SPCLMD;
64236423   rectangle mycliprect;
64246424
64256425   if ( (stv_sprite_priorities_usage_valid == 1) && (stv_sprite_priorities_used[pri] == 0) )
r20772r20773
68056805               {
68066806                  if ( pix & ~sprite_shadow )
68076807                  {
6808                     UINT32 p = bitmap_line[x];
6809                     bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
6808                     UINT32 p; //= bitmap_line[x];
6809                     if(double_x)
6810                     {
6811                        p = bitmap_line[x*2];
6812                        bitmap_line[x*2] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
6813                        p = bitmap_line[x*2+1];
6814                        bitmap_line[x*2+1] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
6815                     }
6816                     else
6817                        bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
68106818                  }
68116819               }
68126820               else
r20772r20773
68176825                     /*shadow - in reality, we should check from what layer pixel beneath comes...*/
68186826                     if ( STV_VDP2_SDCTL & 0x3f )
68196827                     {
6820                        UINT32 p = bitmap_line[x];
6821                        bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
6828                        UINT32 p;// = bitmap_line[x];
6829                        if(double_x)
6830                        {
6831                           p = bitmap_line[x*2];
6832                           bitmap_line[x*2] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
6833                           p = bitmap_line[x*2+1];
6834                           bitmap_line[x*2+1] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
6835                        }
6836                        else
6837                           bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
68226838                     }
68236839                     /* note that when shadows are disabled, "shadow" palette entries are not drawn */
68246840                  } else if ( pix )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team