mirror of
https://github.com/holub/mame
synced 2025-10-06 09:00:04 +03:00
unify sprite handling between bionicc, tigeroad, supduck etc. (nw)
This commit is contained in:
parent
73304c7065
commit
01e218c4d8
@ -366,8 +366,10 @@ static MACHINE_CONFIG_START( bionicc, bionicc_state )
|
||||
MCFG_SCREEN_PALETTE("palette")
|
||||
|
||||
MCFG_GFXDECODE_ADD("gfxdecode", "palette", bionicc)
|
||||
MCFG_PALETTE_ADD("palette", 1024)
|
||||
|
||||
MCFG_DEVICE_ADD("spritegen", TIGEROAD_SPRITE, 0)
|
||||
|
||||
MCFG_PALETTE_ADD("palette", 1024)
|
||||
|
||||
MCFG_BUFFERED_SPRITERAM16_ADD("spriteram")
|
||||
|
||||
|
@ -24,6 +24,7 @@ All clock timing comes from crystal 1
|
||||
#include "cpu/m68000/m68000.h"
|
||||
#include "sound/okim6295.h"
|
||||
#include "video/bufsprite.h"
|
||||
#include "video/tigeroad_spr.h"
|
||||
|
||||
class supduck_state : public driver_device
|
||||
{
|
||||
@ -37,7 +38,8 @@ public:
|
||||
m_fore_videoram(*this, "forevideoram"),
|
||||
m_back_videoram(*this, "backvideoram"),
|
||||
m_gfxdecode(*this, "gfxdecode"),
|
||||
m_palette(*this, "palette")
|
||||
m_palette(*this, "palette"),
|
||||
m_spritegen(*this, "spritegen")
|
||||
{ }
|
||||
|
||||
// devices
|
||||
@ -52,6 +54,7 @@ public:
|
||||
|
||||
required_device<gfxdecode_device> m_gfxdecode;
|
||||
required_device<palette_device> m_palette;
|
||||
required_device<tigeroad_spr_device> m_spritegen;
|
||||
|
||||
tilemap_t *m_text_tilemap;
|
||||
tilemap_t *m_fore_tilemap;
|
||||
@ -79,7 +82,6 @@ protected:
|
||||
|
||||
virtual void video_start();
|
||||
|
||||
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority);
|
||||
TILE_GET_INFO_MEMBER(get_text_tile_info);
|
||||
TILE_GET_INFO_MEMBER(get_fore_tile_info);
|
||||
TILE_GET_INFO_MEMBER(get_back_tile_info);
|
||||
@ -124,9 +126,7 @@ UINT32 supduck_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap,
|
||||
m_back_tilemap->draw(screen, bitmap, cliprect, 0, 0);
|
||||
m_fore_tilemap->draw(screen, bitmap, cliprect, 0, 0);
|
||||
|
||||
|
||||
draw_sprites(bitmap, cliprect, 0);
|
||||
draw_sprites(bitmap, cliprect, 1); //draw priority sprites?
|
||||
m_spritegen->draw_sprites(bitmap, cliprect, m_gfxdecode, 3, m_spriteram->buffer(), m_spriteram->bytes(), flip_screen(), 1 );
|
||||
|
||||
m_text_tilemap->draw(screen, bitmap, cliprect, 0, 0);
|
||||
return 0;
|
||||
@ -197,46 +197,6 @@ TILE_GET_INFO_MEMBER(supduck_state::get_back_tile_info)
|
||||
}
|
||||
|
||||
|
||||
void supduck_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
|
||||
{
|
||||
UINT16 *source = &m_spriteram->buffer()[m_spriteram->bytes()/2] - 4;
|
||||
UINT16 *finish = m_spriteram->buffer();
|
||||
|
||||
while (source >= finish)
|
||||
{
|
||||
int tile_number = source[0];
|
||||
|
||||
if (tile_number != 0xfff) {
|
||||
int attr = source[1];
|
||||
int sy = source[2] & 0x1ff;
|
||||
int sx = source[3] & 0x1ff;
|
||||
|
||||
int flipx = attr & 0x02;
|
||||
int flipy = attr & 0x01;
|
||||
int color = (attr >> 2) & 0x0f;
|
||||
|
||||
if (sx > 0x100) sx -= 0x200;
|
||||
if (sy > 0x100) sy -= 0x200;
|
||||
|
||||
if (flip_screen())
|
||||
{
|
||||
sx = 240 - sx;
|
||||
sy = 240 - sy;
|
||||
flipx = !flipx;
|
||||
flipy = !flipy;
|
||||
}
|
||||
|
||||
|
||||
m_gfxdecode->gfx(3)->transpen(bitmap,cliprect,
|
||||
tile_number,
|
||||
color,
|
||||
flipx, flipy,
|
||||
sx, 240 - sy, 15);
|
||||
}
|
||||
|
||||
source -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(supduck_state::supduck_4000_w)
|
||||
{
|
||||
@ -490,6 +450,8 @@ static MACHINE_CONFIG_START( supduck, supduck_state )
|
||||
|
||||
MCFG_GFXDECODE_ADD("gfxdecode", "palette", supduck)
|
||||
|
||||
MCFG_DEVICE_ADD("spritegen", TIGEROAD_SPRITE, 0)
|
||||
|
||||
MCFG_PALETTE_ADD("palette", 0x800/2)
|
||||
MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB_bit4)
|
||||
|
||||
|
@ -619,6 +619,8 @@ static MACHINE_CONFIG_START( tigeroad, tigeroad_state )
|
||||
MCFG_SCREEN_PALETTE("palette")
|
||||
|
||||
MCFG_GFXDECODE_ADD("gfxdecode", "palette", tigeroad)
|
||||
|
||||
MCFG_DEVICE_ADD("spritegen", TIGEROAD_SPRITE, 0)
|
||||
|
||||
MCFG_PALETTE_ADD("palette", 1024)
|
||||
MCFG_PALETTE_FORMAT(xxxxRRRRGGGGBBBB)
|
||||
@ -680,6 +682,8 @@ static MACHINE_CONFIG_START( f1dream_comad, tigeroad_state )
|
||||
|
||||
MCFG_GFXDECODE_ADD("gfxdecode", "palette", tigeroad)
|
||||
|
||||
MCFG_DEVICE_ADD("spritegen", TIGEROAD_SPRITE, 0)
|
||||
|
||||
MCFG_PALETTE_ADD("palette", 1024)
|
||||
MCFG_PALETTE_FORMAT(xxxxRRRRGGGGBBBB)
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "video/bufsprite.h"
|
||||
#include "video/tigeroad_spr.h"
|
||||
|
||||
class bionicc_state : public driver_device
|
||||
{
|
||||
@ -18,7 +19,9 @@ public:
|
||||
m_paletteram(*this, "paletteram"),
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_gfxdecode(*this, "gfxdecode"),
|
||||
m_palette(*this, "palette") { }
|
||||
m_palette(*this, "palette"),
|
||||
m_spritegen(*this, "spritegen")
|
||||
{ }
|
||||
|
||||
/* memory pointers */
|
||||
required_device<buffered_spriteram16_device> m_spriteram;
|
||||
@ -55,8 +58,8 @@ public:
|
||||
virtual void video_start();
|
||||
UINT32 screen_update_bionicc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(bionicc_scanline);
|
||||
void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<gfxdecode_device> m_gfxdecode;
|
||||
required_device<palette_device> m_palette;
|
||||
required_device<tigeroad_spr_device> m_spritegen;
|
||||
};
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "sound/2203intf.h"
|
||||
#include "sound/msm5205.h"
|
||||
#include "cpu/m6805/m6805.h"
|
||||
#include "video/tigeroad_spr.h"
|
||||
|
||||
class tigeroad_state : public driver_device
|
||||
{
|
||||
@ -20,6 +21,7 @@ public:
|
||||
m_gfxdecode(*this, "gfxdecode"),
|
||||
m_palette(*this, "palette"),
|
||||
m_mcu(*this, "mcu"),
|
||||
m_spritegen(*this, "spritegen"),
|
||||
m_has_coinlock(1)
|
||||
{ }
|
||||
|
||||
@ -43,7 +45,6 @@ public:
|
||||
TILEMAP_MAPPER_MEMBER(tigeroad_tilemap_scan);
|
||||
virtual void video_start();
|
||||
UINT32 screen_update_tigeroad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
|
||||
void f1dream_protection_w(address_space &space);
|
||||
DECLARE_WRITE_LINE_MEMBER(irqhandler);
|
||||
required_device<cpu_device> m_maincpu;
|
||||
@ -52,6 +53,7 @@ public:
|
||||
required_device<gfxdecode_device> m_gfxdecode;
|
||||
required_device<palette_device> m_palette;
|
||||
optional_device<cpu_device> m_mcu;
|
||||
required_device<tigeroad_spr_device> m_spritegen;
|
||||
|
||||
UINT16 m_control[2];
|
||||
|
||||
|
@ -988,6 +988,7 @@ $(MAMEOBJ)/capcom.a: \
|
||||
$(DRIVERS)/alien.o \
|
||||
$(DRIVERS)/bionicc.o $(VIDEO)/bionicc.o \
|
||||
$(DRIVERS)/supduck.o \
|
||||
$(VIDEO)/tigeroad_spr.o \
|
||||
$(DRIVERS)/blktiger.o $(VIDEO)/blktiger.o \
|
||||
$(DRIVERS)/cbasebal.o $(VIDEO)/cbasebal.o \
|
||||
$(DRIVERS)/commando.o $(VIDEO)/commando.o \
|
||||
|
@ -185,43 +185,7 @@ WRITE16_MEMBER(bionicc_state::bionicc_gfxctrl_w)
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
void bionicc_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
|
||||
{
|
||||
UINT16 *buffered_spriteram = m_spriteram->buffer();
|
||||
int offs;
|
||||
gfx_element *gfx = m_gfxdecode->gfx(3);
|
||||
|
||||
for (offs = (m_spriteram->bytes() - 8) / 2; offs >= 0; offs -= 4)
|
||||
{
|
||||
int tile_number = buffered_spriteram[offs] & 0x7ff;
|
||||
if( tile_number != 0x7ff )
|
||||
{
|
||||
int attr = buffered_spriteram[offs + 1];
|
||||
int color = (attr & 0x3c) >> 2;
|
||||
int flipx = attr & 0x02;
|
||||
int flipy = 0;
|
||||
int sx = (INT16)buffered_spriteram[offs + 3]; /* signed */
|
||||
int sy = (INT16)buffered_spriteram[offs + 2]; /* signed */
|
||||
|
||||
if (sy > 512 - 16)
|
||||
sy -= 512;
|
||||
|
||||
if (flip_screen())
|
||||
{
|
||||
sx = 240 - sx;
|
||||
sy = 240 - sy;
|
||||
flipx = !flipx;
|
||||
flipy = !flipy;
|
||||
}
|
||||
|
||||
gfx->transpen(bitmap,cliprect,
|
||||
tile_number,
|
||||
color,
|
||||
flipx,flipy,
|
||||
sx,sy,15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UINT32 bionicc_state::screen_update_bionicc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
@ -229,7 +193,7 @@ UINT32 bionicc_state::screen_update_bionicc(screen_device &screen, bitmap_ind16
|
||||
m_fg_tilemap->draw(screen, bitmap, cliprect, 1 | TILEMAP_DRAW_LAYER1, 0); /* nothing in FRONT */
|
||||
m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
|
||||
m_fg_tilemap->draw(screen, bitmap, cliprect, 0 | TILEMAP_DRAW_LAYER1, 0);
|
||||
draw_sprites(bitmap, cliprect);
|
||||
m_spritegen->draw_sprites(bitmap, cliprect, m_gfxdecode, 3, m_spriteram->buffer(), m_spriteram->bytes(), flip_screen(), 0 );
|
||||
m_fg_tilemap->draw(screen, bitmap, cliprect, 0 | TILEMAP_DRAW_LAYER0, 0);
|
||||
m_tx_tilemap->draw(screen, bitmap, cliprect, 0, 0);
|
||||
return 0;
|
||||
|
@ -66,46 +66,7 @@ WRITE16_MEMBER(tigeroad_state::tigeroad_scroll_w)
|
||||
}
|
||||
}
|
||||
|
||||
void tigeroad_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
|
||||
{
|
||||
UINT16 *source = &m_spriteram->buffer()[m_spriteram->bytes()/2] - 4;
|
||||
UINT16 *finish = m_spriteram->buffer();
|
||||
|
||||
while (source >= finish)
|
||||
{
|
||||
int tile_number = source[0];
|
||||
|
||||
if (tile_number != 0xfff) {
|
||||
int attr = source[1];
|
||||
int sy = source[2] & 0x1ff;
|
||||
int sx = source[3] & 0x1ff;
|
||||
|
||||
int flipx = attr & 0x02;
|
||||
int flipy = attr & 0x01;
|
||||
int color = (attr >> 2) & 0x0f;
|
||||
|
||||
if (sx > 0x100) sx -= 0x200;
|
||||
if (sy > 0x100) sy -= 0x200;
|
||||
|
||||
if (flip_screen())
|
||||
{
|
||||
sx = 240 - sx;
|
||||
sy = 240 - sy;
|
||||
flipx = !flipx;
|
||||
flipy = !flipy;
|
||||
}
|
||||
|
||||
|
||||
m_gfxdecode->gfx(2)->transpen(bitmap,cliprect,
|
||||
tile_number,
|
||||
color,
|
||||
flipx, flipy,
|
||||
sx, 240 - sy, 15);
|
||||
}
|
||||
|
||||
source -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
TILE_GET_INFO_MEMBER(tigeroad_state::get_bg_tile_info)
|
||||
{
|
||||
@ -156,9 +117,9 @@ void tigeroad_state::video_start()
|
||||
UINT32 tigeroad_state::screen_update_tigeroad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
m_bg_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
|
||||
draw_sprites(bitmap, cliprect, 0);
|
||||
m_spritegen->draw_sprites(bitmap, cliprect, m_gfxdecode, 2, m_spriteram->buffer(), m_spriteram->bytes(), flip_screen(), 1 );
|
||||
m_bg_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
|
||||
//draw_sprites(bitmap, cliprect, 1); draw priority sprites?
|
||||
m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
94
src/mame/video/tigeroad_spr.c
Normal file
94
src/mame/video/tigeroad_spr.c
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
|
||||
very simple sprite scheme, used by some Capcom games and hardware cloned from them
|
||||
|
||||
bionicc.c
|
||||
tigeroad.c
|
||||
supduck.c
|
||||
|
||||
it is unknown if this is handled by a custom chip, or simple logic.
|
||||
y positions are inverted in Bionic Commando, but it seems otherwise the same as
|
||||
Tiger Road
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "emu.h"
|
||||
#include "tigeroad_spr.h"
|
||||
|
||||
|
||||
const device_type TIGEROAD_SPRITE = &device_creator<tigeroad_spr_device>;
|
||||
|
||||
tigeroad_spr_device::tigeroad_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, TIGEROAD_SPRITE, "Simple Capcom (Tiger Road) Sprite", tag, owner, clock, "tigeroad_spr", __FILE__)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void tigeroad_spr_device::device_start()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tigeroad_spr_device::device_reset()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
4 words per sprite
|
||||
|
||||
0 ---- ---t tttt tttt = tile number
|
||||
|
||||
1 ---- ---- --cc cc-- = colour
|
||||
1 ---- ---- ---- --x- = flip x
|
||||
1 ---- ---- ---- ---y = flip y
|
||||
|
||||
2 ---- ---x xxxx xxxx = x pos (signed)
|
||||
|
||||
3 ---- ---y yyyy yyyy = y pos (signed)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
void tigeroad_spr_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int region, UINT16* ram, UINT32 size, int flip_screen, int rev_y )
|
||||
{
|
||||
UINT16 *source = &ram[size/2] - 4;
|
||||
UINT16 *finish = ram;
|
||||
|
||||
while (source >= finish)
|
||||
{
|
||||
int tile_number = source[0];
|
||||
|
||||
int attr = source[1];
|
||||
int sy = source[2] & 0x1ff;
|
||||
int sx = source[3] & 0x1ff;
|
||||
|
||||
int flipx = attr & 0x02;
|
||||
int flipy = attr & 0x01;
|
||||
int color = (attr >> 2) & 0x0f;
|
||||
|
||||
if (sx > 0x100) sx -= 0x200;
|
||||
if (sy > 0x100) sy -= 0x200;
|
||||
|
||||
if (flip_screen)
|
||||
{
|
||||
sx = 240 - sx;
|
||||
sy = 240 - sy;
|
||||
flipx = !flipx;
|
||||
flipy = !flipy;
|
||||
}
|
||||
|
||||
if (rev_y)
|
||||
sy = 240 - sy;
|
||||
|
||||
|
||||
gfxdecode->gfx(region)->transpen(bitmap,cliprect,
|
||||
tile_number,
|
||||
color,
|
||||
flipx, flipy,
|
||||
sx, sy, 15);
|
||||
|
||||
source -= 4;
|
||||
}
|
||||
}
|
16
src/mame/video/tigeroad_spr.h
Normal file
16
src/mame/video/tigeroad_spr.h
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
class tigeroad_spr_device : public device_t
|
||||
{
|
||||
public:
|
||||
tigeroad_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int region, UINT16* ram, UINT32 size, int flip_screen, int rev_y);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
private:
|
||||
};
|
||||
|
||||
extern const device_type TIGEROAD_SPRITE;
|
Loading…
Reference in New Issue
Block a user