airbustr.cpp : Minor cleanups, Remove unnecessary bitmap (#3381)

* airbustr.cpp : Minor cleanups, Remove unnecessary bitmap

* airbustr.cpp : Minor cleanup of duplicates
This commit is contained in:
cam900 2018-03-25 03:29:25 +09:00 committed by Vas Crabb
parent e02583d79b
commit c1cc085725
3 changed files with 92 additions and 117 deletions

View File

@ -269,15 +269,16 @@ WRITE8_MEMBER(airbustr_state::master_nmi_trigger_w)
WRITE8_MEMBER(airbustr_state::master_bankswitch_w)
{
membank("masterbank")->set_entry(data & 0x07);
m_masterbank->set_entry(data & 0x07);
}
WRITE8_MEMBER(airbustr_state::slave_bankswitch_w)
{
membank("slavebank")->set_entry(data & 0x07);
m_slavebank->set_entry(data & 0x07);
for (int layer = 0; layer < 2; layer++)
m_tilemap[layer]->set_flip(BIT(data, 4) ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
m_bg_tilemap->set_flip(BIT(data, 4) ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
m_fg_tilemap->set_flip(BIT(data, 4) ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
m_pandora->flip_screen_set(BIT(data, 4));
// used at the end of levels, after defeating the boss, to leave trails
@ -286,16 +287,30 @@ WRITE8_MEMBER(airbustr_state::slave_bankswitch_w)
WRITE8_MEMBER(airbustr_state::sound_bankswitch_w)
{
membank("audiobank")->set_entry(data & 0x07);
m_audiobank->set_entry(data & 0x07);
}
READ8_MEMBER(airbustr_state::soundcommand_status_r)
{
// bits: 2 <-> ? 1 <-> soundlatch full 0 <-> soundlatch2 empty
return 4 | (m_soundlatch->pending_r() << 1) | !m_soundlatch2->pending_r();
return 4 | (m_soundlatch[0]->pending_r() << 1) | !m_soundlatch[1]->pending_r();
}
template<int Layer>
WRITE8_MEMBER(airbustr_state::videoram_w)
{
m_videoram[Layer][offset] = data;
m_tilemap[Layer]->mark_tile_dirty(offset);
}
template<int Layer>
WRITE8_MEMBER(airbustr_state::colorram_w)
{
m_colorram[Layer][offset] = data;
m_tilemap[Layer]->mark_tile_dirty(offset);
}
WRITE8_MEMBER(airbustr_state::coin_counter_w)
{
machine().bookkeeping().coin_counter_w(0, data & 1);
@ -327,10 +342,10 @@ void airbustr_state::slave_map(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0x8000, 0xbfff).bankr("slavebank");
map(0xc000, 0xc3ff).ram().w(this, FUNC(airbustr_state::videoram2_w)).share("videoram2");
map(0xc400, 0xc7ff).ram().w(this, FUNC(airbustr_state::colorram2_w)).share("colorram2");
map(0xc800, 0xcbff).ram().w(this, FUNC(airbustr_state::videoram_w)).share("videoram");
map(0xcc00, 0xcfff).ram().w(this, FUNC(airbustr_state::colorram_w)).share("colorram");
map(0xc000, 0xc3ff).ram().w(this, FUNC(airbustr_state::videoram_w<1>)).share("videoram2");
map(0xc400, 0xc7ff).ram().w(this, FUNC(airbustr_state::colorram_w<1>)).share("colorram2");
map(0xc800, 0xcbff).ram().w(this, FUNC(airbustr_state::videoram_w<0>)).share("videoram1");
map(0xcc00, 0xcfff).ram().w(this, FUNC(airbustr_state::colorram_w<0>)).share("colorram1");
map(0xd000, 0xd5ff).ram().w(m_palette, FUNC(palette_device::write8)).share("palette");
map(0xd600, 0xdfff).ram();
map(0xe000, 0xefff).ram();
@ -341,7 +356,7 @@ void airbustr_state::slave_io_map(address_map &map)
{
map.global_mask(0xff);
map(0x00, 0x00).w(this, FUNC(airbustr_state::slave_bankswitch_w));
map(0x02, 0x02).r(m_soundlatch2, FUNC(generic_latch_8_device::read)).w(m_soundlatch, FUNC(generic_latch_8_device::write));
map(0x02, 0x02).r(m_soundlatch[1], FUNC(generic_latch_8_device::read)).w(m_soundlatch[0], FUNC(generic_latch_8_device::write));
map(0x04, 0x0c).w(this, FUNC(airbustr_state::scrollregs_w));
map(0x0e, 0x0e).r(this, FUNC(airbustr_state::soundcommand_status_r));
map(0x20, 0x20).portr("P1");
@ -364,7 +379,7 @@ void airbustr_state::sound_io_map(address_map &map)
map(0x00, 0x00).w(this, FUNC(airbustr_state::sound_bankswitch_w));
map(0x02, 0x03).rw("ymsnd", FUNC(ym2203_device::read), FUNC(ym2203_device::write));
map(0x04, 0x04).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write));
map(0x06, 0x06).r(m_soundlatch, FUNC(generic_latch_8_device::read)).w(m_soundlatch2, FUNC(generic_latch_8_device::write));
map(0x06, 0x06).r(m_soundlatch[0], FUNC(generic_latch_8_device::read)).w(m_soundlatch[1], FUNC(generic_latch_8_device::write));
}
/* Input Ports */
@ -527,23 +542,21 @@ INTERRUPT_GEN_MEMBER(airbustr_state::slave_interrupt)
void airbustr_state::machine_start()
{
membank("masterbank")->configure_entries(0, 8, memregion("master")->base(), 0x4000);
membank("slavebank")->configure_entries(0, 8, memregion("slave")->base(), 0x4000);
membank("audiobank")->configure_entries(0, 8, memregion("audiocpu")->base(), 0x4000);
m_masterbank->configure_entries(0, 8, memregion("master")->base(), 0x4000);
m_slavebank->configure_entries(0, 8, memregion("slave")->base(), 0x4000);
m_audiobank->configure_entries(0, 8, memregion("audiocpu")->base(), 0x4000);
save_item(NAME(m_bg_scrollx));
save_item(NAME(m_bg_scrolly));
save_item(NAME(m_fg_scrollx));
save_item(NAME(m_fg_scrolly));
save_item(NAME(m_scrollx));
save_item(NAME(m_scrolly));
save_item(NAME(m_highbits));
}
void airbustr_state::machine_reset()
{
m_bg_scrollx = 0;
m_bg_scrolly = 0;
m_fg_scrollx = 0;
m_fg_scrolly = 0;
m_scrollx[0] = 0;
m_scrolly[0] = 0;
m_scrollx[1] = 0;
m_scrolly[1] = 0;
m_highbits = 0;
}
@ -594,7 +607,7 @@ MACHINE_CONFIG_START(airbustr_state::airbustr)
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_GENERIC_LATCH_8_ADD("soundlatch")
MCFG_GENERIC_LATCH_8_ADD("soundlatch1")
MCFG_GENERIC_LATCH_DATA_PENDING_CB(INPUTLINE("audiocpu", INPUT_LINE_NMI))
MCFG_GENERIC_LATCH_8_ADD("soundlatch2")

View File

@ -16,39 +16,38 @@ class airbustr_state : public driver_device
{
public:
airbustr_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_devram(*this, "devram"),
m_videoram2(*this, "videoram2"),
m_colorram2(*this, "colorram2"),
m_videoram(*this, "videoram"),
m_colorram(*this, "colorram"),
m_master(*this, "master"),
m_slave(*this, "slave"),
m_audiocpu(*this, "audiocpu"),
m_pandora(*this, "pandora"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_palette(*this, "palette"),
m_watchdog(*this, "watchdog"),
m_soundlatch(*this, "soundlatch"),
m_soundlatch2(*this, "soundlatch2")
{ }
: driver_device(mconfig, type, tag)
, m_devram(*this, "devram")
, m_videoram(*this, "videoram%u", 1)
, m_colorram(*this, "colorram%u", 1)
, m_masterbank(*this, "masterbank")
, m_slavebank(*this, "slavebank")
, m_audiobank(*this, "audiobank")
, m_master(*this, "master")
, m_slave(*this, "slave")
, m_audiocpu(*this, "audiocpu")
, m_pandora(*this, "pandora")
, m_gfxdecode(*this, "gfxdecode")
, m_screen(*this, "screen")
, m_palette(*this, "palette")
, m_watchdog(*this, "watchdog")
, m_soundlatch(*this, "soundlatch%u", 1)
{
}
/* memory pointers */
required_shared_ptr<uint8_t> m_devram;
required_shared_ptr<uint8_t> m_videoram2;
required_shared_ptr<uint8_t> m_colorram2;
required_shared_ptr<uint8_t> m_videoram;
required_shared_ptr<uint8_t> m_colorram;
required_shared_ptr_array<uint8_t, 2> m_videoram;
required_shared_ptr_array<uint8_t, 2> m_colorram;
required_memory_bank m_masterbank;
required_memory_bank m_slavebank;
required_memory_bank m_audiobank;
/* video-related */
tilemap_t *m_bg_tilemap;
tilemap_t *m_fg_tilemap;
bitmap_ind16 m_sprites_bitmap;
int m_bg_scrollx;
int m_bg_scrolly;
int m_fg_scrollx;
int m_fg_scrolly;
tilemap_t *m_tilemap[2];
int m_scrollx[2];
int m_scrolly[2];
int m_highbits;
/* devices */
@ -60,8 +59,7 @@ public:
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
required_device<watchdog_timer_device> m_watchdog;
required_device<generic_latch_8_device> m_soundlatch;
required_device<generic_latch_8_device> m_soundlatch2;
required_device_array<generic_latch_8_device, 2> m_soundlatch;
DECLARE_READ8_MEMBER(devram_r);
DECLARE_WRITE8_MEMBER(master_nmi_trigger_w);
@ -70,14 +68,11 @@ public:
DECLARE_WRITE8_MEMBER(sound_bankswitch_w);
DECLARE_READ8_MEMBER(soundcommand_status_r);
DECLARE_WRITE8_MEMBER(coin_counter_w);
DECLARE_WRITE8_MEMBER(videoram_w);
DECLARE_WRITE8_MEMBER(colorram_w);
DECLARE_WRITE8_MEMBER(videoram2_w);
DECLARE_WRITE8_MEMBER(colorram2_w);
template<int Layer> DECLARE_WRITE8_MEMBER(videoram_w);
template<int Layer> DECLARE_WRITE8_MEMBER(colorram_w);
DECLARE_WRITE8_MEMBER(scrollregs_w);
DECLARE_DRIVER_INIT(airbustr);
TILE_GET_INFO_MEMBER(get_fg_tile_info);
TILE_GET_INFO_MEMBER(get_bg_tile_info);
template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info);
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;

View File

@ -35,30 +35,6 @@
#include "emu.h"
#include "includes/airbustr.h"
WRITE8_MEMBER(airbustr_state::videoram_w)
{
m_videoram[offset] = data;
m_bg_tilemap->mark_tile_dirty(offset);
}
WRITE8_MEMBER(airbustr_state::colorram_w)
{
m_colorram[offset] = data;
m_bg_tilemap->mark_tile_dirty(offset);
}
WRITE8_MEMBER(airbustr_state::videoram2_w)
{
m_videoram2[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
WRITE8_MEMBER(airbustr_state::colorram2_w)
{
m_colorram2[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
/* Scroll Registers
Port:
@ -75,60 +51,51 @@ WRITE8_MEMBER(airbustr_state::scrollregs_w)
{
switch (offset) // offset 0 <-> port 4
{
case 0x00: m_fg_scrolly = data; break; // low 8 bits
case 0x02: m_fg_scrollx = data; break;
case 0x04: m_bg_scrolly = data; break;
case 0x06: m_bg_scrollx = data; break;
case 0x00:
case 0x04: m_scrolly[((offset & 4) >> 2) ^ 1] = data; break; // low 8 bits
case 0x02:
case 0x06: m_scrollx[((offset & 4) >> 2) ^ 1] = data; break;
case 0x08: m_highbits = ~data; break; // complemented high bits
default: logerror("CPU #2 - port %02X written with %02X - PC = %04X\n", offset, data, m_slave->pc());
}
m_bg_tilemap->set_scrolly(0, ((m_highbits << 5) & 0x100) + m_bg_scrolly);
m_bg_tilemap->set_scrollx(0, ((m_highbits << 6) & 0x100) + m_bg_scrollx);
m_fg_tilemap->set_scrolly(0, ((m_highbits << 7) & 0x100) + m_fg_scrolly);
m_fg_tilemap->set_scrollx(0, ((m_highbits << 8) & 0x100) + m_fg_scrollx);
for (int layer = 0; layer < 2; layer++)
{
m_tilemap[layer]->set_scrolly(0, ((m_highbits << (5+(layer<<1))) & 0x100) + m_scrolly[layer]);
m_tilemap[layer]->set_scrollx(0, ((m_highbits << (6+(layer<<1))) & 0x100) + m_scrollx[layer]);
}
}
TILE_GET_INFO_MEMBER(airbustr_state::get_fg_tile_info)
template<int Layer>
TILE_GET_INFO_MEMBER(airbustr_state::get_tile_info)
{
int attr = m_colorram2[tile_index];
int code = m_videoram2[tile_index] + ((attr & 0x0f) << 8);
int color = attr >> 4;
SET_TILE_INFO_MEMBER(0, code, color, 0);
}
TILE_GET_INFO_MEMBER(airbustr_state::get_bg_tile_info)
{
int attr = m_colorram[tile_index];
int code = m_videoram[tile_index] + ((attr & 0x0f) << 8);
int color = (attr >> 4) + 16;
int attr = m_colorram[Layer][tile_index];
int code = m_videoram[Layer][tile_index] + ((attr & 0x0f) << 8);
int color = (attr >> 4) + ((Layer ^ 1) << 4);
SET_TILE_INFO_MEMBER(0, code, color, 0);
}
void airbustr_state::video_start()
{
m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(airbustr_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(airbustr_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(airbustr_state::get_tile_info<0>),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(airbustr_state::get_tile_info<1>),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_screen->register_screen_bitmap(m_sprites_bitmap);
m_fg_tilemap->set_transparent_pen(0);
m_tilemap[1]->set_transparent_pen(0);
m_bg_tilemap->set_scrolldx(0x094, 0x06a);
m_bg_tilemap->set_scrolldy(0x100, 0x1ff);
m_fg_tilemap->set_scrolldx(0x094, 0x06a);
m_fg_tilemap->set_scrolldy(0x100, 0x1ff);
save_item(NAME(m_sprites_bitmap));
for (int layer = 0; layer < 2; layer++)
{
m_tilemap[layer]->set_scrolldx(0x094, 0x06a);
m_tilemap[layer]->set_scrolldy(0x100, 0x1ff);
}
}
uint32_t airbustr_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
m_tilemap[0]->draw(screen, bitmap, cliprect, 0, 0);
m_tilemap[1]->draw(screen, bitmap, cliprect, 0, 0);
// copy the sprite bitmap to the screen
m_pandora->update(bitmap, cliprect);