wc90 sprites refactor (nw)

This commit is contained in:
David Haywood 2014-05-30 11:17:41 +00:00
parent 7b0cbe61d7
commit 16fd7b383b
3 changed files with 33 additions and 221 deletions

View File

@ -267,18 +267,6 @@ static const gfx_layout tilelayout =
128*8
};
static const gfx_layout spritelayout =
{
16,16,
RGN_FRAC(1,2),
4,
{ 0, 1, 2, 3 },
{ 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,
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 },
{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
16*16, 17*16, 18*16, 19*16, 20*16, 21*16, 22*16, 23*16 },
64*8
};
static const gfx_layout spritelayout8 =
{
@ -288,7 +276,7 @@ static const gfx_layout spritelayout8 =
{ 0, 1, 2, 3 },
{ 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 },
{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
64*8
16*8
};
@ -296,8 +284,7 @@ static GFXDECODE_START( wc90 )
GFXDECODE_ENTRY( "gfx1", 0x00000, charlayout, 1*16*16, 16*16 )
GFXDECODE_ENTRY( "gfx2", 0x00000, tilelayout, 2*16*16, 16*16 )
GFXDECODE_ENTRY( "gfx3", 0x00000, tilelayout, 3*16*16, 16*16 )
GFXDECODE_ENTRY( "gfx4", 0x00000, spritelayout, 0*16*16, 16*16 ) // sprites
GFXDECODE_ENTRY( "gfx4", 0x00000, spritelayout8, 0*16*16, 16*16 ) // sprites (8x8 layout for once we refactor sprite drawing)
GFXDECODE_ENTRY( "gfx4", 0x00000, spritelayout8, 0*16*16, 16*16 )
GFXDECODE_END

View File

@ -298,193 +298,19 @@ void tecmo_spr_device::draw_sprites_8bit(screen_device &screen, bitmap_ind16 &bi
}
/* sprite format (wc90.c):
/* sprite format (wc90.c): - similar to the 16-bit one
*
* byte bit usage
* --------+-76543210-+----------------
0 | xxxxx--- | bank / upper tile bits
*/
#define WC90_DRAW_SPRITE( code, sx, sy ) \
gfxdecode->gfx(3)->transpen(bitmap,cliprect, code, flags >> 4, \
bank&1, bank&2, sx, sy, 0 )
static const char p32x32[4][4] = {
{ 0, 1, 2, 3 },
{ 1, 0, 3, 2 },
{ 2, 3, 0, 1 },
{ 3, 2, 1, 0 }
};
static const char p32x64[4][8] = {
{ 0, 1, 2, 3, 4, 5, 6, 7 },
{ 5, 4, 7, 6, 1, 0, 3, 2 },
{ 2, 3, 0, 1, 6, 7, 4, 5 },
{ 7, 6, 5, 4, 3, 2, 1, 0 }
};
static const char p64x32[4][8] = {
{ 0, 1, 2, 3, 4, 5, 6, 7 },
{ 1, 0, 3, 2, 5, 4, 7, 6 },
{ 6, 7, 4, 5, 2, 3, 0, 1 },
{ 7, 6, 5, 4, 3, 2, 1, 0 }
};
static const char p64x64[4][16] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
{ 5, 4, 7, 6, 1, 0, 3, 2, 13, 12, 15, 14, 9, 8, 11, 10 },
{ 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5 },
{ 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }
};
void 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 )
{
WC90_DRAW_SPRITE( code, sx, sy );
}
void 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 )
{
if ( bank & 2 ) {
WC90_DRAW_SPRITE( code+1, sx, sy+16 );
WC90_DRAW_SPRITE( code, sx, sy );
} else {
WC90_DRAW_SPRITE( code, sx, sy );
WC90_DRAW_SPRITE( code+1, sx, sy+16 );
}
}
void 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 )
{
if ( bank & 2 ) {
WC90_DRAW_SPRITE( code+3, sx, sy+48 );
WC90_DRAW_SPRITE( code+2, sx, sy+32 );
WC90_DRAW_SPRITE( code+1, sx, sy+16 );
WC90_DRAW_SPRITE( code, sx, sy );
} else {
WC90_DRAW_SPRITE( code, sx, sy );
WC90_DRAW_SPRITE( code+1, sx, sy+16 );
WC90_DRAW_SPRITE( code+2, sx, sy+32 );
WC90_DRAW_SPRITE( code+3, sx, sy+48 );
}
}
void 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 )
{
if ( bank & 1 ) {
WC90_DRAW_SPRITE( code+1, sx+16, sy );
WC90_DRAW_SPRITE( code, sx, sy );
} else {
WC90_DRAW_SPRITE( code, sx, sy );
WC90_DRAW_SPRITE( code+1, sx+16, sy );
}
}
void 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 )
{
const char *p = p32x32[ bank&3 ];
WC90_DRAW_SPRITE( code+p[0], sx, sy );
WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
}
void 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 )
{
const char *p = p32x64[ bank&3 ];
WC90_DRAW_SPRITE( code+p[0], sx, sy );
WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
WC90_DRAW_SPRITE( code+p[4], sx, sy+32 );
WC90_DRAW_SPRITE( code+p[5], sx+16, sy+32 );
WC90_DRAW_SPRITE( code+p[6], sx, sy+48 );
WC90_DRAW_SPRITE( code+p[7], sx+16, sy+48 );
}
void 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 )
{
if ( bank & 1 ) {
WC90_DRAW_SPRITE( code+3, sx+48, sy );
WC90_DRAW_SPRITE( code+2, sx+32, sy );
WC90_DRAW_SPRITE( code+1, sx+16, sy );
WC90_DRAW_SPRITE( code, sx, sy );
} else {
WC90_DRAW_SPRITE( code, sx, sy );
WC90_DRAW_SPRITE( code+1, sx+16, sy );
WC90_DRAW_SPRITE( code+2, sx+32, sy );
WC90_DRAW_SPRITE( code+3, sx+48, sy );
}
}
void 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 )
{
const char *p = p64x32[ bank&3 ];
WC90_DRAW_SPRITE( code+p[0], sx, sy );
WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
WC90_DRAW_SPRITE( code+p[4], sx+32, sy );
WC90_DRAW_SPRITE( code+p[5], sx+48, sy );
WC90_DRAW_SPRITE( code+p[6], sx+32, sy+16 );
WC90_DRAW_SPRITE( code+p[7], sx+48, sy+16 );
}
void 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 )
{
const char *p = p64x64[ bank&3 ];
WC90_DRAW_SPRITE( code+p[0], sx, sy );
WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
WC90_DRAW_SPRITE( code+p[4], sx+32, sy );
WC90_DRAW_SPRITE( code+p[5], sx+48, sy );
WC90_DRAW_SPRITE( code+p[6], sx+32, sy+16 );
WC90_DRAW_SPRITE( code+p[7], sx+48, sy+16 );
WC90_DRAW_SPRITE( code+p[8], sx, sy+32 );
WC90_DRAW_SPRITE( code+p[9], sx+16, sy+32 );
WC90_DRAW_SPRITE( code+p[10], sx, sy+48 );
WC90_DRAW_SPRITE( code+p[11], sx+16, sy+48 );
WC90_DRAW_SPRITE( code+p[12], sx+32, sy+32 );
WC90_DRAW_SPRITE( code+p[13], sx+48, sy+32 );
WC90_DRAW_SPRITE( code+p[14], sx+32, sy+48 );
WC90_DRAW_SPRITE( code+p[15], sx+48, sy+48 );
}
void 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 )
{
logerror("8 pixel sprite size not supported\n" );
}
static const tecmo_spr_device::draw_wc90_sprites_func draw_wc90_sprites_proc[16] = {
&tecmo_spr_device::draw_wc90_sprite_invalid, /* 0000 = 08x08 */
&tecmo_spr_device::draw_wc90_sprite_invalid, /* 0001 = 16x08 */
&tecmo_spr_device::draw_wc90_sprite_invalid, /* 0010 = 32x08 */
&tecmo_spr_device::draw_wc90_sprite_invalid, /* 0011 = 64x08 */
&tecmo_spr_device::draw_wc90_sprite_invalid, /* 0100 = 08x16 */
&tecmo_spr_device::draw_wc90_sprite_16x16, /* 0101 = 16x16 */
&tecmo_spr_device::draw_wc90_sprite_32x16, /* 0110 = 32x16 */
&tecmo_spr_device::draw_wc90_sprite_64x16, /* 0111 = 64x16 */
&tecmo_spr_device::draw_wc90_sprite_invalid, /* 1000 = 08x32 */
&tecmo_spr_device::draw_wc90_sprite_16x32, /* 1001 = 16x32 */
&tecmo_spr_device::draw_wc90_sprite_32x32, /* 1010 = 32x32 */
&tecmo_spr_device::draw_wc90_sprite_64x32, /* 1011 = 64x32 */
&tecmo_spr_device::draw_wc90_sprite_invalid, /* 1100 = 08x64 */
&tecmo_spr_device::draw_wc90_sprite_16x64, /* 1101 = 16x64 */
&tecmo_spr_device::draw_wc90_sprite_32x64, /* 1110 = 32x64 */
&tecmo_spr_device::draw_wc90_sprite_64x64 /* 1111 = 64x64 */
};
void tecmo_spr_device::draw_wc90_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, UINT8* spriteram, int size, int priority )
{
int offs, sx,sy, flags, which;
int offs, flags, code;
/* draw all visible sprites of specified priority */
for (offs = 0;offs < size;offs += 16){
@ -492,15 +318,38 @@ void tecmo_spr_device::draw_wc90_sprites(bitmap_ind16 &bitmap, const rectangle &
if ( ( bank >> 4 ) == priority ) {
if ( bank & 4 ) { /* visible */
which = ( spriteram[offs+2] >> 2 ) + ( spriteram[offs+3] << 6 );
code = ( spriteram[offs+2] ) + ( spriteram[offs+3] << 8 );
sx = spriteram[offs + 8] + ( (spriteram[offs + 9] & 3 ) << 8 );
sy = spriteram[offs + 6] + ( (spriteram[offs + 7] & 1 ) << 8 );
int xpos = spriteram[offs + 8] + ( (spriteram[offs + 9] & 3 ) << 8 );
int ypos = spriteram[offs + 6] + ( (spriteram[offs + 7] & 1 ) << 8 );
if (sx >= 0x0300) sx -= 0x0400;
if (xpos >= 0x0300) xpos -= 0x0400;
flags = spriteram[offs+4];
(this->*( draw_wc90_sprites_proc[ flags & 0x0f ] ) )(bitmap,cliprect, gfxdecode, which, sx, sy, bank, flags );
int sizex = 1 << ((flags >> 0) & 3);
int sizey = 1 << ((flags >> 2) & 3);
int flipx = bank & 1;
int flipy = bank & 2;
for (int y = 0;y < sizey;y++)
{
for (int x = 0;x < sizex;x++)
{
int sx = xpos + 8*(flipx?(sizex-1-x):x);
int sy = ypos + 8*(flipy?(sizey-1-y):y);
gfxdecode->gfx(3)->transpen(bitmap,cliprect,
code + layout[y][x],
(flags>>4) & 0xf,
flipx,flipy,
sx,sy,
0);
}
}
}
}
}
@ -513,17 +362,6 @@ void tecmo_spr_device::draw_wc90_sprites(bitmap_ind16 &bitmap, const rectangle &
void tecmo_spr_device::tbowl_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect, gfxdecode_device *gfxdecode, int xscroll, UINT8* spriteram)
{
int offs;
static const UINT8 layout[8][8] =
{
{0,1,4,5,16,17,20,21},
{2,3,6,7,18,19,22,23},
{8,9,12,13,24,25,28,29},
{10,11,14,15,26,27,30,31},
{32,33,36,37,48,49,52,53},
{34,35,38,39,50,51,54,55},
{40,41,44,45,56,57,60,61},
{42,43,46,47,58,59,62,63}
};
for (offs = 0;offs < 0x800;offs += 8)
{

View File

@ -15,22 +15,9 @@ public:
// tecmo.c sprites
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);
typedef void (tecmo_spr_device::*draw_wc90_sprites_func)(bitmap_ind16 &, const rectangle &, gfxdecode_device *, int, int, int, int, int );
// wc90.c sprites
void draw_wc90_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, UINT8* spriteram, int size, int priority);
void draw_wc90_sprite_16x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
void draw_wc90_sprite_16x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
void draw_wc90_sprite_16x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
void draw_wc90_sprite_32x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
void draw_wc90_sprite_32x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
void draw_wc90_sprite_32x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code, int sx, int sy, int bank, int flags );
void draw_wc90_sprite_64x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
void draw_wc90_sprite_64x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
void draw_wc90_sprite_64x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code,int sx, int sy, int bank, int flags );
void draw_wc90_sprite_invalid(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode,int code, int sx, int sy, int bank, int flags );
// tbowl.c sprites
void tbowl_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int xscroll, UINT8* spriteram);