diff options
Diffstat (limited to 'src/devices/bus/a2bus/a2mockingboard.cpp')
-rw-r--r-- | src/devices/bus/a2bus/a2mockingboard.cpp | 507 |
1 files changed, 213 insertions, 294 deletions
diff --git a/src/devices/bus/a2bus/a2mockingboard.cpp b/src/devices/bus/a2bus/a2mockingboard.cpp index 3ddcc8bbd92..dbc9370bf69 100644 --- a/src/devices/bus/a2bus/a2mockingboard.cpp +++ b/src/devices/bus/a2bus/a2mockingboard.cpp @@ -38,72 +38,60 @@ DEFINE_DEVICE_TYPE(A2BUS_ECHOPLUS, a2bus_echoplus_device, "a2echop", "S // device_add_mconfig - add device configuration //------------------------------------------------- -MACHINE_CONFIG_START(a2bus_ayboard_device::device_add_mconfig) - MCFG_DEVICE_ADD(VIA1_TAG, VIA6522, 1022727) - MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(*this, a2bus_ayboard_device, via1_out_a)) - MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(*this, a2bus_ayboard_device, via1_out_b)) - MCFG_VIA6522_IRQ_HANDLER(WRITELINE(*this, a2bus_ayboard_device, via1_irq_w)) +void a2bus_ayboard_device::add_common_devices(machine_config &config) +{ + VIA6522(config, m_via1, 1022727); + m_via1->writepa_handler().set(FUNC(a2bus_ayboard_device::via1_out_a)); + m_via1->writepb_handler().set(FUNC(a2bus_ayboard_device::via1_out_b)); + m_via1->irq_handler().set(FUNC(a2bus_ayboard_device::via1_irq_w)); - MCFG_DEVICE_ADD(VIA2_TAG, VIA6522, 1022727) - MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(*this, a2bus_ayboard_device, via2_out_a)) - MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(*this, a2bus_ayboard_device, via2_out_b)) - MCFG_VIA6522_IRQ_HANDLER(WRITELINE(*this, a2bus_ayboard_device, via2_irq_w)) + VIA6522(config, m_via2, 1022727); + m_via2->writepa_handler().set(FUNC(a2bus_ayboard_device::via2_out_a)); + m_via2->writepb_handler().set(FUNC(a2bus_ayboard_device::via2_out_b)); + m_via2->irq_handler().set(FUNC(a2bus_ayboard_device::via2_irq_w)); SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); - MCFG_DEVICE_ADD(AY1_TAG, AY8913, 1022727) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) - MCFG_DEVICE_ADD(AY2_TAG, AY8913, 1022727) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) -MACHINE_CONFIG_END - -MACHINE_CONFIG_START(a2bus_phasor_device::device_add_mconfig) - MCFG_DEVICE_ADD(VIA1_TAG, VIA6522, 1022727) - MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(*this, a2bus_ayboard_device, via1_out_a)) - MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(*this, a2bus_ayboard_device, via1_out_b)) - MCFG_VIA6522_IRQ_HANDLER(WRITELINE(*this, a2bus_ayboard_device, via1_irq_w)) - - MCFG_DEVICE_ADD(VIA2_TAG, VIA6522, 1022727) - MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(*this, a2bus_ayboard_device, via2_out_a)) - MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(*this, a2bus_ayboard_device, via2_out_b)) - MCFG_VIA6522_IRQ_HANDLER(WRITELINE(*this, a2bus_ayboard_device, via2_irq_w)) + AY8913(config, m_ay1, 1022727); + m_ay1->add_route(ALL_OUTPUTS, "lspeaker", 1.0); +} + +void a2bus_ayboard_device::device_add_mconfig(machine_config &config) +{ + add_common_devices(config); + + AY8913(config, m_ay2, 1022727); + m_ay2->add_route(ALL_OUTPUTS, "rspeaker", 1.0); +} + +void a2bus_phasor_device::device_add_mconfig(machine_config &config) +{ + add_common_devices(config); + + m_via1->writepb_handler().set(FUNC(a2bus_phasor_device::via1_out_b)); + m_via2->writepb_handler().set(FUNC(a2bus_phasor_device::via2_out_b)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); SPEAKER(config, "lspeaker2").front_left(); SPEAKER(config, "rspeaker2").front_right(); - MCFG_DEVICE_ADD(AY1_TAG, AY8913, 1022727) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) - MCFG_DEVICE_ADD(AY2_TAG, AY8913, 1022727) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker2", 1.0) - MCFG_DEVICE_ADD(AY3_TAG, AY8913, 1022727) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MCFG_DEVICE_ADD(AY4_TAG, AY8913, 1022727) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker2", 1.0) -MACHINE_CONFIG_END - -MACHINE_CONFIG_START(a2bus_echoplus_device::device_add_mconfig) - MCFG_DEVICE_ADD(VIA1_TAG, VIA6522, 1022727) - MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(*this, a2bus_ayboard_device, via1_out_a)) - MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(*this, a2bus_ayboard_device, via1_out_b)) - MCFG_VIA6522_IRQ_HANDLER(WRITELINE(*this, a2bus_ayboard_device, via1_irq_w)) - - MCFG_DEVICE_ADD(VIA2_TAG, VIA6522, 1022727) - MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(*this, a2bus_ayboard_device, via2_out_a)) - MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(*this, a2bus_ayboard_device, via2_out_b)) - MCFG_VIA6522_IRQ_HANDLER(WRITELINE(*this, a2bus_ayboard_device, via2_irq_w)) + AY8913(config, m_ay2, 1022727); + AY8913(config, m_ay3, 1022727); + AY8913(config, m_ay4, 1022727); + m_ay2->add_route(ALL_OUTPUTS, "lspeaker2", 1.0); + m_ay3->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_ay4->add_route(ALL_OUTPUTS, "rspeaker2", 1.0); +} - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - MCFG_DEVICE_ADD(AY1_TAG, AY8913, 1022727) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) - MCFG_DEVICE_ADD(AY2_TAG, AY8913, 1022727) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) +void a2bus_echoplus_device::device_add_mconfig(machine_config &config) +{ + add_common_devices(config); + + AY8913(config, m_ay2, 1022727); + m_ay2->add_route(ALL_OUTPUTS, "rspeaker", 1.0); SPEAKER(config, "echosp").front_center(); - MCFG_DEVICE_ADD(E2P_TMS_TAG, TMS5220, 640000) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "echosp", 1.0) -MACHINE_CONFIG_END + TMS5220(config, m_tms, 640000); + m_tms->add_route(ALL_OUTPUTS, "echosp", 1.0); +} //************************************************************************** // LIVE DEVICE @@ -116,31 +104,28 @@ a2bus_ayboard_device::a2bus_ayboard_device(const machine_config &mconfig, device m_via2(*this, VIA2_TAG), m_ay1(*this, AY1_TAG), m_ay2(*this, AY2_TAG), - m_ay3(*this, AY3_TAG), - m_ay4(*this, AY4_TAG), m_isPhasor(false), m_PhasorNative(false), m_porta1(0), m_porta2(0) + m_porta1(0), + m_porta2(0) { } a2bus_mockingboard_device::a2bus_mockingboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : a2bus_ayboard_device(mconfig, A2BUS_MOCKINGBOARD, tag, owner, clock) { - m_isPhasor = false; - m_PhasorNative = false; } a2bus_phasor_device::a2bus_phasor_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - a2bus_ayboard_device(mconfig, A2BUS_PHASOR, tag, owner, clock) + a2bus_ayboard_device(mconfig, A2BUS_PHASOR, tag, owner, clock), + m_ay3(*this, AY3_TAG), + m_ay4(*this, AY4_TAG), + m_native(false) { - m_isPhasor = true; - m_PhasorNative = false; } a2bus_echoplus_device::a2bus_echoplus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : a2bus_ayboard_device(mconfig, A2BUS_ECHOPLUS, tag, owner, clock), m_tms(*this, E2P_TMS_TAG) { - m_isPhasor = false; - m_PhasorNative = false; } //------------------------------------------------- @@ -164,48 +149,34 @@ void a2bus_ayboard_device::device_reset() uint8_t a2bus_ayboard_device::read_cnxx(uint8_t offset) { - if (m_isPhasor) - { - uint8_t retVal = 0; - int viaSel; + if (offset <= 0x10) + return m_via1->read(offset & 0xf); + else if (offset >= 0x80 && offset <= 0x90) + return m_via2->read(offset & 0xf); - if (m_PhasorNative) - { - viaSel = ((offset & 0x80)>> 6) | ((offset & 0x10)>> 4); - } - else - { - viaSel = (offset & 0x80) ? 2 : 1; - } + return 0; +} - if ((offset <= 0x20) || (offset >= 0x80 && offset <= 0xa0)) - { - if (viaSel & 1) - { - retVal |= m_via1->read(machine().dummy_space(), offset & 0xf); - } - - if (viaSel & 2) - { - retVal |= m_via2->read(machine().dummy_space(), offset & 0xf); - } - } +uint8_t a2bus_phasor_device::read_cnxx(uint8_t offset) +{ + uint8_t ret = 0; + int via_sel; - return retVal; - } + if (m_native) + via_sel = ((offset & 0x80) >> 6) | ((offset & 0x10) >> 4); else + via_sel = (offset & 0x80) ? 2 : 1; + + if ((offset <= 0x20) || (offset >= 0x80 && offset <= 0xa0)) { - if (offset <= 0x10) - { - return m_via1->read(machine().dummy_space(), offset & 0xf); - } - else if (offset >= 0x80 && offset <= 0x90) - { - return m_via2->read(machine().dummy_space(), offset & 0xf); - } + if (BIT(via_sel, 0)) + ret |= m_via1->read(offset & 0xf); + + if (BIT(via_sel, 1)) + ret |= m_via2->read(offset & 0xf); } - return 0; + return ret; } /*------------------------------------------------- @@ -214,71 +185,47 @@ uint8_t a2bus_ayboard_device::read_cnxx(uint8_t offset) void a2bus_ayboard_device::write_cnxx(uint8_t offset, uint8_t data) { - if (m_isPhasor) - { - if ((offset <= 0x20) || (offset >= 0x80 && offset <= 0xa0)) - { - int viaSel; - - if (m_PhasorNative) - { - viaSel = ((offset & 0x80)>> 6) | ((offset & 0x10)>> 4); - } - else - { - viaSel = (offset & 0x80) ? 2 : 1; - } - - if (viaSel & 1) - { - m_via1->write(machine().dummy_space(), offset&0xf, data); - } - if (viaSel & 2) - { - m_via2->write(machine().dummy_space(), offset&0xf, data); - } - } - } + if (offset <= 0x10) + m_via1->write(offset & 0xf, data); + else if (offset >= 0x80 && offset <= 0x90) + m_via2->write(offset & 0xf, data); else + logerror("Mockingboard(%d): unk write %02x to Cn%02X (%s)\n", slotno(), data, offset, machine().describe_context()); +} + +void a2bus_phasor_device::write_cnxx(uint8_t offset, uint8_t data) +{ + if ((offset <= 0x20) || (offset >= 0x80 && offset <= 0xa0)) { - if (offset <= 0x10) - { - m_via1->write(machine().dummy_space(), offset & 0xf, data); - } - else if (offset >= 0x80 && offset <= 0x90) - { - m_via2->write(machine().dummy_space(), offset & 0xf, data); - } + int via_sel; + + if (m_native) + via_sel = ((offset & 0x80) >> 6) | ((offset & 0x10) >> 4); else - { - logerror("Mockingboard(%d): unk write %02x to Cn%02X (%s)\n", slotno(), data, offset, machine().describe_context()); - } + via_sel = (offset & 0x80) ? 2 : 1; + + if (BIT(via_sel, 0)) + m_via1->write(offset & 0xf, data); + + if (BIT(via_sel, 1)) + m_via2->write(offset & 0xf, data); } } - WRITE_LINE_MEMBER( a2bus_ayboard_device::via1_irq_w ) { if (state) - { raise_slot_irq(); - } else - { lower_slot_irq(); - } } WRITE_LINE_MEMBER( a2bus_ayboard_device::via2_irq_w ) { if (state) - { raise_slot_irq(); - } else - { lower_slot_irq(); - } } WRITE8_MEMBER( a2bus_ayboard_device::via1_out_a ) @@ -288,88 +235,77 @@ WRITE8_MEMBER( a2bus_ayboard_device::via1_out_a ) WRITE8_MEMBER( a2bus_ayboard_device::via1_out_b ) { + if (!BIT(data, 2)) + { + m_ay1->reset_w(space, 0, 0); + } + else + { + switch (data & 3) + { + case 0: // BDIR=0, BC1=0 (inactive) + break; + + case 1: // BDIR=0, BC1=1 (read PSG) + m_porta1 = m_ay1->read_data(); + break; + + case 2: // BDIR=1, BC1=0 (write PSG) + m_ay1->write_data(m_porta1); + break; + + case 3: // BDIR=1, BC1=1 (latch) + m_ay1->write_address(m_porta1); + break; + } + } +} + +WRITE8_MEMBER( a2bus_phasor_device::via1_out_b ) +{ if (!(data & 4)) { m_ay1->reset_w(space, 0, 0); - if (m_isPhasor && m_PhasorNative) + if (m_native) { m_ay2->reset_w(space, 0, 0); } } else { - if (!m_isPhasor) + int chip_sel; + + if (m_native) + chip_sel = (~(data >> 3) & 3); + else + chip_sel = 1; + +// logerror("Phasor: %02x to AY1/2 CS %02x (BDIR/BC1 %02x, data %02x)\n", m_porta1, chipSel, data & 3, data); + switch (data & 3) { - switch (data & 3) - { - case 0: // BDIR=0, BC1=0 (inactive) - break; + case 0: // BDIR=0, BC1=0 (inactive) + break; - case 1: // BDIR=0, BC1=1 (read PSG) + case 1: // BDIR=0, BC1=1 (read PSG) + if (BIT(chip_sel, 0)) m_porta1 = m_ay1->read_data(); - break; + if (BIT(chip_sel, 1)) + m_porta1 = m_ay2->read_data(); + break; - case 2: // BDIR=1, BC1=0 (write PSG) + case 2: // BDIR=1, BC1=0 (write PSG) + if (BIT(chip_sel, 0)) m_ay1->write_data(m_porta1); - break; + if (BIT(chip_sel, 1)) + m_ay2->write_data(m_porta1); + break; - case 3: // BDIR=1, BC1=1 (latch) + case 3: // BDIR=1, BC1=1 (latch) + if (BIT(chip_sel, 0)) m_ay1->write_address(m_porta1); - break; - } - } - else - { - int chipSel; - - if (m_PhasorNative) - { - chipSel = (~(data >> 3) & 3); - } - else - { - chipSel = 1; - } - -// logerror("Phasor: %02x to AY1/2 CS %02x (BDIR/BC1 %02x, data %02x)\n", m_porta1, chipSel, data & 3, data); - switch (data & 3) - { - case 0: // BDIR=0, BC1=0 (inactive) - break; - - case 1: // BDIR=0, BC1=1 (read PSG) - if (chipSel & 1) - { - m_porta1 = m_ay1->read_data(); - } - if (chipSel & 2) - { - m_porta1 = m_ay2->read_data(); - } - break; - - case 2: // BDIR=1, BC1=0 (write PSG) - if (chipSel & 1) - { - m_ay1->write_data(m_porta1); - } - if (chipSel & 2) - { - m_ay2->write_data(m_porta1); - } - break; - - case 3: // BDIR=1, BC1=1 (latch) - if (chipSel & 1) - { - m_ay1->write_address(m_porta1); - } - if (chipSel & 2) - { - m_ay2->write_address(m_porta1); - } - break; - } + if (BIT(chip_sel, 1)) + m_ay2->write_address(m_porta1); + break; } } } @@ -381,9 +317,37 @@ WRITE8_MEMBER( a2bus_ayboard_device::via2_out_a ) WRITE8_MEMBER( a2bus_ayboard_device::via2_out_b ) { - if (!(data & 4)) + if (!BIT(data, 2)) + { + m_ay2->reset_w(space, 0, 0); + } + else + { + switch (data & 3) + { + case 0: // BDIR=0, BC1=0 (inactive) + break; + + case 1: // BDIR=0, BC1=1 (read PSG) + m_porta2 = m_ay2->read_data(); + break; + + case 2: // BDIR=1, BC1=0 (write PSG) + m_ay2->write_data(m_porta2); + break; + + case 3: // BDIR=1, BC1=1 (latch) + m_ay2->write_data(m_porta2); + break; + } + } +} + +WRITE8_MEMBER( a2bus_phasor_device::via2_out_b ) +{ + if (!BIT(data, 2)) { - if (m_isPhasor && m_PhasorNative) + if (m_native) { m_ay3->reset_w(space, 0, 0); m_ay4->reset_w(space, 0, 0); @@ -395,98 +359,53 @@ WRITE8_MEMBER( a2bus_ayboard_device::via2_out_b ) } else { - if (!m_isPhasor) - { - switch (data & 3) - { - case 0: // BDIR=0, BC1=0 (inactive) - break; - - case 1: // BDIR=0, BC1=1 (read PSG) - m_porta2 = m_ay2->read_data(); - break; - - case 2: // BDIR=1, BC1=0 (write PSG) - m_ay2->write_data(m_porta2); - break; - - case 3: // BDIR=1, BC1=1 (latch) - m_ay2->write_data(m_porta2); - break; - } - } + int chip_sel; + + if (m_native) + chip_sel = (~(data >> 3) & 3); else + chip_sel = 1; + +// logerror("Phasor: %02x to AY3/4 CS %02x (BDIR/BC1 %02x, data %02x)\n", m_porta2, chipSel, data & 3, data); + switch (data & 3) { - int chipSel; - - if (m_PhasorNative) - { - chipSel = (~(data >> 3) & 3); - } - else - { - chipSel = 1; - } - -// logerror("Phasor: %02x to AY3/4 CS %02x (BDIR/BC1 %02x, data %02x)\n", m_porta2, chipSel, data & 3, data); - switch (data & 3) - { - case 0: // BDIR=0, BC1=0 (inactive) - break; - - case 1: // BDIR=0, BC1=1 (read PSG) - if (chipSel & 1) - { - m_porta2 = m_ay3->read_data(); - } - if (chipSel & 2) - { - m_porta2 = m_ay4->read_data(); - } - break; - - case 2: // BDIR=1, BC1=0 (write PSG) - if (chipSel & 1) - { - m_ay3->write_data(m_porta2); - } - if (chipSel & 2) - { - m_ay4->write_data(m_porta2); - } - break; - - case 3: // BDIR=1, BC1=1 (latch) - if (chipSel & 1) - { - m_ay3->write_address(m_porta2); - } - if (chipSel & 2) - { - m_ay4->write_address(m_porta2); - } - break; - } + case 0: // BDIR=0, BC1=0 (inactive) + break; + + case 1: // BDIR=0, BC1=1 (read PSG) + if (BIT(chip_sel, 0)) + m_porta2 = m_ay3->read_data(); + if (BIT(chip_sel, 1)) + m_porta2 = m_ay4->read_data(); + break; + + case 2: // BDIR=1, BC1=0 (write PSG) + if (BIT(chip_sel, 0)) + m_ay3->write_data(m_porta2); + if (BIT(chip_sel, 1)) + m_ay4->write_data(m_porta2); + break; + + case 3: // BDIR=1, BC1=1 (latch) + if (BIT(chip_sel, 0)) + m_ay3->write_address(m_porta2); + if (BIT(chip_sel, 1)) + m_ay4->write_address(m_porta2); + break; } } } -uint8_t a2bus_ayboard_device::read_c0nx(uint8_t offset) -{ - if (m_isPhasor) - { - m_PhasorNative = (offset & 1) ? true : false; - } +uint8_t a2bus_phasor_device::read_c0nx(uint8_t offset) +{ + m_native = BIT(offset, 0); return 0xff; } -void a2bus_ayboard_device::write_c0nx(uint8_t offset, uint8_t data) +void a2bus_phasor_device::write_c0nx(uint8_t offset, uint8_t data) { - if (m_isPhasor) - { - m_PhasorNative = (offset & 1) ? true : false; - } + m_native = BIT(offset, 0); } uint8_t a2bus_echoplus_device::read_c0nx(uint8_t offset) |