gp9001.c (toaplan2.c): convert to device_gfx_interface, cleanups [Alex Jackson]

This commit is contained in:
Alex W. Jackson 2014-04-14 20:45:26 +00:00
parent e741d4e6d3
commit ac6d88a264
5 changed files with 288 additions and 450 deletions

File diff suppressed because it is too large Load Diff

View File

@ -32,8 +32,8 @@ public:
m_mainram16(*this, "mainram16"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_vdp0(*this, "gp9001vdp0"),
m_vdp1(*this, "gp9001vdp1"),
m_vdp0(*this, "gp9001"),
m_vdp1(*this, "gp9001_1"),
m_nmk112(*this, "nmk112"),
m_oki(*this, "oki"),
m_oki1(*this, "oki1"),
@ -61,12 +61,11 @@ public:
optional_device<okim6295_device> m_oki1;
optional_device<eeprom_serial_93cxx_device> m_eeprom;
optional_device<upd4992_device> m_rtc;
required_device<gfxdecode_device> m_gfxdecode;
optional_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
UINT16 m_mcu_data;
UINT16 m_video_status;
INT8 m_old_p1_paddle_h; /* For Ghox */
INT8 m_old_p2_paddle_h;
UINT8 m_v25_reset_line; /* 0x20 for dogyuun/batsugun, 0x10 for vfive, 0x08 for fixeight */

View File

@ -150,87 +150,74 @@ Pipi & Bibis | Fix Eight | V-Five | Snow Bros. 2 |
WRITE16_MEMBER( gp9001vdp_device::gp9001_bg_tmap_w )
{
COMBINE_DATA(&bg.vram16[offset]);
COMBINE_DATA(&m_vram_bg[offset]);
bg.tmap->mark_tile_dirty(offset/2);
}
WRITE16_MEMBER( gp9001vdp_device::gp9001_fg_tmap_w )
{
COMBINE_DATA(&fg.vram16[offset]);
COMBINE_DATA(&m_vram_fg[offset]);
fg.tmap->mark_tile_dirty(offset/2);
}
WRITE16_MEMBER( gp9001vdp_device::gp9001_top_tmap_w )
{
COMBINE_DATA(&top.vram16[offset]);
COMBINE_DATA(&m_vram_top[offset]);
top.tmap->mark_tile_dirty(offset/2);
}
READ16_MEMBER( gp9001vdp_device::gp9001_bg_tmap_r )
{
return bg.vram16[offset];
}
READ16_MEMBER( gp9001vdp_device::gp9001_fg_tmap_r )
{
return fg.vram16[offset];
}
READ16_MEMBER( gp9001vdp_device::gp9001_top_tmap_r )
{
return top.vram16[offset];
}
READ16_MEMBER( gp9001vdp_device::gp9001_spram_r )
{
return sp.vram16[offset];
}
WRITE16_MEMBER( gp9001vdp_device::gp9001_spram_w )
{
COMBINE_DATA(&sp.vram16[offset]);
}
static ADDRESS_MAP_START( gp9001vdp_map, AS_0, 16, gp9001vdp_device )
AM_RANGE(0x0000, 0x0fff) AM_READWRITE(gp9001_bg_tmap_r, gp9001_bg_tmap_w)
AM_RANGE(0x1000, 0x1fff) AM_READWRITE(gp9001_fg_tmap_r, gp9001_fg_tmap_w)
AM_RANGE(0x2000, 0x2fff) AM_READWRITE(gp9001_top_tmap_r, gp9001_top_tmap_w)
AM_RANGE(0x3000, 0x37ff) AM_READWRITE(gp9001_spram_r, gp9001_spram_w)
DEVICE_ADDRESS_MAP_START( map, 16, gp9001vdp_device )
AM_RANGE(0x0000, 0x0fff) AM_RAM_WRITE(gp9001_bg_tmap_w) AM_SHARE("vram_bg")
AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(gp9001_fg_tmap_w) AM_SHARE("vram_fg")
AM_RANGE(0x2000, 0x2fff) AM_RAM_WRITE(gp9001_top_tmap_w) AM_SHARE("vram_top")
AM_RANGE(0x3000, 0x37ff) AM_RAM AM_SHARE("spriteram")
AM_RANGE(0x3800, 0x3fff) AM_RAM // sprite mirror?
ADDRESS_MAP_END
const gfx_layout gp9001vdp_device::tilelayout =
{
16,16, /* 16x16 */
RGN_FRAC(1,2), /* Number of tiles */
4, /* 4 bits per pixel */
{ RGN_FRAC(1,2)+8, RGN_FRAC(1,2), 8, 0 },
{ 0, 1, 2, 3, 4, 5, 6, 7,
8*16+0, 8*16+1, 8*16+2, 8*16+3, 8*16+4, 8*16+5, 8*16+6, 8*16+7 },
{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
16*16, 17*16, 18*16, 19*16, 20*16, 21*16, 22*16, 23*16 },
8*4*16
};
const gfx_layout gp9001vdp_device::spritelayout =
{
8,8, /* 8x8 */
RGN_FRAC(1,2), /* Number of 8x8 sprites */
4, /* 4 bits per pixel */
{ RGN_FRAC(1,2)+8, RGN_FRAC(1,2), 8, 0 },
{ 0, 1, 2, 3, 4, 5, 6, 7 },
{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
8*16
};
GFXDECODE_MEMBER( gp9001vdp_device::gfxinfo )
GFXDECODE_DEVICE( DEVICE_SELF, 0, tilelayout, 0, 0x1000 )
GFXDECODE_DEVICE( DEVICE_SELF, 0, spritelayout, 0, 0x1000 )
GFXDECODE_END
const device_type GP9001_VDP = &device_creator<gp9001vdp_device>;
gp9001vdp_device::gp9001vdp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, GP9001_VDP, "GP9001 VDP", tag, owner, clock, "gp9001vdp", __FILE__),
device_gfx_interface(mconfig, *this, gfxinfo),
device_video_interface(mconfig, *this),
device_memory_interface(mconfig, *this),
m_space_config("gp9001vdp", ENDIANNESS_BIG, 16,14, 0, NULL, *ADDRESS_MAP_NAME(gp9001vdp_map)),
m_gfxregion(0),
m_gfxdecode(*this),
m_palette(*this)
{
}
//-------------------------------------------------
// static_set_gfxdecode_tag: Set the tag of the
// gfx decoder
//-------------------------------------------------
void gp9001vdp_device::static_set_gfxdecode_tag(device_t &device, const char *tag)
{
downcast<gp9001vdp_device &>(device).m_gfxdecode.set_tag(tag);
}
void gp9001vdp_device::static_set_gfx_region(device_t &device, int gfxregion)
{
gp9001vdp_device &vdp = downcast<gp9001vdp_device &>(device);
vdp.m_gfxregion = gfxregion;
}
void gp9001vdp_device::device_validity_check(validity_checker &valid) const
m_space_config("gp9001vdp", ENDIANNESS_BIG, 16,14, 0, address_map_delegate(FUNC(gp9001vdp_device::map), this)),
m_vram_bg(*this, "vram_bg"),
m_vram_fg(*this, "vram_fg"),
m_vram_top(*this, "vram_top"),
m_spriteram(*this, "spriteram")
{
}
@ -243,9 +230,9 @@ TILE_GET_INFO_MEMBER(gp9001vdp_device::get_top0_tile_info)
{
int color, tile_number, attrib;
attrib = top.vram16[2*tile_index];
attrib = m_vram_top[2*tile_index];
tile_number = top.vram16[2*tile_index+1];
tile_number = m_vram_top[2*tile_index+1];
if (gp9001_gfxrom_is_banked)
{
@ -253,7 +240,7 @@ TILE_GET_INFO_MEMBER(gp9001vdp_device::get_top0_tile_info)
}
color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour
SET_TILE_INFO_MEMBER(tile_region,
SET_TILE_INFO_MEMBER(0,
tile_number,
color,
0);
@ -264,9 +251,9 @@ TILE_GET_INFO_MEMBER(gp9001vdp_device::get_fg0_tile_info)
{
int color, tile_number, attrib;
attrib = fg.vram16[2*tile_index];
attrib = m_vram_fg[2*tile_index];
tile_number = fg.vram16[2*tile_index+1];
tile_number = m_vram_fg[2*tile_index+1];
if (gp9001_gfxrom_is_banked)
@ -275,7 +262,7 @@ TILE_GET_INFO_MEMBER(gp9001vdp_device::get_fg0_tile_info)
}
color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour
SET_TILE_INFO_MEMBER(tile_region,
SET_TILE_INFO_MEMBER(0,
tile_number,
color,
0);
@ -285,9 +272,9 @@ TILE_GET_INFO_MEMBER(gp9001vdp_device::get_fg0_tile_info)
TILE_GET_INFO_MEMBER(gp9001vdp_device::get_bg0_tile_info)
{
int color, tile_number, attrib;
attrib = bg.vram16[2*tile_index];
attrib = m_vram_bg[2*tile_index];
tile_number = bg.vram16[2*tile_index+1];
tile_number = m_vram_bg[2*tile_index+1];
if (gp9001_gfxrom_is_banked)
{
@ -295,20 +282,18 @@ TILE_GET_INFO_MEMBER(gp9001vdp_device::get_bg0_tile_info)
}
color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour
SET_TILE_INFO_MEMBER(tile_region,
SET_TILE_INFO_MEMBER(0,
tile_number,
color,
0);
//tileinfo.category = (attrib & 0x0f00) >> 8;
}
void gp9001vdp_device::create_tilemaps(int region)
void gp9001vdp_device::create_tilemaps()
{
tile_region = region;
top.tmap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(gp9001vdp_device::get_top0_tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32);
fg.tmap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(gp9001vdp_device::get_fg0_tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32);
bg.tmap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(gp9001vdp_device::get_bg0_tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32);
top.tmap = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(gp9001vdp_device::get_top0_tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32);
fg.tmap = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(gp9001vdp_device::get_fg0_tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32);
bg.tmap = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(gp9001vdp_device::get_bg0_tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32);
top.tmap->set_transparent_pen(0);
fg.tmap->set_transparent_pen(0);
@ -318,23 +303,11 @@ void gp9001vdp_device::create_tilemaps(int region)
void gp9001vdp_device::device_start()
{
if(!m_gfxdecode->started())
throw device_missing_dependencies();
top.vram16 = auto_alloc_array_clear(machine(), UINT16, GP9001_TOP_VRAM_SIZE/2);
fg.vram16 = auto_alloc_array_clear(machine(), UINT16, GP9001_FG_VRAM_SIZE/2);
bg.vram16 = auto_alloc_array_clear(machine(), UINT16, GP9001_BG_VRAM_SIZE/2);
sp.vram16 = auto_alloc_array_clear(machine(), UINT16, GP9001_SPRITERAM_SIZE/2);
sp.vram16_buffer = auto_alloc_array_clear(machine(), UINT16, GP9001_SPRITERAM_SIZE/2);
create_tilemaps(m_gfxregion);
create_tilemaps();
save_pointer(NAME(sp.vram16), GP9001_SPRITERAM_SIZE/2);
save_pointer(NAME(sp.vram16_buffer), GP9001_SPRITERAM_SIZE/2);
save_pointer(NAME(top.vram16), GP9001_TOP_VRAM_SIZE/2);
save_pointer(NAME(fg.vram16), GP9001_FG_VRAM_SIZE/2);
save_pointer(NAME(bg.vram16), GP9001_BG_VRAM_SIZE/2);
save_item(NAME(gp9001_scroll_reg));
save_item(NAME(gp9001_voffs));
@ -397,12 +370,12 @@ void gp9001vdp_device::device_reset()
}
void gp9001vdp_device::gp9001_voffs_w(offs_t offset, UINT16 data, UINT16 mem_mask)
void gp9001vdp_device::gp9001_voffs_w(UINT16 data, UINT16 mem_mask)
{
COMBINE_DATA(&gp9001_voffs);
}
int gp9001vdp_device::gp9001_videoram16_r(offs_t offset)
int gp9001vdp_device::gp9001_videoram16_r()
{
int offs = gp9001_voffs;
gp9001_voffs++;
@ -410,7 +383,7 @@ int gp9001vdp_device::gp9001_videoram16_r(offs_t offset)
}
void gp9001vdp_device::gp9001_videoram16_w(offs_t offset, UINT16 data, UINT16 mem_mask)
void gp9001vdp_device::gp9001_videoram16_w(UINT16 data, UINT16 mem_mask)
{
int offs = gp9001_voffs;
gp9001_voffs++;
@ -423,17 +396,17 @@ UINT16 gp9001vdp_device::gp9001_vdpstatus_r()
return ((m_screen->vpos() + 15) % 262) >= 245;
}
void gp9001vdp_device::gp9001_scroll_reg_select_w( offs_t offset, UINT16 data, UINT16 mem_mask )
void gp9001vdp_device::gp9001_scroll_reg_select_w(UINT16 data, UINT16 mem_mask)
{
if (ACCESSING_BITS_0_7)
{
gp9001_scroll_reg = data & 0x8f;
if (data & 0x70)
logerror("Hmmm, selecting unknown LSB video control register (%04x) Video controller %01x \n",gp9001_scroll_reg,tile_region>>1);
logerror("Hmmm, selecting unknown LSB video control register (%04x)\n",gp9001_scroll_reg);
}
else
{
logerror("Hmmm, selecting unknown MSB video control register (%04x) Video controller %01x \n",gp9001_scroll_reg,tile_region>>1);
logerror("Hmmm, selecting unknown MSB video control register (%04x)\n",gp9001_scroll_reg);
}
}
@ -514,14 +487,12 @@ static void gp9001_set_sprite_scrolly_and_flip_reg(gp9001spritelayer* layer, UIN
}
}
void gp9001vdp_device::gp9001_scroll_reg_data_w(offs_t offset, UINT16 data, UINT16 mem_mask)
void gp9001vdp_device::gp9001_scroll_reg_data_w(UINT16 data, UINT16 mem_mask)
{
/************************************************************************/
/***** layer X and Y flips can be set independently, so emulate it ******/
/************************************************************************/
//printf("gp9001_scroll_reg_data_w %04x %04x\n", offset, data);
// writes with 8x set turn on flip for the specified layer / axis
int flip = gp9001_scroll_reg & 0x80;
@ -545,7 +516,7 @@ void gp9001vdp_device::gp9001_scroll_reg_data_w(offs_t offset, UINT16 data, UINT
case 0x0f: break;
default: logerror("Hmmm, writing %08x to unknown video control register (%08x) Video controller %01x !!!\n",data ,gp9001_scroll_reg,tile_region>>1);
default: logerror("Hmmm, writing %08x to unknown video control register (%08x) !!!\n",data,gp9001_scroll_reg);
break;
}
}
@ -566,11 +537,10 @@ void gp9001vdp_device::init_scroll_regs()
READ16_MEMBER( gp9001vdp_device::gp9001_vdp_r )
{
switch (offset)
switch (offset & (0xc/2))
{
case 0x04/2:
case 0x06/2:
return gp9001_videoram16_r(offset-0x04/2);
return gp9001_videoram16_r();
case 0x0c/2:
return gp9001_vdpstatus_r();
@ -584,43 +554,36 @@ READ16_MEMBER( gp9001vdp_device::gp9001_vdp_r )
WRITE16_MEMBER( gp9001vdp_device::gp9001_vdp_w )
{
switch (offset)
switch (offset & (0xc/2))
{
case 0x00/2:
gp9001_voffs_w(offset-0x00/2, data, mem_mask);
gp9001_voffs_w(data, mem_mask);
break;
case 0x04/2:
case 0x06/2:
gp9001_videoram16_w(offset-0x04/2, data, mem_mask);
gp9001_videoram16_w(data, mem_mask);
break;
case 0x08/2:
gp9001_scroll_reg_select_w(offset-0x08/2, data, mem_mask);
gp9001_scroll_reg_select_w(data, mem_mask);
break;
case 0x0c/2:
gp9001_scroll_reg_data_w(offset-0x0c/2, data, mem_mask);
break;
default:
logerror("gp9001_vdp_w: write to unhandled offset %04x %04x\n",offset, data);
gp9001_scroll_reg_data_w(data, mem_mask);
break;
}
}
/* some raizing games have a different layout */
/* batrider and bbakraid invert the register select lines */
READ16_MEMBER( gp9001vdp_device::gp9001_vdp_alt_r )
{
switch (offset)
switch (offset & (0xc/2))
{
case 0x00/2:
case 0x0/2:
return gp9001_vdpstatus_r();
case 0x08/2:
case 0x0a/2:
return gp9001_videoram16_r(offset-0x04/2);
case 0x8/2:
return gp9001_videoram16_r();
default:
logerror("gp9001_vdp_alt_r: read from unhandled offset %04x\n",offset*2);
@ -631,27 +594,22 @@ READ16_MEMBER( gp9001vdp_device::gp9001_vdp_alt_r )
WRITE16_MEMBER( gp9001vdp_device::gp9001_vdp_alt_w )
{
switch (offset)
switch (offset & (0xc/2))
{
case 0x00/2:
gp9001_scroll_reg_data_w(offset-0x0c/2, data, mem_mask);
case 0x0/2:
gp9001_scroll_reg_data_w(data, mem_mask);
break;
case 0x04/2:
gp9001_scroll_reg_select_w(offset-0x08/2, data, mem_mask);
case 0x4/2:
gp9001_scroll_reg_select_w(data, mem_mask);
break;
case 0x08/2:
case 0x0a/2:
gp9001_videoram16_w(offset-0x04/2, data, mem_mask);
case 0x8/2:
gp9001_videoram16_w(data, mem_mask);
break;
case 0x0c/2:
gp9001_voffs_w(offset-0x00/2, data, mem_mask);
break;
default:
logerror("gp9001_vdp_alt_w: write to unhandled offset %04x %04x\n",offset, data);
case 0xc/2:
gp9001_voffs_w(data, mem_mask);
break;
}
}
@ -679,32 +637,32 @@ WRITE16_MEMBER( gp9001vdp_device::pipibibi_bootleg_scroll_w )
}
gp9001_scroll_reg = offset;
gp9001_scroll_reg_data_w(offset, data, mem_mask);
gp9001_scroll_reg_data_w(data, mem_mask);
}
}
READ16_MEMBER( gp9001vdp_device::pipibibi_bootleg_videoram16_r )
{
gp9001_voffs_w(0, offset, 0xffff);
return gp9001_videoram16_r(0);
gp9001_voffs_w(offset, 0xffff);
return gp9001_videoram16_r();
}
WRITE16_MEMBER( gp9001vdp_device::pipibibi_bootleg_videoram16_w )
{
gp9001_voffs_w(0, offset, 0xffff);
gp9001_videoram16_w(0, data, mem_mask);
gp9001_voffs_w(offset, 0xffff);
gp9001_videoram16_w(data, mem_mask);
}
READ16_MEMBER( gp9001vdp_device::pipibibi_bootleg_spriteram16_r )
{
gp9001_voffs_w(0, (0x1800 + offset), 0);
return gp9001_videoram16_r(0);
gp9001_voffs_w((0x1800 + offset), 0);
return gp9001_videoram16_r();
}
WRITE16_MEMBER( gp9001vdp_device::pipibibi_bootleg_spriteram16_w )
{
gp9001_voffs_w(0, (0x1800 + offset), mem_mask);
gp9001_videoram16_w(0, data, mem_mask);
gp9001_voffs_w((0x1800 + offset), mem_mask);
gp9001_videoram16_w(data, mem_mask);
}
/***************************************************************************
@ -713,25 +671,24 @@ WRITE16_MEMBER( gp9001vdp_device::pipibibi_bootleg_spriteram16_w )
void gp9001vdp_device::draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8* primap )
{
gfx_element *gfx = m_gfxdecode->gfx(tile_region+1);
int offs, old_x, old_y;
const UINT16 primask = (GP9001_PRIMASK << 8);
UINT16 *source;
if (sp.use_sprite_buffer) source=(UINT16 *)(sp.vram16_buffer);
else source=(UINT16 *)(sp.vram16);
if (sp.use_sprite_buffer) source = sp.vram16_buffer;
else source = m_spriteram;
gfx_element *spritegfx = gfx(1);
int total_elements = spritegfx->elements();
int total_colors = spritegfx->colors();
old_x = (-(sp.scrollx)) & 0x1ff;
old_y = (-(sp.scrolly)) & 0x1ff;
int old_x = (-(sp.scrollx)) & 0x1ff;
int old_y = (-(sp.scrolly)) & 0x1ff;
for (offs = 0; offs < (GP9001_SPRITERAM_SIZE/2); offs += 4)
for (int offs = 0; offs < (GP9001_SPRITERAM_SIZE/2); offs += 4)
{
int attrib, sprite, color, priority, flipx, flipy, sx, sy;
int sprite_sizex, sprite_sizey, dim_x, dim_y, sx_base, sy_base;
int bank, sprite_num;
UINT16 primask = (GP9001_PRIMASK << 8);
attrib = source[offs];
priority = primap[((attrib & primask)>>8)]+1;
@ -821,13 +778,12 @@ void gp9001vdp_device::draw_sprites( running_machine &machine, bitmap_ind16 &bit
flipx,flipy,
sx,sy,0);
*/
sprite %= gfx->elements();
color %= gfx->colors();
sprite %= total_elements;
color %= total_colors;
const pen_t *paldata = &palette()->pen(color * 16);
{
int yy, xx;
const pen_t *paldata = &m_palette->pen(gfx->colorbase() + gfx->granularity() * color);
const UINT8* srcdata = gfx->get_data(sprite);
const UINT8* srcdata = spritegfx->get_data(sprite);
int count = 0;
int ystart, yend, yinc;
int xstart, xend, xinc;
@ -976,15 +932,5 @@ void gp9001vdp_device::gp9001_render_vdp(running_machine& machine, bitmap_ind16
void gp9001vdp_device::gp9001_screen_eof(void)
{
/** Shift sprite RAM buffers *** Used to fix sprite lag **/
if (sp.use_sprite_buffer) memcpy(sp.vram16_buffer,sp.vram16,GP9001_SPRITERAM_SIZE);
}
//-------------------------------------------------
// static_set_palette_tag: Set the tag of the
// palette device
//-------------------------------------------------
void gp9001vdp_device::static_set_palette_tag(device_t &device, const char *tag)
{
downcast<gp9001vdp_device &>(device).m_palette.set_tag(tag);
if (sp.use_sprite_buffer) memcpy(sp.vram16_buffer,m_spriteram,GP9001_SPRITERAM_SIZE);
}

View File

@ -14,8 +14,6 @@ struct gp9001layer
gp9001layeroffsets extra_xoffset;
gp9001layeroffsets extra_yoffset;
UINT16* vram16; // vram for this layer
};
struct gp9001tilemaplayer : gp9001layer
@ -31,25 +29,22 @@ struct gp9001spritelayer : gp9001layer
class gp9001vdp_device : public device_t,
public device_gfx_interface,
public device_video_interface,
public device_memory_interface
{
static const gfx_layout tilelayout, spritelayout;
DECLARE_GFXDECODE_MEMBER(gfxinfo);
public:
gp9001vdp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// static configuration
static void static_set_gfxdecode_tag(device_t &device, const char *tag);
static void static_set_palette_tag(device_t &device, const char *tag);
static void static_set_gfx_region(device_t &device, int gfxregion);
UINT16 gp9001_voffs;
UINT16 gp9001_scroll_reg;
gp9001tilemaplayer bg, top, fg;
gp9001spritelayer sp;
int tile_region; // we also use this to figure out which vdp we're using in some debug logging features
// technically this is just rom banking, allowing the chip to see more graphic ROM, however it's easier to handle it
// in the chip implementation than externally for now (which would require dynamic decoding of the entire charsets every
// time the bank was changed)
@ -62,11 +57,13 @@ public:
void gp9001_draw_custom_tilemap(running_machine& machine, bitmap_ind16 &bitmap, tilemap_t* tilemap, const UINT8* priremap, const UINT8* pri_enable );
void gp9001_render_vdp(running_machine& machine, bitmap_ind16 &bitmap, const rectangle &cliprect);
void gp9001_screen_eof(void);
void create_tilemaps(int region);
void create_tilemaps(void);
void init_scroll_regs(void);
bitmap_ind8 *custom_priority_bitmap;
DECLARE_ADDRESS_MAP(map, 16);
// access to VDP
DECLARE_READ16_MEMBER( gp9001_vdp_r );
DECLARE_WRITE16_MEMBER( gp9001_vdp_w );
@ -84,35 +81,31 @@ public:
DECLARE_WRITE16_MEMBER( gp9001_bg_tmap_w );
DECLARE_WRITE16_MEMBER( gp9001_fg_tmap_w );
DECLARE_WRITE16_MEMBER( gp9001_top_tmap_w );
DECLARE_READ16_MEMBER( gp9001_bg_tmap_r );
DECLARE_READ16_MEMBER( gp9001_fg_tmap_r );
DECLARE_READ16_MEMBER( gp9001_top_tmap_r );
DECLARE_READ16_MEMBER( gp9001_spram_r );
DECLARE_WRITE16_MEMBER( gp9001_spram_w );
protected:
virtual void device_validity_check(validity_checker &valid) const;
virtual void device_start();
virtual void device_reset();
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
address_space_config m_space_config;
UINT8 m_gfxregion;
TILE_GET_INFO_MEMBER(get_top0_tile_info);
TILE_GET_INFO_MEMBER(get_fg0_tile_info);
TILE_GET_INFO_MEMBER(get_bg0_tile_info);
private:
void gp9001_voffs_w(offs_t offset, UINT16 data, UINT16 mem_mask);
int gp9001_videoram16_r(offs_t offset);
void gp9001_videoram16_w(offs_t offset, UINT16 data, UINT16 mem_mask);
UINT16 gp9001_vdpstatus_r();
void gp9001_scroll_reg_select_w( offs_t offset, UINT16 data, UINT16 mem_mask );
void gp9001_scroll_reg_data_w(offs_t offset, UINT16 data, UINT16 mem_mask);
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_shared_ptr<UINT16> m_vram_bg;
required_shared_ptr<UINT16> m_vram_fg;
required_shared_ptr<UINT16> m_vram_top;
required_shared_ptr<UINT16> m_spriteram;
void gp9001_voffs_w(UINT16 data, UINT16 mem_mask);
int gp9001_videoram16_r(void);
void gp9001_videoram16_w(UINT16 data, UINT16 mem_mask);
UINT16 gp9001_vdpstatus_r(void);
void gp9001_scroll_reg_select_w(UINT16 data, UINT16 mem_mask);
void gp9001_scroll_reg_data_w(UINT16 data, UINT16 mem_mask);
};
extern const device_type GP9001_VDP;
@ -123,21 +116,3 @@ extern const device_type GP9001_VDP;
#define GP9001_SPRITERAM_SIZE 0x800 /* Sprite RAM size */
#define GP9001_SPRITE_FLIPX 0x1000 /* Sprite flip flags */
#define GP9001_SPRITE_FLIPY 0x2000
/* vdp map 0, gfx region 0 */
#define MCFG_DEVICE_ADD_VDP0 \
MCFG_DEVICE_ADD("gp9001vdp0", GP9001_VDP, 0) \
gp9001vdp_device::static_set_gfx_region(*device, 0);
/* vdp map 1, gfx region 2 */
#define MCFG_DEVICE_ADD_VDP1 \
MCFG_DEVICE_ADD("gp9001vdp1", GP9001_VDP, 0) \
gp9001vdp_device::static_set_gfx_region(*device, 2);
#define MCFG_GP9001_VDP_GFXDECODE(_gfxtag) \
gp9001vdp_device::static_set_gfxdecode_tag(*device, "^" _gfxtag);
#define MCFG_GP9001_VDP_PALETTE(_palette_tag) \
gp9001vdp_device::static_set_palette_tag(*device, "^" _palette_tag);

View File

@ -1,7 +1,7 @@
/***************************************************************************
Functions to emulate additional video hardware on several Toaplan2 games.
The main video is handled by the GP9001 (see video gp9001.c)
The main video is handled by the GP9001 (see video/gp9001.c)
Extra-text RAM format
@ -41,7 +41,7 @@ TILE_GET_INFO_MEMBER(toaplan2_state::get_text_tile_info)
attrib = m_tx_videoram[tile_index];
tile_number = attrib & 0x3ff;
color = attrib >> 10;
SET_TILE_INFO_MEMBER(2,
SET_TILE_INFO_MEMBER(0,
tile_number,
color,
0);
@ -66,8 +66,7 @@ void toaplan2_state::create_tx_tilemap(int dx, int dx_flipped)
void toaplan2_state::truxton2_postload()
{
for (int i = 0; i < 1024; i++)
m_gfxdecode->gfx(2)->mark_dirty(i);
m_gfxdecode->gfx(0)->mark_all_dirty();
}
VIDEO_START_MEMBER(toaplan2_state,toaplan2)
@ -93,7 +92,7 @@ VIDEO_START_MEMBER(toaplan2_state,truxton2)
VIDEO_START_CALL_MEMBER( toaplan2 );
/* Create the Text tilemap for this game */
m_gfxdecode->gfx(2)->set_source(reinterpret_cast<UINT8 *>(m_tx_gfxram16.target()));
m_gfxdecode->gfx(0)->set_source(reinterpret_cast<UINT8 *>(m_tx_gfxram16.target()));
machine().save().register_postload(save_prepost_delegate(FUNC(toaplan2_state::truxton2_postload), this));
create_tx_tilemap(0x1d5, 0x16a);
@ -146,7 +145,7 @@ VIDEO_START_MEMBER(toaplan2_state,batrider)
/* Create the Text tilemap for this game */
m_tx_gfxram16.allocate(RAIZING_TX_GFXRAM_SIZE/2);
m_gfxdecode->gfx(2)->set_source(reinterpret_cast<UINT8 *>(m_tx_gfxram16.target()));
m_gfxdecode->gfx(0)->set_source(reinterpret_cast<UINT8 *>(m_tx_gfxram16.target()));
machine().save().register_postload(save_prepost_delegate(FUNC(toaplan2_state::truxton2_postload), this));
create_tx_tilemap(0x1d4, 0x16b);
@ -178,9 +177,8 @@ WRITE16_MEMBER(toaplan2_state::toaplan2_tx_gfxram16_w)
if (oldword != data)
{
int code = offset/32;
COMBINE_DATA(&m_tx_gfxram16[offset]);
m_gfxdecode->gfx(2)->mark_dirty(code);
m_gfxdecode->gfx(0)->mark_dirty(offset/32);
}
}
@ -201,8 +199,7 @@ WRITE16_MEMBER(toaplan2_state::batrider_textdata_dma_w)
dest += (m_tx_linescroll.bytes()/2);
memcpy(dest, m_mainram16, m_mainram16.bytes());
for (int i = 0; i < 1024; i++)
m_gfxdecode->gfx(2)->mark_dirty(i);
m_gfxdecode->gfx(0)->mark_all_dirty();
}
WRITE16_MEMBER(toaplan2_state::batrider_unknown_dma_w)
@ -349,12 +346,9 @@ UINT32 toaplan2_state::screen_update_batsugun(screen_device &screen, bitmap_ind1
UINT32 toaplan2_state::screen_update_toaplan2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
if (m_vdp0)
{
bitmap.fill(0, cliprect);
m_custom_priority_bitmap.fill(0, cliprect);
m_vdp0->gp9001_render_vdp(machine(), bitmap, cliprect);
}
bitmap.fill(0, cliprect);
m_custom_priority_bitmap.fill(0, cliprect);
m_vdp0->gp9001_render_vdp(machine(), bitmap, cliprect);
return 0;
}