summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/namcos2_sprite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/video/namcos2_sprite.cpp')
-rw-r--r--src/mame/video/namcos2_sprite.cpp235
1 files changed, 110 insertions, 125 deletions
diff --git a/src/mame/video/namcos2_sprite.cpp b/src/mame/video/namcos2_sprite.cpp
index 9c9bca2546b..7d2f2f434b7 100644
--- a/src/mame/video/namcos2_sprite.cpp
+++ b/src/mame/video/namcos2_sprite.cpp
@@ -41,35 +41,35 @@ void namcos2_sprite_device::device_start()
void namcos2_sprite_device::zdrawgfxzoom(
screen_device &screen,
bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
- uint32_t code,uint32_t color,int flipx,int flipy,int sx,int sy,
- int scalex, int scaley, int zpos )
+ u32 code,u32 color,bool flipx,bool flipy,int sx,int sy,
+ int scalex, int scaley, int zpos)
{
if (!scalex || !scaley) return;
if (dest_bmp.bpp() == 16)
{
- if( gfx )
+ if (gfx)
{
- device_palette_interface &palette = m_gfxdecode->palette();
- int shadow_offset = (palette.shadows_enabled())?palette.entries():0;
+ device_palette_interface &palette = gfx->palette();
+ const int shadow_offset = (palette.shadows_enabled()) ? palette.entries() : 0;
const pen_t *pal = &palette.pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors()));
- const uint8_t *source_base = gfx->get_data(code % gfx->elements());
- int sprite_screen_height = (scaley*gfx->height()+0x8000)>>16;
- int sprite_screen_width = (scalex*gfx->width()+0x8000)>>16;
+ const u8 *source_base = gfx->get_data(code % gfx->elements());
+ const int sprite_screen_height = (scaley * gfx->height() + 0x8000) >> 16;
+ const int sprite_screen_width = (scalex * gfx->width() + 0x8000) >> 16;
if (sprite_screen_width && sprite_screen_height)
{
/* compute sprite increment per screen pixel */
- int dx = (gfx->width()<<16)/sprite_screen_width;
- int dy = (gfx->height()<<16)/sprite_screen_height;
+ int dx = (gfx->width() << 16) / sprite_screen_width;
+ int dy = (gfx->height() << 16) / sprite_screen_height;
- int ex = sx+sprite_screen_width;
- int ey = sy+sprite_screen_height;
+ int ex = sx + sprite_screen_width;
+ int ey = sy + sprite_screen_height;
int x_index_base;
int y_index;
- if( flipx )
+ if (flipx)
{
- x_index_base = (sprite_screen_width-1)*dx;
+ x_index_base = (sprite_screen_width - 1) * dx;
dx = -dx;
}
else
@@ -77,9 +77,9 @@ void namcos2_sprite_device::zdrawgfxzoom(
x_index_base = 0;
}
- if( flipy )
+ if (flipy)
{
- y_index = (sprite_screen_height-1)*dy;
+ y_index = (sprite_screen_height - 1) * dy;
dy = -dy;
}
else
@@ -87,58 +87,57 @@ void namcos2_sprite_device::zdrawgfxzoom(
y_index = 0;
}
- if( sx < clip.min_x)
+ if (sx < clip.min_x)
{ /* clip left */
- int pixels = clip.min_x-sx;
+ int pixels = clip.min_x - sx;
sx += pixels;
- x_index_base += pixels*dx;
+ x_index_base += pixels * dx;
}
- if( sy < clip.min_y )
+ if (sy < clip.min_y)
{ /* clip top */
- int pixels = clip.min_y-sy;
+ int pixels = clip.min_y - sy;
sy += pixels;
- y_index += pixels*dy;
+ y_index += pixels * dy;
}
- if( ex > clip.max_x+1 )
+ if (ex > clip.max_x + 1)
{ /* clip right */
- int pixels = ex-clip.max_x-1;
+ int pixels = ex - clip.max_x - 1;
ex -= pixels;
}
- if( ey > clip.max_y+1 )
+ if (ey > clip.max_y + 1)
{ /* clip bottom */
- int pixels = ey-clip.max_y-1;
+ int pixels = ey - clip.max_y - 1;
ey -= pixels;
}
- if( ex>sx )
+ if (ex > sx)
{ /* skip if inner loop doesn't draw anything */
- int y;
bitmap_ind8 &priority_bitmap = screen.priority();
- if( priority_bitmap.valid() )
+ if (priority_bitmap.valid())
{
- for( y=sy; y<ey; y++ )
+ for (int y = sy; y < ey; y++)
{
- const uint8_t *source = source_base + (y_index>>16) * gfx->rowbytes();
- uint16_t *dest = &dest_bmp.pix16(y);
- uint8_t *pri = &priority_bitmap.pix8(y);
- int x, x_index = x_index_base;
+ const u8 *source = source_base + (y_index>>16) * gfx->rowbytes();
+ u16 *dest = &dest_bmp.pix16(y);
+ u8 *pri = &priority_bitmap.pix8(y);
+ int x_index = x_index_base;
/* this code was previously shared with the c355 where this was needed
- if( m_palxor )
+ if (m_palxor)
{
- for( x=sx; x<ex; x++ )
+ for (int x = sx; x < ex; x++)
{
- int c = source[x_index>>16];
- if( c != 0xff )
+ const u8 c = source[x_index >> 16];
+ if (c != 0xff)
{
- if( pri[x]<=zpos )
+ if (pri[x] <= zpos)
{
- switch( c )
+ switch(c)
{
case 0:
- dest[x] = 0x4000|(dest[x]&0x1fff);
+ dest[x] = 0x4000 | (dest[x] & 0x1fff);
break;
case 1:
- dest[x] = 0x6000|(dest[x]&0x1fff);
+ dest[x] = 0x6000 | (dest[x] & 0x1fff);
break;
default:
dest[x] = pal[c];
@@ -154,14 +153,14 @@ void namcos2_sprite_device::zdrawgfxzoom(
else
*/
{
- for( x=sx; x<ex; x++ )
+ for (int x = sx; x < ex; x++)
{
- int c = source[x_index>>16];
- if( c != 0xff )
+ const u8 c = source[x_index >> 16];
+ if (c != 0xff)
{
- if( pri[x]<=zpos )
+ if (pri[x] <= zpos)
{
- if( color == 0xf && c==0xfe && shadow_offset )
+ if (color == 0xf && c==0xfe && shadow_offset)
{
dest[x] |= shadow_offset;
}
@@ -187,21 +186,20 @@ void namcos2_sprite_device::zdrawgfxzoom(
void namcos2_sprite_device::zdrawgfxzoom(
screen_device &screen,
bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
- uint32_t code,uint32_t color,int flipx,int flipy,int sx,int sy,
- int scalex, int scaley, int zpos )
+ u32 code,u32 color,bool flipx,bool flipy,int sx,int sy,
+ int scalex, int scaley, int zpos)
{
/* nop */
}
-void namcos2_sprite_device::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int control )
+void namcos2_sprite_device::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int control)
{
- int offset = (control & 0x000f) * (128*4);
- int loop;
- if( pri==0 )
+ int offset = (control & 0x000f) * (128 * 4);
+ if (pri == 0)
{
- screen.priority().fill(0, cliprect );
+ screen.priority().fill(0, cliprect);
}
- for( loop=0; loop < 128; loop++ )
+ for (int loop = 0; loop < 128; loop++)
{
/****************************************
* word#0
@@ -211,8 +209,7 @@ void namcos2_sprite_device::draw_sprites(screen_device &screen, bitmap_ind16 &bi
*
* word#1
* Sprite Quadrant D00-D01
- * Sprite Number D02-D12
- * Sprite ROM Bank select D13
+ * Sprite Number D02-D13
* Sprite flip X D14
* Sprite flip Y D15
*
@@ -224,35 +221,34 @@ void namcos2_sprite_device::draw_sprites(screen_device &screen, bitmap_ind16 &bi
* Sprite colour index D04-D07
* Sprite Size X D10-D15
*/
- int word3 = m_spriteram[offset+(loop*4)+3];
- if( (word3&0xf)==pri )
+ const u16 word3 = m_spriteram[offset + (loop * 4) + 3];
+ if ((word3 & 0xf) == pri)
{
- int word0 = m_spriteram[offset+(loop*4)+0];
- int word1 = m_spriteram[offset+(loop*4)+1];
- int offset4 = m_spriteram[offset+(loop*4)+2];
+ const u16 word0 = m_spriteram[offset + (loop * 4) + 0];
+ const u16 word1 = m_spriteram[offset + (loop * 4) + 1];
+ const u16 offset4 = m_spriteram[offset + (loop * 4) + 2];
- int sizey=((word0>>10)&0x3f)+1;
- int sizex=(word3>>10)&0x3f;
+ const int sizey = ((word0 >> 10) & 0x003f) + 1;
+ int sizex = (word3 >> 10) & 0x003f;
- if((word0&0x0200)==0) sizex>>=1;
+ if ((word0 & 0x0200) == 0) sizex >>= 1;
- if((sizey-1) && sizex )
+ if ((sizey - 1) && sizex)
{
- int color = (word3>>4)&0x000f;
- int sprn = (word1>>2)&0x7ff;
- int rgn = (word1&0x2000)?1:0;
- int ypos = (0x1ff-(word0&0x01ff))-0x50+0x02;
- int xpos = (offset4&0x03ff)-0x50+0x07;
- int flipy = word1&0x8000;
- int flipx = word1&0x4000;
- int scalex = (sizex<<16)/((word0&0x0200)?0x20:0x10);
- int scaley = (sizey<<16)/((word0&0x0200)?0x20:0x10);
- if(scalex && scaley)
+ const u32 color = (word3 >> 4) & 0x000f;
+ const u32 sprn = (word1 >> 2) & 0x0fff;
+ const int ypos = (0x1ff - (word0 & 0x01ff)) - 0x50 + 0x02;
+ const int xpos = (offset4 & 0x03ff) - 0x50 + 0x07;
+ const bool flipy = word1 & 0x8000;
+ const bool flipx = word1 & 0x4000;
+ const int scalex = (sizex << 16) / ((word0 & 0x0200) ? 0x20 : 0x10);
+ const int scaley = (sizey << 16) / ((word0 & 0x0200) ? 0x20 : 0x10);
+ if (scalex && scaley)
{
- gfx_element *gfx = m_gfxdecode->gfx(rgn);
+ gfx_element *gfx = m_gfxdecode->gfx(0);
- if( (word0&0x0200)==0 )
- gfx->set_source_clip((word1&0x0001) ? 16 : 0, 16, (word1&0x0002) ? 16 : 0, 16);
+ if ((word0 & 0x0200) == 0)
+ gfx->set_source_clip((word1 & 0x0001) ? 16 : 0, 16, (word1 & 0x0002) ? 16 : 0, 16);
else
gfx->set_source_clip(0, 32, 0, 32);
@@ -266,14 +262,14 @@ void namcos2_sprite_device::draw_sprites(screen_device &screen, bitmap_ind16 &bi
flipx,flipy,
xpos,ypos,
scalex,scaley,
- loop );
+ loop);
}
}
}
}
-} /* namcos2_draw_sprites */
+} /* draw_sprites */
-void namcos2_sprite_device::draw_sprites_metalhawk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
+void namcos2_sprite_device::draw_sprites_metalhawk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri)
{
/**
* word#0
@@ -282,8 +278,7 @@ void namcos2_sprite_device::draw_sprites_metalhawk(screen_device &screen, bitmap
* -------xxxxxxxxx screeny
*
* word#1
- * --x------------- bank
- * ----xxxxxxxxxxxx tile
+ * --xxxxxxxxxxxxxx tile
*
* word#2 (unused)
*
@@ -305,62 +300,52 @@ void namcos2_sprite_device::draw_sprites_metalhawk(screen_device &screen, bitmap
* --------xxxx---- color
* x--------------- unknown
*/
- const uint16_t *pSource = m_spriteram;
- int loop;
- if( pri==0 )
+ const u16 *pSource = m_spriteram;
+ if (pri == 0)
{
- screen.priority().fill(0, cliprect );
+ screen.priority().fill(0, cliprect);
}
- for( loop=0; loop < 128; loop++ )
+ for (int loop=0; loop < 128; loop++)
{
- int ypos = pSource[0];
- int tile = pSource[1];
- int xpos = pSource[3];
- int flags = pSource[6];
- int attrs = pSource[7];
- int sizey = ((ypos>>10)&0x3f)+1;
- int sizex = (xpos>>10)&0x3f;
- int sprn = (tile>>2)&0x7ff;
-
- if( tile&0x2000 )
+ const u16 ypos = pSource[0];
+ const u16 tile = pSource[1];
+ const u16 xpos = pSource[3];
+ const u16 flags = pSource[6];
+ const u16 attrs = pSource[7];
+ const int sizey = ((ypos >> 10) & 0x003f) + 1;
+ const int sizex = (xpos >> 10) & 0x003f;
+ const u32 sprn = (tile >> 2) & 0x0fff;
+
+ if ((sizey - 1) && sizex && (attrs & 0xf) == pri)
{
- sprn&=0x3ff;
- }
- else
- {
- sprn|=0x400;
- }
-
- if( (sizey-1) && sizex && (attrs&0xf)==pri )
- {
- int bBigSprite = (flags&8);
- int color = (attrs>>4)&0xf;
- int sx = (xpos&0x03ff)-0x50+0x07;
- int sy = (0x1ff-(ypos&0x01ff))-0x50+0x02;
- int flipx = flags&2;
- int flipy = flags&4;
- int scalex = (sizex<<16)/(0x20);//(sizex<<16)/(bBigSprite?0x20:0x10); correct formula?
- int scaley = (sizey<<16)/(bBigSprite?0x20:0x10);
+ const bool bBigSprite = flags & 0x0008;
+ const u32 color = (attrs >> 4) & 0x000f;
+ int sx = (xpos & 0x03ff) - 0x50 + 0x07;
+ int sy = (0x1ff - (ypos & 0x01ff)) - 0x50 + 0x02;
+ const bool flipx = flags & 0x0002;
+ const bool flipy = flags & 0x0004;
+ const int scalex = (sizex << 16) / (0x20);//(sizex << 16) / (bBigSprite ? 0x20 : 0x10); correct formula?
+ const int scaley = (sizey << 16) / (bBigSprite ? 0x20 : 0x10);
/* swap xy */
- int rgn = (flags&0x01);
+ const int rgn = (flags & 0x0001);
gfx_element *gfx = m_gfxdecode->gfx(rgn);
- if( bBigSprite )
+ if (bBigSprite)
{
- if( sizex < 0x20 )
+ if (sizex < 0x20)
{
- sx -= (0x20-sizex)/0x8;
+ sx -= (0x20 - sizex) / 0x8;
}
- if( sizey < 0x20 )
+ if (sizey < 0x20)
{
- sy += (0x20-sizey)/0xC;
+ sy += (0x20 - sizey) / 0xC;
}
gfx->set_source_clip(0, 32, 0, 32);
}
else
- gfx->set_source_clip((tile&0x0001) ? 16 : 0, 16, (tile&0x0002) ? 16 : 0, 16);
+ gfx->set_source_clip((tile & 0x0001) ? 16 : 0, 16, (tile & 0x0002) ? 16 : 0, 16);
zdrawgfxzoom(
screen,
@@ -371,8 +356,8 @@ void namcos2_sprite_device::draw_sprites_metalhawk(screen_device &screen, bitmap
flipx,flipy,
sx,sy,
scalex, scaley,
- loop );
+ loop);
}
pSource += 8;
}
-} /* namcos2_draw_sprites_metalhawk */
+} /* draw_sprites_metalhawk */