diff options
| author | 2016-08-24 23:07:14 +0200 | |
|---|---|---|
| committer | 2016-08-25 19:04:14 +0200 | |
| commit | f4db841a2e70e0f4bf440b912de717c72d445a5f (patch) | |
| tree | 299eabcc85fb89070a53795361c7ab08cee8ba91 /src/emu/dirom.cpp | |
| parent | 4d440e949a62498a4b3f249554af7c658564920d (diff) | |
dirom,okim6295: Add/fix banking support. Better okim fix post-release [O. Galibert]
Diffstat (limited to 'src/emu/dirom.cpp')
| -rw-r--r-- | src/emu/dirom.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/emu/dirom.cpp b/src/emu/dirom.cpp index 45a4dd2dc56..a055ce00539 100644 --- a/src/emu/dirom.cpp +++ b/src/emu/dirom.cpp @@ -16,17 +16,35 @@ const address_space_config *device_rom_interface::memory_space_config(address_sp return spacenum ? nullptr : &m_rom_config; } +void device_rom_interface::set_rom_bank(int bank) +{ + if(!m_bank) + emu_fatalerror("%s: device_rom_interface::set_rom_bank called without banking setup", device().tag()); + + m_cur_bank = bank; + m_bank->set_entry(bank); +} + +void device_rom_interface::reset_bank() +{ + if(m_bank) + m_bank->set_entry(m_cur_bank); +} + void device_rom_interface::set_rom(const void *base, UINT32 size) { UINT32 mend = m_rom_config.addr_width() == 32 ? 0xffffffff : (1 << m_rom_config.addr_width()) - 1; UINT32 rend = size-1; - if(rend > mend) { - device().logerror("Warning: The rom for device %s is %x bytes, while the chip addressing space is only %x bytes.\n", device().tag(), rend+1, mend+1); - rend = mend; - } - if(rend == mend) - space().install_rom(0, mend, const_cast<void *>(base)); - else { + UINT32 banks = (rend+1) / (mend+1); + if(banks < 1) + banks = 1; + + if(rend >= mend) { + space().install_read_bank(0, mend, device().tag()); + m_bank = device().machine().memory().banks().find(device().tag())->second.get(); + m_bank->configure_entries(0, banks, const_cast<void *>(base), mend+1); + + } else { // Round up to the nearest power-of-two-minus-one UINT32 rmask = rend; rmask |= rmask >> 1; @@ -45,6 +63,10 @@ void device_rom_interface::set_rom(const void *base, UINT32 size) void device_rom_interface::interface_pre_start() { m_rom_direct = &space().direct(); + m_bank = nullptr; + m_cur_bank = -1; + device().save_item(NAME(m_cur_bank)); + device().machine().save().register_postload(save_prepost_delegate(FUNC(device_rom_interface::reset_bank), this)); if(!has_configured_map(0)) { memory_region *reg = device().memregion(DEVICE_SELF); |
