mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
start collapsing the code (nw)
This commit is contained in:
parent
3dbb81e4f8
commit
c34738fbe0
@ -768,6 +768,7 @@ static MACHINE_CONFIG_START( shadoww, gaiden_state )
|
||||
MCFG_PALETTE_FORMAT(xxxxBBBBGGGGRRRR)
|
||||
|
||||
MCFG_DEVICE_ADD("spritegen", TECMO_SPRITE, 0)
|
||||
MCFG_TECMO_SPRITE_GFX_REGION(3)
|
||||
|
||||
MCFG_VIDEO_START_OVERRIDE(gaiden_state,gaiden)
|
||||
|
||||
|
@ -244,6 +244,7 @@ static MACHINE_CONFIG_START( galspnbl, galspnbl_state )
|
||||
MCFG_PALETTE_FORMAT(xxxxBBBBGGGGRRRR)
|
||||
|
||||
MCFG_DEVICE_ADD("spritegen", TECMO_SPRITE, 0)
|
||||
MCFG_TECMO_SPRITE_GFX_REGION(1)
|
||||
|
||||
/* sound hardware */
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
|
@ -431,6 +431,7 @@ static MACHINE_CONFIG_START( spbactn, spbactn_state )
|
||||
MCFG_PALETTE_FORMAT(xxxxBBBBGGGGRRRR)
|
||||
|
||||
MCFG_DEVICE_ADD("spritegen", TECMO_SPRITE, 0)
|
||||
MCFG_TECMO_SPRITE_GFX_REGION(2)
|
||||
|
||||
/* sound hardware */
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
@ -475,6 +476,7 @@ static MACHINE_CONFIG_START( spbactnp, spbactn_state )
|
||||
MCFG_PALETTE_FORMAT(xxxxBBBBRRRRGGGG)
|
||||
|
||||
MCFG_DEVICE_ADD("spritegen", TECMO_SPRITE, 0)
|
||||
MCFG_TECMO_SPRITE_GFX_REGION(2)
|
||||
|
||||
/* sound hardware - different? */
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
|
@ -386,6 +386,7 @@ static MACHINE_CONFIG_START( fstarfrc, tecmo16_state )
|
||||
MCFG_PALETTE_FORMAT(xxxxBBBBGGGGRRRR)
|
||||
|
||||
MCFG_DEVICE_ADD("spritegen", TECMO_SPRITE, 0)
|
||||
MCFG_TECMO_SPRITE_GFX_REGION(2)
|
||||
|
||||
/* sound hardware */
|
||||
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
DECLARE_VIDEO_START(ginkun);
|
||||
DECLARE_VIDEO_START(riot);
|
||||
UINT32 screen_update_tecmo16(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
void blendbitmaps(bitmap_rgb32 &dest, bitmap_ind16 &src1, bitmap_ind16 &src2, bitmap_ind16 &src3,
|
||||
int sx, int sy, const rectangle &cliprect);
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<cpu_device> m_audiocpu;
|
||||
required_device<gfxdecode_device> m_gfxdecode;
|
||||
|
@ -263,11 +263,6 @@ WRITE16_MEMBER(gaiden_state::gaiden_videoram_w)
|
||||
***************************************************************************/
|
||||
|
||||
/* mix & blend the paletted 16-bit tile and sprite bitmaps into an RGB 32-bit bitmap */
|
||||
|
||||
/* the source data is 3 16-bit indexed bitmaps, we use them to determine which 2 colours
|
||||
to blend into the final 32-bit rgb bitmaps, this is currently broken (due to zsolt's core
|
||||
changes?) it appears that the sprite drawing is no longer putting the correct raw data
|
||||
in the bitmaps? */
|
||||
void gaiden_state::blendbitmaps(bitmap_rgb32 &dest,bitmap_ind16 &src1,bitmap_ind16 &src2,bitmap_ind16 &src3,
|
||||
int sx,int sy,const rectangle &cliprect)
|
||||
{
|
||||
@ -407,7 +402,7 @@ UINT32 gaiden_state::screen_update_raiga(screen_device &screen, bitmap_rgb32 &bi
|
||||
m_text_layer->draw(screen, m_tile_bitmap_fg, cliprect, 0, 4);
|
||||
|
||||
/* draw sprites into a 16-bit bitmap */
|
||||
m_sprgen->raiga_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen());
|
||||
m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen());
|
||||
|
||||
/* mix & blend the tilemaps and sprites into a 32-bit bitmap */
|
||||
blendbitmaps(bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect);
|
||||
|
@ -193,110 +193,40 @@ WRITE16_MEMBER(tecmo16_state::tecmo16_scroll_char_y_w)
|
||||
/******************************************************************************/
|
||||
|
||||
/* mix & blend the paletted 16-bit tile and sprite bitmaps into an RGB 32-bit bitmap */
|
||||
static void blendbitmaps(palette_device &palette,
|
||||
bitmap_rgb32 &dest,bitmap_ind16 &src1,bitmap_ind16 &src2,bitmap_ind16 &src3,
|
||||
int sx,int sy,const rectangle &clip)
|
||||
void tecmo16_state::blendbitmaps(bitmap_rgb32 &dest,bitmap_ind16 &src1,bitmap_ind16 &src2,bitmap_ind16 &src3,
|
||||
int sx,int sy,const rectangle &cliprect)
|
||||
{
|
||||
int ox;
|
||||
int oy;
|
||||
int ex;
|
||||
int ey;
|
||||
|
||||
/* check bounds */
|
||||
ox = sx;
|
||||
oy = sy;
|
||||
|
||||
ex = sx + src1.width() - 1;
|
||||
if (sx < 0) sx = 0;
|
||||
if (sx < clip.min_x) sx = clip.min_x;
|
||||
if (ex >= dest.width()) ex = dest.width() - 1;
|
||||
if (ex > clip.max_x) ex = clip.max_x;
|
||||
if (sx > ex) return;
|
||||
|
||||
ey = sy + src1.height() - 1;
|
||||
if (sy < 0) sy = 0;
|
||||
if (sy < clip.min_y) sy = clip.min_y;
|
||||
if (ey >= dest.height()) ey = dest.height() - 1;
|
||||
if (ey > clip.max_y) ey = clip.max_y;
|
||||
if (sy > ey) return;
|
||||
int y,x;
|
||||
const pen_t *paldata = m_palette->pens();
|
||||
|
||||
for (y = cliprect.min_y; y <= cliprect.max_y; y++)
|
||||
{
|
||||
const pen_t *paldata = palette.pens();
|
||||
UINT32 *end;
|
||||
UINT32 *dd = &dest.pix32(y);
|
||||
UINT16 *sd1 = &src1.pix16(y);
|
||||
UINT16 *sd2 = &src2.pix16(y);
|
||||
UINT16 *sd3 = &src3.pix16(y);
|
||||
|
||||
UINT16 *sd1 = &src1.pix16(0);
|
||||
UINT16 *sd2 = &src2.pix16(0);
|
||||
UINT16 *sd3 = &src3.pix16(0);
|
||||
|
||||
int sw = ex-sx+1; /* source width */
|
||||
int sh = ey-sy+1; /* source height */
|
||||
int sm = src1.rowpixels(); /* source modulo */
|
||||
|
||||
UINT32 *dd = &dest.pix32(sy, sx); /* dest data */
|
||||
int dm = dest.rowpixels(); /* dest modulo */
|
||||
|
||||
sd1 += (sx-ox);
|
||||
sd1 += sm * (sy-oy);
|
||||
sd2 += (sx-ox);
|
||||
sd2 += sm * (sy-oy);
|
||||
sd3 += (sx-ox);
|
||||
sd3 += sm * (sy-oy);
|
||||
|
||||
sm -= sw;
|
||||
dm -= sw;
|
||||
|
||||
while (sh)
|
||||
for (x = cliprect.min_x; x <= cliprect.max_x; x++)
|
||||
{
|
||||
#define BLENDPIXEL(x) if (sd3[x]) { \
|
||||
if (sd2[x]) { \
|
||||
dd[x] = paldata[sd2[x] | 0x0400] + paldata[sd3[x]]; \
|
||||
} else { \
|
||||
dd[x] = paldata[sd1[x] | 0x0400] + paldata[sd3[x]]; \
|
||||
} \
|
||||
} else { \
|
||||
if (sd2[x]) { \
|
||||
if (sd2[x] & 0x0800) { \
|
||||
dd[x] = paldata[sd1[x] | 0x0400] + paldata[sd2[x]]; \
|
||||
} else { \
|
||||
dd[x] = paldata[sd2[x]]; \
|
||||
} \
|
||||
} else { \
|
||||
dd[x] = paldata[sd1[x]]; \
|
||||
} \
|
||||
if (sd3[x])
|
||||
{
|
||||
if (sd2[x])
|
||||
dd[x] = paldata[sd2[x] | 0x0400] | paldata[sd3[x]];
|
||||
else
|
||||
dd[x] = paldata[sd1[x] | 0x0400] | paldata[sd3[x]];
|
||||
}
|
||||
|
||||
end = dd + sw;
|
||||
while (dd <= end - 8)
|
||||
else
|
||||
{
|
||||
BLENDPIXEL(0);
|
||||
BLENDPIXEL(1);
|
||||
BLENDPIXEL(2);
|
||||
BLENDPIXEL(3);
|
||||
BLENDPIXEL(4);
|
||||
BLENDPIXEL(5);
|
||||
BLENDPIXEL(6);
|
||||
BLENDPIXEL(7);
|
||||
dd += 8;
|
||||
sd1 += 8;
|
||||
sd2 += 8;
|
||||
sd3 += 8;
|
||||
}
|
||||
while (dd < end)
|
||||
if (sd2[x])
|
||||
{
|
||||
BLENDPIXEL(0);
|
||||
dd++;
|
||||
sd1++;
|
||||
sd2++;
|
||||
sd3++;
|
||||
if (sd2[x] & 0x800)
|
||||
dd[x] = paldata[sd1[x] | 0x0400] | paldata[sd2[x]];
|
||||
else
|
||||
dd[x] = paldata[sd2[x]];
|
||||
}
|
||||
else
|
||||
dd[x] = paldata[sd1[x]];
|
||||
}
|
||||
dd += dm;
|
||||
sd1 += sm;
|
||||
sd2 += sm;
|
||||
sd3 += sm;
|
||||
sh--;
|
||||
|
||||
#undef BLENDPIXEL
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -320,9 +250,11 @@ UINT32 tecmo16_state::screen_update_tecmo16(screen_device &screen, bitmap_rgb32
|
||||
m_tx_tilemap->draw(screen, m_tile_bitmap_fg, cliprect, 0, 4);
|
||||
|
||||
/* draw sprites into a 16-bit bitmap */
|
||||
m_sprgen->tecmo16_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_spriteram.bytes(), m_game_is_riot, m_flipscreen);
|
||||
if (m_game_is_riot) m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, 0, 0, flip_screen());
|
||||
else m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, 2, 0, flip_screen());
|
||||
|
||||
|
||||
/* mix & blend the tilemaps and sprites into a 32-bit bitmap */
|
||||
blendbitmaps(m_palette, bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect);
|
||||
blendbitmaps(bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect);
|
||||
return 0;
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ const device_type TECMO_SPRITE = &device_creator<tecmo_spr_device>;
|
||||
|
||||
tecmo_spr_device::tecmo_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, TECMO_SPRITE, "Teccmo 16-bit Sprite", tag, owner, clock, "tecmo_spr", __FILE__),
|
||||
device_video_interface(mconfig, *this)
|
||||
device_video_interface(mconfig, *this),
|
||||
m_gfxregion(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -32,6 +33,13 @@ void tecmo_spr_device::device_reset()
|
||||
}
|
||||
|
||||
|
||||
void tecmo_spr_device::set_gfx_region(device_t &device, int gfxregion)
|
||||
{
|
||||
tecmo_spr_device &dev = downcast<tecmo_spr_device &>(device);
|
||||
dev.m_gfxregion = gfxregion;
|
||||
// printf("decospr_device::set_gfx_region()\n");
|
||||
}
|
||||
|
||||
|
||||
static const UINT8 layout[8][8] =
|
||||
{
|
||||
@ -138,9 +146,9 @@ int tecmo_spr_device::spbactn_draw_sprites(screen_device &screen, gfxdecode_devi
|
||||
int x = sx + 8 * (flipx ? (size - 1 - col) : col);
|
||||
int y = sy + 8 * (flipy ? (size - 1 - row) : row);
|
||||
|
||||
gfxdecode->gfx(2)->transpen_raw(bitmap,cliprect,
|
||||
gfxdecode->gfx(m_gfxregion)->transpen_raw(bitmap,cliprect,
|
||||
code + layout[row][col],
|
||||
gfxdecode->gfx(2)->colorbase() + color * gfxdecode->gfx(2)->granularity(),
|
||||
gfxdecode->gfx(m_gfxregion)->colorbase() + color * gfxdecode->gfx(2)->granularity(),
|
||||
flipx, flipy,
|
||||
x, y,
|
||||
0);
|
||||
@ -155,6 +163,120 @@ int tecmo_spr_device::spbactn_draw_sprites(screen_device &screen, gfxdecode_devi
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define NUM_SPRITES 256
|
||||
|
||||
void tecmo_spr_device::gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen )
|
||||
{
|
||||
gfx_element *gfx = gfxdecode->gfx(m_gfxregion);
|
||||
const UINT16 *source = (NUM_SPRITES - 1) * 8 + spriteram;
|
||||
int count = NUM_SPRITES;
|
||||
|
||||
/* draw all sprites from front to back */
|
||||
while (count--)
|
||||
{
|
||||
UINT32 attributes = source[0];
|
||||
UINT32 priority_mask;
|
||||
int col,row;
|
||||
|
||||
if (attributes & 0x04)
|
||||
{
|
||||
UINT32 priority = (attributes >> 6) & 3;
|
||||
UINT32 flipx = (attributes & 1);
|
||||
UINT32 flipy = (attributes & 2);
|
||||
|
||||
UINT32 color = source[2];
|
||||
UINT32 sizex = 1 << ((color >> 0) & 3); /* 1,2,4,8 */
|
||||
UINT32 sizey = 1 << ((color >> sprite_sizey) & 3); /* 1,2,4,8 */
|
||||
|
||||
/* raiga needs something like this */
|
||||
UINT32 number = (source[1] & (sizex > 2 ? 0x7ff8 : 0x7ffc));
|
||||
|
||||
int ypos = (source[3] + spr_offset_y) & 0x01ff;
|
||||
int xpos = source[4] & 0x01ff;
|
||||
|
||||
color = (color >> 4) & 0x0f;
|
||||
|
||||
/* wraparound */
|
||||
if (xpos >= 256)
|
||||
xpos -= 512;
|
||||
if (ypos >= 256)
|
||||
ypos -= 512;
|
||||
|
||||
if (flip_screen)
|
||||
{
|
||||
flipx = !flipx;
|
||||
flipy = !flipy;
|
||||
|
||||
xpos = 256 - (8 * sizex) - xpos;
|
||||
ypos = 256 - (8 * sizey) - ypos;
|
||||
|
||||
if (xpos <= -256)
|
||||
xpos += 512;
|
||||
if (ypos <= -256)
|
||||
ypos += 512;
|
||||
}
|
||||
|
||||
/* bg: 1; fg:2; text: 4 */
|
||||
switch( priority )
|
||||
{
|
||||
default:
|
||||
case 0x0: priority_mask = 0; break;
|
||||
case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */
|
||||
case 0x2: priority_mask = 0xf0 | 0xcc; break; /* obscured by foreground */
|
||||
case 0x3: priority_mask = 0xf0 | 0xcc | 0xaa; break; /* obscured by bg and fg */
|
||||
}
|
||||
|
||||
|
||||
/* blending */
|
||||
if (attributes & 0x20)
|
||||
{
|
||||
color |= 0x80;
|
||||
|
||||
for (row = 0; row < sizey; row++)
|
||||
{
|
||||
for (col = 0; col < sizex; col++)
|
||||
{
|
||||
int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
|
||||
int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
|
||||
|
||||
gfx->prio_transpen_raw(bitmap_sp,cliprect,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
screen.priority(), priority_mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg;
|
||||
|
||||
for (row = 0; row < sizey; row++)
|
||||
{
|
||||
for (col = 0; col < sizex; col++)
|
||||
{
|
||||
int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
|
||||
int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
|
||||
|
||||
gfx->prio_transpen_raw(bitmap,cliprect,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
screen.priority(), priority_mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
source -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// comad bootleg of spbactn
|
||||
void tecmo_spr_device::galspnbl_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes )
|
||||
{
|
||||
@ -187,7 +309,7 @@ void tecmo_spr_device::galspnbl_draw_sprites( screen_device &screen, gfxdecode_d
|
||||
{
|
||||
int x = sx + 8 * (flipx ? (size - 1 - col) : col);
|
||||
int y = sy + 8 * (flipy ? (size - 1 - row) : row);
|
||||
gfxdecode->gfx(1)->transpen(bitmap,cliprect,
|
||||
gfxdecode->gfx(m_gfxregion)->transpen(bitmap,cliprect,
|
||||
code + layout[row][col],
|
||||
color,
|
||||
flipx,flipy,
|
||||
@ -197,366 +319,3 @@ void tecmo_spr_device::galspnbl_draw_sprites( screen_device &screen, gfxdecode_d
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tecmo_spr_device::tecmo16_draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, UINT16 spriteram16_bytes, int game_is_riot, int flipscreen )
|
||||
{
|
||||
UINT16 *spriteram16 = spriteram;
|
||||
int offs;
|
||||
|
||||
bitmap_ind16 &bitmap = bitmap_bg;
|
||||
|
||||
for (offs = spriteram16_bytes/2 - 8;offs >= 0;offs -= 8)
|
||||
{
|
||||
if (spriteram16[offs] & 0x04) /* enable */
|
||||
{
|
||||
int code,color,sizex,sizey,flipx,flipy,xpos,ypos;
|
||||
int x,y,priority,priority_mask;
|
||||
|
||||
code = spriteram16[offs+1];
|
||||
color = (spriteram16[offs+2] & 0xf0) >> 4;
|
||||
sizex = 1 << ((spriteram16[offs+2] & 0x03) >> 0);
|
||||
|
||||
if(game_is_riot)
|
||||
sizey = sizex;
|
||||
else
|
||||
sizey = 1 << ((spriteram16[offs+2] & 0x0c) >> 2);
|
||||
|
||||
if (sizex >= 2) code &= ~0x01;
|
||||
if (sizey >= 2) code &= ~0x02;
|
||||
if (sizex >= 4) code &= ~0x04;
|
||||
if (sizey >= 4) code &= ~0x08;
|
||||
if (sizex >= 8) code &= ~0x10;
|
||||
if (sizey >= 8) code &= ~0x20;
|
||||
flipx = spriteram16[offs] & 0x01;
|
||||
flipy = spriteram16[offs] & 0x02;
|
||||
xpos = spriteram16[offs+4];
|
||||
if (xpos >= 0x8000) xpos -= 0x10000;
|
||||
ypos = spriteram16[offs+3];
|
||||
if (ypos >= 0x8000) ypos -= 0x10000;
|
||||
priority = (spriteram16[offs] & 0xc0) >> 6;
|
||||
|
||||
/* bg: 1; fg:2; text: 4 */
|
||||
switch (priority)
|
||||
{
|
||||
default:
|
||||
case 0x0: priority_mask = 0; break;
|
||||
case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */
|
||||
case 0x2: priority_mask = 0xf0|0xcc; break; /* obscured by foreground */
|
||||
case 0x3: priority_mask = 0xf0|0xcc|0xaa; break; /* obscured by bg and fg */
|
||||
}
|
||||
|
||||
if (flipscreen)
|
||||
{
|
||||
flipx = !flipx;
|
||||
flipy = !flipy;
|
||||
}
|
||||
|
||||
/* blending */
|
||||
if (spriteram16[offs] & 0x20)
|
||||
{
|
||||
color |= 0x80;
|
||||
|
||||
for (y = 0;y < sizey;y++)
|
||||
{
|
||||
for (x = 0;x < sizex;x++)
|
||||
{
|
||||
int sx,sy;
|
||||
|
||||
if (!flipscreen)
|
||||
{
|
||||
sx = xpos + 8*(flipx?(sizex-1-x):x);
|
||||
sy = ypos + 8*(flipy?(sizey-1-y):y);
|
||||
} else {
|
||||
sx = 256 - (xpos + 8*(!flipx?(sizex-1-x):x) + 8);
|
||||
sy = 256 - (ypos + 8*(!flipy?(sizey-1-y):y) + 8);
|
||||
}
|
||||
gfxdecode->gfx(2)->prio_transpen_raw(bitmap,cliprect,
|
||||
code + layout[y][x],
|
||||
gfxdecode->gfx(2)->colorbase() + color * gfxdecode->gfx(2)->granularity(),
|
||||
flipx,flipy,
|
||||
sx,sy,
|
||||
screen.priority(), priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
gfxdecode->gfx(2)->prio_transpen_raw(bitmap,cliprect,
|
||||
code + layout[y][x],
|
||||
gfxdecode->gfx(2)->colorbase() + color * gfxdecode->gfx(2)->granularity(),
|
||||
flipx,flipy,
|
||||
sx-512,sy,
|
||||
screen.priority(), priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
gfxdecode->gfx(2)->prio_transpen_raw(bitmap,cliprect,
|
||||
code + layout[y][x],
|
||||
gfxdecode->gfx(2)->colorbase() + color * gfxdecode->gfx(2)->granularity(),
|
||||
flipx,flipy,
|
||||
sx+512,sy,
|
||||
screen.priority(), priority_mask,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg;
|
||||
|
||||
for (y = 0;y < sizey;y++)
|
||||
{
|
||||
for (x = 0;x < sizex;x++)
|
||||
{
|
||||
int sx,sy;
|
||||
|
||||
if (!flipscreen)
|
||||
{
|
||||
sx = xpos + 8*(flipx?(sizex-1-x):x);
|
||||
sy = ypos + 8*(flipy?(sizey-1-y):y);
|
||||
} else {
|
||||
sx = 256 - (xpos + 8*(!flipx?(sizex-1-x):x) + 8);
|
||||
sy = 256 - (ypos + 8*(!flipy?(sizey-1-y):y) + 8);
|
||||
}
|
||||
gfxdecode->gfx(2)->prio_transpen_raw(bitmap,cliprect,
|
||||
code + layout[y][x],
|
||||
gfxdecode->gfx(2)->colorbase() + color * gfxdecode->gfx(2)->granularity(),
|
||||
flipx,flipy,
|
||||
sx,sy,
|
||||
screen.priority(), priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
gfxdecode->gfx(2)->prio_transpen_raw(bitmap,cliprect,
|
||||
code + layout[y][x],
|
||||
gfxdecode->gfx(2)->colorbase() + color * gfxdecode->gfx(2)->granularity(),
|
||||
flipx,flipy,
|
||||
sx-512,sy,
|
||||
screen.priority(), priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
gfxdecode->gfx(2)->prio_transpen_raw(bitmap,cliprect,
|
||||
code + layout[y][x],
|
||||
gfxdecode->gfx(2)->colorbase() + color * gfxdecode->gfx(2)->granularity(),
|
||||
flipx,flipy,
|
||||
sx+512,sy,
|
||||
screen.priority(), priority_mask,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define NUM_SPRITES 256
|
||||
|
||||
void tecmo_spr_device::gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen )
|
||||
{
|
||||
gfx_element *gfx = gfxdecode->gfx(3);
|
||||
const UINT16 *source = (NUM_SPRITES - 1) * 8 + spriteram;
|
||||
int count = NUM_SPRITES;
|
||||
|
||||
/* draw all sprites from front to back */
|
||||
while (count--)
|
||||
{
|
||||
UINT32 attributes = source[0];
|
||||
UINT32 priority_mask;
|
||||
int col,row;
|
||||
|
||||
if (attributes & 0x04)
|
||||
{
|
||||
UINT32 priority = (attributes >> 6) & 3;
|
||||
UINT32 flipx = (attributes & 1);
|
||||
UINT32 flipy = (attributes & 2);
|
||||
|
||||
UINT32 color = source[2];
|
||||
UINT32 sizex = 1 << ((color >> 0) & 3); /* 1,2,4,8 */
|
||||
UINT32 sizey = 1 << ((color >> sprite_sizey) & 3); /* 1,2,4,8 */
|
||||
|
||||
/* raiga needs something like this */
|
||||
UINT32 number = (source[1] & (sizex > 2 ? 0x7ff8 : 0x7ffc));
|
||||
|
||||
int ypos = (source[3] + spr_offset_y) & 0x01ff;
|
||||
int xpos = source[4] & 0x01ff;
|
||||
|
||||
color = (color >> 4) & 0x0f;
|
||||
|
||||
/* wraparound */
|
||||
if (xpos >= 256)
|
||||
xpos -= 512;
|
||||
if (ypos >= 256)
|
||||
ypos -= 512;
|
||||
|
||||
if (flip_screen)
|
||||
{
|
||||
flipx = !flipx;
|
||||
flipy = !flipy;
|
||||
|
||||
xpos = 256 - (8 * sizex) - xpos;
|
||||
ypos = 256 - (8 * sizey) - ypos;
|
||||
|
||||
if (xpos <= -256)
|
||||
xpos += 512;
|
||||
if (ypos <= -256)
|
||||
ypos += 512;
|
||||
}
|
||||
|
||||
/* bg: 1; fg:2; text: 4 */
|
||||
switch( priority )
|
||||
{
|
||||
default:
|
||||
case 0x0: priority_mask = 0; break;
|
||||
case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */
|
||||
case 0x2: priority_mask = 0xf0 | 0xcc; break; /* obscured by foreground */
|
||||
case 0x3: priority_mask = 0xf0 | 0xcc | 0xaa; break; /* obscured by bg and fg */
|
||||
}
|
||||
|
||||
|
||||
/* blending */
|
||||
if (attributes & 0x20)
|
||||
{
|
||||
color |= 0x80;
|
||||
|
||||
for (row = 0; row < sizey; row++)
|
||||
{
|
||||
for (col = 0; col < sizex; col++)
|
||||
{
|
||||
int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
|
||||
int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
|
||||
|
||||
gfx->prio_transpen_raw(bitmap_sp,cliprect,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
screen.priority(), priority_mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg;
|
||||
|
||||
for (row = 0; row < sizey; row++)
|
||||
{
|
||||
for (col = 0; col < sizex; col++)
|
||||
{
|
||||
int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
|
||||
int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
|
||||
|
||||
gfx->prio_transpen_raw(bitmap,cliprect,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
screen.priority(), priority_mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
source -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tecmo_spr_device::raiga_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen )
|
||||
{
|
||||
gfx_element *gfx = gfxdecode->gfx(3);
|
||||
const UINT16 *source = (NUM_SPRITES - 1) * 8 + spriteram;
|
||||
int count = NUM_SPRITES;
|
||||
|
||||
/* draw all sprites from front to back */
|
||||
while (count--)
|
||||
{
|
||||
UINT32 attributes = source[0];
|
||||
UINT32 priority_mask;
|
||||
int col,row;
|
||||
|
||||
if (attributes & 0x04)
|
||||
{
|
||||
UINT32 priority = (attributes >> 6) & 3;
|
||||
UINT32 flipx = (attributes & 1);
|
||||
UINT32 flipy = (attributes & 2);
|
||||
|
||||
UINT32 color = source[2];
|
||||
UINT32 sizex = 1 << ((color >> 0) & 3); /* 1,2,4,8 */
|
||||
UINT32 sizey = 1 << ((color >> sprite_sizey) & 3); /* 1,2,4,8 */
|
||||
|
||||
/* raiga needs something like this */
|
||||
UINT32 number = (source[1] & (sizex > 2 ? 0x7ff8 : 0x7ffc));
|
||||
|
||||
int ypos = (source[3] + spr_offset_y) & 0x01ff;
|
||||
int xpos = source[4] & 0x01ff;
|
||||
|
||||
color = (color >> 4) & 0x0f;
|
||||
|
||||
/* wraparound */
|
||||
if (xpos >= 256)
|
||||
xpos -= 512;
|
||||
if (ypos >= 256)
|
||||
ypos -= 512;
|
||||
|
||||
if (flip_screen)
|
||||
{
|
||||
flipx = !flipx;
|
||||
flipy = !flipy;
|
||||
|
||||
xpos = 256 - (8 * sizex) - xpos;
|
||||
ypos = 256 - (8 * sizey) - ypos;
|
||||
|
||||
if (xpos <= -256)
|
||||
xpos += 512;
|
||||
if (ypos <= -256)
|
||||
ypos += 512;
|
||||
}
|
||||
|
||||
/* bg: 1; fg:2; text: 4 */
|
||||
switch( priority )
|
||||
{
|
||||
default:
|
||||
case 0x0: priority_mask = 0; break;
|
||||
case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */
|
||||
case 0x2: priority_mask = 0xf0 | 0xcc; break; /* obscured by foreground */
|
||||
case 0x3: priority_mask = 0xf0 | 0xcc | 0xaa; break; /* obscured by bg and fg */
|
||||
}
|
||||
|
||||
/* blending */
|
||||
if (attributes & 0x20)
|
||||
{
|
||||
color |= 0x80;
|
||||
|
||||
for (row = 0; row < sizey; row++)
|
||||
{
|
||||
for (col = 0; col < sizex; col++)
|
||||
{
|
||||
int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
|
||||
int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
|
||||
|
||||
gfx->prio_transpen_raw(bitmap_sp,cliprect,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
screen.priority(), priority_mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg;
|
||||
|
||||
for (row = 0; row < sizey; row++)
|
||||
{
|
||||
for (col = 0; col < sizex; col++)
|
||||
{
|
||||
int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
|
||||
int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
|
||||
|
||||
gfx->prio_transpen_raw(bitmap,cliprect,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
screen.priority(), priority_mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
source -= 8;
|
||||
}
|
||||
}
|
||||
|
@ -7,20 +7,24 @@ class tecmo_spr_device : public device_t,
|
||||
{
|
||||
public:
|
||||
tecmo_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
static void set_gfx_region(device_t &device, int gfxregion);
|
||||
|
||||
void galspnbl_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes );
|
||||
void tecmo16_draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, UINT16 spriteram16_bytes, int game_is_riot, int flipscreen );
|
||||
void gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flipscreen );
|
||||
void raiga_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flipscreen );
|
||||
int spbactn_draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, bool alt_sprites, UINT16* spriteram);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
UINT8 m_gfxregion;
|
||||
private:
|
||||
};
|
||||
|
||||
extern const device_type TECMO_SPRITE;
|
||||
|
||||
|
||||
#define MCFG_TECMO_SPRITE_GFX_REGION(_region) \
|
||||
tecmo_spr_device::set_gfx_region(*device, _region);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user