mirror of
https://github.com/holub/mame
synced 2025-04-21 16:01:56 +03:00
shuffle some tecmo sprite code around ready for device conversion / attempting to unify it a bit (nw)
This commit is contained in:
parent
583d8d754f
commit
c736577005
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -5676,6 +5676,8 @@ src/mame/video/tbowl.c svneol=native#text/plain
|
||||
src/mame/video/tceptor.c svneol=native#text/plain
|
||||
src/mame/video/tecmo.c svneol=native#text/plain
|
||||
src/mame/video/tecmo16.c svneol=native#text/plain
|
||||
src/mame/video/tecmo_spr.c svneol=native#text/plain
|
||||
src/mame/video/tecmo_spr.h svneol=native#text/plain
|
||||
src/mame/video/tecmosys.c svneol=native#text/plain
|
||||
src/mame/video/tehkanwc.c svneol=native#text/plain
|
||||
src/mame/video/terracre.c svneol=native#text/plain
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "video/tecmo_spr.h"
|
||||
|
||||
class gaiden_state : public driver_device
|
||||
{
|
||||
public:
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
*************************************************************************/
|
||||
|
||||
#include "video/tecmo_spr.h"
|
||||
|
||||
class galspnbl_state : public driver_device
|
||||
{
|
||||
public:
|
||||
|
@ -1,3 +1,6 @@
|
||||
|
||||
#include "video/tecmo_spr.h"
|
||||
|
||||
class spbactn_state : public driver_device
|
||||
{
|
||||
public:
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
class tbowl_state : public driver_device
|
||||
{
|
||||
public:
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "video/tecmo_spr.h"
|
||||
|
||||
class tecmo16_state : public driver_device
|
||||
{
|
||||
public:
|
||||
|
@ -1538,6 +1538,7 @@ $(MAMEOBJ)/technos.a: \
|
||||
$(DRIVERS)/xain.o $(VIDEO)/xain.o \
|
||||
|
||||
$(MAMEOBJ)/tehkan.a: \
|
||||
$(VIDEO)/tecmo_spr.o \
|
||||
$(DRIVERS)/bombjack.o $(VIDEO)/bombjack.o \
|
||||
$(DRIVERS)/gaiden.o $(VIDEO)/gaiden.o \
|
||||
$(DRIVERS)/lvcards.o $(VIDEO)/lvcards.o \
|
||||
|
@ -311,269 +311,7 @@ static void blendbitmaps(running_machine &machine,
|
||||
}
|
||||
}
|
||||
|
||||
/* sprite format:
|
||||
*
|
||||
* word bit usage
|
||||
* --------+-fedcba9876543210-+----------------
|
||||
* 0 | ---------------x | flip x
|
||||
* | --------------x- | flip y
|
||||
* | -------------x-- | enable
|
||||
* | ----------x----- | blend
|
||||
* | --------xx------ | sprite-tile priority
|
||||
* 1 | xxxxxxxxxxxxxxxx | number
|
||||
* 2 | --------xxxx---- | palette
|
||||
* | --------------xx | size: 8x8, 16x16, 32x32, 64x64
|
||||
* 3 | xxxxxxxxxxxxxxxx | y position
|
||||
* 4 | xxxxxxxxxxxxxxxx | x position
|
||||
* 5,6,7| | unused
|
||||
*/
|
||||
|
||||
#define NUM_SPRITES 256
|
||||
|
||||
static void gaiden_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect )
|
||||
{
|
||||
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}
|
||||
};
|
||||
|
||||
gaiden_state *state = machine.driver_data<gaiden_state>();
|
||||
gfx_element *gfx = machine.gfx[3];
|
||||
const UINT16 *source = (NUM_SPRITES - 1) * 8 + state->m_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 >> state->m_sprite_sizey) & 3); /* 1,2,4,8 */
|
||||
|
||||
/* raiga needs something like this */
|
||||
UINT32 number = (source[1] & (sizex > 2 ? 0x7ff8 : 0x7ffc));
|
||||
|
||||
int ypos = (source[3] + state->m_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 (state->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);
|
||||
|
||||
pdrawgfx_transpen_raw(bitmap_sp, cliprect, gfx,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
machine.priority_bitmap, 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);
|
||||
|
||||
pdrawgfx_transpen_raw(bitmap, cliprect, gfx,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
machine.priority_bitmap, priority_mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
source -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void raiga_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect )
|
||||
{
|
||||
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}
|
||||
};
|
||||
|
||||
gaiden_state *state = machine.driver_data<gaiden_state>();
|
||||
gfx_element *gfx = machine.gfx[3];
|
||||
const UINT16 *source = (NUM_SPRITES - 1) * 8 + state->m_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 >> state->m_sprite_sizey) & 3); /* 1,2,4,8 */
|
||||
|
||||
/* raiga needs something like this */
|
||||
UINT32 number = (source[1] & (sizex > 2 ? 0x7ff8 : 0x7ffc));
|
||||
|
||||
int ypos = (source[3] + state->m_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 (state->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);
|
||||
|
||||
pdrawgfx_transpen_raw(bitmap_sp, cliprect, gfx,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
machine.priority_bitmap, 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);
|
||||
|
||||
pdrawgfx_transpen_raw(bitmap, cliprect, gfx,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
machine.priority_bitmap, priority_mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
source -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// dragon bowl uses a bootleg format
|
||||
/* sprite format:
|
||||
*
|
||||
* word bit usage
|
||||
@ -650,7 +388,7 @@ UINT32 gaiden_state::screen_update_gaiden(screen_device &screen, bitmap_rgb32 &b
|
||||
m_text_layer->draw(m_tile_bitmap_fg, cliprect, 0, 4);
|
||||
|
||||
/* draw sprites into a 16-bit bitmap */
|
||||
gaiden_draw_sprites(machine(), m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect);
|
||||
gaiden_draw_sprites(machine(), 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(machine(), bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect);
|
||||
@ -675,7 +413,7 @@ UINT32 gaiden_state::screen_update_raiga(screen_device &screen, bitmap_rgb32 &bi
|
||||
m_text_layer->draw(m_tile_bitmap_fg, cliprect, 0, 4);
|
||||
|
||||
/* draw sprites into a 16-bit bitmap */
|
||||
raiga_draw_sprites(machine(), m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect);
|
||||
raiga_draw_sprites(machine(), 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(machine(), bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect);
|
||||
|
@ -13,77 +13,6 @@ void galspnbl_state::palette_init()
|
||||
|
||||
|
||||
|
||||
/* sprite format (see also Ninja Gaiden):
|
||||
*
|
||||
* word bit usage
|
||||
* --------+-fedcba9876543210-+----------------
|
||||
* 0 | ---------------x | flip x
|
||||
* | --------------x- | flip y
|
||||
* | -------------x-- | enable
|
||||
* | ----------xx---- | priority?
|
||||
* | ---------x------ | flicker?
|
||||
* 1 | xxxxxxxxxxxxxxxx | code
|
||||
* 2 | --------xxxx---- | color
|
||||
* | --------------xx | size: 8x8, 16x16, 32x32, 64x64
|
||||
* 3 | xxxxxxxxxxxxxxxx | y position
|
||||
* 4 | xxxxxxxxxxxxxxxx | x position
|
||||
* 5,6,7| | unused
|
||||
*/
|
||||
static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
|
||||
{
|
||||
galspnbl_state *state = machine.driver_data<galspnbl_state>();
|
||||
UINT16 *spriteram = state->m_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 = (state->m_spriteram.bytes() - 16) / 2; offs >= 0; offs -= 8)
|
||||
{
|
||||
int sx, sy, code, color, size, attr, flipx, flipy;
|
||||
int col, row;
|
||||
|
||||
attr = spriteram[offs];
|
||||
if ((attr & 0x0004) && ((attr & 0x0040) == 0 || (machine.primary_screen->frame_number() & 1))
|
||||
// && ((attr & 0x0030) >> 4) == priority)
|
||||
&& ((attr & 0x0020) >> 5) == priority)
|
||||
{
|
||||
code = spriteram[offs + 1];
|
||||
color = spriteram[offs + 2];
|
||||
size = 1 << (color & 0x0003); // 1,2,4,8
|
||||
color = (color & 0x00f0) >> 4;
|
||||
// sx = spriteram[offs + 4] + screenscroll;
|
||||
sx = spriteram[offs + 4];
|
||||
sy = spriteram[offs + 3];
|
||||
flipx = attr & 0x0001;
|
||||
flipy = attr & 0x0002;
|
||||
|
||||
for (row = 0; row < size; row++)
|
||||
{
|
||||
for (col = 0; col < size; col++)
|
||||
{
|
||||
int x = sx + 8 * (flipx ? (size - 1 - col) : col);
|
||||
int y = sy + 8 * (flipy ? (size - 1 - row) : row);
|
||||
drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
|
||||
code + layout[row][col],
|
||||
color,
|
||||
flipx,flipy,
|
||||
x,y,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void draw_background( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
|
||||
{
|
||||
galspnbl_state *state = machine.driver_data<galspnbl_state>();
|
||||
@ -107,7 +36,7 @@ UINT32 galspnbl_state::screen_update_galspnbl(screen_device &screen, bitmap_ind1
|
||||
|
||||
draw_background(machine(), bitmap, cliprect);
|
||||
|
||||
draw_sprites(machine(), bitmap, cliprect, 0);
|
||||
galspnbl_draw_sprites(machine(), bitmap, cliprect, 0, m_spriteram, m_spriteram.bytes());
|
||||
|
||||
for (offs = 0; offs < 0x1000 / 2; offs++)
|
||||
{
|
||||
@ -131,6 +60,6 @@ UINT32 galspnbl_state::screen_update_galspnbl(screen_device &screen, bitmap_ind1
|
||||
}
|
||||
}
|
||||
|
||||
draw_sprites(machine(), bitmap, cliprect, 1);
|
||||
galspnbl_draw_sprites(machine(), bitmap, cliprect, 1, m_spriteram, m_spriteram.bytes());
|
||||
return 0;
|
||||
}
|
||||
|
@ -32,90 +32,6 @@ static void blendbitmaps(running_machine &machine,
|
||||
}
|
||||
|
||||
|
||||
/* from gals pinball (which was in turn from ninja gaiden) */
|
||||
static int draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, bool alt_sprites)
|
||||
{
|
||||
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}
|
||||
};
|
||||
|
||||
spbactn_state *state = machine.driver_data<spbactn_state>();
|
||||
int count = 0;
|
||||
int offs;
|
||||
|
||||
for (offs = (0x1000 - 16) / 2; offs >= 0; offs -= 8)
|
||||
{
|
||||
int sx, sy, code, color, size, attr, flipx, flipy;
|
||||
int col, row;
|
||||
|
||||
attr = state->m_spvideoram[offs];
|
||||
|
||||
int pri = (state->m_spvideoram[offs] & 0x0030);
|
||||
// int pri = (state->m_spvideoram[offs+2] & 0x0030);
|
||||
|
||||
|
||||
if ((attr & 0x0004) &&
|
||||
((pri & 0x0030) >> 4) == priority)
|
||||
{
|
||||
flipx = attr & 0x0001;
|
||||
flipy = attr & 0x0002;
|
||||
|
||||
code = state->m_spvideoram[offs + 1];
|
||||
|
||||
if (alt_sprites)
|
||||
{
|
||||
color = state->m_spvideoram[offs + 0];
|
||||
}
|
||||
else
|
||||
{
|
||||
color = state->m_spvideoram[offs + 2];
|
||||
}
|
||||
|
||||
size = 1 << (state->m_spvideoram[offs + 2] & 0x0003); /* 1,2,4,8 */
|
||||
color = (color & 0x00f0) >> 4;
|
||||
|
||||
sx = state->m_spvideoram[offs + 4];
|
||||
sy = state->m_spvideoram[offs + 3];
|
||||
|
||||
attr &= ~0x0040; /* !!! */
|
||||
|
||||
if (attr & 0x0040)
|
||||
color |= 0x0180;
|
||||
else
|
||||
color |= 0x0080;
|
||||
|
||||
|
||||
for (row = 0; row < size; row++)
|
||||
{
|
||||
for (col = 0; col < size; col++)
|
||||
{
|
||||
int x = sx + 8 * (flipx ? (size - 1 - col) : col);
|
||||
int y = sy + 8 * (flipy ? (size - 1 - row) : row);
|
||||
|
||||
drawgfx_transpen_raw(bitmap, cliprect, machine.gfx[2],
|
||||
code + layout[row][col],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx, flipy,
|
||||
x, y,
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
WRITE16_MEMBER(spbactn_state::bg_videoram_w)
|
||||
{
|
||||
@ -238,18 +154,18 @@ int spbactn_state::draw_video(screen_device &screen, bitmap_rgb32 &bitmap, const
|
||||
|
||||
|
||||
|
||||
if (draw_sprites(machine(), m_tile_bitmap_bg, cliprect, 0, alt_sprites))
|
||||
if (spbactn_draw_sprites(machine(), m_tile_bitmap_bg, cliprect, 0, alt_sprites, m_spvideoram))
|
||||
{
|
||||
m_bg_tilemap->draw(m_tile_bitmap_bg, cliprect, 0, 0);
|
||||
}
|
||||
|
||||
draw_sprites(machine(), m_tile_bitmap_bg, cliprect, 1, alt_sprites);
|
||||
spbactn_draw_sprites(machine(), m_tile_bitmap_bg, cliprect, 1, alt_sprites, m_spvideoram);
|
||||
|
||||
m_fg_tilemap->draw(m_tile_bitmap_fg, cliprect, 0, 0);
|
||||
|
||||
|
||||
draw_sprites(machine(), m_tile_bitmap_fg, cliprect, 2, alt_sprites);
|
||||
draw_sprites(machine(), m_tile_bitmap_fg, cliprect, 3, alt_sprites);
|
||||
spbactn_draw_sprites(machine(), m_tile_bitmap_fg, cliprect, 2, alt_sprites, m_spvideoram);
|
||||
spbactn_draw_sprites(machine(), m_tile_bitmap_fg, cliprect, 3, alt_sprites, m_spvideoram);
|
||||
|
||||
/* mix & blend the tilemaps and sprites into a 32-bit bitmap */
|
||||
blendbitmaps(machine(), bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, cliprect);
|
||||
|
@ -104,9 +104,23 @@ WRITE8_MEMBER(tbowl_state::tbowl_bg2yscroll_hi)
|
||||
m_bg2yscroll = (m_bg2yscroll & 0x00ff) | (data << 8);
|
||||
}
|
||||
|
||||
static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect, int xscroll)
|
||||
|
||||
/*** Video Start / Update ***/
|
||||
|
||||
void tbowl_state::video_start()
|
||||
{
|
||||
m_tx_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_tx_tile_info),this),TILEMAP_SCAN_ROWS, 8, 8,64,32);
|
||||
m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_bg_tile_info),this),TILEMAP_SCAN_ROWS, 16, 16,128,32);
|
||||
m_bg2_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_bg2_tile_info),this),TILEMAP_SCAN_ROWS, 16, 16,128,32);
|
||||
|
||||
m_tx_tilemap->set_transparent_pen(0);
|
||||
m_bg_tilemap->set_transparent_pen(0);
|
||||
m_bg2_tilemap->set_transparent_pen(0);
|
||||
}
|
||||
|
||||
|
||||
void tbowl_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect, int xscroll, UINT8* spriteram)
|
||||
{
|
||||
tbowl_state *state = machine.driver_data<tbowl_state>();
|
||||
int offs;
|
||||
static const UINT8 layout[8][8] =
|
||||
{
|
||||
@ -122,20 +136,20 @@ static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const re
|
||||
|
||||
for (offs = 0;offs < 0x800;offs += 8)
|
||||
{
|
||||
if (state->m_spriteram[offs+0] & 0x80) /* enable */
|
||||
if (spriteram[offs+0] & 0x80) /* enable */
|
||||
{
|
||||
int code,color,sizex,sizey,flipx,flipy,xpos,ypos;
|
||||
int x,y;//,priority,priority_mask;
|
||||
|
||||
code = (state->m_spriteram[offs+2])+(state->m_spriteram[offs+1]<<8);
|
||||
color = (state->m_spriteram[offs+3])&0x1f;
|
||||
sizex = 1 << ((state->m_spriteram[offs+0] & 0x03) >> 0);
|
||||
sizey = 1 << ((state->m_spriteram[offs+0] & 0x0c) >> 2);
|
||||
code = (spriteram[offs+2])+(spriteram[offs+1]<<8);
|
||||
color = (spriteram[offs+3])&0x1f;
|
||||
sizex = 1 << ((spriteram[offs+0] & 0x03) >> 0);
|
||||
sizey = 1 << ((spriteram[offs+0] & 0x0c) >> 2);
|
||||
|
||||
flipx = (state->m_spriteram[offs+0])&0x20;
|
||||
flipx = (spriteram[offs+0])&0x20;
|
||||
flipy = 0;
|
||||
xpos = (state->m_spriteram[offs+6])+((state->m_spriteram[offs+4]&0x03)<<8);
|
||||
ypos = (state->m_spriteram[offs+5])+((state->m_spriteram[offs+4]&0x10)<<4);
|
||||
xpos = (spriteram[offs+6])+((spriteram[offs+4]&0x03)<<8);
|
||||
ypos = (spriteram[offs+5])+((spriteram[offs+4]&0x10)<<4);
|
||||
|
||||
/* bg: 1; fg:2; text: 4 */
|
||||
|
||||
@ -181,24 +195,8 @@ static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const re
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*** Video Start / Update ***/
|
||||
|
||||
void tbowl_state::video_start()
|
||||
{
|
||||
m_tx_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_tx_tile_info),this),TILEMAP_SCAN_ROWS, 8, 8,64,32);
|
||||
m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_bg_tile_info),this),TILEMAP_SCAN_ROWS, 16, 16,128,32);
|
||||
m_bg2_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_bg2_tile_info),this),TILEMAP_SCAN_ROWS, 16, 16,128,32);
|
||||
|
||||
m_tx_tilemap->set_transparent_pen(0);
|
||||
m_bg_tilemap->set_transparent_pen(0);
|
||||
m_bg2_tilemap->set_transparent_pen(0);
|
||||
}
|
||||
|
||||
|
||||
UINT32 tbowl_state::screen_update_tbowl_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
m_bg_tilemap->set_scrollx(0, m_xscroll );
|
||||
@ -210,7 +208,7 @@ UINT32 tbowl_state::screen_update_tbowl_left(screen_device &screen, bitmap_ind16
|
||||
|
||||
bitmap.fill(0x100, cliprect); /* is there a register controling the colour? looks odd when screen is blank */
|
||||
m_bg_tilemap->draw(bitmap, cliprect, 0,0);
|
||||
draw_sprites(machine(), bitmap,cliprect, 0);
|
||||
tbowl_draw_sprites(machine(), bitmap,cliprect, 0, m_spriteram);
|
||||
m_bg2_tilemap->draw(bitmap, cliprect, 0,0);
|
||||
m_tx_tilemap->draw(bitmap, cliprect, 0,0);
|
||||
|
||||
@ -228,7 +226,7 @@ UINT32 tbowl_state::screen_update_tbowl_right(screen_device &screen, bitmap_ind1
|
||||
|
||||
bitmap.fill(0x100, cliprect); /* is there a register controling the colour? looks odd when screen is blank */
|
||||
m_bg_tilemap->draw(bitmap, cliprect, 0,0);
|
||||
draw_sprites(machine(), bitmap,cliprect, 32*8);
|
||||
tbowl_draw_sprites(machine(), bitmap,cliprect, 32*8, m_spriteram);
|
||||
m_bg2_tilemap->draw(bitmap, cliprect, 0,0);
|
||||
m_tx_tilemap->draw(bitmap, cliprect, 0,0);
|
||||
|
||||
|
@ -304,162 +304,6 @@ static void blendbitmaps(running_machine &machine,
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect)
|
||||
{
|
||||
tecmo16_state *state = machine.driver_data<tecmo16_state>();
|
||||
UINT16 *spriteram16 = state->m_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}
|
||||
};
|
||||
|
||||
bitmap_ind16 &bitmap = bitmap_bg;
|
||||
|
||||
for (offs = state->m_spriteram.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(state->m_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 (state->m_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 (!state->m_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);
|
||||
}
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx,sy,
|
||||
machine.priority_bitmap, priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx-512,sy,
|
||||
machine.priority_bitmap, priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx+512,sy,
|
||||
machine.priority_bitmap, 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 (!state->m_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);
|
||||
}
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx,sy,
|
||||
machine.priority_bitmap, priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx-512,sy,
|
||||
machine.priority_bitmap, priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx+512,sy,
|
||||
machine.priority_bitmap, priority_mask,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
UINT32 tecmo16_state::screen_update_tecmo16(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
@ -479,7 +323,7 @@ UINT32 tecmo16_state::screen_update_tecmo16(screen_device &screen, bitmap_rgb32
|
||||
m_tx_tilemap->draw(m_tile_bitmap_fg, cliprect, 0, 4);
|
||||
|
||||
/* draw sprites into a 16-bit bitmap */
|
||||
draw_sprites(machine(), m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect);
|
||||
tecmo16_draw_sprites(machine(), m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_spriteram.bytes(), m_game_is_riot, m_flipscreen);
|
||||
|
||||
/* mix & blend the tilemaps and sprites into a 32-bit bitmap */
|
||||
blendbitmaps(machine(), bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect);
|
||||
|
546
src/mame/video/tecmo_spr.c
Normal file
546
src/mame/video/tecmo_spr.c
Normal file
@ -0,0 +1,546 @@
|
||||
/* Various Tecmo Sprite implementations
|
||||
- for unifying and converting to a device
|
||||
|
||||
- check wc90.c, tecmo.c, tbowl.c others? - they seem more significantly different but are they close to each other
|
||||
(but at the same time use the same 'layout' table as this implementation)
|
||||
|
||||
- is there a single chip responsible for these, or is it just a family of closely connected implementations?
|
||||
(because we seem to need some per-game code right now)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "emu.h"
|
||||
#include "tecmo_spr.h"
|
||||
|
||||
|
||||
|
||||
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}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/* sprite format (gaiden):
|
||||
*
|
||||
* word bit usage
|
||||
* --------+-fedcba9876543210-+----------------
|
||||
* 0 | ---------------x | flip x
|
||||
* | --------------x- | flip y
|
||||
* | -------------x-- | enable
|
||||
* | ----------x----- | blend
|
||||
* | --------xx------ | sprite-tile priority
|
||||
* 1 | xxxxxxxxxxxxxxxx | number
|
||||
* 2 | --------xxxx---- | palette
|
||||
* | --------------xx | size: 8x8, 16x16, 32x32, 64x64
|
||||
* 3 | xxxxxxxxxxxxxxxx | y position
|
||||
* 4 | xxxxxxxxxxxxxxxx | x position
|
||||
* 5,6,7| | unused
|
||||
*/
|
||||
|
||||
/* sprite format (galspnbl):
|
||||
*
|
||||
* word bit usage
|
||||
* --------+-fedcba9876543210-+----------------
|
||||
* 0 | ---------------x | flip x
|
||||
* | --------------x- | flip y
|
||||
* | -------------x-- | enable
|
||||
* | ----------xx---- | priority?
|
||||
* | ---------x------ | flicker?
|
||||
* 1 | xxxxxxxxxxxxxxxx | code
|
||||
* 2 | --------xxxx---- | color
|
||||
* | --------------xx | size: 8x8, 16x16, 32x32, 64x64
|
||||
* 3 | xxxxxxxxxxxxxxxx | y position
|
||||
* 4 | xxxxxxxxxxxxxxxx | x position
|
||||
* 5,6,7| | unused
|
||||
*/
|
||||
|
||||
|
||||
/* from gals pinball (which was in turn from ninja gaiden) */
|
||||
int spbactn_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, bool alt_sprites, UINT16* spriteram)
|
||||
{
|
||||
int count = 0;
|
||||
int offs;
|
||||
|
||||
for (offs = (0x1000 - 16) / 2; offs >= 0; offs -= 8)
|
||||
{
|
||||
int sx, sy, code, color, size, attr, flipx, flipy;
|
||||
int col, row;
|
||||
|
||||
attr = spriteram[offs];
|
||||
|
||||
int pri = (spriteram[offs] & 0x0030);
|
||||
// int pri = (spriteram[offs+2] & 0x0030);
|
||||
|
||||
|
||||
if ((attr & 0x0004) &&
|
||||
((pri & 0x0030) >> 4) == priority)
|
||||
{
|
||||
flipx = attr & 0x0001;
|
||||
flipy = attr & 0x0002;
|
||||
|
||||
code = spriteram[offs + 1];
|
||||
|
||||
if (alt_sprites)
|
||||
{
|
||||
color = spriteram[offs + 0];
|
||||
}
|
||||
else
|
||||
{
|
||||
color = spriteram[offs + 2];
|
||||
}
|
||||
|
||||
size = 1 << (spriteram[offs + 2] & 0x0003); /* 1,2,4,8 */
|
||||
color = (color & 0x00f0) >> 4;
|
||||
|
||||
sx = spriteram[offs + 4];
|
||||
sy = spriteram[offs + 3];
|
||||
|
||||
attr &= ~0x0040; /* !!! */
|
||||
|
||||
if (attr & 0x0040)
|
||||
color |= 0x0180;
|
||||
else
|
||||
color |= 0x0080;
|
||||
|
||||
|
||||
for (row = 0; row < size; row++)
|
||||
{
|
||||
for (col = 0; col < size; col++)
|
||||
{
|
||||
int x = sx + 8 * (flipx ? (size - 1 - col) : col);
|
||||
int y = sy + 8 * (flipy ? (size - 1 - row) : row);
|
||||
|
||||
drawgfx_transpen_raw(bitmap, cliprect, machine.gfx[2],
|
||||
code + layout[row][col],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx, flipy,
|
||||
x, y,
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
// comad bootleg of spbactn
|
||||
void galspnbl_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes )
|
||||
{
|
||||
int offs;
|
||||
|
||||
|
||||
for (offs = (spriteram_bytes - 16) / 2; offs >= 0; offs -= 8)
|
||||
{
|
||||
int sx, sy, code, color, size, attr, flipx, flipy;
|
||||
int col, row;
|
||||
|
||||
attr = spriteram[offs];
|
||||
if ((attr & 0x0004) && ((attr & 0x0040) == 0 || (machine.primary_screen->frame_number() & 1))
|
||||
// && ((attr & 0x0030) >> 4) == priority)
|
||||
&& ((attr & 0x0020) >> 5) == priority)
|
||||
{
|
||||
code = spriteram[offs + 1];
|
||||
color = spriteram[offs + 2];
|
||||
size = 1 << (color & 0x0003); // 1,2,4,8
|
||||
color = (color & 0x00f0) >> 4;
|
||||
// sx = spriteram[offs + 4] + screenscroll;
|
||||
sx = spriteram[offs + 4];
|
||||
sy = spriteram[offs + 3];
|
||||
flipx = attr & 0x0001;
|
||||
flipy = attr & 0x0002;
|
||||
|
||||
for (row = 0; row < size; row++)
|
||||
{
|
||||
for (col = 0; col < size; col++)
|
||||
{
|
||||
int x = sx + 8 * (flipx ? (size - 1 - col) : col);
|
||||
int y = sy + 8 * (flipy ? (size - 1 - row) : row);
|
||||
drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
|
||||
code + layout[row][col],
|
||||
color,
|
||||
flipx,flipy,
|
||||
x,y,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tecmo16_draw_sprites(running_machine &machine, 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);
|
||||
}
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx,sy,
|
||||
machine.priority_bitmap, priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx-512,sy,
|
||||
machine.priority_bitmap, priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx+512,sy,
|
||||
machine.priority_bitmap, 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);
|
||||
}
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx,sy,
|
||||
machine.priority_bitmap, priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx-512,sy,
|
||||
machine.priority_bitmap, priority_mask,0);
|
||||
|
||||
/* wrap around x */
|
||||
pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2],
|
||||
code + layout[y][x],
|
||||
machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(),
|
||||
flipx,flipy,
|
||||
sx+512,sy,
|
||||
machine.priority_bitmap, priority_mask,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define NUM_SPRITES 256
|
||||
|
||||
void gaiden_draw_sprites( running_machine &machine, 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 = machine.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);
|
||||
|
||||
pdrawgfx_transpen_raw(bitmap_sp, cliprect, gfx,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
machine.priority_bitmap, 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);
|
||||
|
||||
pdrawgfx_transpen_raw(bitmap, cliprect, gfx,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
machine.priority_bitmap, priority_mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
source -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void raiga_draw_sprites( running_machine &machine, 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 = machine.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);
|
||||
|
||||
pdrawgfx_transpen_raw(bitmap_sp, cliprect, gfx,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
machine.priority_bitmap, 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);
|
||||
|
||||
pdrawgfx_transpen_raw(bitmap, cliprect, gfx,
|
||||
number + layout[row][col],
|
||||
gfx->colorbase() + color * gfx->granularity(),
|
||||
flipx, flipy,
|
||||
sx, sy,
|
||||
machine.priority_bitmap, priority_mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
source -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
8
src/mame/video/tecmo_spr.h
Normal file
8
src/mame/video/tecmo_spr.h
Normal file
@ -0,0 +1,8 @@
|
||||
/* Tecmo Sprites */
|
||||
|
||||
void galspnbl_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes );
|
||||
void tecmo16_draw_sprites(running_machine &machine, 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( running_machine &machine, 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( running_machine &machine, 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(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, bool alt_sprites, UINT16* spriteram);
|
||||
|
Loading…
Reference in New Issue
Block a user