ninjakd2.cpp : Reduce duplicates, Reduce runtime tag lookups (#3583)

* ninjakd2.cpp : Reduce duplicates, Reduce runtime tag lookups

* ninjakd2.cpp : Fix build

* ninjakd2.cpp : Fix build

* ninjakd2.cpp : Fix build
This commit is contained in:
cam900 2018-06-16 23:01:33 +09:00 committed by Vas Crabb
parent 0275673dba
commit 6c8ddd08e1
3 changed files with 118 additions and 197 deletions

View File

@ -313,8 +313,8 @@ READ8_MEMBER(omegaf_state::io_protection_r)
case 1: // dip switches
switch (offset)
{
case 0: result = ioport("DIPSW1")->read(); break;
case 1: result = ioport("DIPSW2")->read(); break;
case 0:
case 1: result = m_dsw_io[offset & 1]->read(); break;
case 2: result = 0x02; break;
}
break;
@ -322,8 +322,8 @@ READ8_MEMBER(omegaf_state::io_protection_r)
case 2: // player inputs
switch (offset)
{
case 0: result = ioport("PAD1")->read(); break;
case 1: result = ioport("PAD2")->read(); break;
case 0:
case 1: result = m_pad_io[offset & 1]->read(); break;
case 2: result = 0x01; break;
}
break;
@ -350,7 +350,7 @@ WRITE8_MEMBER(omegaf_state::io_protection_w)
WRITE8_MEMBER(ninjakd2_state::ninjakd2_bankselect_w)
{
membank("bank1")->set_entry(data & m_rom_bank_mask);
m_mainbank->set_entry(data & m_rom_bank_mask);
}
WRITE8_MEMBER(ninjakd2_state::ninjakd2_soundreset_w)
@ -364,6 +364,33 @@ WRITE8_MEMBER(ninjakd2_state::ninjakd2_soundreset_w)
// other bits unused
}
template<int Layer>
WRITE8_MEMBER(robokid_state::robokid_bg_bank_w)
{
m_robokid_bg_bank[Layer] = data & m_vram_bank_mask;
}
template<int Layer>
READ8_MEMBER(robokid_state::robokid_bg_videoram_r)
{
return m_robokid_bg_videoram[Layer][(m_robokid_bg_bank[Layer] << 10) | offset];
}
template<int Layer>
WRITE8_MEMBER(robokid_state::robokid_bg_videoram_w)
{
int const address = (m_robokid_bg_bank[Layer] << 10 ) | offset;
m_robokid_bg_videoram[Layer][address] = data;
m_robokid_tilemap[Layer]->mark_tile_dirty(address >> 1);
}
template<int Layer>
WRITE8_MEMBER(robokid_state::robokid_bg_ctrl_w)
{
bg_ctrl(offset, data, m_robokid_tilemap[Layer]);
}
// omega fighter compares port $c1e7 with and $e0
// returning 0 and no small enemies shoot any bullet.
// returning 0xff seems enough
@ -383,7 +410,7 @@ READ8_MEMBER(omegaf_state::unk_r)
void ninjakd2_state::ninjakd2_main_cpu(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0x8000, 0xbfff).bankr("bank1");
map(0x8000, 0xbfff).bankr("mainbank");
map(0xc000, 0xc000).portr("KEYCOIN");
map(0xc001, 0xc001).portr("PAD1");
map(0xc002, 0xc002).portr("PAD2");
@ -404,7 +431,7 @@ void ninjakd2_state::ninjakd2_main_cpu(address_map &map)
void mnight_state::mnight_main_cpu(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0x8000, 0xbfff).bankr("bank1");
map(0x8000, 0xbfff).bankr("mainbank");
map(0xc000, 0xd9ff).ram();
map(0xda00, 0xdfff).ram().share("spriteram");
map(0xe000, 0xe7ff).ram().w(FUNC(ninjakd2_state::ninjakd2_bgvideoram_w)).share("bg_videoram");
@ -426,23 +453,23 @@ void mnight_state::mnight_main_cpu(address_map &map)
void robokid_state::robokid_main_cpu(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0x8000, 0xbfff).bankr("bank1");
map(0x8000, 0xbfff).bankr("mainbank");
map(0xc000, 0xc7ff).ram().w(m_palette, FUNC(palette_device::write8)).share("palette");
map(0xc800, 0xcfff).ram().w(FUNC(ninjakd2_state::ninjakd2_fgvideoram_w)).share("fg_videoram");
map(0xd000, 0xd3ff).rw(FUNC(robokid_state::robokid_bg2_videoram_r), FUNC(robokid_state::robokid_bg2_videoram_w)); // banked
map(0xd400, 0xd7ff).rw(FUNC(robokid_state::robokid_bg1_videoram_r), FUNC(robokid_state::robokid_bg1_videoram_w)); // banked
map(0xd800, 0xdbff).rw(FUNC(robokid_state::robokid_bg0_videoram_r), FUNC(robokid_state::robokid_bg0_videoram_w)); // banked
map(0xd000, 0xd3ff).rw(FUNC(robokid_state::robokid_bg_videoram_r<2>), FUNC(robokid_state::robokid_bg_videoram_w<2>)); // banked
map(0xd400, 0xd7ff).rw(FUNC(robokid_state::robokid_bg_videoram_r<1>), FUNC(robokid_state::robokid_bg_videoram_w<1>)); // banked
map(0xd800, 0xdbff).rw(FUNC(robokid_state::robokid_bg_videoram_r<0>), FUNC(robokid_state::robokid_bg_videoram_w<0>)); // banked
map(0xdc00, 0xdc00).portr("KEYCOIN").w("soundlatch", FUNC(generic_latch_8_device::write));
map(0xdc01, 0xdc01).portr("PAD1").w(FUNC(ninjakd2_state::ninjakd2_soundreset_w));
map(0xdc02, 0xdc02).portr("PAD2").w(FUNC(ninjakd2_state::ninjakd2_bankselect_w));
map(0xdc03, 0xdc03).portr("DIPSW1").w(FUNC(ninjakd2_state::ninjakd2_sprite_overdraw_w));
map(0xdc04, 0xdc04).portr("DIPSW2");
map(0xdd00, 0xdd04).w(FUNC(robokid_state::robokid_bg0_ctrl_w));
map(0xdd05, 0xdd05).w(FUNC(robokid_state::robokid_bg0_bank_w));
map(0xde00, 0xde04).w(FUNC(robokid_state::robokid_bg1_ctrl_w));
map(0xde05, 0xde05).w(FUNC(robokid_state::robokid_bg1_bank_w));
map(0xdf00, 0xdf04).w(FUNC(robokid_state::robokid_bg2_ctrl_w));
map(0xdf05, 0xdf05).w(FUNC(robokid_state::robokid_bg2_bank_w));
map(0xdd00, 0xdd04).w(FUNC(robokid_state::robokid_bg_ctrl_w<0>));
map(0xdd05, 0xdd05).w(FUNC(robokid_state::robokid_bg_bank_w<0>));
map(0xde00, 0xde04).w(FUNC(robokid_state::robokid_bg_ctrl_w<1>));
map(0xde05, 0xde05).w(FUNC(robokid_state::robokid_bg_bank_w<1>));
map(0xdf00, 0xdf04).w(FUNC(robokid_state::robokid_bg_ctrl_w<2>));
map(0xdf05, 0xdf05).w(FUNC(robokid_state::robokid_bg_bank_w<2>));
map(0xe000, 0xf9ff).ram();
map(0xfa00, 0xffff).ram().share("spriteram");
}
@ -451,23 +478,23 @@ void robokid_state::robokid_main_cpu(address_map &map)
void omegaf_state::omegaf_main_cpu(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0x8000, 0xbfff).bankr("bank1");
map(0x8000, 0xbfff).bankr("mainbank");
map(0xc000, 0xc000).portr("KEYCOIN").w("soundlatch", FUNC(generic_latch_8_device::write));
map(0xc001, 0xc003).r(FUNC(omegaf_state::io_protection_r));
map(0xc001, 0xc001).w(FUNC(ninjakd2_state::ninjakd2_soundreset_w));
map(0xc002, 0xc002).w(FUNC(ninjakd2_state::ninjakd2_bankselect_w));
map(0xc003, 0xc003).w(FUNC(ninjakd2_state::ninjakd2_sprite_overdraw_w));
map(0xc004, 0xc006).w(FUNC(omegaf_state::io_protection_w));
map(0xc100, 0xc104).w(FUNC(omegaf_state::robokid_bg0_ctrl_w));
map(0xc105, 0xc105).w(FUNC(omegaf_state::robokid_bg0_bank_w));
map(0xc100, 0xc104).w(FUNC(omegaf_state::robokid_bg_ctrl_w<0>));
map(0xc105, 0xc105).w(FUNC(omegaf_state::robokid_bg_bank_w<0>));
map(0xc1e7, 0xc1e7).r(FUNC(omegaf_state::unk_r)); // see notes
map(0xc200, 0xc204).w(FUNC(omegaf_state::robokid_bg1_ctrl_w));
map(0xc205, 0xc205).w(FUNC(omegaf_state::robokid_bg1_bank_w));
map(0xc300, 0xc304).w(FUNC(omegaf_state::robokid_bg2_ctrl_w));
map(0xc305, 0xc305).w(FUNC(omegaf_state::robokid_bg2_bank_w));
map(0xc400, 0xc7ff).rw(FUNC(omegaf_state::robokid_bg0_videoram_r), FUNC(omegaf_state::robokid_bg0_videoram_w)); // banked
map(0xc800, 0xcbff).rw(FUNC(omegaf_state::robokid_bg1_videoram_r), FUNC(omegaf_state::robokid_bg1_videoram_w)); // banked
map(0xcc00, 0xcfff).rw(FUNC(omegaf_state::robokid_bg2_videoram_r), FUNC(omegaf_state::robokid_bg2_videoram_w)); // banked
map(0xc200, 0xc204).w(FUNC(omegaf_state::robokid_bg_ctrl_w<1>));
map(0xc205, 0xc205).w(FUNC(omegaf_state::robokid_bg_bank_w<1>));
map(0xc300, 0xc304).w(FUNC(omegaf_state::robokid_bg_ctrl_w<2>));
map(0xc305, 0xc305).w(FUNC(omegaf_state::robokid_bg_bank_w<2>));
map(0xc400, 0xc7ff).rw(FUNC(omegaf_state::robokid_bg_videoram_r<0>), FUNC(omegaf_state::robokid_bg_videoram_w<0>)); // banked
map(0xc800, 0xcbff).rw(FUNC(omegaf_state::robokid_bg_videoram_r<1>), FUNC(omegaf_state::robokid_bg_videoram_w<1>)); // banked
map(0xcc00, 0xcfff).rw(FUNC(omegaf_state::robokid_bg_videoram_r<2>), FUNC(omegaf_state::robokid_bg_videoram_w<2>)); // banked
map(0xd000, 0xd7ff).ram().w(FUNC(ninjakd2_state::ninjakd2_fgvideoram_w)).share("fg_videoram");
map(0xd800, 0xdfff).ram().w(m_palette, FUNC(palette_device::write8)).share("palette");
map(0xe000, 0xf9ff).ram();
@ -910,17 +937,17 @@ GFXDECODE_END
void ninjakd2_state::machine_start()
{
/* initialize main Z80 bank */
int num_banks = (memregion("maincpu")->bytes() - 0x10000) / 0x4000;
m_mainbank->configure_entries(0, num_banks, memregion("maincpu")->base() + 0x10000, 0x4000);
// ...
m_rom_bank_mask = num_banks - 1;
}
void ninjakd2_state::machine_reset()
{
/* initialize main Z80 bank */
int num_banks = (memregion("maincpu")->bytes() - 0x10000) / 0x4000;
membank("bank1")->configure_entries(0, num_banks, memregion("maincpu")->base() + 0x10000, 0x4000);
membank("bank1")->set_entry(0);
m_rom_bank_mask = num_banks - 1;
m_mainbank->set_entry(0);
}
void omegaf_state::machine_start()

