pc9801_cbus.cpp: bulk replace install_device() -> install_io(), made it a bus responsibility (nw)

This commit is contained in:
angelosa 2018-05-26 17:19:29 +02:00
parent 91ebb2f21f
commit e08ff4118c
11 changed files with 36 additions and 94 deletions

View File

@ -71,8 +71,7 @@ void mpu_pc98_device::map(address_map &map)
void mpu_pc98_device::device_start()
{
address_space &iospace = m_bus->io_space();
iospace.install_device(0xe0d0, 0xe0d3, *this, &mpu_pc98_device::map);
m_bus->io_space().install_device(0xe0d0, 0xe0d3, *this, &mpu_pc98_device::map);
}
//-------------------------------------------------

View File

@ -109,28 +109,12 @@ void pc9801_118_device::device_validity_check(validity_checker &valid) const
// device_start - device-specific startup
//-------------------------------------------------
void pc9801_118_device::install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler)
{
int buswidth = m_bus->io_space().data_width();
switch(buswidth)
{
case 8:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0);
break;
case 16:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0xffff);
break;
case 32:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0xffffffff);
break;
default:
fatalerror("PC-9801-118: Bus width %d not supported\n", buswidth);
}
}
void pc9801_118_device::device_start()
{
m_bus->install_io(0xa460, 0xa463, read8_delegate(FUNC(pc9801_118_device::id_r), this), write8_delegate(FUNC(pc9801_118_device::ext_w), this) );
save_item(NAME(m_ext_reg));
}
@ -141,8 +125,8 @@ void pc9801_118_device::device_start()
void pc9801_118_device::device_reset()
{
uint16_t port_base = (ioport("OPN3_DSW")->read() & 1) << 8;
install_device(port_base + 0x0088, port_base + 0x008f, read8_delegate(FUNC(pc9801_118_device::opn3_r), this), write8_delegate(FUNC(pc9801_118_device::opn3_w), this) );
install_device(0xa460, 0xa463, read8_delegate(FUNC(pc9801_118_device::id_r), this), write8_delegate(FUNC(pc9801_118_device::ext_w), this) );
m_bus->io_space().unmap_readwrite(0x0088, 0x008b, 0x100);
m_bus->install_io(port_base + 0x0088, port_base + 0x008f, read8_delegate(FUNC(pc9801_118_device::opn3_r), this), write8_delegate(FUNC(pc9801_118_device::opn3_w), this) );
m_ext_reg = 1; // TODO: enabled or disabled?
}

View File

@ -42,7 +42,6 @@ protected:
virtual void device_add_mconfig(machine_config &config) override;
virtual ioport_constructor device_input_ports() const override;
virtual const tiny_rom_entry *device_rom_region() const override;
void install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);
private:
required_device<pc9801_slot_device> m_bus;

View File

@ -118,25 +118,6 @@ void pc9801_26_device::device_validity_check(validity_checker &valid) const
// device_start - device-specific startup
//-------------------------------------------------
void pc9801_26_device::install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler)
{
int buswidth = m_bus->io_space().data_width();
switch(buswidth)
{
case 8:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0);
break;
case 16:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0xffff);
break;
case 32:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0xffffffff);
break;
default:
fatalerror("PC-9801-26: Bus width %d not supported\n", buswidth);
}
}
void pc9801_26_device::device_start()
{
@ -153,7 +134,7 @@ void pc9801_26_device::device_reset()
uint16_t port_base = (ioport("OPN_DSW")->read() & 1) << 8;
m_bus->io_space().unmap_readwrite(0x0088, 0x008b, 0x100);
install_device(port_base + 0x0088, port_base + 0x008b, read8_delegate(FUNC(pc9801_26_device::opn_r), this), write8_delegate(FUNC(pc9801_26_device::opn_w), this) );
m_bus->install_io(port_base + 0x0088, port_base + 0x008b, read8_delegate(FUNC(pc9801_26_device::opn_r), this), write8_delegate(FUNC(pc9801_26_device::opn_w), this) );
}

View File

@ -39,7 +39,6 @@ protected:
virtual void device_add_mconfig(machine_config &config) override;
virtual ioport_constructor device_input_ports() const override;
virtual const tiny_rom_entry *device_rom_region() const override;
void install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);
private:
required_device<pc9801_slot_device> m_bus;

View File

