From 92da004d49b5b774c7804185e8787d464b098e18 Mon Sep 17 00:00:00 2001 From: wilbertpol Date: Sun, 21 Apr 2024 19:01:21 +0100 Subject: bus/msx/cart: Use arrays of memory views to make code more concise. (#12292) bus/msx/cart/dooly.cpp: Use memory banks instead of views. --- src/devices/bus/msx/cart/ascii.cpp | 34 ++--- src/devices/bus/msx/cart/dooly.cpp | 42 +++--- src/devices/bus/msx/cart/fs_sr021.cpp | 76 ++++------ src/devices/bus/msx/cart/halnote.cpp | 82 +++++------ src/devices/bus/msx/cart/holy_quran.cpp | 42 +++--- src/devices/bus/msx/cart/konami.cpp | 221 +++++++++++++----------------- src/devices/bus/msx/cart/msx_audio.cpp | 52 +++---- src/devices/bus/msx/cart/msxdos2.cpp | 40 ++---- src/devices/bus/msx/cart/scsi.cpp | 64 ++++----- src/devices/bus/msx/cart/slotexpander.cpp | 42 ++---- 10 files changed, 285 insertions(+), 410 deletions(-) diff --git a/src/devices/bus/msx/cart/ascii.cpp b/src/devices/bus/msx/cart/ascii.cpp index 61572df0fdd..359b7f479e5 100644 --- a/src/devices/bus/msx/cart/ascii.cpp +++ b/src/devices/bus/msx/cart/ascii.cpp @@ -158,8 +158,7 @@ public: : device_t(mconfig, MSX_CART_ASCII8_SRAM, tag, owner, clock) , msx_cart_interface(mconfig, *this) , m_rombank(*this, "rombank%u", 0U) - , m_view2(*this, "view2") - , m_view3(*this, "view3") + , m_view{ {*this, "view2"}, {*this, "view3"} } , m_bank_mask(0) , m_sram_select_mask(0) { } @@ -177,8 +176,7 @@ private: void mapper_write(offs_t offset, u8 data); memory_bank_array_creator<4> m_rombank; - memory_view m_view2; - memory_view m_view3; + memory_view m_view[2]; u8 m_bank_mask; u8 m_sram_select_mask; }; @@ -187,8 +185,8 @@ void msx_cart_ascii8_sram_device::device_reset() { for (int i = 0; i < 4; i++) m_rombank[i]->set_entry(0); - m_view2.select(0); - m_view3.select(0); + m_view[0].select(0); + m_view[1].select(0); } std::error_condition msx_cart_ascii8_sram_device::initialize_cartridge(std::string &message) @@ -229,12 +227,12 @@ std::error_condition msx_cart_ascii8_sram_device::initialize_cartridge(std::stri page(1)->install_read_bank(0x4000, 0x5fff, m_rombank[0]); page(1)->install_read_bank(0x6000, 0x7fff, m_rombank[1]); page(1)->install_write_handler(0x6000, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_ascii8_sram_device::mapper_write))); - page(2)->install_view(0x8000, 0x9fff, m_view2); - m_view2[0].install_read_bank(0x8000, 0x9fff, m_rombank[2]); - m_view2[1].install_ram(0x8000, 0x9fff, cart_sram_region()->base()); - page(2)->install_view(0xa000, 0xbfff, m_view3); - m_view3[0].install_read_bank(0xa000, 0xbfff, m_rombank[3]); - m_view3[1].install_ram(0xa000, 0xbfff, cart_sram_region()->base()); + page(2)->install_view(0x8000, 0x9fff, m_view[0]); + m_view[0][0].install_read_bank(0x8000, 0x9fff, m_rombank[2]); + m_view[0][1].install_ram(0x8000, 0x9fff, cart_sram_region()->base()); + page(2)->install_view(0xa000, 0xbfff, m_view[1]); + m_view[1][0].install_read_bank(0xa000, 0xbfff, m_rombank[3]); + m_view[1][1].install_ram(0xa000, 0xbfff, cart_sram_region()->base()); return std::error_condition(); } @@ -244,17 +242,13 @@ void msx_cart_ascii8_sram_device::mapper_write(offs_t offset, u8 data) u8 bank = (offset / 0x800) & 0x03; if (data & m_sram_select_mask) { - if (bank == 2) - m_view2.select(1); - if (bank == 3) - m_view3.select(1); + if (BIT(bank, 1)) + m_view[BIT(bank, 0)].select(1); } else { - if (bank == 2) - m_view2.select(0); - if (bank == 3) - m_view3.select(0); + if (BIT(bank, 1)) + m_view[BIT(bank, 0)].select(0); m_rombank[bank]->set_entry(data & m_bank_mask); } diff --git a/src/devices/bus/msx/cart/dooly.cpp b/src/devices/bus/msx/cart/dooly.cpp index 24a12a98b1a..b01baf35bf2 100644 --- a/src/devices/bus/msx/cart/dooly.cpp +++ b/src/devices/bus/msx/cart/dooly.cpp @@ -11,8 +11,7 @@ public: msx_cart_dooly_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, MSX_CART_DOOLY, tag, owner, clock) , msx_cart_interface(mconfig, *this) - , m_view1(*this, "view1") - , m_view2(*this, "view2") + , m_rombank(*this, "bank%u", 0U) { } virtual std::error_condition initialize_cartridge(std::string &message) override; @@ -27,14 +26,14 @@ private: u8 mode4_page1_r(offs_t offset); u8 mode4_page2_r(offs_t offset); - memory_view m_view1; - memory_view m_view2; + std::unique_ptr m_bitswapped; + memory_bank_array_creator<2> m_rombank; }; void msx_cart_dooly_device::device_reset() { - m_view1.select(0); - m_view2.select(0); + m_rombank[0]->set_entry(0); + m_rombank[1]->set_entry(0); } std::error_condition msx_cart_dooly_device::initialize_cartridge(std::string &message) @@ -51,34 +50,29 @@ std::error_condition msx_cart_dooly_device::initialize_cartridge(std::string &me return image_error::INVALIDLENGTH; } - page(1)->install_view(0x4000, 0x7fff, m_view1); - m_view1[0].install_rom(0x4000, 0x7fff, cart_rom_region()->base()); - m_view1[1].install_read_handler(0x4000, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_dooly_device::mode4_page1_r))); - page(2)->install_view(0x8000, 0xbfff, m_view2); - m_view2[0].install_rom(0x8000, 0xbfff, cart_rom_region()->base() + 0x4000); - m_view2[1].install_read_handler(0x8000, 0xbfff, emu::rw_delegate(*this, FUNC(msx_cart_dooly_device::mode4_page2_r))); + m_bitswapped = std::make_unique(0x8000); + for (int i = 0; i < 0x8000; i++) + m_bitswapped[i] = bitswap<8>(cart_rom_region()->base()[i], 7, 6, 5, 4, 3, 1, 0, 2); + m_rombank[0]->configure_entry(0, cart_rom_region()->base()); + m_rombank[0]->configure_entry(1, m_bitswapped.get()); + m_rombank[1]->configure_entry(0, cart_rom_region()->base() + 0x4000); + m_rombank[1]->configure_entry(1, m_bitswapped.get() + 0x4000); + + page(1)->install_read_bank(0x4000, 0x7fff, m_rombank[0]); page(1)->install_write_handler(0x4000, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_dooly_device::prot_w))); + page(2)->install_read_bank(0x8000, 0xbfff, m_rombank[1]); page(2)->install_write_handler(0x8000, 0xbfff, emu::rw_delegate(*this, FUNC(msx_cart_dooly_device::prot_w))); return std::error_condition(); } -u8 msx_cart_dooly_device::mode4_page1_r(offs_t offset) -{ - return bitswap<8>(cart_rom_region()->base()[offset], 7, 6, 5, 4, 3, 1, 0, 2); -} - -u8 msx_cart_dooly_device::mode4_page2_r(offs_t offset) -{ - return bitswap<8>(cart_rom_region()->base()[0x4000 | offset], 7, 6, 5, 4, 3, 1, 0, 2); -} - void msx_cart_dooly_device::prot_w(u8 data) { data &= 0x07; - m_view1.select(BIT(data, 2) ? 1 : 0); - m_view2.select(BIT(data, 2) ? 1 : 0); + m_rombank[0]->set_entry(BIT(data, 2) ? 1 : 0); + m_rombank[1]->set_entry(BIT(data, 2) ? 1 : 0); + if (data != 0 && data != 4) { logerror("msx_cart_dooly_device: unhandled protection mode %02x\n", data); diff --git a/src/devices/bus/msx/cart/fs_sr021.cpp b/src/devices/bus/msx/cart/fs_sr021.cpp index 712b7826a3f..ada85937b7a 100644 --- a/src/devices/bus/msx/cart/fs_sr021.cpp +++ b/src/devices/bus/msx/cart/fs_sr021.cpp @@ -21,12 +21,7 @@ public: : device_t(mconfig, MSX_CART_FS_SR021, tag, owner, clock) , msx_cart_interface(mconfig, *this) , m_bank(*this, "bank%u", 0U) - , m_view_0000(*this, "view0000") - , m_view_2000(*this, "view2000") - , m_view_4000(*this, "view4000") - , m_view_6000(*this, "view6000") - , m_view_8000(*this, "view8000") - , m_view_a000(*this, "viewa000") + , m_view{ {*this, "view0000"}, {*this, "view2000"}, {*this, "view4000"}, {*this, "view6000"}, {*this, "view8000"}, {*this, "viewa000"} } { } virtual std::error_condition initialize_cartridge(std::string &message) override; @@ -47,12 +42,7 @@ private: void kanji_w(offs_t offset, u8 data); memory_bank_array_creator<6> m_bank; - memory_view m_view_0000; - memory_view m_view_2000; - memory_view m_view_4000; - memory_view m_view_6000; - memory_view m_view_8000; - memory_view m_view_a000; + memory_view m_view[6]; u8 m_selected_bank[6]; u8 m_control; u32 m_kanji_latch; @@ -68,12 +58,8 @@ void msx_cart_fs_sr021_device::device_start() void msx_cart_fs_sr021_device::device_reset() { m_control = 0; - m_view_0000.select(0); - m_view_2000.select(0); - m_view_4000.select(0); - m_view_6000.select(0); - m_view_8000.select(0); - m_view_a000.select(0); + for (int i = 0; i < 6; i++) + m_view[i].select(0); m_bank[2]->set_entry(0); } @@ -113,30 +99,22 @@ std::error_condition msx_cart_fs_sr021_device::initialize_cartridge(std::string m_bank[i]->configure_entry(0x81, cart_sram_region()->base() + BANK_SIZE); } - page(0)->install_view(0x0000, 0x1fff, m_view_0000); - m_view_0000[0].install_read_bank(0x0000, 0x1fff, m_bank[0]); - m_view_0000[1].install_readwrite_bank(0x0000, 0x1fff, m_bank[0]); - page(0)->install_view(0x2000, 0x3fff, m_view_2000); - m_view_2000[0].install_read_bank(0x2000, 0x3fff, m_bank[1]); - m_view_2000[1].install_readwrite_bank(0x2000, 0x3fff, m_bank[1]); - - page(1)->install_view(0x4000, 0x5fff, m_view_4000); - m_view_4000[0].install_read_bank(0x4000, 0x5fff, m_bank[2]); - m_view_4000[1].install_readwrite_bank(0x4000, 0x5fff, m_bank[2]); - page(1)->install_view(0x6000, 0x7fff, m_view_6000); - m_view_6000[0].install_read_bank(0x6000, 0x7fff, m_bank[3]); - m_view_6000[1].install_readwrite_bank(0x6000, 0x7fff, m_bank[3]); - m_view_6000[2].install_read_bank(0x6000, 0x7fff, m_bank[3]); - m_view_6000[2].install_read_handler(0x7ff0, 0x7ff5, emu::rw_delegate(*this, FUNC(msx_cart_fs_sr021_device::bank_r))); - m_view_6000[3].install_readwrite_bank(0x6000, 0x7fff, m_bank[3]); - m_view_6000[3].install_read_handler(0x7ff0, 0x7ff5, emu::rw_delegate(*this, FUNC(msx_cart_fs_sr021_device::bank_r))); - - page(2)->install_view(0x8000, 0x9fff, m_view_8000); - m_view_8000[0].install_read_bank(0x8000, 0x9fff, m_bank[4]); - m_view_8000[1].install_readwrite_bank(0x8000, 0x9fff, m_bank[4]); - page(2)->install_view(0xa000, 0xbfff, m_view_a000); - m_view_a000[0].install_read_bank(0xa000, 0xbfff, m_bank[5]); - m_view_a000[1].install_readwrite_bank(0xa000, 0xbfff, m_bank[5]); + for (int pg = 0; pg < 3; pg++) + { + const offs_t start = pg * 0x4000; + const int index = pg * 2; + page(pg)->install_view(start, start + 0x1fff, m_view[index]); + m_view[index][0].install_read_bank(start, start + 0x1fff, m_bank[index]); + m_view[index][1].install_readwrite_bank(start, start + 0x1fff, m_bank[index]); + page(pg)->install_view(start + 0x2000, start + 0x3fff, m_view[index + 1]); + m_view[index + 1][0].install_read_bank(start + 0x2000, start + 0x3fff, m_bank[index + 1]); + m_view[index + 1][1].install_readwrite_bank(start + 0x2000, start + 0x3fff, m_bank[index + 1]); + } + + m_view[3][2].install_read_bank(0x6000, 0x7fff, m_bank[3]); + m_view[3][2].install_read_handler(0x7ff0, 0x7ff5, emu::rw_delegate(*this, FUNC(msx_cart_fs_sr021_device::bank_r))); + m_view[3][3].install_readwrite_bank(0x6000, 0x7fff, m_bank[3]); + m_view[3][3].install_read_handler(0x7ff0, 0x7ff5, emu::rw_delegate(*this, FUNC(msx_cart_fs_sr021_device::bank_r))); page(1)->install_write_handler(0x6000, 0x6000, emu::rw_delegate(*this, FUNC(msx_cart_fs_sr021_device::bank_w<0>))); // 0000-1fff page(1)->install_write_handler(0x6400, 0x6400, emu::rw_delegate(*this, FUNC(msx_cart_fs_sr021_device::bank_w<1>))); // 2000-3fff @@ -157,18 +135,10 @@ template void msx_cart_fs_sr021_device::set_view() { bool ram_active = (m_selected_bank[Bank] >= 0x80 && m_selected_bank[Bank] < 0x82); - if (Bank == 0) - m_view_0000.select(ram_active ? 1 : 0); - if (Bank == 1) - m_view_2000.select(ram_active ? 1 : 0); - if (Bank == 2) - m_view_4000.select(ram_active ? 1 : 0); if (Bank == 3) - m_view_6000.select((BIT(m_control, 2) ? 2 : 0) | (ram_active ? 1 : 0)); - if (Bank == 4) - m_view_8000.select(ram_active ? 1 : 0); - if (Bank == 5) - m_view_a000.select(ram_active ? 1 : 0); + m_view[Bank].select((BIT(m_control, 2) ? 2 : 0) | (ram_active ? 1 : 0)); + else + m_view[Bank].select(ram_active ? 1 : 0); } template diff --git a/src/devices/bus/msx/cart/halnote.cpp b/src/devices/bus/msx/cart/halnote.cpp index bbd6b034364..cc9c5dcfca3 100644 --- a/src/devices/bus/msx/cart/halnote.cpp +++ b/src/devices/bus/msx/cart/halnote.cpp @@ -12,8 +12,7 @@ public: : device_t(mconfig, MSX_CART_HALNOTE, tag, owner, clock) , msx_cart_interface(mconfig, *this) , m_rombank(*this, "rombank%u", 0U) - , m_view0(*this, "view0") - , m_view1(*this, "view1") + , m_view{ {*this, "view0"}, {*this, "view1"} } { } virtual std::error_condition initialize_cartridge(std::string &message) override; @@ -26,16 +25,15 @@ protected: private: static constexpr u8 BANK_MASK = (0x100000 / 0x2000) - 1; + template void bank_w(u8 data); void bank0_w(u8 data); void bank1_w(u8 data); void bank2_w(u8 data); void bank3_w(u8 data); - void bank4_w(u8 data); - void bank5_w(u8 data); + template void bank_small_w(u8 data); memory_bank_array_creator<6> m_rombank; - memory_view m_view0; - memory_view m_view1; + memory_view m_view[2]; }; void msx_cart_halnote_device::device_reset() @@ -43,8 +41,8 @@ void msx_cart_halnote_device::device_reset() for (int i = 0; i < 6; i++) m_rombank[i]->set_entry(0); - m_view0.disable(); - m_view1.select(0); + m_view[0].disable(); + m_view[1].select(0); } std::error_condition msx_cart_halnote_device::initialize_cartridge(std::string &message) @@ -80,60 +78,42 @@ std::error_condition msx_cart_halnote_device::initialize_cartridge(std::string & m_rombank[4]->configure_entries(0, 0x100, cart_rom_region()->base() + 0x80000, 0x800); m_rombank[5]->configure_entries(0, 0x100, cart_rom_region()->base() + 0x80000, 0x800); - page(0)->install_view(0x0000, 0x3fff, m_view0); - m_view0[0]; - m_view0[1].install_ram(0x0000, 0x3fff, cart_sram_region()->base()); + page(0)->install_view(0x0000, 0x3fff, m_view[0]); + m_view[0][0]; + m_view[0][1].install_ram(0x0000, 0x3fff, cart_sram_region()->base()); page(1)->install_read_bank(0x4000, 0x5fff, m_rombank[0]); - page(1)->install_write_handler(0x4fff, 0x4fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank0_w))); - page(1)->install_view(0x6000, 0x7fff, m_view1); - m_view1[0].install_read_bank(0x6000, 0x7fff, m_rombank[1]); - m_view1[0].install_write_handler(0x6fff, 0x6fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank1_w))); - m_view1[0].install_write_handler(0x77ff, 0x77ff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank4_w))); - m_view1[0].install_write_handler(0x7fff, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank5_w))); - m_view1[1].install_read_bank(0x6000, 0x6fff, m_rombank[1]); - m_view1[1].install_write_handler(0x6fff, 0x6fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank1_w))); - m_view1[1].install_read_bank(0x7000, 0x77ff, m_rombank[4]); - m_view1[1].install_write_handler(0x77ff, 0x77ff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank4_w))); - m_view1[1].install_read_bank(0x7800, 0x7fff, m_rombank[5]); - m_view1[1].install_write_handler(0x7fff, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank5_w))); + page(1)->install_write_handler(0x4fff, 0x4fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank_w<0>))); + page(1)->install_view(0x6000, 0x7fff, m_view[1]); + m_view[1][0].install_read_bank(0x6000, 0x7fff, m_rombank[1]); + m_view[1][0].install_write_handler(0x6fff, 0x6fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank_w<1>))); + m_view[1][0].install_write_handler(0x77ff, 0x77ff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank_small_w<4>))); + m_view[1][0].install_write_handler(0x7fff, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank_small_w<5>))); + m_view[1][1].install_read_bank(0x6000, 0x6fff, m_rombank[1]); + m_view[1][1].install_write_handler(0x6fff, 0x6fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank_w<1>))); + m_view[1][1].install_read_bank(0x7000, 0x77ff, m_rombank[4]); + m_view[1][1].install_write_handler(0x77ff, 0x77ff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank_small_w<4>))); + m_view[1][1].install_read_bank(0x7800, 0x7fff, m_rombank[5]); + m_view[1][1].install_write_handler(0x7fff, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank_small_w<5>))); page(2)->install_read_bank(0x8000, 0x9fff, m_rombank[2]); - page(2)->install_write_handler(0x8fff, 0x8fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank2_w))); + page(2)->install_write_handler(0x8fff, 0x8fff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank_w<2>))); page(2)->install_read_bank(0xa000, 0xbfff, m_rombank[3]); - page(2)->install_write_handler(0xafff, 0xafff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank3_w))); + page(2)->install_write_handler(0xafff, 0xafff, emu::rw_delegate(*this, FUNC(msx_cart_halnote_device::bank_w<3>))); return std::error_condition(); } -void msx_cart_halnote_device::bank0_w(u8 data) +template +void msx_cart_halnote_device::bank_w(u8 data) { - m_rombank[0]->set_entry(data & 0x7f); - m_view0.select(BIT(data, 7) ? 1 : 0); + m_rombank[Bank]->set_entry(data & 0x7f); + if (Bank == 0 || Bank == 3) + m_view[Bank ? 1 : 0].select(BIT(data, 7) ? 1 : 0); } -void msx_cart_halnote_device::bank1_w(u8 data) +template +void msx_cart_halnote_device::bank_small_w(u8 data) { - m_rombank[1]->set_entry(data & 0x7f); -} - -void msx_cart_halnote_device::bank2_w(u8 data) -{ - m_rombank[2]->set_entry(data & 0x7f); -} - -void msx_cart_halnote_device::bank3_w(u8 data) -{ - m_rombank[3]->set_entry(data & 0x7f); - m_view1.select(BIT(data, 7) ? 1 : 0); -} - -void msx_cart_halnote_device::bank4_w(u8 data) -{ - m_rombank[4]->set_entry(data); -} - -void msx_cart_halnote_device::bank5_w(u8 data) -{ - m_rombank[5]->set_entry(data); + m_rombank[Bank]->set_entry(data); } } // anonymous namespace diff --git a/src/devices/bus/msx/cart/holy_quran.cpp b/src/devices/bus/msx/cart/holy_quran.cpp index 74df118b46b..327651ed96a 100644 --- a/src/devices/bus/msx/cart/holy_quran.cpp +++ b/src/devices/bus/msx/cart/holy_quran.cpp @@ -21,8 +21,7 @@ public: : device_t(mconfig, MSX_CART_HOLY_QURAN, tag, owner, clock) , msx_cart_interface(mconfig, *this) , m_rombank(*this, "rombank%u", 0U) - , m_view1(*this, "view1") - , m_view2(*this, "view2") + , m_view{ {*this, "view1"}, {*this, "view2"} } { } virtual std::error_condition initialize_cartridge(std::string &message) override; @@ -40,8 +39,7 @@ private: template void bank_w(u8 data); memory_bank_array_creator<4> m_rombank; - memory_view m_view1; - memory_view m_view2; + memory_view m_view[2]; std::vector m_decrypted; u8 m_bank_mask; @@ -76,27 +74,27 @@ std::error_condition msx_cart_holy_quran_device::initialize_cartridge(std::strin for (int i = 0; i < 4; i++) m_rombank[i]->configure_entries(0, banks, m_decrypted.data(), BANK_SIZE); - page(1)->install_view(0x4000, 0x7fff, m_view1); - m_view1[0].install_read_handler(0x4000, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::read))); - m_view1[1].install_read_bank(0x4000, 0x5fff, m_rombank[0]); - m_view1[1].install_read_bank(0x6000, 0x7fff, m_rombank[1]); - m_view1[1].install_write_handler(0x5000, 0x5000, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::bank_w<0>))); - m_view1[1].install_write_handler(0x5400, 0x5400, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::bank_w<1>))); - m_view1[1].install_write_handler(0x5800, 0x5800, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::bank_w<2>))); - m_view1[1].install_write_handler(0x5c00, 0x5c00, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::bank_w<3>))); + page(1)->install_view(0x4000, 0x7fff, m_view[0]); + m_view[0][0].install_read_handler(0x4000, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::read))); + m_view[0][1].install_read_bank(0x4000, 0x5fff, m_rombank[0]); + m_view[0][1].install_read_bank(0x6000, 0x7fff, m_rombank[1]); + m_view[0][1].install_write_handler(0x5000, 0x5000, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::bank_w<0>))); + m_view[0][1].install_write_handler(0x5400, 0x5400, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::bank_w<1>))); + m_view[0][1].install_write_handler(0x5800, 0x5800, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::bank_w<2>))); + m_view[0][1].install_write_handler(0x5c00, 0x5c00, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::bank_w<3>))); - page(2)->install_view(0x8000, 0xbfff, m_view2); - m_view2[0].install_read_handler(0x8000, 0xbfff, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::read2))); - m_view2[1].install_read_bank(0x8000, 0x9fff, m_rombank[2]); - m_view2[1].install_read_bank(0xa000, 0xbfff, m_rombank[3]); + page(2)->install_view(0x8000, 0xbfff, m_view[1]); + m_view[1][0].install_read_handler(0x8000, 0xbfff, emu::rw_delegate(*this, FUNC(msx_cart_holy_quran_device::read2))); + m_view[1][1].install_read_bank(0x8000, 0x9fff, m_rombank[2]); + m_view[1][1].install_read_bank(0xa000, 0xbfff, m_rombank[3]); return std::error_condition(); } void msx_cart_holy_quran_device::device_reset() { - m_view1.select(0); - m_view2.select(0); + m_view[0].select(0); + m_view[1].select(0); for (int i = 0; i < 4; i++) m_rombank[i]->set_entry(0); } @@ -108,8 +106,8 @@ u8 msx_cart_holy_quran_device::read(offs_t offset) if (offset + 0x4000 == ((cart_rom_region()->base()[3] << 8) | cart_rom_region()->base()[2]) && !machine().side_effects_disabled()) { // Switch to decrypted contents - m_view1.select(1); - m_view2.select(1); + m_view[0].select(1); + m_view[1].select(1); } return data; } @@ -121,8 +119,8 @@ u8 msx_cart_holy_quran_device::read2(offs_t offset) if (offset + 0x8000 == ((cart_rom_region()->base()[3] << 8) | cart_rom_region()->base()[2]) && !machine().side_effects_disabled()) { // Switch to decrypted contents - m_view1.select(1); - m_view2.select(1); + m_view[0].select(1); + m_view[1].select(1); } return data; } diff --git a/src/devices/bus/msx/cart/konami.cpp b/src/devices/bus/msx/cart/konami.cpp index 73944e945b8..0cee367d2e5 100644 --- a/src/devices/bus/msx/cart/konami.cpp +++ b/src/devices/bus/msx/cart/konami.cpp @@ -345,9 +345,7 @@ public: , msx_cart_interface(mconfig, *this) , m_rombank(*this, "rombank%u", 0U) , m_rambank(*this, "rambank%u", 0U) - , m_view0(*this, "view0") - , m_view1(*this, "view1") - , m_view2(*this, "view2") + , m_view{ {*this, "view0"}, {*this, "view1"}, {*this, "view2"} } { } virtual std::error_condition initialize_cartridge(std::string &message) override; @@ -362,9 +360,7 @@ private: memory_bank_array_creator<3> m_rombank; memory_bank_array_creator<3> m_rambank; - memory_view m_view0; - memory_view m_view1; - memory_view m_view2; + memory_view m_view[3]; }; void msx_cart_gamemaster2_device::device_reset() @@ -372,9 +368,8 @@ void msx_cart_gamemaster2_device::device_reset() m_rombank[0]->set_entry(1); m_rombank[1]->set_entry(1); m_rombank[2]->set_entry(2); - m_view0.select(0); - m_view1.select(0); - m_view2.select(0); + for (int i = 0; i < 3; i++) + m_view[i].select(0); } std::error_condition msx_cart_gamemaster2_device::initialize_cartridge(std::string &message) @@ -414,24 +409,24 @@ std::error_condition msx_cart_gamemaster2_device::initialize_cartridge(std::stri page(1)->install_rom(0x4000, 0x5fff, cart_rom_region()->base()); - page(1)->install_view(0x6000, 0x7fff, m_view0); - m_view0[0].install_read_bank(0x6000, 0x7fff, m_rombank[0]); - m_view0[0].install_write_handler(0x6000, 0x6fff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<0>))); - m_view0[1].install_read_bank(0x6000, 0x6fff, 0x1000, m_rambank[0]); - m_view0[1].install_write_handler(0x6000, 0x6fff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<0>))); - - page(2)->install_view(0x8000, 0x9fff, m_view1); - m_view1[0].install_read_bank(0x8000, 0x9fff, m_rombank[1]); - m_view1[0].install_write_handler(0x8000, 0x8fff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<1>))); - m_view1[1].install_read_bank(0x8000, 0x8fff, 0x1000, m_rambank[1]); - m_view1[1].install_write_handler(0x8000, 0x8fff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<1>))); - - page(2)->install_view(0xa000, 0xbfff, m_view2); - m_view2[0].install_read_bank(0xa000, 0xbfff, m_rombank[2]); - m_view2[0].install_write_handler(0xa000, 0xafff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<2>))); - m_view2[1].install_read_bank(0xa000, 0xafff, m_rambank[2]); - m_view2[1].install_write_handler(0xa000, 0xafff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<2>))); - m_view2[1].install_readwrite_bank(0xb000, 0xbfff, m_rambank[2]); + page(1)->install_view(0x6000, 0x7fff, m_view[0]); + m_view[0][0].install_read_bank(0x6000, 0x7fff, m_rombank[0]); + m_view[0][0].install_write_handler(0x6000, 0x6fff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<0>))); + m_view[0][1].install_read_bank(0x6000, 0x6fff, 0x1000, m_rambank[0]); + m_view[0][1].install_write_handler(0x6000, 0x6fff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<0>))); + + page(2)->install_view(0x8000, 0x9fff, m_view[1]); + m_view[1][0].install_read_bank(0x8000, 0x9fff, m_rombank[1]); + m_view[1][0].install_write_handler(0x8000, 0x8fff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<1>))); + m_view[1][1].install_read_bank(0x8000, 0x8fff, 0x1000, m_rambank[1]); + m_view[1][1].install_write_handler(0x8000, 0x8fff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<1>))); + + page(2)->install_view(0xa000, 0xbfff, m_view[2]); + m_view[2][0].install_read_bank(0xa000, 0xbfff, m_rombank[2]); + m_view[2][0].install_write_handler(0xa000, 0xafff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<2>))); + m_view[2][1].install_read_bank(0xa000, 0xafff, m_rambank[2]); + m_view[2][1].install_write_handler(0xa000, 0xafff, emu::rw_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<2>))); + m_view[2][1].install_readwrite_bank(0xb000, 0xbfff, m_rambank[2]); return std::error_condition(); } @@ -441,12 +436,7 @@ void msx_cart_gamemaster2_device::bank_w(u8 data) { m_rombank[Bank]->set_entry(data & 0x0f); m_rambank[Bank]->set_entry(BIT(data, 5) ? 1 : 0); - if (Bank == 0) - m_view0.select(BIT(data, 4) ? 1 : 0); - if (Bank == 1) - m_view1.select(BIT(data, 4) ? 1 : 0); - if (Bank == 2) - m_view2.select(BIT(data, 4) ? 1 : 0); + m_view[Bank].select(BIT(data, 4) ? 1 : 0); } @@ -516,10 +506,7 @@ protected: , msx_cart_interface(mconfig, *this) , m_k052539(*this, "k052539") , m_rambank(*this, "rambank%u", 0U) - , m_view0(*this, "view0") - , m_view1(*this, "view1") - , m_view2(*this, "view2") - , m_view3(*this, "view3") + , m_view{ {*this, "view0"}, {*this, "view1"}, {*this, "view2"}, {*this, "view3"} } , m_min_rambank(min_rambank) , m_max_rambank(max_rambank) , m_selected_bank{0, 0, 0, 0} @@ -545,10 +532,7 @@ private: // This is actually a K052539 required_device m_k052539; memory_bank_array_creator<4> m_rambank; - memory_view m_view0; - memory_view m_view1; - memory_view m_view2; - memory_view m_view3; + memory_view m_view[4]; u8 m_min_rambank; u8 m_max_rambank; @@ -591,79 +575,79 @@ std::error_condition msx_cart_konami_sound_device::initialize_cartridge(std::str // TODO Mirrors at 0000-3fff and c000-ffff - page(1)->install_view(0x4000, 0x5fff, m_view0); - m_view0[VIEW_READ].install_read_bank(0x4000, 0x5fff, m_rambank[0]); - m_view0[VIEW_READ].install_write_handler(0x5000, 0x57ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<0>))); - m_view0[VIEW_RAM].install_readwrite_bank(0x4000, 0x5fff, m_rambank[0]); - m_view0[VIEW_INVALID].install_write_handler(0x5000, 0x57ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<0>))); - m_view0[VIEW_INVALID | VIEW_RAM]; - - page(1)->install_view(0x6000, 0x7fff, m_view1); - m_view1[VIEW_READ].install_read_bank(0x6000, 0x7fff, m_rambank[1]); - m_view1[VIEW_READ].install_write_handler(0x7000, 0x77ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<1>))); - m_view1[VIEW_RAM].install_readwrite_bank(0x6000, 0x7fff, m_rambank[1]); - m_view1[VIEW_INVALID].install_write_handler(0x7000, 0x77ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<1>))); - m_view1[VIEW_INVALID | VIEW_RAM]; - - page(2)->install_view(0x8000, 0x9fff, m_view2); - m_view2[VIEW_READ].install_read_bank(0x8000, 0x9fff, m_rambank[2]); - m_view2[VIEW_READ].install_write_handler(0x9000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<2>))); - m_view2[VIEW_RAM].install_readwrite_bank(0x8000, 0x9fff, m_rambank[2]); - m_view2[VIEW_INVALID].install_write_handler(0x9000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<2>))); - m_view2[VIEW_INVALID | VIEW_RAM]; - m_view2[VIEW_SCC | VIEW_READ].install_read_bank(0x8000, 0x9fff, m_rambank[2]); - m_view2[VIEW_SCC | VIEW_READ].install_write_handler(0x9000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<2>))); - m_view2[VIEW_SCC | VIEW_READ].install_read_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_r))); - m_view2[VIEW_SCC | VIEW_READ].install_write_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_w))); - m_view2[VIEW_SCC | VIEW_READ].install_write_handler(0x9880, 0x9889, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_frequency_w))); - m_view2[VIEW_SCC | VIEW_READ].install_write_handler(0x988a, 0x988e, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_volume_w))); - m_view2[VIEW_SCC | VIEW_READ].install_write_handler(0x988f, 0x988f, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_keyonoff_w))); - m_view2[VIEW_SCC | VIEW_READ].install_read_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); - m_view2[VIEW_SCC | VIEW_READ].install_write_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_w))); - m_view2[VIEW_SCC | VIEW_RAM].install_readwrite_bank(0x8000, 0x9fff, m_rambank[2]); - m_view2[VIEW_SCC | VIEW_RAM].install_read_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_r))); - m_view2[VIEW_SCC | VIEW_RAM].install_read_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); - m_view2[VIEW_SCC | VIEW_INVALID].install_write_handler(0x9000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<2>))); - m_view2[VIEW_SCC | VIEW_INVALID].install_read_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_r))); - m_view2[VIEW_SCC | VIEW_INVALID].install_write_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_w))); - m_view2[VIEW_SCC | VIEW_INVALID].install_write_handler(0x9880, 0x9889, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_frequency_w))); - m_view2[VIEW_SCC | VIEW_INVALID].install_write_handler(0x988a, 0x988e, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_volume_w))); - m_view2[VIEW_SCC | VIEW_INVALID].install_write_handler(0x988f, 0x988f, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_keyonoff_w))); - m_view2[VIEW_SCC | VIEW_INVALID].install_read_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); - m_view2[VIEW_SCC | VIEW_INVALID].install_write_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_w))); - m_view2[VIEW_SCC | VIEW_INVALID | VIEW_RAM]; - m_view2[VIEW_SCC | VIEW_INVALID | VIEW_RAM].install_read_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_r))); - m_view2[VIEW_SCC | VIEW_INVALID | VIEW_RAM].install_read_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); - - page(2)->install_view(0xa000, 0xbfff, m_view3); - m_view3[VIEW_READ].install_read_bank(0xa000, 0xbfff, m_rambank[3]); - m_view3[VIEW_READ].install_write_handler(0xb000, 0xb7ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<3>))); - m_view3[VIEW_RAM].install_readwrite_bank(0xa000, 0xbfff, m_rambank[3]); - m_view3[VIEW_INVALID].install_write_handler(0xb000, 0xb7ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<3>))); - m_view3[VIEW_INVALID | VIEW_RAM]; - m_view3[VIEW_SCC | VIEW_READ].install_read_bank(0xa000, 0xbfff, m_rambank[3]); - m_view3[VIEW_SCC | VIEW_READ].install_write_handler(0xb000, 0xb7ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<3>))); - m_view3[VIEW_SCC | VIEW_READ].install_read_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_r))); - m_view3[VIEW_SCC | VIEW_READ].install_write_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_w))); - m_view3[VIEW_SCC | VIEW_READ].install_write_handler(0xb8a0, 0xb8a9, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_frequency_w))); - m_view3[VIEW_SCC | VIEW_READ].install_write_handler(0xb8aa, 0xb8ae, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_volume_w))); - m_view3[VIEW_SCC | VIEW_READ].install_write_handler(0xb8af, 0xb8af, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_keyonoff_w))); - m_view3[VIEW_SCC | VIEW_READ].install_read_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); - m_view3[VIEW_SCC | VIEW_READ].install_write_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_w))); - m_view3[VIEW_SCC | VIEW_RAM].install_readwrite_bank(0xa000, 0xbfff, m_rambank[3]); - m_view3[VIEW_SCC | VIEW_RAM].install_read_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_r))); - m_view3[VIEW_SCC | VIEW_RAM].install_read_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); - m_view3[VIEW_SCC | VIEW_INVALID].install_write_handler(0xb000, 0xb7ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<3>))); - m_view3[VIEW_SCC | VIEW_INVALID].install_read_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_r))); - m_view3[VIEW_SCC | VIEW_INVALID].install_write_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_w))); - m_view3[VIEW_SCC | VIEW_INVALID].install_write_handler(0xb8a0, 0xb8a9, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_frequency_w))); - m_view3[VIEW_SCC | VIEW_INVALID].install_write_handler(0xb8aa, 0xb8ae, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_volume_w))); - m_view3[VIEW_SCC | VIEW_INVALID].install_write_handler(0xb8af, 0xb8af, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_keyonoff_w))); - m_view3[VIEW_SCC | VIEW_INVALID].install_read_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); - m_view3[VIEW_SCC | VIEW_INVALID].install_write_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_w))); - m_view3[VIEW_SCC | VIEW_INVALID | VIEW_RAM]; - m_view3[VIEW_SCC | VIEW_INVALID| VIEW_RAM].install_read_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_r))); - m_view3[VIEW_SCC | VIEW_INVALID| VIEW_RAM].install_read_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); + page(1)->install_view(0x4000, 0x5fff, m_view[0]); + m_view[0][VIEW_READ].install_read_bank(0x4000, 0x5fff, m_rambank[0]); + m_view[0][VIEW_READ].install_write_handler(0x5000, 0x57ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<0>))); + m_view[0][VIEW_RAM].install_readwrite_bank(0x4000, 0x5fff, m_rambank[0]); + m_view[0][VIEW_INVALID].install_write_handler(0x5000, 0x57ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<0>))); + m_view[0][VIEW_INVALID | VIEW_RAM]; + + page(1)->install_view(0x6000, 0x7fff, m_view[1]); + m_view[1][VIEW_READ].install_read_bank(0x6000, 0x7fff, m_rambank[1]); + m_view[1][VIEW_READ].install_write_handler(0x7000, 0x77ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<1>))); + m_view[1][VIEW_RAM].install_readwrite_bank(0x6000, 0x7fff, m_rambank[1]); + m_view[1][VIEW_INVALID].install_write_handler(0x7000, 0x77ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<1>))); + m_view[1][VIEW_INVALID | VIEW_RAM]; + + page(2)->install_view(0x8000, 0x9fff, m_view[2]); + m_view[2][VIEW_READ].install_read_bank(0x8000, 0x9fff, m_rambank[2]); + m_view[2][VIEW_READ].install_write_handler(0x9000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<2>))); + m_view[2][VIEW_RAM].install_readwrite_bank(0x8000, 0x9fff, m_rambank[2]); + m_view[2][VIEW_INVALID].install_write_handler(0x9000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<2>))); + m_view[2][VIEW_INVALID | VIEW_RAM]; + m_view[2][VIEW_SCC | VIEW_READ].install_read_bank(0x8000, 0x9fff, m_rambank[2]); + m_view[2][VIEW_SCC | VIEW_READ].install_write_handler(0x9000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<2>))); + m_view[2][VIEW_SCC | VIEW_READ].install_read_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_r))); + m_view[2][VIEW_SCC | VIEW_READ].install_write_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_w))); + m_view[2][VIEW_SCC | VIEW_READ].install_write_handler(0x9880, 0x9889, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_frequency_w))); + m_view[2][VIEW_SCC | VIEW_READ].install_write_handler(0x988a, 0x988e, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_volume_w))); + m_view[2][VIEW_SCC | VIEW_READ].install_write_handler(0x988f, 0x988f, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_keyonoff_w))); + m_view[2][VIEW_SCC | VIEW_READ].install_read_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); + m_view[2][VIEW_SCC | VIEW_READ].install_write_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_w))); + m_view[2][VIEW_SCC | VIEW_RAM].install_readwrite_bank(0x8000, 0x9fff, m_rambank[2]); + m_view[2][VIEW_SCC | VIEW_RAM].install_read_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_r))); + m_view[2][VIEW_SCC | VIEW_RAM].install_read_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); + m_view[2][VIEW_SCC | VIEW_INVALID].install_write_handler(0x9000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<2>))); + m_view[2][VIEW_SCC | VIEW_INVALID].install_read_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_r))); + m_view[2][VIEW_SCC | VIEW_INVALID].install_write_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_w))); + m_view[2][VIEW_SCC | VIEW_INVALID].install_write_handler(0x9880, 0x9889, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_frequency_w))); + m_view[2][VIEW_SCC | VIEW_INVALID].install_write_handler(0x988a, 0x988e, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_volume_w))); + m_view[2][VIEW_SCC | VIEW_INVALID].install_write_handler(0x988f, 0x988f, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_keyonoff_w))); + m_view[2][VIEW_SCC | VIEW_INVALID].install_read_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); + m_view[2][VIEW_SCC | VIEW_INVALID].install_write_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_w))); + m_view[2][VIEW_SCC | VIEW_INVALID | VIEW_RAM]; + m_view[2][VIEW_SCC | VIEW_INVALID | VIEW_RAM].install_read_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_waveform_r))); + m_view[2][VIEW_SCC | VIEW_INVALID | VIEW_RAM].install_read_handler(0x98c0, 0x98c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); + + page(2)->install_view(0xa000, 0xbfff, m_view[3]); + m_view[3][VIEW_READ].install_read_bank(0xa000, 0xbfff, m_rambank[3]); + m_view[3][VIEW_READ].install_write_handler(0xb000, 0xb7ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<3>))); + m_view[3][VIEW_RAM].install_readwrite_bank(0xa000, 0xbfff, m_rambank[3]); + m_view[3][VIEW_INVALID].install_write_handler(0xb000, 0xb7ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<3>))); + m_view[3][VIEW_INVALID | VIEW_RAM]; + m_view[3][VIEW_SCC | VIEW_READ].install_read_bank(0xa000, 0xbfff, m_rambank[3]); + m_view[3][VIEW_SCC | VIEW_READ].install_write_handler(0xb000, 0xb7ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<3>))); + m_view[3][VIEW_SCC | VIEW_READ].install_read_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_r))); + m_view[3][VIEW_SCC | VIEW_READ].install_write_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_w))); + m_view[3][VIEW_SCC | VIEW_READ].install_write_handler(0xb8a0, 0xb8a9, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_frequency_w))); + m_view[3][VIEW_SCC | VIEW_READ].install_write_handler(0xb8aa, 0xb8ae, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_volume_w))); + m_view[3][VIEW_SCC | VIEW_READ].install_write_handler(0xb8af, 0xb8af, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_keyonoff_w))); + m_view[3][VIEW_SCC | VIEW_READ].install_read_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); + m_view[3][VIEW_SCC | VIEW_READ].install_write_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_w))); + m_view[3][VIEW_SCC | VIEW_RAM].install_readwrite_bank(0xa000, 0xbfff, m_rambank[3]); + m_view[3][VIEW_SCC | VIEW_RAM].install_read_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_r))); + m_view[3][VIEW_SCC | VIEW_RAM].install_read_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); + m_view[3][VIEW_SCC | VIEW_INVALID].install_write_handler(0xb000, 0xb7ff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::bank_w<3>))); + m_view[3][VIEW_SCC | VIEW_INVALID].install_read_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_r))); + m_view[3][VIEW_SCC | VIEW_INVALID].install_write_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_w))); + m_view[3][VIEW_SCC | VIEW_INVALID].install_write_handler(0xb8a0, 0xb8a9, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_frequency_w))); + m_view[3][VIEW_SCC | VIEW_INVALID].install_write_handler(0xb8aa, 0xb8ae, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_volume_w))); + m_view[3][VIEW_SCC | VIEW_INVALID].install_write_handler(0xb8af, 0xb8af, 0, 0x0710, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_keyonoff_w))); + m_view[3][VIEW_SCC | VIEW_INVALID].install_read_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); + m_view[3][VIEW_SCC | VIEW_INVALID].install_write_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_w))); + m_view[3][VIEW_SCC | VIEW_INVALID | VIEW_RAM]; + m_view[3][VIEW_SCC | VIEW_INVALID| VIEW_RAM].install_read_handler(0xb800, 0xb89f, 0, 0x0700, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k052539_waveform_r))); + m_view[3][VIEW_SCC | VIEW_INVALID| VIEW_RAM].install_read_handler(0xb8c0, 0xb8c0, 0, 0x071f, 0, emu::rw_delegate(m_k052539, FUNC(k051649_device::k051649_test_r))); page(2)->install_write_handler(0xbffe, 0xbfff, emu::rw_delegate(*this, FUNC(msx_cart_konami_sound_device::control_w))); @@ -702,14 +686,7 @@ void msx_cart_konami_sound_device::switch_bank() if (Bank == 3 && BIT(m_control, 5) && BIT(m_selected_bank[3], 7)) view |= VIEW_SCC; - if (Bank == 0) - m_view0.select(view); - if (Bank == 1) - m_view1.select(view); - if (Bank == 2) - m_view2.select(view); - if (Bank == 3) - m_view3.select(view); + m_view[Bank].select(view); } template diff --git a/src/devices/bus/msx/cart/msx_audio.cpp b/src/devices/bus/msx/cart/msx_audio.cpp index 8a28016acd3..1baae1488a0 100644 --- a/src/devices/bus/msx/cart/msx_audio.cpp +++ b/src/devices/bus/msx/cart/msx_audio.cpp @@ -267,8 +267,7 @@ public: , m_io_config(*this, "CONFIG") , m_region_y8950(*this, "y8950") , m_rombank(*this, "rombank%u", 0U) - , m_view0(*this, "view0") - , m_view1(*this, "view1") + , m_view{ {*this, "view0"}, {*this, "view1"} } , m_7fff(0) { } @@ -294,8 +293,7 @@ private: required_ioport m_io_config; required_memory_region m_region_y8950; memory_bank_array_creator<2> m_rombank; - memory_view m_view0; - memory_view m_view1; + memory_view m_view[2]; u8 m_7fff; }; @@ -344,10 +342,11 @@ void msx_cart_msx_audio_fsca1_device::device_start() void msx_cart_msx_audio_fsca1_device::device_reset() { - m_view0.select(0); - m_view1.select(0); - m_rombank[0]->set_entry(0); - m_rombank[1]->set_entry(0); + for (int i = 0; i < 2; i++) + { + m_view[i].select(0); + m_rombank[i]->set_entry(0); + } } std::error_condition msx_cart_msx_audio_fsca1_device::initialize_cartridge(std::string &message) @@ -367,15 +366,15 @@ std::error_condition msx_cart_msx_audio_fsca1_device::initialize_cartridge(std:: m_rombank[0]->configure_entries(0, 4, cart_rom_region()->base(), 0x8000); m_rombank[1]->configure_entries(0, 4, cart_rom_region()->base() + 0x4000, 0x8000); - page(0)->install_view(0x0000, 0x3fff, m_view0); - m_view0[0].install_read_bank(0x0000, 0x3fff, m_rombank[0]); - m_view0[0].install_ram(0x3000, 0x3fff, cart_sram_region()->base()); - m_view0[1].install_read_bank(0x0000, 0x3fff, m_rombank[0]); + page(0)->install_view(0x0000, 0x3fff, m_view[0]); + m_view[0][0].install_read_bank(0x0000, 0x3fff, m_rombank[0]); + m_view[0][0].install_ram(0x3000, 0x3fff, cart_sram_region()->base()); + m_view[0][1].install_read_bank(0x0000, 0x3fff, m_rombank[0]); - page(1)->install_view(0x4000, 0x7fff, m_view1); - m_view1[0].install_read_bank(0x4000, 0x7ffd, m_rombank[1]); - m_view1[0].install_ram(0x7000, 0x7ffd, cart_sram_region()->base()); - m_view1[1].install_read_bank(0x4000, 0x7ffd, m_rombank[1]); + page(1)->install_view(0x4000, 0x7fff, m_view[1]); + m_view[1][0].install_read_bank(0x4000, 0x7ffd, m_rombank[1]); + m_view[1][0].install_ram(0x7000, 0x7ffd, cart_sram_region()->base()); + m_view[1][1].install_read_bank(0x4000, 0x7ffd, m_rombank[1]); page(1)->install_write_handler(0x7ffe, 0x7ffe, emu::rw_delegate(*this, FUNC(msx_cart_msx_audio_fsca1_device::bank_w))); page(1)->install_write_handler(0x7fff, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_msx_audio_fsca1_device::write_7fff))); @@ -387,10 +386,11 @@ std::error_condition msx_cart_msx_audio_fsca1_device::initialize_cartridge(std:: void msx_cart_msx_audio_fsca1_device::bank_w(u8 data) { - m_rombank[0]->set_entry(data & 0x03); - m_rombank[1]->set_entry(data & 0x03); - m_view0.select((data != 0) ? 1 : 0); - m_view1.select((data != 0) ? 1 : 0); + for (int i = 0; i < 2; i++) + { + m_rombank[i]->set_entry(data & 0x03); + m_view[i].select((data != 0) ? 1 : 0); + } } void msx_cart_msx_audio_fsca1_device::write_7fff(u8 data) @@ -400,24 +400,24 @@ void msx_cart_msx_audio_fsca1_device::write_7fff(u8 data) void msx_cart_msx_audio_fsca1_device::write_y8950(offs_t offset, u8 data) { - if (offset & 2) + if (BIT(offset, 1)) { - if (m_7fff & 0x02) + if (BIT(m_7fff, 1)) m_y8950->write(offset, data); } else { - if (m_7fff & 0x01) + if (BIT(m_7fff, 0)) m_y8950->write(offset, data); } } u8 msx_cart_msx_audio_fsca1_device::read_y8950(offs_t offset) { - if (offset & 2) - return (m_7fff & 0x02) ? m_y8950->read(offset) : 0xff; + if (BIT(offset, 1)) + return BIT(m_7fff, 1) ? m_y8950->read(offset) : 0xff; else - return (m_7fff & 0x01) ? m_y8950->read(offset) : 0xff; + return BIT(m_7fff, 0) ? m_y8950->read(offset) : 0xff; } void msx_cart_msx_audio_fsca1_device::y8950_io_w(u8 data) diff --git a/src/devices/bus/msx/cart/msxdos2.cpp b/src/devices/bus/msx/cart/msxdos2.cpp index 05953e93de4..d502b422352 100644 --- a/src/devices/bus/msx/cart/msxdos2.cpp +++ b/src/devices/bus/msx/cart/msxdos2.cpp @@ -95,10 +95,7 @@ public: msx_cart_msxdos2j_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : msx_cart_msxdos2_base_device(mconfig, MSX_CART_MSXDOS2J, tag, owner, clock) , m_rambank(*this, "rambank%u", 0) - , m_view_page0(*this, "view_page0") - , m_view_page1(*this, "view_page1") - , m_view_page2(*this, "view_page2") - , m_view_page3(*this, "view_page3") + , m_view_page{ {*this, "view_page0"}, {*this, "view_page1"}, {*this, "view_page2"}, {*this, "view_page3"} } , m_secondary_slot(0) , m_bank_mask(0) { } @@ -114,10 +111,7 @@ private: template void mm_bank_w(u8 data); memory_bank_array_creator<4> m_rambank; - memory_view m_view_page0; - memory_view m_view_page1; - memory_view m_view_page2; - memory_view m_view_page3; + memory_view m_view_page[4]; u8 m_secondary_slot; u8 m_bank_mask; }; @@ -142,27 +136,23 @@ std::error_condition msx_cart_msxdos2j_device::initialize_cartridge(std::string return image_error::BADSOFTWARE; } - page(0)->install_view(0x0000, 0x3fff, m_view_page0); - page(1)->install_view(0x4000, 0x7fff, m_view_page1); - page(2)->install_view(0x8000, 0xbfff, m_view_page2); - page(3)->install_view(0xc000, 0xffff, m_view_page3); + for (int pg = 0; pg < 4; pg++) + page(pg)->install_view(0x4000 * pg, 0x4000 * pg + 0x3fff, m_view_page[pg]); page(3)->install_readwrite_handler(0xffff, 0xffff, emu::rw_delegate(*this, FUNC(msx_cart_msxdos2j_device::secondary_slot_r)), emu::rw_delegate(*this, FUNC(msx_cart_msxdos2j_device::secondary_slot_w))); // Make sure all views we can select do exist. for (int subslot = 0; subslot < 4; subslot++) { - m_view_page0[subslot]; - m_view_page1[subslot]; - m_view_page2[subslot]; - m_view_page3[subslot]; + for (int page = 0; page < 4; page++) + m_view_page[page][subslot]; } // Kanji driver - m_view_page1[2].install_rom(0x4000, 0x7fff, cart_rom_region()->base() + 0xc000); + m_view_page[1][2].install_rom(0x4000, 0x7fff, cart_rom_region()->base() + 0xc000); // MSX-DOS2 rom - m_view_page1[3].install_read_bank(0x4000, 0x7fff, m_rombank); - m_view_page1[3].install_write_handler(m_bank_address, m_bank_address, emu::rw_delegate(*this, FUNC(msx_cart_msxdos2j_device::bank_w))); + m_view_page[1][3].install_read_bank(0x4000, 0x7fff, m_rombank); + m_view_page[1][3].install_write_handler(m_bank_address, m_bank_address, emu::rw_delegate(*this, FUNC(msx_cart_msxdos2j_device::bank_w))); // On-cartridge memory mapper RAM if (ram_size) @@ -176,10 +166,8 @@ std::error_condition msx_cart_msxdos2j_device::initialize_cartridge(std::string } ); - m_view_page0[1].install_readwrite_bank(0x0000, 0x3fff, m_rambank[0]); - m_view_page1[1].install_readwrite_bank(0x4000, 0x7fff, m_rambank[1]); - m_view_page2[1].install_readwrite_bank(0x8000, 0xbfff, m_rambank[2]); - m_view_page3[1].install_readwrite_bank(0xc000, 0xffff, m_rambank[3]); + for (int pg = 0; pg < 4; pg++) + m_view_page[pg][1].install_readwrite_bank(0x4000 * pg, 0x4000 * pg + 0x3fff, m_rambank[pg]); io_space().install_write_tap(0xfc, 0xfc, "bank0", [this] (offs_t, u8& data, u8){ this->mm_bank_w<0>(data); }); io_space().install_write_tap(0xfd, 0xfd, "bank1", [this] (offs_t, u8& data, u8){ this->mm_bank_w<1>(data); }); @@ -197,10 +185,8 @@ u8 msx_cart_msxdos2j_device::secondary_slot_r() void msx_cart_msxdos2j_device::secondary_slot_w(u8 data) { - m_view_page0.select((data >> 0) & 0x03); - m_view_page1.select((data >> 2) & 0x03); - m_view_page2.select((data >> 4) & 0x03); - m_view_page3.select((data >> 6) & 0x03); + for (int page = 0; page < 4; page++) + m_view_page[page].select((data >> (2 * page)) & 0x03); m_secondary_slot = data; } diff --git a/src/devices/bus/msx/cart/scsi.cpp b/src/devices/bus/msx/cart/scsi.cpp index 02bb8d5bf39..9b049a89ec2 100644 --- a/src/devices/bus/msx/cart/scsi.cpp +++ b/src/devices/bus/msx/cart/scsi.cpp @@ -104,9 +104,7 @@ public: , msx_cart_interface(mconfig, *this) , m_mb89352a(*this, "scsi:7:mb89352a") , m_srambank(*this, "srambank%u", 0U) - , m_view0(*this, "view0") - , m_view2(*this, "view2") - , m_view3(*this, "view3") + , m_view{ {*this, "view0"}, {*this, "view1"}, {*this, "view2"}, {*this, "view3"} } , m_bank_mask(0) { } @@ -124,9 +122,7 @@ private: required_device m_mb89352a; memory_bank_array_creator<4> m_srambank; - memory_view m_view0; - memory_view m_view2; - memory_view m_view3; + memory_view m_view[4]; u8 m_bank_mask; template void bank_w(u8 data); @@ -150,10 +146,11 @@ void msx_cart_mega_scsi_device::device_add_mconfig(machine_config &config) void msx_cart_mega_scsi_device::device_reset() { for (int i = 0; i < 4; i++) + { + if (i != 1) + m_view[i].select(0); m_srambank[i]->set_entry(0); - m_view0.select(0); - m_view2.select(0); - m_view3.select(0); + } } std::error_condition msx_cart_mega_scsi_device::initialize_cartridge(std::string &message) @@ -178,31 +175,31 @@ std::error_condition msx_cart_mega_scsi_device::initialize_cartridge(std::string for (int i = 0; i < 4; i++) m_srambank[i]->configure_entries(0, sram_banks, cart_sram_region()->base(), BANK_SIZE); - page(1)->install_view(0x4000, 0x5fff, m_view0); - m_view0[0].install_read_bank(0x4000, 0x5fff, m_srambank[0]); - m_view0[1].install_readwrite_bank(0x4000, 0x5fff, m_srambank[0]); - m_view0[2].install_read_handler(0x4000, 0x4fff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_r))); - m_view0[2].install_write_handler(0x4000, 0x4fff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_w))); + page(1)->install_view(0x4000, 0x5fff, m_view[0]); + m_view[0][0].install_read_bank(0x4000, 0x5fff, m_srambank[0]); + m_view[0][1].install_readwrite_bank(0x4000, 0x5fff, m_srambank[0]); + m_view[0][2].install_read_handler(0x4000, 0x4fff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_r))); + m_view[0][2].install_write_handler(0x4000, 0x4fff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_w))); // mb89352 is mirrored at 5000 - 5fff - for (int i = 0; i < 0x1000; i += 0x10) - m_view0[2].install_device(0x5000 + i, 0x500f + i, *m_mb89352a, &mb89352_device::map); + for (int addr = 0x5000; addr < 0x6000; addr += 0x10) + m_view[0][2].install_device(addr, addr + 0x0f, *m_mb89352a, &mb89352_device::map); page(1)->install_read_bank(0x6000, 0x7fff, m_srambank[1]); - page(2)->install_view(0x8000, 0x9fff, m_view2); - m_view2[0].install_read_bank(0x8000, 0x9fff, m_srambank[2]); - m_view2[1].install_readwrite_bank(0x8000, 0x9fff, m_srambank[2]); - m_view2[2].install_read_handler(0x8000, 0x8fff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_r))); - m_view2[2].install_write_handler(0x8000, 0x8fff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_w))); + page(2)->install_view(0x8000, 0x9fff, m_view[2]); + m_view[2][0].install_read_bank(0x8000, 0x9fff, m_srambank[2]); + m_view[2][1].install_readwrite_bank(0x8000, 0x9fff, m_srambank[2]); + m_view[2][2].install_read_handler(0x8000, 0x8fff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_r))); + m_view[2][2].install_write_handler(0x8000, 0x8fff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_w))); // mb89352 is mirrored at 9000 - 9fff - for (int i = 0; i < 0x1000; i += 0x10) - m_view2[2].install_device(0x9000 + i, 0x900f + i, *m_mb89352a, &mb89352_device::map); - page(2)->install_view(0xa000, 0xbfff, m_view3); - m_view3[0].install_read_bank(0xa000, 0xbfff, m_srambank[3]); - m_view3[1].install_readwrite_bank(0xa000, 0xbfff, m_srambank[3]); - m_view3[2].install_read_handler(0xa000, 0xafff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_r))); - m_view3[2].install_write_handler(0xa000, 0xafff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_w))); + for (int addr = 0x9000; addr < 0xa000; addr += 0x10) + m_view[2][2].install_device(addr, addr + 0x0f, *m_mb89352a, &mb89352_device::map); + page(2)->install_view(0xa000, 0xbfff, m_view[3]); + m_view[3][0].install_read_bank(0xa000, 0xbfff, m_srambank[3]); + m_view[3][1].install_readwrite_bank(0xa000, 0xbfff, m_srambank[3]); + m_view[3][2].install_read_handler(0xa000, 0xafff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_r))); + m_view[3][2].install_write_handler(0xa000, 0xafff, emu::rw_delegate(*m_mb89352a, FUNC(mb89352_device::dma_w))); // mb89352 is mirrored at b000 - bfff - for (int i = 0; i < 0x1000; i += 0x10) - m_view3[2].install_device(0xb000 + i, 0xb00f + i, *m_mb89352a, &mb89352_device::map); + for (int addr = 0xb000; addr < 0xc000; addr += 0x10) + m_view[3][2].install_device(addr, addr + 0x0f, *m_mb89352a, &mb89352_device::map); page(1)->install_write_handler(0x6000, 0x67ff, emu::rw_delegate(*this, FUNC(msx_cart_mega_scsi_device::bank_w<0>))); page(1)->install_write_handler(0x6800, 0x6fff, emu::rw_delegate(*this, FUNC(msx_cart_mega_scsi_device::bank_w<1>))); @@ -221,12 +218,7 @@ void msx_cart_mega_scsi_device::bank_w(u8 data) { int view_to_select = BIT(data, 7) ? 1 : (BIT(data, 6) ? 2 : 0); - if (Bank == 0) - m_view0.select(view_to_select); - if (Bank == 2) - m_view2.select(view_to_select); - if (Bank == 3) - m_view3.select(view_to_select); + m_view[Bank].select(view_to_select); } } diff --git a/src/devices/bus/msx/cart/slotexpander.cpp b/src/devices/bus/msx/cart/slotexpander.cpp index 11ad77a877a..cf3a78ce733 100644 --- a/src/devices/bus/msx/cart/slotexpander.cpp +++ b/src/devices/bus/msx/cart/slotexpander.cpp @@ -48,10 +48,7 @@ public: , msx_cart_interface(mconfig, *this) , m_cartslot(*this, "cartslot%u", 1) , m_irq_out(*this, "irq_out") - , m_view0(*this, "view0") - , m_view1(*this, "view1") - , m_view2(*this, "view2") - , m_view3(*this, "view3") + , m_view{ {*this, "view0"}, {*this, "view1"}, {*this, "view2"}, {*this, "view3"} } , m_secondary_slot(0) { } @@ -68,10 +65,7 @@ private: required_device_array m_cartslot; required_device m_irq_out; - memory_view m_view0; - memory_view m_view1; - memory_view m_view2; - memory_view m_view3; + memory_view m_view[4]; u8 m_secondary_slot; }; @@ -114,22 +108,16 @@ void msx_cart_slotexpander_device::device_config_complete() void msx_cart_slotexpander_device::device_resolve_objects() { - page(0)->install_view(0x0000, 0x3fff, m_view0); - page(1)->install_view(0x4000, 0x7fff, m_view1); - page(2)->install_view(0x8000, 0xbfff, m_view2); - page(3)->install_view(0xc000, 0xffff, m_view3); + for (int pg = 0; pg < 4; pg++) + page(pg)->install_view(0x4000 * pg, 0x04000 * pg + 0x3fff, m_view[pg]); page(3)->install_readwrite_handler(0xffff, 0xffff, emu::rw_delegate(*this, FUNC(msx_cart_slotexpander_device::secondary_slot_r)), emu::rw_delegate(*this, FUNC(msx_cart_slotexpander_device::secondary_slot_w))); - for (int page = 0; page < 4; page++) - { - m_view0[page]; - m_view1[page]; - m_view2[page]; - m_view3[page]; - } + for (int subslot = 0; subslot < 4; subslot++) + for (int page = 0; page < 4; page++) + m_view[page][subslot]; - for (int i = 0; i < 4; i++) - m_cartslot[i]->install(&m_view0[i], &m_view1[i], &m_view2[i], &m_view3[i]); + for (int subslot = 0; subslot < 4; subslot++) + m_cartslot[subslot]->install(&m_view[0][subslot], &m_view[1][subslot], &m_view[2][subslot], &m_view[3][subslot]); } void msx_cart_slotexpander_device::device_start() @@ -137,10 +125,8 @@ void msx_cart_slotexpander_device::device_start() save_item(NAME(m_secondary_slot)); m_secondary_slot = 0; - m_view0.select(0); - m_view1.select(0); - m_view2.select(0); - m_view3.select(0); + for (int page = 0; page < 4; page++) + m_view[page].select(0); } u8 msx_cart_slotexpander_device::secondary_slot_r() @@ -150,10 +136,8 @@ u8 msx_cart_slotexpander_device::secondary_slot_r() void msx_cart_slotexpander_device::secondary_slot_w(u8 data) { - m_view0.select((data >> 0) & 0x03); - m_view1.select((data >> 2) & 0x03); - m_view2.select((data >> 4) & 0x03); - m_view3.select((data >> 6) & 0x03); + for (int page = 0; page < 4; page++) + m_view[page].select((data >> (2 * page)) & 0x03); m_secondary_slot = data; } -- cgit v1.2.3