View File

@ -16,8 +16,8 @@
class ninjakd2_state : public driver_device
{
public:
ninjakd2_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
ninjakd2_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this,"maincpu"),
m_soundcpu(*this, "soundcpu"),
m_pcm(*this, "pcm"),
@ -28,8 +28,8 @@ public:
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_palette(*this, "palette"),
m_decrypted_opcodes(*this, "decrypted_opcodes")
{ }
m_decrypted_opcodes(*this, "decrypted_opcodes"),
m_mainbank(*this, "mainbank") { }
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_soundcpu;
@ -43,6 +43,8 @@ public:
required_device<palette_device> m_palette;
optional_shared_ptr<uint8_t> m_decrypted_opcodes;
required_memory_bank m_mainbank;
const int16_t* m_sampledata;
int m_next_sprite_overdraw_enabled;
bool (*m_stencil_compare_function) (uint16_t pal);
@ -93,9 +95,8 @@ protected:
class mnight_state : public ninjakd2_state
{
public:
mnight_state(const machine_config &mconfig, device_type type, const char *tag)
: ninjakd2_state(mconfig, type, tag)
{}
mnight_state(const machine_config &mconfig, device_type type, const char *tag) :
ninjakd2_state(mconfig, type, tag) { }
void arkarea(machine_config &config);
void mnight(machine_config &config);
@ -112,32 +113,21 @@ public:
class robokid_state : public mnight_state
{
public:
robokid_state(const machine_config &mconfig, device_type type, const char *tag)
: mnight_state(mconfig, type, tag)
{}
robokid_state(const machine_config &mconfig, device_type type, const char *tag) :
mnight_state(mconfig, type, tag) { }
void robokid(machine_config &config);
void robokid_main_cpu(address_map &map);
DECLARE_READ8_MEMBER(motion_error_verbose_r);
DECLARE_READ8_MEMBER(robokid_bg0_videoram_r);
DECLARE_READ8_MEMBER(robokid_bg1_videoram_r);
DECLARE_READ8_MEMBER(robokid_bg2_videoram_r);
DECLARE_WRITE8_MEMBER(robokid_bg0_videoram_w);
DECLARE_WRITE8_MEMBER(robokid_bg1_videoram_w);
DECLARE_WRITE8_MEMBER(robokid_bg2_videoram_w);
DECLARE_WRITE8_MEMBER(robokid_bg0_ctrl_w);
DECLARE_WRITE8_MEMBER(robokid_bg1_ctrl_w);
DECLARE_WRITE8_MEMBER(robokid_bg2_ctrl_w);
DECLARE_WRITE8_MEMBER(robokid_bg0_bank_w);
DECLARE_WRITE8_MEMBER(robokid_bg1_bank_w);
DECLARE_WRITE8_MEMBER(robokid_bg2_bank_w);
template<int Layer> DECLARE_READ8_MEMBER(robokid_bg_videoram_r);
template<int Layer> DECLARE_WRITE8_MEMBER(robokid_bg_videoram_w);
template<int Layer> DECLARE_WRITE8_MEMBER(robokid_bg_ctrl_w);
template<int Layer> DECLARE_WRITE8_MEMBER(robokid_bg_bank_w);
TILEMAP_MAPPER_MEMBER(robokid_bg_scan);
TILE_GET_INFO_MEMBER(robokid_get_bg0_tile_info);
TILE_GET_INFO_MEMBER(robokid_get_bg1_tile_info);
TILE_GET_INFO_MEMBER(robokid_get_bg2_tile_info);
template<int Layer> TILE_GET_INFO_MEMBER(robokid_get_bg_tile_info);
DECLARE_VIDEO_START(robokid);
uint32_t screen_update_robokid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
@ -146,27 +136,21 @@ public:
protected:
void video_init_banked(uint32_t vram_alloc_size);
tilemap_t* m_bg0_tilemap;
tilemap_t* m_bg1_tilemap;
tilemap_t* m_bg2_tilemap;
tilemap_t* m_robokid_tilemap[3];
private:
void motion_error_kludge(uint16_t offset);
uint8_t m_robokid_bg0_bank;
uint8_t m_robokid_bg1_bank;
uint8_t m_robokid_bg2_bank;
std::unique_ptr<uint8_t[]> m_robokid_bg0_videoram;
std::unique_ptr<uint8_t[]> m_robokid_bg1_videoram;
std::unique_ptr<uint8_t[]> m_robokid_bg2_videoram;
void robokid_get_bg_tile_info( tile_data& tileinfo, tilemap_memory_index const tile_index, int const gfxnum, const uint8_t* const videoram);
uint8_t m_robokid_bg_bank[3];
std::unique_ptr<uint8_t[]> m_robokid_bg_videoram[3];
};
class omegaf_state : public robokid_state
{
public:
omegaf_state(const machine_config &mconfig, device_type type, const char *tag)
: robokid_state(mconfig, type, tag)
{}
omegaf_state(const machine_config &mconfig, device_type type, const char *tag) :
robokid_state(mconfig, type, tag),
m_dsw_io(*this, "DIPSW%u", 1U),
m_pad_io(*this, "PAD%u", 1U) { }
DECLARE_READ8_MEMBER(unk_r);
DECLARE_READ8_MEMBER(io_protection_r);
@ -183,6 +167,9 @@ protected:
virtual void machine_start() override;
virtual void machine_reset() override;
private:
required_ioport_array<2> m_dsw_io;
required_ioport_array<2> m_pad_io;
void io_protection_start();
void io_protection_reset();

View File

@ -11,7 +11,6 @@
#include "emu.h"
#include "includes/ninjakd2.h"
/*************************************
*
* Callbacks for the TileMap code
@ -72,35 +71,20 @@ TILEMAP_MAPPER_MEMBER(omegaf_state::omegaf_bg_scan)
return (col & 0x0f) | ((row & 0x1f) << 4) | ((col & 0x70) << 5);
}
void robokid_state::robokid_get_bg_tile_info( tile_data& tileinfo, tilemap_memory_index const tile_index, int const gfxnum, const uint8_t* const videoram)
template<int Layer>
TILE_GET_INFO_MEMBER(robokid_state::robokid_get_bg_tile_info)
{
int const lo = videoram[(tile_index << 1)];
int const hi = videoram[(tile_index << 1) | 1];
int const lo = m_robokid_bg_videoram[Layer][(tile_index << 1)];
int const hi = m_robokid_bg_videoram[Layer][(tile_index << 1) | 1];
int const tile = ((hi & 0x10) << 7) | ((hi & 0x20) << 5) | ((hi & 0xc0) << 2) | lo;
int const color = hi & 0x0f;
SET_TILE_INFO_MEMBER(gfxnum,
SET_TILE_INFO_MEMBER(Layer + 2,
tile,
color,
0);
}
TILE_GET_INFO_MEMBER(robokid_state::robokid_get_bg0_tile_info)
{
robokid_get_bg_tile_info(tileinfo, tile_index, 2, m_robokid_bg0_videoram.get());
}
TILE_GET_INFO_MEMBER(robokid_state::robokid_get_bg1_tile_info)
{
robokid_get_bg_tile_info(tileinfo, tile_index, 3, m_robokid_bg1_videoram.get());
}
TILE_GET_INFO_MEMBER(robokid_state::robokid_get_bg2_tile_info)
{
robokid_get_bg_tile_info(tileinfo, tile_index, 4, m_robokid_bg2_videoram.get());
}
/*************************************
*
@ -129,19 +113,16 @@ void robokid_state::video_init_banked(uint32_t vram_alloc_size)
// create video ram
if (vram_alloc_size)
{
m_robokid_bg0_videoram = make_unique_clear<uint8_t[]>(vram_alloc_size);
m_robokid_bg1_videoram = make_unique_clear<uint8_t[]>(vram_alloc_size);
m_robokid_bg2_videoram = make_unique_clear<uint8_t[]>(vram_alloc_size);
for (int i = 0; i < 3; i++)
{
m_robokid_bg_videoram[i] = make_unique_clear<uint8_t[]>(vram_alloc_size);
save_pointer(NAME(m_robokid_bg0_videoram.get()), vram_alloc_size);
save_pointer(NAME(m_robokid_bg1_videoram.get()), vram_alloc_size);
save_pointer(NAME(m_robokid_bg2_videoram.get()), vram_alloc_size);
save_pointer(NAME(m_robokid_bg_videoram[i].get()), vram_alloc_size, i);
}
m_vram_bank_mask = (vram_alloc_size >> 10) - 1;
}
save_item(NAME(m_robokid_bg0_bank));
save_item(NAME(m_robokid_bg1_bank));
save_item(NAME(m_robokid_bg2_bank));
save_item(NAME(m_robokid_bg_bank));
}
static bool stencil_ninjakd2( uint16_t pal );
@ -181,15 +162,14 @@ VIDEO_START_MEMBER(robokid_state,robokid)
{
video_init_common();
video_init_banked(0x0800);
m_vram_bank_mask = 1;
m_robokid_sprites = 1;
m_bg0_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(robokid_state::robokid_get_bg0_tile_info),this), tilemap_mapper_delegate(FUNC(robokid_state::robokid_bg_scan),this), 16, 16, 32, 32);
m_bg1_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(robokid_state::robokid_get_bg1_tile_info),this), tilemap_mapper_delegate(FUNC(robokid_state::robokid_bg_scan),this), 16, 16, 32, 32);
m_bg2_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(robokid_state::robokid_get_bg2_tile_info),this), tilemap_mapper_delegate(FUNC(robokid_state::robokid_bg_scan),this), 16, 16, 32, 32);
m_robokid_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(robokid_state::robokid_get_bg_tile_info<0>),this), tilemap_mapper_delegate(FUNC(robokid_state::robokid_bg_scan),this), 16, 16, 32, 32);
m_robokid_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(robokid_state::robokid_get_bg_tile_info<1>),this), tilemap_mapper_delegate(FUNC(robokid_state::robokid_bg_scan),this), 16, 16, 32, 32);
m_robokid_tilemap[2] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(robokid_state::robokid_get_bg_tile_info<2>),this), tilemap_mapper_delegate(FUNC(robokid_state::robokid_bg_scan),this), 16, 16, 32, 32);
m_bg1_tilemap->set_transparent_pen(0xf);
m_bg2_tilemap->set_transparent_pen(0xf);
m_robokid_tilemap[1]->set_transparent_pen(0xf);
m_robokid_tilemap[2]->set_transparent_pen(0xf);
m_stencil_compare_function = stencil_robokid;
}
@ -198,16 +178,15 @@ VIDEO_START_MEMBER(omegaf_state,omegaf)
{
video_init_common();
video_init_banked(0x2000);
m_vram_bank_mask = 7;
m_robokid_sprites = 1;
m_bg0_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(omegaf_state::robokid_get_bg0_tile_info),this), tilemap_mapper_delegate(FUNC(omegaf_state::omegaf_bg_scan),this), 16, 16, 128, 32);
m_bg1_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(omegaf_state::robokid_get_bg1_tile_info),this), tilemap_mapper_delegate(FUNC(omegaf_state::omegaf_bg_scan),this), 16, 16, 128, 32);
m_bg2_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(omegaf_state::robokid_get_bg2_tile_info),this), tilemap_mapper_delegate(FUNC(omegaf_state::omegaf_bg_scan),this), 16, 16, 128, 32);
m_robokid_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(omegaf_state::robokid_get_bg_tile_info<0>),this), tilemap_mapper_delegate(FUNC(omegaf_state::omegaf_bg_scan),this), 16, 16, 128, 32);
m_robokid_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(omegaf_state::robokid_get_bg_tile_info<1>),this), tilemap_mapper_delegate(FUNC(omegaf_state::omegaf_bg_scan),this), 16, 16, 128, 32);
m_robokid_tilemap[2] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(omegaf_state::robokid_get_bg_tile_info<2>),this), tilemap_mapper_delegate(FUNC(omegaf_state::omegaf_bg_scan),this), 16, 16, 128, 32);
m_bg0_tilemap->set_transparent_pen(0xf);
m_bg1_tilemap->set_transparent_pen(0xf);
m_bg2_tilemap->set_transparent_pen(0xf);
m_robokid_tilemap[0]->set_transparent_pen(0xf);
m_robokid_tilemap[1]->set_transparent_pen(0xf);
m_robokid_tilemap[2]->set_transparent_pen(0xf);
m_stencil_compare_function = stencil_omegaf;
}
@ -232,62 +211,6 @@ WRITE8_MEMBER(ninjakd2_state::ninjakd2_fgvideoram_w)
m_fg_tilemap->mark_tile_dirty(offset >> 1);
}
WRITE8_MEMBER(robokid_state::robokid_bg0_bank_w)
{
m_robokid_bg0_bank = data & m_vram_bank_mask;
}
WRITE8_MEMBER(robokid_state::robokid_bg1_bank_w)
{
m_robokid_bg1_bank = data & m_vram_bank_mask;
}
WRITE8_MEMBER(robokid_state::robokid_bg2_bank_w)
{
m_robokid_bg2_bank = data & m_vram_bank_mask;
}
READ8_MEMBER(robokid_state::robokid_bg0_videoram_r)
{
return m_robokid_bg0_videoram[(m_robokid_bg0_bank << 10) | offset];
}
READ8_MEMBER(robokid_state::robokid_bg1_videoram_r)
{
return m_robokid_bg1_videoram[(m_robokid_bg1_bank << 10) | offset];
}
READ8_MEMBER(robokid_state::robokid_bg2_videoram_r)
{
return m_robokid_bg2_videoram[(m_robokid_bg2_bank << 10) | offset];
}
WRITE8_MEMBER(robokid_state::robokid_bg0_videoram_w)
{
int const address = (m_robokid_bg0_bank << 10 ) | offset;
m_robokid_bg0_videoram[address] = data;
m_bg0_tilemap->mark_tile_dirty(address >> 1);
}
WRITE8_MEMBER(robokid_state::robokid_bg1_videoram_w)
{
int const address = (m_robokid_bg1_bank << 10 ) | offset;
m_robokid_bg1_videoram[address] = data;
m_bg1_tilemap->mark_tile_dirty(address >> 1);
}
WRITE8_MEMBER(robokid_state::robokid_bg2_videoram_w)
{
int const address = (m_robokid_bg2_bank << 10 ) | offset;
m_robokid_bg2_videoram[address] = data;
m_bg2_tilemap->mark_tile_dirty(address >> 1);
}
void ninjakd2_state::bg_ctrl(int offset, int data, tilemap_t* tilemap)
{
int scrollx = tilemap->scrollx(0);
@ -295,10 +218,10 @@ void ninjakd2_state::bg_ctrl(int offset, int data, tilemap_t* tilemap)
switch (offset)
{
case 0: scrollx = ((scrollx & 0x100) | data); break;
case 1: scrollx = ((scrollx & 0x0ff) | (data << 8)); break;
case 2: scrolly = ((scrolly & 0x100) | data); break;
case 3: scrolly = ((scrolly & 0x0ff) | (data << 8)); break;
case 0: scrollx = ((scrollx & ~0xff) | data); break;
case 1: scrollx = ((scrollx & 0xff) | (data << 8)); break;
case 2: scrolly = ((scrolly & ~0xff) | data); break;
case 3: scrolly = ((scrolly & 0xff) | (data << 8)); break;
case 4: tilemap->enable(data & 1); break;
}
@ -311,22 +234,6 @@ WRITE8_MEMBER(ninjakd2_state::ninjakd2_bg_ctrl_w)
bg_ctrl(offset, data, m_bg_tilemap);
}
WRITE8_MEMBER(robokid_state::robokid_bg0_ctrl_w)
{
bg_ctrl(offset, data, m_bg0_tilemap);
}
WRITE8_MEMBER(robokid_state::robokid_bg1_ctrl_w)
{
bg_ctrl(offset, data, m_bg1_tilemap);
}
WRITE8_MEMBER(robokid_state::robokid_bg2_ctrl_w)
{
bg_ctrl(offset, data, m_bg2_tilemap);
}
WRITE8_MEMBER(ninjakd2_state::ninjakd2_sprite_overdraw_w)
{
m_next_sprite_overdraw_enabled = data & 1;
@ -488,10 +395,10 @@ uint32_t robokid_state::screen_update_robokid(screen_device &screen, bitmap_ind1
bitmap.fill(0, cliprect);
m_bg0_tilemap->draw(screen, bitmap, cliprect, 0, 0);
m_bg1_tilemap->draw(screen, bitmap, cliprect, 0, 0);
m_robokid_tilemap[0]->draw(screen, bitmap, cliprect, 0, 0);
m_robokid_tilemap[1]->draw(screen, bitmap, cliprect, 0, 0);
copybitmap_trans(bitmap, m_sprites_bitmap, 0, 0, 0, 0, cliprect, 0xf);
m_bg2_tilemap->draw(screen, bitmap, cliprect, 0, 0);
m_robokid_tilemap[2]->draw(screen, bitmap, cliprect, 0, 0);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
return 0;
@ -504,9 +411,9 @@ uint32_t omegaf_state::screen_update_omegaf(screen_device &screen, bitmap_ind16
bitmap.fill(0, cliprect);
m_bg0_tilemap->draw(screen, bitmap, cliprect, 0, 0);
m_bg1_tilemap->draw(screen, bitmap, cliprect, 0, 0);
m_bg2_tilemap->draw(screen, bitmap, cliprect, 0, 0);
m_robokid_tilemap[0]->draw(screen, bitmap, cliprect, 0, 0);
m_robokid_tilemap[1]->draw(screen, bitmap, cliprect, 0, 0);
m_robokid_tilemap[2]->draw(screen, bitmap, cliprect, 0, 0);
copybitmap_trans(bitmap, m_sprites_bitmap, 0, 0, 0, 0, cliprect, 0xf);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);