Previous 15994 Revisions Next

r6874 Saturday 2nd January, 2010 at 19:04:48 UTC by Wilbert Pol
[SCV] Added some more sprite drawing features.
[src/mess/drivers]scv.c

src/mess/drivers/scv.c
r6873r6874
190190}
191191
192192
193INLINE void draw_sprite( bitmap_t *bitmap, UINT8 x, UINT8 y, UINT8 tile_idx, UINT8 col )
193INLINE void draw_sprite( bitmap_t *bitmap, UINT8 x, UINT8 y, UINT8 tile_idx, UINT8 col, UINT8 left, UINT8 right, UINT8 top, UINT8 bottom, UINT8 clip_y )
194194{
195195   int j;
196196
197   for ( j = 0; j < 32; j += 4 )
197   y += clip_y * 2;
198   for ( j = clip_y * 4; j < 32; j += 4 )
198199   {
199200      UINT8 pat0 = scv_vram[ tile_idx * 32 + j + 0 ];
200201      UINT8 pat1 = scv_vram[ tile_idx * 32 + j + 1 ];
201202      UINT8 pat2 = scv_vram[ tile_idx * 32 + j + 2 ];
202203      UINT8 pat3 = scv_vram[ tile_idx * 32 + j + 3 ];
203204
204      plot_sprite_part( bitmap, x     , y, pat0 >> 4, col );
205      plot_sprite_part( bitmap, x +  4, y, pat1 >> 4, col );
206      plot_sprite_part( bitmap, x +  8, y, pat2 >> 4, col );
207      plot_sprite_part( bitmap, x + 12, y, pat3 >> 4, col );
205      if ( ( top && j < 16 ) || ( bottom && j >= 16 ) )
206      {
207         if ( left )
208         {
209            plot_sprite_part( bitmap, x     , y, pat0 >> 4, col );
210            plot_sprite_part( bitmap, x +  4, y, pat1 >> 4, col );
211         }
212         if ( right )
213         {
214            plot_sprite_part( bitmap, x +  8, y, pat2 >> 4, col );
215            plot_sprite_part( bitmap, x + 12, y, pat3 >> 4, col );
216         }
208217
209      plot_sprite_part( bitmap, x     , y + 1, pat0 & 0x0f, col );
210      plot_sprite_part( bitmap, x +  4, y + 1, pat1 & 0x0f, col );
211      plot_sprite_part( bitmap, x +  8, y + 1, pat2 & 0x0f, col );
212      plot_sprite_part( bitmap, x + 12, y + 1, pat3 & 0x0f, col );
218         if ( left )
219         {
220            plot_sprite_part( bitmap, x     , y + 1, pat0 & 0x0f, col );
221            plot_sprite_part( bitmap, x +  4, y + 1, pat1 & 0x0f, col );
222         }
223         if ( right )
224         {
225            plot_sprite_part( bitmap, x +  8, y + 1, pat2 & 0x0f, col );
226            plot_sprite_part( bitmap, x + 12, y + 1, pat3 & 0x0f, col );
227         }
228      }
213229
214230      y += 2;
215231   }
r6873r6874
320336      {
321337         UINT8 spr_y = scv_vram[ 0x1200 + i * 4 ] & 0xfe;
322338         UINT8 y_32 = scv_vram[ 0x1200 + i * 4 ] & 0x01;      /* Xx32 sprite */
339         UINT8 clip = scv_vram[ 0x1201 + i * 4 ] >> 4;
323340         UINT8 col = scv_vram[ 0x1201 + i * 4 ] & 0x0f;
324341         UINT8 spr_x = scv_vram[ 0x1202 + i * 4 ] & 0xfe;
325342         UINT8 x_32 = scv_vram[ 0x1202 + i * 4 ] & 0x01;      /* 32xX sprite */
326343         UINT8 tile_idx = scv_vram[ 0x1203 + i * 4 ] & 0x7f;
344         UINT8 half = scv_vram[ 0x1203 + i * 4] & 0x80;
345         UINT8 left = 1;
346         UINT8 right = 1;
347         UINT8 top = 1;
348         UINT8 bottom = 1;
327349
328350         if ( !col )
329351            continue;
330352
353         if ( half )
354         {
355            if ( tile_idx & 0x40 )
356            {
357               if ( y_32 )
358               {
359                  spr_y -= 8;
360                  top = 0;
361                  bottom = 1;
362                  y_32 = 0;
363               }
364               else
365               {
366                  top = 1;
367                  bottom = 0;
368               }
369            }
370            if ( x_32 )
371            {
372               spr_x -= 8;
373               left = 0;
374               right = 1;
375               x_32 = 0;
376            }
377            else
378            {
379               left = 1;
380               right = 0;
381            }
382         }
383
331384         /* Check if 2 color sprites are enabled */
332385         if ( ( scv_vram[0x1400] & 0x20 ) && ( i & 0x20 ) )
333386         {
334387            /* 2 color sprite handling */
335            draw_sprite( bitmap, spr_x, spr_y, tile_idx, col );
388            draw_sprite( bitmap, spr_x, spr_y, tile_idx, col, left, right, top, bottom, clip );
336389            if ( x_32 || y_32 )
337390            {
338391               static const UINT8 spr_2col_lut0[16] = { 0, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 1, 1 };
339392               static const UINT8 spr_2col_lut1[16] = { 0, 1, 8, 11, 2, 3, 10, 9, 4, 5, 12, 13, 6, 7, 14, 15 };
340393
341               draw_sprite( bitmap, spr_x, spr_y, tile_idx + 8 * x_32 + y_32, ( i & 0x40 ) ? spr_2col_lut1[col] : spr_2col_lut0[col] );
394               draw_sprite( bitmap, spr_x, spr_y, tile_idx + 8 * x_32 + y_32, ( i & 0x40 ) ? spr_2col_lut1[col] : spr_2col_lut0[col], left, right, top, bottom, clip );
342395            }
343396         }
344397         else
345398         {
346399            /* regular sprite handling */
347            draw_sprite( bitmap, spr_x, spr_y, tile_idx, col );
400            draw_sprite( bitmap, spr_x, spr_y, tile_idx, col, left, right, top, bottom, clip );
348401            if ( x_32 )
349402            {
350               draw_sprite( bitmap, spr_x + 16, spr_y, tile_idx + 8, col );
403               draw_sprite( bitmap, spr_x + 16, spr_y, tile_idx + 8, col, 1, 1, top, bottom, clip );
351404            }
352405            if ( y_32 )
353406            {
354               draw_sprite( bitmap, spr_x, spr_y + 16, tile_idx + 1, col );
407               clip &= 0x07;
408               draw_sprite( bitmap, spr_x, spr_y + 16, tile_idx + 1, col, left, right, 1, 1, clip );
355409               if ( x_32 )
356410               {
357                  draw_sprite( bitmap, spr_x + 16, spr_y + 16, tile_idx + 9, col );
411                  draw_sprite( bitmap, spr_x + 16, spr_y + 16, tile_idx + 9, col, 1, 1, 1, 1, clip );
358412               }
359413            }
360414         }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team