@ -153,32 +153,13 @@ void pc9801_86_device::device_validity_check(validity_checker &valid) const
// device_start - device-specific startup
//-------------------------------------------------
void pc9801_86_device::install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler)
{
int buswidth = m_bus->io_space().data_width();
switch(buswidth)
{
case 8:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0);
break;
case 16:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0xffff);
break;
case 32:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0xffffffff);
break;
default:
fatalerror("PC-9801-86: Bus width %d not supported\n", buswidth);
}
}
void pc9801_86_device::device_start()
{
m_bus->program_space().install_rom(0xcc000,0xcffff,memregion(this->subtag("sound_bios").c_str())->base());
install_device(0xa460, 0xa463, read8_delegate(FUNC(pc9801_86_device::id_r), this), write8_delegate(FUNC(pc9801_86_device::mask_w), this));
install_device(0xa464, 0xa46f, read8_delegate(FUNC(pc9801_86_device::pcm_r), this), write8_delegate(FUNC(pc9801_86_device::pcm_w), this));
install_device(0xa66c, 0xa66f, read8_delegate([this](address_space &s, offs_t o, u8 mm){ return o == 2 ? m_pcm_mute : 0xff; }, "pc9801_86_mute_r"),
m_bus->install_io(0xa460, 0xa463, read8_delegate(FUNC(pc9801_86_device::id_r), this), write8_delegate(FUNC(pc9801_86_device::mask_w), this));
m_bus->install_io(0xa464, 0xa46f, read8_delegate(FUNC(pc9801_86_device::pcm_r), this), write8_delegate(FUNC(pc9801_86_device::pcm_w), this));
m_bus->install_io(0xa66c, 0xa66f, read8_delegate([this](address_space &s, offs_t o, u8 mm){ return o == 2 ? m_pcm_mute : 0xff; }, "pc9801_86_mute_r"),
write8_delegate([this](address_space &s, offs_t o, u8 d, u8 mm){ if(o == 2) m_pcm_mute = d; }, "pc9801_86_mute_w"));
m_dac_timer = timer_alloc();
@ -196,7 +177,7 @@ void pc9801_86_device::device_reset()
{
uint16_t port_base = (ioport("OPNA_DSW")->read() & 1) << 8;
m_bus->io_space().unmap_readwrite(0x0088, 0x008f, 0x100);
install_device(port_base + 0x0088, port_base + 0x008f, read8_delegate(FUNC(pc9801_86_device::opna_r), this), write8_delegate(FUNC(pc9801_86_device::opna_w), this) );
m_bus->install_io(port_base + 0x0088, port_base + 0x008f, read8_delegate(FUNC(pc9801_86_device::opna_r), this), write8_delegate(FUNC(pc9801_86_device::opna_w), this) );
m_mask = 0;
m_head = m_tail = m_count = 0;
@ -419,7 +400,7 @@ void pc9801_speakboard_device::device_start()
{
pc9801_86_device::device_start();
install_device(0x0588, 0x058f, read8_delegate(FUNC(pc9801_speakboard_device::opna_slave_r), this), write8_delegate(FUNC(pc9801_speakboard_device::opna_slave_w), this) );
m_bus->install_io(0x0588, 0x058f, read8_delegate(FUNC(pc9801_speakboard_device::opna_slave_r), this), write8_delegate(FUNC(pc9801_speakboard_device::opna_slave_w), this) );
}
void pc9801_speakboard_device::device_reset()

View File

@ -47,15 +47,15 @@ protected:
virtual void device_add_mconfig(machine_config &config) override;
virtual ioport_constructor device_input_ports() const override;
virtual const tiny_rom_entry *device_rom_region() const override;
void install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
void pc9801_86_config(machine_config &config);
required_device<pc9801_slot_device> m_bus;
private:
int queue_count();
uint8_t queue_pop();
required_device<pc9801_slot_device> m_bus;
uint8_t m_mask, m_pcm_mode, m_vol[7], m_pcm_ctrl, m_pcm_mute;
uint16_t m_head, m_tail, m_count, m_irq_rate;

View File

@ -124,26 +124,6 @@ void pc9801_amd98_device::device_validity_check(validity_checker &valid) const
// device_start - device-specific startup
//-------------------------------------------------
void pc9801_amd98_device::install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler)
{
int buswidth = m_bus->io_space().data_width();
switch(buswidth)
{
case 8:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0);
break;
case 16:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0xffff);
break;
case 32:
m_bus->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0xffffffff);
break;
default:
fatalerror("PC-9801-AMD98: Bus width %d not supported\n", buswidth);
}
}
void pc9801_amd98_device::device_start()
{
}
@ -155,9 +135,9 @@ void pc9801_amd98_device::device_start()
void pc9801_amd98_device::device_reset()
{
install_device(0x00d8, 0x00df, read8_delegate(FUNC(pc9801_amd98_device::read), this), write8_delegate(FUNC(pc9801_amd98_device::write), this) );
m_bus->install_io(0x00d8, 0x00df, read8_delegate(FUNC(pc9801_amd98_device::read), this), write8_delegate(FUNC(pc9801_amd98_device::write), this) );
// Thexder access with following
install_device(0x38d8, 0x38df, read8_delegate(FUNC(pc9801_amd98_device::read), this), write8_delegate(FUNC(pc9801_amd98_device::write), this) );
m_bus->install_io(0x38d8, 0x38df, read8_delegate(FUNC(pc9801_amd98_device::read), this), write8_delegate(FUNC(pc9801_amd98_device::write), this) );
}

View File

@ -39,7 +39,6 @@ protected:
virtual void device_reset() override;
// optional information overrides
virtual void device_add_mconfig(machine_config &config) override;
void install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);
virtual ioport_constructor device_input_ports() const override;
private:

View File

@ -94,3 +94,22 @@ void pc9801_slot_device::device_start()
{
// m_card = dynamic_cast<device_pc9801_slot_card_interface *>(get_card_device());
}
void pc9801_slot_device::install_io(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler)
{
int buswidth = this->io_space().data_width();
switch(buswidth)
{
case 8:
this->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0);
break;
case 16:
this->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0xffff);
break;
case 32:
this->io_space().install_readwrite_handler(start, end, rhandler, whandler, 0xffffffff);
break;
default:
fatalerror("PC-9801-26: Bus width %d not supported\n", buswidth);
}
}

View File

@ -84,6 +84,7 @@ public:
address_space &program_space() const { return m_cpu->space(AS_PROGRAM); }
address_space &io_space() const { return m_cpu->space(AS_IO); }
template<int I> void int_w(bool state) { m_int_callback[I](state); }
void install_io(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);
protected:
// device-level overrides