summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video
diff options
context:
space:
mode:
author cam900 <dbtlrchl@naver.com>2018-05-17 08:32:59 +0900
committer Vas Crabb <cuavas@users.noreply.github.com>2018-05-17 09:32:59 +1000
commit70c9f899957d0472aa2756ea30f576a79ad78468 (patch)
treed25fd7fa50e082ef8849c9ae0df4a3bb57853cd5 /src/mame/video
parent692752246ed757eca1f5bded1db8b89f95a8e3ec (diff)
toaplan2.cpp, gp9001.cpp Cleanups (#3460)
* toaplan2.cpp : Reduce duplicates, Unnecessary things, Runtime tag lookups, Fix DMA'd palette/text things, Add input_merger_any_high_device for batrider sound IRQ gp9001.cpp : Minor cleanups, Reduce duplicates, Make sprite draw function related by MAX_SPRITE (it's possibly lower than 256 at real hardware), Add notes * gp9001.cpp : Add notes * gp9001.cpp : Add notes * toaplan2.h : Fix typo * toaplan2.cpp : Fix bgaregga audiobank * toaplan2.cpp : Cleanup unused, ACCESSING_BITS, Make batsugun screen update related to cliprect * toaplan2.cpp : Add notes * toaplan2.cpp : Fix build * toaplan2.cpp : Revert GFXDECODE_RAM things, Fix sound error at batrider
Diffstat (limited to 'src/mame/video')
-rw-r--r--src/mame/video/gp9001.cpp217
-rw-r--r--src/mame/video/gp9001.h24
-rw-r--r--src/mame/video/toaplan2.cpp91
3 files changed, 133 insertions, 199 deletions
diff --git a/src/mame/video/gp9001.cpp b/src/mame/video/gp9001.cpp
index 4e876c6c67f..84b97ab9916 100644
--- a/src/mame/video/gp9001.cpp
+++ b/src/mame/video/gp9001.cpp
@@ -151,35 +151,27 @@ Pipi & Bibis | Fix Eight | V-Five | Snow Bros. 2 |
priority system.
*/
-#define GP9001_PRIMASK (0x000f)
-#define GP9001_PRIMASK_TMAPS (0x000e)
+static constexpr unsigned GP9001_PRIMASK = 0x000f;
+static constexpr unsigned GP9001_PRIMASK_TMAPS = 0x000e;
+// TODO : Wrong; It's possibly lower than 256 at real hardware
+// Most noticeable at some boss explosion scene in bgaregga
+static constexpr unsigned MAX_SPRITES = 256;
-WRITE16_MEMBER(gp9001vdp_device::bg_tmap_w)
+template<int Layer>
+WRITE16_MEMBER(gp9001vdp_device::tmap_w)
{
- COMBINE_DATA(&m_vram_bg[offset]);
- bg.tmap->mark_tile_dirty(offset/2);
-}
-
-WRITE16_MEMBER(gp9001vdp_device::fg_tmap_w)
-{
- COMBINE_DATA(&m_vram_fg[offset]);
- fg.tmap->mark_tile_dirty(offset/2);
-}
-
-WRITE16_MEMBER(gp9001vdp_device::top_tmap_w)
-{
- COMBINE_DATA(&m_vram_top[offset]);
- top.tmap->mark_tile_dirty(offset/2);
+ COMBINE_DATA(&m_vram[Layer][offset]);
+ tm[Layer].tmap->mark_tile_dirty(offset/2);
}
void gp9001vdp_device::map(address_map &map)
{
- map(0x0000, 0x0fff).ram().w(this, FUNC(gp9001vdp_device::bg_tmap_w)).share("vram_bg");
- map(0x1000, 0x1fff).ram().w(this, FUNC(gp9001vdp_device::fg_tmap_w)).share("vram_fg");
- map(0x2000, 0x2fff).ram().w(this, FUNC(gp9001vdp_device::top_tmap_w)).share("vram_top");
+ map(0x0000, 0x0fff).ram().w(this, FUNC(gp9001vdp_device::tmap_w<0>)).share("vram_0");
+ map(0x1000, 0x1fff).ram().w(this, FUNC(gp9001vdp_device::tmap_w<1>)).share("vram_1");
+ map(0x2000, 0x2fff).ram().w(this, FUNC(gp9001vdp_device::tmap_w<2>)).share("vram_2");
map(0x3000, 0x37ff).ram().share("spriteram").mirror(0x0800);
-// AM_RANGE(0x3800, 0x3fff) AM_RAM // sprite mirror?
+// map(0x3800, 0x3fff).ram(); // sprite mirror?
}
@@ -189,11 +181,9 @@ const gfx_layout gp9001vdp_device::tilelayout =
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
+ { STEP8(0,1), STEP8(8*8*2,1) },
+ { STEP8(0,8*2), STEP8(16*8*2,8*2) },
+ 16*16*2
};
const gfx_layout gp9001vdp_device::spritelayout =
@@ -202,9 +192,9 @@ const gfx_layout gp9001vdp_device::spritelayout =
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
+ { STEP8(0,1) },
+ { STEP8(0,8*2) },
+ 8*8*2
};
GFXDECODE_MEMBER( gp9001vdp_device::gfxinfo )
@@ -216,16 +206,14 @@ GFXDECODE_END
DEFINE_DEVICE_TYPE(GP9001_VDP, gp9001vdp_device, "gp9001vdp", "GP9001 VDP")
gp9001vdp_device::gp9001vdp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, GP9001_VDP, tag, owner, clock),
- 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, address_map_constructor(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"),
- m_vint_out_cb(*this)
+ : device_t(mconfig, GP9001_VDP, tag, owner, clock)
+ , 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, address_map_constructor(FUNC(gp9001vdp_device::map), this))
+ , m_vram(*this, "vram_%u", 0)
+ , m_spriteram(*this, "spriteram")
+ , m_vint_out_cb(*this)
{
}
@@ -236,44 +224,14 @@ device_memory_interface::space_config_vector gp9001vdp_device::memory_space_conf
};
}
-TILE_GET_INFO_MEMBER(gp9001vdp_device::get_top0_tile_info)
+template<int Layer>
+TILE_GET_INFO_MEMBER(gp9001vdp_device::get_tile_info)
{
int color, tile_number, attrib;
- attrib = m_vram_top[2*tile_index];
+ attrib = m_vram[Layer][2*tile_index];
- tile_number = get_tile_number(m_vram_top, tile_index);
-
- color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour
- SET_TILE_INFO_MEMBER(0,
- tile_number,
- color,
- 0);
- //tileinfo.category = (attrib & 0x0f00) >> 8;
-}
-
-TILE_GET_INFO_MEMBER(gp9001vdp_device::get_fg0_tile_info)
-{
- int color, tile_number, attrib;
-
- attrib = m_vram_fg[2*tile_index];
-
- tile_number = get_tile_number(m_vram_fg, tile_index);
-
- color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour
- SET_TILE_INFO_MEMBER(0,
- tile_number,
- color,
- 0);
- //tileinfo.category = (attrib & 0x0f00) >> 8;
-}
-
-TILE_GET_INFO_MEMBER(gp9001vdp_device::get_bg0_tile_info)
-{
- int color, tile_number, attrib;
- attrib = m_vram_bg[2*tile_index];
-
- tile_number = get_tile_number(m_vram_bg, tile_index);
+ tile_number = get_tile_number(Layer, tile_index);
color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour
SET_TILE_INFO_MEMBER(0,
@@ -285,13 +243,13 @@ TILE_GET_INFO_MEMBER(gp9001vdp_device::get_bg0_tile_info)
void gp9001vdp_device::create_tilemaps()
{
- 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);
+ tm[2].tmap = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(gp9001vdp_device::get_tile_info<2>),this),TILEMAP_SCAN_ROWS,16,16,32,32);
+ tm[1].tmap = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(gp9001vdp_device::get_tile_info<1>),this),TILEMAP_SCAN_ROWS,16,16,32,32);
+ tm[0].tmap = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(gp9001vdp_device::get_tile_info<0>),this),TILEMAP_SCAN_ROWS,16,16,32,32);
- top.tmap->set_transparent_pen(0);
- fg.tmap->set_transparent_pen(0);
- bg.tmap->set_transparent_pen(0);
+ tm[2].tmap->set_transparent_pen(0);
+ tm[1].tmap->set_transparent_pen(0);
+ tm[0].tmap->set_transparent_pen(0);
}
@@ -309,17 +267,14 @@ void gp9001vdp_device::device_start()
save_item(NAME(gp9001_scroll_reg));
save_item(NAME(gp9001_voffs));
- save_item(NAME(bg.scrollx));
- save_item(NAME(bg.scrolly));
- save_item(NAME(fg.scrollx));
- save_item(NAME(fg.scrolly));
- save_item(NAME(top.scrollx));
- save_item(NAME(top.scrolly));
+ for (int i = 0; i < 3; i++)
+ {
+ save_item(NAME(tm[i].scrollx), i);
+ save_item(NAME(tm[i].scrolly), i);
+ save_item(NAME(tm[i].flip), i);
+ }
save_item(NAME(sp.scrollx));
save_item(NAME(sp.scrolly));
- save_item(NAME(bg.flip));
- save_item(NAME(fg.flip));
- save_item(NAME(top.flip));
save_item(NAME(sp.flip));
gfxrom_is_banked = false;
@@ -327,20 +282,20 @@ void gp9001vdp_device::device_start()
save_item(NAME(gfxrom_bank));
// default layer offsets used by all original games
- bg.extra_xoffset.normal = -0x1d6;
- bg.extra_xoffset.flipped = -0x229;
- bg.extra_yoffset.normal = -0x1ef;
- bg.extra_yoffset.flipped = -0x210;
+ tm[0].extra_xoffset.normal = -0x1d6;
+ tm[0].extra_xoffset.flipped = -0x229;
+ tm[0].extra_yoffset.normal = -0x1ef;
+ tm[0].extra_yoffset.flipped = -0x210;
- fg.extra_xoffset.normal = -0x1d8;
- fg.extra_xoffset.flipped = -0x227;
- fg.extra_yoffset.normal = -0x1ef;
- fg.extra_yoffset.flipped = -0x210;
+ tm[1].extra_xoffset.normal = -0x1d8;
+ tm[1].extra_xoffset.flipped = -0x227;
+ tm[1].extra_yoffset.normal = -0x1ef;
+ tm[1].extra_yoffset.flipped = -0x210;
- top.extra_xoffset.normal = -0x1da;
- top.extra_xoffset.flipped= -0x225;
- top.extra_yoffset.normal = -0x1ef;
- top.extra_yoffset.flipped= -0x210;
+ tm[2].extra_xoffset.normal = -0x1da;
+ tm[2].extra_xoffset.flipped= -0x225;
+ tm[2].extra_yoffset.normal = -0x1ef;
+ tm[2].extra_yoffset.flipped= -0x210;
sp.extra_xoffset.normal = -0x1cc;
sp.extra_xoffset.flipped = -0x17b;
@@ -354,14 +309,14 @@ void gp9001vdp_device::device_reset()
{
gp9001_voffs = 0;
gp9001_scroll_reg = 0;
- bg.scrollx = bg.scrolly = 0;
- fg.scrollx = fg.scrolly = 0;
- top.scrollx = top.scrolly = 0;
+ tm[0].scrollx = tm[0].scrolly = 0;
+ tm[1].scrollx = tm[1].scrolly = 0;
+ tm[2].scrollx = tm[2].scrolly = 0;
sp.scrollx = sp.scrolly = 0;
- bg.flip = 0;
- fg.flip = 0;
- top.flip = 0;
+ tm[0].flip = 0;
+ tm[1].flip = 0;
+ tm[2].flip = 0;
sp.flip = 0;
init_scroll_regs();
@@ -500,14 +455,14 @@ void gp9001vdp_device::gp9001_scroll_reg_data_w(uint16_t data, uint16_t mem_mask
switch (gp9001_scroll_reg&0x7f)
{
- case 0x00: bg.set_scrollx_and_flip_reg(data, mem_mask, flip); break;
- case 0x01: bg.set_scrolly_and_flip_reg(data, mem_mask, flip); break;
+ case 0x00: tm[0].set_scrollx_and_flip_reg(data, mem_mask, flip); break;
+ case 0x01: tm[0].set_scrolly_and_flip_reg(data, mem_mask, flip); break;
- case 0x02: fg.set_scrollx_and_flip_reg(data, mem_mask, flip); break;
- case 0x03: fg.set_scrolly_and_flip_reg(data, mem_mask, flip); break;
+ case 0x02: tm[1].set_scrollx_and_flip_reg(data, mem_mask, flip); break;
+ case 0x03: tm[1].set_scrolly_and_flip_reg(data, mem_mask, flip); break;
- case 0x04: top.set_scrollx_and_flip_reg(data, mem_mask, flip); break;
- case 0x05: top.set_scrolly_and_flip_reg(data, mem_mask, flip); break;
+ case 0x04: tm[2].set_scrollx_and_flip_reg(data, mem_mask, flip); break;
+ case 0x05: tm[2].set_scrolly_and_flip_reg(data, mem_mask, flip); break;
case 0x06: sp.set_scrollx_and_flip_reg(data, mem_mask, flip); break;
case 0x07: sp.set_scrolly_and_flip_reg(data, mem_mask, flip); break;
@@ -525,12 +480,12 @@ void gp9001vdp_device::gp9001_scroll_reg_data_w(uint16_t data, uint16_t mem_mask
void gp9001vdp_device::init_scroll_regs()
{
- bg.set_scrollx_and_flip_reg(0, 0xffff, 0);
- bg.set_scrolly_and_flip_reg(0, 0xffff, 0);
- fg.set_scrollx_and_flip_reg(0, 0xffff, 0);
- fg.set_scrolly_and_flip_reg(0, 0xffff, 0);
- top.set_scrollx_and_flip_reg(0, 0xffff, 0);
- top.set_scrolly_and_flip_reg(0, 0xffff, 0);
+ tm[0].set_scrollx_and_flip_reg(0, 0xffff, 0);
+ tm[0].set_scrolly_and_flip_reg(0, 0xffff, 0);
+ tm[1].set_scrollx_and_flip_reg(0, 0xffff, 0);
+ tm[1].set_scrolly_and_flip_reg(0, 0xffff, 0);
+ tm[2].set_scrollx_and_flip_reg(0, 0xffff, 0);
+ tm[2].set_scrolly_and_flip_reg(0, 0xffff, 0);
sp.set_scrollx_and_flip_reg(0, 0xffff, 0);
sp.set_scrolly_and_flip_reg(0, 0xffff, 0);
}
@@ -699,8 +654,6 @@ READ_LINE_MEMBER(gp9001vdp_device::fblank_r)
void gp9001vdp_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, const uint8_t* primap )
{
- const uint16_t primask = (GP9001_PRIMASK << 8);
-
uint16_t *source;
if (sp.use_sprite_buffer) source = sp.vram16_buffer.get();
@@ -711,14 +664,14 @@ void gp9001vdp_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &clip
int old_x = (-(sp.scrollx)) & 0x1ff;
int old_y = (-(sp.scrolly)) & 0x1ff;
- for (int offs = 0; offs < (SPRITERAM_SIZE/2); offs += 4)
+ for (int offs = 0; offs < (MAX_SPRITES * 4); 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;
attrib = source[offs];
- priority = primap[((attrib & primask)>>8)]+1;
+ priority = primap[(attrib>>8) & GP9001_PRIMASK]+1;
if ((attrib & 0x8000))
{
@@ -800,8 +753,8 @@ void gp9001vdp_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &clip
else sx = sx_base + dim_x;
/*
- gfx->transpen(bitmap,cliprect,sprite,
- color,
+ gfx->transpen_raw(bitmap,cliprect,sprite,
+ color << 4,
flipx,flipy,
sx,sy,0);
*/
@@ -887,8 +840,9 @@ void gp9001vdp_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &clip
Draw the game screen in the given bitmap_ind16.
***************************************************************************/
-void gp9001vdp_device::gp9001_draw_custom_tilemap( bitmap_ind16 &bitmap, tilemap_t* tilemap, const uint8_t* priremap, const uint8_t* pri_enable )
+void gp9001vdp_device::gp9001_draw_custom_tilemap( bitmap_ind16 &bitmap, int layer, const uint8_t* priremap, const uint8_t* pri_enable )
{
+ tilemap_t* tilemap = tm[layer].tmap;
int width = screen().width();
int height = screen().height();
int y,x;
@@ -913,7 +867,7 @@ void gp9001vdp_device::gp9001_draw_custom_tilemap( bitmap_ind16 &bitmap, tilemap
int realx = (x+scrollx)&0x1ff;
uint16_t pixdat = srcptr[realx];
- uint8_t pixpri = ((pixdat & (GP9001_PRIMASK_TMAPS<<12))>>12);
+ uint8_t pixpri = ((pixdat>>12) & GP9001_PRIMASK_TMAPS);
if (pri_enable[pixpri])
{
@@ -944,14 +898,15 @@ void gp9001vdp_device::gp9001_render_vdp(bitmap_ind16 &bitmap, const rectangle &
{
if (gfxrom_is_banked && gfxrom_bank_dirty)
{
- bg.tmap->mark_all_dirty();
- fg.tmap->mark_all_dirty();
+ for (int i = 0; i < 3; i++)
+ tm[i].tmap->mark_all_dirty();
+
gfxrom_bank_dirty = false;
}
- gp9001_draw_custom_tilemap(bitmap, bg.tmap, gp9001_primap1, batsugun_prienable0);
- gp9001_draw_custom_tilemap(bitmap, fg.tmap, gp9001_primap1, batsugun_prienable0);
- gp9001_draw_custom_tilemap(bitmap, top.tmap, gp9001_primap1, batsugun_prienable0);
+ gp9001_draw_custom_tilemap(bitmap, 0, gp9001_primap1, batsugun_prienable0);
+ gp9001_draw_custom_tilemap(bitmap, 1, gp9001_primap1, batsugun_prienable0);
+ gp9001_draw_custom_tilemap(bitmap, 2, gp9001_primap1, batsugun_prienable0);
draw_sprites(bitmap,cliprect, gp9001_sprprimap1);
}
diff --git a/src/mame/video/gp9001.h b/src/mame/video/gp9001.h
index 2f515b3e053..876ea9ba886 100644
--- a/src/mame/video/gp9001.h
+++ b/src/mame/video/gp9001.h
@@ -25,7 +25,7 @@ public:
template<class Object> devcb_base &set_vint_out_cb(Object &&obj) { return m_vint_out_cb.set_callback(std::forward<Object>(obj)); }
void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, const uint8_t* primap );
- void gp9001_draw_custom_tilemap( bitmap_ind16 &bitmap, tilemap_t* tilemap, const uint8_t* priremap, const uint8_t* pri_enable );
+ void gp9001_draw_custom_tilemap( bitmap_ind16 &bitmap, int layer, const uint8_t* priremap, const uint8_t* pri_enable );
void gp9001_render_vdp( bitmap_ind16 &bitmap, const rectangle &cliprect);
void gp9001_screen_eof(void);
void create_tilemaps(void);
@@ -37,9 +37,7 @@ public:
// game-specific hack stuff
void disable_sprite_buffer() { sp.use_sprite_buffer = 0; }
- void set_bg_extra_offsets(int xn, int yn, int xf, int yf) { bg.set_extra_offsets(xn, yn, xf, yf); }
- void set_fg_extra_offsets(int xn, int yn, int xf, int yf) { fg.set_extra_offsets(xn, yn, xf, yf); }
- void set_top_extra_offsets(int xn, int yn, int xf, int yf) { top.set_extra_offsets(xn, yn, xf, yf); }
+ void set_tm_extra_offsets(int layer, int xn, int yn, int xf, int yf) { tm[layer].set_extra_offsets(xn, yn, xf, yf); }
void set_sp_extra_offsets(int xn, int yn, int xf, int yf) { sp.set_extra_offsets(xn, yn, xf, yf); }
// ROM banking control
@@ -79,15 +77,11 @@ protected:
address_space_config m_space_config;
- TILE_GET_INFO_MEMBER(get_top0_tile_info);
- TILE_GET_INFO_MEMBER(get_fg0_tile_info);
- TILE_GET_INFO_MEMBER(get_bg0_tile_info);
+ template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info);
private:
// internal handlers
- DECLARE_WRITE16_MEMBER(bg_tmap_w);
- DECLARE_WRITE16_MEMBER(fg_tmap_w);
- DECLARE_WRITE16_MEMBER(top_tmap_w);
+ template<int Layer> DECLARE_WRITE16_MEMBER(tmap_w);
static constexpr unsigned BG_VRAM_SIZE = 0x1000; /* Background RAM size */
static constexpr unsigned FG_VRAM_SIZE = 0x1000; /* Foreground RAM size */
@@ -137,9 +131,9 @@ private:
std::unique_ptr<uint16_t[]> vram16_buffer; // vram buffer for this layer
};
- int get_tile_number(uint16_t const *vram, int index)
+ int get_tile_number(int layer, int index)
{
- uint16_t const value = vram[(index << 1) | 1];
+ uint16_t const value = m_vram[layer][(index << 1) | 1];
if (gfxrom_is_banked)
return (gfxrom_bank[(value >> 13) & 7] << 13) | (value & 0x1fff);
else
@@ -159,7 +153,7 @@ private:
uint16_t gp9001_voffs;
uint16_t gp9001_scroll_reg;
- tilemaplayer bg, top, fg;
+ tilemaplayer tm[3];
spritelayer sp;
// technically this is just rom banking, allowing the chip to see more graphic ROM, however it's easier to handle it
@@ -169,9 +163,7 @@ private:
bool gfxrom_bank_dirty; /* dirty flag of object bank (for Batrider) */
uint16_t gfxrom_bank[8]; /* Batrider object bank */
- required_shared_ptr<uint16_t> m_vram_bg;
- required_shared_ptr<uint16_t> m_vram_fg;
- required_shared_ptr<uint16_t> m_vram_top;
+ required_shared_ptr_array<uint16_t, 3> m_vram;
required_shared_ptr<uint16_t> m_spriteram;
devcb_write_line m_vint_out_cb;
diff --git a/src/mame/video/toaplan2.cpp b/src/mame/video/toaplan2.cpp
index 86bddaec96f..8b7e7a608a1 100644
--- a/src/mame/video/toaplan2.cpp
+++ b/src/mame/video/toaplan2.cpp
@@ -26,9 +26,6 @@
#include "emu.h"
#include "includes/toaplan2.h"
-#define RAIZING_TX_GFXRAM_SIZE 0x8000 /* GFX data decode RAM size */
-
-
/***************************************************************************
@@ -76,16 +73,16 @@ VIDEO_START_MEMBER(toaplan2_state,toaplan2)
/* our current VDP implementation needs this bitmap to work with */
m_screen->register_screen_bitmap(m_custom_priority_bitmap);
- if (m_vdp0 != nullptr)
+ if (m_vdp[0] != nullptr)
{
m_secondary_render_bitmap.reset();
- m_vdp0->custom_priority_bitmap = &m_custom_priority_bitmap;
+ m_vdp[0]->custom_priority_bitmap = &m_custom_priority_bitmap;
}
- if (m_vdp1 != nullptr)
+ if (m_vdp[1] != nullptr)
{
m_screen->register_screen_bitmap(m_secondary_render_bitmap);
- m_vdp1->custom_priority_bitmap = &m_custom_priority_bitmap;
+ m_vdp[1]->custom_priority_bitmap = &m_custom_priority_bitmap;
}
}
@@ -108,12 +105,12 @@ VIDEO_START_MEMBER(toaplan2_state,fixeightbl)
create_tx_tilemap();
/* This bootleg has additional layer offsets on the VDP */
- m_vdp0->set_bg_extra_offsets( -0x1d6 - 26, -0x1ef - 15, 0, 0 );
- m_vdp0->set_fg_extra_offsets( -0x1d8 - 22, -0x1ef - 15, 0, 0 );
- m_vdp0->set_top_extra_offsets( -0x1da - 18, -0x1ef - 15, 0, 0 );
- m_vdp0->set_sp_extra_offsets(8/*-0x1cc - 64*/, 8/*-0x1ef - 128*/, 0, 0);
+ m_vdp[0]->set_tm_extra_offsets(0, -0x1d6 - 26, -0x1ef - 15, 0, 0 );
+ m_vdp[0]->set_tm_extra_offsets(1, -0x1d8 - 22, -0x1ef - 15, 0, 0 );
+ m_vdp[0]->set_tm_extra_offsets(2, -0x1da - 18, -0x1ef - 15, 0, 0 );
+ m_vdp[0]->set_sp_extra_offsets(8/*-0x1cc - 64*/, 8/*-0x1ef - 128*/, 0, 0);
- m_vdp0->init_scroll_regs();
+ m_vdp[0]->init_scroll_regs();
}
VIDEO_START_MEMBER(toaplan2_state,bgaregga)
@@ -136,17 +133,16 @@ VIDEO_START_MEMBER(toaplan2_state,batrider)
{
VIDEO_START_CALL_MEMBER( toaplan2 );
- m_vdp0->disable_sprite_buffer(); // disable buffering on this game
+ m_vdp[0]->disable_sprite_buffer(); // disable buffering on this game
/* Create the Text tilemap for this game */
- m_tx_gfxram16.allocate(RAIZING_TX_GFXRAM_SIZE/2);
m_gfxdecode->gfx(0)->set_source(reinterpret_cast<uint8_t *>(m_tx_gfxram16.target()));
machine().save().register_postload(save_prepost_delegate(FUNC(toaplan2_state::truxton2_postload), this));
create_tx_tilemap(0x1d4, 0x16b);
/* Has special banking */
- m_vdp0->set_gfxrom_banked();
+ m_vdp[0]->set_gfxrom_banked();
}
WRITE16_MEMBER(toaplan2_state::toaplan2_tx_videoram_w)
@@ -181,50 +177,44 @@ WRITE16_MEMBER(toaplan2_state::batrider_textdata_dma_w)
{
/*** Dynamic Text GFX decoding for Batrider ***/
/*** Only done once during start-up ***/
-
- uint16_t *dest = m_tx_gfxram16;
-
- memcpy(dest, m_tx_videoram, m_tx_videoram.bytes());
- dest += (m_tx_videoram.bytes()/2);
- memcpy(dest, m_paletteram, m_paletteram.bytes());
- dest += (m_paletteram.bytes()/2);
- memcpy(dest, m_tx_lineselect, m_tx_lineselect.bytes());
- dest += (m_tx_lineselect.bytes()/2);
- memcpy(dest, m_tx_linescroll, m_tx_linescroll.bytes());
- dest += (m_tx_linescroll.bytes()/2);
- memcpy(dest, m_mainram16, m_mainram16.bytes());
-
- m_gfxdecode->gfx(0)->mark_all_dirty();
+ m_dma_space->set_bank(1);
+ for (int i = 0; i < (0x8000 >> 1); i++)
+ {
+ m_dma_space->write16(space, i, m_mainram16[i]);
+ }
}
-WRITE16_MEMBER(toaplan2_state::batrider_unknown_dma_w)
+WRITE16_MEMBER(toaplan2_state::batrider_pal_text_dma_w)
{
// FIXME: In batrider and bbakraid, the text layer and palette RAM
// are probably DMA'd from main RAM by writing here at every vblank,
// rather than being directly accessible to the 68K like the other games
+ m_dma_space->set_bank(0);
+ for (int i = 0; i < (0x3400 >> 1); i++)
+ {
+ m_dma_space->write16(space, i, m_mainram16[i]);
+ }
}
-WRITE16_MEMBER(toaplan2_state::batrider_objectbank_w)
+WRITE8_MEMBER(toaplan2_state::batrider_objectbank_w)
{
- if (ACCESSING_BITS_0_7)
- m_vdp0->set_gfxrom_bank(offset, data & 0x0f);
+ m_vdp[0]->set_gfxrom_bank(offset, data & 0x0f);
}
// Dogyuun doesn't appear to require fancy mixing?
uint32_t toaplan2_state::screen_update_dogyuun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- if (m_vdp1)
+ bitmap.fill(0, cliprect);
+ if (m_vdp[1])
{
- bitmap.fill(0, cliprect);
m_custom_priority_bitmap.fill(0, cliprect);
- m_vdp1->gp9001_render_vdp(bitmap, cliprect);
+ m_vdp[1]->gp9001_render_vdp(bitmap, cliprect);
}
- if (m_vdp0)
+ if (m_vdp[0])
{
- // bitmap.fill(0, cliprect);
m_custom_priority_bitmap.fill(0, cliprect);
- m_vdp0->gp9001_render_vdp(bitmap, cliprect);
+ m_vdp[0]->gp9001_render_vdp(bitmap, cliprect);
}
@@ -238,17 +228,17 @@ uint32_t toaplan2_state::screen_update_batsugun(screen_device &screen, bitmap_in
// bitmap.fill(0, cliprect);
// gp9001_custom_priority_bitmap->fill(0, cliprect);
- if (m_vdp0)
+ if (m_vdp[0])
{
bitmap.fill(0, cliprect);
m_custom_priority_bitmap.fill(0, cliprect);
- m_vdp0->gp9001_render_vdp(bitmap, cliprect);
+ m_vdp[0]->gp9001_render_vdp(bitmap, cliprect);
}
- if (m_vdp1)
+ if (m_vdp[1])
{
m_secondary_render_bitmap.fill(0, cliprect);
m_custom_priority_bitmap.fill(0, cliprect);
- m_vdp1->gp9001_render_vdp(m_secondary_render_bitmap, cliprect);
+ m_vdp[1]->gp9001_render_vdp(m_secondary_render_bitmap, cliprect);
}
@@ -263,20 +253,17 @@ uint32_t toaplan2_state::screen_update_batsugun(screen_device &screen, bitmap_in
// on that do.
//
- if (m_vdp0 && m_vdp1)
+ if (m_vdp[0] && m_vdp[1])
{
- int width = screen.width();
- int height = screen.height();
- int y,x;
uint16_t* src_vdp0; // output buffer of vdp0
uint16_t* src_vdp1; // output buffer of vdp1
- for (y=0;y<height;y++)
+ for (int y=cliprect.min_y;y<=cliprect.max_y;y++)
{
src_vdp0 = &bitmap.pix16(y);
src_vdp1 = &m_secondary_render_bitmap.pix16(y);
- for (x=0;x<width;x++)
+ for (int x=cliprect.min_x;x<=cliprect.max_x;x++)
{
uint16_t GPU0_LUTaddr = src_vdp0[x];
uint16_t GPU1_LUTaddr = src_vdp1[x];
@@ -336,7 +323,7 @@ uint32_t toaplan2_state::screen_update_toaplan2(screen_device &screen, bitmap_in
{
bitmap.fill(0, cliprect);
m_custom_priority_bitmap.fill(0, cliprect);
- m_vdp0->gp9001_render_vdp(bitmap, cliprect);
+ m_vdp[0]->gp9001_render_vdp(bitmap, cliprect);
return 0;
}
@@ -379,7 +366,7 @@ WRITE_LINE_MEMBER(toaplan2_state::screen_vblank_toaplan2)
// rising edge
if (state)
{
- if (m_vdp0) m_vdp0->gp9001_screen_eof();
- if (m_vdp1) m_vdp1->gp9001_screen_eof();
+ if (m_vdp[0]) m_vdp[0]->gp9001_screen_eof();
+ if (m_vdp[1]) m_vdp[1]->gp9001_screen_eof();
}
}