diff --git a/src/mame/audio/laserbat.cpp b/src/mame/audio/laserbat.cpp index a10e749757f..963f3aa7f76 100644 --- a/src/mame/audio/laserbat.cpp +++ b/src/mame/audio/laserbat.cpp @@ -230,7 +230,9 @@ WRITE8_MEMBER(laserbat_state::csound2_w) The Cat and Mouse sound board has a 6802 processor with three ROMs, a 6821 PIA, two AY-3-8910 PSGs, and some other logic and analog circuitry. Unfortunately we lack a schematic, so all knowledge of - this board is based on tracing the sound program. + this board is based on tracing the sound program, examining PCB + photos and cross-referencing with the schematic for the 1B11142 + schematic. The 6821 PIA is mapped at addresses $005C..$005F. The known PIA signal assignments are as follows: @@ -306,7 +308,8 @@ WRITE8_MEMBER(laserbat_state::csound2_w) WRITE8_MEMBER(catnmous_state::csound1_w) { - m_pia->ca1_w((data & 0x20) ? 1 : 0); + m_audiopcb->sound_w(space, offset, data); + m_csound1 = data; } @@ -315,66 +318,8 @@ WRITE8_MEMBER(catnmous_state::csound2_w) // the bottom bit is used for sprite banking, of all things m_gfx2 = memregion("gfx2")->base() + ((data & 0x01) ? 0x0800 : 0x0000); - // the top bit is called RESET on the wiring diagram - assume it resets the sound CPU - m_audiocpu->set_input_line(INPUT_LINE_RESET, (data & 0x80) ? ASSERT_LINE : CLEAR_LINE); + // the top bit is called RESET on the wiring diagram + m_audiopcb->reset_w((data & 0x80) ? 1 : 0); m_csound2 = data; } - -READ8_MEMBER(catnmous_state::pia_porta_r) -{ - UINT8 const control = m_pia->b_output(); - UINT8 data = 0xff; - - if (0x01 == (control & 0x03)) - data &= m_psg1->data_r(space, 0); - - if (0x04 == (control & 0x0c)) - data &= m_psg2->data_r(space, 0); - - return data; -} - -WRITE8_MEMBER(catnmous_state::pia_porta_w) -{ - UINT8 const control = m_pia->b_output(); - - if (control & 0x02) - m_psg1->data_address_w(space, (control >> 0) & 0x01, data); - - if (control & 0x08) - m_psg2->data_address_w(space, (control >> 2) & 0x01, data); -} - -WRITE8_MEMBER(catnmous_state::pia_portb_w) -{ - if (data & 0x02) - m_psg1->data_address_w(space, (data >> 0) & 0x01, m_pia->a_output()); - - if (data & 0x08) - m_psg2->data_address_w(space, (data >> 2) & 0x01, m_pia->a_output()); -} - -WRITE8_MEMBER(catnmous_state::psg1_porta_w) -{ - // similar to zaccaria.c since we have no clue how this board really works - // this code could be completely wrong/inappropriate for this game for all we know - static double const table[8] = { - RES_K(8.2), - RES_R(820), - RES_K(3.3), - RES_R(150), - RES_K(5.6), - RES_R(390), - RES_K(1.5), - RES_R(47) }; - RES_VOLTAGE_DIVIDER(RES_K(4.7), table[data & 0x07]); - m_psg2->set_volume(1, 150 * RES_VOLTAGE_DIVIDER(RES_K(4.7), table[data & 0x07])); -} - -READ8_MEMBER(catnmous_state::psg1_portb_r) -{ - // the sound program masks out the three most significant bits - // assume they're not connected and read high from the internal pull-ups - return m_csound1 | 0xe0; -} diff --git a/src/mame/audio/zaccaria.cpp b/src/mame/audio/zaccaria.cpp index 9f9b71c9a7b..0df34d1d626 100644 --- a/src/mame/audio/zaccaria.cpp +++ b/src/mame/audio/zaccaria.cpp @@ -5,73 +5,125 @@ #include "cpu/m6800/m6800.h" #include "machine/clock.h" +#include "machine/rescap.h" #include "sound/dac.h" +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +device_type const ZACCARIA_1B11107 = &device_creator; device_type const ZACCARIA_1B11142 = &device_creator; + +//************************************************************************** +// MEMORY MAPS +//************************************************************************** + /* - * slave sound cpu, produces music and sound effects - * mapping: - * A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00 - * 0 0 0 0 0 0 0 0 0 * * * * * * * RW 6802 internal ram - * 0 0 0 x x x x x x x x x x x x x Open bus (for area that doesn't overlap ram) - * 0 0 1 x x x x x x x x x x x x x Open bus - * 0 1 0 x x x x x x x x x 0 0 x x Open bus - * 0 1 0 x x x x x x x x x 0 1 x x Open bus - * 0 1 0 x x x x x x x x x 1 0 x x Open bus - * 0 1 0 x x x x x x x x x 1 1 * * RW 6821 PIA @ 4I - * 0 1 1 x x x x x x x x x x x x x Open bus - * 1 0 % % * * * * * * * * * * * * R /CS4A: Enable ROM 13 - * 1 1 % % * * * * * * * * * * * * R /CS5A: Enable ROM 9 - * note that the % bits go to pins 2 (6802 A12) and 26 (6802 A13) of the roms - * monymony and jackrabt both use 2764 roms, which use pin 2 as A12 and pin 26 as N/C don't care - * hence for actual chips used, the mem map is: - * 1 0 x * * * * * * * * * * * * * R /CS4A: Enable ROM 13 - * 1 1 x * * * * * * * * * * * * * R /CS5A: Enable ROM 9 - * - * 6821 PIA: - * CA1 comes from the master sound cpu's latch bit 7 (which is also connected to the AY chip at 4G's IOB1) - * CB1 comes from the 6802's clock divided by 4096*2 (about 437Hz) - * CA2 and CB2 are not connected - * PA0-7 connect to the data busses of the AY-3-8910 chips - * PB0 and PB1 connect to the BC1 and BDIR pins of the AY chip at 4G - * PB2 and PB3 connect to the BC1 and BDIR pins of the AY chip at 4H. - */ -static ADDRESS_MAP_START(zac1b11142_melody_map, AS_PROGRAM, 8, zac1b11142_audio_device) + base melody/SFX generator CPU map + 1B11107 and 1B11142 both have a 6802 with internal RAM and a PIA accessed at 0x500c +*/ +static ADDRESS_MAP_START(zac1b111xx_melody_base_map, AS_PROGRAM, 8, zac1b111xx_melody_base) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x0000, 0x007f) AM_RAM // 6802 internal RAM - AM_RANGE(0x400c, 0x400f) AM_MIRROR(0x1ff0) AM_DEVREADWRITE("pia_4i", pia6821_device, read, write) - AM_RANGE(0x8000, 0x9fff) AM_MIRROR(0x2000) AM_ROM // rom 13 - AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x2000) AM_ROM // rom 9 + AM_RANGE(0x400c, 0x400f) AM_MIRROR(0x1ff0) AM_DEVREADWRITE("melodypia", pia6821_device, read, write) ADDRESS_MAP_END /* - * master sound cpu, controls speech directly - * mapping: - * A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00 - * 0 0 0 0 0 0 0 0 0 * * * * * * * RW 6802 internal ram - * x 0 0 0 x x x x 1 x x 0 x x * * Open bus (test mode writes as if there was another PIA here) - * x 0 0 0 x x x x 1 x x 1 x x * * RW 6821 PIA @ 1I - * x 0 0 1 0 0 x x x x x x x x x x W MC1408 DAC - * x x 0 1 0 1 x x x x x x x x x x W Command to slave melody cpu - * x x 0 1 1 0 x x x x x x x x x x R Command read latch from z80 - * x x 0 1 1 1 x x x x x x x x x x Open bus - * % % 1 0 * * * * * * * * * * * * R /CS1A: Enable ROM 8 - * % % 1 1 * * * * * * * * * * * * R /CS0A: Enable ROM 7 - * note that the % bits go to pins 2 (6802 A14) and 26 (6802 A15) of the roms - * monymony and jackrabt both use 2764 roms, which use pin 2 as A12 and pin 26 as N/C don't care - * hence for actual chips used, the mem map is: - * x * 1 0 * * * * * * * * * * * * R /CS1A: Enable ROM 8 - * x * 1 1 * * * * * * * * * * * * R /CS0A: Enable ROM 7 - * - * 6821 PIA: - * PA0-7, PB0-1, CA2 and CB1 connect to the TMS5200 - * CA1 and CB2 are not connected, though the test mode assumes there's something connected to CB2 (possibly another LED like the one connected to PB4) - * PB3 connects to 'ACS' which goes to the Z80 - */ + 1B11107 sound CPU, produces music and sound effects + mapping (from tracing sound program and cross-referencing 1B1142 schematic): + A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00 + 0 0 0 0 0 0 0 0 0 * * * * * * * RW 6802 internal ram + 0 0 0 x x x x x x x x x x x x x Open bus (for area that doesn't overlap RAM) + 0 0 1 x x x x x x x x x x x x x Open bus + 0 1 0 x x x x x x x x x 0 0 x x Open bus + 0 1 0 x x x x x x x x x 0 1 x x Open bus + 0 1 0 x x x x x x x x x 1 0 x x Open bus + 0 1 0 x x x x x x x x x 1 1 * * RW 6821 PIA @ 1G + 0 1 1 x x x x x x x x x x x x x Open bus + 1 0 x x x x x x x x x x x x x x Open bus + 1 1 0 0 * * * * * * * * * * * * R Enable ROM @ 1F + 1 1 0 1 * * * * * * * * * * * * Open bus + 1 1 1 0 * * * * * * * * * * * * R Enable ROM @ 1D + 1 1 1 1 * * * * * * * * * * * * R Enable ROM @ 1E + + 6821 PIA: + * CA1 comes from the SOUND 5 line on the input (which may also be connected to an input on the AY chip at 1H) + * CB1 comes from the 6802's clock divided by 4096*2 (about 437Hz) + * PA0-7 connect to the data busses of the AY-3-8910 chips + * PB0 and PB1 connect to the BC1 and BDIR pins of the AY chip at 1H + * PB2 and PB3 connect to the BC1 and BDIR pins of the AY chip at 1I +*/ +static ADDRESS_MAP_START(zac1b11107_melody_map, AS_PROGRAM, 8, zac1b11107_audio_device) + AM_IMPORT_FROM(zac1b111xx_melody_base_map) + AM_RANGE(0xc000, 0xcfff) AM_ROM // ROM @ 1F + AM_RANGE(0xe000, 0xffff) AM_ROM // ROM @ 1D, 1E +ADDRESS_MAP_END + + +/* + 1B11142 slave sound CPU, produces music and sound effects + mapping: + A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00 + 0 0 0 0 0 0 0 0 0 * * * * * * * RW 6802 internal ram + 0 0 0 x x x x x x x x x x x x x Open bus (for area that doesn't overlap RAM) + 0 0 1 x x x x x x x x x x x x x Open bus + 0 1 0 x x x x x x x x x 0 0 x x Open bus + 0 1 0 x x x x x x x x x 0 1 x x Open bus + 0 1 0 x x x x x x x x x 1 0 x x Open bus + 0 1 0 x x x x x x x x x 1 1 * * RW 6821 PIA @ 4I + 0 1 1 x x x x x x x x x x x x x Open bus + 1 0 % % * * * * * * * * * * * * R /CS4A: Enable ROM 13 + 1 1 % % * * * * * * * * * * * * R /CS5A: Enable ROM 9 + note that the % bits go to pins 2 (6802 A12) and 26 (6802 A13) of the roms + monymony and jackrabt both use 2764 roms, which use pin 2 as A12 and pin 26 as N/C don't care + hence for actual chips used, the mem map is: + 1 0 x * * * * * * * * * * * * * R /CS4A: Enable ROM 13 + 1 1 x * * * * * * * * * * * * * R /CS5A: Enable ROM 9 + + 6821 PIA: + * CA1 comes from the master sound cpu's latch bit 7 (which is also connected to the AY chip at 4G's IOB1) + * CB1 comes from the 6802's clock divided by 4096*2 (about 437Hz) + * CA2 and CB2 are not connected + * PA0-7 connect to the data busses of the AY-3-8910 chips + * PB0 and PB1 connect to the BC1 and BDIR pins of the AY chip at 4G + * PB2 and PB3 connect to the BC1 and BDIR pins of the AY chip at 4H +*/ +static ADDRESS_MAP_START(zac1b11142_melody_map, AS_PROGRAM, 8, zac1b11142_audio_device) + AM_IMPORT_FROM(zac1b111xx_melody_base_map) + AM_RANGE(0x8000, 0x9fff) AM_MIRROR(0x2000) AM_ROM // ROM 13 + AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x2000) AM_ROM // ROM 9 +ADDRESS_MAP_END + + +/* + 1B11142 master sound CPU, controls DAC and speech directly + mapping: + A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00 + 0 0 0 0 0 0 0 0 0 * * * * * * * RW 6802 internal ram + x 0 0 0 x x x x 1 x x 0 x x * * Open bus (test mode writes as if there was another PIA here) + x 0 0 0 x x x x 1 x x 1 x x * * RW 6821 PIA @ 1I + x 0 0 1 0 0 x x x x x x x x x x W MC1408 DAC + x x 0 1 0 1 x x x x x x x x x x W Command to slave melody cpu + x x 0 1 1 0 x x x x x x x x x x R Command read latch from z80 + x x 0 1 1 1 x x x x x x x x x x Open bus + % % 1 0 * * * * * * * * * * * * R /CS1A: Enable ROM 8 + % % 1 1 * * * * * * * * * * * * R /CS0A: Enable ROM 7 + note that the % bits go to pins 2 (6802 A14) and 26 (6802 A15) of the roms + monymony and jackrabt both use 2764 roms, which use pin 2 as A12 and pin 26 as N/C don't care + hence for actual chips used, the mem map is: + x * 1 0 * * * * * * * * * * * * R /CS1A: Enable ROM 8 + x * 1 1 * * * * * * * * * * * * R /CS0A: Enable ROM 7 + + 6821 PIA: + PA0-7, PB0-1, CA2 and CB1 connect to the TMS5200 + CA1 and CB2 are not connected, though the test mode assumes there's something connected to CB2 (possibly another LED like the one connected to PB4) + PB3 connects to 'ACS' which goes to the Z80 +*/ static ADDRESS_MAP_START(zac1b11142_audio_map, AS_PROGRAM, 8, zac1b11142_audio_device) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x0000, 0x007f) AM_RAM // 6802 internal RAM @@ -86,29 +138,58 @@ static ADDRESS_MAP_START(zac1b11142_audio_map, AS_PROGRAM, 8, zac1b11142_audio_d ADDRESS_MAP_END -MACHINE_CONFIG_FRAGMENT(zac1b11142_config) + +//************************************************************************** +// MACHINE FRAGMENTS +//************************************************************************** + +MACHINE_CONFIG_FRAGMENT(zac1b111xx_base_config) MCFG_CPU_ADD("melodycpu", M6802, XTAL_3_579545MHz) // verified on pcb - MCFG_CPU_PROGRAM_MAP(zac1b11142_melody_map) + MCFG_CPU_PROGRAM_MAP(zac1b111xx_melody_base_map) MCFG_DEVICE_ADD("timebase", CLOCK, XTAL_3_579545MHz/4096/2) // CPU clock divided using 4040 and half of 74LS74 - MCFG_CLOCK_SIGNAL_HANDLER(DEVWRITELINE("pia_4i", pia6821_device, cb1_w)) + MCFG_CLOCK_SIGNAL_HANDLER(DEVWRITELINE("melodypia", pia6821_device, cb1_w)) - MCFG_DEVICE_ADD("pia_4i", PIA6821, 0) - MCFG_PIA_READPA_HANDLER(READ8(zac1b11142_audio_device, pia_4i_porta_r)) - MCFG_PIA_WRITEPA_HANDLER(WRITE8(zac1b11142_audio_device, pia_4i_porta_w)) - MCFG_PIA_WRITEPB_HANDLER(WRITE8(zac1b11142_audio_device, pia_4i_portb_w)) + MCFG_DEVICE_ADD("melodypia", PIA6821, 0) + MCFG_PIA_READPA_HANDLER(READ8(zac1b111xx_melody_base, melodypia_porta_r)) + MCFG_PIA_WRITEPA_HANDLER(WRITE8(zac1b111xx_melody_base, melodypia_porta_w)) + MCFG_PIA_WRITEPB_HANDLER(WRITE8(zac1b111xx_melody_base, melodypia_portb_w)) MCFG_PIA_IRQA_HANDLER(DEVWRITELINE("melodycpu", m6802_cpu_device, nmi_line)) MCFG_PIA_IRQB_HANDLER(DEVWRITELINE("melodycpu", m6802_cpu_device, irq_line)) - MCFG_SOUND_ADD("ay_4g", AY8910, XTAL_3_579545MHz/2) // CPU clock divided using 4040 - MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(zac1b11142_audio_device, ay_4g_porta_w)) - MCFG_AY8910_PORT_B_READ_CB(READ8(zac1b11142_audio_device, ay_4g_portb_r)) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.15) + MCFG_SOUND_ADD("melodypsg1", AY8910, XTAL_3_579545MHz/2) // CPU clock divided using 4040 + MCFG_AY8910_PORT_B_READ_CB(READ8(zac1b111xx_melody_base, melodypsg1_portb_r)) - MCFG_SOUND_ADD("ay_4h", AY8910, XTAL_3_579545MHz/2) // CPU clock divided using 4040 + MCFG_SOUND_ADD("melodypsg2", AY8910, XTAL_3_579545MHz/2) // CPU clock divided using 4040 +MACHINE_CONFIG_END + + +MACHINE_CONFIG_DERIVED(zac1b11107_config, zac1b111xx_base_config) + MCFG_CPU_MODIFY("melodycpu") + MCFG_CPU_PROGRAM_MAP(zac1b11107_melody_map) + + MCFG_DEVICE_MODIFY("melodypsg1") + MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(zac1b11107_audio_device, melodypsg1_porta_w)) + MCFG_MIXER_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.5, 0) + + MCFG_DEVICE_MODIFY("melodypsg2") + MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(zac1b11107_audio_device, melodypsg2_porta_w)) + MCFG_MIXER_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.5, 0) +MACHINE_CONFIG_END + + +MACHINE_CONFIG_DERIVED(zac1b11142_config, zac1b111xx_base_config) + MCFG_CPU_MODIFY("melodycpu") + MCFG_CPU_PROGRAM_MAP(zac1b11142_melody_map) + + MCFG_DEVICE_MODIFY("melodypsg1") + MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(zac1b11142_audio_device, ay_4g_porta_w)) + MCFG_MIXER_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.15, 0) + + MCFG_DEVICE_MODIFY("melodypsg2") MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(zac1b11142_audio_device, ay_4h_porta_w)) MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(zac1b11142_audio_device, ay_4h_portb_w)) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.15) + MCFG_MIXER_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.15, 0) MCFG_CPU_ADD("audiocpu", M6802, XTAL_3_579545MHz) // verified on pcb MCFG_CPU_PROGRAM_MAP(zac1b11142_audio_map) @@ -120,17 +201,22 @@ MACHINE_CONFIG_FRAGMENT(zac1b11142_config) MCFG_PIA_WRITEPB_HANDLER(WRITE8(zac1b11142_audio_device, pia_1i_portb_w)) MCFG_DAC_ADD("dac_1f") - MCFG_SOUND_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.80) + MCFG_MIXER_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.80, 0) // There is no xtal, the clock is obtained from a RC oscillator as shown in the TMS5220 datasheet (R=100kOhm C=22pF) // 162kHz measured on pin 3 20 minutes after power on, clock would then be 162.3*4=649.2kHz MCFG_SOUND_ADD("speech", TMS5200, 649200) // ROMCLK pin measured at 162.3Khz, OSC is exactly *4 of that) MCFG_TMS52XX_IRQ_HANDLER(DEVWRITELINE("pia_1i", pia6821_device, cb1_w)) MCFG_TMS52XX_READYQ_HANDLER(DEVWRITELINE("pia_1i", pia6821_device, ca2_w)) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.80) + MCFG_MIXER_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.80, 0) MACHINE_CONFIG_END + +//************************************************************************** +// I/O PORT DEFINITIONS +//************************************************************************** + INPUT_PORTS_START(zac1b11142_ioports) PORT_START("1B11142") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -140,24 +226,151 @@ INPUT_PORTS_START(zac1b11142_ioports) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("P1") + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("P1") // test button? generates NMI on master CPU INPUT_PORTS_END -zac1b11142_audio_device::zac1b11142_audio_device(machine_config const &mconfig, char const *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, ZACCARIA_1B11142, "Zaccaria 1B11142 Sound Board", tag, owner, clock, "zac1b11142", __FILE__) + +//************************************************************************** +// BASE MELODY GENERATOR DEVICE CLASS +//************************************************************************** + +zac1b111xx_melody_base::zac1b111xx_melody_base( + machine_config const &mconfig, + device_type devtype, + char const *name, + char const *tag, + device_t *owner, + UINT32 clock, + char const *shortname, + char const *source) + : device_t(mconfig, devtype, name, tag, owner, clock, shortname, source) , device_mixer_interface(mconfig, *this, 1) - , m_acs_cb(*this) , m_melodycpu(*this, "melodycpu") - , m_pia_4i(*this, "pia_4i") - , m_ay_4g(*this, "ay_4g") - , m_ay_4h(*this, "ay_4h") + , m_melodypia(*this, "melodypia") + , m_melodypsg1(*this, "melodypsg1") + , m_melodypsg2(*this, "melodypsg2") + , m_melody_command(0) +{ +} + +READ8_MEMBER(zac1b111xx_melody_base::melodypia_porta_r) +{ + UINT8 const control = m_melodypia->b_output(); + UINT8 data = 0xff; + + if (0x01 == (control & 0x03)) + data &= m_melodypsg1->data_r(space, 0); + + if (0x04 == (control & 0x0c)) + data &= m_melodypsg2->data_r(space, 0); + + return data; +} + +WRITE8_MEMBER(zac1b111xx_melody_base::melodypia_porta_w) +{ + UINT8 const control = m_melodypia->b_output(); + + if (control & 0x02) + m_melodypsg1->data_address_w(space, (control >> 0) & 0x01, data); + + if (control & 0x08) + m_melodypsg2->data_address_w(space, (control >> 2) & 0x01, data); +} + +WRITE8_MEMBER(zac1b111xx_melody_base::melodypia_portb_w) +{ + if (data & 0x02) + m_melodypsg1->data_address_w(space, (data >> 0) & 0x01, m_melodypia->a_output()); + + if (data & 0x08) + m_melodypsg2->data_address_w(space, (data >> 2) & 0x01, m_melodypia->a_output()); +} + +READ8_MEMBER(zac1b111xx_melody_base::melodypsg1_portb_r) +{ + return m_melody_command; +} + +void zac1b111xx_melody_base::device_start() +{ + save_item(NAME(m_melody_command)); +} + +void zac1b111xx_melody_base::device_reset() +{ + m_melody_command = 0; +} + + + +//************************************************************************** +// 1B11107-SPECIFIC IMPLEMENTATION +//************************************************************************** + +zac1b11107_audio_device::zac1b11107_audio_device(machine_config const &mconfig, char const *tag, device_t *owner, UINT32 clock) + : zac1b111xx_melody_base(mconfig, ZACCARIA_1B11107, "Zaccaria 1B11107 Sound Board", tag, owner, clock, "zac1b11107", __FILE__) +{ +} + +WRITE8_MEMBER(zac1b11107_audio_device::sound_w) +{ + // the sound program masks out the three most significant bits + // assume the top two bits are not connected and read high from the internal pull-ups + m_melodypia->ca1_w((data >> 5) & 0x01); + m_melody_command = data | 0xc0; +} + +WRITE_LINE_MEMBER(zac1b11107_audio_device::reset_w) +{ + // TODO: there is a pulse-stretching network attached that should be simulated + m_melodycpu->set_input_line(INPUT_LINE_RESET, state); + // TODO: holds the reset line of m_melodypia - can't implement this in MAME at this time + // TODO: holds the reset line of m_melodypsg1 - can't implement this in MAME at this time + // TODO: holds the reset line of m_melodypsg2 - can't implement this in MAME at this time +} + +WRITE8_MEMBER(zac1b11107_audio_device::melodypsg1_porta_w) +{ + // similar to 1B11142 + // TODO: move this to netlist audio where it belongs, along with the rest of the filtering + static double const table[8] = { + RES_K(8.2), + RES_R(820), + RES_K(3.3), + RES_R(150), + RES_K(5.6), + RES_R(390), + RES_K(1.5), + RES_R(47) }; + m_melodypsg2->set_volume(1, 150 * RES_VOLTAGE_DIVIDER(RES_K(4.7), table[data & 0x07])); +} + +WRITE8_MEMBER(zac1b11107_audio_device::melodypsg2_porta_w) +{ + // TODO: assume LEVELT is controlled here as is the case for 1B11142? +} + +machine_config_constructor zac1b11107_audio_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME(zac1b11107_config); +} + + + +//************************************************************************** +// 1B11142-SPECIFIC IMPLEMENTATION +//************************************************************************** + +zac1b11142_audio_device::zac1b11142_audio_device(machine_config const &mconfig, char const *tag, device_t *owner, UINT32 clock) + : zac1b111xx_melody_base(mconfig, ZACCARIA_1B11142, "Zaccaria 1B11142 Sound Board", tag, owner, clock, "zac1b11142", __FILE__) + , m_acs_cb(*this) , m_audiocpu(*this, "audiocpu") , m_pia_1i(*this, "pia_1i") , m_speech(*this, "speech") , m_inputs(*this, "1B11142") , m_host_command(0) - , m_melody_command(0) { } @@ -176,48 +389,14 @@ WRITE_LINE_MEMBER(zac1b11142_audio_device::ressound_w) { // TODO: there is a pulse-stretching network attached that should be simulated m_melodycpu->set_input_line(INPUT_LINE_RESET, state); - // TODO: holds the reset line of m_pia_4i - can't implement this in MAME at this time - // TODO: holds the reset line of m_ay_4g - can't implement this in MAME at this time - // TODO: holds the reset line of m_ay_4h - can't implement this in MAME at this time + // TODO: holds the reset line of m_melodypia - can't implement this in MAME at this time + // TODO: holds the reset line of m_melodypsg1 - can't implement this in MAME at this time + // TODO: holds the reset line of m_melodypsg2 - can't implement this in MAME at this time m_audiocpu->set_input_line(INPUT_LINE_RESET, state); // TODO: holds the reset line of m_pia_1i - can't implement this in MAME at this time // TODO: does some funky stuff with the VDD and VSS lines on the speech chip } -READ8_MEMBER(zac1b11142_audio_device::pia_4i_porta_r) -{ - UINT8 const control = m_pia_4i->b_output(); - UINT8 data = 0xff; - - if (0x01 == (control & 0x03)) - data &= m_ay_4g->data_r(space, 0); - - if (0x04 == (control & 0x0c)) - data &= m_ay_4h->data_r(space, 0); - - return data; -} - -WRITE8_MEMBER(zac1b11142_audio_device::pia_4i_porta_w) -{ - UINT8 const control = m_pia_4i->b_output(); - - if (control & 0x02) - m_ay_4g->data_address_w(space, (control >> 0) & 0x01, data); - - if (control & 0x08) - m_ay_4h->data_address_w(space, (control >> 2) & 0x01, data); -} - -WRITE8_MEMBER(zac1b11142_audio_device::pia_4i_portb_w) -{ - if (data & 0x02) - m_ay_4g->data_address_w(space, (data >> 0) & 0x01, m_pia_4i->a_output()); - - if (data & 0x08) - m_ay_4h->data_address_w(space, (data >> 2) & 0x01, m_pia_4i->a_output()); -} - WRITE8_MEMBER(zac1b11142_audio_device::ay_4g_porta_w) { // TODO: (data & 0x07) controls tromba mix volume @@ -225,11 +404,6 @@ WRITE8_MEMBER(zac1b11142_audio_device::ay_4g_porta_w) // TODO: (data & 0x10) controls rullante gate } -READ8_MEMBER(zac1b11142_audio_device::ay_4g_portb_r) -{ - return m_melody_command; -} - WRITE8_MEMBER(zac1b11142_audio_device::ay_4h_porta_w) { // TODO: data & 0x01 controls LEVEL @@ -248,8 +422,8 @@ READ8_MEMBER(zac1b11142_audio_device::host_command_r) WRITE8_MEMBER(zac1b11142_audio_device::melody_command_w) { + m_melodypia->ca1_w((data >> 7) & 0x01); m_melody_command = data; - m_pia_4i->ca1_w((data >> 7) & 0x01); } WRITE8_MEMBER(zac1b11142_audio_device::pia_1i_portb_w) @@ -275,20 +449,18 @@ ioport_constructor zac1b11142_audio_device::device_input_ports() const return INPUT_PORTS_NAME(zac1b11142_ioports); } -void zac1b11142_audio_device::device_config_complete() -{ -} - void zac1b11142_audio_device::device_start() { + zac1b111xx_melody_base::device_start(); + m_acs_cb.resolve_safe(); save_item(NAME(m_host_command)); - save_item(NAME(m_melody_command)); } void zac1b11142_audio_device::device_reset() { + zac1b111xx_melody_base::device_reset(); + m_host_command = 0; - m_melody_command = 0; } diff --git a/src/mame/audio/zaccaria.h b/src/mame/audio/zaccaria.h index de796f9cf06..1414b9d2959 100644 --- a/src/mame/audio/zaccaria.h +++ b/src/mame/audio/zaccaria.h @@ -12,9 +12,22 @@ #include "sound/tms5220.h" +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +extern device_type const ZACCARIA_1B11107; extern device_type const ZACCARIA_1B11142; + +//************************************************************************** +// DEVICE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_ZACCARIA_1B11107(_tag) \ + MCFG_DEVICE_ADD(_tag, ZACCARIA_1B11107, 0) + #define MCFG_ZACCARIA_1B11142(_tag) \ MCFG_DEVICE_ADD(_tag, ZACCARIA_1B11142, 0) @@ -22,14 +35,67 @@ extern device_type const ZACCARIA_1B11142; devcb = &zac1b11142_audio_device::static_set_acs_cb(*device, DEVCB_##_devcb); -class zac1b11142_audio_device : public device_t, public device_mixer_interface + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class zac1b111xx_melody_base : public device_t, public device_mixer_interface +{ +public: + zac1b111xx_melody_base( + machine_config const &mconfig, + device_type devtype, + char const *name, + char const *tag, + device_t *owner, + UINT32 clock, + char const *shortname, + char const *source); + + DECLARE_READ8_MEMBER(melodypia_porta_r); + DECLARE_WRITE8_MEMBER(melodypia_porta_w); + DECLARE_WRITE8_MEMBER(melodypia_portb_w); + DECLARE_READ8_MEMBER(melodypsg1_portb_r); + +protected: + virtual void device_start() override; + virtual void device_reset() override; + + required_device m_melodycpu; + required_device m_melodypia; + required_device m_melodypsg1; + required_device m_melodypsg2; + + UINT8 m_melody_command; +}; + + +class zac1b11107_audio_device : public zac1b111xx_melody_base +{ +public: + zac1b11107_audio_device(machine_config const &mconfig, char const *tag, device_t *owner, UINT32 clock); + + // host interface + DECLARE_WRITE8_MEMBER(sound_w); + DECLARE_WRITE_LINE_MEMBER(reset_w); + + // PSG output handlers + DECLARE_WRITE8_MEMBER(melodypsg1_porta_w); + DECLARE_WRITE8_MEMBER(melodypsg2_porta_w); + +protected: + virtual machine_config_constructor device_mconfig_additions() const override; +}; + + +class zac1b11142_audio_device : public zac1b111xx_melody_base { public: template static devcb_base &static_set_acs_cb(device_t &device, _Object object) { return downcast(device).m_acs_cb.set_callback(object); } zac1b11142_audio_device(machine_config const &mconfig, char const *tag, device_t *owner, UINT32 clock); - ~zac1b11142_audio_device() { } // host interface DECLARE_WRITE8_MEMBER(hs_w); @@ -37,11 +103,7 @@ public: DECLARE_WRITE_LINE_MEMBER(ressound_w); // melody section handlers - DECLARE_READ8_MEMBER(pia_4i_porta_r); - DECLARE_WRITE8_MEMBER(pia_4i_porta_w); - DECLARE_WRITE8_MEMBER(pia_4i_portb_w); DECLARE_WRITE8_MEMBER(ay_4g_porta_w); - DECLARE_READ8_MEMBER(ay_4g_portb_r); DECLARE_WRITE8_MEMBER(ay_4h_porta_w); DECLARE_WRITE8_MEMBER(ay_4h_portb_w); @@ -56,17 +118,11 @@ public: protected: virtual machine_config_constructor device_mconfig_additions() const override; virtual ioport_constructor device_input_ports() const override; - virtual void device_config_complete() override; virtual void device_start() override; virtual void device_reset() override; devcb_write_line m_acs_cb; - required_device m_melodycpu; - required_device m_pia_4i; - required_device m_ay_4g; - required_device m_ay_4h; - required_device m_audiocpu; required_device m_pia_1i; required_device m_speech; @@ -74,7 +130,6 @@ protected: required_ioport m_inputs; UINT8 m_host_command; - UINT8 m_melody_command; }; #endif // __AUDIO_ZACCARIA_H__ \ No newline at end of file diff --git a/src/mame/drivers/laserbat.cpp b/src/mame/drivers/laserbat.cpp index 60aeeef360b..3f3342c3ed0 100644 --- a/src/mame/drivers/laserbat.cpp +++ b/src/mame/drivers/laserbat.cpp @@ -197,14 +197,6 @@ static ADDRESS_MAP_START( laserbat_io_map, AS_IO, 8, laserbat_state_base ) ADDRESS_MAP_END -static ADDRESS_MAP_START( catnmous_sound_map, AS_PROGRAM, 8, catnmous_state ) - AM_RANGE(0x0000, 0x007f) AM_RAM - AM_RANGE(0x500c, 0x500f) AM_DEVREADWRITE("pia", pia6821_device, read, write) - AM_RANGE(0xc000, 0xcfff) AM_ROM - AM_RANGE(0xe000, 0xffff) AM_ROM -ADDRESS_MAP_END - - static INPUT_PORTS_START( laserbat_base ) PORT_START("ROW0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) @@ -545,27 +537,9 @@ static MACHINE_CONFIG_DERIVED_CLASS( catnmous, laserbat_base, catnmous_state ) MCFG_PALETTE_INIT_OWNER(catnmous_state, catnmous) // sound board devices - MCFG_CPU_ADD("audiocpu", M6802, XTAL_3_579545MHz) - MCFG_CPU_PROGRAM_MAP(catnmous_sound_map) - - MCFG_DEVICE_ADD("timebase", CLOCK, XTAL_3_579545MHz/4096/2) // CPU clock divided with 4040 and half of 7474 - MCFG_CLOCK_SIGNAL_HANDLER(DEVWRITELINE("pia", pia6821_device, cb1_w)) - - MCFG_DEVICE_ADD("pia", PIA6821, 0) - MCFG_PIA_READPA_HANDLER(READ8(catnmous_state, pia_porta_r)) - MCFG_PIA_WRITEPA_HANDLER(WRITE8(catnmous_state, pia_porta_w)) - MCFG_PIA_WRITEPB_HANDLER(WRITE8(catnmous_state, pia_portb_w)) - MCFG_PIA_IRQA_HANDLER(DEVWRITELINE("audiocpu", m6802_cpu_device, nmi_line)) - MCFG_PIA_IRQB_HANDLER(DEVWRITELINE("audiocpu", m6802_cpu_device, irq_line)) - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("psg1", AY8910, XTAL_3_579545MHz/2) // CPU clock divided with 4040 - MCFG_AY8910_PORT_B_READ_CB(READ8(catnmous_state, psg1_portb_r)) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - - MCFG_SOUND_ADD("psg2", AY8910, XTAL_3_579545MHz/2) // CPU clock divided with 4040 - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) + MCFG_ZACCARIA_1B11107("audiopcb") + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MACHINE_CONFIG_END @@ -705,7 +679,7 @@ ROM_START( catnmous ) ROM_REGION( 0x0100, "gfxmix", 0 ) ROM_LOAD( "82s100.13m", 0x0000, 0x00f5, CRC(6b724cdb) SHA1(8a0ca3b171b103661a3b2fffbca3d7162089e243) ) - ROM_REGION( 0x10000, "audiocpu", 0 ) + ROM_REGION( 0x10000, "audiopcb:melodycpu", 0 ) ROM_LOAD( "sound01.1f", 0xc000, 0x1000, CRC(473c44de) SHA1(ff08b02d45a2c23cabb5db716aa203225a931424) ) ROM_LOAD( "sound01.1d", 0xe000, 0x1000, CRC(f65cb9d0) SHA1(a2fe7563c6da055bf6aa20797b2d9fa184f0133c) ) ROM_LOAD( "sound01.1e", 0xf000, 0x1000, CRC(1bd90c93) SHA1(20fd2b765a42e25cf7f716e6631b8c567785a866) ) @@ -747,7 +721,7 @@ ROM_START( catnmousa ) // copied from parent set to give working graphics, need dump to confirm ROM_LOAD( "catnmousa_82s100.13m", 0x0000, 0x00f5, CRC(6b724cdb) SHA1(8a0ca3b171b103661a3b2fffbca3d7162089e243) BAD_DUMP ) - ROM_REGION( 0x10000, "audiocpu", 0 ) + ROM_REGION( 0x10000, "audiopcb:melodycpu", 0 ) ROM_LOAD( "snd.1f", 0xc000, 0x1000, CRC(473c44de) SHA1(ff08b02d45a2c23cabb5db716aa203225a931424) ) ROM_LOAD( "snd.1d", 0xe000, 0x1000, CRC(f65cb9d0) SHA1(a2fe7563c6da055bf6aa20797b2d9fa184f0133c) ) ROM_LOAD( "snd.1e", 0xf000, 0x1000, CRC(1bd90c93) SHA1(20fd2b765a42e25cf7f716e6631b8c567785a866) ) diff --git a/src/mame/includes/laserbat.h b/src/mame/includes/laserbat.h index a07cdd97a87..e3b130a109d 100644 --- a/src/mame/includes/laserbat.h +++ b/src/mame/includes/laserbat.h @@ -6,6 +6,8 @@ *************************************************************************/ +#include "audio/zaccaria.h" + #include "machine/6821pia.h" #include "machine/pla.h" #include "machine/s2636.h" @@ -185,10 +187,7 @@ class catnmous_state : public laserbat_state_base public: catnmous_state(const machine_config &mconfig, device_type type, const char *tag) : laserbat_state_base(mconfig, type, tag) - , m_audiocpu(*this, "audiocpu") - , m_pia(*this, "pia") - , m_psg1(*this, "psg1") - , m_psg2(*this, "psg2") + , m_audiopcb(*this, "audiopcb") { } @@ -199,20 +198,6 @@ public: virtual DECLARE_WRITE8_MEMBER(csound1_w) override; virtual DECLARE_WRITE8_MEMBER(csound2_w) override; - // PIA handlers - DECLARE_READ8_MEMBER(pia_porta_r); - DECLARE_WRITE8_MEMBER(pia_porta_w); - DECLARE_WRITE8_MEMBER(pia_portb_w); - - // PSG handlers - DECLARE_WRITE8_MEMBER(psg1_porta_w); - DECLARE_READ8_MEMBER(psg1_portb_r); - protected: - - // sound board devices - required_device m_audiocpu; - required_device m_pia; - required_device m_psg1; - required_device m_psg2; + required_device m_audiopcb; };