diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index fa21eeb2482..5f4650a0211 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -3368,6 +3368,8 @@ if (BUSES["CBUS"]~=null) then MAME_DIR .. "src/devices/bus/cbus/pc9801_118.h", MAME_DIR .. "src/devices/bus/cbus/pc9801_amd98.cpp", MAME_DIR .. "src/devices/bus/cbus/pc9801_amd98.h", + MAME_DIR .. "src/devices/bus/cbus/pc9801_snd.cpp", + MAME_DIR .. "src/devices/bus/cbus/pc9801_snd.h", MAME_DIR .. "src/devices/bus/cbus/mpu_pc98.cpp", MAME_DIR .. "src/devices/bus/cbus/mpu_pc98.h", MAME_DIR .. "src/devices/bus/cbus/pc9801_cbus.cpp", diff --git a/src/devices/bus/cbus/pc9801_118.cpp b/src/devices/bus/cbus/pc9801_118.cpp index 719f226fe3b..8242d5aeeb7 100644 --- a/src/devices/bus/cbus/pc9801_118.cpp +++ b/src/devices/bus/cbus/pc9801_118.cpp @@ -8,7 +8,7 @@ TODO: - preliminary, presumably needs CS-4231 too - - joystick code should be shared between -26, -86 and -118 + - verify sound irq; ***************************************************************************/ @@ -28,18 +28,7 @@ // device type definition DEFINE_DEVICE_TYPE(PC9801_118, pc9801_118_device, "pc9801_118", "pc9801_118") - -READ8_MEMBER(pc9801_118_device::opn_porta_r) -{ - if(m_joy_sel & 0x80) - return ioport(m_joy_sel & 0x40 ? "OPN3_PA2" : "OPN3_PA1")->read(); - - return 0xff; -} - -WRITE8_MEMBER(pc9801_118_device::opn_portb_w){ m_joy_sel = data; } - -WRITE_LINE_MEMBER(pc9801_118_device::pc9801_sound_irq) +WRITE_LINE_MEMBER(pc9801_118_device::sound_irq) { /* TODO: seems to die very often */ m_bus->int_w<5>(state); @@ -50,14 +39,16 @@ WRITE_LINE_MEMBER(pc9801_118_device::pc9801_sound_irq) //------------------------------------------------- MACHINE_CONFIG_START(pc9801_118_device::device_add_mconfig) - SPEAKER(config, "mono").front_center(); + SPEAKER(config, "lspeaker").front_left(); + SPEAKER(config, "rspeaker").front_right(); MCFG_DEVICE_ADD("opn3", YM2608, MAIN_CLOCK_X2*4) // actually YMF288, unknown clock / divider, might be X1 x 5 actually - MCFG_YM2608_IRQ_HANDLER(WRITELINE(*this, pc9801_118_device, pc9801_sound_irq)) - MCFG_AY8910_PORT_A_READ_CB(READ8(*this, pc9801_118_device, opn_porta_r)) + MCFG_YM2608_IRQ_HANDLER(WRITELINE(*this, pc9801_118_device, sound_irq)) + MCFG_AY8910_PORT_A_READ_CB(READ8(*this, pc9801_snd_device, opn_porta_r)) //MCFG_AY8910_PORT_B_READ_CB(READ8(*this, pc9801_state, opn_portb_r)) //MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(*this, pc9801_state, opn_porta_w)) - MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(*this, pc9801_118_device, opn_portb_w)) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) + MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(*this, pc9801_snd_device, opn_portb_w)) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.00) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.00) MACHINE_CONFIG_END @@ -66,23 +57,7 @@ MACHINE_CONFIG_END //------------------------------------------------- static INPUT_PORTS_START( pc9801_118 ) - PORT_START("OPN3_PA1") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Up") - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Down") - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Left") - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Right") - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 Joystick Button 1") - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Joystick Button 2") - PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("OPN3_PA2") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Up") - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Down") - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Left") - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Right") - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Joystick Button 1") - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Joystick Button 2") - PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_INCLUDE( pc9801_joy_port ) PORT_START("OPN3_DSW") PORT_CONFNAME( 0x01, 0x00, "PC-9801-118: Port Base" ) @@ -114,7 +89,7 @@ const tiny_rom_entry *pc9801_118_device::device_rom_region() const //------------------------------------------------- pc9801_118_device::pc9801_118_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, PC9801_118, tag, owner, clock), + : pc9801_snd_device(mconfig, PC9801_118, tag, owner, clock), m_bus(*this, DEVICE_SELF_OWNER), m_opn3(*this, "opn3") { @@ -166,8 +141,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::pc9801_118_r), this), write8_delegate(FUNC(pc9801_118_device::pc9801_118_w), this) ); - install_device(0xa460, 0xa463, read8_delegate(FUNC(pc9801_118_device::pc9801_118_ext_r), this), write8_delegate(FUNC(pc9801_118_device::pc9801_118_ext_w), this) ); + 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_ext_reg = 1; // TODO: enabled or disabled? } @@ -177,7 +152,7 @@ void pc9801_118_device::device_reset() //************************************************************************** -READ8_MEMBER(pc9801_118_device::pc9801_118_r) +READ8_MEMBER(pc9801_118_device::opn3_r) { if(((offset & 5) == 0) || m_ext_reg) return m_opn3->read(space, offset >> 1); @@ -189,7 +164,7 @@ READ8_MEMBER(pc9801_118_device::pc9801_118_r) } -WRITE8_MEMBER(pc9801_118_device::pc9801_118_w) +WRITE8_MEMBER(pc9801_118_device::opn3_w) { if(((offset & 5) == 0) || m_ext_reg) m_opn3->write(space, offset >> 1,data); @@ -197,7 +172,7 @@ WRITE8_MEMBER(pc9801_118_device::pc9801_118_w) // printf("PC9801-118: Write to undefined port [%02x] %02x\n",offset+0x188,data); } -READ8_MEMBER( pc9801_118_device::pc9801_118_ext_r ) +READ8_MEMBER( pc9801_118_device::id_r ) { if(offset == 0) { @@ -209,7 +184,7 @@ READ8_MEMBER( pc9801_118_device::pc9801_118_ext_r ) return 0xff; } -WRITE8_MEMBER( pc9801_118_device::pc9801_118_ext_w ) +WRITE8_MEMBER( pc9801_118_device::ext_w ) { if(offset == 0) { diff --git a/src/devices/bus/cbus/pc9801_118.h b/src/devices/bus/cbus/pc9801_118.h index 99a4287e429..a565e24eded 100644 --- a/src/devices/bus/cbus/pc9801_118.h +++ b/src/devices/bus/cbus/pc9801_118.h @@ -13,6 +13,7 @@ #include "bus/cbus/pc9801_cbus.h" #include "sound/2608intf.h" +#include "pc9801_snd.h" //************************************************************************** @@ -21,16 +22,16 @@ // ======================> pc9801_118_device -class pc9801_118_device : public device_t +class pc9801_118_device : public pc9801_snd_device { public: // construction/destruction pc9801_118_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - DECLARE_READ8_MEMBER(pc9801_118_r); - DECLARE_WRITE8_MEMBER(pc9801_118_w); - DECLARE_READ8_MEMBER(pc9801_118_ext_r); - DECLARE_WRITE8_MEMBER(pc9801_118_ext_w); + DECLARE_READ8_MEMBER(opn3_r); + DECLARE_WRITE8_MEMBER(opn3_w); + DECLARE_READ8_MEMBER(id_r); + DECLARE_WRITE8_MEMBER(ext_w); protected: // device-level overrides @@ -47,12 +48,9 @@ private: required_device m_bus; required_device m_opn3; - uint8_t m_joy_sel; uint8_t m_ext_reg; - DECLARE_READ8_MEMBER(opn_porta_r); - DECLARE_WRITE8_MEMBER(opn_portb_w); - DECLARE_WRITE_LINE_MEMBER(pc9801_sound_irq); + DECLARE_WRITE_LINE_MEMBER(sound_irq); }; diff --git a/src/devices/bus/cbus/pc9801_26.cpp b/src/devices/bus/cbus/pc9801_26.cpp index d19bf57f522..6c60bcaa969 100644 --- a/src/devices/bus/cbus/pc9801_26.cpp +++ b/src/devices/bus/cbus/pc9801_26.cpp @@ -7,8 +7,8 @@ Legacy sound card for PC-98xx family, composed by a single YM2203 TODO: - - joystick code should be shared between -26, -86 and -118 - + - verify sound irq; + ***************************************************************************/ #include "emu.h" @@ -27,18 +27,6 @@ // device type definition DEFINE_DEVICE_TYPE(PC9801_26, pc9801_26_device, "pc9801_26", "pc9801_26") - - -READ8_MEMBER(pc9801_26_device::opn_porta_r) -{ - if(m_joy_sel & 0x80) - return ioport(m_joy_sel & 0x40 ? "OPN_PA2" : "OPN_PA1")->read(); - - return 0xff; -} - -WRITE8_MEMBER(pc9801_26_device::opn_portb_w){ m_joy_sel = data; } - WRITE_LINE_MEMBER(pc9801_26_device::pc9801_sound_irq) { /* TODO: seems to die very often */ @@ -54,10 +42,10 @@ MACHINE_CONFIG_START(pc9801_26_device::device_add_mconfig) SPEAKER(config, "mono").front_center(); MCFG_DEVICE_ADD("opn", YM2203, MAIN_CLOCK_X1*2) // unknown clock / divider MCFG_YM2203_IRQ_HANDLER(WRITELINE(*this, pc9801_26_device, pc9801_sound_irq)) - MCFG_AY8910_PORT_A_READ_CB(READ8(*this, pc9801_26_device, opn_porta_r)) + MCFG_AY8910_PORT_A_READ_CB(READ8(*this, pc9801_snd_device, opn_porta_r)) //MCFG_AY8910_PORT_B_READ_CB(READ8(*this, pc9801_state, opn_portb_r)) //MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(*this, pc9801_state, opn_porta_w)) - MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(*this, pc9801_26_device, opn_portb_w)) + MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(*this, pc9801_snd_device, opn_portb_w)) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MACHINE_CONFIG_END @@ -88,25 +76,7 @@ const tiny_rom_entry *pc9801_26_device::device_rom_region() const //------------------------------------------------- static INPUT_PORTS_START( pc9801_26 ) - PORT_START("OPN_PA1") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Up") - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Down") - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Left") - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Right") - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 Joystick Button 1") - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Joystick Button 2") - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("OPN_PA2") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Up") - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Down") - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Left") - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Right") - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Joystick Button 1") - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Joystick Button 2") - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_INCLUDE( pc9801_joy_port ) PORT_START("OPN_DSW") PORT_CONFNAME( 0x01, 0x01, "PC-9801-26: Port Base" ) @@ -128,7 +98,7 @@ ioport_constructor pc9801_26_device::device_input_ports() const //------------------------------------------------- pc9801_26_device::pc9801_26_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, PC9801_26, tag, owner, clock), + : pc9801_snd_device(mconfig, PC9801_26, tag, owner, clock), m_bus(*this, DEVICE_SELF_OWNER), m_opn(*this, "opn") { diff --git a/src/devices/bus/cbus/pc9801_26.h b/src/devices/bus/cbus/pc9801_26.h index 250d38a6d8a..fe3c8b7667b 100644 --- a/src/devices/bus/cbus/pc9801_26.h +++ b/src/devices/bus/cbus/pc9801_26.h @@ -13,7 +13,7 @@ Template for skeleton device #include "bus/cbus/pc9801_cbus.h" #include "sound/2203intf.h" - +#include "pc9801_snd.h" //************************************************************************** // TYPE DEFINITIONS @@ -21,7 +21,7 @@ Template for skeleton device // ======================> pc9801_26_device -class pc9801_26_device : public device_t +class pc9801_26_device : public pc9801_snd_device { public: // construction/destruction @@ -48,8 +48,6 @@ private: uint8_t m_joy_sel; DECLARE_WRITE_LINE_MEMBER(pc9801_sound_irq); - DECLARE_READ8_MEMBER(opn_porta_r); - DECLARE_WRITE8_MEMBER(opn_portb_w); }; diff --git a/src/devices/bus/cbus/pc9801_86.cpp b/src/devices/bus/cbus/pc9801_86.cpp index 130878a58ee..977a70ae187 100644 --- a/src/devices/bus/cbus/pc9801_86.cpp +++ b/src/devices/bus/cbus/pc9801_86.cpp @@ -16,7 +16,8 @@ - Make volume work - Recording - actual stereo sound routing (currently routes to ALL_OUTPUTS) - - SpeakBoard: no idea about software that uses this; + - SpeakBoard: no idea about software that uses this, also board shows a single YM2608B?; + - verify sound irq; ***************************************************************************/ @@ -34,17 +35,6 @@ // device type definition DEFINE_DEVICE_TYPE(PC9801_86, pc9801_86_device, "pc9801_86", "pc9801_86") - -READ8_MEMBER(pc9801_86_device::opn_porta_r) -{ - if(m_joy_sel & 0x80) - return ioport(m_joy_sel & 0x40 ? "OPNA_PA2" : "OPNA_PA1")->read(); - - return 0xff; -} - -WRITE8_MEMBER(pc9801_86_device::opn_portb_w){ m_joy_sel = data; } - WRITE_LINE_MEMBER(pc9801_86_device::sound_irq) { m_fmirq = state ? true : false; @@ -63,12 +53,13 @@ MACHINE_CONFIG_START(pc9801_86_device::pc9801_86_config) MCFG_DEVICE_ADD("opna", YM2608, 7.987_MHz_XTAL) MCFG_YM2608_IRQ_HANDLER(WRITELINE(*this, pc9801_86_device, sound_irq)) MCFG_AY8910_OUTPUT_TYPE(0) - MCFG_AY8910_PORT_A_READ_CB(READ8(*this, pc9801_86_device, opn_porta_r)) + MCFG_AY8910_PORT_A_READ_CB(READ8(*this, pc9801_snd_device, opn_porta_r)) //MCFG_AY8910_PORT_B_READ_CB(READ8(*this, pc9801_state, opn_portb_r)) //MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(*this, pc9801_state, opn_porta_w)) - MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(*this, pc9801_86_device, opn_portb_w)) + MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(*this, pc9801_snd_device, opn_portb_w)) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.00) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.00) + MCFG_DEVICE_ADD("ldac", DAC_16BIT_R2R_TWOS_COMPLEMENT, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) // burr brown pcm61p MCFG_DEVICE_ADD("rdac", DAC_16BIT_R2R_TWOS_COMPLEMENT, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) // burr brown pcm61p MCFG_DEVICE_ADD("vref", VOLTAGE_REGULATOR, 0) MCFG_VOLTAGE_REGULATOR_OUTPUT(5.0) @@ -108,23 +99,7 @@ const tiny_rom_entry *pc9801_86_device::device_rom_region() const //------------------------------------------------- static INPUT_PORTS_START( pc9801_86 ) - PORT_START("OPNA_PA1") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Up") - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Down") - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Left") - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Right") - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 Joystick Button 1") - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Joystick Button 2") - PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("OPNA_PA2") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Up") - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Down") - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Left") - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Right") - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Joystick Button 1") - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Joystick Button 2") - PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_INCLUDE( pc9801_joy_port ) PORT_START("OPNA_DSW") PORT_CONFNAME( 0x01, 0x01, "PC-9801-86: Port Base" ) @@ -146,7 +121,7 @@ ioport_constructor pc9801_86_device::device_input_ports() const //------------------------------------------------- pc9801_86_device::pc9801_86_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock), + : pc9801_snd_device(mconfig, type, tag, owner, clock), m_bus(*this, DEVICE_SELF_OWNER), m_opna(*this, "opna"), m_ldac(*this, "ldac"), @@ -419,7 +394,7 @@ const tiny_rom_entry *pc9801_speakboard_device::device_rom_region() const //************************************************************************** //------------------------------------------------- -// pc9801_86_device - constructor +// pc9801_speakboard_device - constructor //------------------------------------------------- pc9801_speakboard_device::pc9801_speakboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) diff --git a/src/devices/bus/cbus/pc9801_86.h b/src/devices/bus/cbus/pc9801_86.h index 29088119e58..4394cb72451 100644 --- a/src/devices/bus/cbus/pc9801_86.h +++ b/src/devices/bus/cbus/pc9801_86.h @@ -14,6 +14,7 @@ #include "bus/cbus/pc9801_cbus.h" #include "sound/2608intf.h" #include "sound/dac.h" +#include "pc9801_snd.h" //************************************************************************** // TYPE DEFINITIONS @@ -21,7 +22,7 @@ // ======================> pc9801_86_device -class pc9801_86_device : public device_t +class pc9801_86_device : public pc9801_snd_device { public: // construction/destruction @@ -36,8 +37,6 @@ public: DECLARE_WRITE8_MEMBER(pcm_w); DECLARE_WRITE_LINE_MEMBER(sound_irq); - DECLARE_READ8_MEMBER(opn_porta_r); - DECLARE_WRITE8_MEMBER(opn_portb_w); protected: // device-level overrides @@ -58,7 +57,7 @@ private: required_device m_bus; - uint8_t m_joy_sel, m_mask, m_pcm_mode, m_vol[7], m_pcm_ctrl, m_pcm_mute; + 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; bool m_pcmirq, m_fmirq, m_pcm_clk, m_init; required_device m_opna; diff --git a/src/devices/bus/cbus/pc9801_snd.cpp b/src/devices/bus/cbus/pc9801_snd.cpp new file mode 100644 index 00000000000..68b4d3df97d --- /dev/null +++ b/src/devices/bus/cbus/pc9801_snd.cpp @@ -0,0 +1,50 @@ +// license:BSD-3-Clause +// copyright-holders:Angelo Salese +/*************************************************************************** + + NEC PC-9801 + common functions for CBUS sound boards -26, -86, -118 + +***************************************************************************/ + +#include "emu.h" +#include "pc9801_snd.h" + +//DEFINE_DEVICE_TYPE(PC9801_SND, pc9801_snd_device, "pc9801_snd", "PC9801 CBUS Sound") + +pc9801_snd_device::pc9801_snd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, type, tag, owner, clock) +{ +} + +READ8_MEMBER(pc9801_snd_device::opn_porta_r) +{ + if(m_joy_sel & 0x80) + return ioport(m_joy_sel & 0x40 ? "PA2" : "PA1")->read(); + + return 0xff; +} + +WRITE8_MEMBER(pc9801_snd_device::opn_portb_w) { m_joy_sel = data; } + +INPUT_PORTS_START(pc9801_joy_port) + PORT_START("PA1") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Up") + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Down") + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Left") + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Joystick Right") + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 Joystick Button 1") + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Joystick Button 2") + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) + + PORT_START("PA2") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Up") + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Down") + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Left") + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_NAME("P2 Joystick Right") + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Joystick Button 1") + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Joystick Button 2") + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) +INPUT_PORTS_END diff --git a/src/devices/bus/cbus/pc9801_snd.h b/src/devices/bus/cbus/pc9801_snd.h new file mode 100644 index 00000000000..24c410cf12d --- /dev/null +++ b/src/devices/bus/cbus/pc9801_snd.h @@ -0,0 +1,31 @@ +// license:BSD-3-Clause +// copyright-holders:Angelo Salese +/*************************************************************************** + + NEC PC-9801 + common functions for CBUS sound boards -26, -86, -118 + +***************************************************************************/ + +#ifndef MAME_BUS_CBUS_PC9801_SND_H +#define MAME_BUS_CBUS_PC9801_SND_H + +#pragma once + +class pc9801_snd_device : public device_t +{ +public: + pc9801_snd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + + DECLARE_READ8_MEMBER(opn_porta_r); + DECLARE_WRITE8_MEMBER(opn_portb_w); +protected: + +private: + uint8_t m_joy_sel; +}; + +//DECLARE_DEVICE_TYPE(PC9801_SND, pc9801_snd_device) +INPUT_PORTS_EXTERN(pc9801_joy_port); + +#endif