mirror of
https://github.com/holub/mame
synced 2025-10-07 17:27:06 +03:00
emumem: Fix ioports/membanks in internal maps [O. Galibert]
PS: That may break things, we'll see.
This commit is contained in:
parent
03adeab064
commit
dd64cdceee
@ -30,29 +30,23 @@ st6228_device::st6228_device(const machine_config &mconfig, const char *tag, dev
|
||||
, m_portd_out{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}}
|
||||
, m_program(nullptr)
|
||||
, m_data(nullptr)
|
||||
// FIXME: memory banks do not currently work with internal maps.
|
||||
//, m_rambank(*this, "^rambank")
|
||||
//, m_program_rombank(*this, "^program_rombank")
|
||||
//, m_data_rombank(*this, "^data_rombank")
|
||||
, m_rambank(*this, "rambank")
|
||||
, m_program_rombank(*this, "program_rombank")
|
||||
, m_data_rombank(*this, "data_rombank")
|
||||
, m_rom(*this, this->tag())
|
||||
{
|
||||
}
|
||||
|
||||
void st6228_device::st6228_program_map(address_map &map)
|
||||
{
|
||||
// FIXME: memory banks do not currently work with internal maps.
|
||||
//map(0x000, 0x7ff).bankr(m_program_rombank);
|
||||
map(0x000, 0x7ff).r(FUNC(st6228_device::program_rombank_r));
|
||||
map(0x000, 0x7ff).bankr(m_program_rombank);
|
||||
map(0x800, 0xfff).rom().region(tag(), 0x800);
|
||||
}
|
||||
|
||||
void st6228_device::st6228_data_map(address_map &map)
|
||||
{
|
||||
// FIXME: memory banks do not currently work with internal maps.
|
||||
//map(0x00, 0x3f).bankrw(m_rambank);
|
||||
//map(0x40, 0x7f).bankr(m_data_rombank);
|
||||
map(0x00, 0x3f).rw(FUNC(st6228_device::rambank_r), FUNC(st6228_device::rambank_w));
|
||||
map(0x40, 0x7f).r(FUNC(st6228_device::data_rombank_r));
|
||||
map(0x00, 0x3f).bankrw(m_rambank);
|
||||
map(0x40, 0x7f).bankr(m_data_rombank);
|
||||
map(0x80, 0xff).rw(FUNC(st6228_device::regs_r), FUNC(st6228_device::regs_w));
|
||||
}
|
||||
|
||||
@ -102,10 +96,9 @@ void st6228_device::device_start()
|
||||
// set our instruction counter
|
||||
set_icountptr(m_icount);
|
||||
|
||||
// FIXME: memory banks do not currently work with internal maps.
|
||||
//m_rambank->configure_entries(0, 2, m_ram, 0x40);
|
||||
//m_program_rombank->configure_entries(0, 4, m_rom, 0x800);
|
||||
//m_data_rombank->configure_entries(0, 128, m_rom, 0x40);
|
||||
m_rambank->configure_entries(0, 2, m_ram, 0x40);
|
||||
m_program_rombank->configure_entries(0, 4, m_rom->base(), 0x800);
|
||||
m_data_rombank->configure_entries(0, 128, m_rom->base(), 0x40);
|
||||
|
||||
// TODO: magic numbers
|
||||
for (uint8_t bit = 0; bit < 6; bit++)
|
||||
@ -141,10 +134,9 @@ void st6228_device::device_reset()
|
||||
m_mode = MODE_NMI;
|
||||
m_prev_mode = MODE_NORMAL;
|
||||
|
||||
// FIXME: memory banks do not currently work with internal maps.
|
||||
//m_rambank->set_entry(0);
|
||||
//m_program_rombank->set_entry(0);
|
||||
//m_data_rombank->set_entry(0);
|
||||
m_rambank->set_entry(0);
|
||||
m_program_rombank->set_entry(0);
|
||||
m_data_rombank->set_entry(0);
|
||||
|
||||
m_regs[REG_TIMER_COUNT] = 0xff;
|
||||
m_regs[REG_TIMER_PRESCALE] = 0x7f;
|
||||
@ -268,26 +260,6 @@ void st6228_device::update_port_mode(uint8_t index, uint8_t changed)
|
||||
}
|
||||
}
|
||||
|
||||
READ8_MEMBER(st6228_device::program_rombank_r)
|
||||
{
|
||||
return m_rom->base()[(m_regs[REG_ROM_BANK_SELECT] & 3) * 0x800 + offset];
|
||||
}
|
||||
|
||||
READ8_MEMBER(st6228_device::data_rombank_r)
|
||||
{
|
||||
return m_rom->base()[(m_regs[REG_DATA_ROM_WINDOW] & 0x7f) * 0x40 + offset];
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(st6228_device::rambank_w)
|
||||
{
|
||||
m_ram[(m_regs[REG_RAM_BANK_SELECT] & 1) * 0x40 + offset] = data;
|
||||
}
|
||||
|
||||
READ8_MEMBER(st6228_device::rambank_r)
|
||||
{
|
||||
return m_ram[(m_regs[REG_RAM_BANK_SELECT] & 1) * 0x40 + offset];
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(st6228_device::regs_w)
|
||||
{
|
||||
offset += 0x80;
|
||||
@ -313,17 +285,17 @@ WRITE8_MEMBER(st6228_device::regs_w)
|
||||
|
||||
case REG_DATA_ROM_WINDOW:
|
||||
m_regs[offset] = data;
|
||||
//m_data_rombank->set_entry(data & 0x7f);
|
||||
m_data_rombank->set_entry(data & 0x7f);
|
||||
break;
|
||||
|
||||
case REG_ROM_BANK_SELECT:
|
||||
m_regs[offset] = data;
|
||||
//m_program_rombank->set_entry(data & 3);
|
||||
m_program_rombank->set_entry(data & 3);
|
||||
break;
|
||||
|
||||
case REG_RAM_BANK_SELECT:
|
||||
m_regs[offset] = data;
|
||||
//m_rambank->set_entry(data & 1);
|
||||
m_rambank->set_entry(data & 1);
|
||||
break;
|
||||
|
||||
case REG_PORTA_DATA:
|
||||
|
@ -108,11 +108,6 @@ protected:
|
||||
void update_port_mode(uint8_t index, uint8_t changed);
|
||||
void set_port_output_bit(uint8_t index, uint8_t bit, uint8_t state);
|
||||
|
||||
DECLARE_READ8_MEMBER(program_rombank_r);
|
||||
DECLARE_READ8_MEMBER(data_rombank_r);
|
||||
DECLARE_WRITE8_MEMBER(rambank_w);
|
||||
DECLARE_READ8_MEMBER(rambank_r);
|
||||
|
||||
DECLARE_WRITE8_MEMBER(regs_w);
|
||||
DECLARE_READ8_MEMBER(regs_r);
|
||||
|
||||
@ -244,9 +239,9 @@ protected:
|
||||
address_space *m_data;
|
||||
|
||||
// FIXME: memory banks do not currently work with internal maps.
|
||||
//required_memory_bank m_rambank;
|
||||
//required_memory_bank m_program_rombank;
|
||||
//required_memory_bank m_data_rombank;
|
||||
required_memory_bank m_rambank;
|
||||
required_memory_bank m_program_rombank;
|
||||
required_memory_bank m_data_rombank;
|
||||
required_memory_region m_rom;
|
||||
};
|
||||
|
||||
|
@ -127,10 +127,10 @@ device_t::~device_t()
|
||||
// info for a given region
|
||||
//-------------------------------------------------
|
||||
|
||||
memory_region *device_t::memregion(const char *_tag) const
|
||||
memory_region *device_t::memregion(std::string _tag) const
|
||||
{
|
||||
// build a fully-qualified name and look it up
|
||||
if (_tag)
|
||||
if (_tag != "")
|
||||
{
|
||||
auto search = machine().memory().regions().find(subtag(_tag).c_str());
|
||||
if (search != machine().memory().regions().end())
|
||||
@ -148,10 +148,10 @@ memory_region *device_t::memregion(const char *_tag) const
|
||||
// info for a given share
|
||||
//-------------------------------------------------
|
||||
|
||||
memory_share *device_t::memshare(const char *_tag) const
|
||||
memory_share *device_t::memshare(std::string _tag) const
|
||||
{
|
||||
// build a fully-qualified name and look it up
|
||||
if (_tag)
|
||||
if (_tag != "")
|
||||
{
|
||||
auto search = machine().memory().shares().find(subtag(_tag).c_str());
|
||||
if (search != machine().memory().shares().end())
|
||||
@ -169,9 +169,9 @@ memory_share *device_t::memshare(const char *_tag) const
|
||||
// bank info for a given bank
|
||||
//-------------------------------------------------
|
||||
|
||||
memory_bank *device_t::membank(const char *_tag) const
|
||||
memory_bank *device_t::membank(std::string _tag) const
|
||||
{
|
||||
if (_tag)
|
||||
if (_tag != "")
|
||||
{
|
||||
auto search = machine().memory().banks().find(subtag(_tag).c_str());
|
||||
if (search != machine().memory().banks().end())
|
||||
@ -189,7 +189,7 @@ memory_bank *device_t::membank(const char *_tag) const
|
||||
// object for a given port name
|
||||
//-------------------------------------------------
|
||||
|
||||
ioport_port *device_t::ioport(const char *tag) const
|
||||
ioport_port *device_t::ioport(std::string tag) const
|
||||
{
|
||||
// build a fully-qualified name and look it up
|
||||
return machine().ioport().port(subtag(tag).c_str());
|
||||
@ -890,8 +890,9 @@ device_t *device_t::subdevice_slow(const char *tag) const
|
||||
// to our device based on the provided tag
|
||||
//-------------------------------------------------
|
||||
|
||||
std::string device_t::subtag(const char *tag) const
|
||||
std::string device_t::subtag(std::string _tag) const
|
||||
{
|
||||
const char *tag = _tag.c_str();
|
||||
std::string result;
|
||||
// if the tag begins with a colon, ignore our path and start from the root
|
||||
if (*tag == ':')
|
||||
|
@ -524,12 +524,12 @@ public:
|
||||
const subdevice_list &subdevices() const { return m_subdevices; }
|
||||
|
||||
// device-relative tag lookups
|
||||
std::string subtag(const char *tag) const;
|
||||
std::string siblingtag(const char *tag) const { return (m_owner != nullptr) ? m_owner->subtag(tag) : std::string(tag); }
|
||||
memory_region *memregion(const char *tag) const;
|
||||
memory_share *memshare(const char *tag) const;
|
||||
memory_bank *membank(const char *tag) const;
|
||||
ioport_port *ioport(const char *tag) const;
|
||||
std::string subtag(std::string tag) const;
|
||||
std::string siblingtag(std::string tag) const { return (m_owner != nullptr) ? m_owner->subtag(tag) : tag; }
|
||||
memory_region *memregion(std::string tag) const;
|
||||
memory_share *memshare(std::string tag) const;
|
||||
memory_bank *membank(std::string tag) const;
|
||||
ioport_port *ioport(std::string tag) const;
|
||||
device_t *subdevice(const char *tag) const;
|
||||
device_t *siblingdevice(const char *tag) const;
|
||||
template<class DeviceClass> DeviceClass *subdevice(const char *tag) const { return downcast<DeviceClass *>(subdevice(tag)); }
|
||||
|
@ -240,9 +240,9 @@ public:
|
||||
|
||||
void unmap_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, read_or_write readorwrite, bool quiet) override;
|
||||
void install_ram_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, read_or_write readorwrite, void *baseptr) override;
|
||||
void install_bank_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *rtag, const char *wtag) override;
|
||||
void install_bank_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, std::string rtag, std::string wtag) override;
|
||||
void install_bank_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, memory_bank *rbank, memory_bank *wbank) override;
|
||||
void install_readwrite_port(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *rtag, const char *wtag) override;
|
||||
void install_readwrite_port(offs_t addrstart, offs_t addrend, offs_t addrmirror, std::string rtag, std::string wtag) override;
|
||||
void install_device_delegate(offs_t addrstart, offs_t addrend, device_t &device, address_map_constructor &map, u64 unitmask = 0, int cswidth = 0) override;
|
||||
|
||||
void install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read8_delegate rhandler, u64 unitmask = 0, int cswidth = 0) override;
|
||||
@ -1497,14 +1497,14 @@ void address_space::populate_map_entry(const address_map_entry &entry, read_or_w
|
||||
|
||||
case AMH_PORT:
|
||||
install_readwrite_port(entry.m_addrstart, entry.m_addrend, entry.m_addrmirror,
|
||||
(readorwrite == read_or_write::READ) ? data.m_tag : nullptr,
|
||||
(readorwrite == read_or_write::WRITE) ? data.m_tag : nullptr);
|
||||
(readorwrite == read_or_write::READ) ? entry.m_devbase.subtag(data.m_tag) : "",
|
||||
(readorwrite == read_or_write::WRITE) ? entry.m_devbase.subtag(data.m_tag) : "");
|
||||
break;
|
||||
|
||||
case AMH_BANK:
|
||||
install_bank_generic(entry.m_addrstart, entry.m_addrend, entry.m_addrmirror,
|
||||
(readorwrite == read_or_write::READ) ? data.m_tag : nullptr,
|
||||
(readorwrite == read_or_write::WRITE) ? data.m_tag : nullptr);
|
||||
(readorwrite == read_or_write::READ) ? entry.m_devbase.subtag(data.m_tag) : "",
|
||||
(readorwrite == read_or_write::WRITE) ? entry.m_devbase.subtag(data.m_tag) : "");
|
||||
break;
|
||||
|
||||
case AMH_DEVICE_SUBMAP:
|
||||
@ -1885,42 +1885,42 @@ template<int Width, int AddrShift, endianness_t Endian> void address_space_speci
|
||||
// handler into this address space
|
||||
//-------------------------------------------------
|
||||
|
||||
template<int Width, int AddrShift, endianness_t Endian> void address_space_specific<Width, AddrShift, Endian>::install_readwrite_port(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *rtag, const char *wtag)
|
||||
template<int Width, int AddrShift, endianness_t Endian> void address_space_specific<Width, AddrShift, Endian>::install_readwrite_port(offs_t addrstart, offs_t addrend, offs_t addrmirror, std::string rtag, std::string wtag)
|
||||
{
|
||||
VPRINTF(("address_space::install_readwrite_port(%s-%s mirror=%s, read=\"%s\" / write=\"%s\")\n",
|
||||
core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
|
||||
core_i64_hex_format(addrmirror, m_addrchars),
|
||||
(rtag != nullptr) ? rtag : "(none)", (wtag != nullptr) ? wtag : "(none)"));
|
||||
rtag.empty() ? "(none)" : rtag.c_str(), wtag.empty() ? "(none)" : wtag.c_str()));
|
||||
|
||||
offs_t nstart, nend, nmask, nmirror;
|
||||
check_optimize_mirror("install_readwrite_port", addrstart, addrend, addrmirror, nstart, nend, nmask, nmirror);
|
||||
|
||||
// read handler
|
||||
if (rtag != nullptr)
|
||||
if (rtag != "")
|
||||
{
|
||||
// find the port
|
||||
ioport_port *port = device().owner()->ioport(rtag);
|
||||
if (port == nullptr)
|
||||
throw emu_fatalerror("Attempted to map non-existent port '%s' for read in space %s of device '%s'\n", rtag, m_name, m_device.tag());
|
||||
throw emu_fatalerror("Attempted to map non-existent port '%s' for read in space %s of device '%s'\n", rtag.c_str(), m_name, m_device.tag());
|
||||
|
||||
// map the range and set the ioport
|
||||
auto hand_r = new handler_entry_read_ioport<Width, AddrShift, Endian>(this, port);
|
||||
m_root_read->populate(nstart, nend, nmirror, hand_r);
|
||||
}
|
||||
|
||||
if (wtag != nullptr)
|
||||
if (wtag != "")
|
||||
{
|
||||
// find the port
|
||||
ioport_port *port = device().owner()->ioport(wtag);
|
||||
if (port == nullptr)
|
||||
fatalerror("Attempted to map non-existent port '%s' for write in space %s of device '%s'\n", wtag, m_name, m_device.tag());
|
||||
fatalerror("Attempted to map non-existent port '%s' for write in space %s of device '%s'\n", wtag.c_str(), m_name, m_device.tag());
|
||||
|
||||
// map the range and set the ioport
|
||||
auto hand_w = new handler_entry_write_ioport<Width, AddrShift, Endian>(this, port);
|
||||
m_root_write->populate(nstart, nend, nmirror, hand_w);
|
||||
}
|
||||
|
||||
invalidate_caches(rtag ? wtag ? read_or_write::READWRITE : read_or_write::READ : read_or_write::WRITE);
|
||||
invalidate_caches(rtag != "" ? wtag != "" ? read_or_write::READWRITE : read_or_write::READ : read_or_write::WRITE);
|
||||
}
|
||||
|
||||
|
||||
@ -1929,18 +1929,18 @@ template<int Width, int AddrShift, endianness_t Endian> void address_space_speci
|
||||
// mapping to a particular bank
|
||||
//-------------------------------------------------
|
||||
|
||||
template<int Width, int AddrShift, endianness_t Endian> void address_space_specific<Width, AddrShift, Endian>::install_bank_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *rtag, const char *wtag)
|
||||
template<int Width, int AddrShift, endianness_t Endian> void address_space_specific<Width, AddrShift, Endian>::install_bank_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, std::string rtag, std::string wtag)
|
||||
{
|
||||
VPRINTF(("address_space::install_readwrite_bank(%s-%s mirror=%s, read=\"%s\" / write=\"%s\")\n",
|
||||
core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
|
||||
core_i64_hex_format(addrmirror, m_addrchars),
|
||||
(rtag != nullptr) ? rtag : "(none)", (wtag != nullptr) ? wtag : "(none)"));
|
||||
rtag.empty() ? "(none)" : rtag.c_str(), wtag.empty() ? "(none)" : wtag.c_str()));
|
||||
|
||||
offs_t nstart, nend, nmask, nmirror;
|
||||
check_optimize_mirror("install_bank_generic", addrstart, addrend, addrmirror, nstart, nend, nmask, nmirror);
|
||||
|
||||
// map the read bank
|
||||
if (rtag != nullptr)
|
||||
if (rtag != "")
|
||||
{
|
||||
std::string fulltag = device().siblingtag(rtag);
|
||||
memory_bank &bank = bank_find_or_allocate(fulltag.c_str(), addrstart, addrend, addrmirror, read_or_write::READ);
|
||||
@ -1951,7 +1951,7 @@ template<int Width, int AddrShift, endianness_t Endian> void address_space_speci
|
||||
}
|
||||
|
||||
// map the write bank
|
||||
if (wtag != nullptr)
|
||||
if (wtag != "")
|
||||
{
|
||||
std::string fulltag = device().siblingtag(wtag);
|
||||
memory_bank &bank = bank_find_or_allocate(fulltag.c_str(), addrstart, addrend, addrmirror, read_or_write::WRITE);
|
||||
@ -1961,7 +1961,7 @@ template<int Width, int AddrShift, endianness_t Endian> void address_space_speci
|
||||
m_root_write->populate(nstart, nend, nmirror, hand_w);
|
||||
}
|
||||
|
||||
invalidate_caches(rtag ? wtag ? read_or_write::READWRITE : read_or_write::READ : read_or_write::WRITE);
|
||||
invalidate_caches(rtag != "" ? wtag != "" ? read_or_write::READWRITE : read_or_write::READ : read_or_write::WRITE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1320,11 +1320,11 @@ public:
|
||||
void install_ram(offs_t addrstart, offs_t addrend, void *baseptr = nullptr) { install_ram(addrstart, addrend, 0, baseptr); }
|
||||
|
||||
// install ports, banks, RAM (with mirror/mask)
|
||||
void install_read_port(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *rtag) { install_readwrite_port(addrstart, addrend, addrmirror, rtag, nullptr); }
|
||||
void install_write_port(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *wtag) { install_readwrite_port(addrstart, addrend, addrmirror, nullptr, wtag); }
|
||||
virtual void install_readwrite_port(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *rtag, const char *wtag) = 0;
|
||||
void install_read_bank(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *tag) { install_bank_generic(addrstart, addrend, addrmirror, tag, nullptr); }
|
||||
void install_write_bank(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *tag) { install_bank_generic(addrstart, addrend, addrmirror, nullptr, tag); }
|
||||
void install_read_port(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *rtag) { install_readwrite_port(addrstart, addrend, addrmirror, rtag, ""); }
|
||||
void install_write_port(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *wtag) { install_readwrite_port(addrstart, addrend, addrmirror, "", wtag); }
|
||||
virtual void install_readwrite_port(offs_t addrstart, offs_t addrend, offs_t addrmirror, std::string rtag, std::string wtag) = 0;
|
||||
void install_read_bank(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *tag) { install_bank_generic(addrstart, addrend, addrmirror, tag, ""); }
|
||||
void install_write_bank(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *tag) { install_bank_generic(addrstart, addrend, addrmirror, "", tag); }
|
||||
void install_readwrite_bank(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *tag) { install_bank_generic(addrstart, addrend, addrmirror, tag, tag); }
|
||||
void install_read_bank(offs_t addrstart, offs_t addrend, offs_t addrmirror, memory_bank *bank) { install_bank_generic(addrstart, addrend, addrmirror, bank, nullptr); }
|
||||
void install_write_bank(offs_t addrstart, offs_t addrend, offs_t addrmirror, memory_bank *bank) { install_bank_generic(addrstart, addrend, addrmirror, nullptr, bank); }
|
||||
@ -1544,7 +1544,7 @@ protected:
|
||||
void populate_map_entry(const address_map_entry &entry, read_or_write readorwrite);
|
||||
virtual void unmap_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, read_or_write readorwrite, bool quiet) = 0;
|
||||
virtual void install_ram_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, read_or_write readorwrite, void *baseptr) = 0;
|
||||
virtual void install_bank_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, const char *rtag, const char *wtag) = 0;
|
||||
virtual void install_bank_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, std::string rtag, std::string wtag) = 0;
|
||||
virtual void install_bank_generic(offs_t addrstart, offs_t addrend, offs_t addrmirror, memory_bank *rbank, memory_bank *wbank) = 0;
|
||||
void adjust_addresses(offs_t &start, offs_t &end, offs_t &mask, offs_t &mirror);
|
||||
void *find_backing_memory(offs_t addrstart, offs_t addrend);
|
||||
|
Loading…
Reference in New Issue
Block a user