Previous 199869 Revisions Next

r30719 Friday 30th May, 2014 at 11:17:41 UTC by David Haywood
wc90 sprites refactor (nw)
[src/mame/drivers]wc90.c
[src/mame/video]tecmo_spr.c tecmo_spr.h

trunk/src/mame/drivers/wc90.c
r30718r30719
267267   128*8
268268};
269269
270static const gfx_layout spritelayout =
271{
272   16,16,
273   RGN_FRAC(1,2),
274   4,
275   { 0, 1, 2, 3 },
276   { 0*4, 1*4, RGN_FRAC(1,2)+0*4, RGN_FRAC(1,2)+1*4, 2*4, 3*4, RGN_FRAC(1,2)+2*4, RGN_FRAC(1,2)+3*4,
277         16*8+0*4, 16*8+1*4, RGN_FRAC(1,2)+16*8+0*4, RGN_FRAC(1,2)+16*8+1*4, 16*8+2*4, 16*8+3*4, RGN_FRAC(1,2)+16*8+2*4, RGN_FRAC(1,2)+16*8+3*4 },
278   { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
279         16*16, 17*16, 18*16, 19*16, 20*16, 21*16, 22*16, 23*16 },
280   64*8
281};
282270
283271static const gfx_layout spritelayout8 =
284272{
r30718r30719
288276   { 0, 1, 2, 3 },
289277   { 0*4, 1*4, RGN_FRAC(1,2)+0*4, RGN_FRAC(1,2)+1*4, 2*4, 3*4, RGN_FRAC(1,2)+2*4, RGN_FRAC(1,2)+3*4 },
290278   { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
291   64*8
279   16*8
292280};
293281
294282
r30718r30719
296284   GFXDECODE_ENTRY( "gfx1", 0x00000, charlayout,       1*16*16, 16*16 )
297285   GFXDECODE_ENTRY( "gfx2", 0x00000, tilelayout,       2*16*16, 16*16 )
298286   GFXDECODE_ENTRY( "gfx3", 0x00000, tilelayout,       3*16*16, 16*16 )
299   GFXDECODE_ENTRY( "gfx4", 0x00000, spritelayout,     0*16*16, 16*16 ) // sprites
300   GFXDECODE_ENTRY( "gfx4", 0x00000, spritelayout8,     0*16*16, 16*16 ) // sprites (8x8 layout for once we refactor sprite drawing)
287   GFXDECODE_ENTRY( "gfx4", 0x00000, spritelayout8,     0*16*16, 16*16 )
301288GFXDECODE_END
302289
303290
trunk/src/mame/video/tecmo_spr.c
r30718r30719
298298}
299299
300300
301/* sprite format (wc90.c):
301/* sprite format (wc90.c):  - similar to the 16-bit one
302302 *
303303 *  byte     bit        usage
304304 * --------+-76543210-+----------------
305         0 | xxxxx--- | bank / upper tile bits
305   
306306
307307
308308*/
309309
310310
311#define WC90_DRAW_SPRITE( code, sx, sy ) \
312               gfxdecode->gfx(3)->transpen(bitmap,cliprect, code, flags >> 4, \
313               bank&1, bank&2, sx, sy, 0 )
314
315static const char p32x32[4][4] = {
316   { 0, 1, 2, 3 },
317   { 1, 0, 3, 2 },
318   { 2, 3, 0, 1 },
319   { 3, 2, 1, 0 }
320};
321
322static const char p32x64[4][8] = {
323   { 0, 1, 2, 3, 4, 5, 6, 7 },
324   { 5, 4, 7, 6, 1, 0, 3, 2 },
325   { 2, 3, 0, 1, 6, 7, 4, 5 },
326   { 7, 6, 5, 4, 3, 2, 1, 0 }
327};
328
329static const char p64x32[4][8] = {
330   { 0, 1, 2, 3, 4, 5, 6, 7 },
331   { 1, 0, 3, 2, 5, 4, 7, 6 },
332   { 6, 7, 4, 5, 2, 3, 0, 1 },
333   { 7, 6, 5, 4, 3, 2, 1, 0 }
334};
335
336static const char p64x64[4][16] = {
337   { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
338   { 5, 4, 7, 6, 1, 0, 3, 2, 13, 12, 15, 14, 9, 8, 11, 10 },
339   { 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5 },
340   { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }
341};
342
343void tecmo_spr_device::draw_wc90_sprite_16x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags )
344{
345   WC90_DRAW_SPRITE( code, sx, sy );
346}
347
348void tecmo_spr_device::draw_wc90_sprite_16x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags )
349{
350   if ( bank & 2 ) {
351      WC90_DRAW_SPRITE( code+1, sx, sy+16 );
352      WC90_DRAW_SPRITE( code, sx, sy );
353   } else {
354      WC90_DRAW_SPRITE( code, sx, sy );
355      WC90_DRAW_SPRITE( code+1, sx, sy+16 );
356   }
357}
358
359void tecmo_spr_device::draw_wc90_sprite_16x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags )
360{
361   if ( bank & 2 ) {
362      WC90_DRAW_SPRITE( code+3, sx, sy+48 );
363      WC90_DRAW_SPRITE( code+2, sx, sy+32 );
364      WC90_DRAW_SPRITE( code+1, sx, sy+16 );
365      WC90_DRAW_SPRITE( code, sx, sy );
366   } else {
367      WC90_DRAW_SPRITE( code, sx, sy );
368      WC90_DRAW_SPRITE( code+1, sx, sy+16 );
369      WC90_DRAW_SPRITE( code+2, sx, sy+32 );
370      WC90_DRAW_SPRITE( code+3, sx, sy+48 );
371   }
372}
373
374void tecmo_spr_device::draw_wc90_sprite_32x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags )
375{
376   if ( bank & 1 ) {
377      WC90_DRAW_SPRITE( code+1, sx+16, sy );
378      WC90_DRAW_SPRITE( code, sx, sy );
379   } else {
380      WC90_DRAW_SPRITE( code, sx, sy );
381      WC90_DRAW_SPRITE( code+1, sx+16, sy );
382   }
383}
384
385void tecmo_spr_device::draw_wc90_sprite_32x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags )
386{
387   const char *p = p32x32[ bank&3 ];
388
389   WC90_DRAW_SPRITE( code+p[0], sx, sy );
390   WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
391   WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
392   WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
393}
394
395void tecmo_spr_device::draw_wc90_sprite_32x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code, int sx, int sy, int bank, int flags )
396{
397   const char *p = p32x64[ bank&3 ];
398
399   WC90_DRAW_SPRITE( code+p[0], sx, sy );
400   WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
401   WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
402   WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
403   WC90_DRAW_SPRITE( code+p[4], sx, sy+32 );
404   WC90_DRAW_SPRITE( code+p[5], sx+16, sy+32 );
405   WC90_DRAW_SPRITE( code+p[6], sx, sy+48 );
406   WC90_DRAW_SPRITE( code+p[7], sx+16, sy+48 );
407}
408
409void tecmo_spr_device::draw_wc90_sprite_64x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags )
410{
411   if ( bank & 1 ) {
412      WC90_DRAW_SPRITE( code+3, sx+48, sy );
413      WC90_DRAW_SPRITE( code+2, sx+32, sy );
414      WC90_DRAW_SPRITE( code+1, sx+16, sy );
415      WC90_DRAW_SPRITE( code, sx, sy );
416   } else {
417      WC90_DRAW_SPRITE( code, sx, sy );
418      WC90_DRAW_SPRITE( code+1, sx+16, sy );
419      WC90_DRAW_SPRITE( code+2, sx+32, sy );
420      WC90_DRAW_SPRITE( code+3, sx+48, sy );
421   }
422}
423
424void tecmo_spr_device::draw_wc90_sprite_64x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags )
425{
426   const char *p = p64x32[ bank&3 ];
427
428   WC90_DRAW_SPRITE( code+p[0], sx, sy );
429   WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
430   WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
431   WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
432   WC90_DRAW_SPRITE( code+p[4], sx+32, sy );
433   WC90_DRAW_SPRITE( code+p[5], sx+48, sy );
434   WC90_DRAW_SPRITE( code+p[6], sx+32, sy+16 );
435   WC90_DRAW_SPRITE( code+p[7], sx+48, sy+16 );
436}
437
438void tecmo_spr_device::draw_wc90_sprite_64x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags )
439{
440   const char *p = p64x64[ bank&3 ];
441
442   WC90_DRAW_SPRITE( code+p[0], sx, sy );
443   WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
444   WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
445   WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
446   WC90_DRAW_SPRITE( code+p[4], sx+32, sy );
447   WC90_DRAW_SPRITE( code+p[5], sx+48, sy );
448   WC90_DRAW_SPRITE( code+p[6], sx+32, sy+16 );
449   WC90_DRAW_SPRITE( code+p[7], sx+48, sy+16 );
450
451   WC90_DRAW_SPRITE( code+p[8], sx, sy+32 );
452   WC90_DRAW_SPRITE( code+p[9], sx+16, sy+32 );
453   WC90_DRAW_SPRITE( code+p[10], sx, sy+48 );
454   WC90_DRAW_SPRITE( code+p[11], sx+16, sy+48 );
455   WC90_DRAW_SPRITE( code+p[12], sx+32, sy+32 );
456   WC90_DRAW_SPRITE( code+p[13], sx+48, sy+32 );
457   WC90_DRAW_SPRITE( code+p[14], sx+32, sy+48 );
458   WC90_DRAW_SPRITE( code+p[15], sx+48, sy+48 );
459}
460
461void tecmo_spr_device::draw_wc90_sprite_invalid(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code, int sx, int sy, int bank, int flags )
462{
463   logerror("8 pixel sprite size not supported\n" );
464}
465
466static const tecmo_spr_device::draw_wc90_sprites_func draw_wc90_sprites_proc[16] = {
467   &tecmo_spr_device::draw_wc90_sprite_invalid,    /* 0000 = 08x08 */
468   &tecmo_spr_device::draw_wc90_sprite_invalid,    /* 0001 = 16x08 */
469   &tecmo_spr_device::draw_wc90_sprite_invalid,    /* 0010 = 32x08 */
470   &tecmo_spr_device::draw_wc90_sprite_invalid,    /* 0011 = 64x08 */
471   &tecmo_spr_device::draw_wc90_sprite_invalid,    /* 0100 = 08x16 */
472   &tecmo_spr_device::draw_wc90_sprite_16x16,      /* 0101 = 16x16 */
473   &tecmo_spr_device::draw_wc90_sprite_32x16,      /* 0110 = 32x16 */
474   &tecmo_spr_device::draw_wc90_sprite_64x16,      /* 0111 = 64x16 */
475   &tecmo_spr_device::draw_wc90_sprite_invalid,    /* 1000 = 08x32 */
476   &tecmo_spr_device::draw_wc90_sprite_16x32,      /* 1001 = 16x32 */
477   &tecmo_spr_device::draw_wc90_sprite_32x32,      /* 1010 = 32x32 */
478   &tecmo_spr_device::draw_wc90_sprite_64x32,      /* 1011 = 64x32 */
479   &tecmo_spr_device::draw_wc90_sprite_invalid,    /* 1100 = 08x64 */
480   &tecmo_spr_device::draw_wc90_sprite_16x64,      /* 1101 = 16x64 */
481   &tecmo_spr_device::draw_wc90_sprite_32x64,      /* 1110 = 32x64 */
482   &tecmo_spr_device::draw_wc90_sprite_64x64       /* 1111 = 64x64 */
483};
484
485311void tecmo_spr_device::draw_wc90_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, UINT8* spriteram, int size, int priority )
486312{
487   int offs, sx,sy, flags, which;
313   int offs, flags, code;
488314
489315   /* draw all visible sprites of specified priority */
490316   for (offs = 0;offs < size;offs += 16){
r30718r30719
492318
493319      if ( ( bank >> 4 ) == priority ) {
494320         if ( bank & 4 ) { /* visible */
495            which = ( spriteram[offs+2] >> 2 ) + ( spriteram[offs+3] << 6 );
321            code = ( spriteram[offs+2] ) + ( spriteram[offs+3] << 8 );
496322
497            sx = spriteram[offs + 8] + ( (spriteram[offs + 9] & 3 ) << 8 );
498            sy = spriteram[offs + 6] + ( (spriteram[offs + 7] & 1 ) << 8 );
323            int xpos = spriteram[offs + 8] + ( (spriteram[offs + 9] & 3 ) << 8 );
324            int ypos = spriteram[offs + 6] + ( (spriteram[offs + 7] & 1 ) << 8 );
499325
500            if (sx >= 0x0300) sx -= 0x0400;
326            if (xpos >= 0x0300) xpos -= 0x0400;
501327
502328            flags = spriteram[offs+4];
503            (this->*( draw_wc90_sprites_proc[ flags & 0x0f ] ) )(bitmap,cliprect, gfxdecode, which, sx, sy, bank, flags );
329           
330            int sizex = 1 << ((flags >> 0) & 3);
331            int sizey = 1 << ((flags >> 2) & 3);
332
333
334            int flipx = bank & 1;
335            int flipy = bank & 2;
336
337            for (int y = 0;y < sizey;y++)
338            {
339               for (int x = 0;x < sizex;x++)
340               {
341                  int sx = xpos + 8*(flipx?(sizex-1-x):x);
342                  int sy = ypos + 8*(flipy?(sizey-1-y):y);
343                  gfxdecode->gfx(3)->transpen(bitmap,cliprect,
344                        code + layout[y][x],
345                        (flags>>4) & 0xf,
346                        flipx,flipy,
347                        sx,sy,
348                        0);
349               }
350            }
351
352
504353         }
505354      }
506355   }
r30718r30719
513362void tecmo_spr_device::tbowl_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect, gfxdecode_device *gfxdecode, int xscroll, UINT8* spriteram)
514363{
515364   int offs;
516   static const UINT8 layout[8][8] =
517   {
518      {0,1,4,5,16,17,20,21},
519      {2,3,6,7,18,19,22,23},
520      {8,9,12,13,24,25,28,29},
521      {10,11,14,15,26,27,30,31},
522      {32,33,36,37,48,49,52,53},
523      {34,35,38,39,50,51,54,55},
524      {40,41,44,45,56,57,60,61},
525      {42,43,46,47,58,59,62,63}
526   };
527365
528366   for (offs = 0;offs < 0x800;offs += 8)
529367   {
trunk/src/mame/video/tecmo_spr.h
r30718r30719
1515   // tecmo.c sprites
1616   void draw_sprites_8bit(screen_device &screen, bitmap_ind16 &bitmap, gfxdecode_device *gfxdecode, const rectangle &cliprect, UINT8* spriteram, int size, int video_type, int flip_screen);
1717
18   typedef void (tecmo_spr_device::*draw_wc90_sprites_func)(bitmap_ind16 &, const rectangle &,  gfxdecode_device *, int, int, int, int, int );
19
2018   // wc90.c sprites
2119   void draw_wc90_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, UINT8* spriteram, int size, int priority);
2220
23   void draw_wc90_sprite_16x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
24   void draw_wc90_sprite_16x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
25   void draw_wc90_sprite_16x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
26   void draw_wc90_sprite_32x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
27   void draw_wc90_sprite_32x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
28   void draw_wc90_sprite_32x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code, int sx, int sy, int bank, int flags );
29   void draw_wc90_sprite_64x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
30   void draw_wc90_sprite_64x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
31   void draw_wc90_sprite_64x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
32   void draw_wc90_sprite_invalid(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code, int sx, int sy, int bank, int flags );
33
3421   // tbowl.c sprites
3522   void tbowl_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int xscroll, UINT8* spriteram);
3623

Previous 199869 Revisions Next


© 1997-2024 The MAME Team